| 160 | } |
| 161 | |
| 162 | void 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]); |
no test coverage detected