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

Function WritePoints

IO/Geometry/vtkOBJWriter.cxx:84–139  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

82};
83//----------------------------------------------------------------------------
84void WritePoints(std::ostream& f, vtkPoints* pts, vtkDataArray* normals,
85 const std::vector<vtkDataArray*>& tcoordsArray, std::vector<EndIndex>* endIndexes)
86{
87 vtkIdType nbPts = pts->GetNumberOfPoints();
88
89 // Positions
90 for (vtkIdType i = 0; i < nbPts; i++)
91 {
92 double p[3];
93 pts->GetPoint(i, p);
94 f << vtk::format("v {} {} {}\n", p[0], p[1], p[2]);
95 }
96
97 // Normals
98 if (normals)
99 {
100 for (vtkIdType i = 0; i < nbPts; i++)
101 {
102 double p[3];
103 normals->GetTuple(i, p);
104 f << vtk::format("vn {} {} {}\n", p[0], p[1], p[2]);
105 }
106 }
107
108 // Textures
109 if (!tcoordsArray.empty())
110 {
111 vtkIdType vtEndIndex = 0;
112 vtkIdType pointEndIndex = 0;
113 for (size_t tcoordsIndex = 0; tcoordsIndex < tcoordsArray.size(); ++tcoordsIndex)
114 {
115 f << "# tcoords array " << tcoordsIndex << "\n";
116 vtkDataArray* tcoords = tcoordsArray[tcoordsIndex];
117 if (tcoords)
118 {
119 for (vtkIdType i = 0; i < nbPts; i++)
120 {
121 double p[2];
122 tcoords->GetTuple(i, p);
123 if (p[0] != -1.0)
124 {
125 f << vtk::format("vt {} {}\n", p[0], p[1]);
126 ++vtEndIndex;
127 pointEndIndex = i + 1;
128 }
129 }
130 endIndexes->emplace_back(vtEndIndex, pointEndIndex);
131 }
132 else
133 {
134 // there are no vertex textures (vt) for no_material
135 endIndexes->emplace_back(-1, -1);
136 }
137 }
138 }
139}
140
141//----------------------------------------------------------------------------

Callers 1

WriteDataMethod · 0.70

Calls 7

formatFunction · 0.50
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
GetTupleMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected