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

Method ComputeNumberOfCellsAndTypes

Testing/GenericBridge/vtkBridgeDataSet.cxx:144–201  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Description: Compute the number of cells for each dimension and the list of types of cells. \pre implementation_exists: this->Implementation!=0

Source from the content-addressed store, hash-verified

142// cells.
143// \pre implementation_exists: this->Implementation!=0
144void vtkBridgeDataSet::ComputeNumberOfCellsAndTypes()
145{
146 unsigned char type;
147 vtkIdType cellId;
148 vtkIdType numCells;
149 vtkCell* c;
150
151 if (this->GetMTime() > this->ComputeNumberOfCellsTime) // cache is obsolete
152 {
153 numCells = this->GetNumberOfCells();
154 this->NumberOf0DCells = 0;
155 this->NumberOf1DCells = 0;
156 this->NumberOf2DCells = 0;
157 this->NumberOf3DCells = 0;
158
159 this->Types->Reset();
160
161 if (this->Implementation != nullptr)
162 {
163 cellId = 0;
164 while (cellId < numCells)
165 {
166 c = this->Implementation->GetCell(cellId);
167 switch (c->GetCellDimension())
168 {
169 case 0:
170 this->NumberOf0DCells++;
171 break;
172 case 1:
173 this->NumberOf1DCells++;
174 break;
175 case 2:
176 this->NumberOf2DCells++;
177 break;
178 case 3:
179 this->NumberOf3DCells++;
180 break;
181 }
182 type = c->GetCellType();
183 if (!this->Types->IsType(type))
184 {
185 this->Types->InsertNextType(type);
186 }
187 cellId++;
188 }
189 }
190
191 this->ComputeNumberOfCellsTime.Modified(); // cache is up-to-date
192 assert("check: positive_dim0" && this->NumberOf0DCells >= 0);
193 assert("check: valid_dim0" && this->NumberOf0DCells <= numCells);
194 assert("check: positive_dim1" && this->NumberOf1DCells >= 0);
195 assert("check: valid_dim1" && this->NumberOf1DCells <= numCells);
196 assert("check: positive_dim2" && this->NumberOf2DCells >= 0);
197 assert("check: valid_dim2" && this->NumberOf2DCells <= numCells);
198 assert("check: positive_dim3" && this->NumberOf3DCells >= 0);
199 assert("check: valid_dim3" && this->NumberOf3DCells <= numCells);
200 }
201}

Callers 3

GetNumberOfCellsMethod · 0.95
GetCellDimensionMethod · 0.95
GetDistinctCellTypesMethod · 0.95

Calls 9

GetMTimeMethod · 0.95
GetNumberOfCellsMethod · 0.95
assertFunction · 0.50
ResetMethod · 0.45
GetCellMethod · 0.45
GetCellDimensionMethod · 0.45
GetCellTypeMethod · 0.45
IsTypeMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected