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

Method WriteGeometryFile

IO/Geometry/vtkBYUWriter.cxx:148–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void vtkBYUWriter::WriteGeometryFile(FILE* geomFile, int numPts)
149{
150 int numPolys, numEdges;
151 int i;
152 double* x;
153 vtkIdType npts = 0;
154 const vtkIdType* pts = nullptr;
155 vtkPoints* inPts;
156 vtkCellArray* inPolys;
157 vtkPolyData* input = this->GetInput();
158 //
159 // Check input
160 //
161 inPolys = input->GetPolys();
162 if ((inPts = input->GetPoints()) == nullptr || inPolys == nullptr)
163 {
164 vtkErrorMacro(<< "No data to write!");
165 return;
166 }
167 //
168 // Write header (not using fixed format! - potential problem in some files.)
169 //
170 numPolys = input->GetPolys()->GetNumberOfCells();
171 for (numEdges = 0, inPolys->InitTraversal(); inPolys->GetNextCell(npts, pts);)
172 {
173 numEdges += npts;
174 }
175
176 vtk::print(geomFile, "{:d} {:d} {:d} {:d}\n", 1, numPts, numPolys, numEdges);
177 vtk::print(geomFile, "{:d} {:d}\n", 1, numPolys);
178
179 //
180 // Write data
181 //
182 // write point coordinates
183 for (i = 0; i < numPts; i++)
184 {
185 x = inPts->GetPoint(i);
186 vtk::print(geomFile, "{:e} {:e} {:e} ", x[0], x[1], x[2]);
187 if ((i % 2))
188 {
189 vtk::print(geomFile, "\n");
190 }
191 }
192 if ((numPts % 2))
193 {
194 vtk::print(geomFile, "\n");
195 }
196
197 // write poly data. Remember 1-offset.
198 for (inPolys->InitTraversal(); inPolys->GetNextCell(npts, pts);)
199 {
200 // write this polygon
201 // treating vtkIdType as int
202 for (i = 0; i < (npts - 1); i++)
203 {
204 vtk::print(geomFile, "{:d} ", static_cast<int>(pts[i] + 1));
205 }

Callers 1

WriteDataMethod · 0.95

Calls 8

GetInputMethod · 0.95
GetPolysMethod · 0.80
printFunction · 0.50
GetPointsMethod · 0.45
GetNumberOfCellsMethod · 0.45
InitTraversalMethod · 0.45
GetNextCellMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected