VTK  9.7.1
vtkSurfaceNetsAtlas.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 vtkSurfaceNetsAtlas_h
135 #define vtkSurfaceNetsAtlas_h
136 
137 #include "vtkFiltersCoreModule.h" // for export macro
139 #include "vtkSmartPointer.h" // for vtkSmartPointer
140 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
141 
142 #include <atomic> // for std::atomic
143 #include <memory> // for std::unique_ptr
144 #include <string> // for std::string
145 #include <vector> // for std::vector
146 
147 VTK_ABI_NAMESPACE_BEGIN
148 
149 class vtkIdTypeArray;
150 class vtkPolyData;
151 
152 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkSurfaceNetsAtlas
154 {
155 public:
157 
160  static vtkSurfaceNetsAtlas* New();
162  void PrintSelf(ostream& os, vtkIndent indent) override;
164 
165  // ==========================================================================
166  // Extraction mode
167  // ==========================================================================
168 
170  {
171  EXTRACT_ALL = 0,
172  EXTRACT_LABEL_SET = 1,
173  };
174 
176 
186  vtkSetClampMacro(ExtractionMode, int, EXTRACT_ALL, EXTRACT_LABEL_SET);
187  vtkGetMacro(ExtractionMode, int);
188  void SetExtractionModeToAll() { this->SetExtractionMode(EXTRACT_ALL); }
189  void SetExtractionModeToLabelSet() { this->SetExtractionMode(EXTRACT_LABEL_SET); }
191 
192  // ==========================================================================
193  // Output style
194  // ==========================================================================
195 
197  {
198  OUTPUT_STYLE_ALL = 0,
199  OUTPUT_STYLE_BOUNDARY = 1
200  };
201 
203 
220  vtkSetClampMacro(OutputStyle, int, OUTPUT_STYLE_ALL, OUTPUT_STYLE_BOUNDARY);
221  vtkGetMacro(OutputStyle, int);
222  void SetOutputStyleToAll() { this->SetOutputStyle(OUTPUT_STYLE_ALL); }
223  void SetOutputStyleToBoundary() { this->SetOutputStyle(OUTPUT_STYLE_BOUNDARY); }
225 
227 
237  vtkSetMacro(BackgroundLabel, vtkIdType);
238  vtkGetMacro(BackgroundLabel, vtkIdType);
240 
241  // ==========================================================================
242  // Selected labels (used when ExtractionMode is EXTRACT_LABEL_SET)
243  // ==========================================================================
244 
246 
251  void AddSelectedLabel(vtkIdType label);
252  void RemoveSelectedLabel(vtkIdType label);
253  void ClearSelectedLabels();
255 
257 
262  void SetNumberOfSelectedLabels(int n);
263  int GetNumberOfSelectedLabels() const;
265 
267 
274  void SetSelectedLabel(int i, vtkIdType label);
275  vtkIdType GetSelectedLabel(int i) const;
277 
279 
282  std::vector<vtkIdType> GetSelectedLabels() const;
283  void SetSelectedLabels(const std::vector<vtkIdType>& labels);
285 
287 
295  void GenerateSelectedLabels(int numLabels, vtkIdType rangeStart, vtkIdType rangeEnd);
296  void GenerateSelectedLabels(int numLabels, vtkIdType range[2]);
297  void GenerateSelectedLabels(vtkIdType rangeStart, vtkIdType rangeEnd);
299 
300  // ==========================================================================
301  // Label names
302  // ==========================================================================
303 
305 
316  int GetNumberOfLabelNames() const;
317  void SetLabelName(vtkIdType label, const std::string& name);
318  std::string GetLabelName(vtkIdType label) const;
319  void AddLabelName(vtkIdType label, const std::string& name);
320  void RemoveLabelName(vtkIdType label);
321  void ClearLabelNames();
323 
324  // ==========================================================================
325  // Optional outputs
326  // ==========================================================================
327 
329 
338  vtkSetMacro(GenerateRegions, bool);
339  vtkGetMacro(GenerateRegions, bool);
340  vtkBooleanMacro(GenerateRegions, bool);
342 
344 
358  vtkSetMacro(GeneratePatches, bool);
359  vtkGetMacro(GeneratePatches, bool);
360  vtkBooleanMacro(GeneratePatches, bool);
362 
364 
379  vtkSetMacro(ResolveNonManifoldPoints, bool);
380  vtkGetMacro(ResolveNonManifoldPoints, bool);
381  vtkBooleanMacro(ResolveNonManifoldPoints, bool);
383 
384  // ==========================================================================
385  // Atlas inspection (Phase 2: queries against the built atlas)
386  //
387  // These methods inspect the atlas built from the most recent Update().
388  // They require the filter to have been executed at least once with a
389  // valid input; otherwise they return zero / empty results (the
390  // "invalid" sentinel for index-returning methods is -1).
391  //
392  // None of these methods trigger re-execution.
393  // ==========================================================================
394 
395  // -- Label queries ---------------------------------------------------------
396 
400  int GetNumberOfLabels() const;
401 
403 
406  bool HasLabel(vtkIdType label) const;
407  bool HasLabel(const std::string& name) const;
409 
414  vtkIdType GetLabelForName(const std::string& name) const;
415 
417 
422  int GetLIDForLabel(vtkIdType label) const;
423  int GetLIDForLabel(const std::string& name) const;
424  vtkIdType GetLabelForLID(int lid) const;
426 
427  // -- Adjacency queries -----------------------------------------------------
428 
430 
434  bool AreAdjacent(vtkIdType label0, vtkIdType label1) const;
435  bool AreAdjacent(const std::string& name0, const std::string& name1) const;
437 
439 
443  std::vector<vtkIdType> GetAdjacentLabels(vtkIdType label) const;
444  std::vector<vtkIdType> GetAdjacentLabels(const std::string& name) const;
446 
447  // -- Patch queries ---------------------------------------------------------
448 
453  vtkIdType GetNumberOfPatches() const;
454 
460  void GetPatchLabels(int patchID, vtkIdType labels[2]) const;
461 
463 
468  int GetPatchID(vtkIdType label0, vtkIdType label1) const;
469  int GetPatchID(const std::string& name0, const std::string& name1) const;
471 
478  vtkIdType GetPatchCellCount(int patchID) const;
479 
481 
485  std::vector<int> GetPatchesForLabel(vtkIdType label) const;
486  std::vector<int> GetPatchesForLabel(const std::string& name) const;
488 
489 protected:
491  ~vtkSurfaceNetsAtlas() override;
492 
493  int FillInputPortInformation(int port, vtkInformation* info) override;
494 
495  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
496  vtkInformationVector* outputVector) override;
497 
498 private:
499  vtkSurfaceNetsAtlas(const vtkSurfaceNetsAtlas&) = delete;
500  void operator=(const vtkSurfaceNetsAtlas&) = delete;
501 
506  void BuildAtlas(vtkPolyData* input);
507 
508  template <bool IsPatch>
510  const std::vector<const std::vector<vtkIdType>*>& groups, vtkIdType label,
511  std::atomic<unsigned char>* ptUses, std::vector<vtkIdType>& pointMap) const;
512 
517  void BuildOutput(vtkPolyData* input, vtkPartitionedDataSetCollection* output) const;
518 
519  // -- Parameters ------------------------------------------------------------
520 
521  int ExtractionMode = EXTRACT_ALL;
522  int OutputStyle = OUTPUT_STYLE_BOUNDARY;
523  vtkIdType BackgroundLabel = 0;
524  bool GenerateRegions = true;
525  bool GeneratePatches = true;
526  bool ResolveNonManifoldPoints = false;
527 
528  std::vector<vtkIdType> Labels;
529 
530  // The atlas information
531  struct AtlasData;
532  std::unique_ptr<AtlasData> Atlas;
533 
534  vtkTimeStamp AtlasBuildTime;
535 };
536 
537 VTK_ABI_NAMESPACE_END
538 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Methods for subclasses to override to handle different pipeline requests.
record modification and/or execution time
Definition: vtkTimeStamp.h:24
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetOutputStyleToAll()
Specify which cells are included in each emitted Region partition.
Superclass for algorithms that produce vtkPartitionedDataSetCollectionAlgorithm.
void SetExtractionModeToAll()
Specify which regions are emitted in the output:
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
query-driven extraction of regions and patches from any SurfaceNets filter output ...
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
#define VTK_MARSHALAUTO
void SetOutputStyleToBoundary()
Specify which cells are included in each emitted Region partition.
void SetExtractionModeToLabelSet()
Specify which regions are emitted in the output:
Composite dataset that groups datasets as a collection.