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

Method SetViewInfo

Rendering/Core/vtkLabeledContourMapper.cxx:1042–1114  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1040
1041//------------------------------------------------------------------------------
1042bool vtkLabeledContourMapper::Private::SetViewInfo(vtkRenderer* ren, vtkActor* act)
1043{
1044 vtkCamera* cam = ren->GetActiveCamera();
1045 if (!cam)
1046 {
1047 vtkGenericWarningMacro(<< "No active camera on renderer.");
1048 return false;
1049 }
1050
1051 vtkMatrix4x4* mat = cam->GetModelViewTransformMatrix();
1052 this->CameraRight.Set(mat->GetElement(0, 0), mat->GetElement(0, 1), mat->GetElement(0, 2));
1053 this->CameraUp.Set(mat->GetElement(1, 0), mat->GetElement(1, 1), mat->GetElement(1, 2));
1054 this->CameraForward.Set(mat->GetElement(2, 0), mat->GetElement(2, 1), mat->GetElement(2, 2));
1055
1056 // figure out the same aspect ratio used by the render engine
1057 // (see vtkOpenGLCamera::Render())
1058 int lowerLeft[2];
1059 int usize, vsize;
1060 double aspect1[2];
1061 double aspect2[2];
1062 ren->GetTiledSizeAndOrigin(&usize, &vsize, lowerLeft, lowerLeft + 1);
1063 ren->ComputeAspect();
1064 ren->GetAspect(aspect1);
1065 ren->vtkViewport::ComputeAspect();
1066 ren->vtkViewport::GetAspect(aspect2);
1067 double aspectModification = (aspect1[0] * aspect2[1]) / (aspect1[1] * aspect2[0]);
1068 double aspect = aspectModification * usize / vsize;
1069
1070 // Get the mvp (mcdc) matrix
1071 double mvp[16];
1072 mat = cam->GetCompositeProjectionTransformMatrix(aspect, -1, 1);
1073 vtkMatrix4x4::DeepCopy(mvp, mat);
1074
1075 // Apply the actor's matrix:
1076 vtkMatrix4x4::DeepCopy(this->ActorMatrix.GetData(), act->GetMatrix());
1077 vtkMatrix4x4::Multiply4x4(mvp, this->ActorMatrix.GetData(), this->AMVP.GetData());
1078
1079 vtkMatrix4x4::Invert(this->ActorMatrix.GetData(), this->InverseActorMatrix.GetData());
1080
1081 if (vtkWindow* win = ren->GetVTKWindow())
1082 {
1083 const int* size = win->GetSize();
1084 this->WindowSize[0] = size[0];
1085 this->WindowSize[1] = size[1];
1086
1087 size = ren->GetSize();
1088 this->ViewPortSize[0] = size[0];
1089 this->ViewPortSize[1] = size[1];
1090
1091 ren->GetViewport(this->ViewPort.GetData());
1092
1093 double* tvport = win->GetTileViewport();
1094 this->NormalizedViewPort[0] = std::max(this->ViewPort[0], tvport[0]);
1095 this->NormalizedViewPort[1] = std::max(this->ViewPort[1], tvport[1]);
1096 this->NormalizedViewPort[2] = std::min(this->ViewPort[2], tvport[2]);
1097 this->NormalizedViewPort[3] = std::min(this->ViewPort[3], tvport[3]);
1098
1099 this->ViewportBounds[0] = this->ViewPort[0] * this->WindowSize[0];

Callers 1

PrepareRenderMethod · 0.45

Calls 15

GetActiveCameraMethod · 0.80
ComputeAspectMethod · 0.80
GetVTKWindowMethod · 0.80
GetViewportMethod · 0.80
DeepCopyFunction · 0.50
InvertFunction · 0.50
maxFunction · 0.50
minFunction · 0.50
SetMethod · 0.45
GetTiledSizeAndOriginMethod · 0.45

Tested by

no test coverage detected