------------------------------------------------------------------------------
| 1252 | |
| 1253 | //------------------------------------------------------------------------------ |
| 1254 | void vtkContourRepresentation::BuildLocator() |
| 1255 | { |
| 1256 | if (!this->RebuildLocator && !this->NeedToRender) |
| 1257 | { |
| 1258 | // rebuild if rebuildLocator or needtorender are true |
| 1259 | return; |
| 1260 | } |
| 1261 | |
| 1262 | vtkIdType size = (vtkIdType)this->Internal->Nodes.size(); |
| 1263 | vtkPoints* points = vtkPoints::New(); |
| 1264 | points->SetNumberOfPoints(size); |
| 1265 | |
| 1266 | // setup up the matrixes needed to transform |
| 1267 | // world to display. We are going to do this manually |
| 1268 | // as calling the renderer will create a new matrix for each call |
| 1269 | vtkMatrix4x4* matrix = vtkMatrix4x4::New(); |
| 1270 | matrix->DeepCopy(this->Renderer->GetActiveCamera()->GetCompositeProjectionTransformMatrix( |
| 1271 | this->Renderer->GetTiledAspectRatio(), 0, 1)); |
| 1272 | |
| 1273 | // viewport info |
| 1274 | double viewPortRatio[2]; |
| 1275 | int sizex, sizey; |
| 1276 | |
| 1277 | /* get physical window dimensions */ |
| 1278 | if (this->Renderer->GetVTKWindow()) |
| 1279 | { |
| 1280 | double* viewPort = this->Renderer->GetViewport(); |
| 1281 | sizex = this->Renderer->GetVTKWindow()->GetSize()[0]; |
| 1282 | sizey = this->Renderer->GetVTKWindow()->GetSize()[1]; |
| 1283 | viewPortRatio[0] = (sizex * (viewPort[2] - viewPort[0])) / 2.0 + sizex * viewPort[0]; |
| 1284 | viewPortRatio[1] = (sizey * (viewPort[3] - viewPort[1])) / 2.0 + sizey * viewPort[1]; |
| 1285 | } |
| 1286 | else |
| 1287 | { |
| 1288 | // can't compute the locator without a vtk window |
| 1289 | return; |
| 1290 | } |
| 1291 | |
| 1292 | double view[4]; |
| 1293 | double pos[3] = { 0, 0, 0 }; |
| 1294 | double* wp; |
| 1295 | for (vtkIdType i = 0; i < size; ++i) |
| 1296 | { |
| 1297 | wp = this->Internal->Nodes[i]->WorldPosition; |
| 1298 | pos[0] = this->Internal->Nodes[i]->WorldPosition[0]; |
| 1299 | pos[1] = this->Internal->Nodes[i]->WorldPosition[1]; |
| 1300 | pos[2] = this->Internal->Nodes[i]->WorldPosition[2]; |
| 1301 | |
| 1302 | // convert from world to view |
| 1303 | view[0] = wp[0] * matrix->Element[0][0] + wp[1] * matrix->Element[0][1] + |
| 1304 | wp[2] * matrix->Element[0][2] + matrix->Element[0][3]; |
| 1305 | view[1] = wp[0] * matrix->Element[1][0] + wp[1] * matrix->Element[1][1] + |
| 1306 | wp[2] * matrix->Element[1][2] + matrix->Element[1][3]; |
| 1307 | view[2] = wp[0] * matrix->Element[2][0] + wp[1] * matrix->Element[2][1] + |
| 1308 | wp[2] * matrix->Element[2][2] + matrix->Element[2][3]; |
| 1309 | view[3] = wp[0] * matrix->Element[3][0] + wp[1] * matrix->Element[3][1] + |
| 1310 | wp[2] * matrix->Element[3][2] + matrix->Element[3][3]; |
| 1311 | if (view[3] != 0.0) |
no test coverage detected