Commit 7fbe9d9c authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Fixing merge problem

parents d4710ee0 2b2589e8
......@@ -24,24 +24,25 @@ namespace ITAPropagationPathSim
CPathEngine();
void Configure(const bool bFilterNotNeighbouredEdges = false, const bool bFilterIlluminatedRegionDiffraction = false,
const bool bFilterEdgeToEdgeIntersectedPaths = false,
const bool bFilterEmitterToEdgeIntersectedPaths = false,
const bool bFilterSensorToEdgeIntersectedPaths = false,
const bool bFilterIntersectedPaths = false,
const int iNumberIterationApexCalculation = 5,
const float fIntersectionTestResolution = 0.001f,
const float fAccumulatedAngleThreshold = -1.0f);
const bool bFilterEdgeToEdgeIntersectedPaths = false, const bool bFilterEmitterToEdgeIntersectedPaths = false,
const bool bFilterSensorToEdgeIntersectedPaths = false, const bool bFilterIntersectedPaths = false,
const int iNumberIterationApexCalculation = 5, const float fIntersectionTestResolution = 0.001f);
void SetAbortionCriteria(const int iMaxDiffractions, const int iMaxReflections, const int iMaxCombinedOrder,
const float fMaxLevelReduction=-1.f, const float fReflectionPenalty=0.f, const float fDiffractionPenalty=0.f,
const float fAccumulatedAngleThreshold = -1.0f);
void InitializePathEnvironment(shared_ptr<const Halfedge::CMeshModelList> pMeshModelList);
void ApplyEmitter(shared_ptr<CEmitter> pEmitter, const int iMaxDiffractions, const int iMaxReflections, const int iMaxCombinedOrder);
void ApplyEmitter(shared_ptr<CEmitter> pEmitter);
void ApplySensor(shared_ptr<CSensor> pSensor);
void ConstructPropagationPaths(CPropagationPathList& oPaths);
void ConstructPropagationPathsWithStopWatch(CPropagationPathList& oPaths);
void ConstructPropagationPaths(CPropagationPathList& oPaths);
size_t GetNumberPropagationPathCandidates();
private:
......@@ -49,13 +50,20 @@ namespace ITAPropagationPathSim
shared_ptr<const ITAGeo::Halfedge::CMeshModelList> m_pMeshModelList; //!< Copy of propagation model list
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
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
//Abortion criteria
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 float> m_pMaxLevelReduction; //!< Const pointer to maximum level reduction
unique_ptr<const float> m_pMaxPropagationRange; //!< Const pointer to maximum propagation range [m]
unique_ptr<const float> m_pReflectionPenalty; //!< Const pointer to reflection penalty
unique_ptr<const float> m_pDiffractionPenalty; //!< Const pointer to angle independent diffraction penalty
unique_ptr <const float> m_pAccumulatedAngleThreshold; //!< Threshold for the accumulated diffraction angle
//Filter member variables
unique_ptr<const bool> m_pFilterNotNeighbouredEdges; //!< Filter not neighboured edges for faster filter calculation
unique_ptr<const bool> m_pFilterIlluminatedRegionDiffraction; //!< Boolean pointer whether to ignore diffractions that can only diffract in illuminated regions(and have therefore a low impact to the whole IR)
......@@ -64,7 +72,6 @@ namespace ITAPropagationPathSim
unique_ptr<const bool> m_pFilterSensorToEdgeIntersectedPaths; //!< Boolean pointer for filtering paths, where always an intersection between the sensor and an edge occurs
unique_ptr<const bool> m_pFilterIntersectedPaths; //!< Boolean pointer for for filtering paths if intersection occurs
unique_ptr<const float> m_pIntersectionTestResolution; //!< Resolution for intersection test
unique_ptr <const float> m_pAccumulatedAngleThreshold; //!< Threshold for the accumulated diffraction angle
unique_ptr <const size_t> m_pNumberIterationApexCalc; //!< Number of iterations for the calculation of the aperture points
......@@ -80,7 +87,7 @@ namespace ITAPropagationPathSim
//Create the propagation tree
void CreatePropagationTree();
void RecursiveAddChildrenToTree(const CPropagationShapeShared & pPropagationShapeChildIn, CPropagationShapeShared& vpShapeChildCopyOut, int iReflectionOrder, int iDiffractionOrder, int iCombinedOrder);
void RecursiveAddChildrenToTree(const CPropagationShapeShared & pPropagationShapeChildIn, CPropagationShapeShared& vpShapeChildCopyOut, int iReflectionOrder, int iDiffractionOrder, int iCombinedOrder, float fAccumulatedPenalty, float fFirstDistance, float fSecondDistance, float fLevelDropAtFirstEdge);
//Create the propagation list
void CreatePropagationLists();
......@@ -89,6 +96,9 @@ namespace ITAPropagationPathSim
//Filter not visible, intersected, paths
void FilterVisiblePaths(const vector<CPropagationShapeShared> vpAllPathsIn, vector<CPropagationShapeShared>& vpVisiblePathsOut);
//Culling of unperceived paths
void PerceptionalCulling(const vector<CPropagationShapeShared> vpAllPathsIn, vector<CPropagationShapeShared>& vpAudiblePathsOut);
//Convert the propagation list
void ConvertShapeListsToPropagationPaths(ITAGeo::CPropagationPathList& oPathsOut);
......
......@@ -25,11 +25,12 @@ namespace ITAPropagationPathSim
typedef shared_ptr<CPropagationFace> CPropagationFaceShared;
typedef shared_ptr<CPropagationEdge> CPropagationEdgeShared;
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
typedef map <CPropagationShapeShared, vector<CPropagationShapeShared>> CShapesMap;
typedef map <size_t, vector<CPropagationShapeShared>> CShapesMap;
typedef string MeshModelHandle;
typedef pair < MeshModelHandle, CITAMesh::FaceHandle> PropagationFaceHandle;
//Old implementation[TODO: remove]
//struct ImageReceiverMap : map<PropagationFaceHandle, shared_ptr<ImageReceiverMap>>
/* {
shared_ptr<VistaVector3D> v3ImageReceiver;
......@@ -46,7 +47,7 @@ namespace ITAPropagationPathSim
class CPropagationShape
{
public:
//Public member variables
//---Public member variables-----------------------------------------------------------------------
//!< Type of shape(e.g. edge or face)
enum EShapeType
......@@ -65,6 +66,12 @@ namespace ITAPropagationPathSim
//!< Point of interaction
unique_ptr<VistaVector3D> v3InteractionPoint;
//!< Shape handle
OpenMesh::BaseHandle hShape;
//!< Vertices of shape
vector<shared_ptr<VistaVector3D>> vv3Vertices;
//!< Parent shape(previous shape)
weak_ptr<CPropagationShape> pParent;
......@@ -74,24 +81,52 @@ namespace ITAPropagationPathSim
shared_ptr<string> sMeshModelName;
//Public member functions
//!< Barycenter of shape (used for boundary sphere)
shared_ptr<VistaVector3D> v3Barycenter;
//!< Radius of boundary sphere (longest distance from barycenter to vertex)
float fRadius;
//!< Minimum distance to previous shape
float fMinimumDistance = 0.0f;
//!< Distance level drop
float fDistanceLevelDrop = 0.0f;
//---Public member functions--------------------------------------------------------------------
//!<Copy shape
void CopyFrom(const CPropagationShape& oPropagationShapeIn);
private:
void GetBoundingBoxAxesAligned(VistaVector3D& v3Min, VistaVector3D& v3Max) const;
//!< Set barycenter and radius of the boundary sphere of the shape
bool SetBoundarySphere();
bool SetMinimumDistance(const CPropagationShape& oPropagationShape);
//!< Set fMinimumDistance to point (e.g. emitter)
bool SetMinimumDistance(const VistaVector3D& v3Point);
//!< Calculate minimum distance to point (e.g. emitter) and return value
float CalculateMinimumDistance(const VistaVector3D& v3Point);
//!< Calculate the level drop due to the propagation of the sound
float CalculateLevelDrop(float& fFirstDistance, float& fSecondDistance, float& fLevelDropAtFirstEdge);
size_t GetIdentifier() const;
};
class CPropagationFace : public CPropagationShape
{
public:
//Public member variables
//---Public member variables--------------------------------------------------------------------
CITAMesh::FaceHandle hFace; //Face handle corresponding to propagation face
shared_ptr<VistaPlane> pPlane; //Plane built up by face
vector<shared_ptr<VistaVector3D>> vv3Vertices;
shared_ptr<VistaVector3D> v3ImageSource;
shared_ptr<VistaVector3D> v3ImageEdgeSourceStart;
......@@ -99,15 +134,26 @@ namespace ITAPropagationPathSim
shared_ptr<bool> pHasValidImageSource;
//Public member functions
//---Public member functions----------------------------------------------------------------------
//!< Copy face
void CopyFrom(const CPropagationFace& oPropagationFaceIn);
// Set minimum distance to shape
bool SetMinimumDistance(const CPropagationShape& oPropagationShape);
// Set fMinimumDistance to point (e.g. emitter)
bool SetMinimumDistance(const VistaVector3D& v3Point);
// Calculate minimum distance to point (e.g. emitter) and return value
float CalculateMinimumDistance(const VistaVector3D& v3Point);
};
class CPropagationEdge : public CPropagationShape
{
public:
//Public member variables
//---Public member variables-------------------------------------------------------------------------
CITAMesh::HalfedgeHandle hHalfedge;
CITAMesh::EdgeHandle hEdge;
CITAMesh::FaceHandle hMainFace;
......@@ -129,9 +175,22 @@ namespace ITAPropagationPathSim
//!< If the relative position lies between 0.0(at v3FromVertex) and 1.0(at v3ToVertex), the interaction point is on the edge
unique_ptr<float> pRelativeInteractionPoint;
//Public member functions
//---Public member functions-----------------------------------------------------------------------
//!< Copy edge
void CopyFrom(const CPropagationEdge& oPropagationEdgeIn);
// Set minimum distance to shape
bool SetMinimumDistance(const CPropagationShape& oPropagationShape);
// Set fMinimumDistance to point (e.g. emitter)
bool SetMinimumDistance(const VistaVector3D& v3Point);
// Calculate minimum distance to point (e.g. emitter) and return value
float CalculateMinimumDistance(const VistaVector3D& v3Point);
//!< Calculate the level drop due to the propagation of the sound
float CalculateLevelDrop(float& fFirstDistance, float& fSecondDistance, float& fLevelDropAtFirstEdge);
};
}
}
......
#ifndef INCLUDE_WATCHER_PROPAGATION_RTREE
#define INCLUDE_WATCHER_PROPAGATION_RTREE
// ITAGeo
#include <ITAGeo/Definitions.h>
#include <ITAGeo/Utils.h>
#include <ITAGeo/Base.h>
#include <ITAGeo/ModelBase.h>
#include <ITAGeo/Halfedge/MeshModel.h>
#include<ITAPropagationPathSim/CombinedModel/PropagationShapes.h>
using namespace std;
namespace ITAPropagationPathSim
{
namespace CombinedModel
{
// Typedefs
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
//! Buildings RTree class
/**
* @todo
*
*/
class ITA_GEO_API CShapesTree
{
public:
//---Constructor and Destructor---------------------------------------------
CShapesTree();
~CShapesTree();
//---Public member functions------------------------------------------------
void Create(const vector<CPropagationShapeShared>& vpShapesIn);
//TODO
bool IsLineSegmentIntersected(const VistaVector3D& oLineStart, const VistaVector3D& oLineEnd) const;
//TODO
//void GetNonIntersectedFaces(vector<CPropagationShapeShared>& vpFacesOut, const VistaVector3D& oLineStart, const VistaVector3D& oLineStart);
/*TODO: For faster illumination tests
void GetIlluminableShapes(vector<CPropagationShapeShared>& vpShapesOut, const VistaPlane& oPlaneIn);
void GetIlluminableShapes(vector<CPropagationShapeShared>& vpShapesOut, const CPropagationFaceShared& pFace);
void GetIlluminableShapes(vector<CPropagationShapeShared>& vpShapesOut, const CPropagationEdgeShared& pEdge);
*/
//---Public member variables------------------------------------------------
private:
//---Private member functions-----------------------------------------------
void SetVertices();
void CreateBranches();
//---Private member variables-----------------------------------------------
//Minimum and maximum of bounding box as well as vertices of box
VistaVector3D m_v3TreeMin;
VistaVector3D m_v3TreeMax;
//Vector of shapes within bounding box
vector<CPropagationShapeShared> m_vpShapes;
//Branches
vector<shared_ptr<CShapesTree>> m_vpBranches;
};
}
}
#endif // INCLUDE_WATCHER_PROPAGATION_RTREE
\ No newline at end of file
......@@ -9,6 +9,7 @@ set( DirFiles
ImageConstructor.h
PropagationEngine.h
PropagationShapes.h
RTree.h
ReflectionLocator.h
)
......
......@@ -178,7 +178,7 @@ namespace ITAPropagationPathSim
map <UrbanEdgeHandle, map <UrbanEdgeHandle, double>> m_mdApertureStartDifferenceMap;
//RTree of building meshes
shared_ptr<ITAGeo::Urban::RTree::CBuildings> m_pBuildingsTree;
shared_ptr<ITAGeo::Urban::RTree::CShapesTree> m_pBuildingsTree;
//Matrix of illumination of diffraction edges
map<UrbanEdgeHandle, set<shared_ptr<DiffractionEdge>>> m_mDiffractionMatrix;
......
......@@ -8,26 +8,176 @@ void CPropagationShape::CopyFrom(const CPropagationShape & oPropagationShapeIn)
{
iShapeType = oPropagationShapeIn.iShapeType;
vv3Vertices = oPropagationShapeIn.vv3Vertices;
pParent = oPropagationShapeIn.pParent;
pChild = oPropagationShapeIn.pChild;
vpChildren = oPropagationShapeIn.vpChildren;
sMeshModelName = oPropagationShapeIn.sMeshModelName;
v3Barycenter = oPropagationShapeIn.v3Barycenter;
fRadius = oPropagationShapeIn.fRadius;
fMinimumDistance = oPropagationShapeIn.fMinimumDistance;
hShape = oPropagationShapeIn.hShape;
pIsIlluminableBySensor = oPropagationShapeIn.pIsIlluminableBySensor;
}
void CPropagationShape::GetBoundingBoxAxesAligned(VistaVector3D& v3Min, VistaVector3D& v3Max) const
{
v3Min = *vv3Vertices[0];
v3Max = v3Min;
for (auto& v3Vertex : vv3Vertices)
{
v3Min.SetValues(fminf(v3Min[0], (*v3Vertex)[0]), fminf(v3Min[1], (*v3Vertex)[1]), fminf(v3Min[2], (*v3Vertex)[2]));
v3Max.SetValues(fmaxf(v3Max[0], (*v3Vertex)[0]), fmaxf(v3Max[1], (*v3Vertex)[1]), fmaxf(v3Max[2], (*v3Vertex)[2]));
}
}
bool CPropagationShape::SetBoundarySphere()
{
//the shape must have at least one vertex
if (vv3Vertices.size() < 1)
return false;
//Set barycenter
v3Barycenter = make_shared<VistaVector3D>(0,0,0,1);
for (auto& v3Vertex : vv3Vertices)
{
*v3Barycenter += *v3Vertex;
}
*v3Barycenter /= vv3Vertices.size();
//Set the radius of the sphere(longest distance between vertex and shape)
fRadius = 0.0f;
for (auto& v3Vertex : vv3Vertices)
{
fRadius = fmaxf(fRadius,(*v3Barycenter- *v3Vertex).GetLength());
}
return true;
}
bool ITAPropagationPathSim::CombinedModel::CPropagationShape::SetMinimumDistance(const CPropagationShape & oPropagationShape)
{
if (v3Barycenter == nullptr || oPropagationShape.v3Barycenter == nullptr)
return false;
//Calculate the distance between two spheres
fMinimumDistance = CalculateMinimumDistance (*oPropagationShape.v3Barycenter) - oPropagationShape.fRadius;
//Negative distances are not possible
fMinimumDistance = fmaxf(fMinimumDistance, 0.0f);
return true;
}
bool CPropagationShape::SetMinimumDistance(const VistaVector3D & v3Point)
{
if (v3Barycenter == nullptr)
return false;
fMinimumDistance = CalculateMinimumDistance(v3Point);
return true;
}
float CPropagationShape::CalculateMinimumDistance(const VistaVector3D & v3Point)
{
//Calculate the distance between two spheres
float fMinimumDistance = (*v3Barycenter - v3Point).GetLength() - fRadius;
//Negative distances are not possible
fMinimumDistance = fmaxf(fMinimumDistance, 0.0f);
return fMinimumDistance;
}
float CPropagationShape::CalculateLevelDrop(float & fFirstDistance, float & fSecondDistance, float & fLevelDropAtFirstEdge)
{
float fLevelDrop = 0;
if (fLevelDropAtFirstEdge < 0.0f)
{
fFirstDistance += fMinimumDistance;
fLevelDrop =fmaxf(0.0f, 20 * log10f(fFirstDistance));
}
else
{
fSecondDistance += fMinimumDistance;
float fAdditionalLevelDrop = 10 * log10f(fSecondDistance*(fSecondDistance + fFirstDistance) / fFirstDistance);
fLevelDrop = fLevelDropAtFirstEdge + fmaxf(0.0f,fAdditionalLevelDrop);
}
return fLevelDrop;
}
size_t CPropagationShape::GetIdentifier() const
{
hash<string> hashString;
hash<EShapeType> hashType;
hash<OpenMesh::BaseHandle> hashShape;
size_t identifier = hashString(*sMeshModelName);
identifier ^= hashType(iShapeType) + 0x9e3779b9 + (identifier << 6) + (identifier >> 2); // Magic number: 2 ^ 32 / ((1 + sqrt(5)) / 2) = 0x9e3779b9
identifier ^= hashShape(hShape) + 0x9e3779b9 + (identifier << 6) + (identifier >> 2);
return identifier;
}
void CPropagationFace::CopyFrom(const CPropagationFace & oPropagationFaceIn)
{
CPropagationShape::CopyFrom(oPropagationFaceIn);
hFace = oPropagationFaceIn.hFace;
pPlane = oPropagationFaceIn.pPlane;
vv3Vertices = oPropagationFaceIn.vv3Vertices;
v3ImageSource = oPropagationFaceIn.v3ImageSource;
v3ImageEdgeSourceStart = oPropagationFaceIn.v3ImageEdgeSourceStart;
v3ImageEdgeSourceEnd = oPropagationFaceIn.v3ImageEdgeSourceEnd;
pHasValidImageSource = oPropagationFaceIn.pHasValidImageSource;
}
bool CPropagationFace::SetMinimumDistance(const CPropagationShape & oPropagationShape)
{
if (v3Barycenter == nullptr || oPropagationShape.v3Barycenter == nullptr)
return false;
//Calculate the distance between two spheres
fMinimumDistance = CalculateMinimumDistance(*oPropagationShape.v3Barycenter) - oPropagationShape.fRadius;
//Negative distances are not possible
fMinimumDistance = fmaxf(fMinimumDistance, 0.0f);
return true;
}
bool CPropagationFace::SetMinimumDistance(const VistaVector3D & v3Point)
{
if (v3Barycenter == nullptr)
return false;
fMinimumDistance = CalculateMinimumDistance(v3Point);
return true;
}
float CPropagationFace::CalculateMinimumDistance(const VistaVector3D & v3Point)
{
//Distance to plane
float fPlaneDistance = fabs(pPlane->CalcDistance(v3Point));
//Distance to sphere
float fSphereDistance = CPropagationShape::CalculateMinimumDistance(v3Point);
//Maximum of both is used
return max(fPlaneDistance, fSphereDistance);
}
void CPropagationEdge::CopyFrom(const CPropagationEdge & oPropagationEdgeIn)
{
CPropagationShape::CopyFrom(oPropagationEdgeIn);
......@@ -44,3 +194,67 @@ void CPropagationEdge::CopyFrom(const CPropagationEdge & oPropagationEdgeIn)
v3ImageEdgeReceiverEnd = oPropagationEdgeIn.v3ImageEdgeReceiverEnd;
pHasValidImageEdge = oPropagationEdgeIn.pHasValidImageEdge;
}
bool CPropagationEdge::SetMinimumDistance(const CPropagationShape & oPropagationShape)
{
if (v3Barycenter == nullptr || oPropagationShape.v3Barycenter == nullptr)
return false;
//Calculate the distance between two spheres
fMinimumDistance = CalculateMinimumDistance(*oPropagationShape.v3Barycenter) - oPropagationShape.fRadius;
//Negative distances are not possible
fMinimumDistance = fmaxf(fMinimumDistance, 0.0f);
return true;
}
bool CPropagationEdge::SetMinimumDistance(const VistaVector3D & v3Point)
{
if (v3Barycenter == nullptr)
return false;
fMinimumDistance = CalculateMinimumDistance(v3Point);
return true;
}
float CPropagationEdge::CalculateMinimumDistance(const VistaVector3D & v3Point)
{
//Distance to projection on line defined by edge
VistaPlane plane1, plane2;
plane1.SetOrigin(*v3StartVertex);
plane2.SetOrigin(*v3StartVertex);
plane1.SetNormVector(*v3MainFaceNormal);
plane2.SetNormVector(*v3OppositeFaceNormal);
//Project point on first plane. Thereafter, project projected point on second plane
VistaVector3D v3Projection = plane1.CalcNearestPointOnPlane(v3Point);
v3Projection = plane2.CalcNearestPointOnPlane(v3Projection);
float fLineDistance = (v3Point - v3Projection).GetLength();
//Distance to sphere
float fSphereDistance = CPropagationShape::CalculateMinimumDistance(v3Point);
//Maximum of both is used
return max(fLineDistance, fSphereDistance);
}
float CPropagationEdge::CalculateLevelDrop(float & fFirstDistance, float & fSecondDistance, float & fLevelDropAtFirstEdge)
{
float fLevelDrop = 0;
fLevelDrop = CPropagationShape::CalculateLevelDrop(fFirstDistance, fSecondDistance, fLevelDropAtFirstEdge);
//This is the first edge
if (fLevelDropAtFirstEdge < 0.0f)
{
fLevelDropAtFirstEdge = fLevelDrop;
}
return fLevelDrop;
}
#include <ITAPropagationPathSim/CombinedModel/RTree.h>
using namespace ITAGeo;
using namespace ITAPropagationPathSim::CombinedModel;
//===RTree::CBuildings class=======================================================================================
// ---Constructor & Destructor-------------------------------------------------------------------------------------
CShapesTree::CShapesTree()
{
}
CShapesTree::~CShapesTree()
{
}
// ---Create functions----------------------------------------------------------------------------------------------
void CShapesTree::Create(const vector<CPropagationShapeShared>& vpShapesIn)
{
//Set buildings vector
m_vpShapes = vpShapesIn;
//Set vertex VistaVectors
SetVertices();
//Create branches if number of shapes is more than one
if (m_vpShapes.size() > 1)
CreateBranches();
}
void CShapesTree::CreateBranches()