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

Method GetTransform

Interaction/Widgets/vtkBoxWidget.cxx:1222–1289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1220}
1221
1222void vtkBoxWidget::GetTransform(vtkTransform* t)
1223{
1224 double* pts = static_cast<vtkDoubleArray*>(this->Points->GetData())->GetPointer(0);
1225 double* p0 = pts;
1226 double* p1 = pts + 3 * 1;
1227 double* p3 = pts + 3 * 3;
1228 double* p4 = pts + 3 * 4;
1229 double* p14 = pts + 3 * 14;
1230 double center[3], translate[3], scale[3], scaleVec[3][3];
1231 double InitialCenter[3];
1232 int i;
1233
1234 // The transformation is relative to the initial bounds.
1235 // Initial bounds are set when PlaceWidget() is invoked.
1236 t->Identity();
1237
1238 // Translation
1239 for (i = 0; i < 3; i++)
1240 {
1241 InitialCenter[i] = (this->InitialBounds[2 * i + 1] + this->InitialBounds[2 * i]) / 2.0;
1242 center[i] = p14[i] - InitialCenter[i];
1243 }
1244 translate[0] = center[0] + InitialCenter[0];
1245 translate[1] = center[1] + InitialCenter[1];
1246 translate[2] = center[2] + InitialCenter[2];
1247 t->Translate(translate[0], translate[1], translate[2]);
1248
1249 // Orientation
1250 vtkMatrix4x4* matrix = vtkMatrix4x4::New();
1251 this->PositionHandles();
1252 this->ComputeNormals();
1253 for (i = 0; i < 3; i++)
1254 {
1255 matrix->SetElement(i, 0, this->N[1][i]);
1256 matrix->SetElement(i, 1, this->N[3][i]);
1257 matrix->SetElement(i, 2, this->N[5][i]);
1258 }
1259 t->Concatenate(matrix);
1260 matrix->Delete();
1261
1262 // Scale
1263 for (i = 0; i < 3; i++)
1264 {
1265 scaleVec[0][i] = (p1[i] - p0[i]);
1266 scaleVec[1][i] = (p3[i] - p0[i]);
1267 scaleVec[2][i] = (p4[i] - p0[i]);
1268 }
1269
1270 scale[0] = vtkMath::Norm(scaleVec[0]);
1271 if (this->InitialBounds[1] != this->InitialBounds[0])
1272 {
1273 scale[0] = scale[0] / (this->InitialBounds[1] - this->InitialBounds[0]);
1274 }
1275 scale[1] = vtkMath::Norm(scaleVec[1]);
1276 if (this->InitialBounds[3] != this->InitialBounds[2])
1277 {
1278 scale[1] = scale[1] / (this->InitialBounds[3] - this->InitialBounds[2]);
1279 }

Callers 9

GetFrustumMethod · 0.45
GetAnnulusMethod · 0.45
GetConeMethod · 0.45
ExecuteMethod · 0.45
ExecuteMethod · 0.45
ExecuteMethod · 0.45
ExecuteMethod · 0.45

Calls 12

PositionHandlesMethod · 0.95
ComputeNormalsMethod · 0.95
DeleteMethod · 0.65
NewFunction · 0.50
NormFunction · 0.50
GetPointerMethod · 0.45
GetDataMethod · 0.45
IdentityMethod · 0.45
TranslateMethod · 0.45
SetElementMethod · 0.45
ConcatenateMethod · 0.45
ScaleMethod · 0.45

Tested by 1

ExecuteMethod · 0.36