VTK  9.7.1
vtkSurfaceNets3D.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
197 #ifndef vtkSurfaceNets3D_h
198 #define vtkSurfaceNets3D_h
199 
200 #include "vtkConstrainedSmoothingFilter.h" // Perform mesh smoothing
201 #include "vtkContourValues.h" // Needed for direct access to ContourValues
202 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
203 #include "vtkFiltersCoreModule.h" // For export macro
204 #include "vtkPolyDataAlgorithm.h"
205 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
206 
207 #include <vector> // For selected seeds
208 
209 VTK_ABI_NAMESPACE_BEGIN
210 
211 class vtkImageData;
212 
213 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkSurfaceNets3D : public vtkPolyDataAlgorithm
214 {
215 public:
217 
221  static vtkSurfaceNets3D* New();
223  void PrintSelf(ostream& os, vtkIndent indent) override;
225 
230  vtkMTimeType GetMTime() override;
231 
233 
246  void SetValue(int i, double value) { this->Labels->SetValue(i, value); }
247  void SetLabel(int i, double value) { this->Labels->SetValue(i, value); }
249 
251 
254  double GetValue(int i) { return this->Labels->GetValue(i); }
255  double GetLabel(int i) { return this->Labels->GetValue(i); }
257 
259 
263  double* GetValues() { return this->Labels->GetValues(); }
264  double* GetLabels() { return this->Labels->GetValues(); }
266 
268 
273  void GetValues(double* contourValues) { this->Labels->GetValues(contourValues); }
274  void GetLabels(double* contourValues) { this->Labels->GetValues(contourValues); }
276 
278 
285  void SetNumberOfLabels(int number) { this->Labels->SetNumberOfContours(number); }
286  void SetNumberOfContours(int number) { this->Labels->SetNumberOfContours(number); }
288 
290 
293  vtkIdType GetNumberOfLabels() { return this->Labels->GetNumberOfContours(); }
294  vtkIdType GetNumberOfContours() { return this->Labels->GetNumberOfContours(); }
296 
298 
302  void GenerateLabels(int numLabels, double range[2])
303  {
304  this->Labels->GenerateValues(numLabels, range);
305  }
306  void GenerateValues(int numContours, double range[2])
307  {
308  this->Labels->GenerateValues(numContours, range);
309  }
310  void GenerateLabels(int numLabels, double rangeStart, double rangeEnd)
311  {
312  this->Labels->GenerateValues(numLabels, rangeStart, rangeEnd);
313  }
314  void GenerateValues(int numContours, double rangeStart, double rangeEnd)
315  {
316  this->Labels->GenerateValues(numContours, rangeStart, rangeEnd);
317  }
319 
321 
331  vtkSetMacro(BackgroundLabel, double);
332  vtkGetMacro(BackgroundLabel, double);
334 
336 
340  vtkSetMacro(ArrayComponent, int);
341  vtkGetMacro(ArrayComponent, int);
343 
347  enum MeshType
348  {
349  MESH_TYPE_DEFAULT = 0,
351  MESH_TYPE_QUADS
352  };
353 
355 
365  vtkSetClampMacro(OutputMeshType, int, MESH_TYPE_DEFAULT, MESH_TYPE_QUADS);
366  vtkGetMacro(OutputMeshType, int);
367  void SetOutputMeshTypeToDefault() { this->SetOutputMeshType(MESH_TYPE_DEFAULT); }
368  void SetOutputMeshTypeToTriangles() { this->SetOutputMeshType(MESH_TYPE_TRIANGLES); }
369  void SetOutputMeshTypeToQuads() { this->SetOutputMeshType(MESH_TYPE_QUADS); }
371 
372  // The following code is used to control the smoothing process. Internally
373  // there is a vtkConstrainedSmoothingFilter that can be directly
374  // manipulated. In addition, methods that delegate to this filter are also
375  // provided.
376 
378 
383  vtkSetMacro(Smoothing, bool);
384  vtkGetMacro(Smoothing, bool);
385  vtkBooleanMacro(Smoothing, bool);
387 
389 
394  void SetNumberOfIterations(int n) { this->Smoother->SetNumberOfIterations(n); }
395  int GetNumberOfIterations() { return this->Smoother->GetNumberOfIterations(); }
396  void SetRelaxationFactor(double f) { this->Smoother->SetRelaxationFactor(f); }
397  double GetRelaxationFactor() { return this->Smoother->GetRelaxationFactor(); }
398  void SetConstraintDistance(double d) { this->Smoother->SetConstraintDistance(d); }
399  double GetConstraintDistance() { return this->Smoother->GetConstraintDistance(); }
400  void SetConstraintBox(double sx, double sy, double sz)
401  {
402  this->Smoother->SetConstraintBox(sx, sy, sz);
403  }
404  void SetConstraintBox(double s[3]) { this->Smoother->SetConstraintBox(s); }
405  double* GetConstraintBox() VTK_SIZEHINT(3) { return this->Smoother->GetConstraintBox(); }
406  void GetConstraintBox(double s[3]) { this->Smoother->GetConstraintBox(s); }
408  {
409  this->Smoother->SetConstraintStrategyToConstraintDistance();
410  }
412  {
413  this->Smoother->SetConstraintStrategyToConstraintBox();
414  }
415  int GetConstraintStrategy() { return this->Smoother->GetConstraintStrategy(); }
417 
419 
431  vtkSetMacro(AutomaticSmoothingConstraints, bool);
432  vtkGetMacro(AutomaticSmoothingConstraints, bool);
433  vtkBooleanMacro(AutomaticSmoothingConstraints, bool);
434  vtkSetClampMacro(ConstraintScale, double, 0, 100);
435  vtkGetMacro(ConstraintScale, double);
437 
439 
445  VTK_DEPRECATED_IN_9_7_0("No longer used")
446  virtual void SetOptimizedSmoothingStencils(bool) {}
447  VTK_DEPRECATED_IN_9_7_0("No longer used")
448  virtual bool GetOptimizedSmoothingStencils() { return true; }
449  VTK_DEPRECATED_IN_9_7_0("No longer used")
450  virtual void OptimizedSmoothingStencilsOn() {}
451  VTK_DEPRECATED_IN_9_7_0("No longer used")
452  virtual void OptimizedSmoothingStencilsOff() {}
454 
456 
463  vtkGetSmartPointerMacro(Smoother, vtkConstrainedSmoothingFilter);
465 
466  // The following code is used to control what is produced for output.
467 
479  {
480  OUTPUT_STYLE_DEFAULT VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas instead") = 0,
481  OUTPUT_STYLE_BOUNDARY VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas instead") = 1,
482  OUTPUT_STYLE_SELECTED VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas instead") = 2,
483  };
484 
486 
492  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas instead")
493  vtkSetClampMacro(OutputStyle, int, 0, 2);
495  vtkGetMacro(OutputStyle, int);
496  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with OutputStyle=EXTRACT_ALL instead")
497  void SetOutputStyleToDefault();
498  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with OutputStyle=OUTPUT_STYLE_BOUNDARY instead")
499  void SetOutputStyleToBoundary();
500  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with ExtractionMode=EXTRACT_LABEL_SET instead")
501  void SetOutputStyleToSelected();
503 
505 
508  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with ExtractionMode=EXTRACT_LABEL_SET instead")
509  void InitializeSelectedLabelsList();
510  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with ExtractionMode=EXTRACT_LABEL_SET instead")
511  void AddSelectedLabel(double label);
512  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with ExtractionMode=EXTRACT_LABEL_SET instead")
513  void DeleteSelectedLabel(double label);
514  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with ExtractionMode=EXTRACT_LABEL_SET instead")
515  vtkIdType GetNumberOfSelectedLabels();
516  VTK_DEPRECATED_IN_9_7_0("Use vtkSurfaceNetsAtlas with ExtractionMode=EXTRACT_LABEL_SET instead")
517  double GetSelectedLabel(vtkIdType ithLabel);
519 
524  {
525  TRIANGULATION_GREEDY = 0,
527  TRIANGULATION_MIN_AREA
528  };
529 
531 
541  vtkSetClampMacro(TriangulationStrategy, int, TRIANGULATION_GREEDY, TRIANGULATION_MIN_AREA);
542  vtkGetMacro(TriangulationStrategy, int);
543  void SetTriangulationStrategyToGreedy() { this->SetTriangulationStrategy(TRIANGULATION_GREEDY); }
545  {
546  this->SetTriangulationStrategy(TRIANGULATION_MIN_EDGE);
547  }
549  {
550  this->SetTriangulationStrategy(TRIANGULATION_MIN_AREA);
551  }
553 
555 
565  vtkSetMacro(DataCaching, bool);
566  vtkGetMacro(DataCaching, bool);
567  vtkBooleanMacro(DataCaching, bool);
569 
570 protected:
572  ~vtkSurfaceNets3D() override = default;
573 
574  // Support visualization pipeline operations.
576  int FillInputPortInformation(int port, vtkInformation* info) override;
577 
578  // Support the contouring operation.
584 
585  // Support smoothing.
586  bool Smoothing;
590 
591  // Support data caching of the extracted surface nets. This is used to
592  // avoid repeated surface extraction when only smoothing filter
593  // parameters are modified.
598  bool IsCacheEmpty();
599  void CacheData(vtkPolyData* pd, vtkCellArray* ca);
600 
601  // Support output style
603  std::vector<double> SelectedLabels;
605 
606  // Support triangulation strategy
608 
609 private:
610  vtkSurfaceNets3D(const vtkSurfaceNets3D&) = delete;
611  void operator=(const vtkSurfaceNets3D&) = delete;
612 };
613 
614 VTK_ABI_NAMESPACE_END
615 #endif
adjust point positions using constrained smoothing
MeshType
This enum is used to control the type of the output polygonal mesh.
void SetNumberOfIterations(int n)
Convenience methods that delegate to the internal smoothing filter follow below.
bool AutomaticSmoothingConstraints
vtkSmartPointer< vtkPolyData > GeometryCache
void GetValues(double *contourValues)
Fill a supplied list with label values.
void SetConstraintStrategyToConstraintBox()
Convenience methods that delegate to the internal smoothing filter follow below.
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
vtkSmartPointer< vtkContourValues > Labels
double GetValue(int i)
Get the ith label value.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
int GetConstraintStrategy()
Convenience methods that delegate to the internal smoothing filter follow below.
vtkSmartPointer< vtkConstrainedSmoothingFilter > Smoother
vtkIdType GetNumberOfLabels()
Get the number of labels in the list of label values.
void GenerateLabels(int numLabels, double range[2])
Generate numLabels equally spaced labels between the specified range.
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetRelaxationFactor(double f)
Convenience methods that delegate to the internal smoothing filter follow below.
void GetConstraintBox(double s[3])
Convenience methods that delegate to the internal smoothing filter follow below.
void SetOutputMeshTypeToDefault()
Control the type of output mesh.
void SetTriangulationStrategyToMinArea()
Specify the strategy to triangulate the quads (not applicable if the output mesh type is set to MESH_...
void SetOutputMeshTypeToQuads()
Control the type of output mesh.
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
void SetLabel(int i, double value)
Set a particular label value at label number i.
int GetNumberOfIterations()
Convenience methods that delegate to the internal smoothing filter follow below.
void GenerateLabels(int numLabels, double rangeStart, double rangeEnd)
Generate numLabels equally spaced labels between the specified range.
OutputType
This enum is used to control the production of the filter output.
void GenerateValues(int numContours, double rangeStart, double rangeEnd)
Generate numLabels equally spaced labels between the specified range.
static vtkPolyDataAlgorithm * New()
void SetConstraintBox(double sx, double sy, double sz)
Convenience methods that delegate to the internal smoothing filter follow below.
Superclass for algorithms that produce only polydata as output.
void SetConstraintDistance(double d)
Convenience methods that delegate to the internal smoothing filter follow below.
vtkTimeStamp SmoothingTime
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIdType GetNumberOfContours()
Get the number of labels in the list of label values.
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkSmartPointer< vtkCellArray > StencilsCache
double GetConstraintDistance()
Convenience methods that delegate to the internal smoothing filter follow below.
void SetValue(int i, double value)
Set a particular label value at label number i.
void SetTriangulationStrategyToGreedy()
Specify the strategy to triangulate the quads (not applicable if the output mesh type is set to MESH_...
#define VTK_SIZEHINT(...)
TriangulationType
This enum is used to control how quadrilaterals are triangulated.
double * GetValues()
Get a pointer to an array of labels.
query-driven extraction of regions and patches from any SurfaceNets filter output ...
void SetConstraintBox(double s[3])
Convenience methods that delegate to the internal smoothing filter follow below.
void GetLabels(double *contourValues)
Fill a supplied list with label values.
object to represent cell connectivity
Definition: vtkCellArray.h:177
generate smoothed isocontours from segmented 3D image data (i.e., "label maps")
void GenerateValues(int numContours, double range[2])
Generate numLabels equally spaced labels between the specified range.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store zero or more vtkInformation instances.
double * GetLabels()
Get a pointer to an array of labels.
double GetRelaxationFactor()
Convenience methods that delegate to the internal smoothing filter follow below.
#define VTK_MARSHALAUTO
vtkTimeStamp SelectedLabelsTime
double GetLabel(int i)
Get the ith label value.
#define VTK_DEPRECATED_IN_9_7_0(reason)
void SetNumberOfContours(int number)
Set the number of labels to place into the list.
std::vector< double > SelectedLabels
void SetConstraintStrategyToConstraintDistance()
Convenience methods that delegate to the internal smoothing filter follow below.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetTriangulationStrategyToMinEdge()
Specify the strategy to triangulate the quads (not applicable if the output mesh type is set to MESH_...
double * GetConstraintBox()
Convenience methods that delegate to the internal smoothing filter follow below.
void SetOutputMeshTypeToTriangles()
Control the type of output mesh.
void SetNumberOfLabels(int number)
Set the number of labels to place into the list.