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

Apply a neighborhood to the points of a manifold surface. More...

#include <vtkvmtkPolyDataManifoldNeighborhood.h>

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

Public Types

typedef vtkvmtkNeighborhood Superclass
Public Types inherited from vtkvmtkNeighborhood
typedef vtkvmtkDataSetItem Superclass
Public Types inherited from vtkvmtkDataSetItem
typedef vtkvmtkItem Superclass
Public Types inherited from vtkvmtkItem
typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataManifoldNeighborhood * NewInstance () const
virtual vtkIdType GetItemType () override
virtual void Build () override
Public Member Functions inherited from vtkvmtkNeighborhood
vtkvmtkNeighborhood * NewInstance () const
virtual bool GetIsBoundary ()
vtkIdType GetNumberOfPoints ()
vtkIdType GetPointId (vtkIdType i)
vtkIdType * GetPointer (vtkIdType i)
virtual void DeepCopy (vtkvmtkItem *src) override
Public Member Functions inherited from vtkvmtkDataSetItem
vtkvmtkDataSetItem * NewInstance () const
void SetDataSet (vtkDataSet *dataSet)
vtkDataSet * GetDataSet ()
virtual void SetDataSetPointId (vtkIdType)
virtual vtkIdType GetDataSetPointId ()
virtual void SetReallocateOnBuild (int)
virtual int GetReallocateOnBuild ()
virtual void ReallocateOnBuildOn ()
virtual void ReallocateOnBuildOff ()
Public Member Functions inherited from vtkvmtkItem
vtkvmtkItem * NewInstance () const

Static Public Member Functions

static vtkvmtkPolyDataManifoldNeighborhood * New ()
static int IsTypeOf (const char *type)
static vtkvmtkPolyDataManifoldNeighborhood * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkNeighborhood
static int IsTypeOf (const char *type)
static vtkvmtkNeighborhood * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkDataSetItem
static int IsTypeOf (const char *type)
static vtkvmtkDataSetItem * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkItem
static int IsTypeOf (const char *type)
static vtkvmtkItem * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataManifoldNeighborhood ()
 ~vtkvmtkPolyDataManifoldNeighborhood ()
Protected Member Functions inherited from vtkvmtkNeighborhood
 vtkvmtkNeighborhood ()
 ~vtkvmtkNeighborhood ()
void ResizePointList (vtkIdType ptId, int size)
Protected Member Functions inherited from vtkvmtkDataSetItem
 vtkvmtkDataSetItem ()
 ~vtkvmtkDataSetItem ()
Protected Member Functions inherited from vtkvmtkItem
 vtkvmtkItem ()
 ~vtkvmtkItem ()

Additional Inherited Members

Protected Attributes inherited from vtkvmtkNeighborhood
vtkIdType NPoints
vtkIdType * PointIds
bool IsBoundary
Protected Attributes inherited from vtkvmtkDataSetItem
vtkDataSet * DataSet
vtkIdType DataSetPointId
int ReallocateOnBuild

Detailed Description

Apply a neighborhood to the points of a manifold surface.

vtkvmtkPolyDataManifoldNeighborhood computes the ordered one-ring neighborhood (the points directly connected by an edge) of a point (DataSetPointId) on a manifold triangulated surface: it walks around the point from cell to cell via shared edges (vtkPolyData::GetCellEdgeNeighbors), collecting neighbor point ids in angular order, until it returns to the start (interior point, IsBoundary false) or runs out of triangles on one side and must walk the remaining triangles from the other side (point on an open mesh boundary, IsBoundary true, in which case the neighbor ids are reordered so the two boundary neighbors end up first/last). This is the neighborhood used by vtkvmtkPolyDataManifoldStencil::Build (and by vtkvmtkPolyDataManifoldExtendedNeighborhood, which enlarges it further) to build discrete differential operators (Laplacian, gradient, curvature) on a surface mesh.

See also
vtkvmtkPolyDataManifoldExtendedNeighborhood, vtkvmtkPolyDataManifoldStencil

Definition at line 46 of file vtkvmtkPolyDataManifoldNeighborhood.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataManifoldNeighborhood()

vtkvmtkPolyDataManifoldNeighborhood::vtkvmtkPolyDataManifoldNeighborhood ( )
inlineprotected

Definition at line 61 of file vtkvmtkPolyDataManifoldNeighborhood.h.

61{};

◆ ~vtkvmtkPolyDataManifoldNeighborhood()

vtkvmtkPolyDataManifoldNeighborhood::~vtkvmtkPolyDataManifoldNeighborhood ( )
inlineprotected

Definition at line 62 of file vtkvmtkPolyDataManifoldNeighborhood.h.

62{};

Member Function Documentation

◆ New()

vtkvmtkPolyDataManifoldNeighborhood * vtkvmtkPolyDataManifoldNeighborhood::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataManifoldNeighborhood::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataManifoldNeighborhood * vtkvmtkPolyDataManifoldNeighborhood::NewInstance ( ) const

◆ GetItemType()

virtual vtkIdType vtkvmtkPolyDataManifoldNeighborhood::GetItemType ( )
inlineoverridevirtual

Get an identifier for the concrete item type (one of the VTK_VMTK_*_NEIGHBORHOOD / VTK_VMTK_*_STENCIL constants), used by owning vtkvmtkItems collections to instantiate the correct subclass.

Implements vtkvmtkItem.

Reimplemented in vtkvmtkPolyDataManifoldExtendedNeighborhood.

Definition at line 53 of file vtkvmtkPolyDataManifoldNeighborhood.h.

@ VTK_VMTK_POLYDATA_MANIFOLD_NEIGHBORHOOD

◆ Build()

void vtkvmtkPolyDataManifoldNeighborhood::Build ( )
overridevirtual

Build the neighborhood.

Implements vtkvmtkNeighborhood.

Reimplemented in vtkvmtkPolyDataManifoldExtendedNeighborhood.

Definition at line 32 of file vtkvmtkPolyDataManifoldNeighborhood.cxx.

33{
34 vtkIdType i, j, id;
35 vtkIdType numCellsInStencil;
36 vtkIdType startCell, nextCell;
37 vtkIdType p1, p2;
38 vtkIdType bp1, bp2;
39 vtkIdType K;
40 vtkIdType pointId;
41 vtkIdList *cellIds, *ptIds, *stencilIds;
42 vtkCell* cell;
43 vtkPolyData* pdata = vtkPolyData::SafeDownCast(this->DataSet);
44
45 if (pdata==NULL)
46 {
47 vtkErrorMacro(<< "Input data NULL or not poly data");
48 }
49
50 pointId = this->DataSetPointId;
51
52 this->NPoints = 0;
53
54 cellIds = vtkIdList::New();
55 ptIds = vtkIdList::New();
56 stencilIds = vtkIdList::New();
57
58 pdata->GetPointCells (pointId, cellIds);
59 numCellsInStencil = cellIds->GetNumberOfIds();
60 if (numCellsInStencil < 1)
61 {
62 // vtkWarningMacro("numCellsInStencil < 1: " << numCellsInStencil);
63 cellIds->Delete();
64 ptIds->Delete();
65 stencilIds->Delete();
66 return;
67 }
68
69 pdata->GetCellPoints(cellIds->GetId(0),ptIds);
70 p2 = ptIds->GetId(0);
71 i = 1;
72 while (pointId == p2)
73 {
74 p2 = ptIds->GetId(i++);
75 }
76
77 pdata->GetCellEdgeNeighbors (-1,pointId,p2,cellIds);
78
79 nextCell = cellIds->GetId(0);
80 bp2 = -1;
81 bp1 = p2;
82 if (cellIds->GetNumberOfIds() == 1)
83 {
84 startCell = -1;
85 }
86 else
87 {
88 startCell = cellIds->GetId(1);
89 }
90
91 stencilIds->InsertNextId(p2);
92
93 // walk around the stencil counter-clockwise and get cells
94 for (j=0; j<numCellsInStencil; j++)
95 {
96 cell = pdata->GetCell(nextCell);
97 p1 = -1;
98 for (i = 0; i < 3; i++)
99 {
100 if ((p1 = cell->GetPointId(i)) != pointId && cell->GetPointId(i) != p2)
101 {
102 break;
103 }
104 }
105
106 p2 = p1;
107 stencilIds->InsertNextId (p2);
108 pdata->GetCellEdgeNeighbors (nextCell, pointId, p2, cellIds);
109 if (cellIds->GetNumberOfIds() != 1)
110 {
111 bp2 = p2;
112 j++;
113 break;
114 }
115 nextCell = cellIds->GetId(0);
116 }
117
118 // now walk around the other way. this will only happen if there
119 // is a boundary cell left that we have not visited
120 nextCell = startCell;
121 p2 = bp1;
122 for (; j<numCellsInStencil && startCell!=-1; j++)
123 {
124 cell = pdata->GetCell(nextCell);
125 p1 = -1;
126 for (i=0; i<3; i++)
127 {
128 if ((p1=cell->GetPointId(i))!=pointId && cell->GetPointId(i)!=p2)
129 {
130 break;
131 }
132 }
133 p2 = p1;
134 stencilIds->InsertNextId(p2);
135 pdata->GetCellEdgeNeighbors (nextCell, pointId, p2, cellIds);
136 if (cellIds->GetNumberOfIds() != 1)
137 {
138 bp1 = p2;
139 break;
140 }
141 nextCell = cellIds->GetId(0);
142 }
143
144 if (bp2 != -1) // boundary edge
145 {
146 this->IsBoundary = true;
147 id = stencilIds->IsId(bp2);
148 for (i=0; i<=id/2; i++)
149 {
150 p1 = stencilIds->GetId(i);
151 p2 = stencilIds->GetId(id-i);
152 stencilIds->SetId(i,p2);
153 stencilIds->SetId(id-i,p1);
154 }
155 }
156 else
157 {
158 this->IsBoundary = false;
159 K = stencilIds->GetNumberOfIds();
160 // Remove last id. It's a duplicate of the first
161 stencilIds->SetNumberOfIds(--K);
162 }
163
164 this->NPoints = stencilIds->GetNumberOfIds();
165 if (this->PointIds!=NULL)
166 {
167 delete[] this->PointIds;
168 this->PointIds = NULL;
169 }
170 this->PointIds = new vtkIdType[this->NPoints];
171 memcpy(this->PointIds,stencilIds->GetPointer(0),this->NPoints*sizeof(vtkIdType));
172
173 cellIds->Delete();
174 ptIds->Delete();
175 stencilIds->Delete();
176}

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