231 static_assert(std::is_same_v<T, Vector3> || std::is_same_v<T, Vector4>,
"Need Vector3 or Vector4 type");
275 bool _shouldPreservePlane;
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
CSOHeapObject: base class for objects to be used with the heap.
MLCSO_EXPORT void disable()
Disables the plane guard, so that level method is not called.
MLCSO_EXPORT ~CSOPlaneGuard()
MLCSO_EXPORT CSOPlaneGuard(CSO &cso)
Small helper class that can be used to keep a CSO in its original plane.
The CSO represents a contour segmentation object.
Class to handle Rotations (internally, the rotation is stored as a unit quaternion)
#define ML_REFCOUNTED_PTR(CLASSNAME)
Macro that defines convenience Ptr/ConstPtr typedefs to be used instead of intrusive_ptr templates.
long double fabs(__int64 i)
MLCSO_EXPORT void translate(CSO *cso, const Vector3 &translation)
Translates a CSO with all its seed- and path points by the specified translation vector.
MLCSO_EXPORT double computeVolume(const CSOListPtr &csoList, double sliceThickness)
Returns the sum of areas of all CSOs in csoList, multiplied by the specified sliceThickness,...
MLCSO_EXPORT bool areInSamePlane(const CSO *cso0, const CSO *cso1, MLdouble angleEpsilon=10e-5, MLdouble minPlaneDistanceInMM=10e-5)
Returns whether the two specified CSOs lie in the same plane.
@ REDUCTION_MODE_ANGLE_AND_LENGTH
MLCSO_EXPORT bool isSelfIntersecting(const std::vector< Vector3 > &positions, std::vector< Vector3 > &intersectPoints, bool isClosed)
Returns whether the specified list of points interpreted as a contour intersects itself.
MLCSO_EXPORT void appendUniquePosition(std::vector< Vector3 > &positions, Vector3 pos)
Appends a new point to the specified vector without double insertions.
MLCSO_EXPORT void 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 specified normal and...
MLCSO_EXPORT void computeClosestSeedPoint(CSO *cso, const Vector3 &referencePoint, unsigned int &resultSeedPointIndex)
Returns the closest point on a CSO to the specified reference point.
MLCSO_EXPORT double computeSumOfAreas(const CSOListPtr &csoList)
Returns the sum of areas of all CSOs in csoList. Area is counted negative if level of embedding is od...
bool isInSegment(const Vector2 &point, const Vector2 &segmentStart, const Vector2 &segmentEnd)
Helper function for intersect2DSegments.
MLCSO_EXPORT size_t getLevelOfEmbedding(const CSOListPtr &csoList, std::vector< size_t > &result)
Writes the level of embedding of the CSOs in the specified CSOList into the specified vector of integ...
MLdouble perp(const Vector2 &v0, const Vector2 &v1)
Helper function for intersect2DSegments.
MLCSO_EXPORT void rotateAndProject(Rotation &rot, Vector3 &voxelPos, bool shouldProject=true)
Transforms and projects a voxelPos according to a rotation.
MLCSO_EXPORT void computeClosestPoint(CSO *cso, const Vector3 &referencePoint, unsigned int &resultPathPointListIndex, unsigned int &resultPathPointIndex, Vector3 &resultPosition)
Returns the closest point on a CSO to the specified reference point. Interpolates the closest point o...
MLCSO_EXPORT void groupByLevelOfEmbedding(const std::vector< CSO * > &csos, std::vector< std::vector< CSO * > > &groupedCSOs)
Arranges the specified CSOs into a vector of vectors so that CSOs embedded into each other are groupe...
MLCSO_EXPORT bool isPointInsidePolygon(const std::vector< Vector3 > &polygonPoints, const Vector3 &point)
Returns whether a point is inside the polygon defined by the specified list of positions.
const unsigned int INVALID_INDEX
A symbolic value that indicates an invalid index (-1).
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)
Thins out the specified CSO by removing all positions that do not contribute to the overall geometry ...
MLCSO_EXPORT double distanceToLine(const Vector3 &point, const Vector3 &linePoint1, const Vector3 &linePoint2)
Computes distance of point to (infinite) line specified by two other points.
MLCSO_EXPORT double computeDiameter(const CSO *cso)
Computes the maximum distance between any two path points in the specified CSO.
MLCSO_EXPORT bool canFormPlane(const Vector3 &vec1, const Vector3 &vec2, double epsilon=1e-3)
Returns whether both given vectors can form a plane, i.e., are not collinear or any of the vector is ...
MLCSO_EXPORT void computeClosestPathPoint(CSO *cso, const Vector3 &referencePoint, unsigned int &resultPathPointListIndex, unsigned int &resultPathPointIndex, Vector3 &resultPosition)
Returns the closest path point of a CSO to the specified reference point without interpolation.
MLCSO_EXPORT double computeDistance(CSO *cso, const Vector3 &referencePoint)
Returns the distance of the specified point to the specified CSO.
MLCSO_EXPORT double squaredDistanceToLineSegment(const Vector3 &point, const Vector3 &linePoint1, const Vector3 &linePoint2)
Computes the squared distance of point to line segment specified by two other points.
MLCSO_EXPORT double getLargestDistanceBetweenAllPathPoints(CSO &cso, Vector3 &point0, Vector3 &point1)
Returns the largest distance between any of the path points of the CSO.
MLCSO_EXPORT void level(CSO *cso)
Determines the normal and the center of gravity of the specified CSO.
const double maxPointDiff
Maximum distance of two points in each axis to be considered equal.
MLCSO_EXPORT std::vector< Vector3 > 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 planeAncho...
MLCSO_EXPORT void orthogonalizePreserveLength(const Vector3 &reference, Vector3 &toAdjust)
Makes the specified vector toAdjust perpendicular to the specified reference vector while preserving ...
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)
Thins out the specified list of positions by removing all positions that do not contribute to the ove...
MLCSO_EXPORT bool 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.
bool isSamePosition(const T &pos1, const T &pos2)
Returns whether the two positions are considered equal as points of a CSO.
MLCSO_EXPORT bool computeIsInPlane(const CSO *cso, Vector3 &planeNormal, double angleEpsilon=1e-3, double collinearEpsilon=1e-3)
Returns whether all path points lie in one plane, and fills the plane normal.
MLCSO_EXPORT double computeLength(const CSOPathPointIterator &startIter, const CSOPathPointIterator &endIter)
Computes the length of a CSO between two PathPointIterators.
MLCSO_EXPORT bool csoIsEnclosedByCSO(CSO *toTestInnerCSO, CSO *toTestOuterCSO)
Returns whether the first specified CSO lies fully within the second specified CSO without crossing.
MLCSO_EXPORT int intersect2DSegments(const Vector2 &start0, const Vector2 &end0, const Vector2 &start1, const Vector2 &end1, Vector2 &intersection0, Vector2 &intersection1)
Computes whether the two specified 2D segments intersect; if they intersect, the intersection point i...
MLCSO_EXPORT Vector3 getCenterOfGravity(CSO *cso, bool considerSeedPointsExtra=false)
Returns the center of gravity of a specified CSO.
MLCSO_EXPORT bool isApproximatelyParallel(const CSO *cso, const Vector3 &normal, double epsilon=0.1)
Returns whether the specified CSO is approximately parallel to a plane specified by the normal vector...
MLCSO_EXPORT bool arePointsCollinear(const std::vector< Vector3 > &points, double epsilon)
Returns whether all points are collinear.
MLCSO_EXPORT Vector3 computeNewellsNormal(const std::vector< Vector3 > &points)
Returns a normal for the specified list of points using Newell's method.
MLCSO_EXPORT void rotateAroundAxis(const Vector3 &axis, const Vector3 ¢erPoint, Vector3 &pointToRotate, double angleInRadian)
Rotates the specified pointToRotate around the axis originating from centerPoint by angleInRadian.
MLCSO_EXPORT std::vector< Vector2 > 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,...