| 49 | } |
| 50 | |
| 51 | void vtkOpenGLCellToVTKCellMap::BuildPrimitiveOffsetsIfNeeded( |
| 52 | vtkCellArray* prims[4], int representation, vtkPoints* points) |
| 53 | { |
| 54 | // if the users created a full cell cell map AND it is still valid then |
| 55 | // the values will be computed as part of that and we should use them |
| 56 | if (!this->CellCellMap.empty()) |
| 57 | { |
| 58 | this->TempState.Clear(); |
| 59 | this->TempState.Append(prims[0]->GetNumberOfCells() ? prims[0]->GetMTime() : 0, "verts"); |
| 60 | this->TempState.Append(prims[1]->GetNumberOfCells() ? prims[1]->GetMTime() : 0, "lines"); |
| 61 | this->TempState.Append(prims[2]->GetNumberOfCells() ? prims[2]->GetMTime() : 0, "polys"); |
| 62 | this->TempState.Append(prims[3]->GetNumberOfCells() ? prims[3]->GetMTime() : 0, "strips"); |
| 63 | this->TempState.Append(representation, "representation"); |
| 64 | this->TempState.Append(points ? points->GetMTime() : 0, "points"); |
| 65 | |
| 66 | // include StartOffset in the state so that changes to the offset |
| 67 | // (which can happen when composing multiple pieces) force a rebuild |
| 68 | // of the support arrays. Without this the cached map may be reused |
| 69 | // with an incorrect offset resulting in bad mappings. |
| 70 | this->TempState.Append(this->StartOffset, "startOffset"); |
| 71 | |
| 72 | if (this->MapBuildState != this->TempState) |
| 73 | { |
| 74 | this->CellCellMap.clear(); |
| 75 | } |
| 76 | else |
| 77 | { |
| 78 | return; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // otherwise compute some conservative values |
| 83 | // verts |
| 84 | this->PrimitiveOffsets[0] = this->StartOffset; |
| 85 | this->CellMapSizes[0] = prims[0]->GetNumberOfConnectivityIds(); |
| 86 | |
| 87 | // point rep is easy for all prims |
| 88 | if (representation == VTK_POINTS) |
| 89 | { |
| 90 | for (int j = 1; j < 4; j++) |
| 91 | { |
| 92 | this->CellMapSizes[j] = prims[j]->GetNumberOfConnectivityIds(); |
| 93 | this->PrimitiveOffsets[j] = this->PrimitiveOffsets[j - 1] + this->CellMapSizes[j - 1]; |
| 94 | } |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | // lines |
| 99 | this->CellMapSizes[1] = prims[1]->GetNumberOfConnectivityIds() - prims[1]->GetNumberOfCells(); |
| 100 | this->PrimitiveOffsets[1] = this->PrimitiveOffsets[0] + this->CellMapSizes[0]; |
| 101 | |
| 102 | if (representation == VTK_WIREFRAME) |
| 103 | { |
| 104 | // polys |
| 105 | this->CellMapSizes[2] = prims[2]->GetNumberOfConnectivityIds(); |
| 106 | this->PrimitiveOffsets[2] = this->PrimitiveOffsets[1] + this->CellMapSizes[1]; |
| 107 | |
| 108 | // strips |
no test coverage detected