Commit 86358390 authored by Armin Erraji's avatar Armin Erraji

Added additional input parameter for ignoring edges that are not able to lead...

Added additional input parameter for ignoring edges that are not able to lead to paths into the shadow region.
parent d442e10b
......@@ -19,7 +19,7 @@ namespace ITAPropagationPathSim
public:
//Constructor
CPathEngine(shared_ptr<const Halfedge::CMeshModelList> pMeshModelList);
CPathEngine(shared_ptr<const Halfedge::CMeshModelList> pMeshModelList, bool bIgnoreIlluminatedRegionDiffraction = false);
void ApplyEmitter(shared_ptr<CEmitter> pEmitter, const int iMaxDiffractions, const int iMaxReflections, const int iMaxCombinedOrder);
......@@ -40,6 +40,8 @@ namespace ITAPropagationPathSim
unique_ptr<const int> m_pMaxReflectionOrder; //!< Const pointer to maximum reflection order
unique_ptr<const int> m_pMaxDiffractionOrder; //!< Const pointer to maximum diffraction order
unique_ptr<const int> m_pMaxCombinedOrder; //!< Const pointer to maximum order of combined diffractions and reflections
unique_ptr<const bool> m_pIgnoreIlluminatedRegionDiffraction; //!< Const pointer to bolean whether to ignore diffractions that can only diffract in illuminated regions(and have therefore a low impact to the whole IR)
void CreateVisibilityMap();
bool CanPointIlluminateFace(const VistaVector3D & v3Point, const string & sMeshModelName, CITAMesh::FaceHandle hFace);
......
......@@ -66,7 +66,7 @@ namespace ITAPropagationPathSim
unique_ptr<VistaVector3D> v3InteractionPoint;
//!< Parent shape(previous shape)
CPropagationShapeShared pParent;
weak_ptr<CPropagationShape> pParent;
//!< Child(ren) shape(s)
CPropagationShapeShared pChild; //Shape used in propagation paths
......
......@@ -60,7 +60,7 @@ bool ITAPropagationPathSim::CombinedModel::Diffraction::ConstructAperturePoints(
vfE_square.push_back(vpE_out.back()->GetLengthSquared());
//The first shape has no parent. If the parent is a face, the edge must be mirrored(already done in a previous step)
if (pEdge->pParent != nullptr && pEdge->pParent->iShapeType == CPropagationShape::FACE)
if (!pEdge->pParent.expired() && pEdge->pParent.lock()->iShapeType == CPropagationShape::FACE)
{
vpE_in.push_back(make_shared<VistaVector3D>(*pEdge->v3ToVertexMirrored - *pEdge->v3FromVertexMirrored));
......@@ -95,7 +95,7 @@ bool ITAPropagationPathSim::CombinedModel::Diffraction::ConstructAperturePoints(
//Mirror the (imaged) sensor until an edge is reached
ITAGeoUtils::MirrorPointOverPlane(v3SensorPosition, *static_pointer_cast<CPropagationFace>(pShape)->pPlane, v3SensorPosition);
pShape = pShape->pParent;
pShape = pShape->pParent.lock();
}
else //If the (imaged) sensor is not visible, the whole path is invalid
{
......@@ -217,12 +217,12 @@ bool ITAPropagationPathSim::CombinedModel::Diffraction::ConstructAperturePoints(
vfRelativeApexPosition.pop_back();
//Get the previous shape
pShape = pEdge->pParent;
pShape = pEdge->pParent.lock();
//Loop until the next edge is found or no further shape are before the current one
while (pShape != nullptr && pShape->iShapeType != CPropagationShape::EDGE)
{
pShape = pShape->pParent;
pShape = pShape->pParent.lock();
}
//Break if no further edge are found
......
......@@ -12,7 +12,7 @@ namespace ITAPropagationPathSim
//Recursive construct of image sources (only visible locally)
bool RecursiveConstructImageSources(CPropagationFaceShared pPropagationFace)
{
auto v3ParentImageSource = static_pointer_cast<CPropagationFace>(pPropagationFace->pParent)->v3ImageSource;
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))
......@@ -159,9 +159,9 @@ namespace ITAPropagationPathSim
ITAGeoUtils::MirrorPointOverPlane(*(pPropagationEdge->v3ToVertexMirrored.get()), *(pParentFace->pPlane.get()), *(pPropagationEdge->v3ToVertexMirrored.get()));
//Recursive construction until no further faces are found
if (pParentFace->pParent != nullptr && pParentFace->pParent->iShapeType == CPropagationShape::FACE)
if (!pParentFace->pParent.expired() && pParentFace->pParent.lock()->iShapeType == CPropagationShape::FACE)
{
auto pGrandParentFace = static_pointer_cast<CPropagationFace>(pPropagationEdge->pParent);
auto pGrandParentFace = static_pointer_cast<CPropagationFace>(pPropagationEdge->pParent.lock());
bValidImageEdge = RecursiveConstructImageEdge(pGrandParentFace, pPropagationEdge);
}
......@@ -179,14 +179,14 @@ namespace ITAPropagationPathSim
auto pPropagationEdge = static_pointer_cast<CPropagationEdge>(pPropagationShape);
//Create image vertices only for edges with faces as parents
if (pPropagationEdge->pParent != nullptr && pPropagationEdge->pParent->iShapeType == CPropagationShape::FACE)
if (!pPropagationEdge->pParent.expired() && pPropagationEdge->pParent.lock()->iShapeType == CPropagationShape::FACE)
{
pPropagationEdge->v3FromVertexMirrored = make_shared<VistaVector3D>(*pPropagationEdge->v3FromVertex);
pPropagationEdge->v3ToVertexMirrored = make_shared<VistaVector3D>(*pPropagationEdge->v3ToVertex);
pPropagationEdge->pHasValidImageEdge = make_shared<bool>(true);
auto pParentFace = static_pointer_cast<CPropagationFace>(pPropagationEdge->pParent);
auto pParentFace = static_pointer_cast<CPropagationFace>(pPropagationEdge->pParent.lock());
while (true)
{
//Only one image must be in front of plane
......@@ -204,9 +204,9 @@ namespace ITAPropagationPathSim
ITAGeoUtils::MirrorPointOverPlane(*pPropagationEdge->v3FromVertex, *pParentFace->pPlane, *pPropagationEdge->v3FromVertexMirrored);
ITAGeoUtils::MirrorPointOverPlane(*pPropagationEdge->v3ToVertex, *pParentFace->pPlane, *pPropagationEdge->v3ToVertexMirrored);
if (pParentFace->pParent != nullptr && pParentFace->pParent->iShapeType == CPropagationShape::FACE)
if (!pParentFace->pParent.expired() && pParentFace->pParent.lock()->iShapeType == CPropagationShape::FACE)
{
pParentFace = static_pointer_cast<CPropagationFace>(pParentFace->pParent);
pParentFace = static_pointer_cast<CPropagationFace>(pParentFace->pParent.lock());
}
else
{
......
......@@ -10,10 +10,12 @@ struct CITAMeshPtr
CITAMesh* pMesh;
};
ITAPropagationPathSim::CombinedModel::CPathEngine::CPathEngine(shared_ptr<const ITAGeo::Halfedge::CMeshModelList> pMeshModelList)
ITAPropagationPathSim::CombinedModel::CPathEngine::CPathEngine(shared_ptr<const ITAGeo::Halfedge::CMeshModelList> pMeshModelList, bool bIgnoreIlluminatedRegionDiffraction /* =false*/)
{
m_pMeshModelList = pMeshModelList;
m_pIgnoreIlluminatedRegionDiffraction = make_unique<bool>(bIgnoreIlluminatedRegionDiffraction);
for (int i = 0; i < m_pMeshModelList->GetNumMeshes(); i++)
{
......@@ -355,35 +357,32 @@ void ITAPropagationPathSim::CombinedModel::CPathEngine::RecursiveAddShapesToProp
if (pShape != nullptr)
{
//Add parents up until the start point is reached
while (pShape->pParent != nullptr)
while (CPropagationShapeShared pParent = pShape->pParent.lock())
{
switch (pShape->pParent->iShapeType)
switch (pParent->iShapeType)
{
case CPropagationShape::FACE:
{
CPropagationFaceShared pFaceParent = make_shared<CPropagationFace>();
pFaceParent->CopyFrom(*static_pointer_cast<CPropagationFace>(pShape->pParent));
//Set parent and child member variables to each other
pShape->pParent = pFaceParent;
pFaceParent->pChild = pShape;
pFaceParent->CopyFrom(*static_pointer_cast<CPropagationFace>(pParent));
pParent = pFaceParent;
break;
}
case CPropagationShape::EDGE:
{
CPropagationEdgeShared pEdgeParent = make_shared<CPropagationEdge>();
pEdgeParent->CopyFrom(*static_pointer_cast<CPropagationEdge>(pShape->pParent));
//Set parent and child member variables to each other
pShape->pParent = pEdgeParent;
pEdgeParent->pChild = pShape;
pEdgeParent->CopyFrom(*static_pointer_cast<CPropagationEdge>(pParent));
pParent = pEdgeParent;
break;
}
}
//Set parent and child member variables to each other
pShape->pParent = pParent;
pParent->pChild = pShape;
//Set copied parent to new shape for next iteration
pShape = pShape->pParent;
pShape = pParent;
}
//Add shape to list
......@@ -579,11 +578,17 @@ void ITAPropagationPathSim::CombinedModel::CPathEngine::CanFaceIlluminateEdge(bo
auto& pEdgeMesh = m_pMeshModelList->GetMeshModel(*pPropagationEdge->sMeshModelName)->GetMesh()->pMesh;
//Iterate over all vertices of the face. If at least one vertex is in the illuminable range of the edge, return true
bCanFaceIlluminateEdgeOut = false;
bool bMainFaceIlluminated, bOppositeFaceIlluminated;
for (auto& pVertex : pPropagationFace->vv3Vertices)
{
bCanFaceIlluminateEdgeOut |= ITAGeoUtils::CanFaceBeIlluminated(*pEdgeMesh, pPropagationEdge->hMainFace, *pVertex);
bCanFaceIlluminateEdgeOut |= ITAGeoUtils::CanFaceBeIlluminated(*pEdgeMesh, pPropagationEdge->hOppositeFace, *pVertex);
bMainFaceIlluminated = ITAGeoUtils::CanFaceBeIlluminated(*pEdgeMesh, pPropagationEdge->hMainFace, *pVertex);
bOppositeFaceIlluminated = ITAGeoUtils::CanFaceBeIlluminated(*pEdgeMesh, pPropagationEdge->hOppositeFace, *pVertex);
if (*m_pIgnoreIlluminatedRegionDiffraction)
bCanFaceIlluminateEdgeOut = bMainFaceIlluminated != bOppositeFaceIlluminated; // A XOR B, only valid, if at least one point can lie in the shadow region
else
bCanFaceIlluminateEdgeOut = bMainFaceIlluminated || bOppositeFaceIlluminated; // A OR B, also valid, if face can only lie in the illuminated region
if (bCanFaceIlluminateEdgeOut)
return;
......@@ -605,16 +610,35 @@ void ITAPropagationPathSim::CombinedModel::CPathEngine::CanFaceIlluminateFace(bo
}
}
void ITAPropagationPathSim::CombinedModel::CPathEngine::CanEdgeIlluminateEdge(bool &bCanEdgeIlluminateEdgeOut, CPropagationEdgeShared & pPropagationEdgeStart, CPropagationEdgeShared & pPropagationEdgeEnd)
void ITAPropagationPathSim::CombinedModel::CPathEngine::CanEdgeIlluminateEdge(bool &bCanEdgeIlluminateEdgeOut, CPropagationEdgeShared & pPropagationEdgeStart, CPropagationEdgeShared & pPropagationEdgeEnd )
{
auto& pEdgeEndMesh = m_pMeshModelList->GetMeshModel(*pPropagationEdgeEnd->sMeshModelName)->GetMesh()->pMesh;
bool bMainFaceIlluminated, bOppositeFaceIlluminated;
float eps = ITAConstants::EPS_F_L;
//Illumination test at from vertex position
bMainFaceIlluminated = ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hMainFace, (1 - eps)*(*pPropagationEdgeStart->v3FromVertex) + (eps)*(*pPropagationEdgeStart->v3ToVertex));
bOppositeFaceIlluminated = ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hOppositeFace, (1 - eps)*(*pPropagationEdgeStart->v3FromVertex) + (eps)*(*pPropagationEdgeStart->v3ToVertex));
if (*m_pIgnoreIlluminatedRegionDiffraction)
bCanEdgeIlluminateEdgeOut = bMainFaceIlluminated != bOppositeFaceIlluminated; // A XOR B, only valid, if at least one point can lie in the shadow region
else
bCanEdgeIlluminateEdgeOut = bMainFaceIlluminated || bOppositeFaceIlluminated; // A OR B, also valid, if face can only lie in the illuminated region
if (bCanEdgeIlluminateEdgeOut)
return;
//Illumination test at to vertex position
bMainFaceIlluminated = ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hMainFace, (1 - eps)*(*pPropagationEdgeStart->v3ToVertex) + (eps)*(*pPropagationEdgeStart->v3FromVertex));
bOppositeFaceIlluminated = ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hOppositeFace, (1 - eps)*(*pPropagationEdgeStart->v3ToVertex) + (eps)*(*pPropagationEdgeStart->v3FromVertex));
if (*m_pIgnoreIlluminatedRegionDiffraction)
bCanEdgeIlluminateEdgeOut = bMainFaceIlluminated != bOppositeFaceIlluminated; // A XOR B, only valid, if at least one point can lie in the shadow region
else
bCanEdgeIlluminateEdgeOut = bMainFaceIlluminated || bOppositeFaceIlluminated; // A OR B, also valid, if face can only lie in the illuminated region
bCanEdgeIlluminateEdgeOut = ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hMainFace, (1 - eps)*(*pPropagationEdgeStart->v3FromVertex) + (eps)*(*pPropagationEdgeStart->v3ToVertex));
bCanEdgeIlluminateEdgeOut |= ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hMainFace, (1 - eps)*(*pPropagationEdgeStart->v3ToVertex) + (eps)*(*pPropagationEdgeStart->v3FromVertex));
bCanEdgeIlluminateEdgeOut |= ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hOppositeFace, (1 - eps)*(*pPropagationEdgeStart->v3FromVertex) + (eps)*(*pPropagationEdgeStart->v3ToVertex));
bCanEdgeIlluminateEdgeOut |= ITAGeoUtils::CanFaceBeIlluminated(*pEdgeEndMesh, pPropagationEdgeEnd->hOppositeFace, (1 - eps)*(*pPropagationEdgeStart->v3ToVertex) + (eps)*(*pPropagationEdgeStart->v3FromVertex));
}
void ITAPropagationPathSim::CombinedModel::CPathEngine::ConstructPropagationShapes()
......
......@@ -63,7 +63,7 @@ bool ITAPropagationPathSim::CombinedModel::Reflection::ConstructPointsOfReflecti
v3LastInteraction = *pShape->v3InteractionPoint;
}
pShape = pShape->pParent;
pShape = pShape->pParent.lock();
}
......
......@@ -84,7 +84,7 @@ int main( int iNumInArgs, char* pcInArgs[] )
ITAStopWatch sw; sw.start();
auto pPathEngine = make_shared<CombinedModel::CPathEngine>(pMeshModelList);
auto pPathEngine = make_shared<CombinedModel::CPathEngine>(pMeshModelList,true);
cout << "Calculation time initialization path engine: " << timeToString(sw.stop()) << endl;
sw.start();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment