MCPcopy Create free account
hub / github.com/MITK/MITK / DeformObject

Method DeformObject

Modules/DataTypesExt/src/mitkSurfaceDeformationDataInteractor3D.cpp:140–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void mitk::SurfaceDeformationDataInteractor3D::DeformObject(StateMachineAction *, InteractionEvent *interactionEvent)
141{
142 const auto *positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent);
143 if (positionEvent == nullptr)
144 return;
145
146 int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
147 vtkPolyData *polyData = m_Surface->GetVtkPolyData(timeStep);
148 BaseGeometry::Pointer geometry = this->GetDataNode()->GetData()->GetGeometry(timeStep);
149
150 double currentWorldPoint[4];
151 mitk::Point2D currentDisplayPoint = positionEvent->GetPointerPositionOnScreen();
152 vtkInteractorObserver::ComputeDisplayToWorld(interactionEvent->GetSender()->GetVtkRenderer(),
153 currentDisplayPoint[0],
154 currentDisplayPoint[1],
155 0.0, // m_InitialInteractionPickedPoint[2],
156 currentWorldPoint);
157
158 // Calculate mouse move in 3D space
159 Vector3D interactionMove;
160 interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
161 interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
162 interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
163
164 // Transform mouse move into geometry space
165 this->GetDataNode()->GetData()->UpdateOutputInformation(); // make sure that the Geometry is up-to-date
166 Vector3D interactionMoveIndex;
167 geometry->WorldToIndex(interactionMove, interactionMoveIndex);
168
169 // Get picked point and transform into local coordinates
170 Point3D pickedPoint;
171 geometry->WorldToIndex(m_InitialPickedPoint, pickedPoint);
172
173 Vector3D v1 = pickedPoint.GetVectorFromOrigin();
174
175 vtkDataArray *normal = polyData->GetPointData()->GetVectors("planeNormal");
176 if (normal != nullptr)
177 {
178 m_ObjectNormal[0] = normal->GetComponent(0, 0);
179 m_ObjectNormal[1] = normal->GetComponent(0, 1);
180 m_ObjectNormal[2] = normal->GetComponent(0, 2);
181 }
182
183 Vector3D v2 = m_ObjectNormal * (interactionMoveIndex * m_ObjectNormal);
184
185 vtkPoints *originalPoints = m_OriginalPolyData->GetPoints();
186 vtkPoints *deformedPoints = polyData->GetPoints();
187
188 double denom = m_GaussSigma * m_GaussSigma * 2;
189 double point[3];
190 for (vtkIdType i = 0; i < deformedPoints->GetNumberOfPoints(); ++i)
191 {
192 // Get original point
193 double *originalPoint = originalPoints->GetPoint(i);
194
195 Vector3D v0;
196 v0[0] = originalPoint[0];
197 v0[1] = originalPoint[1];

Callers

nothing calls this directly

Calls 15

GetSenderMethod · 0.80
GetGeometryMethod · 0.80
GetNumberOfPointsMethod · 0.80
GetTimeStepMethod · 0.45
GetDataMethod · 0.45
GetDataNodeMethod · 0.45
GetVtkPolyDataMethod · 0.45
GetVtkRendererMethod · 0.45
WorldToIndexMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected