MCPcopy Create free account
hub / github.com/Kitware/VTK / RequestData

Method RequestData

Filters/Geometry/vtkRecoverGeometryWireframe.cxx:128–296  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

126
127//-----------------------------------------------------------------------------
128int vtkRecoverGeometryWireframe::RequestData(vtkInformation* vtkNotUsed(request),
129 vtkInformationVector** inputVector, vtkInformationVector* outputVector)
130{
131 vtkPolyData* input = vtkPolyData::GetData(inputVector[0]);
132 vtkPolyData* output = vtkPolyData::GetData(outputVector);
133
134 // If nothing to do, early return
135 if (input->GetNumberOfCells() == 0 || input->GetNumberOfPoints() == 0)
136 {
137 output->ShallowCopy(input);
138 return 1;
139 }
140
141 if (!input->GetCellData()->HasArray(this->CellIdsAttribute.c_str()))
142 {
143 vtkWarningMacro("Couldn't find any cell attribute, passing through the input.");
144 output->ShallowCopy(input);
145 return 1;
146 }
147
148 vtkIdTypeArray* faceIds = vtkIdTypeArray::SafeDownCast(
149 input->GetCellData()->GetAbstractArray(this->CellIdsAttribute.c_str()));
150 if (!faceIds)
151 {
152 vtkErrorMacro(<< this->CellIdsAttribute.c_str() << " array is not of expected type.");
153 return 0;
154 }
155
156 // Shallow copy the cell data. All the cells get copied to output.
157 output->GetCellData()->PassData(input->GetCellData());
158
159 // Deep copy the point information and be ready to add points.
160 vtkNew<vtkPoints> points;
161 points->DeepCopy(input->GetPoints());
162 output->SetPoints(points);
163 vtkPointData* inputPD = input->GetPointData();
164 vtkPointData* outputPD = output->GetPointData();
165 outputPD->CopyAllocate(inputPD);
166 const vtkIdType numOriginalPoints = points->GetNumberOfPoints();
167 for (vtkIdType i = 0; i < numOriginalPoints; ++i)
168 {
169 outputPD->CopyData(inputPD, i, i);
170 }
171
172 // Create an edge flag array.
173 vtkNew<vtkUnsignedCharArray> edgeflags;
174 edgeflags->SetName("vtkEdgeFlags");
175 edgeflags->SetNumberOfComponents(1);
176 edgeflags->SetNumberOfTuples(numOriginalPoints);
177 auto edgeflagsRange = vtk::DataArrayValueRange<1>(edgeflags);
178 std::fill(edgeflagsRange.begin(), edgeflagsRange.end(), NO_EDGE_FLAG);
179 outputPD->AddArray(edgeflags);
180 outputPD->SetActiveAttribute("vtkEdgeFlags", vtkDataSetAttributes::EDGEFLAG);
181
182 auto tagEdgeFlags = [&edgeflags](vtkCellArray* inputCell, vtkIdType offset = 0)
183 {
184 auto cellIter = vtk::TakeSmartPointer(inputCell->NewIterator());
185 vtkIdType npts;

Callers

nothing calls this directly

Calls 15

RecordEdgeFlagFunction · 0.85
GetAbstractArrayMethod · 0.80
GoToNextCellMethod · 0.80
GetVertsMethod · 0.80
SetVertsMethod · 0.80
SetLinesMethod · 0.80
GetStripsMethod · 0.80
SetStripsMethod · 0.80
GetPolysMethod · 0.80
SetPolysMethod · 0.80
GetDataFunction · 0.50
fillFunction · 0.50

Tested by

no test coverage detected