ImFusion SDK 4.3
PoissonSurfaceReconstructionAlgorithm Class Reference

#include <ImFusion/Mesh/PoissonSurfaceReconstructionAlgorithm.h>

Algorithm for computing poisson reconstruction from a point cloud with normals. More...

+ Inheritance diagram for PoissonSurfaceReconstructionAlgorithm:

Detailed Description

Algorithm for computing poisson reconstruction from a point cloud with normals.

This is an Algorithm frontend for the low-level algorithm in PoissonReconstruction, which can be used directly if the application does not rely on the Algorithm interface being used or if one needs fine control over all algorithm parameters.

In this algorithm only the most relevant parameters of PoissonReconstruction are forwarded to the respective getters and setters, see PoissonReconstruction::PoissonParams for their documentation and for additional parameters that were omitted here.

A common use case for this algorithm is creating a Mesh out of a point cloud that was obtained from a 3D scanner (should there be multiple scans we need to register and merge them into a single point cloud first):

std::unique_ptr<Mesh> createMesh(const PointCloud& pc)
{
assert(pc.hasNormals());
PoissonSurfaceReconstructionAlgorithm algo(&pc);
algo.setSpacing(pc.bounds().extent().norm()*0.002); // triangle edge length approx 1/500th of object diameter
algo.setLevel(-1); //else this overrides setSpacing
//alternative: algo.setLevel(9); //divide the point cloud bounding box 9 times, leading to minimum voxel side lengths of approx 0.002*cube side length
algo.compute();
if (algo.status() == static_cast<int>(Algorithm::Status::Success))
return algo.takeOutput().extractFirst<Mesh>(); //this algorithm only has one output
else
return nullptr;
}
@ Success
Computation was successful.
Definition Algorithm.h:61
vec3 extent() const
Returns the extent of the bounding box (URB - LLF).
Represents a triangle mesh.
Definition Mesh.h:43
Data structure for point clouds.
Definition PointCloud.h:24
bool hasNormals() const
Return true if point cloud has normals.
Geometry::AlignedBox bounds() const override
Returns the axis-aligned bounding box of this data in world space.

In addition to the usually watertight Mesh produced by PoissonReconstruction this algorithm offers the option to filter the resulting mesh w.r.t distance to the original point cloud, allowing to keep gaps in the measurements open:

// [...] see above
algo.setSurfaceDistanceR1(pc.bounds().extent().norm()*0.002); // erase triangles that do not have a point as close to them as their minimum side length
algo.compute();
// [...] see above

setSurfaceDistanceR2() works together with setMaxAngleDegrees() to filter out faces by distance if also the angle between point and face normal falls below the given threshold.

Colors are taken from the point cloud by default if the point cloud has colors. If this is not desired setColorSource() can be used. The other parameters have reasonable default values that should usually not need to be changed.

Public Types

enum  ColorSource { Color = 0 , NoColor = 1 , Density = 2 }
 Source of the color for the generated Mesh. More...
 
- Public Types inherited from Algorithm
enum  Status {
  Unknown = -1 , Success = 0 , Error = 1 , InvalidInput ,
  IncompleteInput , OutOfMemoryHost , OutOfMemoryGPU , UnsupportedGPU ,
  UnknownAction , AbortedByUser , User = 1000
}
 Status codes. More...
 

Public Member Functions

 PoissonSurfaceReconstructionAlgorithm (const PointCloud *pointCloud)
 
int level () const
 Octree level of the reconstruction.
 
void setLevel (int level)
 Sets level().
 
double spacing () const
 Voxel spacing of the output volume.
 
void setSpacing (double spacing)
 Sets spacing().
 
std::array< double, 2 > surfaceDistanceThresholds () const
 Thresholds for filtering generated triangles w.r.t their distance to the original point cloud.
 
void setSurfaceDistanceThresholds (double lowerBound, double upperBound)
 Sets surfaceDistanceThresholds().
 
double maxSurfaceDistance () const
 Maximum distance of generated triangles to original point cloud. Set to 0 to obtain watertight mesh which interpolates all holes.
 
void setMaxSurfaceDistance (double dist)
 Sets maxSurfaceDistance().
 
double surfaceDistanceR1 () const
 Maximum distance of generated triangles to original point cloud.
 
void setSurfaceDistanceR1 (double dist)
 Sets surfaceDistanceR1().
 
double surfaceDistanceR2 () const
 Maximum distance of generated triangles to original point cloud given similar normals.
 
void setSurfaceDistanceR2 (double dist)
 Sets surfaceDistanceR2().
 
double maxAngleDegrees () const
 Maximum normal deviation for surfaceDistanceThresholds().
 
void setMaxAngleDegrees (double angle)
 Sets maxAngleDegrees().
 
ColorSource colorSource () const
 Source for mesh colors.
 
void setColorSource (ColorSource source)
 Sets colorSource().
 
float samplesPerNode ()
 Minimum number of sample points that should fall within an octree node as the octree construction is adapted to sampling density.
 
void setSamplesPerNode (float val)
 Sets samplesPerNode().
 
PoissonReconstruction::DensityThresholdMode densityThresholdMode () const
 Mode of density thresholding.
 
void setDensityThresholdMode (PoissonReconstruction::DensityThresholdMode val)
 Sets densityThresholdMode().
 
float densityThreshold () const
 Threshold to be used for the respective densityThresholdMode().
 
void setDensityThreshold (float val)
 Sets densityThreshold().
 
void compute () override
 Execute the algorithm.
 
OwningDataList takeOutput () override
 Return any new Data that was created by the Algorithm during the last call to compute().
 
void configure (const Properties *p) override
 Configure this object instance by de-serializing the given Properties.
 
void configuration (Properties *p) const override
 Serialize the current object configuration into the given Properties object.
 
- Public Member Functions inherited from Algorithm
 Algorithm ()
 Default constructor will registers a single "compute" action that calls compute() and returns status().
 
virtual void setProgress (Progress *progress)
 Sets a Progress interface the algorithm can use to notify observers about its computing progress.
 
Progressprogress () const
 Returns the progress interface if set.
 
virtual int status () const
 Indicates the status of the last call to compute().
 
virtual bool survivesDataDeletion (const Data *) const
 Indicates whether the algorithm can handle (partial) deletion of the specified data, by default this checks whether the data is in the input list.
 
const FactoryInfofactoryInfo () const
 Returns the record describing how this Algorithm was instantiated by the AlgorithmFactory.
 
void setFactoryInfo (const FactoryInfo &value)
 Sets the record describing how this Algorithm was instantiated by the AlgorithmFactory.
 
Status runAction (const std::string &id)
 Run the action with name id if it exists.
 
const std::vector< Action > & actions ()
 Get a mapping from Action id to Action as registered in this algorithm.
 
- Public Member Functions inherited from Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Static Public Member Functions

static bool createCompatible (const DataList &data, Algorithm **a=0)
 Factory method to check for applicability or to create the algorithm.
 
- Static Public Member Functions inherited from Algorithm
static bool createCompatible (const DataList &data, Algorithm **a=nullptr)
 Factory function to check algorithm compatibility with input data and optionally instantiate it.
 

Additional Inherited Members

- Public Attributes inherited from Algorithm
Signal signalOutputChanged
 Signal should be emitted by Algorithms when their output/result has changed.
 
Signal signalParametersChanged
 Signal should be emitted by Algorithms when their parameter configuration has changed.
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 
- Protected Member Functions inherited from Algorithm
void loadDefaults ()
 
void registerAction (const std::string &id, const std::string &guiName, const std::function< Algorithm::Status(void)> &action)
 Register an action to be run via runAction.
 
template<typename D>
void registerAction (const std::string &id, const std::string &guiName, Algorithm::Status(D::*action)(void))
 Template version of runAction that can be used with a pointer to a member function.
 
void registerAction (const Action &action)
 Register an action.
 
- Protected Attributes inherited from Algorithm
std::string m_name
 Algorithm name.
 
Progressm_progress = nullptr
 Non-owing pointer to a progress interface. May be a nullptr.
 
FactoryInfo m_factoryInfo = {}
 Record describing how this algorithm was instantiated by the AlgorithmFactory.
 
int m_status = Status::Unknown
 Algorithm status after last call to compute()
 
std::vector< Actionm_actions
 Map of key given by the id of the action, of the available actions of this algorithm.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Member Enumeration Documentation

◆ ColorSource

Source of the color for the generated Mesh.

Enumerator
Color 

Take the color information from point-cloud.

NoColor 

Do not use any color information.

Density 

Colormap the density information.

Member Function Documentation

◆ level()

int level ( ) const
inline

Octree level of the reconstruction.

Overrides voxel spacing setting.

Set to -1 to use voxel spacing.

Default value is 7.

◆ spacing()

double spacing ( ) const
inline

Voxel spacing of the output volume.

Ignored if level is not -1.

Default value is 0.

◆ surfaceDistanceThresholds()

