Commit 940fecac authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Implementing fast movement adaption for combined model

parent 50b07a15
......@@ -18,12 +18,12 @@ namespace ITAPropagationPathSim
namespace Diffraction
{
bool ITA_PROPAGATION_PATH_SIM_API ConstructAperturePoints( shared_ptr< const CEmitter > pEmitter, shared_ptr< const CSensor > pSensor, const int iNumberIterations, const vector< CPropagationShapeShared > pPropagationListsIn, vector< CPropagationShapeShared >& pPropagationListsOut, ITABase::IProgressHandler* pProgressHandler = nullptr );
ITA_PROPAGATION_PATH_SIM_API bool ConstructAperturePoints( shared_ptr< const CEmitter > pEmitter, shared_ptr< const CSensor > pSensor, const int iNumberIterations, const vector< CPropagationShapeShared > pPropagationListsIn, vector< CPropagationShapeShared >& pPropagationListsOut, ITABase::IProgressHandler* pProgressHandler = nullptr );
//!< Exclude propagation paths with an accumulated diffraction angle that is bigger than the angle threshold.
bool ITA_PROPAGATION_PATH_SIM_API AccumulatedAngleCulling( const float fAngleThreshold, shared_ptr< const CEmitter > pEmitter, const vector< CPropagationShapeShared > pPropagationTreeIn, vector< CPropagationShapeShared >& pPropagationTreeOut );
ITA_PROPAGATION_PATH_SIM_API bool AccumulatedAngleCulling( const float fAngleThreshold, shared_ptr< const CEmitter > pEmitter, const vector< CPropagationShapeShared > pPropagationTreeIn, vector< CPropagationShapeShared >& pPropagationTreeOut );
bool ITA_PROPAGATION_PATH_SIM_API AccumulatedAngleCulling( const float fAngleThreshold, shared_ptr< const CEmitter > pEmitter, shared_ptr<const CSensor> pSensor, const vector<CPropagationShapeShared> pPropagationListsIn, vector< CPropagationShapeShared >& pPropagationListsOut );
ITA_PROPAGATION_PATH_SIM_API bool AccumulatedAngleCulling( const float fAngleThreshold, shared_ptr< const CEmitter > pEmitter, shared_ptr<const CSensor> pSensor, const vector<CPropagationShapeShared> pPropagationListsIn, vector< CPropagationShapeShared >& pPropagationListsOut );
}
}
......
......@@ -19,14 +19,11 @@ namespace ITAPropagationPathSim
namespace ImageConstruction
{
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageSources(shared_ptr<const CEmitter> pEmitter, vector<CPropagationShapeShared>& vpPropagationTree);
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageReceivers(shared_ptr<const CSensor> pSensor, vector<CPropagationShapeShared>& vpPropagationLists, CShapesMap vpVisibilityMap, const int iMaxReflectionOrder);
ITA_PROPAGATION_PATH_SIM_API bool ConstructImages( const VistaVector3D& v3Pos, vector< CPropagationShapeShared >& vpPropagationTree );
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageApertures(const vector<CPropagationShapeShared> vpPropagationListsIn, vector<CPropagationShapeShared>& vpPropagationListsOut);
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageEdges(vector<CPropagationShapeShared>& vpPropagationTree);
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageApertures( const vector< CPropagationShapeShared > vpPropagationListsIn, vector< CPropagationShapeShared >& vpPropagationListsOut );
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageEdges( vector< CPropagationShapeShared >& vpPropagationTree );
}
}
}
......
......@@ -32,6 +32,7 @@ namespace ITAPropagationPathSim
bool bFilterIntersectedPaths;
int iNumberIterationApexCalculation;
float fIntersectionTestResolution;
bool bReciprocalPropagationSimulation;
inline CSimulationConfig()
{
......@@ -48,6 +49,7 @@ namespace ITAPropagationPathSim
bFilterIntersectedPaths = false;
iNumberIterationApexCalculation = 5;
fIntersectionTestResolution = 0.001f;
bReciprocalPropagationSimulation = true;
};
};
......@@ -71,7 +73,7 @@ namespace ITAPropagationPathSim
iMaxDiffractionOrder = 2;
iMaxReflectionOrder = 2;
iMaxCombinedOrder = 4;
fDynamicRange = -1.0f; // disabled
fDynamicRange = 124;
fReflectionPenalty = -10.0f * log10( 0.8f ); // for conservative sim, set to 0
fDiffractionPenalty = 2.5f; // for conservative sim, set to 0
fAccumulatedAngleThreshold = -1.0f; // disabled
......@@ -87,17 +89,20 @@ namespace ITAPropagationPathSim
void InitializePathEnvironment( shared_ptr< const Halfedge::CMeshModelList > pMeshModelList );
void ApplyEmitter( shared_ptr< CEmitter > pEmitter );
void ApplySensor( shared_ptr< CSensor > pSensor );
//! Set the source and target entities for the path finder
void SetEntities( shared_ptr< CEmitter > pEmitter, shared_ptr< CSensor > pSensor );
void UpdateEmitter( shared_ptr< CEmitter > pEmitter );
void UpdateSensor( shared_ptr< CSensor > pSensor );
void ConstructPropagationPathsWithStopWatch( CPropagationPathList& oPaths );
//! Constructs the propagation paths (requires entitites)
void ConstructPropagationPaths( CPropagationPathList& oPaths );
size_t GetNumberPropagationPathCandidates();
//Just for testing, the ApplyEmitter is divided into two parts
void ApplyEmitterForTestingOnlyTreeAndImageEdges( shared_ptr<CEmitter> pEmitter );
void ApplyEmitterForTestingOnlyImageSources();
protected:
void ApplyEmitter( shared_ptr< CEmitter > pEmitter );
void ApplySensor( shared_ptr< CSensor > pSensor );
private:
......@@ -114,8 +119,9 @@ namespace ITAPropagationPathSim
CShapesMap m_mvpShapeVisibilityMap; //!< Map of which shape can illuminate which ones
vector<CPropagationShapeShared> m_vpPropagationTree; //!< Vector of all propagation shapes (as well as its children) visible to the emitter
vector<CPropagationShapeShared> m_vpPropagationCandidates; //!< Vector of all propagation shape visible to the emitter with each one pointing to up to one child with the last one visible to the sensor
shared_ptr<CEmitter> m_pEmitter; //!< Const pointer to emitter
shared_ptr<CSensor> m_pSensor; //!< Const pointer to sensor
shared_ptr< CEmitter > m_pEmitter; //!< Const pointer to emitter
shared_ptr< CSensor > m_pSensor; //!< Const pointer to sensor
float GetMaxPropagationRange() const;
bool GetMaxPropagationRangeValid() const;
......@@ -124,10 +130,10 @@ namespace ITAPropagationPathSim
bool CanPointIlluminateFace( const VistaVector3D & v3Point, const string & sMeshModelName, CITAMesh::FaceHandle hFace );
bool CanPointIlluminateEdge( const VistaVector3D & v3Point, CPropagationEdgeShared & pPropagationEdge, const bool& bTestIntersection = false );
bool IsPathVisible( const VistaVector3D & v3StartPoint, const VistaVector3D & v3EndPoint );
void CanEdgeIlluminateFace( bool & bCanEdgeIlluminateFaceOut, ITAPropagationPathSim::CombinedModel::CPropagationFaceShared & pPropagationFace, ITAPropagationPathSim::CombinedModel::CPropagationEdgeShared & pPropagationEdge );
void CanFaceIlluminateEdge( bool & bCanFaceIlluminateEdgeOut, CPropagationFaceShared & pPropagationFace, CPropagationEdgeShared & pPropagationEdge );
void CanFaceIlluminateFace( bool & bCanFaceIlluminateFaceOut, CPropagationFaceShared & pPropagationFaceStart, CPropagationFaceShared & pPropagationFaceEnd );
void CanEdgeIlluminateEdge( bool & bCanEdgeIlluminateEdgeOut, CPropagationEdgeShared & pPropagationEdgeStart, CPropagationEdgeShared & pPropagationEdgeEnd, const bool& bTestIntersection = false );
void CanEdgeIlluminateFace( bool& bCanEdgeIlluminateFaceOut, ITAPropagationPathSim::CombinedModel::CPropagationFaceShared & pPropagationFace, ITAPropagationPathSim::CombinedModel::CPropagationEdgeShared & pPropagationEdge );
void CanFaceIlluminateEdge( bool& bCanFaceIlluminateEdgeOut, CPropagationFaceShared& pPropagationFace, CPropagationEdgeShared & pPropagationEdge );
void CanFaceIlluminateFace( bool& bCanFaceIlluminateFaceOut, CPropagationFaceShared& pPropagationFaceStart, CPropagationFaceShared & pPropagationFaceEnd );
void CanEdgeIlluminateEdge( bool& bCanEdgeIlluminateEdgeOut, CPropagationEdgeShared& pPropagationEdgeStart, CPropagationEdgeShared & pPropagationEdgeEnd, const bool& bTestIntersection = false );
void ConstructPropagationShapes();
// Create the propagation tree
......
......@@ -25,7 +25,7 @@ namespace ITAPropagationPathSim
typedef shared_ptr<CPropagationFace> CPropagationFaceShared;
typedef shared_ptr<CPropagationEdge> CPropagationEdgeShared;
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
typedef map <size_t, vector<CPropagationShapeShared>> CShapesMap;
typedef map< size_t, vector< CPropagationShapeShared > > CShapesMap;
typedef string MeshModelHandle;
typedef pair < MeshModelHandle, CITAMesh::FaceHandle> PropagationFaceHandle;
......
......@@ -83,7 +83,7 @@ bool RecursiveAngleCulling( const ITAPropagationPathSim::CombinedModel::CPropaga
return true;
}
bool ITAPropagationPathSim::CombinedModel::Diffraction::ConstructAperturePoints( shared_ptr< const CEmitter > pEmitter, shared_ptr< const CSensor > pSensor, const int iNumberIterations, const vector< CPropagationShapeShared> vpPropagationListsIn, vector<CPropagationShapeShared>& pPropagationListsOut, ITABase::IProgressHandler* pProgressHandler /* = nullptr */ )
bool ITAPropagationPathSim::CombinedModel::Diffraction::ConstructAperturePoints( shared_ptr< const CEmitter > pEmitter, shared_ptr< const CSensor > pSensor, const int iNumberIterations, const vector< CPropagationShapeShared > vpPropagationListsIn, vector< CPropagationShapeShared >& pPropagationListsOut, ITABase::IProgressHandler* pProgressHandler /* = nullptr */ )
{
pPropagationListsOut.clear();
......
......@@ -8,87 +8,86 @@ namespace ITAPropagationPathSim
{
namespace ImageConstruction
{
bool RecursiveConstructImageSources( CPropagationFaceShared pPropagationFace );
//Recursive construct of image sources (only visible locally)
bool RecursiveConstructImageSources(CPropagationFaceShared pPropagationFace)
bool ConstructImages( const VistaVector3D& v3Pos, vector< CPropagationShapeShared >& vpPropagationTree )
{
auto v3ParentImageSource = static_pointer_cast<CPropagationFace>(pPropagationFace->pParent.lock())->v3ImageSource;
//If the previous image source lies beyond the plane, a valid path can not be built
if (!ITAGeoUtils::IsPointInFrontOfPlane(*pPropagationFace->pPlane, *v3ParentImageSource))
return false;
//Initialize image source and set it
pPropagationFace->v3ImageSource = make_shared<VistaVector3D>();
ITAGeoUtils::MirrorPointOverPlane(*v3ParentImageSource, *pPropagationFace->pPlane, *pPropagationFace->v3ImageSource);
//Add further images
for (auto& pShapeChild : pPropagationFace->vpChildren)
for( auto& pStartShape : vpPropagationTree )
{
if (pShapeChild->iShapeType == CPropagationShape::FACE)
if( pStartShape->iShapeType == CPropagationShape::FACE )
{
auto pPropagationFaceChild = static_pointer_cast<CPropagationFace>(pShapeChild);
auto pStartFace = static_pointer_cast< CPropagationFace >( pStartShape );
if (RecursiveConstructImageSources(pPropagationFaceChild))
pPropagationFaceChild->pHasValidImageSource = make_shared<bool>(true);
else
pShapeChild = nullptr;
// Initialize image point and set it
pStartFace->v3ImageSource = make_shared< VistaVector3D >();
ITAGeoUtils::MirrorPointOverPlane( v3Pos, *pStartFace->pPlane, *pStartFace->v3ImageSource );
// First image point is valid
pStartFace->pHasValidImageSource = make_shared< bool >( true );
// Add further images
for( auto& pShapeChild : pStartFace->vpChildren )
{
if( pShapeChild->iShapeType == CPropagationShape::FACE )
{
pStartFace = static_pointer_cast< CPropagationFace >( pShapeChild );
if( RecursiveConstructImageSources( pStartFace ) )
pStartFace->pHasValidImageSource = make_shared< bool >( true );
else
pShapeChild = nullptr;
}
}
}
}
return true;
}
bool ConstructImageSources(shared_ptr<const ITAGeo::CEmitter> pEmitter, vector<CPropagationShapeShared>& vpPropagationTree)
// Recursive construct of image sources (only visible locally)
bool RecursiveConstructImageSources( CPropagationFaceShared pPropagationFace )
{
for (auto& pStartShape : vpPropagationTree)
{
if (pStartShape->iShapeType == CPropagationShape::FACE)
{
auto pStartFace = static_pointer_cast<CPropagationFace>(pStartShape);
//Initialize image source and set it
pStartFace->v3ImageSource = make_shared<VistaVector3D>();
ITAGeoUtils::MirrorPointOverPlane(pEmitter->v3InteractionPoint, *pStartFace->pPlane, *pStartFace->v3ImageSource);
//First image source is valid
pStartFace->pHasValidImageSource = make_shared<bool>(true);
auto v3ParentImageSource = static_pointer_cast< CPropagationFace >( pPropagationFace->pParent.lock() )->v3ImageSource;
//Add further images
for (auto& pShapeChild : pStartFace->vpChildren)
{
if (pShapeChild->iShapeType == CPropagationShape::FACE)
{
pStartFace = static_pointer_cast<CPropagationFace>(pShapeChild);
if (RecursiveConstructImageSources(pStartFace))
pStartFace->pHasValidImageSource = make_shared<bool>(true);
else
pShapeChild = nullptr;
//If the previous image source lies beyond the plane, a valid path can not be built
if( !ITAGeoUtils::IsPointInFrontOfPlane( *pPropagationFace->pPlane, *v3ParentImageSource ) )
return false;
//Initialize image source and set it
pPropagationFace->v3ImageSource = make_shared<VistaVector3D>();
ITAGeoUtils::MirrorPointOverPlane( *v3ParentImageSource, *pPropagationFace->pPlane, *pPropagationFace->v3ImageSource );
}
}
//Add further images
for( auto& pShapeChild : pPropagationFace->vpChildren )
{
if( pShapeChild->iShapeType == CPropagationShape::FACE )
{
auto pPropagationFaceChild = static_pointer_cast< CPropagationFace >( pShapeChild );
if( RecursiveConstructImageSources( pPropagationFaceChild ) )
pPropagationFaceChild->pHasValidImageSource = make_shared<bool>( true );
else
pShapeChild = nullptr;
}
}
return true;
}
bool ConstructImageSources(const VistaVector3D& v3SourceIn, vector<CPropagationFaceShared>& pFacesOut)
bool ConstructImages( const VistaVector3D& v3SourceIn, vector<CPropagationFaceShared>& pFacesOut )
{
VistaVector3D v3ImageSource = v3SourceIn;
for (auto& pFace : pFacesOut)
for( auto& pFace : pFacesOut )
{
if (ITAGeoUtils::IsPointInFrontOfPlane(*pFace->pPlane, v3ImageSource))
if( ITAGeoUtils::IsPointInFrontOfPlane( *pFace->pPlane, v3ImageSource ) )
{
ITAGeoUtils::MirrorPointOverPlane(v3ImageSource, *pFace->pPlane, v3ImageSource);
pFace->v3ImageSource = make_shared <VistaVector3D>(v3ImageSource);
pFace->pHasValidImageSource = make_shared<bool>(true);
ITAGeoUtils::MirrorPointOverPlane( v3ImageSource, *pFace->pPlane, v3ImageSource );
pFace->v3ImageSource = make_shared <VistaVector3D>( v3ImageSource );
pFace->pHasValidImageSource = make_shared<bool>( true );
}
else //Image source is not illuminable and thus, the whole path is invalid
{
pFace->pHasValidImageSource = make_shared<bool>(false);
pFace->pHasValidImageSource = make_shared<bool>( false );
return false;
}
}
......@@ -96,26 +95,25 @@ namespace ITAPropagationPathSim
//No invalid image source found
return true;
}
bool ConstructImageApertures(const vector<CPropagationShapeShared> vpPropagationListsIn, vector<CPropagationShapeShared>& vpPropagationListsOut)
bool ConstructImageApertures( const vector< CPropagationShapeShared > vpPropagationListsIn, vector< CPropagationShapeShared >& vpPropagationListsOut )
{
vpPropagationListsOut.clear();
for (auto& pStartShape : vpPropagationListsIn)
for( auto& pStartShape : vpPropagationListsIn )
{
bool bValidImageApertures = true;
CPropagationShapeShared pShape = pStartShape;//Start point
while (pShape != nullptr)
while( pShape != nullptr )
{
while (pShape != nullptr && pShape->iShapeType != CPropagationShape::EDGE)
while( pShape != nullptr && pShape->iShapeType != CPropagationShape::EDGE )
{
pShape = pShape->pChild;
}
//No edge found, go to next start shape
if (pShape == nullptr)
if( pShape == nullptr )
continue;
//Set secondary source to the aperture point of the edge
......@@ -126,14 +124,14 @@ namespace ITAPropagationPathSim
//Vector of faces between two edges
vector<CPropagationFaceShared> vpFaces;
while (pShape != nullptr && pShape->iShapeType == CPropagationShape::FACE)
while( pShape != nullptr && pShape->iShapeType == CPropagationShape::FACE )
{
vpFaces.push_back(static_pointer_cast<CPropagationFace>(pShape));
vpFaces.push_back( static_pointer_cast< CPropagationFace >( pShape ) );
pShape = pShape->pChild;
}
//Construct image sources between two edges
if (!ConstructImageSources(v3SecondarySource, vpFaces))
if( !ConstructImages( v3SecondarySource, vpFaces ) )
{
//If no valid image source could be created, ignore the propagation candidate and set its pointer to zero
bValidImageApertures = false;
......@@ -141,41 +139,38 @@ namespace ITAPropagationPathSim
}
}
if (bValidImageApertures)
vpPropagationListsOut.push_back(pStartShape);
if( bValidImageApertures )
vpPropagationListsOut.push_back( pStartShape );
}
return true;
}
bool RecursiveConstructImageEdge(shared_ptr<const CPropagationFace> pParentFace, shared_ptr<CPropagationEdge>& pPropagationEdge)
bool RecursiveConstructImageEdge( shared_ptr< const CPropagationFace > pParentFace, shared_ptr< CPropagationEdge >& pPropagationEdge )
{
//Only one image must be in front of plane
bool bValidImageEdge = ITAGeoUtils::IsPointInFrontOfPlane(*pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart);
bValidImageEdge |= ITAGeoUtils::IsPointInFrontOfPlane(*pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart);
bool bValidImageEdge = ITAGeoUtils::IsPointInFrontOfPlane( *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart );
bValidImageEdge |= ITAGeoUtils::IsPointInFrontOfPlane( *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart );
//If both images are not valid the whole image edge is invalid
if (!bValidImageEdge)
if( !bValidImageEdge )
return false;
ITAGeoUtils::MirrorPointOverPlane(*(pPropagationEdge->v3ImageEdgeReceiverStart.get()), *(pParentFace->pPlane.get()), *(pPropagationEdge->v3ImageEdgeReceiverStart.get()));
ITAGeoUtils::MirrorPointOverPlane(*(pPropagationEdge->v3ImageEdgeReceiverEnd.get()), *(pParentFace->pPlane.get()), *(pPropagationEdge->v3ImageEdgeReceiverEnd.get()));
ITAGeoUtils::MirrorPointOverPlane( *( pPropagationEdge->v3ImageEdgeReceiverStart.get() ), *( pParentFace->pPlane.get() ), *( pPropagationEdge->v3ImageEdgeReceiverStart.get() ) );
ITAGeoUtils::MirrorPointOverPlane( *( pPropagationEdge->v3ImageEdgeReceiverEnd.get() ), *( pParentFace->pPlane.get() ), *( pPropagationEdge->v3ImageEdgeReceiverEnd.get() ) );
//Recursive construction until no further faces are found
if (!pParentFace->pParent.expired() && pParentFace->pParent.lock()->iShapeType == CPropagationShape::FACE)
if( !pParentFace->pParent.expired() && pParentFace->pParent.lock()->iShapeType == CPropagationShape::FACE )
{
auto pGrandParentFace = static_pointer_cast<CPropagationFace>(pPropagationEdge->pParent.lock());
bValidImageEdge = RecursiveConstructImageEdge(pGrandParentFace, pPropagationEdge);
auto pGrandParentFace = static_pointer_cast< CPropagationFace >( pPropagationEdge->pParent.lock() );
bValidImageEdge = RecursiveConstructImageEdge( pGrandParentFace, pPropagationEdge );
}
return bValidImageEdge;
}
bool RecursiveConstructImageEdges(CPropagationShapeShared& pPropagationShape)
bool RecursiveConstructImageEdges( CPropagationShapeShared& pPropagationShape )
{
if( pPropagationShape == nullptr )
return false;
......@@ -183,39 +178,39 @@ namespace ITAPropagationPathSim
//Create image edge receiver in case of an edge and image edge source of an face followed by at least one edge
//Due to the structure of the propagation tree, image edge sources of each mirrored edge is saved in the corresponding following
//propagation faces and the image edge receiver are saved in the corresponding edge followed up by a number of faces
if (pPropagationShape->iShapeType == CPropagationShape::EDGE)
if( pPropagationShape->iShapeType == CPropagationShape::EDGE )
{
auto pPropagationEdge = static_pointer_cast<CPropagationEdge>(pPropagationShape);
auto pPropagationEdge = static_pointer_cast< CPropagationEdge >( pPropagationShape );
//Create image vertices only for edges with faces as parents
if (!pPropagationEdge->pParent.expired() && pPropagationEdge->pParent.lock()->iShapeType == CPropagationShape::FACE)
if( !pPropagationEdge->pParent.expired() && pPropagationEdge->pParent.lock()->iShapeType == CPropagationShape::FACE )
{
pPropagationEdge->v3ImageEdgeReceiverStart = make_shared<VistaVector3D>(*pPropagationEdge->v3StartVertex);
pPropagationEdge->v3ImageEdgeReceiverEnd = make_shared<VistaVector3D>(*pPropagationEdge->v3EndVertex);
pPropagationEdge->pHasValidImageEdge = make_shared<bool>(true);
pPropagationEdge->v3ImageEdgeReceiverStart = make_shared<VistaVector3D>( *pPropagationEdge->v3StartVertex );
pPropagationEdge->v3ImageEdgeReceiverEnd = make_shared<VistaVector3D>( *pPropagationEdge->v3EndVertex );
pPropagationEdge->pHasValidImageEdge = make_shared<bool>( true );
auto pParentFace = static_pointer_cast<CPropagationFace>(pPropagationEdge->pParent.lock());
while (true)
auto pParentFace = static_pointer_cast< CPropagationFace >( pPropagationEdge->pParent.lock() );
while( true )
{
//Only one image must be in front of plane
bool bValidImageEdge = ITAGeoUtils::IsPointInFrontOfPlane(*pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart);
bValidImageEdge |= ITAGeoUtils::IsPointInFrontOfPlane(*pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverEnd);
bool bValidImageEdge = ITAGeoUtils::IsPointInFrontOfPlane( *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart );
bValidImageEdge |= ITAGeoUtils::IsPointInFrontOfPlane( *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverEnd );
//If both images are not valid the whole image edge is invalid
if (!bValidImageEdge)
if( !bValidImageEdge )
{
*(pPropagationEdge->pHasValidImageEdge) = false;
*( pPropagationEdge->pHasValidImageEdge ) = false;
break;
}
ITAGeoUtils::MirrorPointOverPlane(*pPropagationEdge->v3StartVertex, *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart);
ITAGeoUtils::MirrorPointOverPlane(*pPropagationEdge->v3EndVertex, *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverEnd);
ITAGeoUtils::MirrorPointOverPlane( *pPropagationEdge->v3StartVertex, *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverStart );
ITAGeoUtils::MirrorPointOverPlane( *pPropagationEdge->v3EndVertex, *pParentFace->pPlane, *pPropagationEdge->v3ImageEdgeReceiverEnd );
if (!pParentFace->pParent.expired() && pParentFace->pParent.lock()->iShapeType == CPropagationShape::FACE)
if( !pParentFace->pParent.expired() && pParentFace->pParent.lock()->iShapeType == CPropagationShape::FACE )
{
pParentFace = static_pointer_cast<CPropagationFace>(pParentFace->pParent.lock());
pParentFace = static_pointer_cast< CPropagationFace >( pParentFace->pParent.lock() );
}
else
{
......@@ -225,38 +220,38 @@ namespace ITAPropagationPathSim
}
}
else if (pPropagationShape->iShapeType == CPropagationShape::FACE)
else if( pPropagationShape->iShapeType == CPropagationShape::FACE )
{
auto pPropagationFace = static_pointer_cast<CPropagationFace>(pPropagationShape);
auto pPropagationFace = static_pointer_cast< CPropagationFace >( pPropagationShape );
//Create image vertices only for edges with faces as parents
if (!pPropagationFace->pParent.expired())
if( !pPropagationFace->pParent.expired() )
{
if (pPropagationFace->pParent.lock()->iShapeType == CPropagationShape::FACE)
if( pPropagationFace->pParent.lock()->iShapeType == CPropagationShape::FACE )
{
auto pParentFace = static_pointer_cast<CPropagationFace>(pPropagationFace->pParent.lock());
auto pParentFace = static_pointer_cast< CPropagationFace >( pPropagationFace->pParent.lock() );
if (pParentFace->v3ImageEdgeSourceStart != nullptr)
if( pParentFace->v3ImageEdgeSourceStart != nullptr )
{
//Only one image must be in front of plane
bool bValidImageEdge = ITAGeoUtils::IsPointInFrontOfPlane(*pPropagationFace->pPlane, *pParentFace->v3ImageEdgeSourceStart);
bValidImageEdge |= ITAGeoUtils::IsPointInFrontOfPlane(*pPropagationFace->pPlane, *pParentFace->v3ImageEdgeSourceEnd);
bool bValidImageEdge = ITAGeoUtils::IsPointInFrontOfPlane( *pPropagationFace->pPlane, *pParentFace->v3ImageEdgeSourceStart );
bValidImageEdge |= ITAGeoUtils::IsPointInFrontOfPlane( *pPropagationFace->pPlane, *pParentFace->v3ImageEdgeSourceEnd );
//Set image edge source if valid
if (bValidImageEdge)
if( bValidImageEdge )
{
pPropagationFace->v3ImageEdgeSourceStart = make_shared<VistaVector3D>();
pPropagationFace->v3ImageEdgeSourceEnd = make_shared<VistaVector3D>();
ITAGeoUtils::MirrorPointOverPlane(*pParentFace->v3ImageEdgeSourceStart, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceStart);
ITAGeoUtils::MirrorPointOverPlane(*pParentFace->v3ImageEdgeSourceEnd, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceEnd);
ITAGeoUtils::MirrorPointOverPlane( *pParentFace->v3ImageEdgeSourceStart, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceStart );
ITAGeoUtils::MirrorPointOverPlane( *pParentFace->v3ImageEdgeSourceEnd, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceEnd );
}
}
}
else if (pPropagationFace->pParent.lock()->iShapeType == CPropagationShape::EDGE)
else if( pPropagationFace->pParent.lock()->iShapeType == CPropagationShape::EDGE )
{
auto pParentEdge = static_pointer_cast<CPropagationEdge>(pPropagationFace->pParent.lock());
auto pParentEdge = static_pointer_cast< CPropagationEdge >( pPropagationFace->pParent.lock() );
//Calculate image edge source.
//A PointInFrontOfPlane test is not needed, because a backfaceculling with vertices and plane is already done.
......@@ -264,36 +259,32 @@ namespace ITAPropagationPathSim
pPropagationFace->v3ImageEdgeSourceStart = make_shared<VistaVector3D>();
pPropagationFace->v3ImageEdgeSourceEnd = make_shared<VistaVector3D>();
ITAGeoUtils::MirrorPointOverPlane(*pParentEdge->v3StartVertex, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceStart);
ITAGeoUtils::MirrorPointOverPlane(*pParentEdge->v3EndVertex, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceEnd);
ITAGeoUtils::MirrorPointOverPlane( *pParentEdge->v3StartVertex, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceStart );
ITAGeoUtils::MirrorPointOverPlane( *pParentEdge->v3EndVertex, *pPropagationFace->pPlane, *pPropagationFace->v3ImageEdgeSourceEnd );
}
}
}
//Go one level deeper
for (auto& pShapeChild : pPropagationShape->vpChildren)
RecursiveConstructImageEdges(pShapeChild);
for( auto& pShapeChild : pPropagationShape->vpChildren )
RecursiveConstructImageEdges( pShapeChild );
return true;
}
bool ConstructImageEdges(vector<CPropagationShapeShared>& vpPropagationTree)
bool ConstructImageEdges( vector< CPropagationShapeShared >& vpPropagationTree )
{
//First element of tree has never an image edge, so only construct them for its children
for (auto& pShape : vpPropagationTree)
if(pShape != nullptr)
for (auto& pShapeChild : pShape->vpChildren)
if(pShapeChild != nullptr)
RecursiveConstructImageEdges(pShapeChild);
for( auto& pShape : vpPropagationTree )
if( pShape != nullptr )
for( auto& pShapeChild : pShape->vpChildren )
if( pShapeChild != nullptr )
RecursiveConstructImageEdges( pShapeChild );
return true;
}
}
}
}
......@@ -14,7 +14,7 @@
*
* ----------------------------------------------------------------
*
* Example generating propagaton paths along a trajectory in
* Example generating propagaton paths along a trajectory in
* an urban setting.
*
*/
......@@ -28,6 +28,7 @@
#include <ITAGeo/SketchUp/Model.h>
#include <ITAGeo/Material/Material.h>
#include <ITAGeo/Material/Manager.h>
#include <ITAGeo/Utils/JSON/PropagationPath.h>
#include <VistaTools/VistaFileSystemDirectory.h>
......@@ -37,9 +38,6 @@ using namespace std;
using namespace ITAGeo;
using namespace ITAPropagationPathSim;
#if 1 //#ifdef WITH_JSON_SUPPORT
#include <ITAGeo/Utils/JSON/PropagationPath.h>
#endif
int main( int, char** )
......@@ -77,24 +75,32 @@ int main( int, char** )
float start_pos_z = 1.0f;
// Scene
//auto pReceiver = make_shared< CSensor >( VistaVector3D( 10.0f, 5.0f, 1.7f ) );
auto pReceiver = make_shared< CSensor >(VistaVector3D(15.0f, 0.0f, 1.7f));
auto pReceiver = make_shared< CSensor >( VistaVector3D( 15.0f, 0.0f, 1.7f ) );
auto pVehicle = make_shared< CEmitter >(VistaVector3D(start_pos_x, start_pos_y, start_pos_z));
auto pVehicle = make_shared< CEmitter >( VistaVector3D( start_pos_x, start_pos_y, start_pos_z ) );