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

Method BuildCellSupportArrays

Rendering/OpenGL2/vtkOpenGLCellToVTKCellMap.cxx:135–271  ·  view source on GitHub ↗

Create supporting arrays that are needed when rendering cell data Some VTK cells have to be broken into smaller cells for OpenGL When we have cell data we have to map cell attributes from the VTK cell number to the actual OpenGL cell The following code fills in cellCellMap which maps a openGL cell id to the VTK cell it came from

Source from the content-addressed store, hash-verified

133// cellCellMap which maps a openGL cell id to the VTK cell it came from
134//
135void vtkOpenGLCellToVTKCellMap::BuildCellSupportArrays(
136 vtkCellArray* prims[4], int representation, vtkPoints* points)
137{
138 // need an array to track what points to orig points
139 vtkIdType minSize = prims[0]->GetNumberOfCells() + prims[1]->GetNumberOfCells() +
140 prims[2]->GetNumberOfCells() + prims[3]->GetNumberOfCells();
141 const vtkIdType* indices(nullptr);
142 vtkIdType npts(0);
143
144 // make sure we have at least minSize
145 this->CellCellMap.clear();
146 this->CellCellMap.reserve(minSize);
147 vtkIdType vtkCellCount = 0;
148 vtkIdType cumulativeSize = 0;
149 this->BuildRepresentation = representation;
150
151 // points
152 this->PrimitiveOffsets[0] = this->StartOffset;
153 for (prims[0]->InitTraversal(); prims[0]->GetNextCell(npts, indices);)
154 {
155 for (vtkIdType i = 0; i < npts; ++i)
156 {
157 this->CellCellMap.push_back(vtkCellCount);
158 }
159 vtkCellCount++;
160 } // for cell
161
162 this->CellMapSizes[0] = static_cast<vtkIdType>(this->CellCellMap.size());
163 cumulativeSize = this->CellMapSizes[0];
164
165 if (representation == VTK_POINTS)
166 {
167 for (int j = 1; j < 4; j++)
168 {
169 for (prims[j]->InitTraversal(); prims[j]->GetNextCell(npts, indices);)
170 {
171 for (vtkIdType i = 0; i < npts; ++i)
172 {
173 this->CellCellMap.push_back(vtkCellCount);
174 }
175 vtkCellCount++;
176 } // for cell
177 this->PrimitiveOffsets[j] = this->PrimitiveOffsets[j - 1] + this->CellMapSizes[j - 1];
178 this->CellMapSizes[j] = static_cast<vtkIdType>(this->CellCellMap.size()) - cumulativeSize;
179 cumulativeSize = static_cast<vtkIdType>(this->CellCellMap.size());
180 }
181 return;
182 }
183
184 // lines
185 for (prims[1]->InitTraversal(); prims[1]->GetNextCell(npts, indices);)
186 {
187 for (vtkIdType i = 0; i < npts - 1; ++i)
188 {
189 this->CellCellMap.push_back(vtkCellCount);
190 }
191 vtkCellCount++;
192 } // for cell

Callers 1

UpdateMethod · 0.95

Calls 8

GetNumberOfCellsMethod · 0.45
clearMethod · 0.45
reserveMethod · 0.45
InitTraversalMethod · 0.45
GetNextCellMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected