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

Merges points, point data, and cell data. More...

#include <vtkvmtkAppendFilter.h>

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

Public Types

typedef vtkAppendFilter Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkAppendFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetMergeDuplicatePoints (int)
virtual int GetMergeDuplicatePoints ()
virtual void MergeDuplicatePointsOn ()
virtual void MergeDuplicatePointsOff ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

int MergeDuplicatePoints

Detailed Description

Merges points, point data, and cell data.

The RequestData method implementation is heavily based on the same method in vtkAppendFilter. vtkAppendFilter is covered by the following (VTK) copyright notice.

Definition at line 34 of file vtkvmtkAppendFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkAppendFilter vtkvmtkAppendFilter::Superclass

Definition at line 39 of file vtkvmtkAppendFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkAppendFilter()

vtkvmtkAppendFilter::vtkvmtkAppendFilter ( )
protected

Definition at line 41 of file vtkvmtkAppendFilter.cxx.

42{
43 this->MergeDuplicatePoints = 1;
44}

◆ ~vtkvmtkAppendFilter()

vtkvmtkAppendFilter::~vtkvmtkAppendFilter ( )
protected

Definition at line 46 of file vtkvmtkAppendFilter.cxx.

47{
48}

Member Function Documentation

◆ New()

vtkvmtkAppendFilter * vtkvmtkAppendFilter::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkAppendFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkAppendFilter * vtkvmtkAppendFilter::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 280 of file vtkvmtkAppendFilter.cxx.

281{
282 this->Superclass::PrintSelf(os,indent);
283}

◆ SetMergeDuplicatePoints()

virtual void vtkvmtkAppendFilter::SetMergeDuplicatePoints ( int )
virtual

Toggle merging of duplicate (coincident) points across the appended inputs, in addition to the point/point-data/cell-data merging already performed by the base vtkAppendFilter. Default: on.

◆ GetMergeDuplicatePoints()

virtual int vtkvmtkAppendFilter::GetMergeDuplicatePoints ( )
virtual

Toggle merging of duplicate (coincident) points across the appended inputs, in addition to the point/point-data/cell-data merging already performed by the base vtkAppendFilter. Default: on.

◆ MergeDuplicatePointsOn()

virtual void vtkvmtkAppendFilter::MergeDuplicatePointsOn ( )
virtual

Toggle merging of duplicate (coincident) points across the appended inputs, in addition to the point/point-data/cell-data merging already performed by the base vtkAppendFilter. Default: on.

◆ MergeDuplicatePointsOff()

virtual void vtkvmtkAppendFilter::MergeDuplicatePointsOff ( )
virtual

Toggle merging of duplicate (coincident) points across the appended inputs, in addition to the point/point-data/cell-data merging already performed by the base vtkAppendFilter. Default: on.

◆ RequestData()

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

Definition at line 50 of file vtkvmtkAppendFilter.cxx.

54{
55 // get the output info object
56 vtkInformation *outInfo = outputVector->GetInformationObject(0);
57
58 // get the output
59 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
60 outInfo->Get(vtkDataObject::DATA_OBJECT()));
61
62 vtkIdType numPts, numCells;
63 int tenth, count, abort=0;
64 float decimal;
65 vtkPoints *newPts;
66 vtkPointData *pd;
67 vtkCellData *cd;
68 vtkIdList *ptIds, *newPtIds;
69 int i, idx;
70 vtkDataSet *ds;
71 vtkIdType ptId, cellId, newCellId;
72 vtkPointData *outputPD = output->GetPointData();
73 vtkCellData *outputCD = output->GetCellData();
74
75 vtkDebugMacro(<<"Appending data together");
76
77 double bounds[6], inputBounds[6];
78 vtkMath::UninitializeBounds(bounds);
79
80 // Loop over all data sets, checking to see what data is common to
81 // all inputs. Note that data is common if 1) it is the same attribute
82 // type (scalar, vector, etc.), 2) it is the same native type (int,
83 // float, etc.), and 3) if a data array in a field, if it has the same name.
84 count = 0;
85 decimal = 0.0;
86
87 numPts = 0;
88 numCells = 0;
89
90 int numInputs = inputVector[0]->GetNumberOfInformationObjects();
91 vtkDataSetAttributes::FieldList ptList(numInputs);
92 vtkDataSetAttributes::FieldList cellList(numInputs);
93 int firstPD=1;
94 int firstCD=1;
95 vtkInformation *inInfo = 0;
96 for (idx = 0; idx < numInputs; ++idx)
97 {
98 inInfo = inputVector[0]->GetInformationObject(idx);
99 ds = 0;
100 if (inInfo)
101 {
102 ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
103 }
104 if (ds != NULL)
105 {
106 if ( ds->GetNumberOfPoints() <= 0 && ds->GetNumberOfCells() <= 0 )
107 {
108 continue; //no input, just skip
109 }
110
111 numPts += ds->GetNumberOfPoints();
112 numCells += ds->GetNumberOfCells();
113
114 ds->GetBounds(inputBounds);
115 if (vtkMath::AreBoundsInitialized(bounds))
116 {
117 int j;
118 for (j=0; j<6; j+=2)
119 {
120 if (inputBounds[j] < bounds[j])
121 {
122 bounds[j] = inputBounds[j];
123 }
124 if (inputBounds[j+1] > bounds[j+1])
125 {
126 bounds[j+1] = inputBounds[j+1];
127 }
128 }
129 }
130 else
131 {
132 int j;
133 for (j=0; j<6; j+=2)
134 {
135 bounds[j] = inputBounds[j];
136 bounds[j+1] = inputBounds[j+1];
137 }
138 }
139
140 pd = ds->GetPointData();
141 if ( firstPD )
142 {
143 ptList.InitializeFieldList(pd);
144 firstPD = 0;
145 }
146 else
147 {
148 ptList.IntersectFieldList(pd);
149 }
150
151 cd = ds->GetCellData();
152 if ( firstCD )
153 {
154 cellList.InitializeFieldList(cd);
155 firstCD = 0;
156 }
157 else
158 {
159 cellList.IntersectFieldList(cd);
160 }
161 }//if non-empty dataset
162 }//for all inputs
163
164 if ( numPts < 1)
165 {
166 vtkDebugMacro(<<"No data to append!");
167 return 1;
168 }
169
170 // Now can allocate memory
171 output->Allocate(numCells); //allocate storage for geometry/topology
172// outputPD->CopyGlobalIdsOn();
173 outputPD->CopyAllocate(ptList,numPts);
174// outputCD->CopyGlobalIdsOn();
175 outputCD->CopyAllocate(cellList,numCells);
176
177 newPts = vtkPoints::New();
178 ptIds = vtkIdList::New(); ptIds->Allocate(VTK_CELL_SIZE);
179 newPtIds = vtkIdList::New(); newPtIds->Allocate(VTK_CELL_SIZE);
180
181 vtkMergePoints* locator = vtkMergePoints::New();
182 if (this->MergeDuplicatePoints)
183 {
184 locator->InitPointInsertion(newPts,bounds);
185 }
186
187 vtkIdList* ptIdMap = vtkIdList::New();
188
189 vtkIdType newPtId;
190 double point[3];
191
192 // Append each input dataset together
193 //
194 tenth = (numPts + numCells)/10 + 1;
195 int inputCount = 0; // Since empty inputs are not in the list.
196 for (idx = 0; idx < numInputs && !abort; ++idx)
197 {
198 inInfo = inputVector[0]->GetInformationObject(idx);
199 ds = 0;
200 if (inInfo)
201 {
202 ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
203 }
204 if ( ds != NULL &&
205 (ds->GetNumberOfPoints() > 0 || ds->GetNumberOfCells() > 0) )
206 {
207 numPts = ds->GetNumberOfPoints();
208 numCells = ds->GetNumberOfCells();
209 pd = ds->GetPointData();
210
211 ptIdMap->Initialize();
212 ptIdMap->SetNumberOfIds(numPts);
213
214 // copy points and point data
215 for (ptId=0; ptId < numPts && !abort; ptId++)
216 {
217 ds->GetPoint(ptId,point);
218 if (this->MergeDuplicatePoints)
219 {
220 if (locator->InsertUniquePoint(point,newPtId))
221 {
222 outputPD->CopyData(ptList,pd,inputCount,ptId,newPtId);
223 }
224 }
225 else
226 {
227 newPtId = newPts->InsertNextPoint(point);
228 outputPD->CopyData(ptList,pd,inputCount,ptId,newPtId);
229 }
230 ptIdMap->SetId(ptId,newPtId);
231
232 // Update progress
233 count++;
234 if (!(count % tenth))
235 {
236 decimal += 0.1;
237 this->UpdateProgress(decimal);
238 abort = this->GetAbortExecute();
239 }
240 }
241
242 cd = ds->GetCellData();
243 // copy cell and cell data
244 for (cellId=0; cellId<numCells && !abort; cellId++)
245 {
246 ds->GetCellPoints(cellId, ptIds);
247 newPtIds->Reset();
248 for (i=0; i<ptIds->GetNumberOfIds(); i++)
249 {
250 newPtIds->InsertId(i,ptIdMap->GetId(ptIds->GetId(i)));
251 }
252 newCellId = output->InsertNextCell(ds->GetCellType(cellId),newPtIds);
253 outputCD->CopyData(cellList,cd,inputCount,cellId,newCellId);
254
255 // Update progress
256 count++;
257 if (!(count % tenth))
258 {
259 decimal += 0.1;
260 this->UpdateProgress(decimal);
261 abort = this->GetAbortExecute();
262 }
263 }
264 ++inputCount;
265 }
266 }
267
268 // Update ourselves and release memory
269 //
270 output->SetPoints(newPts);
271 newPts->Delete();
272 ptIds->Delete();
273 newPtIds->Delete();
274 ptIdMap->Delete();
275 locator->Delete();
276
277 return 1;
278}

Member Data Documentation

◆ MergeDuplicatePoints

int vtkvmtkAppendFilter::MergeDuplicatePoints
protected

Definition at line 59 of file vtkvmtkAppendFilter.h.


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