VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataNeighborhood.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3Program: VMTK
4Module: $RCSfile: vtkvmtkPolyDataNeighborhood.cxx,v $
5Language: C++
6Date: $Date: 2006/04/06 16:46:44 $
7Version: $Revision: 1.3 $
8
9 Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 See LICENSE file for details.
11
12 Portions of this code are covered under the VTK copyright.
13 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
14 for details.
15
16 This software is distributed WITHOUT ANY WARRANTY; without even
17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE. See the above copyright notices for more information.
19
20=========================================================================*/
21
23
24#include "vtkObjectFactory.h"
25#include "vtkIdList.h"
26#include "vtkCell.h"
27
28
30
32{
33 vtkIdType i, j;
34 vtkIdType numCellsInStencil;
35 vtkIdList *cellIds, *ptIds, *stencilIds;
36 vtkPolyData* pdata = vtkPolyData::SafeDownCast(this->DataSet);
37
38 if (pdata==NULL)
39 {
40 vtkErrorMacro(<< "Input data NULL or not poly data");
41 }
42
43 vtkIdType pointId = this->DataSetPointId;
44
45 this->NPoints = 0;
46
47 cellIds = vtkIdList::New();
48 ptIds = vtkIdList::New();
49 stencilIds = vtkIdList::New();
50
51 pdata->GetPointCells (pointId, cellIds);
52 numCellsInStencil = cellIds->GetNumberOfIds();
53 if (numCellsInStencil < 1)
54 {
55 // vtkWarningMacro("numCellsInStencil < 1: " << numCellsInStencil);
56 cellIds->Delete();
57 ptIds->Delete();
58 stencilIds->Delete();
59 return;
60 }
61
62 vtkIdType cellPointId;
63 for (i=0; i<numCellsInStencil; i++)
64 {
65 pdata->GetCellPoints(cellIds->GetId(i),ptIds);
66 for (j=0; j<ptIds->GetNumberOfIds(); j++)
67 {
68 cellPointId = ptIds->GetId(j);
69 if (cellPointId != pointId)
70 {
71 stencilIds->InsertUniqueId(ptIds->GetId(j));
72 }
73 }
74 }
75
76 this->NPoints = stencilIds->GetNumberOfIds();
77 if (this->PointIds!=NULL)
78 {
79 delete[] this->PointIds;
80 this->PointIds = NULL;
81 }
82 this->PointIds = new vtkIdType[this->NPoints];
83 memcpy(this->PointIds,stencilIds->GetPointer(0),this->NPoints*sizeof(vtkIdType));
84
85 cellIds->Delete();
86 ptIds->Delete();
87 stencilIds->Delete();
88}
89
Build the one-ring neighborhood of a point on a vtkPolyData surface mesh.
vtkStandardNewMacro(vtkvmtkPolyDataNeighborhood)