std::array< double, 2 > surfaceDistanceThresholds ( ) const
inline

Thresholds for filtering generated triangles w.r.t their distance to the original point cloud.

The two thresholds form a pair of <lower bound, upper bound>, which work as follows: The lower bound determines a distance below which triangles are always kept, the upper bound determines a distance above which triangles are always deleted. Between the two bounds the decision is based on maxAngleDegrees(): triangles in this range are deleted only if their normal deviates from the closest point's normal by more than maxAngleDegrees() degrees.

Set both values to 0.0 to disable the filtering.

Default values are <2.0, 4.0>.

◆ maxSurfaceDistance()

double maxSurfaceDistance ( ) const
inline

Maximum distance of generated triangles to original point cloud. Set to 0 to obtain watertight mesh which interpolates all holes.

Deprecated
"PoissonSurfaceReconstructionAlgorithm::maxSurfaceDistance is deprecated, instead use 'surfaceDistanceR1' and 'surfaceDistanceR2'"

◆ setMaxSurfaceDistance()

void setMaxSurfaceDistance ( double dist)
inline

Sets maxSurfaceDistance().

Deprecated
"PoissonSurfaceReconstructionAlgorithm::setMaxSurfaceDistance is deprecated, instead use 'setSurfaceDistanceR1' and 'setSurfaceDistanceR2'"

◆ surfaceDistanceR1()

double surfaceDistanceR1 ( ) const
inline

Maximum distance of generated triangles to original point cloud.

Set this and surfaceDistanceR2() to '0' to obtain watertight mesh which interpolates all holes.

Default value is 2.

Deprecated
"PoissonSurfaceReconstructionAlgorithm::surfaceDistanceR1 is deprecated, instead use 'surfaceDistanceThresholds'"

◆ setSurfaceDistanceR1()

void setSurfaceDistanceR1 ( double dist)
inline

Sets surfaceDistanceR1().

Deprecated
"PoissonSurfaceReconstructionAlgorithm::setSurfaceDistanceR1 is deprecated, instead use 'setSurfaceDistanceThresholds'"

◆ surfaceDistanceR2()

double surfaceDistanceR2 ( ) const
inline

Maximum distance of generated triangles to original point cloud given similar normals.

Works in connection with maxAngleDegrees() to filter out triangles that exceed the distance threshold and have a sufficiently similar normal to the closest point.

Set this and surfaceDistanceR1() to '0' to obtain watertight mesh which interpolates all holes.

Default value is 4.

Deprecated
"PoissonSurfaceReconstructionAlgorithm::surfaceDistanceR2 is deprecated, instead use 'surfaceDistanceThresholds'"

◆ setSurfaceDistanceR2()

void setSurfaceDistanceR2 ( double dist)
inline

Sets surfaceDistanceR2().

Deprecated
"PoissonSurfaceReconstructionAlgorithm::setSurfaceDistanceR2 is deprecated, instead use 'setSurfaceDistanceThresholds'"

◆ maxAngleDegrees()

double maxAngleDegrees ( ) const
inline

Maximum normal deviation for surfaceDistanceThresholds().

Works in connection with the two bounds to filter out triangles that have a distance between lower and upper bound and have a sufficiently different normal to the closest point.

Default value is 180.

◆ colorSource()

ColorSource colorSource ( ) const
inline

Source for mesh colors.

Default value is ColorSource::Color.

◆ samplesPerNode()

float samplesPerNode ( )
inline

Minimum number of sample points that should fall within an octree node as the octree construction is adapted to sampling density.

Default value is 1.5.

◆ densityThresholdMode()

PoissonReconstruction::DensityThresholdMode densityThresholdMode ( ) const
inline

Mode of density thresholding.

Default value is PoissonReconstruction::DensityThresholdMode::None.

◆ densityThreshold()

float densityThreshold ( ) const
inline

Threshold to be used for the respective densityThresholdMode().

Default value is 0.0.

◆ compute()

void compute ( )
overridevirtual

Execute the algorithm.

Implements Algorithm.

◆ takeOutput()

OwningDataList takeOutput ( )
overridevirtual

Return any new Data that was created by the Algorithm during the last call to compute().

The default implementation will return an empty list.

Note
Since ownership of the data is transferred, you can call this method only once between calls to compute().

Reimplemented from Algorithm.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Configure this object instance by de-serializing the given Properties.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configuration() for the inverse functionality

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Serialize the current object configuration into the given Properties object.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configure() for the inverse functionality

Reimplemented from Configurable.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close