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

Method BuildSelectionIBO

Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:4281–4392  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

4279
4280//------------------------------------------------------------------------------
4281void vtkOpenGLPolyDataMapper::BuildSelectionIBO(
4282 vtkPolyData* poly, std::vector<unsigned int> (&indices)[4], vtkIdType offset)
4283{
4284 // We need to construct primitives based on a vtkSelection.
4285 // These primitives are filtered based on composite index and process index.
4286 for (int i = 0; i < 4; i++)
4287 {
4288 this->SelectionArrays[i]->Reset();
4289 }
4290
4291 int fieldType = vtkSelectionNode::POINT;
4292 int contentType = vtkSelectionNode::INDICES;
4293 for (unsigned int i = 0; i < this->Selection->GetNumberOfNodes(); i++)
4294 {
4295 vtkSelectionNode* node = this->Selection->GetNode(i);
4296
4297 // gather selection types (field type and content type) to determine if the selection
4298 // is related to point or cell, and if the selection ids are related to a specific
4299 // array (selection by value) or related directly to polydata ids (selection by id).
4300 if (i == 0u)
4301 {
4302 fieldType = node->GetFieldType();
4303 contentType = node->GetContentType();
4304 }
4305 else
4306 {
4307 if (fieldType != node->GetFieldType() || contentType != node->GetContentType())
4308 {
4309 vtkWarningMacro(
4310 "All selection nodes must be of the same type. Only the first node will be used.");
4311 continue;
4312 }
4313 }
4314
4315 // get the process id and the composite id
4316 vtkInformation* info = node->GetProperties();
4317
4318 int processId = 0;
4319 if (info->Has(vtkSelectionNode::PROCESS_ID()))
4320 {
4321 processId = info->Get(vtkSelectionNode::PROCESS_ID());
4322 }
4323 int compositeIndex = 0;
4324 if (info->Has(vtkSelectionNode::COMPOSITE_INDEX()))
4325 {
4326 compositeIndex = info->Get(vtkSelectionNode::COMPOSITE_INDEX());
4327 }
4328
4329 vtkDataSetAttributes* attr = node->GetSelectionData();
4330 for (vtkIdType j = 0; j < attr->GetNumberOfArrays(); j++)
4331 {
4332 vtkIdTypeArray* idArray = vtkIdTypeArray::SafeDownCast(attr->GetArray(j));
4333 if (idArray)
4334 {
4335 // determine the name of the array to use
4336 const char* arrayName = nullptr;
4337 if (contentType == vtkSelectionNode::SelectionContent::VALUES)
4338 {

Callers 1

UpdateBufferObjectsMethod · 0.95

Calls 14

ResetMethod · 0.45
GetNumberOfNodesMethod · 0.45
GetNodeMethod · 0.45
GetFieldTypeMethod · 0.45
GetContentTypeMethod · 0.45
HasMethod · 0.45
GetMethod · 0.45
GetNumberOfArraysMethod · 0.45
GetArrayMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected