MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00005 00010 //---------------------------------------------------------------------------------- 00011 00012 #ifndef __CSOPointInPolygonChecker_H 00013 #define __CSOPointInPolygonChecker_H 00014 00015 #include "MLCSOIncludes.h" 00016 #include <mlRotation.h> 00017 #include "CSOBase/CSO.h" 00018 00019 ML_START_NAMESPACE 00020 00022 00027 class MLCSO_EXPORT CSOPointInPolygonChecker 00028 { 00029 00030 public: 00031 00033 00035 CSOPointInPolygonChecker(CSO* cso); 00036 00039 CSOPointInPolygonChecker(std::vector<Vector3>& pathPoints, const Vector3& normal, bool overwritePathPoints=false); 00040 00042 ~CSOPointInPolygonChecker() {}; 00043 00045 00047 void set(CSO* cso); 00048 00051 void set(std::vector<Vector3>& pathPoints, const Vector3& normal, bool overwritePathPoints=false); 00052 00054 00056 bool isPointInsidePolygon(const Vector3& pos) const; 00057 00058 private: 00059 00061 00062 struct BinnedLine { 00063 Vector2 startPoint; 00064 Vector2 endPoint; 00065 }; 00066 00067 typedef std::vector<BinnedLine> LinesVector; 00068 00070 00072 void _transformAndProject(Vector3& voxelPos) const; 00073 00075 void _fillLineBins(const std::vector<Vector3>& projectedPathPoints); 00076 00079 bool _testLinesInBin(const Vector3& point) const; 00080 00082 00084 mutable Rotation _toZRotation; // mutable because Rotation::rotate is not const although it could be :-( 00085 00087 Vector2 _boundingBoxStart; 00089 Vector2 _boundingBoxEnd; 00090 00092 std::vector<LinesVector> _lineSegmentBin; 00094 int _binShift; 00095 00096 }; 00097 00099 00100 ML_END_NAMESPACE 00101 00102 #endif // __CSOPointInPolygonChecker_H