VTK  9.6.20260614
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
133
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
147VTK_ABI_NAMESPACE_BEGIN
148
149class vtkIdTypeArray;
150class vtkPolyData;
151
152class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkSurfaceNetsAtlas
154{
155public:
157
162 void PrintSelf(ostream& os, vtkIndent indent) override;
164
165 // ==========================================================================
166 // Extraction mode
167 // ==========================================================================
168
174
176
186 vtkSetClampMacro(ExtractionMode, int, EXTRACT_ALL, EXTRACT_LABEL_SET);
187 vtkGetMacro(ExtractionMode, int);
191
192 // ==========================================================================
193 // Output style
194 // ==========================================================================
195
201
203
220 vtkSetClampMacro(OutputStyle, int, OUTPUT_STYLE_ALL, OUTPUT_STYLE_BOUNDARY);
221 vtkGetMacro(OutputStyle, int);
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
255
257
265
267
274 void SetSelectedLabel(int i, vtkIdType label);
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
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);
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
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
489protected:
492
493 int FillInputPortInformation(int port, vtkInformation* info) override;
494
496 vtkInformationVector* outputVector) override;
497
498private:
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
537VTK_ABI_NAMESPACE_END
538#endif
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Composite dataset that groups datasets as a collection.
concrete dataset represents vertices, lines, polygons, and triangle strips
Hold a reference to a vtkObjectBase instance.
vtkIdType GetPatchCellCount(int patchID) const
Return the number of cells on the patch at patchID.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods to instantiate, print, and provide type information.
int GetPatchID(const std::string &name0, const std::string &name1) const
Return the patch ID for the patch defined by the (unordered) pair (label0, label1),...
void GetPatchLabels(int patchID, vtkIdType labels[2]) const
Fill labels with the (L0, L1) pair defining the patch at patchID, with L0 < L1.
void SetNumberOfSelectedLabels(int n)
Set the selection list to exactly n entries.
void GenerateSelectedLabels(vtkIdType rangeStart, vtkIdType rangeEnd)
Populate the selection list with numLabels equally spaced integer labels between rangeStart and range...
vtkIdType GetSelectedLabel(int i) const
Index-based access to the selection list.
int GetNumberOfLabels() const
Return the number of distinct labels in the input.
void RemoveSelectedLabel(vtkIdType label)
Add, remove, or replace a single label in the selection list.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Methods for subclasses to override to handle different pipeline requests.
bool HasLabel(const std::string &name) const
Return whether label exists in the atlas.
~vtkSurfaceNetsAtlas() override
std::vector< int > GetPatchesForLabel(const std::string &name) const
Returns the indices of every patch touching label.
std::vector< vtkIdType > GetAdjacentLabels(vtkIdType label) const
Return a list of labels that share a patch with label.
bool AreAdjacent(vtkIdType label0, vtkIdType label1) const
Return whether two labels share a patch.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int GetNumberOfLabelNames() const
Human-readable names for labels.
vtkIdType GetNumberOfPatches() const
Return the number of patches (unordered {L0, L1} pairs with L0 < L1) in the input.
int GetLIDForLabel(vtkIdType label) const
Translate between Label and LID.
void SetSelectedLabels(const std::vector< vtkIdType > &labels)
Set/Get the complete selection list.
vtkIdType GetLabelForName(const std::string &name) const
Reverse-lookup a label value by its name.
void RemoveLabelName(vtkIdType label)
Human-readable names for labels.
int GetPatchID(vtkIdType label0, vtkIdType label1) const
Return the patch ID for the patch defined by the (unordered) pair (label0, label1),...
std::vector< int > GetPatchesForLabel(vtkIdType label) const
Returns the indices of every patch touching label.
bool HasLabel(vtkIdType label) const
Return whether label exists in the atlas.
void SetOutputStyleToAll()
Specify which cells are included in each emitted Region partition.
void GenerateSelectedLabels(int numLabels, vtkIdType range[2])
Populate the selection list with numLabels equally spaced integer labels between rangeStart and range...
void SetOutputStyleToBoundary()
Specify which cells are included in each emitted Region partition.
virtual void SetExtractionMode(int)
Specify which regions are emitted in the output:
int GetNumberOfSelectedLabels() const
Set the selection list to exactly n entries.
void SetExtractionModeToAll()
Specify which regions are emitted in the output:
int GetLIDForLabel(const std::string &name) const
Translate between Label and LID.
virtual void SetOutputStyle(int)
Specify which cells are included in each emitted Region partition.
void SetLabelName(vtkIdType label, const std::string &name)
Human-readable names for labels.
void SetExtractionModeToLabelSet()
Specify which regions are emitted in the output:
std::string GetLabelName(vtkIdType label) const
Human-readable names for labels.
bool AreAdjacent(const std::string &name0, const std::string &name1) const
Return whether two labels share a patch.
void ClearSelectedLabels()
Add, remove, or replace a single label in the selection list.
void ClearLabelNames()
Human-readable names for labels.
void AddLabelName(vtkIdType label, const std::string &name)
Human-readable names for labels.
std::vector< vtkIdType > GetAdjacentLabels(const std::string &name) const
Return a list of labels that share a patch with label.
void SetSelectedLabel(int i, vtkIdType label)
Index-based access to the selection list.
void GenerateSelectedLabels(int numLabels, vtkIdType rangeStart, vtkIdType rangeEnd)
Populate the selection list with numLabels equally spaced integer labels between rangeStart and range...
vtkIdType GetLabelForLID(int lid) const
Translate between Label and LID.
static vtkSurfaceNetsAtlas * New()
Standard methods to instantiate, print, and provide type information.
std::vector< vtkIdType > GetSelectedLabels() const
Set/Get the complete selection list.
void AddSelectedLabel(vtkIdType label)
Add, remove, or replace a single label in the selection list.
record modification and/or execution time
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition vtkType.h:363
#define VTK_MARSHALAUTO