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

Method SetPropertiesFromModelToWorldMatrix

Rendering/Core/vtkProp3D.cxx:162–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162void vtkProp3D::SetPropertiesFromModelToWorldMatrix(vtkMatrix4x4* modelToWorld)
163{
164 vtkMatrix4x4* inputMatrix = modelToWorld;
165
166 if (this->CoordinateSystem == PHYSICAL && this->CoordinateSystemRenderer)
167 {
168 // model -> intermediate -> user -> physical
169 // so
170 // modeltointermediate = modeltoworld * worldToPhysical * inverseUserMatrix
171 vtkRenderWindow* renWin =
172 static_cast<vtkRenderWindow*>(this->CoordinateSystemRenderer->GetVTKWindow());
173 renWin->GetPhysicalToWorldMatrix(this->TempMatrix4x4);
174 this->TempMatrix4x4->Invert();
175 vtkMatrix4x4::Multiply4x4(this->TempMatrix4x4, modelToWorld, this->TempMatrix4x4);
176 vtkMatrix4x4* userToIntermediate = this->GetUserMatrix();
177 if (userToIntermediate)
178 {
179 vtkNew<vtkMatrix4x4> tmpMatrix;
180 tmpMatrix->DeepCopy(userToIntermediate);
181 tmpMatrix->Invert();
182 vtkMatrix4x4::Multiply4x4(tmpMatrix, this->TempMatrix4x4, this->TempMatrix4x4);
183 }
184 inputMatrix = this->TempMatrix4x4;
185 }
186
187 if (this->CoordinateSystem == DEVICE && this->CoordinateSystemRenderer)
188 {
189 // modelToDevice = modelToWOrld * worldToDevice
190 vtkRenderWindow* renWin =
191 static_cast<vtkRenderWindow*>(this->CoordinateSystemRenderer->GetVTKWindow());
192 if (renWin->GetDeviceToWorldMatrixForDevice(
193 static_cast<vtkEventDataDevice>(this->CoordinateSystemDevice), this->TempMatrix4x4))
194 {
195 this->TempMatrix4x4->Invert();
196 vtkMatrix4x4::Multiply4x4(this->TempMatrix4x4, modelToWorld, this->TempMatrix4x4);
197 inputMatrix = this->TempMatrix4x4;
198 }
199 vtkMatrix4x4* userToIntermediate = this->GetUserMatrix();
200 if (userToIntermediate)
201 {
202 vtkNew<vtkMatrix4x4> tmpMatrix;
203 tmpMatrix->DeepCopy(userToIntermediate);
204 tmpMatrix->Invert();
205 vtkMatrix4x4::Multiply4x4(tmpMatrix, this->TempMatrix4x4, this->TempMatrix4x4);
206 }
207 }
208
209 double* mat = inputMatrix->GetData();
210 this->Origin[0] = 0.0;
211 this->Origin[1] = 0.0;
212 this->Origin[2] = 0.0;
213 this->Position[0] = mat[3];
214 this->Position[1] = mat[7];
215 this->Position[2] = mat[11];
216
217 this->Scale[0] = sqrt(mat[0] * mat[0] + mat[4] * mat[4] + mat[8] * mat[8]);
218 this->Scale[1] = sqrt(mat[1] * mat[1] + mat[5] * mat[5] + mat[9] * mat[9]);
219 this->Scale[2] = sqrt(mat[2] * mat[2] + mat[6] * mat[6] + mat[10] * mat[10]);

Callers 1

PositionPropMethod · 0.80

Calls 11

GetUserMatrixMethod · 0.95
SetOrientationMethod · 0.95
GetVTKWindowMethod · 0.80
sqrtFunction · 0.50
GetOrientationFunction · 0.50
InvertMethod · 0.45
DeepCopyMethod · 0.45
GetDataMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected