OptoInspect3D Inline - alg3Dlib  3.4.0
Library for measured 3D data processing
Data Structures | Enumerations | Functions
Preprocessing and filtering

This module contains functions to smooth, homogenize point clouds, compute features and normal vectors. More...

Data Structures

struct  ALG3D_Intersection
 Intersection between a ray and a triangle mesh. More...
 

Enumerations

enum  SmoothingMethod { Gaussian, ShapePreserving, EdgePreserving }
 Enum to select a smoothing method. More...
 
enum  SurfaceFeatureType { IntrinsicCurvature, ExtrinsicCurvature, LocalEdges, LocalDensity }
 Enum to select a surface feature type. More...
 

Functions

int __cdecl ALG3D_createMesh (const ALG3D_Point3d *data, size_t *indices, size_t numTriangles, ALG3D_MESH *mesh)
 Builds a mesh from given points and indices. Three consecutive entries in the indices array define the indices of the 3 points (in the data array) of a single triangle. More...
 
int __cdecl ALG3D_getNumberOfTriangles (const ALG3D_MESH mesh, size_t *numTriangles)
 Retrieves the number of triangles in a mesh. This number does not need to be the same as the one used in ALG3D_createMesh, since the mesh structure is optimized during the creation (invalid triangles are removed). More...
 
int __cdecl ALG3D_getTrianglePoints (const ALG3D_MESH mesh, size_t triangleIndex, ALG3D_Point3d *a, ALG3D_Point3d *b, ALG3D_Point3d *c)
 Retrieves the 3 vertices of a triangle in a mesh. Use this function to get the triangle (points), returned as an index by the ALG3D_raytracing_* functions. More...
 
int __cdecl ALG3D_createMeshTree (const ALG3D_MESH mesh, ALG3D_MESHTREE *meshTree)
 Builds a kdTree from a mesh. More...
 
int __cdecl ALG3D_freeMesh (ALG3D_MESH mesh)
 Releases memory of a given mesh object. It's up to the application to ensure that the pointer is valid. More...
 
int __cdecl ALG3D_freeMeshTree (ALG3D_MESHTREE meshTree)
 Releases memory of a given kdTree (mesh) object. It's up to the application to ensure that the pointer is valid. More...
 
int __cdecl ALG3D_findNearestPoint2Mesh (const ALG3D_MESHTREE meshTree, double radius, ALG3D_Point3d pt, ALG3D_Point3d *nn)
 Finds the nearest neighbour within a query radius to a given point. More...
 
int __cdecl ALG3D_findNearestPointAndTriangle2Mesh (const ALG3D_MESHTREE meshTree, double radius, ALG3D_Point3d pt, ALG3D_Point3d *nn, size_t *triangleIndex)
 Finds the nearest neighbour and corresponding triangle index within a query radius to a given point. More...
 
int __cdecl ALG3D_computeDistances2Mesh (const ALG3D_MESHTREE meshTree, const ALG3D_Point3d *pts, size_t numPts, double maxDistance, double *distances)
 Computes all signed distances of a point set to a mesh given as a kd-tree. More...
 
int __cdecl ALG3D_sampleMesh (const ALG3D_MESH mesh, size_t numSamples, ALG3D_Point3d **points, size_t *numPts)
 Samples a mesh uniformly with a given number of points. More...
 
int __cdecl ALG3D_sampleMeshNormals (const ALG3D_MESH mesh, size_t numSamples, ALG3D_Point3d **points, ALG3D_Point3d **normals, size_t *numPts)
 Samples a mesh uniformly with a given number of points and generates normal vectors at the samples. More...
 
int __cdecl ALG3D_sampleMeshDensity (const ALG3D_MESH mesh, double density, ALG3D_Point3d **points, size_t *numPts)
 Samples a mesh uniformly with a given density of points. More...
 
int __cdecl ALG3D_sampleMeshDensityNormals (const ALG3D_MESH mesh, double density, ALG3D_Point3d **points, ALG3D_Point3d **normals, size_t *numPts)
 Samples a mesh uniformly with a given density of points and generates normal vectors at the samples. More...
 
int __cdecl ALG3D_raytracing_doesIntersect (const ALG3D_MESHTREE meshTree, ALG3D_Point3d rayOrigin, ALG3D_Point3d rayDirection, double maxHitDistance, int *doesIntersect)
 Checks if a ray intersects with a mesh. More...
 
int __cdecl ALG3D_raytracing_firstIntersection (const ALG3D_MESHTREE meshTree, ALG3D_Point3d rayOrigin, ALG3D_Point3d rayDirection, double maxHitDistance, ALG3D_Intersection *intersection, int *doesIntersect)
 Computes the first intersection between a ray and a mesh. More...
 
int __cdecl ALG3D_raytracing_allIntersections (const ALG3D_MESHTREE meshTree, ALG3D_Point3d rayOrigin, ALG3D_Point3d rayDirection, double maxHitDistance, ALG3D_Intersection **intersections, size_t *numIntersections)
 Computes all intersections between a ray and a mesh. More...
 
int __cdecl ALG3D_subdivideLongEdges (const ALG3D_Point3d *points, size_t *indices, size_t numTriangles, ALG3D_Point3d **newPoints, size_t **newIndices, size_t *newNumTriangles, double maxEdgeLength)
 Subdivides all edges that are too long. More...
 
int ALG3D_computeConnectedRegions (const ALG3D_Point3d *ptsIn, size_t numIn, double radius, size_t *regionIdx, size_t *numIdx)
 Computes spatially connected points and isolated regions. More...
 
int ALG3D_computeConnectedRegionsTree (const ALG3D_KDTREE tree, double radius, size_t *regionIdx, size_t *numIdx)
 Computes spatially connected points and isolated regions using a precomputed KdTree. More...
 
int ALG3D_computeThinningToNeighborhood (ALG3D_Point3d *pts, size_t *numPts, double radius)
 Computes a homogeneous thinning of 3d point set to a given radius (neighborhood). More...
 
int ALG3D_computeThinningToPointNumber (ALG3D_Point3d *pts, size_t *numPts, size_t resultingNumPoints)
 Computes a homogeneous thinning of 3d point set to a given number of resulting points. More...
 
int ALG3D_computeSmoothedThinning (ALG3D_Point3d *pts, size_t *numPts, double radius)
 Computes a combined homogeneous thinning and smoothing of a 3d point set. More...
 
int ALG3D_computeSmoothing (const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *ptsOut, double radius, SmoothingMethod method)
 Computes an edge preserving smoothing of point cloud given by a KD-Tree. More...
 
int ALG3D_computeNormalVectors (const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, double radius)
 Computes surface normals for the given pointcloud within a neighborhood defined by a radius. More...
 
int ALG3D_computeNormalVectorsTree (const ALG3D_KDTREE tree, ALG3D_Point3d *normals, double radius)
 Computes surface normals for the given pointcloud (represented by its KdTree) within a neighborhood defined by a radius. More...
 
int ALG3D_computeNormalVectorsFast (const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, double radius)
 Computes surface normals for the given pointcloud within a neighborhood defined by a radius. More...
 
int ALG3D_computeNormalVectorsTreeFast (const ALG3D_KDTREE tree, ALG3D_Point3d *normals, double radius)
 Computes surface normals vector for the given pointcloud (represented by its KdTree) within a neighborhood defined by a radius. More...
 
int ALG3D_computeNormalVectorsKNN (const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, size_t maxPoints)
 Computes surface normals vector for the given pointcloud from K-Nearest-Neighbours. More...
 
int ALG3D_computeNormalVectorsKNNFast (const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, size_t maxPoints)
 Computes surface normals vector for the given pointcloud from K-Nearest-Neighbours. More...
 
int ALG3D_computeNormalVectorsKNNTree (const ALG3D_KDTREE tree, ALG3D_Point3d *normals, size_t maxPoints)
 Computes surface normals vector for the given pointcloud (represented by its KdTree) from K-Nearest-Neighbours. More...
 
int ALG3D_computeNormalVectorsKNNTreeFast (const ALG3D_KDTREE tree, ALG3D_Point3d *normals, size_t maxPoints)
 Computes surface normals vector for the given pointcloud (represented by its KdTree) from K-Nearest-Neighbours. More...
 
int ALG3D_computeOutlierFactor (const ALG3D_Point3d *pts, size_t numPts, double *values, size_t maxPoints)
 Computes the local outlier factors of the points from a point cloud. More...
 
int ALG3D_computeOutlierFactorTree (const ALG3D_KDTREE tree, double *values, size_t maxPoints)
 Computes the local outlier factor of the points from a point cloud (represented by its KdTree). More...
 
int ALG3D_removeOutliers (ALG3D_Point3d *pts, size_t *numPts, size_t maxPoints, double thresh)
 Remove outliers from the point cloud. More...
 
int ALG3D_removeOutliersTree (ALG3D_KDTREE tree, size_t maxPoints, double thresh)
 Remove outliers from the point cloud. More...
 
int ALG3D_computeSurfaceFeatures (const ALG3D_Point3d *pts, size_t numPts, double *values, double radius, SurfaceFeatureType type)
 Computes surface features for each point of a given point set within a neighborhood defined by a radius. More...
 
int ALG3D_computeSurfaceFeaturesFast (const ALG3D_Point3d *pts, size_t numPts, double *values, double radius, SurfaceFeatureType type)
 Computes surface features for each point of a given point set within a neighborhood defined by a radius. More...
 
int ALG3D_computeSurfaceFeaturesTree (const ALG3D_KDTREE tree, double *values, double radius, SurfaceFeatureType type)
 Computes surface features for each point of a given point set (represented by its KdTree) within a neighborhood defined by a radius. More...
 
int ALG3D_computeSurfaceFeaturesTreeFast (const ALG3D_KDTREE tree, double *values, double radius, SurfaceFeatureType type)
 Computes surface features for each point of a given point set (represented by its KdTree) within a neighborhood defined by a radius. More...
 
int ALG3D_computeSurfaceFeaturesKNN (const ALG3D_Point3d *pts, size_t numPts, double *values, size_t maxPoints, SurfaceFeatureType type)
 Computes surface features for each point of a given point set from K-Nearest-Neighbours. More...
 
int ALG3D_computeSurfaceFeaturesKNNFast (const ALG3D_Point3d *pts, size_t numPts, double *values, size_t maxPoints, SurfaceFeatureType type)
 Computes surface features for each point of a given point set from K-Nearest-Neighbours. More...
 
int ALG3D_computeSurfaceFeaturesKNNTree (const ALG3D_KDTREE tree, double *values, size_t maxPoints, SurfaceFeatureType type)
 Computes surface features for each point of a given point set (represented by its KdTree) from K-Nearest-Neighbours. More...
 
int ALG3D_computeSurfaceFeaturesKNNTreeFast (const ALG3D_KDTREE tree, double *values, size_t maxPoints, SurfaceFeatureType type)
 Computes surface features for each point of a given point set (represented by its KdTree) from K-Nearest-Neighbours. More...
 
int ALG3D_createKdTree (const ALG3D_Point3d *data, size_t numPts, ALG3D_KDTREE *tree)
 Builds a kdTree from given 3D data. More...
 
int ALG3D_freeKdTree (ALG3D_KDTREE tree)
 Releases memory of a given kdTree object. It's up to the application to ensure that the pointer is valid. More...
 
int ALG3D_findNearestNeighbor (const ALG3D_KDTREE tree, ALG3D_Point3d pt, double radius, ALG3D_Point3d *nn)
 Finds the nearest neighbour within a query radius to a given point and uses a given KD-Tree. More...
 
int ALG3D_findNearestNormalCompatibleNeighbor (const ALG3D_KDTREE tree, const ALG3D_Point3d *treeNormals, ALG3D_Point3d pt, ALG3D_Point3d ptNormal, double radius, double minimumDotProduct, ALG3D_Point3d *nn)
 Finds the nearest neighbour within a query radius to a given point with a compatible normal and uses a given KD-Tree. More...
 
int ALG3D_findKNearestNeighbors (const ALG3D_KDTREE tree, ALG3D_Point3d pt, size_t maxPoints, ALG3D_Point3d **vNN, size_t *numNN)
 Finds the k-nearest neighboring points to a given point. More...
 
int ALG3D_findKNearestNormalCompatibleNeighbors (const ALG3D_KDTREE tree, const ALG3D_Point3d *treeNormals, ALG3D_Point3d pt, ALG3D_Point3d ptNormal, size_t maxPoints, double minimumDotProduct, ALG3D_Point3d **vNN, size_t *numNN)
 Finds the k-nearest neighboring points with compatible normal vectors to a given point. More...
 
int ALG3D_findNeighbors (const ALG3D_KDTREE tree, ALG3D_Point3d pt, double radius, ALG3D_Point3d **vNN, size_t *numNN)
 Finds all neighboring points within a query radius to a given point using a given KD-Tree. More...
 
int ALG3D_findNormalCompatibleNeighbors (const ALG3D_KDTREE tree, const ALG3D_Point3d *treeNormals, ALG3D_Point3d pt, ALG3D_Point3d ptNormal, double radius, double minimumDotProduct, ALG3D_Point3d **vNN, size_t *numNN)
 Finds all neighboring points within a query radius with compatible normal vectors to a given point using a given KD-Tree. More...
 
int ALG3D_findNeighborsBox (const ALG3D_KDTREE tree, ALG3D_Point3d pt, double vDist[3], ALG3D_Point3d **vNN, size_t *numNN)
 Finds all neighbouring points within a box around a given point and uses a given KD-Tree. More...
 
int ALG3D_computeDistances2Pointcloud (const ALG3D_KDTREE tree, const ALG3D_Point3d *pts, size_t numPts, double maxDistance, double *distances)
 Computes all distance of a point set to another point set given as a kd-tree. More...
 
int ALG3D_computeThinningTree (ALG3D_KDTREE tree, double radius)
 Computes the homogeneous thinning of a point cloud given by a KdTree. More...
 
int ALG3D_computeCurvatureThinning (ALG3D_Point3d *pts, size_t *numPts, double maxRadius, double minRadius)
 Computes a curvature based thinning of a 3d point set. More...
 
int ALG3D_computeCurvatureThinningFast (ALG3D_Point3d *pts, size_t *numPts, double maxRadius, double minRadius)
 Computes a curvature based thinning of a 3d point set. More...
 
int ALG3D_computeSmoothingTree (const ALG3D_KDTREE tree, ALG3D_Point3d *ptsOut, double radius, SmoothingMethod method)
 Computes the smoothing of point cloud given by a KD-Tree. More...
 

Detailed Description

This module contains functions to smooth, homogenize point clouds, compute features and normal vectors.


Data Structure Documentation

◆ ALG3D_Intersection

struct ALG3D_Intersection

Intersection between a ray and a triangle mesh.

Data Fields
ALG3D_Point3d intersection Point of intersection of the ray with the mesh.
double t Distance along the ray (t parameter from ray equation: o + t*d).
size_t triangleIndex Index of the intersected triangle (use ALG3D_getTrianglePoints to retrieve the corresponding triangle points)

Enumeration Type Documentation

◆ SmoothingMethod

#include <algorithm.h>

Enum to select a smoothing method.

Enumerator
Gaussian 

Gaussian weighted mean (fast, but does not preserve shape or features)

ShapePreserving 

Shape preserving Gaussian smoothing.

EdgePreserving 

Shape and edge preserving smoothing.

◆ SurfaceFeatureType

#include <algorithm.h>

Enum to select a surface feature type.

Enumerator
IntrinsicCurvature 

Curvature value that is derived from the directions and the magnitudes of variance of the local neighborhood. The values vary between 0 and 1 (typically 0.1 already indicates an edge).

ExtrinsicCurvature 

Curvature value that is derived from the inverse radius of the sphere which is representing/touching the local neighborhood around each point. It is always positive.

LocalEdges 

Magnitude of a Difference-of-Gaussian filter for each point within a local neighborhood. Very useful to detect the border points of holes.

LocalDensity 

Density value defined as (number of points) / (size of local surface area). Helps to estimate the local point distribution and redundant/overlaying scan areas.

Function Documentation

◆ ALG3D_computeConnectedRegions()

int ALG3D_computeConnectedRegions ( const ALG3D_Point3d ptsIn,
size_t  numIn,
double  radius,
size_t *  regionIdx,
size_t *  numIdx 
)

#include <algorithm.cpp>

Computes spatially connected points and isolated regions.

code example
const char* fname = "./sample_data/testData.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
size_t* vRegionIdx = 0; //pointer to array of indices
size_t numIdx = 0; //number of indices in array
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the region indices (one index indicates the region of one point)
vRegionIdx = (size_t*)malloc(ptsVec*sizeof(size_t));
//compute regions
if (!ALG3D_checkResult(ALG3D_computeConnectedRegions(vec, ptsVec, 1.0, vRegionIdx, &numIdx))) return 0;
printf("regions found: %I64d\n", numIdx);
Parameters
ptsInpointer to input points
numInnumber of input points
radiusradius/maximum allowed distance of a point to a region in order to belong to this region
regionIdxpointer to a vector of indices with a pre-allocated size of numIn. For each point in ptsIn it contains the index of the region he belongs. The index of the first region is 0.
numIdxnumber of regions found
Returns
ERR_NONE on success

◆ ALG3D_computeConnectedRegionsTree()

int ALG3D_computeConnectedRegionsTree ( const ALG3D_KDTREE  tree,
double  radius,
size_t *  regionIdx,
size_t *  numIdx 
)

#include <algorithm.cpp>

Computes spatially connected points and isolated regions using a precomputed KdTree.

code example
const char* fname = "./sample_data/testData.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
size_t* vRegionIdx = 0; //pointer to array of indices
size_t numIdx = 0; //number of indices in array
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the region indices (one index indicates the region of one point)
vRegionIdx = (size_t*)malloc(ptsVec*sizeof(size_t));
//compute regions
if (!ALG3D_checkResult(ALG3D_computeConnectedRegionsTree(tree, 1.0, vRegionIdx, &numIdx))) return 0;
printf("regions found: %I64d\n", numIdx);
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
radiusradius/maximum allowed distance of a point to a region in order to belong to this region
regionIdxpointer to a pre-allocated vector of indices. The number of preallocated indices must be at least the number of points from which the tree was created. For each point of the tree it contains the index of the region he belongs. The index of the first region is 0.
numIdxnumber of regions found
Returns
ERR_NONE on success

◆ ALG3D_computeCurvatureThinning()

int ALG3D_computeCurvatureThinning ( ALG3D_Point3d pts,
size_t *  numPts,
double  maxRadius,
double  minRadius 
)

#include <algorithm.cpp>

Computes a curvature based thinning of a 3d point set.

The method successively removes points from the local neighbourhood defined by the radius. The radius is adapted to the local curvature around a points. If a points is located in a highly curved region the thinning radius is reduced and fewer points are removed. The radius is interpolated between the two parameters maxRadius and minRadius. In regions with no curvature maxRadius is used. In regions with a very high curvature minRadius is used. You can specify a value greater than 0 for minRadius to ensure that no matter how strong the curvature is, the remaining points will have at least this distance to each other.

The memory provided as input is reused but its size will not be not changed. Instead the parameter numPts returns the new number of points which is equal or smaller than the number of input points. The elements after the new end are still dereferencable but their value is unpecified. It is in the responsibility of the calling application to reduce the used memory to the new size.

code example
//read 3d point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//compute normal thinning
printf("points before: %I64d\n", ptsVec);
if (!ALG3D_checkResult(ALG3D_computeCurvatureThinning(vec, &ptsVec, 2.0, 0.25))) return 0;
printf("points after: %I64d\n", ptsVec);
Parameters
[in,out]ptspointer to points
[in,out]numPtsnumber of points
[in]maxRadiusMaximum thinning radius
[in]minRadiusMinimum thinning radius (use 0 as a default)
Returns
ERR_NONE on success

◆ ALG3D_computeCurvatureThinningFast()

int ALG3D_computeCurvatureThinningFast ( ALG3D_Point3d pts,
size_t *  numPts,
double  maxRadius,
double  minRadius 
)

#include <algorithm.cpp>

Computes a curvature based thinning of a 3d point set.

The method successively removes points from the local neighbourhood defined by the radius. The radius is adapted to the local curvature around a points. If a points is located in a highly curved region the thinning radius is reduced and fewer points are removed. The radius is interpolated between the two parameters maxRadius and minRadius. In regions with no curvature maxRadius is used. In regions with a very high curvature minRadius is used. You can specify a value greater than 0 for minRadius to ensure that no matter how strong the curvature is, the remaining points will have at least this distance to each other.

The memory provided as input is reused but its size will not be not changed. Instead the parameter numPts returns the new number of points which is equal or smaller than the number of input points. The elements after the new end are still dereferencable but their value is unpecified. It is in the responsibility of the calling application to reduce the used memory to the new size.

Note
This function uses an approximation technique to speed up the curvature computations. Depending on the dataset, the computation time can be reduced to 50% of the time of the non-approximating ALG3D_computeCurvatureThinning function.
code example
//read 3d point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//compute normal thinning
printf("points before: %I64d\n", ptsVec);
if (!ALG3D_checkResult(ALG3D_computeCurvatureThinningFast(vec, &ptsVec, 2.0, 0.25))) return 0;
printf("points after: %I64d\n", ptsVec);
Parameters
[in,out]ptspointer to points
[in,out]numPtsnumber of points
[in]maxRadiusMaximum thinning radius
[in]minRadiusMinimum thinning radius (use 0 as a default)
Returns
ERR_NONE on success

◆ ALG3D_computeDistances2Mesh()

int __cdecl ALG3D_computeDistances2Mesh ( const ALG3D_MESHTREE  meshTree,
const ALG3D_Point3d pts,
size_t  numPts,
double  maxDistance,
double *  distances 
)

#include <algorithm.h>

Computes all signed distances of a point set to a mesh given as a kd-tree.

A maximum search distance maybe defined to exclude points from the computation that are potentially to far away (maxDistance > 0). In this case the resulting distance value in distances remains untouched. If instead all distances should be computed than the maximum search distance must be defined as zero (maxDistance = 0) and the algorithms chooses the optimal internal search parameters.

The computed distance are signed. Points inside the mesh have negative distances. The inside/outside decision is based on the normal vector of the triangle that contains the nearest neighbor to the point.

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(refData, indices, numTriangles, &mesh))) return 0;
//create kdTree
if (!ALG3D_checkResult(ALG3D_createMeshTree(mesh, &tree))) return 0;
//allocate storage for the resulting distance values
distances = (double*)malloc(ptsTest*sizeof(double));
for (i = 0; i < ptsTest; ++i){
distances[i] = -1;
}
//compute distances with given search tree
if (!ALG3D_checkResult(ALG3D_computeDistances2Mesh(tree, testData, ptsTest, 0, distances))){
return 0;
}
meanValue = minValue = maxValue = distances[0];
for (i = 1; i < ptsTest; ++i){
const double d = distances[i];
if (d < minValue)minValue = d;
else if (d>maxValue)maxValue = d;
meanValue += d;
}
meanValue /= ptsTest;
printf("[distances]: min: %lf, max: %lf, mean: %lf\n", minValue, maxValue, meanValue);
Parameters
meshTreekdTree containing the mesh
ptspointer to points begin
numPtsnumber of points in pts
maxDistancemaximum search distance (0=auto)
distancespointer to pre-allocated memory (same size as numPts) for storing the resulting distance values
Returns
ERR_NONE on success

◆ ALG3D_computeDistances2Pointcloud()

int ALG3D_computeDistances2Pointcloud ( const ALG3D_KDTREE  tree,
const ALG3D_Point3d pts,
size_t  numPts,
double  maxDistance,
double *  distances 
)

#include <algorithm.cpp>

Computes all distance of a point set to another point set given as a kd-tree.

A maximum search distance maybe defined to exclude points from the computation that are potentially to far away (maxDistance > 0). In this case the resulting distance value in distances remains untouched. The user may initialize the distance array for example with -1 to see for which points distances have been computed and for which not. If instead all distances should be computed than the maximum search distance must be defined as zero (maxDistance = 0) and the algorithms chooses the optimal internal search parameters.

code example
//create kdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(refData, ptsRef, &tree))) return 0;
//allocate storage for the resulting distance values
distances = (double*)malloc(ptsTest*sizeof(double));
for (i = 0; i < ptsTest; ++i){
distances[i] = -1;
}
//compute distances with given search tree
if (!ALG3D_checkResult(ALG3D_computeDistances2Pointcloud(tree, testData, ptsTest, 0, distances))){
return 0;
}
meanValue = minValue = maxValue = distances[0];
for (i = 1; i < ptsTest; ++i){
const double d = distances[i];
if (d < minValue)minValue = d;
else if (d>maxValue)maxValue = d;
meanValue += d;
}
meanValue /= ptsTest;
printf("[distances]: min: %lf, max: %lf, mean: %lf\n", minValue, maxValue, meanValue);
Parameters
treeKD-Tree containing the reference points
ptspointer to points for eich distance are computed
numPtsnumber of points in pts
maxDistancemaximum search distance (0=auto)
distancespointer to pre-allocated memory (same size as numPts) for storing the resulting distance values
Returns
ERR_NONE on success

◆ ALG3D_computeNormalVectors()

int ALG3D_computeNormalVectors ( const ALG3D_Point3d pts,
size_t  numPts,
ALG3D_Point3d normals,
double  radius 
)

#include <algorithm.cpp>

Computes surface normals for the given pointcloud within a neighborhood defined by a radius.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a radius. The algorithm compute a best-fit plane for the neighborhood that represents the local surface.
The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNN(vec, ptsVec, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectors(vec, ptsVec, normals, radius))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
normalspointer to pre-allocated memory (same size as points) for storing the resulting normal vector
radiusradius of the neighborhood around each point
Returns
ERR_NONE on success

◆ ALG3D_computeNormalVectorsFast()

int ALG3D_computeNormalVectorsFast ( const ALG3D_Point3d pts,
size_t  numPts,
ALG3D_Point3d normals,
double  radius 
)

#include <algorithm.cpp>

Computes surface normals for the given pointcloud within a neighborhood defined by a radius.

Note
This function uses an approximation technique to speed up the surface normals computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeNormalVectors function.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a radius. The algorithm compute a best-fit plane for the neighborhood that represents the local surface.
The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNFast(vec, ptsVec, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsFast(vec, ptsVec, normals, radius))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
normalspointer to pre-allocated memory (same size as points) for storing the resulting normal vector
radiusradius of the neighborhood around each point
Returns
ERR_NONE on success

◆ ALG3D_computeNormalVectorsKNN()

int ALG3D_computeNormalVectorsKNN ( const ALG3D_Point3d pts,
size_t  numPts,
ALG3D_Point3d normals,
size_t  maxPoints 
)

#include <algorithm.cpp>

Computes surface normals vector for the given pointcloud from K-Nearest-Neighbours.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a (maximal) number points that should be used. The algorithm finds the maxPoints-nearest neighbours to compute a best-fit plane that represents the local surface.
The algorithm automatically takes care for uneven point distributions and degenerated cases (e.g. if maxPoints are all lying on the same scan line). The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNN(vec, ptsVec, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectors(vec, ptsVec, normals, radius))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
normalspointer to pre-allocated memory (same size as points) for storing the resulting normal vector
maxPointsnumber of K-neighbourhood points that should be used to compute the normal (>= 3)
Returns
ERR_NONE on success, ERR_CONDITION if maxPoints<3

◆ ALG3D_computeNormalVectorsKNNFast()

int ALG3D_computeNormalVectorsKNNFast ( const ALG3D_Point3d pts,
size_t  numPts,
ALG3D_Point3d normals,
size_t  maxPoints 
)

#include <algorithm.cpp>

Computes surface normals vector for the given pointcloud from K-Nearest-Neighbours.

Note
This function uses an approximation technique to speed up the surface normals computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeNormalVectorsKNN function.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a (maximal) number points that should be used. The algorithm finds the maxPoints-nearest neighbours to compute a best-fit plane that represents the local surface.
The algorithm automatically takes care for uneven point distributions and degenerated cases (e.g. if maxPoints are all lying on the same scan line). The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNFast(vec, ptsVec, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsFast(vec, ptsVec, normals, radius))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
normalspointer to pre-allocated memory (same size as points) for storing the resulting normal vector
maxPointsnumber of K-neighbourhood points that should be used to compute the normal (>= 3)
Returns
ERR_NONE on success, ERR_CONDITION if maxPoints<3

◆ ALG3D_computeNormalVectorsKNNTree()

int ALG3D_computeNormalVectorsKNNTree ( const ALG3D_KDTREE  tree,
ALG3D_Point3d normals,
size_t  maxPoints 
)

#include <algorithm.cpp>

Computes surface normals vector for the given pointcloud (represented by its KdTree) from K-Nearest-Neighbours.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a (maximal) number points that should be used. The algorithm finds the maxPoints-nearest neighbours to compute a best-fit plane that represents the local surface.
The algorithm automatically takes care for uneven point distributions and degenerated cases (e.g. if maxPoints are all lying on the same scan line). The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNTree(tree, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsTree(tree, normals, radius))) return 0;
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
normalspointer to pre-allocated memory (same size as number of points of tree) for storing the resulting normal vector
maxPointsnumber of K-neighbourhood points that should be used to compute the normal (>= 3)
Returns
ERR_NONE on success, ERR_CONDITION if maxPoints<3

◆ ALG3D_computeNormalVectorsKNNTreeFast()

int ALG3D_computeNormalVectorsKNNTreeFast ( const ALG3D_KDTREE  tree,
ALG3D_Point3d normals,
size_t  maxPoints 
)

#include <algorithm.cpp>

Computes surface normals vector for the given pointcloud (represented by its KdTree) from K-Nearest-Neighbours.

Note
This function uses an approximation technique to speed up the surface normals computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeNormalVectorsKNNTree function.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a (maximal) number points that should be used. The algorithm finds the maxPoints-nearest neighbours to compute a best-fit plane that represents the local surface.
The algorithm automatically takes care for uneven point distributions and degenerated cases (e.g. if maxPoints are all lying on the same scan line). The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNTreeFast(tree, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsTreeFast(tree, normals, radius))) return 0;
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
normalspointer to pre-allocated memory (same size as number of points of tree) for storing the resulting normal vector
maxPointsnumber of K-neighbourhood points that should be used to compute the normal (>= 3)
Returns
ERR_NONE on success, ERR_CONDITION if maxPoints<3

◆ ALG3D_computeNormalVectorsTree()

int ALG3D_computeNormalVectorsTree ( const ALG3D_KDTREE  tree,
ALG3D_Point3d normals,
double  radius 
)

#include <algorithm.cpp>

Computes surface normals for the given pointcloud (represented by its KdTree) within a neighborhood defined by a radius.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a radius. The algorithm compute a best-fit plane for the neighborhood that represents the local surface.
The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNTree(tree, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsTree(tree, normals, radius))) return 0;
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
normalspointer to pre-allocated memory (same size as number of points of tree) for storing the resulting normal vector
radiusradius of the neighborhood around each point
Returns
ERR_NONE on success

◆ ALG3D_computeNormalVectorsTreeFast()

int ALG3D_computeNormalVectorsTreeFast ( const ALG3D_KDTREE  tree,
ALG3D_Point3d normals,
double  radius 
)

#include <algorithm.cpp>

Computes surface normals vector for the given pointcloud (represented by its KdTree) within a neighborhood defined by a radius.

Note
This function uses an approximation technique to speed up the surface normals computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeNormalVectorsTree function.

This functions implements an algorithm to efficiently compute local surface normal vectors for each given point. The size of the local neighbourhood is defined by a radius. The algorithm compute a best-fit plane for the neighborhood that represents the local surface.
The normal vector of the approximated plane is assumed to be the normal vector of the surface at this position. The sign of the normal vector is not unique (pointing inside or outside) and may be flipped using a-priori knowledge from the scanning process (e.g. depending on scanner position relative to surface).

code example
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise normal vectors
normals = (ALG3D_Point3d*)malloc(ptsVec*sizeof(ALG3D_Point3d));
//a)compute normals using K-Nearest-Neighbours
const size_t K = 25;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNTreeFast(tree, normals, K))) return 0;
//b)compute normals using radial neighborhood
const double radius = 1.0;
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsTreeFast(tree, normals, radius))) return 0;
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
normalspointer to pre-allocated memory (same size as number of points of tree) for storing the resulting normal vector
radiusradius of the neighborhood around each point
Returns
ERR_NONE on success

◆ ALG3D_computeOutlierFactor()

int ALG3D_computeOutlierFactor ( const ALG3D_Point3d pts,
size_t  numPts,
double *  values,
size_t  maxPoints 
)

#include <algorithm.cpp>

Computes the local outlier factors of the points from a point cloud.

For a more detailed explanation of the local outlier factor see LOF.

code example
const char* fname = "./sample_data/testData.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *lof_values = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the outlier factors
lof_values = (double*)malloc(ptsVec * sizeof(double));
//compute local outlier factors
if (!ALG3D_checkResult(ALG3D_computeOutlierFactor(vec, ptsVec, lof_values, 30))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
valuespointer to pre-allocated memory (same size as points) for storing the resulting outlier factor values
maxPointsnumber of K-neighbourhood points that should be used to compute the local outlier factor (20 is a reasonable value)
Returns
ERR_NONE on success

◆ ALG3D_computeOutlierFactorTree()

int ALG3D_computeOutlierFactorTree ( const ALG3D_KDTREE  tree,
double *  values,
size_t  maxPoints 
)

#include <algorithm.cpp>

Computes the local outlier factor of the points from a point cloud (represented by its KdTree).

For a more detailed explanation of the local outlier factor see LOF.

code example
const char* fname = "./sample_data/testData.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *lof_values = 0; //pointer to array of values
ALG3D_KDTREE tree = 0; // Handle to search tree
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the outlier factors
lof_values = (double*)malloc(ptsVec * sizeof(double));
//compute local outlier factors
if (!ALG3D_checkResult(ALG3D_computeOutlierFactorTree(tree, lof_values, 30))) return 0;
Parameters
treeKdTree of the point cloud
valuespointer to pre-allocated memory (same size as points) for storing the resulting outlier factor values
maxPointsnumber of K-neighbourhood points that should be used to compute the local outlier factor (20 is a reasonable value)
Returns
ERR_NONE on success

◆ ALG3D_computeSmoothedThinning()

int ALG3D_computeSmoothedThinning ( ALG3D_Point3d pts,
size_t *  numPts,
double  radius 
)

#include <algorithm.cpp>

Computes a combined homogeneous thinning and smoothing of a 3d point set.

This convenience function is typically used to preprocess a point cloud. It efficiently applies a combination of a smoothing and a thinning operation to a pointcloud.
The memory provided as input is reused but its size will not be not changed. But instead the parameter numPts returns the new number of points which is equal or smaller than the number of input points.

Parameters
ptspointer to points (input and output)
numPtsnumber of points (input and output)
radiusthinning/smoothing radius
Returns
ERR_NONE on success

◆ ALG3D_computeSmoothing()

int ALG3D_computeSmoothing ( const ALG3D_Point3d pts,
size_t  numPts,
ALG3D_Point3d ptsOut,
double  radius,
SmoothingMethod  method 
)

#include <algorithm.cpp>

Computes an edge preserving smoothing of point cloud given by a KD-Tree.

The direction and magnitude of the point movement is limited by the amount of the local curvature and the surface normal vector of the local neighborhood.

code example
const char* fname = "./sample_data/box.xyz";
ALG3D_Point3d *vec = 0; //3d point data
size_t ptsVec = 0; //number of 3d points
//read 3d point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the resulting smoothed point cloud
ALG3D_Point3d *vecOut = (ALG3D_Point3d*)malloc(sizeof(ALG3D_Point3d)*ptsVec);
//compute edge preserving smoothing
if (!ALG3D_checkResult(ALG3D_computeSmoothing(vec, ptsVec, vecOut, 2.0, EdgePreserving))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
ptsOutpre-allocated memory (same size as points in kdTree) for storing the resulting smoothed points
radiussmoothing radius
methodsmoothing method (see SmoothingMethod)
Returns
ERR_NONE on success

◆ ALG3D_computeSmoothingTree()

int ALG3D_computeSmoothingTree ( const ALG3D_KDTREE  tree,
ALG3D_Point3d ptsOut,
double  radius,
SmoothingMethod  method 
)

#include <algorithm.cpp>

Computes the smoothing of point cloud given by a KD-Tree.

code example
//create kdTree
if(!ALG3D_checkResult( ALG3D_createKdTree(data, ptsVec, &tree) )) return 0;
//allocate storage for the resulting, smoothed point data
resdata=(ALG3D_Point3d*) malloc(ptsVec*sizeof(ALG3D_Point3d));
for(i=0;i<ptsVec;++i){
resdata[i].vec[0]=0;
resdata[i].vec[1]=0;
resdata[i].vec[2]=0;
}
//compute smoothing of point data with given search tree
if (!ALG3D_checkResult(ALG3D_computeSmoothingTree(tree, resdata, 1.0, Gaussian))) return 0;
else{
//ALG3D_writeXYZ("smoothed.xyz", resPt,ptsVec);
}
Parameters
treeKdTree
ptsOutpre-allocated memory (same size as points in kdTree) for storing the resulting smoothed points
radiussmoothing radius
methodsmoothing method (see SmoothingMethod)
Returns
ERR_NONE on success

◆ ALG3D_computeSurfaceFeatures()

int ALG3D_computeSurfaceFeatures ( const ALG3D_Point3d pts,
size_t  numPts,
double *  values,
double  radius,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set within a neighborhood defined by a radius.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNN(vec, ptsVec, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNN(vec, ptsVec, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeatures(vec, ptsVec, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeatures(vec, ptsVec, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
radiusradius of the local neighborhood around each point to be used for the curvature estimation
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested

◆ ALG3D_computeSurfaceFeaturesFast()

int ALG3D_computeSurfaceFeaturesFast ( const ALG3D_Point3d pts,
size_t  numPts,
double *  values,
double  radius,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set within a neighborhood defined by a radius.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNFast(vec, ptsVec, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNFast(vec, ptsVec, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesFast(vec, ptsVec, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesFast(vec, ptsVec, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Note
This function uses an approximation technique to speed up the surface features computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeSurfaceFeatures function.
Parameters
ptspointer to points
numPtsnumber of points
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
radiusradius of the local neighborhood around each point to be used for the curvature estimation
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested

◆ ALG3D_computeSurfaceFeaturesKNN()

int ALG3D_computeSurfaceFeaturesKNN ( const ALG3D_Point3d pts,
size_t  numPts,
double *  values,
size_t  maxPoints,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set from K-Nearest-Neighbours.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNN(vec, ptsVec, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNN(vec, ptsVec, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeatures(vec, ptsVec, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeatures(vec, ptsVec, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Parameters
ptspointer to points
numPtsnumber of points
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
maxPointsnumber of K-neighbourhood points that should be used to compute the feature (>= 4)
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested, ERR_CONDITION if maxPoints<4

◆ ALG3D_computeSurfaceFeaturesKNNFast()

int ALG3D_computeSurfaceFeaturesKNNFast ( const ALG3D_Point3d pts,
size_t  numPts,
double *  values,
size_t  maxPoints,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set from K-Nearest-Neighbours.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNFast(vec, ptsVec, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNFast(vec, ptsVec, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesFast(vec, ptsVec, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesFast(vec, ptsVec, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Note
This function uses an approximation technique to speed up the surface features computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeSurfaceFeaturesKNN function.
Parameters
ptspointer to points
numPtsnumber of points
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
maxPointsnumber of K-neighbourhood points that should be used to compute the feature (>= 4)
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested, ERR_CONDITION if maxPoints<4

◆ ALG3D_computeSurfaceFeaturesKNNTree()

int ALG3D_computeSurfaceFeaturesKNNTree ( const ALG3D_KDTREE  tree,
double *  values,
size_t  maxPoints,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set (represented by its KdTree) from K-Nearest-Neighbours.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTree(tree, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTree(tree, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTree(tree, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTree(tree, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
maxPointsnumber of K-neighbourhood points that should be used to compute the feature (>= 4)
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested, ERR_CONDITION if maxPoints<4

◆ ALG3D_computeSurfaceFeaturesKNNTreeFast()

int ALG3D_computeSurfaceFeaturesKNNTreeFast ( const ALG3D_KDTREE  tree,
double *  values,
size_t  maxPoints,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set (represented by its KdTree) from K-Nearest-Neighbours.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTreeFast(tree, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTreeFast(tree, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTreeFast(tree, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTreeFast(tree, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Note
This function uses an approximation technique to speed up the surface features computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeSurfaceFeaturesKNNTree function.
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
maxPointsnumber of K-neighbourhood points that should be used to compute the feature (>= 4)
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested, ERR_CONDITION if maxPoints<4

◆ ALG3D_computeSurfaceFeaturesTree()

int ALG3D_computeSurfaceFeaturesTree ( const ALG3D_KDTREE  tree,
double *  values,
double  radius,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set (represented by its KdTree) within a neighborhood defined by a radius.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTree(tree, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTree(tree, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTree(tree, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTree(tree, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
radiusradius of the local neighborhood around each point to be used for the curvature estimation
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested

◆ ALG3D_computeSurfaceFeaturesTreeFast()

int ALG3D_computeSurfaceFeaturesTreeFast ( const ALG3D_KDTREE  tree,
double *  values,
double  radius,
SurfaceFeatureType  type 
)

#include <algorithm.cpp>

Computes surface features for each point of a given point set (represented by its KdTree) within a neighborhood defined by a radius.

code example
const char* fname = "./sample_data/surface1.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
double *intrinsic_curvatures = 0; //pointer to array of values
double *extrinsic_curvatures = 0; //pointer to array of values
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//storage for the point-wise curvatures
intrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
extrinsic_curvatures = (double*)malloc(ptsVec*sizeof(double));
// a) K-Nearest-Neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTreeFast(tree, intrinsic_curvatures, 15, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesKNNTreeFast(tree, extrinsic_curvatures, 15, ExtrinsicCurvature))) return 0;
// b) Radius neighbours
//compute intrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTreeFast(tree, intrinsic_curvatures, 1.5, IntrinsicCurvature))) return 0;
//compute extrinsic curvatures
if (!ALG3D_checkResult(ALG3D_computeSurfaceFeaturesTreeFast(tree, extrinsic_curvatures, 1.5, ExtrinsicCurvature))) return 0;
Note
This function uses an approximation technique to speed up the surface features computations. Depending on the dataset, the computation time can be reduced to a third or even a quarter of the time of the non-approximating ALG3D_computeSurfaceFeaturesTree function.
Parameters
treeprecomputed KdTree (see ALG3D_createKdTree)
valuespointer to pre-allocated memory (same size as points) for storing the resulting curvature values
radiusradius of the local neighborhood around each point to be used for the curvature estimation
typeThe surface feature type that is computed for each point (see SurfaceFeatureType)
Returns
ERR_NONE on success, ERR_INVALID_ARG if an invalid SurfaceFeatureType was requested

◆ ALG3D_computeThinningToNeighborhood()

int ALG3D_computeThinningToNeighborhood ( ALG3D_Point3d pts,
size_t *  numPts,
double  radius 
)

#include <algorithm.cpp>

Computes a homogeneous thinning of 3d point set to a given radius (neighborhood).

The method successively removes points from the local neighbourhood defined by the radius. The memory provided as input is reused but its size will not be not changed. Instead the parameter numPts returns the new number of points which is equal or smaller than the number of input points. The elements after the new end are still dereferencable but their value is unpecified. It is in the responsibility of the calling application to reduce the used memory to the new size.

code example
//read 3d point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//compute normal thinning
printf("points before: %I64d\n", ptsVec);
if (!ALG3D_checkResult(ALG3D_computeThinningToNeighborhood(vec, &ptsVec, 0.5))) return 0;
printf("points after: %I64d\n", ptsVec); // (14023)
printf("points before: %I64d\n", ptsVec);
if (!ALG3D_checkResult(ALG3D_computeThinningToPointNumber(vec, &ptsVec, 12345))) return 0;
printf("points after: %I64d\n", ptsVec); // (12345)
//compute thinning + smoothing
if (!ALG3D_checkResult(ALG3D_computeSmoothedThinning(vec, &ptsVec, 1.0))) return 0;
printf("points after: %I64d\n", ptsVec); // (3186)
//write result to file
//ALG3D_writeXYZ("smoothedthinning.xyz",vec,ptsVec);
Parameters
[in,out]ptspointer to points
[in,out]numPtsnumber of points
[in]radiusthinning radius
Returns
ERR_NONE on success

◆ ALG3D_computeThinningToPointNumber()

int ALG3D_computeThinningToPointNumber ( ALG3D_Point3d pts,
size_t *  numPts,
size_t  resultingNumPoints 
)

#include <algorithm.cpp>

Computes a homogeneous thinning of 3d point set to a given number of resulting points.

The method removes points from the input until resultingNumPoints are left. It uses an algorithm which tries to preserve the spatial distribution (instead of removing every n-th point). The memory provided as input is reused but its size will not be not changed. Instead the parameter numPts returns the new number of points which is equal or smaller than the number of input points. The elements after the new end are still dereferencable but their value is unpecified. It is in the responsibility of the calling application to reduce the used memory to the new size.

Parameters
[in,out]ptspointer to points
[in,out]numPtsnumber of points
[in]resultingNumPointsdesired number of resulting points
Returns
ERR_NONE on success

◆ ALG3D_computeThinningTree()

int ALG3D_computeThinningTree ( ALG3D_KDTREE  tree,
double  radius 
)

#include <algorithm.cpp>

Computes the homogeneous thinning of a point cloud given by a KdTree.

The algorithm discards all additional points within the query/thinning radius. Note: The points discarded are not deleted but marked by setting their coordinates [0..2] to 0. This behaviour will be changed in future versions.

code example
//create kdTree
if(!ALG3D_checkResult( ALG3D_createKdTree(data, ptsVec, &tree) )) return 0;
//compute thinning using a tree (removed points are set to [0,0,0])
//changes to original data which is referenced by the tree
if (!ALG3D_checkResult(ALG3D_computeThinningTree(tree, 1.0))) return 0;
else{
count=0;
for (i=0; i < ptsVec; ++i){
if (data[i].vec[0] != 0 && data[i].vec[1] != 0 && data[i].vec[2] != 0)
count++;
}
printf("remaining points: %I64d\n",count);
}
Parameters
treeKdTree
radiusthinning radius
Returns
ERR_NONE on success

◆ ALG3D_createKdTree()

int ALG3D_createKdTree ( const ALG3D_Point3d data,
size_t  numPts,
ALG3D_KDTREE *  tree 
)

#include <algorithm.cpp>

Builds a kdTree from given 3D data.

Parameters
datapointer to data begin
numPtsnumber of points
treeaddress of a kdTree object
Returns
ERR_NONE on success

◆ ALG3D_createMesh()

int __cdecl ALG3D_createMesh ( const ALG3D_Point3d data,
size_t *  indices,
size_t  numTriangles,
ALG3D_MESH *  mesh 
)

#include <algorithm.h>

Builds a mesh from given points and indices. Three consecutive entries in the indices array define the indices of the 3 points (in the data array) of a single triangle.

Parameters
datapointer to points begin
indicespointer to indices begin
numTrianglesnumber of triangles (the size of indices is 3 * numTriangles)
meshaddress of a mesh object
Returns
ERR_NONE on success

◆ ALG3D_createMeshTree()

int __cdecl ALG3D_createMeshTree ( const ALG3D_MESH  mesh,
ALG3D_MESHTREE *  meshTree 
)

#include <algorithm.h>

Builds a kdTree from a mesh.

Parameters
meshthe mesh object
meshTreeaddress of a kdTree object
Returns
ERR_NONE on success

◆ ALG3D_findKNearestNeighbors()

int ALG3D_findKNearestNeighbors ( const ALG3D_KDTREE  tree,
ALG3D_Point3d  pt,
size_t  maxPoints,
ALG3D_Point3d **  vNN,
size_t *  numNN 
)

#include <algorithm.cpp>

Finds the k-nearest neighboring points to a given point.

Given an initial start radius as a hint, this function efficiently computes the exact k-nearest neighbors. But finding the k-nearest neighbors for each point of a point set can be expensive. But the speed can be significantly increased if the startRadius is iteratively adapted to the point set density. Note, that the first neighbor in the resulting array is the point which is farthest away from the query point. This distance should be used as startRadius for the next query (take care that this is not close to 0 which is the case if all k-nearest neighbors are nearly on the same point).

Parameters
treeKD-Tree
ptquery point
maxPointsnumber of points to be returned (exactly the maxPoints nearest points are found, if there at least maxPoints inside the KD-tree)
vNNpointer which finally points to an array of all neighbouring points (allocated by this function). The first point in this array is the neighbor which is farthest away from pt.
numNNnumber of resulting neighbouring points (is equal to maxPoints, if there at least maxPoints inside the KD-tree)
Returns
ERR_NONE on success

◆ ALG3D_findKNearestNormalCompatibleNeighbors()

int ALG3D_findKNearestNormalCompatibleNeighbors ( const ALG3D_KDTREE  tree,
const ALG3D_Point3d treeNormals,
ALG3D_Point3d  pt,
ALG3D_Point3d  ptNormal,
size_t  maxPoints,
double  minimumDotProduct,
ALG3D_Point3d **  vNN,
size_t *  numNN 
)

#include <algorithm.cpp>

Finds the k-nearest neighboring points with compatible normal vectors to a given point.

Parameters
treeKD-Tree
treeNormalsCorrectly aligned normals of the points of the KD-Tree
ptquery point
ptNormalCorreclty aligned normal of query point
maxPointsNumber of points to be returned (exactly the maxPoints nearest points with compatible normals are found, if there at least maxPoints with compatible normals inside the KD-tree)
minimumDotProductMinimum dot product between two normal vectors to consider them compatible (e.g 0.85)
vNNPointer which finally points to an array of all neighbouring points (allocated by this function). The first point in this array is the neighbor which is farthest away from pt.
numNNNumber of resulting neighbouring points (is equal to maxPoints, if there at least maxPoints with compatible normals inside the KD-tree)
Returns
ERR_NONE on success
code example
//create kd-tree
if (!ALG3D_checkResult(ALG3D_createKdTree(data, ptsVec, &tree))) return 0;
ALG3D_Point3d* normals = (ALG3D_Point3d*)malloc(ptsVec * sizeof(ALG3D_Point3d));
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNTreeFast(tree, normals, 15))) return 0;
ALG3D_Point3d sensorPos;
sensorPos.vec[0] = -133;
sensorPos.vec[1] = 0;
sensorPos.vec[2] = 112;
// Align normals
for (i = 0; i < ptsVec; ++i)
{
ALG3D_Point3d toSensor;
toSensor.vec[0] = sensorPos.vec[0] - data[i].vec[0];
toSensor.vec[1] = sensorPos.vec[1] - data[i].vec[1];
toSensor.vec[2] = sensorPos.vec[2] - data[i].vec[2];
if (ALG3D_dotProduct(&toSensor, &normals[i]) < 0)
{
normals[i].vec[0] = -normals[i].vec[0];
normals[i].vec[1] = -normals[i].vec[1];
normals[i].vec[2] = -normals[i].vec[2];
}
}
//test point used for the query
pt.vec[0] = -24.066111;
pt.vec[1] = 15.172830;
pt.vec[2] = 4.777431;
ALG3D_Point3d ptNormal;
ptNormal.vec[0] = -1;
ptNormal.vec[1] = 0;
ptNormal.vec[2] = 0;
if (!ALG3D_checkResult(ALG3D_findNearestNormalCompatibleNeighbor(tree, normals, pt, ptNormal, 10.0, 0.95, &nn))){
printf("nearest neighbor: nothing found in range\n");
}
else{
printf("nearest compatible neighbor: %lf %lf %lf\n", nn.vec[0], nn.vec[1], nn.vec[2]);
}
printf("ALG3D_findNearestNormalCompatibleNeighbor finished\n");
//find all neighbours within a given radius
if (!ALG3D_checkResult(ALG3D_findNormalCompatibleNeighbors(tree, normals, pt, ptNormal, 5.0, 0.95, &vNN, &numNN)))
return 0;
else{
printf("found %I64d neighbors:\n", numNN);
for (i = 0; i < numNN; i++){
printf("[%3I64d]: %lf %lf %lf\n", i, vNN[i].vec[0], vNN[i].vec[1], vNN[i].vec[2]);
}
}
printf("ALG3D_findNormalCompatibleNeighbors finished\n");
//find k-nearest points around pt
if (!ALG3D_checkResult(ALG3D_freeMemory(vNN))) return 0;
if (!ALG3D_checkResult(ALG3D_findKNearestNormalCompatibleNeighbors(tree, normals, pt, ptNormal, maxPoints, 0.95, &vNN, &numNN)))
return 0;
else if (numNN != maxPoints){ //this is only allowed to happen if number of points in the tree is smaller than the number of points requested
printf("warning: number of points returned (%I64d) not equals number of points requested (%I64d)\n", numNN, maxPoints);
return 0;
}
else{
printf("points found: %I64d/%I64d\n", numNN, maxPoints);
for (i = 0; i < numNN; i++){
printf("[%3I64d]: %lf %lf %lf\n", i, vNN[i].vec[0], vNN[i].vec[1], vNN[i].vec[2]);
}
}
printf("ALG3D_findKNearestNormalCompatibleNeighbors finished\n");
Warning
The normal vectors of the KD-Tree and the query point must be aligned properly. The normal computation functions of this library do not return correctly aligned normals on their own. You have to use a known sensor position or some other information to realign the normal vectors (flip them around if they point in the wrong direction) before calling this function.

◆ ALG3D_findNearestNeighbor()

int ALG3D_findNearestNeighbor ( const ALG3D_KDTREE  tree,
ALG3D_Point3d  pt,
double  radius,
ALG3D_Point3d nn 
)

#include <algorithm.cpp>

Finds the nearest neighbour within a query radius to a given point and uses a given KD-Tree.

Parameters
treeKD-Tree
radiussearch radius (0=auto)
ptquery point
nnnearest neighbour. If there is no neighbouring point within the given radius ERR_CONDITION is returned.
Returns
ERR_NONE on success

◆ ALG3D_findNearestNormalCompatibleNeighbor()

int ALG3D_findNearestNormalCompatibleNeighbor ( const ALG3D_KDTREE  tree,
const ALG3D_Point3d treeNormals,
ALG3D_Point3d  pt,
ALG3D_Point3d  ptNormal,
double  radius,
double  minimumDotProduct,
ALG3D_Point3d nn 
)

#include <algorithm.cpp>

Finds the nearest neighbour within a query radius to a given point with a compatible normal and uses a given KD-Tree.

Parameters
treeKD-Tree
treeNormalsCorrectly aligned normals of the points of the KD-Tree
ptquery point
ptNormalCorreclty aligned normal of query point
radiussearch radius (0=auto)
minimumDotProductMinimum dot product between two normal vectors to consider them compatible (e.g 0.85)
nnnearest neighbour. If there is no neighbouring point within the given radius ERR_CONDITION is returned.
Returns
ERR_NONE on success
code example
//create kd-tree
if (!ALG3D_checkResult(ALG3D_createKdTree(data, ptsVec, &tree))) return 0;
ALG3D_Point3d* normals = (ALG3D_Point3d*)malloc(ptsVec * sizeof(ALG3D_Point3d));
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNTreeFast(tree, normals, 15))) return 0;
ALG3D_Point3d sensorPos;
sensorPos.vec[0] = -133;
sensorPos.vec[1] = 0;
sensorPos.vec[2] = 112;
// Align normals
for (i = 0; i < ptsVec; ++i)
{
ALG3D_Point3d toSensor;
toSensor.vec[0] = sensorPos.vec[0] - data[i].vec[0];
toSensor.vec[1] = sensorPos.vec[1] - data[i].vec[1];
toSensor.vec[2] = sensorPos.vec[2] - data[i].vec[2];
if (ALG3D_dotProduct(&toSensor, &normals[i]) < 0)
{
normals[i].vec[0] = -normals[i].vec[0];
normals[i].vec[1] = -normals[i].vec[1];
normals[i].vec[2] = -normals[i].vec[2];
}
}
//test point used for the query
pt.vec[0] = -24.066111;
pt.vec[1] = 15.172830;
pt.vec[2] = 4.777431;
ALG3D_Point3d ptNormal;
ptNormal.vec[0] = -1;
ptNormal.vec[1] = 0;
ptNormal.vec[2] = 0;
if (!ALG3D_checkResult(ALG3D_findNearestNormalCompatibleNeighbor(tree, normals, pt, ptNormal, 10.0, 0.95, &nn))){
printf("nearest neighbor: nothing found in range\n");
}
else{
printf("nearest compatible neighbor: %lf %lf %lf\n", nn.vec[0], nn.vec[1], nn.vec[2]);
}
printf("ALG3D_findNearestNormalCompatibleNeighbor finished\n");
//find all neighbours within a given radius
if (!ALG3D_checkResult(ALG3D_findNormalCompatibleNeighbors(tree, normals, pt, ptNormal, 5.0, 0.95, &vNN, &numNN)))
return 0;
else{
printf("found %I64d neighbors:\n", numNN);
for (i = 0; i < numNN; i++){
printf("[%3I64d]: %lf %lf %lf\n", i, vNN[i].vec[0], vNN[i].vec[1], vNN[i].vec[2]);
}
}
printf("ALG3D_findNormalCompatibleNeighbors finished\n");
//find k-nearest points around pt
if (!ALG3D_checkResult(ALG3D_freeMemory(vNN))) return 0;
if (!ALG3D_checkResult(ALG3D_findKNearestNormalCompatibleNeighbors(tree, normals, pt, ptNormal, maxPoints, 0.95, &vNN, &numNN)))
return 0;
else if (numNN != maxPoints){ //this is only allowed to happen if number of points in the tree is smaller than the number of points requested
printf("warning: number of points returned (%I64d) not equals number of points requested (%I64d)\n", numNN, maxPoints);
return 0;
}
else{
printf("points found: %I64d/%I64d\n", numNN, maxPoints);
for (i = 0; i < numNN; i++){
printf("[%3I64d]: %lf %lf %lf\n", i, vNN[i].vec[0], vNN[i].vec[1], vNN[i].vec[2]);
}
}
printf("ALG3D_findKNearestNormalCompatibleNeighbors finished\n");
Warning
The normal vectors of the KD-Tree and the query point must be aligned properly. The normal computation functions of this library do not return correctly aligned normals on their own. You have to use a known sensor position or some other information to realign the normal vectors (flip them around if they point in the wrong direction) before calling this function.

◆ ALG3D_findNearestPoint2Mesh()

int __cdecl ALG3D_findNearestPoint2Mesh ( const ALG3D_MESHTREE  meshTree,
double  radius,
ALG3D_Point3d  pt,
ALG3D_Point3d nn 
)

#include <algorithm.h>

Finds the nearest neighbour within a query radius to a given point.

Parameters
meshTreekdTree of a mesh
radiussearch radius (0=auto)
ptquery point
nnnearest neighbour. If there is no neighbouring point within the given radius ERR_CONDITION is returned.
Returns
ERR_NONE on success

◆ ALG3D_findNearestPointAndTriangle2Mesh()

int __cdecl ALG3D_findNearestPointAndTriangle2Mesh ( const ALG3D_MESHTREE  meshTree,
double  radius,
ALG3D_Point3d  pt,
ALG3D_Point3d nn,
size_t *  triangleIndex 
)

#include <algorithm.h>

Finds the nearest neighbour and corresponding triangle index within a query radius to a given point.

Parameters
meshTreekdTree of a mesh
radiussearch radius (0=auto)
ptquery point
nnnearest neighbour.
triangleIndextriangle index of nearest neighbour.
Returns
ERR_NONE on success. If there is no neighbouring point within the given radius ERR_CONDITION is returned.
Note
The nearest neighbour might be located on an edge or even correspond to a vertex of the mesh. In these cases the returned triangle index can belong to any of the adjacent triangles.

◆ ALG3D_findNeighbors()

int ALG3D_findNeighbors ( const ALG3D_KDTREE  tree,
ALG3D_Point3d  pt,
double  radius,
ALG3D_Point3d **  vNN,
size_t *  numNN 
)

#include <algorithm.cpp>

Finds all neighboring points within a query radius to a given point using a given KD-Tree.

Parameters
treeKD-Tree
radiussearch radius
ptquery point
vNNpointer which finally points to an array of all neighbouring points (allocated by this function)
numNNnumber of resulting neighbouring points
Returns
ERR_NONE on success

◆ ALG3D_findNeighborsBox()

int ALG3D_findNeighborsBox ( const ALG3D_KDTREE  tree,
ALG3D_Point3d  pt,
double  vDist[3],
ALG3D_Point3d **  vNN,
size_t *  numNN 
)

#include <algorithm.cpp>

Finds all neighbouring points within a box around a given point and uses a given KD-Tree.

The box is defined by a canter point pt and 3 (semi)-axis lengths starting from pt. Example: for a given point pt(0,0,0) and the axial lengths vDist{2,4,8} this functions returns all points with coordinates in the range {[-2,2], [-4,4], [-8,8]).

Parameters
treeKD-Tree
ptquery point
vDist3 half-lengths of the box axis with the query point in its center
vNNpointer which finally points to an array of all neighbouring points (allocated by this function)
numNNresulting number of resulting neighbouring points
Returns
ERR_NONE on success

◆ ALG3D_findNormalCompatibleNeighbors()

int ALG3D_findNormalCompatibleNeighbors ( const ALG3D_KDTREE  tree,
const ALG3D_Point3d treeNormals,
ALG3D_Point3d  pt,
ALG3D_Point3d  ptNormal,
double  radius,
double  minimumDotProduct,
ALG3D_Point3d **  vNN,
size_t *  numNN 
)

#include <algorithm.cpp>

Finds all neighboring points within a query radius with compatible normal vectors to a given point using a given KD-Tree.

Parameters
treeKD-Tree
treeNormalsCorrectly aligned normals of the points of the KD-Tree
ptQuery point
ptNormalCorreclty aligned normal of query point
radiusSearch radius
minimumDotProductMinimum dot product between two normal vectors to consider them compatible (e.g 0.85)
vNNpointer which finally points to an array of all neighbouring points (allocated by this function)
numNNnumber of resulting neighbouring points
Returns
ERR_NONE on success
code example
//create kd-tree
if (!ALG3D_checkResult(ALG3D_createKdTree(data, ptsVec, &tree))) return 0;
ALG3D_Point3d* normals = (ALG3D_Point3d*)malloc(ptsVec * sizeof(ALG3D_Point3d));
if (!ALG3D_checkResult(ALG3D_computeNormalVectorsKNNTreeFast(tree, normals, 15))) return 0;
ALG3D_Point3d sensorPos;
sensorPos.vec[0] = -133;
sensorPos.vec[1] = 0;
sensorPos.vec[2] = 112;
// Align normals
for (i = 0; i < ptsVec; ++i)
{
ALG3D_Point3d toSensor;
toSensor.vec[0] = sensorPos.vec[0] - data[i].vec[0];
toSensor.vec[1] = sensorPos.vec[1] - data[i].vec[1];
toSensor.vec[2] = sensorPos.vec[2] - data[i].vec[2];
if (ALG3D_dotProduct(&toSensor, &normals[i]) < 0)
{
normals[i].vec[0] = -normals[i].vec[0];
normals[i].vec[1] = -normals[i].vec[1];
normals[i].vec[2] = -normals[i].vec[2];
}
}
//test point used for the query
pt.vec[0] = -24.066111;
pt.vec[1] = 15.172830;
pt.vec[2] = 4.777431;
ALG3D_Point3d ptNormal;
ptNormal.vec[0] = -1;
ptNormal.vec[1] = 0;
ptNormal.vec[2] = 0;
if (!ALG3D_checkResult(ALG3D_findNearestNormalCompatibleNeighbor(tree, normals, pt, ptNormal, 10.0, 0.95, &nn))){
printf("nearest neighbor: nothing found in range\n");
}
else{
printf("nearest compatible neighbor: %lf %lf %lf\n", nn.vec[0], nn.vec[1], nn.vec[2]);
}
printf("ALG3D_findNearestNormalCompatibleNeighbor finished\n");
//find all neighbours within a given radius
if (!ALG3D_checkResult(ALG3D_findNormalCompatibleNeighbors(tree, normals, pt, ptNormal, 5.0, 0.95, &vNN, &numNN)))
return 0;
else{
printf("found %I64d neighbors:\n", numNN);
for (i = 0; i < numNN; i++){
printf("[%3I64d]: %lf %lf %lf\n", i, vNN[i].vec[0], vNN[i].vec[1], vNN[i].vec[2]);
}
}
printf("ALG3D_findNormalCompatibleNeighbors finished\n");
//find k-nearest points around pt
if (!ALG3D_checkResult(ALG3D_freeMemory(vNN))) return 0;
if (!ALG3D_checkResult(ALG3D_findKNearestNormalCompatibleNeighbors(tree, normals, pt, ptNormal, maxPoints, 0.95, &vNN, &numNN)))
return 0;
else if (numNN != maxPoints){ //this is only allowed to happen if number of points in the tree is smaller than the number of points requested
printf("warning: number of points returned (%I64d) not equals number of points requested (%I64d)\n", numNN, maxPoints);
return 0;
}
else{
printf("points found: %I64d/%I64d\n", numNN, maxPoints);
for (i = 0; i < numNN; i++){
printf("[%3I64d]: %lf %lf %lf\n", i, vNN[i].vec[0], vNN[i].vec[1], vNN[i].vec[2]);
}
}
printf("ALG3D_findKNearestNormalCompatibleNeighbors finished\n");
Warning
The normal vectors of the KD-Tree and the query point must be aligned properly. The normal computation functions of this library do not return correctly aligned normals on their own. You have to use a known sensor position or some other information to realign the normal vectors (flip them around if they point in the wrong direction) before calling this function.

◆ ALG3D_freeKdTree()

int ALG3D_freeKdTree ( ALG3D_KDTREE  tree)

#include <algorithm.cpp>

Releases memory of a given kdTree object. It's up to the application to ensure that the pointer is valid.

Parameters
treeexisting KdTree object
Returns
ERR_NONE on success

◆ ALG3D_freeMesh()

int __cdecl ALG3D_freeMesh ( ALG3D_MESH  mesh)

#include <algorithm.h>

Releases memory of a given mesh object. It's up to the application to ensure that the pointer is valid.

Parameters
meshexisting mesh object
Returns
ERR_NONE on success

◆ ALG3D_freeMeshTree()

int __cdecl ALG3D_freeMeshTree ( ALG3D_MESHTREE  meshTree)

#include <algorithm.h>

Releases memory of a given kdTree (mesh) object. It's up to the application to ensure that the pointer is valid.

Parameters
meshTreeexisting kdTree (mesh) object
Returns
ERR_NONE on success

◆ ALG3D_getNumberOfTriangles()

int __cdecl ALG3D_getNumberOfTriangles ( const ALG3D_MESH  mesh,
size_t *  numTriangles 
)

#include <algorithm.h>

Retrieves the number of triangles in a mesh. This number does not need to be the same as the one used in ALG3D_createMesh, since the mesh structure is optimized during the creation (invalid triangles are removed).

Parameters
meshaddress of a mesh object
numTrianglesnumber of trianlges in mesh
Returns
ERR_NONE on success

◆ ALG3D_getTrianglePoints()

int __cdecl ALG3D_getTrianglePoints ( const ALG3D_MESH  mesh,
size_t  triangleIndex,
ALG3D_Point3d a,
ALG3D_Point3d b,
ALG3D_Point3d c 
)

#include <algorithm.h>

Retrieves the 3 vertices of a triangle in a mesh. Use this function to get the triangle (points), returned as an index by the ALG3D_raytracing_* functions.

Parameters
meshaddress of a mesh object
triangleIndexIndex of the triangle
a,b,cVertices of the triangle
Returns
ERR_NONE on success

◆ ALG3D_raytracing_allIntersections()

int __cdecl ALG3D_raytracing_allIntersections ( const ALG3D_MESHTREE  meshTree,
ALG3D_Point3d  rayOrigin,
ALG3D_Point3d  rayDirection,
double  maxHitDistance,
ALG3D_Intersection **  intersections,
size_t *  numIntersections 
)

#include <algorithm.h>

Computes all intersections between a ray and a mesh.

The intersections are only detected of they are in the direction of the ray (Ray = rayOrigin + t*rayDirection, t is > 0).

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(data, indices, numTriangles, &mesh))) return 0;
ALG3D_MESHTREE tree = 0;
//create kdTree
if (!ALG3D_checkResult(ALG3D_createMeshTree(mesh, &tree))) return 0;
int doesIntersect = 0;
ALG3D_Point3d rayOrigin, rayDirection;
rayOrigin.vec[0] = 21.86;
rayOrigin.vec[1] = 3.89;
rayOrigin.vec[2] = -118.05;
rayDirection.vec[0] = 1;
rayDirection.vec[1] = 1;
rayDirection.vec[2] = -0.5;
// 1 - Does intersect
if (!ALG3D_checkResult(ALG3D_raytracing_doesIntersect(tree, rayOrigin, rayDirection, 0.0, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
// Too small maxDistance -> no intersection
if (!ALG3D_checkResult(ALG3D_raytracing_doesIntersect(tree, rayOrigin, rayDirection, 0.1, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
// 2 - First intersection
ALG3D_Intersection firstIntersection;
if (!ALG3D_checkResult(ALG3D_raytracing_firstIntersection(tree, rayOrigin, rayDirection, 0.0, &firstIntersection, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
if (doesIntersect == 1)
{
ALG3D_Point3d a, b, c;
ALG3D_checkResult(ALG3D_getTrianglePoints(mesh, firstIntersection.triangleIndex, &a, &b, &c));
printf("intersection: pt=[%f, %f, %f], t=%f, idx=%I64d, triangle{a=[%f, %f, %f] b=[%f, %f, %f] c=[%f, %f, %f]}\n",
firstIntersection.intersection.vec[0], firstIntersection.intersection.vec[1],
firstIntersection.intersection.vec[2], firstIntersection.t, firstIntersection.triangleIndex,
a.vec[0], a.vec[1], a.vec[2], b.vec[0], b.vec[1], b.vec[2], c.vec[0], c.vec[1], c.vec[2]);
}
// 3 - All intersections
ALG3D_Intersection* allIntersections = 0;
size_t numIntersections = 0;
rayOrigin.vec[0] = -21.86;
rayDirection.vec[1] = 0;
rayDirection.vec[2] = 0;
if (!ALG3D_checkResult(ALG3D_raytracing_allIntersections(tree, rayOrigin, rayDirection, 0.0, &allIntersections, &numIntersections)))
return 0;
printf("numIntersections: %I64d\n", numIntersections);
for (size_t i = 0; i < numIntersections; ++i)
{
ALG3D_Point3d a, b, c;
ALG3D_checkResult(ALG3D_getTrianglePoints(mesh, allIntersections[i].triangleIndex, &a, &b, &c));
printf(" intersection %I64d: pt=[%f, %f, %f], t=%f, idx=%I64d, triangle{a=[%f, %f, %f] b=[%f, %f, %f] c=[%f, %f, %f]}\n", i,
allIntersections[i].intersection.vec[0], allIntersections[i].intersection.vec[1],
allIntersections[i].intersection.vec[2], allIntersections[i].t, allIntersections[i].triangleIndex,
a.vec[0], a.vec[1], a.vec[2], b.vec[0], b.vec[1], b.vec[2], c.vec[0], c.vec[1], c.vec[2]);
}
Parameters
[in]meshTreekdTree object containing the mesh
[in]rayOriginorigin of the ray
[in]rayDirectiondirection of the ray (does not have to be normalized)
[in]maxHitDistanceMaximum allowed distance between the ray origin and a possible intersection point (0 = no maximum).
[out]intersectionspointer to an array that is filled with the intersection information
[out]numIntersectionsthe number of detected intersections.
Note
The intersections are not sorted (according to their t value).
Returns
ERR_NONE on success

◆ ALG3D_raytracing_doesIntersect()

int __cdecl ALG3D_raytracing_doesIntersect ( const ALG3D_MESHTREE  meshTree,
ALG3D_Point3d  rayOrigin,
ALG3D_Point3d  rayDirection,
double  maxHitDistance,
int *  doesIntersect 
)

#include <algorithm.h>

Checks if a ray intersects with a mesh.

A possible intersection is only detected in the direction of the ray (Ray = rayOrigin + t*rayDirection, t is > 0).

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(data, indices, numTriangles, &mesh))) return 0;
ALG3D_MESHTREE tree = 0;
//create kdTree
if (!ALG3D_checkResult(ALG3D_createMeshTree(mesh, &tree))) return 0;
int doesIntersect = 0;
ALG3D_Point3d rayOrigin, rayDirection;
rayOrigin.vec[0] = 21.86;
rayOrigin.vec[1] = 3.89;
rayOrigin.vec[2] = -118.05;
rayDirection.vec[0] = 1;
rayDirection.vec[1] = 1;
rayDirection.vec[2] = -0.5;
// 1 - Does intersect
if (!ALG3D_checkResult(ALG3D_raytracing_doesIntersect(tree, rayOrigin, rayDirection, 0.0, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
// Too small maxDistance -> no intersection
if (!ALG3D_checkResult(ALG3D_raytracing_doesIntersect(tree, rayOrigin, rayDirection, 0.1, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
// 2 - First intersection
ALG3D_Intersection firstIntersection;
if (!ALG3D_checkResult(ALG3D_raytracing_firstIntersection(tree, rayOrigin, rayDirection, 0.0, &firstIntersection, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
if (doesIntersect == 1)
{
ALG3D_Point3d a, b, c;
ALG3D_checkResult(ALG3D_getTrianglePoints(mesh, firstIntersection.triangleIndex, &a, &b, &c));
printf("intersection: pt=[%f, %f, %f], t=%f, idx=%I64d, triangle{a=[%f, %f, %f] b=[%f, %f, %f] c=[%f, %f, %f]}\n",
firstIntersection.intersection.vec[0], firstIntersection.intersection.vec[1],
firstIntersection.intersection.vec[2], firstIntersection.t, firstIntersection.triangleIndex,
a.vec[0], a.vec[1], a.vec[2], b.vec[0], b.vec[1], b.vec[2], c.vec[0], c.vec[1], c.vec[2]);
}
// 3 - All intersections
ALG3D_Intersection* allIntersections = 0;
size_t numIntersections = 0;
rayOrigin.vec[0] = -21.86;
rayDirection.vec[1] = 0;
rayDirection.vec[2] = 0;
if (!ALG3D_checkResult(ALG3D_raytracing_allIntersections(tree, rayOrigin, rayDirection, 0.0, &allIntersections, &numIntersections)))
return 0;
printf("numIntersections: %I64d\n", numIntersections);
for (size_t i = 0; i < numIntersections; ++i)
{
ALG3D_Point3d a, b, c;
ALG3D_checkResult(ALG3D_getTrianglePoints(mesh, allIntersections[i].triangleIndex, &a, &b, &c));
printf(" intersection %I64d: pt=[%f, %f, %f], t=%f, idx=%I64d, triangle{a=[%f, %f, %f] b=[%f, %f, %f] c=[%f, %f, %f]}\n", i,
allIntersections[i].intersection.vec[0], allIntersections[i].intersection.vec[1],
allIntersections[i].intersection.vec[2], allIntersections[i].t, allIntersections[i].triangleIndex,
a.vec[0], a.vec[1], a.vec[2], b.vec[0], b.vec[1], b.vec[2], c.vec[0], c.vec[1], c.vec[2]);
}
Parameters
[in]meshTreekdTree object containing the mesh
[in]rayOriginorigin of the ray
[in]rayDirectiondirection of the ray (does not have to be normalized)
[in]maxHitDistanceMaximum allowed distance between the ray origin and a possible intersection point (0 = no maximum).
[out]doesIntersect1 if there is an intersection, 0 otherwise
Returns
ERR_NONE on success

◆ ALG3D_raytracing_firstIntersection()

int __cdecl ALG3D_raytracing_firstIntersection ( const ALG3D_MESHTREE  meshTree,
ALG3D_Point3d  rayOrigin,
ALG3D_Point3d  rayDirection,
double  maxHitDistance,
ALG3D_Intersection intersection,
int *  doesIntersect 
)

#include <algorithm.h>

Computes the first intersection between a ray and a mesh.

A possible intersection is only detected in the direction of the ray (Ray = rayOrigin + t*rayDirection, t is > 0).

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(data, indices, numTriangles, &mesh))) return 0;
ALG3D_MESHTREE tree = 0;
//create kdTree
if (!ALG3D_checkResult(ALG3D_createMeshTree(mesh, &tree))) return 0;
int doesIntersect = 0;
ALG3D_Point3d rayOrigin, rayDirection;
rayOrigin.vec[0] = 21.86;
rayOrigin.vec[1] = 3.89;
rayOrigin.vec[2] = -118.05;
rayDirection.vec[0] = 1;
rayDirection.vec[1] = 1;
rayDirection.vec[2] = -0.5;
// 1 - Does intersect
if (!ALG3D_checkResult(ALG3D_raytracing_doesIntersect(tree, rayOrigin, rayDirection, 0.0, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
// Too small maxDistance -> no intersection
if (!ALG3D_checkResult(ALG3D_raytracing_doesIntersect(tree, rayOrigin, rayDirection, 0.1, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
// 2 - First intersection
ALG3D_Intersection firstIntersection;
if (!ALG3D_checkResult(ALG3D_raytracing_firstIntersection(tree, rayOrigin, rayDirection, 0.0, &firstIntersection, &doesIntersect)))
return 0;
printf("doesIntersect: %d\n", doesIntersect);
if (doesIntersect == 1)
{
ALG3D_Point3d a, b, c;
ALG3D_checkResult(ALG3D_getTrianglePoints(mesh, firstIntersection.triangleIndex, &a, &b, &c));
printf("intersection: pt=[%f, %f, %f], t=%f, idx=%I64d, triangle{a=[%f, %f, %f] b=[%f, %f, %f] c=[%f, %f, %f]}\n",
firstIntersection.intersection.vec[0], firstIntersection.intersection.vec[1],
firstIntersection.intersection.vec[2], firstIntersection.t, firstIntersection.triangleIndex,
a.vec[0], a.vec[1], a.vec[2], b.vec[0], b.vec[1], b.vec[2], c.vec[0], c.vec[1], c.vec[2]);
}
// 3 - All intersections
ALG3D_Intersection* allIntersections = 0;
size_t numIntersections = 0;
rayOrigin.vec[0] = -21.86;
rayDirection.vec[1] = 0;
rayDirection.vec[2] = 0;
if (!ALG3D_checkResult(ALG3D_raytracing_allIntersections(tree, rayOrigin, rayDirection, 0.0, &allIntersections, &numIntersections)))
return 0;
printf("numIntersections: %I64d\n", numIntersections);
for (size_t i = 0; i < numIntersections; ++i)
{
ALG3D_Point3d a, b, c;
ALG3D_checkResult(ALG3D_getTrianglePoints(mesh, allIntersections[i].triangleIndex, &a, &b, &c));
printf(" intersection %I64d: pt=[%f, %f, %f], t=%f, idx=%I64d, triangle{a=[%f, %f, %f] b=[%f, %f, %f] c=[%f, %f, %f]}\n", i,
allIntersections[i].intersection.vec[0], allIntersections[i].intersection.vec[1],
allIntersections[i].intersection.vec[2], allIntersections[i].t, allIntersections[i].triangleIndex,
a.vec[0], a.vec[1], a.vec[2], b.vec[0], b.vec[1], b.vec[2], c.vec[0], c.vec[1], c.vec[2]);
}
Parameters
[in]meshTreekdTree object containing the mesh
[in]rayOriginorigin of the ray
[in]rayDirectiondirection of the ray (does not have to be normalized)
[in]maxHitDistanceMaximum allowed distance between the ray origin and a possible intersection point (0 = no maximum).
[out]intersectioninformation about the intersection if there is one
[out]doesIntersect1 if there is an intersection, 0 otherwise
Returns
ERR_NONE on success

◆ ALG3D_removeOutliers()

int ALG3D_removeOutliers ( ALG3D_Point3d pts,
size_t *  numPts,
size_t  maxPoints,
double  thresh 
)

#include <algorithm.cpp>

Remove outliers from the point cloud.

This function uses the "local outlier factor" (LOF) to identify the points that should be removed from the point cloud. You have to provide a threshold to determine which points will be removed.

The memory provided as input is reused and its size will not be changed. Instead the parameter numPts returns the new number of points which is equal or smaller than the number of input points. The elements after the new end are still dereferencable but their values are unpecified. It is in the responsibility of the calling application to reduce the used memory to the new size.

Note
The order of the points might change, since the points above the threshold are moved to the end of the array.
code example
//read 3d point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//remove outliers
printf("points before: %I64d\n", ptsVec);
if (!ALG3D_checkResult(ALG3D_removeOutliers(vec, &ptsVec, 30, 1.15))) return 0;
printf("points after: %I64d\n", ptsVec);
See also
ALG3D_computeOutlierFactor
Parameters
ptspointer to points
numPtspointer to number of points (contains the remaining number of points after the call to this function)
maxPointsnumber of K-neighbourhood points that should be used to compute the local outlier factor (20 is a reasonable value)
threshthreshold, points with a local outlier factor higher than this value will be removed (1.15 is a reasonable default value)
Returns
ERR_NONE on success

◆ ALG3D_removeOutliersTree()

int ALG3D_removeOutliersTree ( ALG3D_KDTREE  tree,
size_t  maxPoints,
double  thresh 
)

#include <algorithm.cpp>

Remove outliers from the point cloud.

This function uses the "local outlier factor" (LOF) to identify the points that should be removed from the point cloud. You have to provide a threshold to determine which points will be removed.

Note: The points discarded are not deleted but marked by setting their coordinates [0..2] to 0.

Warning
After using this function the provided tree is no longer valid!
code example
const char* fname = "./sample_data/testData.xyz";
ALG3D_Point3d *vec = 0; //pointer to array of 3d points
size_t ptsVec = 0; //number of 3d points in array
ALG3D_KDTREE tree = 0; // Handle to search tree
//read point data from file
if (!ALG3D_checkResult(ALG3D_readXYZ(fname, &vec, &ptsVec))) return 0;
//create the KdTree
if (!ALG3D_checkResult(ALG3D_createKdTree(vec, ptsVec, &tree))) return 0;
//remove outliers
if (!ALG3D_checkResult(ALG3D_removeOutliersTree(tree, 30, 1.15))) return 0;
size_t count = 0;
for (int i = 0; i < ptsVec; ++i){
if (vec[i].vec[0] != 0 && vec[i].vec[1] != 0 && vec[i].vec[2] != 0)
count++;
}
printf("remaining points: %I64d\n", ptsVec - count);
See also
ALG3D_computeOutlierFactor
Parameters
treeKdTree of the point cloud
maxPointsnumber of K-neighbourhood points that should be used to compute the local outlier factor (20 is a reasonable value)
threshthreshold, points with a local outlier factor higher than this value will be removed (1.15 is a reasonable default value)
Returns
ERR_NONE on success

◆ ALG3D_sampleMesh()

int __cdecl ALG3D_sampleMesh ( const ALG3D_MESH  mesh,
size_t  numSamples,
ALG3D_Point3d **  points,
size_t *  numPts 
)

#include <algorithm.h>

Samples a mesh uniformly with a given number of points.

The algorithm uses a random number generator to sample the points. Therefore the number of generated points can deviate slightly from the number of requested points (e.g. 50'000 requested -> 49'981 generated). The actual number of generated points is returned through the last parameter.

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(data, indices, numTriangles, &mesh))) return 0;
size_t requestedSamples = 50000;
ALG3D_Point3d* samples = 0;
ALG3D_Point3d* normals = 0;
size_t numSamples = 0;
//sample mesh
if (!ALG3D_checkResult(ALG3D_sampleMeshNormals(mesh, requestedSamples, &samples, &normals, &numSamples))) {
return 0;
}
printf("[samples]: %I64d\n", numSamples);
Parameters
[in]meshmesh
[in]numSamplesthe number of requested samples
[out]pointspointer which finally points to an array of the generated points
[out]numPtsnumber of generated points
Returns
ERR_NONE on success

◆ ALG3D_sampleMeshDensity()

int __cdecl ALG3D_sampleMeshDensity ( const ALG3D_MESH  mesh,
double  density,
ALG3D_Point3d **  points,
size_t *  numPts 
)

#include <algorithm.h>

Samples a mesh uniformly with a given density of points.

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(data, indices, numTriangles, &mesh))) return 0;
double requestedDensity = 10.0;
ALG3D_Point3d* samples = 0;
ALG3D_Point3d* normals = 0;
size_t numSamples = 0;
//sample mesh
if (!ALG3D_checkResult(ALG3D_sampleMeshDensityNormals(mesh, requestedDensity, &samples, &normals, &numSamples))) {
return 0;
}
printf("[samples]: %I64d\n", numSamples);
Parameters
[in]meshmesh
[in]densitythe density (points/unit triangle area)
[out]pointspointer which finally points to an array of the generated points
[out]numPtsnumber of generated points
Returns
ERR_NONE on success

◆ ALG3D_sampleMeshDensityNormals()

int __cdecl ALG3D_sampleMeshDensityNormals ( const ALG3D_MESH  mesh,
double  density,
ALG3D_Point3d **  points,
ALG3D_Point3d **  normals,
size_t *  numPts 
)

#include <algorithm.h>

Samples a mesh uniformly with a given density of points and generates normal vectors at the samples.

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(data, indices, numTriangles, &mesh))) return 0;
double requestedDensity = 10.0;
ALG3D_Point3d* samples = 0;
ALG3D_Point3d* normals = 0;
size_t numSamples = 0;
//sample mesh
if (!ALG3D_checkResult(ALG3D_sampleMeshDensityNormals(mesh, requestedDensity, &samples, &normals, &numSamples))) {
return 0;
}
printf("[samples]: %I64d\n", numSamples);
Parameters
[in]meshmesh
[in]densitythe density (points/unit triangle area)
[out]pointspointer which finally points to an array of the generated points
[out]normalspointer which finally points to an array of the generated normals
[out]numPtsnumber of generated points/normals
Returns
ERR_NONE on success

◆ ALG3D_sampleMeshNormals()

int __cdecl ALG3D_sampleMeshNormals ( const ALG3D_MESH  mesh,
size_t  numSamples,
ALG3D_Point3d **  points,
ALG3D_Point3d **  normals,
size_t *  numPts 
)

#include <algorithm.h>

Samples a mesh uniformly with a given number of points and generates normal vectors at the samples.

The algorithm uses a random number generator to sample the points. Therefore the number of generated points can deviate slightly from the number of requested points (e.g. 50'000 requested -> 49'981 generated). The actual number of generated points is returned through the last parameter.

code example
//create mesh
ALG3D_MESH mesh = 0;
if (!ALG3D_checkResult(ALG3D_createMesh(data, indices, numTriangles, &mesh))) return 0;
size_t requestedSamples = 50000;
ALG3D_Point3d* samples = 0;
ALG3D_Point3d* normals = 0;
size_t numSamples = 0;
//sample mesh
if (!ALG3D_checkResult(ALG3D_sampleMeshNormals(mesh, requestedSamples, &samples, &normals, &numSamples))) {
return 0;
}
printf("[samples]: %I64d\n", numSamples);
Parameters
[in]meshmesh
[in]numSamplesthe number of requested samples
[out]pointspointer which finally points to an array of the generated points
[out]normalspointer which finally points to an array of the generated normals
[out]numPtsnumber of generated points/normals
Returns
ERR_NONE on success

◆ ALG3D_subdivideLongEdges()

int __cdecl ALG3D_subdivideLongEdges ( const ALG3D_Point3d points,
size_t *  indices,
size_t  numTriangles,
ALG3D_Point3d **  newPoints,
size_t **  newIndices,
size_t *  newNumTriangles,
double  maxEdgeLength 
)

#include <algorithm.h>

Subdivides all edges that are too long.

Parameters
[in]pointsPointer to the array of indexed points.
[in]indicesPointer to the array of triangle indices (3 consecutive define a triangle).
[in]numTrianglesNumber of triangles in the mesh (indices has size: 3 * numTriangles).
[out]newPointsPointer to an array of the resulting points (allocated by this function).
[out]newIndicesPointer to an array of the resulting indices (3 consecutive define a triangle, allocated by this function).
[out]newNumTrianglesResulting number of triangles (newIndices has size: 3 * newNumTriangles).
[in]maxEdgeLengthThe maximum edge length. All longer edges are subdivided until they are small enough.
code example
//split mesh
printf("[numTriangles before]: %I64d\n", numTriangles);
ALG3D_Point3d* newPoints = 0;
size_t* newIndices = 0;
size_t newNumTriangles = 0;
if (!ALG3D_checkResult(ALG3D_subdivideLongEdges(data, indices, numTriangles, &newPoints, &newIndices, &newNumTriangles, 0.5))) {
return 0;
}
printf("[numTriangles after]: %I64d\n", newNumTriangles);
Returns
ERR_NONE on success
ALG3D_computeSurfaceFeaturesKNN
int __cdecl ALG3D_computeSurfaceFeaturesKNN(const ALG3D_Point3d *pts, size_t numPts, double *values, size_t maxPoints, SurfaceFeatureType type)
Computes surface features for each point of a given point set from K-Nearest-Neighbours.
Definition: algorithm.cpp:1250
ALG3D_computeSmoothedThinning
int __cdecl ALG3D_computeSmoothedThinning(ALG3D_Point3d *pts, size_t *numPts, double radius)
Computes a combined homogeneous thinning and smoothing of a 3d point set.
Definition: algorithm.cpp:318
ALG3D_computeNormalVectorsKNNTree
int __cdecl ALG3D_computeNormalVectorsKNNTree(const ALG3D_KDTREE tree, ALG3D_Point3d *normals, size_t maxPoints)
Computes surface normals vector for the given pointcloud (represented by its KdTree) from K-Nearest-N...
Definition: algorithm.cpp:701
ALG3D_computeCurvatureThinning
int __cdecl ALG3D_computeCurvatureThinning(ALG3D_Point3d *pts, size_t *numPts, double maxRadius, double minRadius)
Computes a curvature based thinning of a 3d point set.
Definition: algorithm.cpp:2025
ALG3D_freeMemory
int __cdecl ALG3D_freeMemory(void *data)
Releases the memory of an array that was allocated internally. It is up to the application to assure ...
Definition: interface.cpp:127
ALG3D_raytracing_allIntersections
int __cdecl ALG3D_raytracing_allIntersections(const ALG3D_MESHTREE meshTree, ALG3D_Point3d rayOrigin, ALG3D_Point3d rayDirection, double maxHitDistance, ALG3D_Intersection **intersections, size_t *numIntersections)
Computes all intersections between a ray and a mesh.
Definition: algorithm.cpp:3471
ALG3D_createKdTree
int __cdecl ALG3D_createKdTree(const ALG3D_Point3d *data, size_t numPts, ALG3D_KDTREE *tree)
Builds a kdTree from given 3D data.
Definition: algorithm.cpp:1475
ALG3D_subdivideLongEdges
int __cdecl ALG3D_subdivideLongEdges(const ALG3D_Point3d *points, size_t *indices, size_t numTriangles, ALG3D_Point3d **newPoints, size_t **newIndices, size_t *newNumTriangles, double maxEdgeLength)
Subdivides all edges that are too long.
Definition: algorithm.cpp:3525
ALG3D_Intersection::intersection
ALG3D_Point3d intersection
Point of intersection of the ray with the mesh.
Definition: algorithm.h:292
ALG3D_dotProduct
double __cdecl ALG3D_dotProduct(const ALG3D_Point3d *vector1, const ALG3D_Point3d *vector2)
Returns the scalar/dot product of two vectors.
Definition: geometry.cpp:69
ALG3D_removeOutliers
int __cdecl ALG3D_removeOutliers(ALG3D_Point3d *pts, size_t *numPts, size_t maxPoints, double thresh)
Remove outliers from the point cloud.
Definition: algorithm.cpp:905
ALG3D_Point3d::vec
double vec[3]
point data, e.g. 0=x,1=y,2=z
Definition: interface.h:41
ALG3D_checkResult
int __cdecl ALG3D_checkResult(int code)
Function that checks for error codes and prints out the result. To activate console print out use ALG...
Definition: interface.cpp:38
ALG3D_computeThinningToPointNumber
int __cdecl ALG3D_computeThinningToPointNumber(ALG3D_Point3d *pts, size_t *numPts, size_t resultingNumPoints)
Computes a homogeneous thinning of 3d point set to a given number of resulting points.
Definition: algorithm.cpp:279
ALG3D_Intersection::t
double t
Distance along the ray (t parameter from ray equation: o + t*d).
Definition: algorithm.h:293
ALG3D_getTrianglePoints
int __cdecl ALG3D_getTrianglePoints(const ALG3D_MESH mesh, size_t triangleIndex, ALG3D_Point3d *a, ALG3D_Point3d *b, ALG3D_Point3d *c)
Retrieves the 3 vertices of a triangle in a mesh. Use this function to get the triangle (points),...
Definition: algorithm.cpp:2761
ALG3D_Point3d
Data type for 3d points/vectors with a user-defined pointer.
Definition: interface.h:32
ALG3D_computeOutlierFactor
int __cdecl ALG3D_computeOutlierFactor(const ALG3D_Point3d *pts, size_t numPts, double *values, size_t maxPoints)
Computes the local outlier factors of the points from a point cloud.
Definition: algorithm.cpp:802
ALG3D_removeOutliersTree
int __cdecl ALG3D_removeOutliersTree(ALG3D_KDTREE tree, size_t maxPoints, double thresh)
Remove outliers from the point cloud.
Definition: algorithm.cpp:961
ALG3D_computeNormalVectorsKNNTreeFast
int __cdecl ALG3D_computeNormalVectorsKNNTreeFast(const ALG3D_KDTREE tree, ALG3D_Point3d *normals, size_t maxPoints)
Computes surface normals vector for the given pointcloud (represented by its KdTree) from K-Nearest-N...
Definition: algorithm.cpp:756
ALG3D_computeDistances2Mesh
int __cdecl ALG3D_computeDistances2Mesh(const ALG3D_MESHTREE meshTree, const ALG3D_Point3d *pts, size_t numPts, double maxDistance, double *distances)
Computes all signed distances of a point set to a mesh given as a kd-tree.
Definition: algorithm.cpp:2983
ALG3D_raytracing_doesIntersect
int __cdecl ALG3D_raytracing_doesIntersect(const ALG3D_MESHTREE meshTree, ALG3D_Point3d rayOrigin, ALG3D_Point3d rayDirection, double maxHitDistance, int *doesIntersect)
Checks if a ray intersects with a mesh.
Definition: algorithm.cpp:3365
ALG3D_sampleMeshDensityNormals
int __cdecl ALG3D_sampleMeshDensityNormals(const ALG3D_MESH mesh, double density, ALG3D_Point3d **points, ALG3D_Point3d **normals, size_t *numPts)
Samples a mesh uniformly with a given density of points and generates normal vectors at the samples.
Definition: algorithm.cpp:3312
ALG3D_computeNormalVectorsKNN
int __cdecl ALG3D_computeNormalVectorsKNN(const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, size_t maxPoints)
Computes surface normals vector for the given pointcloud from K-Nearest-Neighbours.
Definition: algorithm.cpp:603
ALG3D_computeSurfaceFeaturesTreeFast
int __cdecl ALG3D_computeSurfaceFeaturesTreeFast(const ALG3D_KDTREE tree, double *values, double radius, SurfaceFeatureType type)
Computes surface features for each point of a given point set (represented by its KdTree) within a ne...
Definition: algorithm.cpp:1194
ALG3D_computeSmoothing
int __cdecl ALG3D_computeSmoothing(const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *ptsOut, double radius, SmoothingMethod method)
Computes an edge preserving smoothing of point cloud given by a KD-Tree.
Definition: algorithm.cpp:357
ALG3D_computeNormalVectorsKNNFast
int __cdecl ALG3D_computeNormalVectorsKNNFast(const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, size_t maxPoints)
Computes surface normals vector for the given pointcloud from K-Nearest-Neighbours.
Definition: algorithm.cpp:655
ALG3D_readXYZ
int __cdecl ALG3D_readXYZ(const char *fname, ALG3D_Point3d **data, size_t *numPts)
Reads XYZ-data from a file.
Definition: io.cpp:67
ALG3D_computeCurvatureThinningFast
int __cdecl ALG3D_computeCurvatureThinningFast(ALG3D_Point3d *pts, size_t *numPts, double maxRadius, double minRadius)
Computes a curvature based thinning of a 3d point set.
Definition: algorithm.cpp:2084
ALG3D_computeSurfaceFeaturesTree
int __cdecl ALG3D_computeSurfaceFeaturesTree(const ALG3D_KDTREE tree, double *values, double radius, SurfaceFeatureType type)
Computes surface features for each point of a given point set (represented by its KdTree) within a ne...
Definition: algorithm.cpp:1134
ALG3D_findNearestNormalCompatibleNeighbor
int __cdecl ALG3D_findNearestNormalCompatibleNeighbor(const ALG3D_KDTREE tree, const ALG3D_Point3d *treeNormals, ALG3D_Point3d pt, ALG3D_Point3d ptNormal, double radius, double minimumDotProduct, ALG3D_Point3d *nn)
Finds the nearest neighbour within a query radius to a given point with a compatible normal and uses ...
Definition: algorithm.cpp:1588
EdgePreserving
@ EdgePreserving
Shape and edge preserving smoothing.
Definition: algorithm.h:39
ALG3D_Intersection::triangleIndex
size_t triangleIndex
Index of the intersected triangle (use ALG3D_getTrianglePoints to retrieve the corresponding triangle...
Definition: algorithm.h:294
ALG3D_computeNormalVectorsTree
int __cdecl ALG3D_computeNormalVectorsTree(const ALG3D_KDTREE tree, ALG3D_Point3d *normals, double radius)
Computes surface normals for the given pointcloud (represented by its KdTree) within a neighborhood d...
Definition: algorithm.cpp:448
ALG3D_computeNormalVectors
int __cdecl ALG3D_computeNormalVectors(const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, double radius)
Computes surface normals for the given pointcloud within a neighborhood defined by a radius.
Definition: algorithm.cpp:404
ALG3D_computeSmoothingTree
int __cdecl ALG3D_computeSmoothingTree(const ALG3D_KDTREE tree, ALG3D_Point3d *ptsOut, double radius, SmoothingMethod method)
Computes the smoothing of point cloud given by a KD-Tree.
Definition: algorithm.cpp:2239
ALG3D_computeDistances2Pointcloud
int __cdecl ALG3D_computeDistances2Pointcloud(const ALG3D_KDTREE tree, const ALG3D_Point3d *pts, size_t numPts, double maxDistance, double *distances)
Computes all distance of a point set to another point set given as a kd-tree.
Definition: algorithm.cpp:1905
ALG3D_createMeshTree
int __cdecl ALG3D_createMeshTree(const ALG3D_MESH mesh, ALG3D_MESHTREE *meshTree)
Builds a kdTree from a mesh.
Definition: algorithm.cpp:2795
ALG3D_computeSurfaceFeaturesKNNTree
int __cdecl ALG3D_computeSurfaceFeaturesKNNTree(const ALG3D_KDTREE tree, double *values, size_t maxPoints, SurfaceFeatureType type)
Computes surface features for each point of a given point set (represented by its KdTree) from K-Near...
Definition: algorithm.cpp:1362
ALG3D_computeSurfaceFeaturesFast
int __cdecl ALG3D_computeSurfaceFeaturesFast(const ALG3D_Point3d *pts, size_t numPts, double *values, double radius, SurfaceFeatureType type)
Computes surface features for each point of a given point set within a neighborhood defined by a radi...
Definition: algorithm.cpp:1081
ALG3D_computeSurfaceFeaturesKNNFast
int __cdecl ALG3D_computeSurfaceFeaturesKNNFast(const ALG3D_Point3d *pts, size_t numPts, double *values, size_t maxPoints, SurfaceFeatureType type)
Computes surface features for each point of a given point set from K-Nearest-Neighbours.
Definition: algorithm.cpp:1309
ALG3D_computeNormalVectorsFast
int __cdecl ALG3D_computeNormalVectorsFast(const ALG3D_Point3d *pts, size_t numPts, ALG3D_Point3d *normals, double radius)
Computes surface normals for the given pointcloud within a neighborhood defined by a radius.
Definition: algorithm.cpp:504
IntrinsicCurvature
@ IntrinsicCurvature
Curvature value that is derived from the directions and the magnitudes of variance of the local neigh...
Definition: algorithm.h:184
ALG3D_findKNearestNormalCompatibleNeighbors
int __cdecl ALG3D_findKNearestNormalCompatibleNeighbors(const ALG3D_KDTREE tree, const ALG3D_Point3d *treeNormals, ALG3D_Point3d pt, ALG3D_Point3d ptNormal, size_t maxPoints, double minimumDotProduct, ALG3D_Point3d **vNN, size_t *numNN)
Finds the k-nearest neighboring points with compatible normal vectors to a given point.
Definition: algorithm.cpp:1691
ALG3D_computeConnectedRegions
int __cdecl ALG3D_computeConnectedRegions(const ALG3D_Point3d *ptsIn, size_t numIn, double radius, size_t *regionIdx, size_t *numIdx)
Computes spatially connected points and isolated regions.
Definition: algorithm.cpp:150
ALG3D_computeSurfaceFeatures
int __cdecl ALG3D_computeSurfaceFeatures(const ALG3D_Point3d *pts, size_t numPts, double *values, double radius, SurfaceFeatureType type)
Computes surface features for each point of a given point set within a neighborhood defined by a radi...
Definition: algorithm.cpp:1022
ALG3D_createMesh
int __cdecl ALG3D_createMesh(const ALG3D_Point3d *data, size_t *indices, size_t numTriangles, ALG3D_MESH *mesh)
Builds a mesh from given points and indices. Three consecutive entries in the indices array define th...
Definition: algorithm.cpp:2694
ALG3D_computeNormalVectorsTreeFast
int __cdecl ALG3D_computeNormalVectorsTreeFast(const ALG3D_KDTREE tree, ALG3D_Point3d *normals, double radius)
Computes surface normals vector for the given pointcloud (represented by its KdTree) within a neighbo...
Definition: algorithm.cpp:553
Gaussian
@ Gaussian
Gaussian weighted mean (fast, but does not preserve shape or features)
Definition: algorithm.h:37
ALG3D_computeThinningTree
int __cdecl ALG3D_computeThinningTree(ALG3D_KDTREE tree, double radius)
Computes the homogeneous thinning of a point cloud given by a KdTree.
Definition: algorithm.cpp:1956
ALG3D_computeSurfaceFeaturesKNNTreeFast
int __cdecl ALG3D_computeSurfaceFeaturesKNNTreeFast(const ALG3D_KDTREE tree, double *values, size_t maxPoints, SurfaceFeatureType type)
Computes surface features for each point of a given point set (represented by its KdTree) from K-Near...
Definition: algorithm.cpp:1422
ALG3D_sampleMeshNormals
int __cdecl ALG3D_sampleMeshNormals(const ALG3D_MESH mesh, size_t numSamples, ALG3D_Point3d **points, ALG3D_Point3d **normals, size_t *numPts)
Samples a mesh uniformly with a given number of points and generates normal vectors at the samples.
Definition: algorithm.cpp:3215
ALG3D_findNormalCompatibleNeighbors
int __cdecl ALG3D_findNormalCompatibleNeighbors(const ALG3D_KDTREE tree, const ALG3D_Point3d *treeNormals, ALG3D_Point3d pt, ALG3D_Point3d ptNormal, double radius, double minimumDotProduct, ALG3D_Point3d **vNN, size_t *numNN)
Finds all neighboring points within a query radius with compatible normal vectors to a given point us...
Definition: algorithm.cpp:1795
ExtrinsicCurvature
@ ExtrinsicCurvature
Curvature value that is derived from the inverse radius of the sphere which is representing/touching ...
Definition: algorithm.h:185
ALG3D_raytracing_firstIntersection
int __cdecl ALG3D_raytracing_firstIntersection(const ALG3D_MESHTREE meshTree, ALG3D_Point3d rayOrigin, ALG3D_Point3d rayDirection, double maxHitDistance, ALG3D_Intersection *intersection, int *doesIntersect)
Computes the first intersection between a ray and a mesh.
Definition: algorithm.cpp:3414
ALG3D_computeConnectedRegionsTree
int __cdecl ALG3D_computeConnectedRegionsTree(const ALG3D_KDTREE tree, double radius, size_t *regionIdx, size_t *numIdx)
Computes spatially connected points and isolated regions using a precomputed KdTree.
Definition: algorithm.cpp:193
ALG3D_Intersection
Intersection between a ray and a triangle mesh.
Definition: algorithm.h:290
ALG3D_computeOutlierFactorTree
int __cdecl ALG3D_computeOutlierFactorTree(const ALG3D_KDTREE tree, double *values, size_t maxPoints)
Computes the local outlier factor of the points from a point cloud (represented by its KdTree).
Definition: algorithm.cpp:846
ALG3D_computeThinningToNeighborhood
int __cdecl ALG3D_computeThinningToNeighborhood(ALG3D_Point3d *pts, size_t *numPts, double radius)
Computes a homogeneous thinning of 3d point set to a given radius (neighborhood).
Definition: algorithm.cpp:239