VTK  9.7.1
vtkGeneralizedSurfaceNets3D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
134 #ifndef vtkGeneralizedSurfaceNets3D_h
135 #define vtkGeneralizedSurfaceNets3D_h
136 
137 #include "vtkConstrainedSmoothingFilter.h" // Perform surface smoothing
138 #include "vtkContourValues.h" // Manage contour values
139 #include "vtkFiltersMeshingModule.h" // For export macro
140 #include "vtkPolyDataAlgorithm.h"
141 #include "vtkStaticPointLocator.h" // For point locator
142 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
143 
144 VTK_ABI_NAMESPACE_BEGIN
145 
146 class VTKFILTERSMESHING_EXPORT VTK_MARSHALAUTO vtkGeneralizedSurfaceNets3D
147  : public vtkPolyDataAlgorithm
148 {
149 public:
151 
156  void PrintSelf(ostream& os, vtkIndent indent) override;
158 
159  //---------------The following are methods used to set/get and generate
160  //---------------contour labels. Contour labels are required to be
161  //---------------specified by this filter.
163 
175  void SetValue(int i, double value) { this->Labels->SetValue(i, value); }
176  void SetLabel(int i, double value) { this->Labels->SetValue(i, value); }
178 
180 
183  double GetValue(int i) { return this->Labels->GetValue(i); }
184  double GetLabel(int i) { return this->Labels->GetValue(i); }
186 
188 
192  double* GetValues() { return this->Labels->GetValues(); }
193  double* GetLabels() { return this->Labels->GetValues(); }
195 
197 
202  void GetValues(double* contourValues) { this->Labels->GetValues(contourValues); }
203  void GetLabels(double* contourValues) { this->Labels->GetValues(contourValues); }
205 
207 
214  void SetNumberOfLabels(int number) { this->Labels->SetNumberOfContours(number); }
215  void SetNumberOfContours(int number) { this->Labels->SetNumberOfContours(number); }
217 
219 
222  vtkIdType GetNumberOfLabels() { return this->Labels->GetNumberOfContours(); }
223  vtkIdType GetNumberOfContours() { return this->Labels->GetNumberOfContours(); }
225 
227 
231  void GenerateLabels(int numLabels, double range[2])
232  {
233  this->Labels->GenerateValues(numLabels, range);
234  }
235  void GenerateValues(int numContours, double range[2])
236  {
237  this->Labels->GenerateValues(numContours, range);
238  }
239  void GenerateLabels(int numLabels, double rangeStart, double rangeEnd)
240  {
241  this->Labels->GenerateValues(numLabels, rangeStart, rangeEnd);
242  }
243  void GenerateValues(int numContours, double rangeStart, double rangeEnd)
244  {
245  this->Labels->GenerateValues(numContours, rangeStart, rangeEnd);
246  }
248 
250 
257  vtkSetMacro(BackgroundLabel, int);
258  vtkGetMacro(BackgroundLabel, int);
260 
261  //---------------Done defining label-related methods.
263 
267  vtkGetMacro(BoundaryCapping, vtkTypeBool);
268  vtkSetMacro(BoundaryCapping, vtkTypeBool);
269  vtkBooleanMacro(BoundaryCapping, vtkTypeBool);
271 
273 
279  vtkGetMacro(MergePoints, vtkTypeBool);
280  vtkSetMacro(MergePoints, vtkTypeBool);
281  vtkBooleanMacro(MergePoints, vtkTypeBool);
283 
285 
293  vtkSetMacro(Smoothing, vtkTypeBool);
294  vtkGetMacro(Smoothing, vtkTypeBool);
295  vtkBooleanMacro(Smoothing, vtkTypeBool);
297 
299 
304  void SetNumberOfIterations(int n) { this->Smoother->SetNumberOfIterations(n); }
305  int GetNumberOfIterations() { return this->Smoother->GetNumberOfIterations(); }
306  void SetRelaxationFactor(double f) { this->Smoother->SetRelaxationFactor(f); }
307  double GetRelaxationFactor() { return this->Smoother->GetRelaxationFactor(); }
308  void SetConstraintDistance(double d) { this->Smoother->SetConstraintDistance(d); }
309  double GetConstraintDistance() { return this->Smoother->GetConstraintDistance(); }
311 
313 
328  vtkSetMacro(GenerateSmoothingStencils, vtkTypeBool);
329  vtkGetMacro(GenerateSmoothingStencils, vtkTypeBool);
330  vtkBooleanMacro(GenerateSmoothingStencils, vtkTypeBool);
332 
334 
346  vtkSetVector4Macro(SmoothingConstraints, unsigned char);
347  vtkGetVector4Macro(SmoothingConstraints, unsigned char);
348  void AllSmoothingConstraintsOn() { this->SetSmoothingConstraints(1, 1, 1, 1); }
349  void AllSmoothingConstraintsOff() { this->SetSmoothingConstraints(0, 0, 0, 0); }
350  void EdgeSmoothingConstraintOff() { this->SetSmoothingConstraints(1, 0, 1, 1); }
352 
354 
363  vtkGetSmartPointerMacro(Smoother, vtkConstrainedSmoothingFilter);
365 
372  enum MeshType
373  {
374  MESH_TYPE_DEFAULT = 0,
376  MESH_TYPE_POLYGONS
377  };
378 
380 
390  vtkSetClampMacro(OutputMeshType, int, MESH_TYPE_DEFAULT, MESH_TYPE_POLYGONS);
391  vtkGetMacro(OutputMeshType, int);
392  void SetOutputMeshTypeToDefault() { this->SetOutputMeshType(MESH_TYPE_DEFAULT); }
393  void SetOutputMeshTypeToTriangles() { this->SetOutputMeshType(MESH_TYPE_TRIANGLES); }
394  void SetOutputMeshTypeToPolygons() { this->SetOutputMeshType(MESH_TYPE_POLYGONS); }
396 
398 
404  vtkSetClampMacro(Padding, double, 0.001, 0.25);
405  vtkGetMacro(Padding, double);
407 
409 
414  vtkStaticPointLocator* GetLocator() { return this->Locator; }
416 
418 
424  vtkSetMacro(Validate, vtkTypeBool);
425  vtkGetMacro(Validate, vtkTypeBool);
426  vtkBooleanMacro(Validate, vtkTypeBool);
428 
430 
445  vtkSetClampMacro(PointOfInterest, vtkIdType, -1, VTK_ID_MAX);
446  vtkGetMacro(PointOfInterest, vtkIdType);
447  vtkSetObjectMacro(PointsOfInterest, vtkIdTypeArray);
448  vtkGetObjectMacro(PointsOfInterest, vtkIdTypeArray);
449  vtkSetClampMacro(MaximumNumberOfHullClips, vtkIdType, 1, VTK_ID_MAX);
450  vtkGetMacro(MaximumNumberOfHullClips, vtkIdType);
452 
454 
458  vtkSetClampMacro(PruneTolerance, double, 0.0, 0.5);
459  vtkGetMacro(PruneTolerance, double);
461 
463 
471  vtkSetClampMacro(BatchSize, unsigned int, 1, VTK_INT_MAX);
472  vtkGetMacro(BatchSize, unsigned int);
474 
479  int GetNumberOfThreads() { return this->NumberOfThreads; }
480 
485  int GetNumberOfPrunes() { return this->NumberOfPrunes; }
486 
491  vtkMTimeType GetMTime() override;
492 
493 protected:
495  ~vtkGeneralizedSurfaceNets3D() override = default;
496 
497  // Support the contouring operation by defining labels.
500 
501  // Algorithm control
502  vtkTypeBool BoundaryCapping; // produce boundary surfaces or not
503  vtkTypeBool MergePoints; // merge near coincident points or not
504  vtkTypeBool Smoothing; // enable built-in smoothing process
505 
506  // Internal classes Related to point location and smoothing control
508  vtkSmartPointer<vtkStaticPointLocator> Locator; // locator for finding proximal points
509 
510  // Control the type of output mesh. Triangles by default.
512 
513  // Related to internal Voronoi methods
514  double Padding; // amount to pad out input points bounding box
515  vtkTypeBool Validate; // Choose to validate and repair output
516  vtkTypeBool GenerateSmoothingStencils; // Produce smoothing stencils
517  unsigned char SmoothingConstraints[4]; // Specify which smoothing constraints are active
518  vtkIdType PointOfInterest; // specify a single input point to process
519  vtkSmartPointer<vtkIdTypeArray> PointsOfInterest; // list of points of interest
520  vtkIdType MaximumNumberOfHullClips; // limit the number of hull clips
521  double PruneTolerance; // prune tiny faces
522  unsigned int BatchSize; // process data in batches of specified size
523  int NumberOfThreads; // report on the number of threads used during processing
524  int NumberOfPrunes; // If spoke pruning is enabled, report number of pruning operations
525 
526  // Satisfy pipeline-related API
528  int FillInputPortInformation(int port, vtkInformation* info) override;
529 
530 private:
532  void operator=(const vtkGeneralizedSurfaceNets3D&) = delete;
533 };
534 
535 VTK_ABI_NAMESPACE_END
536 #endif
adjust point positions using constrained smoothing
void SetRelaxationFactor(double f)
Convenience methods that delegate to the internal smoothing filter follow below.
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
create a surface net from an unorganized set of segmented (i.e., labeled) points
vtkSmartPointer< vtkConstrainedSmoothingFilter > Smoother
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
#define VTK_INT_MAX
Definition: vtkType.h:192
void EdgeSmoothingConstraintOff()
If GenerateSmoothingStencils is on, this provides some control over each point's stencil creation...
dynamic, self-adjusting array of vtkIdType
vtkIdType GetNumberOfLabels()
Get the number of labels in the list of label values.
int vtkIdType
Definition: vtkType.h:363
void GetLabels(double *contourValues)
Fill a supplied list with label values.
double * GetValues()
Get a pointer to an array of labels.
double GetRelaxationFactor()
Convenience methods that delegate to the internal smoothing filter follow below.
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:64
void GetValues(double *contourValues)
Fill a supplied list with label values.
Superclass for algorithms that produce only polydata as output.
vtkStaticPointLocator * GetLocator()
Retrieve the internal locator to manually configure it, for example specifying the number of points p...
void SetLabel(int i, double value)
Set a particular label value at label number i.
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkSmartPointer< vtkStaticPointLocator > Locator
void SetNumberOfLabels(int number)
Set the number of labels to place into the list.
int GetNumberOfPrunes()
Return the number of hull prunes performed during execution.
void SetValue(int i, double value)
Set a particular label value at label number i.
virtual vtkMTimeType GetMTime()
Return this object's modified time.
void AllSmoothingConstraintsOn()
If GenerateSmoothingStencils is on, this provides some control over each point's stencil creation...
void GenerateLabels(int numLabels, double range[2])
Generate numLabels equally spaced labels between the specified range.
double GetConstraintDistance()
Convenience methods that delegate to the internal smoothing filter follow below.
quickly locate points in 3-space
double GetValue(int i)
Get the ith label value.
void GenerateValues(int numContours, double range[2])
Generate numLabels equally spaced labels between the specified range.
void GenerateLabels(int numLabels, double rangeStart, double rangeEnd)
Generate numLabels equally spaced labels between the specified range.
double * GetLabels()
Get a pointer to an array of labels.
void SetOutputMeshTypeToTriangles()
Control the type of output mesh.
void SetNumberOfIterations(int n)
Convenience methods that delegate to the internal smoothing filter follow below.
vtkSmartPointer< vtkContourValues > Labels
double GetLabel(int i)
Get the ith label value.
#define VTK_ID_MAX
Definition: vtkType.h:367
void SetNumberOfContours(int number)
Set the number of labels to place into the list.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int GetNumberOfThreads()
Return the number of threads actually used during execution.
MeshType
This enum is used to control the type of the output polygonal mesh.
void SetConstraintDistance(double d)
Convenience methods that delegate to the internal smoothing filter follow below.
Store zero or more vtkInformation instances.
#define VTK_MARSHALAUTO
int GetNumberOfIterations()
Convenience methods that delegate to the internal smoothing filter follow below.
vtkSmartPointer< vtkIdTypeArray > PointsOfInterest
vtkIdType GetNumberOfContours()
Get the number of labels in the list of label values.
void AllSmoothingConstraintsOff()
If GenerateSmoothingStencils is on, this provides some control over each point's stencil creation...
void SetOutputMeshTypeToDefault()
Control the type of output mesh.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GenerateValues(int numContours, double rangeStart, double rangeEnd)
Generate numLabels equally spaced labels between the specified range.
void SetOutputMeshTypeToPolygons()
Control the type of output mesh.