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

Provides an abstract base class for steepest descent on a polygonal non-manifold. More...

#include <vtkvmtkNonManifoldSteepestDescent.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkNonManifoldSteepestDescent * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetDescentArrayName (const char *)
virtual char * GetDescentArrayName ()
virtual void SetDirection (int)
virtual int GetDirection ()
void SetDirectionToDownward ()
void SetDirectionToUpward ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkNonManifoldSteepestDescent ()
 ~vtkvmtkNonManifoldSteepestDescent ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
double GetSteepestDescent (vtkPolyData *input, vtkIdType *edge, double s, vtkIdType *steepestDescentEdge, double &steepestDescentS)
double GetSteepestDescentInCell (vtkPolyData *input, vtkIdType cellId, vtkIdType *edge, double s, vtkIdType *steepestDescentEdge, double &steepestDescentS, double &steepestDescentLength)

Protected Attributes

vtkDataArray * DescentArray
char * DescentArrayName
int NumberOfEdgeSubdivisions
int Direction

Detailed Description

Provides an abstract base class for steepest descent on a polygonal non-manifold.

This class is an abstract filter used as base class for performing steepest descent on a non-manifold surface made of convex polygons (such as the Voronoi diagram) on the basis of a given scalar field. Steepest descent is performed on the edges of input polygons with a first order approximation.

See also
vtkSteepestDescentLineTracer vtkSurfaceToCenterlines vtkVoronoiDiagram3D

Definition at line 40 of file vtkvmtkNonManifoldSteepestDescent.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkNonManifoldSteepestDescent::Superclass

Definition at line 43 of file vtkvmtkNonManifoldSteepestDescent.h.

Constructor & Destructor Documentation

◆ vtkvmtkNonManifoldSteepestDescent()

vtkvmtkNonManifoldSteepestDescent::vtkvmtkNonManifoldSteepestDescent ( )
protected

◆ ~vtkvmtkNonManifoldSteepestDescent()

vtkvmtkNonManifoldSteepestDescent::~vtkvmtkNonManifoldSteepestDescent ( )
protected

Definition at line 44 of file vtkvmtkNonManifoldSteepestDescent.cxx.

45{
46}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkNonManifoldSteepestDescent::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkNonManifoldSteepestDescent * vtkvmtkNonManifoldSteepestDescent::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 249 of file vtkvmtkNonManifoldSteepestDescent.cxx.

250{
251 this->Superclass::PrintSelf(os,indent);
252}

◆ New()

vtkvmtkNonManifoldSteepestDescent * vtkvmtkNonManifoldSteepestDescent::New ( )
static

◆ SetDescentArrayName()

virtual void vtkvmtkNonManifoldSteepestDescent::SetDescentArrayName ( const char * )
virtual

Set/Get the name of the point data array used as the descent scalar field. Commonly named "VoronoiGeodesicDistance".

◆ GetDescentArrayName()

virtual char * vtkvmtkNonManifoldSteepestDescent::GetDescentArrayName ( )
virtual

Set/Get the name of the point data array used as the descent scalar field. Commonly named "VoronoiGeodesicDistance".

◆ SetDirection()

virtual void vtkvmtkNonManifoldSteepestDescent::SetDirection ( int )
virtual

Set/Get the direction of steepest descent search: VTK_VMTK_DOWNWARD (default) looks for the neighboring point along the edges where the descent scalar field decreases most steeply, VTK_VMTK_UPWARD looks for the steepest increase instead. Use SetDirectionToDownward / SetDirectionToUpward as convenience setters.

◆ GetDirection()

virtual int vtkvmtkNonManifoldSteepestDescent::GetDirection ( )
virtual

Set/Get the direction of steepest descent search: VTK_VMTK_DOWNWARD (default) looks for the neighboring point along the edges where the descent scalar field decreases most steeply, VTK_VMTK_UPWARD looks for the steepest increase instead. Use SetDirectionToDownward / SetDirectionToUpward as convenience setters.

◆ SetDirectionToDownward()

void vtkvmtkNonManifoldSteepestDescent::SetDirectionToDownward ( )
inline

Set/Get the direction of steepest descent search: VTK_VMTK_DOWNWARD (default) looks for the neighboring point along the edges where the descent scalar field decreases most steeply, VTK_VMTK_UPWARD looks for the steepest increase instead. Use SetDirectionToDownward / SetDirectionToUpward as convenience setters.

Definition at line 66 of file vtkvmtkNonManifoldSteepestDescent.h.

◆ SetDirectionToUpward()

void vtkvmtkNonManifoldSteepestDescent::SetDirectionToUpward ( )
inline

Set/Get the direction of steepest descent search: VTK_VMTK_DOWNWARD (default) looks for the neighboring point along the edges where the descent scalar field decreases most steeply, VTK_VMTK_UPWARD looks for the steepest increase instead. Use SetDirectionToDownward / SetDirectionToUpward as convenience setters.

Definition at line 68 of file vtkvmtkNonManifoldSteepestDescent.h.

◆ RequestData()

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

Reimplemented in vtkvmtkSteepestDescentLineTracer, and vtkvmtkSteepestDescentShooter.

Definition at line 219 of file vtkvmtkNonManifoldSteepestDescent.cxx.

223{
224 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
225// vtkInformation *outInfo = outputVector->GetInformationObject(0);
226
227 vtkPolyData *input = vtkPolyData::SafeDownCast(
228 inInfo->Get(vtkDataObject::DATA_OBJECT()));
229// vtkPolyData *output = vtkPolyData::SafeDownCast(
230// outInfo->Get(vtkDataObject::DATA_OBJECT()));
231
232 if (!this->DescentArrayName)
233 {
234 vtkErrorMacro("No descent array name specified!");
235 return 1;
236 }
237
238 if (!input->GetPointData()->GetArray(this->DescentArrayName))
239 {
240 vtkErrorMacro("Descent array with specified name does not exist!");
241 return 1;
242 }
243
244 this->DescentArray = input->GetPointData()->GetArray(this->DescentArrayName);
245
246 return 1;
247}

◆ GetSteepestDescent()

double vtkvmtkNonManifoldSteepestDescent::GetSteepestDescent ( vtkPolyData * input,
vtkIdType * edge,
double s,
vtkIdType * steepestDescentEdge,
double & steepestDescentS )
protected

Compute the steepest descent point in terms of edge (point id pair) and parametric coordinate on edge. It takes in input a starting point expressed in terms of edge (point id pair) and parametric coordinate on edge. It returns the descent value.

Definition at line 173 of file vtkvmtkNonManifoldSteepestDescent.cxx.

174{
175 double descent, steepestDescent;
176 double descentLength, steepestDescentLength;
177 vtkIdType descentEdge[2];
178 double descentS;
179 vtkIdList *neighborCells;
180 vtkIdType i, cellId;
181 double directionFactor = 0.0;
182
183 neighborCells = vtkIdList::New();
184
185 input->GetCellEdgeNeighbors(-1,edge[0],edge[1],neighborCells);
186
187 if (this->Direction==VTK_VMTK_DOWNWARD)
188 {
189 directionFactor = 1.0;
190 }
191 else if (this->Direction==VTK_VMTK_UPWARD)
192 {
193 directionFactor = - 1.0;
194 }
195
196 steepestDescent = - VTK_VMTK_LARGE_DOUBLE * directionFactor;
197 steepestDescentLength = VTK_VMTK_LARGE_DOUBLE;
198 steepestDescentEdge[0] = -1;
199 steepestDescentEdge[1] = -1;
200 for (i=0; i<neighborCells->GetNumberOfIds(); i++)
201 {
202 cellId = neighborCells->GetId(i);
203 descent = this->GetSteepestDescentInCell(input,cellId,edge,s,descentEdge,descentS,descentLength);
204 if (directionFactor*(descent - steepestDescent) > VTK_VMTK_DOUBLE_TOL)
205 {
206 steepestDescent = descent;
207 steepestDescentLength = descentLength;
208 steepestDescentEdge[0] = descentEdge[0];
209 steepestDescentEdge[1] = descentEdge[1];
210 steepestDescentS = descentS;
211 }
212 }
213
214 neighborCells->Delete();
215
216 return steepestDescent;
217}
double GetSteepestDescentInCell(vtkPolyData *input, vtkIdType cellId, vtkIdType *edge, double s, vtkIdType *steepestDescentEdge, double &steepestDescentS, double &steepestDescentLength)
#define VTK_VMTK_DOUBLE_TOL
#define VTK_VMTK_LARGE_DOUBLE

◆ GetSteepestDescentInCell()

double vtkvmtkNonManifoldSteepestDescent::GetSteepestDescentInCell ( vtkPolyData * input,
vtkIdType cellId,
vtkIdType * edge,
double s,
vtkIdType * steepestDescentEdge,
double & steepestDescentS,
double & steepestDescentLength )
protected

Compute the steepest descent point in terms of edge (point id pair) and parametric coordinate on edge. It takes in input a starting point expressed in terms of edge (point id pair) and parametric coordinate on edge. It returns the descent value.

Definition at line 48 of file vtkvmtkNonManifoldSteepestDescent.cxx.

49{
50 double currentPoint[3], currentScalar;
51 double descent, steepestDescent;
52 double descentLength;
53 double point0[3], point1[3], point[3];
54 double scalar0, scalar1, scalar;
55 double currentS;
56 double directionFactor = 0.0;
57 vtkIdType npts;
58 const vtkIdType *pts;
59 vtkIdType i, j;
60
61 if (!this->DescentArray)
62 {
63 vtkErrorMacro("DescentArray not set.");
64 }
65
67 {
68 directionFactor = 1.0;
69 }
70 else if (this->Direction==VTK_VMTK_UPWARD)
71 {
72 directionFactor = - 1.0;
73 }
74
75 double edgePoint0[3], edgePoint1[3];
76 input->GetPoint(edge[0],edgePoint0);
77 input->GetPoint(edge[1],edgePoint1);
78
79 currentPoint[0] = edgePoint0[0] * (1.0 - s) + edgePoint1[0] * s;
80 currentPoint[1] = edgePoint0[1] * (1.0 - s) + edgePoint1[1] * s;
81 currentPoint[2] = edgePoint0[2] * (1.0 - s) + edgePoint1[2] * s;
82 currentScalar = this->DescentArray->GetTuple1(edge[0]) * (1.0 - s) + this->DescentArray->GetTuple1(edge[1]) * s;
83
84 steepestDescent = - VTK_VMTK_LARGE_DOUBLE * directionFactor;
85 steepestDescentLength = VTK_VMTK_LARGE_DOUBLE;
86
87 input->GetCellPoints(cellId,npts,pts);
88
89 for (i=0; i<npts; i++)
90 {
91 input->GetPoint(pts[i],point0);
92 input->GetPoint(pts[(i+1)%npts],point1);
93 scalar0 = this->DescentArray->GetTuple1(pts[i]);
94 scalar1 = this->DescentArray->GetTuple1(pts[(i+1)%npts]);
95
96 if (edge[0]==edge[1])
97 {
98 if (pts[i]==edge[0])
99 {
100 continue;
101 }
102 }
103 else
104 {
105 if (((pts[i]==edge[0]) && (pts[(i+1)%npts]==edge[1]))||((pts[i]==edge[1]) && (pts[(i+1)%npts]==edge[0])))
106 {
107 point[0] = point0[0];
108 point[1] = point0[1];
109 point[2] = point0[2];
110 scalar = scalar0;
111 currentS = 0.0;
112 descentLength = sqrt(vtkMath::Distance2BetweenPoints(point,currentPoint));
113 if (descentLength > VTK_VMTK_DOUBLE_TOL)
114 {
115 descent = - (scalar - currentScalar) / descentLength;
116 }
117 else
118 {
119 descent = 0.0;
120 }
121 if (directionFactor*(descent - steepestDescent) > VTK_VMTK_DOUBLE_TOL)
122 {
123 steepestDescent = descent;
124 steepestDescentLength = descentLength;
125 steepestDescentEdge[0] = pts[i];
126 steepestDescentEdge[1] = pts[i];
127 steepestDescentS = currentS;
128 }
129 continue;
130 }
131 }
132
133 currentS = 0.0;
134 for (j=0; j<this->NumberOfEdgeSubdivisions; j++)
135 {
136 point[0] = point0[0] * (1.0 - currentS) + point1[0] * currentS;
137 point[1] = point0[1] * (1.0 - currentS) + point1[1] * currentS;
138 point[2] = point0[2] * (1.0 - currentS) + point1[2] * currentS;
139 scalar = scalar0 * (1.0 - currentS) + scalar1 * currentS;
140 descentLength = sqrt(vtkMath::Distance2BetweenPoints(point,currentPoint));
141 if (descentLength > VTK_VMTK_DOUBLE_TOL)
142 {
143 descent = - (scalar - currentScalar) / descentLength;
144 }
145 else
146 {
147 descent = 0.0;
148 }
149 if (directionFactor * (descent - steepestDescent) > VTK_VMTK_DOUBLE_TOL)
150 {
151 steepestDescent = descent;
152 steepestDescentLength = descentLength;
153 if (fabs(currentS)<VTK_VMTK_DOUBLE_TOL)
154 {
155 steepestDescentEdge[0] = pts[i];
156 steepestDescentEdge[1] = pts[i];
157 }
158 else
159 {
160 steepestDescentEdge[0] = pts[i];
161 steepestDescentEdge[1] = pts[(i+1)%npts];
162 }
163 steepestDescentS = currentS;
164 }
165
166 currentS += 1.0 / (double)this->NumberOfEdgeSubdivisions;
167 }
168 }
169
170 return steepestDescent;
171}

Member Data Documentation

◆ DescentArray

vtkDataArray* vtkvmtkNonManifoldSteepestDescent::DescentArray
protected

Definition at line 88 of file vtkvmtkNonManifoldSteepestDescent.h.

◆ DescentArrayName

char* vtkvmtkNonManifoldSteepestDescent::DescentArrayName
protected

Definition at line 89 of file vtkvmtkNonManifoldSteepestDescent.h.

◆ NumberOfEdgeSubdivisions

int vtkvmtkNonManifoldSteepestDescent::NumberOfEdgeSubdivisions
protected

Definition at line 91 of file vtkvmtkNonManifoldSteepestDescent.h.

◆ Direction

int vtkvmtkNonManifoldSteepestDescent::Direction
protected

Definition at line 92 of file vtkvmtkNonManifoldSteepestDescent.h.


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