MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00007 00012 //---------------------------------------------------------------------------------- 00013 00014 #ifndef __CSOGeometry_H 00015 #define __CSOGeometry_H 00016 00017 #include "MLCSOIncludes.h" 00018 #include "CSOTools/CSOHeapObject.h" 00019 #include "CSOTools/CSOObjectHeap.h" 00020 #include "CSOTools/CSOPathPointIterator.h" 00021 00022 00023 #include <mlRotation.h> 00024 00025 ML_START_NAMESPACE 00026 00027 00029 00030 class CSO; 00031 class CSOList; 00032 ML_REFCOUNTED_PTR(CSOList) 00033 00034 00035 00040 00041 00042 namespace CSOGeometry 00043 { 00044 00045 enum ReductionMode { 00046 REDUCTION_MODE_ANGLE = 0, 00047 REDUCTION_MODE_LENGTH, 00048 REDUCTION_MODE_ANGLE_AND_LENGTH 00049 }; 00050 00051 00053 MLCSO_EXPORT bool computeIsInPlane(const CSO* cso, Vector3& planeNormal); 00055 MLCSO_EXPORT Vector3 computeNewellsNormal(std::vector< Vector3 >& points); 00056 00059 MLCSO_EXPORT bool isSelfIntersecting(const std::vector<Vector3>& positions, std::vector<Vector3>& intersectPoints, bool isClosed); 00061 MLCSO_EXPORT bool isSelfIntersecting(const std::vector<Vector3>& positions, bool isClosed); 00062 00064 MLCSO_EXPORT bool isSelfIntersecting(const CSO* cso); 00066 MLCSO_EXPORT bool isSelfIntersecting(const CSO* cso, std::vector<Vector3>& intersectPositions); 00067 00069 MLCSO_EXPORT double computeSegmentSegmentDistance(const Vector3& start0, const Vector3& end0, const Vector3& start1, const Vector3& end1, Vector3& intersectionPoint, bool& isParallel); 00071 MLCSO_EXPORT double computeSegmentSegmentDistance(const Vector3& start0, const Vector3& end0, const Vector3& start1, const Vector3& end1, Vector3& intersectionPoint); 00072 00074 MLCSO_EXPORT bool areInSamePlane(CSO* cso0, CSO* cso1, const MLdouble epsilon = 10e-5); 00075 00078 MLCSO_EXPORT void rotateAndProject(Rotation& rot, Vector3& voxelPos, bool shouldProject=true); 00079 00083 MLCSO_EXPORT void level(CSO* cso); 00084 00086 MLCSO_EXPORT void translate(CSO* cso, const Vector3& translation); 00087 00091 MLCSO_EXPORT bool isPointInsidePolygon(const std::vector<Vector3>& polygonPoints, const Vector3& point); 00092 00094 MLCSO_EXPORT void appendUniquePosition(std::vector<Vector3>&positions, Vector3 pos); 00095 00099 MLCSO_EXPORT Vector3 getCenterOfGravity(CSO* cso, bool considerSeedPointsExtra=false); 00100 00102 MLCSO_EXPORT double distanceToLine (const Vector3& point, const Vector3& linePoint1, const Vector3& linePoint2); 00103 00105 MLCSO_EXPORT double distanceToLine2(const Vector3& linePoint1, const Vector3& linePoint2, const Vector3& point, Vector3& resultPoint); 00106 00108 MLCSO_EXPORT void computeClosestSeedPoint(CSO* cso, const Vector3& referencePoint, unsigned int &resultSeedPointIndex); 00110 MLCSO_EXPORT void computeClosestPoint(CSO* cso, const Vector3& referencePoint, unsigned int &resultPathPointListIndex, unsigned int &resultPathPointIndex, Vector3 &resultPosition); 00112 MLCSO_EXPORT void computeClosestPoint(const std::vector<Vector3>& pointList, const Vector3& referencePoint, unsigned int& resultPointIndex, Vector3& resultPosition); 00114 MLCSO_EXPORT double computeDistance(CSO* cso, const Vector3& referencePoint); 00116 MLCSO_EXPORT double computeLength(const CSOPathPointIterator& startIter, const CSOPathPointIterator& endIter); 00117 00120 MLCSO_EXPORT void thinOutCSO(CSO* cso, float quality=0.5f, ReductionMode reductionMode=REDUCTION_MODE_ANGLE_AND_LENGTH, unsigned int minPoints=5, float maxAngleLimit=1.0); 00123 MLCSO_EXPORT void thinOutPointList(std::vector<Vector3>& positionList, float quality=0.5f, ReductionMode reductionMode=REDUCTION_MODE_ANGLE_AND_LENGTH, unsigned int minPoints=5, float maxAngleLimit=1.0); 00124 00126 MLCSO_EXPORT bool csoIsEnclosedByCSO(CSO* toTestInnerCSO, CSO* toTestOuterCSO); 00131 MLCSO_EXPORT size_t getLevelOfEmbedding(const CSOListPtr& csoList, std::vector<size_t>& result); 00132 00139 MLCSO_EXPORT bool isApproximatelyParallel(const CSO* cso, const Vector3& normal, double epsilon=0.1); 00140 00142 00144 const unsigned int INVALID_INDEX = static_cast<unsigned int>(-1); 00145 00147 00148 00149 class PositionObj : public CSOHeapObject 00150 { 00151 public: 00152 double angle; 00153 Vector3 position; 00154 PositionObj* predPos; 00155 PositionObj* succPos; 00156 }; 00157 } 00158 00160 00161 ML_END_NAMESPACE 00162 00163 00164 #endif // __CSOGeometry_H