MeVisLab Toolbox Reference
CSOGeometry.h File Reference

Go to the source code of this file.

Classes

class  ml::CSOGeometry::PositionObj
 
class  ml::CSOGeometry::CSOPlaneGuard
 

Namespaces

 ml
 Main documentation file for ML users and developers.
 
 ml::CSOGeometry
 The CSOGeometry namespace offers some common methods for various geometric problems, e.g., determining whether a CSO lies in a plane, if a CSO is self-intersection, computing the center of gravity, thinning out path points or applying Boolean operations.
 

Enumerations

enum  ml::CSOGeometry::ReductionMode { ml::CSOGeometry::REDUCTION_MODE_ANGLE = 0 , ml::CSOGeometry::REDUCTION_MODE_LENGTH , ml::CSOGeometry::REDUCTION_MODE_ANGLE_AND_LENGTH }
 

Functions

MLCSO_EXPORT bool ml::CSOGeometry::computeIsInPlane (const CSO *cso, Vector3 &planeNormal, double angleEpsilon=1e-3, double collinearEpsilon=1e-3)
 Returns whether all the path points lie in one plane, and fills the plane normal. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::computeIsInPlane (const std::vector< Vector3 > &points, Vector3 &planeNormal, double angleEpsilon=1e-3, double collinearEpsilon=1e-3)
 Returns whether the given positions form a contour that is in-plane. More...
 
MLCSO_EXPORT Vector3 ml::CSOGeometry::computeNewellsNormal (const std::vector< Vector3 > &points)
 Returns a normal for the given list of points using Newell's method. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::arePointsCollinear (const std::vector< Vector3 > &points, double epsilon)
 Returns whether all points are collinear. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::isSelfIntersecting (const std::vector< Vector3 > &positions, std::vector< Vector3 > &intersectPoints, bool isClosed)
 Returns whether the given list of points interpreted as a contour intersects itself. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::isSelfIntersecting (const std::vector< Vector3 > &positions, bool isClosed)
 Returns whether the given list of points interpreted as a contour intersects itself. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::isSelfIntersecting (const CSO *cso)
 Returns whether the given contour intersects itself. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::isSelfIntersecting (const CSO *cso, std::vector< Vector3 > &intersectPositions)
 Returns whether the given contour intersects itself. Fills up the given intersectPositions vector. More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeSegmentSegmentDistance (const Vector3 &start0, const Vector3 &end0, const Vector3 &start1, const Vector3 &end1, Vector3 &intersectionPoint, bool &isParallel)
 Returns the minimum distance between the two given segments. If this distance is 0, the intersectionPoint is valid. More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeSegmentSegmentDistance (const Vector3 &start0, const Vector3 &end0, const Vector3 &start1, const Vector3 &end1, Vector3 &intersectionPoint)
 /deprecated More...
 
MLCSO_EXPORT int ml::CSOGeometry::intersect2DSegments (const Vector2 &start0, const Vector2 &end0, const Vector2 &start1, const Vector2 &end1, Vector2 &intersection0, Vector2 &intersection1)
 Computes whether the two given 2D segments intersect; if they intersect, the intersection point is valid. More...
 
bool ml::CSOGeometry::isInSegment (const Vector2 &point, const Vector2 &segmentStart, const Vector2 &segmentEnd)
 Helper function for intersect2DSegments. More...
 
MLdouble ml::CSOGeometry::perp (const Vector2 &v0, const Vector2 &v1)
 Helper function for intersect2DSegments. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::areInSamePlane (const CSO *cso0, const CSO *cso1, MLdouble angleEpsilon=10e-5, MLdouble minPlaneDistanceInMM=10e-5)
 Returns whether the two given CSOs lie in the same plane. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::areOverlapping (const CSO *cso0, const CSO *cso1, MLdouble epsilon=10e-5, MLdouble minPlaneDistanceInMM=10e-5)
 Returns whether any path point of cso0 is within cso1 or vice versa. More...
 
MLCSO_EXPORT void ml::CSOGeometry::rotateAndProject (Rotation &rot, Vector3 &voxelPos, bool shouldProject=true)
 Transforms and projects a voxelPos according to a rotation. More...
 
MLCSO_EXPORT void ml::CSOGeometry::level (CSO *cso)
 Determines the normal and the center of gravity of the given CSO. More...
 
MLCSO_EXPORT void ml::CSOGeometry::level (std::vector< Vector3 > &positions)
 Levels the given positions so that they all lie on the average plane of the input positions. More...
 
MLCSO_EXPORT void ml::CSOGeometry::levelToPlane (CSO &cso, const Vector3 &normal, const Vector3 &planeAnchorPoint)
 Projects all seed points and all path points to the plane that is defined by the given normal and plane anchor point. More...
 
MLCSO_EXPORT std::vector< Vector2 > ml::CSOGeometry::projectTo2D (const std::vector< Vector3 > &points, const Vector3 &normal, const Vector3 &planeAnchorPoint)
 Projects the 3D points to 2D by subtracting planeAnchorPoint, rotating from the normal vector to (0,0,1) and discarding the z positions. More...
 
MLCSO_EXPORT std::vector< Vector3 > ml::CSOGeometry::backprojectTo3D (const std::vector< Vector2 > &points, const Vector3 &normal, const Vector3 &planeAnchorPoint)
 Back-projects the 2D points to 3D by rotating from (0,0,1) to the normal vector and adding planeAnchorPoint. More...
 
MLCSO_EXPORT double ml::CSOGeometry::getLargestDistanceBetweenAllPathPoints (CSO &cso, Vector3 &point0, Vector3 &point1)
 Returns the largest distance between any of the path points of the CSO. More...
 
MLCSO_EXPORT void ml::CSOGeometry::translate (CSO *cso, const Vector3 &translation)
 Translates a CSO with all its seed- and path points by the given translation vector. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::isPointInsidePolygon (const std::vector< Vector3 > &polygonPoints, const Vector3 &point)
 Returns whether a point is inside the polygon defined by the given list of positions. More...
 
MLCSO_EXPORT void ml::CSOGeometry::appendUniquePosition (std::vector< Vector3 > &positions, Vector3 pos)
 Appends a new point to the given vector without double insertions. More...
 
MLCSO_EXPORT Vector3 ml::CSOGeometry::getCenterOfGravity (CSO *cso, bool considerSeedPointsExtra=false)
 Returns the center of gravity of a given CSO. More...
 
MLCSO_EXPORT Vector3 ml::CSOGeometry::getCenterOfGravity (const std::vector< Vector3 > &positions)
 Returns the center of gravity of the given positions. More...
 
MLCSO_EXPORT double ml::CSOGeometry::distanceToLine (const Vector3 &point, const Vector3 &linePoint1, const Vector3 &linePoint2)
 Computes distance of point to (infinite) line given by two other points: More...
 
MLCSO_EXPORT double ml::CSOGeometry::squaredDistanceToLineSegment (const Vector3 &point, const Vector3 &linePoint1, const Vector3 &linePoint2)
 Computes the squared distance of point to line segment given by two other points. More...
 
MLCSO_EXPORT double ml::CSOGeometry::squaredDistanceToLineSegment (const Vector3 &point, const Vector3 &linePoint1, const Vector3 &linePoint2, Vector3 &resultPoint)
 Computes the squared distance of point to line segment given by two other points. More...
 
MLCSO_EXPORT double ml::CSOGeometry::squaredDistanceToLineSegment (const Vector2 &point, const Vector2 &linePoint1, const Vector2 &linePoint2)
 Computes the squared distance of point to line segment given by two other points. More...
 
MLCSO_EXPORT void ml::CSOGeometry::computeClosestSeedPoint (CSO *cso, const Vector3 &referencePoint, unsigned int &resultSeedPointIndex)
 Returns the closest point on a cso to the given reference point. More...
 
MLCSO_EXPORT void ml::CSOGeometry::computeClosestPathPoint (CSO *cso, const Vector3 &referencePoint, unsigned int &resultPathPointListIndex, unsigned int &resultPathPointIndex, Vector3 &resultPosition)
 Returns the closest path point of a cso to the given reference point without interpolation. More...
 
MLCSO_EXPORT void ml::CSOGeometry::computeClosestPoint (CSO *cso, const Vector3 &referencePoint, unsigned int &resultPathPointListIndex, unsigned int &resultPathPointIndex, Vector3 &resultPosition)
 Returns the closest point on a cso to the given reference point. Interpolates the closest point on the line segments. More...
 
MLCSO_EXPORT void ml::CSOGeometry::computeClosestPoint (const std::vector< Vector3 > &pointList, const Vector3 &referencePoint, unsigned int &resultPointIndex, Vector3 &resultPosition)
 Returns the closest point on the given list of positions. More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeDistance (CSO *cso, const Vector3 &referencePoint)
 Returns the distance of the given point to the given CSO . More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeLength (const CSOPathPointIterator &startIter, const CSOPathPointIterator &endIter)
 Computes the length of a CSO between two PathPointIterators. More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeDiameter (const CSO *cso)
 Computes the maximum distance between any two path points in the given CSO. More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeDiameter (const std::vector< Vector3 > &positions)
 Computes the maximum distance between any two points in the given vector. More...
 
MLCSO_EXPORT void ml::CSOGeometry::thinOutCSO (CSO *cso, float quality=0.5f, ReductionMode reductionMode=REDUCTION_MODE_ANGLE_AND_LENGTH, unsigned int minPoints=5, float maxAngleLimit=1.0)
 Thins out the given cso by removing all positions that do not contribute to the overall geometry (angle and length criterion). More...
 
MLCSO_EXPORT void ml::CSOGeometry::thinOutPointList (std::vector< Vector3 > &positionList, float quality=0.5f, ReductionMode reductionMode=REDUCTION_MODE_ANGLE_AND_LENGTH, unsigned int minPoints=5, float maxAngleLimit=1.0)
 Thins out the given list of positions by removing all positions that do not contribute to the overall geometry (angle and length criterion). More...
 
MLCSO_EXPORT bool ml::CSOGeometry::csoIsEnclosedByCSO (CSO *toTestInnerCSO, CSO *toTestOuterCSO)
 Returns whether the first given CSO lies fully within the second given CSO without crossing. More...
 
MLCSO_EXPORT size_t ml::CSOGeometry::getLevelOfEmbedding (const CSOListPtr &csoList, std::vector< size_t > &result)
 Writes the level of embedding of the CSOs in the given CSOList into the given vector of integers. More...
 
MLCSO_EXPORT size_t ml::CSOGeometry::getLevelOfEmbedding (const std::vector< CSO * > &csos, std::vector< size_t > &result, std::vector< std::vector< size_t > > &enclosedCSOIndices)
 Extension of getLevelOfEmbedding which also records the indices of the CSOs enclosed by each CSO. More...
 
MLCSO_EXPORT void ml::CSOGeometry::groupByLevelOfEmbedding (const std::vector< CSO * > &csos, std::vector< std::vector< CSO * > > &groupedCSOs)
 Arranges the given CSOs into a vector of vectors so that CSOs embedded into each other are grouped together with increasing level of embedding. More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeSumOfAreas (const CSOListPtr &csoList)
 Returns the sum of areas of all CSOs in csoList. Area is counted negative if level of embedding is odd. More...
 
MLCSO_EXPORT double ml::CSOGeometry::computeVolume (const CSOListPtr &csoList, double sliceThickness)
 Returns the sum of areas of all CSOs in csoList, multiplied by the given sliceThickness, in ml. More...
 
MLCSO_EXPORT bool ml::CSOGeometry::isApproximatelyParallel (const CSO *cso, const Vector3 &normal, double epsilon=0.1)
 Returns whether the given CSO is approximately parallel to a plane given by the normal vector. More...
 
template<class T >
bool ml::CSOGeometry::isSamePosition (const T &pos1, const T &pos2)
 Returns true if the two positions are considered equal as points of a CSO. More...
 

Variables

const double ml::CSOGeometry::maxPointDiff = 10e-6
 Maximum distance of 2 points in each axis to be considered equal. More...
 
const unsigned int ml::CSOGeometry::INVALID_INDEX = static_cast<unsigned int>(-1)
 A symbolic value that indicates an invalid index (-1). More...