Commit a763c07d authored by Armin Erraji's avatar Armin Erraji

Added with ConstructPointsOfReflection() the last needed function to create propagation path lists.

parent 973a7c64
cmake_minimum_required( VERSION 2.8 )
cmake_minimum_required( VERSION 2.8 )
project( ITAPropagationPathSim )
......
#ifndef INCLUDE_WATCHER_DIFFRACTION_APERTURES
#define INCLUDE_WATCHER_DIFFRACTION_APERTURES
#ifndef INCLUDE_WATCHER_DIFFRACTION_LOCATOR
#define INCLUDE_WATCHER_DIFFRACTION_LOCATOR
// ITA includes
......@@ -18,11 +18,11 @@ namespace ITAPropagationPathSim
namespace Diffraction
{
bool ConstructAperturePoints(shared_ptr<const CEmitter> pEmitter, shared_ptr<const CSensor> pSensor, vector<CPropagationShapeShared> pPropagationLists);
bool ITA_PROPAGATION_PATH_SIM_API ConstructAperturePoints(shared_ptr<const CEmitter> pEmitter, shared_ptr<const CSensor> pSensor, vector<CPropagationShapeShared>& pPropagationLists);
}
}
}
#endif // INCLUDE_WATCHER_DIFFRACTION_APERTURES
#endif // INCLUDE_WATCHER_DIFFRACTION_LOCATOR
......@@ -19,14 +19,14 @@ namespace ITAPropagationPathSim
namespace ImageConstruction
{
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageSources(shared_ptr<const ITAGeo::CEmitter> pEmitter, vector<CPropagationShapeShared>& vpPropagationTree);
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 ConstructImageApertures(vector<CPropagationShapeShared>& vpPropagationLists);
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageEdges(shared_ptr<const ITAGeo::CEmitter> pEmitter, vector<CPropagationShapeShared> vpPropagationTree);
ITA_PROPAGATION_PATH_SIM_API bool ConstructImageEdges(shared_ptr<const ITAGeo::CEmitter> pEmitter, vector<CPropagationShapeShared>& vpPropagationTree);
}
}
}
......
......@@ -21,9 +21,9 @@ namespace ITAPropagationPathSim
//Constructor
CPathEngine(shared_ptr<const Halfedge::CMeshModelList> pMeshModelList);
void ApplyEmitter(shared_ptr<const CEmitter> pEmitter, const int iMaxDiffractions, const int iMaxReflections, const int iMaxCombinedOrder);
void ApplyEmitter(shared_ptr<CEmitter> pEmitter, const int iMaxDiffractions, const int iMaxReflections, const int iMaxCombinedOrder);
void ApplySensor(shared_ptr<const CSensor> pSensor);
void ApplySensor(shared_ptr<CSensor> pSensor);
void ConstructPropagationPaths(CPropagationPathList& oPaths);
......@@ -35,8 +35,8 @@ 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_vpPropagationLists; //!< 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<const CEmitter> m_pEmitter; //!< Const pointer to emitter
shared_ptr<const 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
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
......@@ -56,6 +56,10 @@ namespace ITAPropagationPathSim
//Create the propagation list
void CreatePropagationLists();
void RecursiveAddShapesToPropagationLists(shared_ptr<CPropagationShape>& pPropagationShapeIn);
//Convert the propagation list
void ConvertShapeListsToPropagationPaths(ITAGeo::CPropagationPathList& oPathsOut);
};
}
......
#ifndef INCLUDE_WATCHER_REFLECTION_LOCATOR
#define INCLUDE_WATCHER_REFLECTION_LOCATOR
// ITA includes
#include <ITAGeo/Base.h>
#include <ITAGeo/Halfedge/MeshModel.h>
#include <ITAGeo/Utils.h>
#include<ITAPropagationPathSim/CombinatedModel/PropagationShapes.h>
namespace ITAPropagationPathSim
{
namespace CombinatedModel
{
using namespace std;
namespace Reflection
{
ITA_PROPAGATION_PATH_SIM_API bool ConstructPointsOfReflection(vector<CPropagationShapeShared>& pPropagationLists, shared_ptr<const ITAGeo::CSensor> pSensor);
}
}
}
#endif // INCLUDE_WATCHER_REFLECTION_LOCATOR
#include <ITAPropagationPathSim\CombinatedModel\DiffractionApertures.h>
#include <ITAPropagationPathSim\CombinatedModel\DiffractionLocator.h>
using namespace std;
using namespace ITAGeo;
bool ITAPropagationPathSim::CombinatedModel::Diffraction::ConstructAperturePoints(shared_ptr<const CEmitter> pEmitter, shared_ptr<const CSensor> pSensor, vector<CPropagationShapeShared> pPropagationLists)
bool ITAPropagationPathSim::CombinatedModel::Diffraction::ConstructAperturePoints(shared_ptr<const CEmitter> pEmitter, shared_ptr<const CSensor> pSensor, vector<CPropagationShapeShared>& pPropagationLists)
{
for (auto& pPropagationStartPoint : pPropagationLists)
{
......@@ -99,8 +99,10 @@ bool ITAPropagationPathSim::CombinatedModel::Diffraction::ConstructAperturePoint
}
}
//In the last step, the path candidate could be declared as invalid. If it is invalid, go to the next path candidate
if (pPropagationStartPoint == nullptr)
//In the last step, the path candidate could be declared as invalid.
//If it is invalid, go to the next path candidate
//Also go to the next path candidate, if no edge was found
if (pPropagationStartPoint == nullptr || pEdge == nullptr)
continue;
//Add the (maybe imaged) receiver to the differences vector
......@@ -193,7 +195,7 @@ bool ITAPropagationPathSim::CombinatedModel::Diffraction::ConstructAperturePoint
}
//Set the aperture points of the propagation candidate starting with the last edge
while (pEdge != nullptr)
while (pPropagationStartPoint != nullptr && pEdge != nullptr)
{
//Set the interaction point to the aperture point location
//v3InteractionPoint = from_vertex + vfRelativeApexPosition * (to_vertex - from_vertex)
......@@ -208,7 +210,7 @@ bool ITAPropagationPathSim::CombinatedModel::Diffraction::ConstructAperturePoint
//Loop until the next edge is found or no further shape are before the current one
while (pShape != nullptr && pShape->iShapeType != CPropagationShape::EDGE)
{
pShape == pEdge->pParent;
pShape = pShape->pParent;
}
//Break if no further edge are found
......@@ -221,4 +223,5 @@ bool ITAPropagationPathSim::CombinatedModel::Diffraction::ConstructAperturePoint
}
}
return true;
}
......@@ -69,6 +69,29 @@ namespace ITAPropagationPathSim
return true;
}
bool ConstructImageSources(const VistaVector3D& v3SourceIn, vector<CPropagationFaceShared>& pFacesOut)
{
VistaVector3D v3ImageSource = v3SourceIn;
for (auto& pFace : pFacesOut)
{
if (ITAGeoUtils::IsPointInFrontOfPlane(*pFace->pPlane, v3ImageSource))
{
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);
return false;
}
}
//No invalid image source found
return true;
}
void RecursivePrepareImageReceivers(ITAPropagationPathSim::CombinatedModel::CShapesMap &vpVisibilityMap, CPropagationShapeShared &vpShapeParent, std::shared_ptr<ImageReceiverMap> &pParentImageReceiverMap, int iOrder, int iMaxOrder)
{
auto vpShapeChildren = vpVisibilityMap[vpShapeParent];
......@@ -237,32 +260,14 @@ namespace ITAPropagationPathSim
}
}
}
}
bool ConstructImageSources(const VistaVector3D& v3SourceIn, vector<CPropagationFaceShared>& pFacesOut)
{
VistaVector3D v3ImageSource = v3SourceIn;
for (auto& pFace : pFacesOut)
{
if (ITAGeoUtils::IsPointInFrontOfPlane(*pFace->pPlane, v3ImageSource))
{
ITAGeoUtils::MirrorPointOverPlane(v3ImageSource, *pFace->pPlane, v3ImageSource);
pFace->v3ImageSource = make_shared <VistaVector3D>(v3ImageSource);
}
else //Image source is not illuminable and thus, the whole path is invalid
{
return false;
}
}
//No invalid image source found
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->v3FromVertexMirrored);
......@@ -286,7 +291,7 @@ namespace ITAPropagationPathSim
return bValidImageEdge;
}
bool RecursiveConstructImageEdges(CPropagationShapeShared pPropagationShape)
bool RecursiveConstructImageEdges(CPropagationShapeShared& pPropagationShape)
{
//if the type is face, just go one level deeper
if (pPropagationShape->iShapeType == CPropagationShape::EDGE)
......@@ -325,7 +330,7 @@ namespace ITAPropagationPathSim
return true;
}
bool ConstructImageEdges(shared_ptr<const ITAGeo::CEmitter> pEmitter, vector<CPropagationShapeShared> vpPropagationTree)
bool ConstructImageEdges(shared_ptr<const ITAGeo::CEmitter> pEmitter, vector<CPropagationShapeShared>& vpPropagationTree)
{
//First element of tree has never an image edge, so only construct them for its children
for (auto& pShape : vpPropagationTree)
......
#include <ITAPropagationPathSim\CombinatedModel\PropagationEngine.h>
#include <ITAPropagationPathSim\CombinatedModel\ImageConstructor.h>
#include <ITAPropagationPathSim\CombinatedModel\DiffractionApertures.h>
#include <ITAPropagationPathSim\CombinatedModel\DiffractionLocator.h>
#include <ITAPropagationPathSim\CombinatedModel\ReflectionLocator.h>
//Typedefs
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
......@@ -32,7 +33,7 @@ ITAPropagationPathSim::CombinatedModel::CPathEngine::CPathEngine(shared_ptr<cons
}
void ITAPropagationPathSim::CombinatedModel::CPathEngine::ApplyEmitter(shared_ptr<const ITAGeo::CEmitter> pEmitter, const int iMaxDiffractions, const int iMaxReflections, const int iMaxCombinedOrder)
void ITAPropagationPathSim::CombinatedModel::CPathEngine::ApplyEmitter(shared_ptr<ITAGeo::CEmitter> pEmitter, const int iMaxDiffractions, const int iMaxReflections, const int iMaxCombinedOrder)
{
//Set emitter
m_pEmitter = pEmitter;
......@@ -52,7 +53,7 @@ void ITAPropagationPathSim::CombinatedModel::CPathEngine::ApplyEmitter(shared_pt
ImageConstruction::ConstructImageEdges(m_pEmitter, m_vpPropagationTree);
}
void ITAPropagationPathSim::CombinatedModel::CPathEngine::ApplySensor(shared_ptr<const ITAGeo::CSensor> pSensor)
void ITAPropagationPathSim::CombinatedModel::CPathEngine::ApplySensor(shared_ptr<ITAGeo::CSensor> pSensor)
{
//Set sensor
m_pSensor = pSensor;
......@@ -64,17 +65,124 @@ void ITAPropagationPathSim::CombinatedModel::CPathEngine::ApplySensor(shared_ptr
ImageConstruction::ConstructImageReceivers(m_pSensor, m_vpPropagationLists, m_mvpShapeVisibilityMap, *m_pMaxReflectionOrder);
}
void ITAPropagationPathSim::CombinatedModel::CPathEngine::ConstructPropagationPaths(CPropagationPathList& oPaths)
void ITAPropagationPathSim::CombinatedModel::CPathEngine::ConstructPropagationPaths(ITAGeo::CPropagationPathList& oPaths)
{
int iCounter = 0;
for (auto& pPropagationList : m_vpPropagationLists)
{
if (pPropagationList == nullptr)
iCounter++;
}
std::cout << iCounter << " times nullptr at start\n";
//First, construct the aperture points
Diffraction::ConstructAperturePoints(m_pEmitter, m_pSensor, m_vpPropagationLists);
iCounter = 0;
for (auto& pPropagationList : m_vpPropagationLists)
{
if (pPropagationList == nullptr)
iCounter++;
}
std::cout << iCounter << " times nullptr after aperture points calced\n";
//Thereafter, with the constructed aperture points, construct the image apertures as secondary image sources
//for the faces after each edge
ImageConstruction::ConstructImageApertures(m_vpPropagationLists);
iCounter = 0;
for (auto& pPropagationList : m_vpPropagationLists)
{
if (pPropagationList == nullptr)
iCounter++;
}
std::cout << iCounter << " times nullptr after image aperture calced\n";
//Construct the intersection points of the reflections
Reflection::ConstructPointsOfReflection(m_vpPropagationLists, m_pSensor);
iCounter = 0;
for (auto& pPropagationList : m_vpPropagationLists)
{
if (pPropagationList == nullptr)
iCounter++;
}
std::cout << iCounter << " times nullptr after points of reflection calced\n";
//Convert pPropagationShapes to pPropagationAnchors
ConvertShapeListsToPropagationPaths(oPaths);
}
void ITAPropagationPathSim::CombinatedModel::CPathEngine::ConvertShapeListsToPropagationPaths(ITAGeo::CPropagationPathList& oPathsOut)
{
//Add direct path
CPropagationPath oDirectPath;
oDirectPath.push_back(m_pEmitter);
oDirectPath.push_back(m_pSensor);
oPathsOut.push_back(oDirectPath);
for (auto& pShapeStart : m_vpPropagationLists)
{
if (pShapeStart == nullptr)
continue;
//Create path
CPropagationPath oPath;
//The path always starts with the emitter
oPath.push_back(m_pEmitter);
CPropagationShapeShared pShape = pShapeStart;
while (pShape != nullptr)
{
switch (pShape->iShapeType)
{
case CPropagationShape::FACE:
{
CPropagationFaceShared pFace = static_pointer_cast<CPropagationFace>(pShape);
//Create specular reflection anchor
shared_ptr<CSpecularReflection> pReflectionAnchor = make_shared<CSpecularReflection>();
pReflectionAnchor->v3InteractionPoint = *pFace->v3InteractionPoint;
float x = (*pFace->v3InteractionPoint)[0];
float y = (*pFace->v3InteractionPoint)[1];
oPath.push_back(pReflectionAnchor);
break;
}
case CPropagationShape::EDGE:
{
CPropagationEdgeShared pEdge = static_pointer_cast<CPropagationEdge>(pShape);
//Create specular reflection anchor
shared_ptr<CITADiffractionOuterWedgeAperture> pDiffractionAnchor = make_shared<CITADiffractionOuterWedgeAperture>();
pDiffractionAnchor->v3InteractionPoint = *pEdge->v3InteractionPoint;
pDiffractionAnchor->v3MainWedgeFaceNormal = *pEdge->v3MainFaceNormal;
pDiffractionAnchor->v3OppositeWedgeFaceNormal = *pEdge->v3OppositeFaceNormal;
pDiffractionAnchor->v3VertextStart = *pEdge->v3FromVertex;
pDiffractionAnchor->v3VertextEnd = *pEdge->v3ToVertex;
oPath.push_back(pDiffractionAnchor);
break;
}
}
pShape = pShape->pChild;
}
//The path always ends with the sensor
oPath.push_back(m_pSensor);
//Add current path to path list
oPathsOut.push_back(oPath);
}
}
......
#include <ITAPropagationPathSim\CombinatedModel\ReflectionLocator.h>
bool ITAPropagationPathSim::CombinatedModel::Reflection::ConstructPointsOfReflection(vector<CPropagationShapeShared>& pPropagationLists, shared_ptr<const ITAGeo::CSensor> pSensor)
{
for (auto& pStartShape : pPropagationLists)
{
//Empty lists are ignored
if (pStartShape == nullptr)
continue;
//First, go to the last shape
CPropagationShapeShared pShape = pStartShape;
while (pShape->pChild != nullptr)
pShape = pShape->pChild;
//Set the interaction point of the sensor as the starting receiver
VistaVector3D v3LastInteraction = pSensor->v3InteractionPoint;
//Go through all shapes until the first shape is reached
while (pShape != nullptr)
{
CPropagationFaceShared pFace;
if (pShape->iShapeType == CPropagationShape::FACE)
{
pFace = static_pointer_cast<CPropagationFace>(pShape);
//Calculate the points of intersection
if (ITAGeoUtils::IsPointInFrontOfPlane(*pFace->pPlane,v3LastInteraction))
{
//Calculate the point of intersection.
//The point is directly saved as v3LastInteraction,
//because it will be also used in the next iteration
VistaVector3D test;
bool bValid = pFace->pPlane->CalcIntersection(VistaLineSegment(*pFace->v3ImageSource, v3LastInteraction), v3LastInteraction);
if (bValid && ITAGeoUtils::IsPointInFace(v3LastInteraction, pFace->vv3Vertices))
{
pFace->v3InteractionPoint = make_unique<VistaVector3D>(v3LastInteraction);
}
else //invalid path because the current interaction point does not lie on the face
{
pStartShape = nullptr;
break;
}
}
else //invalid path because the last intersection is not in front of face
{
pStartShape = nullptr;
break;
}
}
else //Everytime an edge occurs, replace the receiver with the aperture point(interaction point) of the edge
{
v3LastInteraction = *pShape->v3InteractionPoint;
}
pShape = pShape->pParent;
}
}
return true;
}
......@@ -5,8 +5,8 @@ set( RelativeDir "src/ITAPropagationPathSim/CombinatedModel" )
set( RelativeSourceGroup "Source Files\\ITAPropagationPathSim\\CombinatedModel" )
set( DirFiles
DiffractionApertures.cpp
ImageLocator.cpp
DiffractionLocator.cpp
ImageConstructor.cpp
PropagationEngine.cpp
PropagationConstructor.cpp
PropagationShapes.cpp
......
......@@ -97,17 +97,25 @@ int main( int iNumInArgs, char* pcInArgs[] )
pPathEngine->ApplySensor(pSensor);
cout << "Calculation time applying sensor: " << timeToString(sw.stop()) << endl;
CPropagationPathList oPathListAll, oPathListVisible;
sw.start();
pPathEngine->ConstructPropagationPaths(oPathListAll);
cout << "Calculation time propagation path creation: " << timeToString(sw.stop()) << endl;
pMeshModelList->FilterVisiblePaths(oPathListAll, oPathListVisible);
//maptest[test1a] = "45645";
//cout << maptest[test1b];
//CPropagationPathList pathList;
for (auto path : oPathListVisible)
{
oGeoModel.AddPropagationPathVisualization(path, "Propagation_Paths");
}
//oGeoModel.Store(sSubFolder +"SimpleImageModelTest_"+ sInFile);
oGeoModel.Store(sSubFolder +"SimpleImageModelTest_"+ sInFile);
return 0;
}
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