VMTK
Loading...
Searching...
No Matches
vtkvmtkTopologicalSeamFilter Class Reference

Create a feature edge on a surface from a point and implicit plane function. More...

#include <vtkvmtkTopologicalSeamFilter.h>

Inheritance diagram for vtkvmtkTopologicalSeamFilter:
[legend]
Collaboration diagram for vtkvmtkTopologicalSeamFilter:
[legend]

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkTopologicalSeamFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetClosestPoint (double data[])
virtual double * GetClosestPoint ()
virtual void GetClosestPoint (double data[3])
virtual void SetSeamScalarsArrayName (const char *)
virtual char * GetSeamScalarsArrayName ()
virtual void SetSeamFunction (vtkImplicitFunction *)
virtual vtkImplicitFunction * GetSeamFunction ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkTopologicalSeamFilter * SafeDownCast (vtkObjectBase *o)
static vtkvmtkTopologicalSeamFilter * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkTopologicalSeamFilter ()
 ~vtkvmtkTopologicalSeamFilter ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

double ClosestPoint [3]
char * SeamScalarsArrayName
vtkImplicitFunction * SeamFunction

Detailed Description

Create a feature edge on a surface from a point and implicit plane function.

Evaluates SeamFunction (typically a vtkPlane) at every point of the input surface, walking outward from the point closest to ClosestPoint, and marks the points forming the resulting "seam" – where the surface crosses the implicit function – in the output point data array named SeamScalarsArrayName. This is used e.g. to cut a topological seam into a tubular surface prior to operations that require a disk-like (simply connected) topology, such as flattening/ unrolling for 2D visualization.

Definition at line 37 of file vtkvmtkTopologicalSeamFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkTopologicalSeamFilter::Superclass

Definition at line 40 of file vtkvmtkTopologicalSeamFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkTopologicalSeamFilter()

vtkvmtkTopologicalSeamFilter::vtkvmtkTopologicalSeamFilter ( )
protected

Definition at line 44 of file vtkvmtkTopologicalSeamFilter.cxx.

45{
46 this->ClosestPoint[0] = this->ClosestPoint[1] = this->ClosestPoint[2] = 0.0;
47 this->SeamScalarsArrayName = NULL;
48 this->SeamFunction = NULL;
49}

◆ ~vtkvmtkTopologicalSeamFilter()

vtkvmtkTopologicalSeamFilter::~vtkvmtkTopologicalSeamFilter ( )
protected

Definition at line 51 of file vtkvmtkTopologicalSeamFilter.cxx.

52{
53 if (this->SeamScalarsArrayName)
54 {
55 delete[] this->SeamScalarsArrayName;
56 this->SeamScalarsArrayName = NULL;
57 }
58
59 if (this->SeamFunction)
60 {
61 this->SeamFunction->Delete();
62 this->SeamFunction = NULL;
63 }
64}

Member Function Documentation

◆ IsTypeOf()

int vtkvmtkTopologicalSeamFilter::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkTopologicalSeamFilter::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkTopologicalSeamFilter * vtkvmtkTopologicalSeamFilter::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkTopologicalSeamFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkTopologicalSeamFilter * vtkvmtkTopologicalSeamFilter::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkTopologicalSeamFilter::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 273 of file vtkvmtkTopologicalSeamFilter.cxx.

274{
275 this->Superclass::PrintSelf(os,indent);
276}

◆ New()

vtkvmtkTopologicalSeamFilter * vtkvmtkTopologicalSeamFilter::New ( )
static

◆ SetClosestPoint()

virtual void vtkvmtkTopologicalSeamFilter::SetClosestPoint ( double data[])
virtual

Set/Get the (x,y,z) location used to find the starting point of the seam (the closest surface point is used). Default: (0,0,0).

◆ GetClosestPoint() [1/2]

virtual double * vtkvmtkTopologicalSeamFilter::GetClosestPoint ( )
virtual

Set/Get the (x,y,z) location used to find the starting point of the seam (the closest surface point is used). Default: (0,0,0).

◆ GetClosestPoint() [2/2]

virtual void vtkvmtkTopologicalSeamFilter::GetClosestPoint ( double data[3])
virtual

Set/Get the (x,y,z) location used to find the starting point of the seam (the closest surface point is used). Default: (0,0,0).

◆ SetSeamScalarsArrayName()

virtual void vtkvmtkTopologicalSeamFilter::SetSeamScalarsArrayName ( const char * )
virtual

Set/Get the name of the output point data array where the seam marker (side of SeamFunction each point falls on) is stored. Commonly named "SeamScalars".

◆ GetSeamScalarsArrayName()

virtual char * vtkvmtkTopologicalSeamFilter::GetSeamScalarsArrayName ( )
virtual

Set/Get the name of the output point data array where the seam marker (side of SeamFunction each point falls on) is stored. Commonly named "SeamScalars".

◆ SetSeamFunction()

virtual void vtkvmtkTopologicalSeamFilter::SetSeamFunction ( vtkImplicitFunction * )
virtual

Set/Get the implicit function (typically a vtkPlane) that defines the cutting surface used to locate the seam. Required input.

◆ GetSeamFunction()

virtual vtkImplicitFunction * vtkvmtkTopologicalSeamFilter::GetSeamFunction ( )
virtual

Set/Get the implicit function (typically a vtkPlane) that defines the cutting surface used to locate the seam. Required input.

◆ RequestData()

int vtkvmtkTopologicalSeamFilter::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 66 of file vtkvmtkTopologicalSeamFilter.cxx.

69{
70 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
71 vtkInformation *outInfo = outputVector->GetInformationObject(0);
72
73 vtkPolyData *input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
74 vtkPolyData *output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
75
76 if (this->SeamScalarsArrayName == NULL)
77 {
78 vtkErrorMacro("Name of seam scalars array not specified.");
79 return 1;
80 }
81
82 vtkDoubleArray* sourceArray = vtkDoubleArray::New();
83
84 vtkIdType numberOfPoints = input->GetNumberOfPoints();
85
86 if (this->SeamFunction == NULL)
87 {
88 if (input->GetPointData()->GetArray(this->SeamScalarsArrayName))
89 {
90 sourceArray->DeepCopy(input->GetPointData()->GetArray(this->SeamScalarsArrayName));
91 }
92 else
93 {
94 vtkErrorMacro("Seam scalars with name specified does not exist and seam function not specified.");
95 return 1;
96 }
97 }
98 else
99 {
100 sourceArray->SetNumberOfTuples(input->GetNumberOfPoints());
101 double point[3], value;
102 for (vtkIdType i=0; i<numberOfPoints; i++)
103 {
104 input->GetPoint(i,point);
105 value = this->SeamFunction->FunctionValue(point);
106 sourceArray->SetValue(i,value);
107 }
108 }
109
110 vtkIdType numberOfCells = input->GetNumberOfCells();
111
112 vtkUnsignedCharArray* visitedArray = vtkUnsignedCharArray::New();
113 visitedArray->SetNumberOfTuples(numberOfPoints);
114 visitedArray->FillComponent(0,0.0);
115
116 vtkDoubleArray* seamArray = vtkDoubleArray::New();
117 seamArray->SetName(this->SeamScalarsArrayName);
118 seamArray->SetNumberOfTuples(numberOfPoints);
119 seamArray->FillComponent(0,0.0);
120
121 input->BuildCells();
122 input->BuildLinks();
123
124 vtkIdType firstSeamPointId = -1;
125 double minDist = VTK_VMTK_LARGE_DOUBLE;
126
127 vtkIdType npts;
128 const vtkIdType *pts;
129 // get the point that is closest to the implicit plane
130 for (vtkIdType i=0; i<numberOfCells; i++)
131 {
132 input->GetCellPoints(i,npts,pts);
133 for (vtkIdType j=0; j<npts-1; j++)
134 {
135 vtkIdType point0Id = pts[j];
136 vtkIdType point1Id = pts[j+1];
137 double point0Value = sourceArray->GetTuple1(point0Id);
138 double point1Value = sourceArray->GetTuple1(point1Id);
139 if (point0Value * point1Value < 0.0)
140 {
141 double point0[3], point1[3];
142 input->GetPoint(point0Id,point0);
143 input->GetPoint(point1Id,point1);
144 double dist0 = vtkMath::Distance2BetweenPoints(point0,this->ClosestPoint);
145 double dist1 = vtkMath::Distance2BetweenPoints(point1,this->ClosestPoint);
146 if (dist0 < minDist)
147 {
148 minDist = dist0;
149 firstSeamPointId = point0Id;
150 }
151 if (dist1 < minDist)
152 {
153 minDist = dist1;
154 firstSeamPointId = point1Id;
155 }
156 continue;
157 }
158 }
159 }
160
161 std::queue<vtkIdType> seamQueue;
162
163 seamQueue.push(firstSeamPointId);
164
165 std::queue<vtkIdType> leftQueue;
166 std::queue<vtkIdType> rightQueue;
167
168 vtkIdType *cells;
169 vtkIdType ncells;
170
171 while (!seamQueue.empty())
172 {
173 vtkIdType point0Id = seamQueue.front();
174 seamQueue.pop();
175 double point0Value = sourceArray->GetTuple1(point0Id);
176 visitedArray->SetValue(point0Id,1);
177 seamArray->SetValue(point0Id,point0Value);
178 input->GetPointCells(point0Id,ncells,cells);
179 for (vtkIdType i=0; i<ncells; i++)
180 {
181 vtkIdType cellId = cells[i];
182 input->GetCellPoints(cellId,npts,pts);
183 for (vtkIdType j=0; j<npts; j++)
184 {
185 vtkIdType point1Id = pts[j];
186 if (visitedArray->GetValue(point1Id) == 1)
187 {
188 continue;
189 }
190 double point1Value = sourceArray->GetTuple1(point1Id);
191 if (point0Value * point1Value > 0.0)
192 {
193 seamArray->SetValue(point1Id,point1Value);
194 if (point1Value > 0.0)
195 {
196 rightQueue.push(point1Id);
197 }
198 else
199 {
200 leftQueue.push(point1Id);
201 }
202 continue;
203 }
204 visitedArray->SetValue(point1Id,1);
205 seamArray->SetValue(point1Id,point1Value);
206 seamQueue.push(point1Id);
207 }
208 }
209 }
210
211 const double leftValue = -1.0;
212 const double rightValue = 1.0;
213
214 while(!leftQueue.empty())
215 {
216 vtkIdType point0Id = leftQueue.front();
217 leftQueue.pop();
218 visitedArray->SetValue(point0Id,1);
219 input->GetPointCells(point0Id,ncells,cells);
220 for (vtkIdType i=0; i<ncells; i++)
221 {
222 vtkIdType cellId = cells[i];
223 input->GetCellPoints(cellId,npts,pts);
224 for (vtkIdType j=0; j<npts; j++)
225 {
226 vtkIdType point1Id = pts[j];
227 if (visitedArray->GetValue(point1Id) == 1)
228 {
229 continue;
230 }
231 visitedArray->SetValue(point1Id,1);
232 seamArray->SetValue(point1Id,leftValue);
233 leftQueue.push(point1Id);
234 }
235 }
236 }
237
238 while(!rightQueue.empty())
239 {
240 vtkIdType point0Id = rightQueue.front();
241 rightQueue.pop();
242 visitedArray->SetValue(point0Id,1);
243 input->GetPointCells(point0Id,ncells,cells);
244 for (vtkIdType i=0; i<ncells; i++)
245 {
246 vtkIdType cellId = cells[i];
247 input->GetCellPoints(cellId,npts,pts);
248 for (vtkIdType j=0; j<npts; j++)
249 {
250 vtkIdType point1Id = pts[j];
251 if (visitedArray->GetValue(point1Id) == 1)
252 {
253 continue;
254 }
255 visitedArray->SetValue(point1Id,1);
256 seamArray->SetValue(point1Id,rightValue);
257 rightQueue.push(point1Id);
258 }
259 }
260 }
261
262 output->DeepCopy(input);
263 output->GetPointData()->AddArray(seamArray);
264 output->GetPointData()->SetActiveScalars(this->SeamScalarsArrayName);
265
266 visitedArray->Delete();
267 sourceArray->Delete();
268 seamArray->Delete();
269
270 return 1;
271}
#define VTK_VMTK_LARGE_DOUBLE

Member Data Documentation

◆ ClosestPoint

double vtkvmtkTopologicalSeamFilter::ClosestPoint[3]
protected

Definition at line 79 of file vtkvmtkTopologicalSeamFilter.h.

◆ SeamScalarsArrayName

char* vtkvmtkTopologicalSeamFilter::SeamScalarsArrayName
protected

Definition at line 80 of file vtkvmtkTopologicalSeamFilter.h.

◆ SeamFunction

vtkImplicitFunction* vtkvmtkTopologicalSeamFilter::SeamFunction
protected

Definition at line 81 of file vtkvmtkTopologicalSeamFilter.h.


The documentation for this class was generated from the following files: