public void ApplyTransformBefore(vtkMatrix4x4 matrix) { vtkMatrix4x4 t = vtkMatrix4x4.New(); vtkMatrix4x4.Multiply4x4(matrix, actor.GetMatrix(), t); vtkTransform transform = vtkTransform.New(); transform.SetMatrix(t); this.actor.SetUserTransform(transform); }
public void ApplyTransform(vtkMatrix4x4 matrix) { vtkMatrix4x4 t = new vtkMatrix4x4(); vtkMatrix4x4.Multiply4x4(centerLineActor.GetMatrix(), matrix, t); vtkTransform transform = new vtkTransform(); transform.SetMatrix(t); this.centerLineActor.SetUserTransform(transform); }
// For reading C# matrices stored in scenario into VTK transforms public void TransferMatrixToVTKTransform(double[][] matrix, vtkTransform transform) { vtkMatrix4x4 vtk_matrix = vtkMatrix4x4.New(); for (int ii = 0; ii < 4; ++ii) { for (int jj = 0; jj < 4; ++jj) { vtk_matrix.SetElement(ii, jj, matrix[ii][jj]); } } transform.SetMatrix(vtk_matrix); }
public void SetTransform(vtkMatrix4x4 matrix) { if (actor == null) { return; } vtkTransform transform = vtkTransform.New(); transform.SetMatrix(matrix); this.actor.SetUserTransform(transform); }
static void AlignFrames(Frame sourceFrame, Frame targetFrame, ref vtkTransform transform) { // This function takes two frames and finds the matrix M between them. vtkLandmarkTransform landmarkTransform = vtkLandmarkTransform.New(); // Setup source points vtkPoints sourcePoints = vtkPoints.New(); sourcePoints.InsertNextPoint( sourceFrame.Origin[0], sourceFrame.Origin[1], sourceFrame.Origin[2]); float[] sourceX = new float[3]; float[] sourceY = new float[3]; float[] sourceZ = new float[3]; Add(sourceFrame.Origin, sourceFrame.XDirection, ref sourceX); Add(sourceFrame.Origin, sourceFrame.YDirection, ref sourceY); Add(sourceFrame.Origin, sourceFrame.ZDirection, ref sourceZ); sourcePoints.InsertNextPoint(sourceX[0], sourceX[1], sourceX[2]); sourcePoints.InsertNextPoint(sourceY[0], sourceY[1], sourceY[2]); sourcePoints.InsertNextPoint(sourceZ[0], sourceZ[1], sourceZ[2]); // Setup target points vtkPoints targetPoints = vtkPoints.New(); targetPoints.InsertNextPoint(targetFrame.Origin[0], targetFrame.Origin[1], targetFrame.Origin[2]); float[] targetX = new float[3]; float[] targetY = new float[3]; float[] targetZ = new float[3]; Add(targetFrame.Origin, targetFrame.XDirection, ref targetX); Add(targetFrame.Origin, targetFrame.YDirection, ref targetY); Add(targetFrame.Origin, targetFrame.ZDirection, ref targetZ); targetPoints.InsertNextPoint(targetX[0], targetX[1], targetX[2]); targetPoints.InsertNextPoint(targetY[0], targetY[1], targetY[2]); targetPoints.InsertNextPoint(targetZ[0], targetZ[1], targetZ[2]); landmarkTransform.SetSourceLandmarks(sourcePoints); landmarkTransform.SetTargetLandmarks(targetPoints); landmarkTransform.SetModeToRigidBody(); landmarkTransform.Update(); vtkMatrix4x4 M = landmarkTransform.GetMatrix(); transform.SetMatrix(M); }
public void SetTransform(vtkMatrix4x4 matrix) { vtkTransform transform = vtkTransform.New(); transform.SetMatrix(matrix); //this.lineActor.SetUserTransform(transform); //return; double[] linePoint1 = GetLinePoint1(); double[] linePoint2 = GetLinePoint2(); linePoint1 = xyz1; linePoint2 = xyz2; double[] p1 = matrix.MultiplyDoublePoint(VTKUtil.ConvertTo4P(linePoint1)); double[] p2 = matrix.MultiplyDoublePoint(VTKUtil.ConvertTo4P(linePoint2)); line.SetPoint1(p1[0], p1[1], p1[2]); line.SetPoint2(p2[0], p2[1], p2[2]); }