X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Fgizmo%2FTranslateGizmo.java;h=49abd1f271f269b40bab4536c9fc24a63ab9c4a2;hb=9783d236a085584ac964444b365b566fd6a921ba;hp=c747e0b943cadc3bc62a23cde0d64f12b6140fcd;hpb=0f1acf557db4515528bc452c037db0831fd34ecf;p=simantics%2F3d.git diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateGizmo.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateGizmo.java index c747e0b9..49abd1f2 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateGizmo.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/gizmo/TranslateGizmo.java @@ -1,383 +1,383 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g3d.vtk.gizmo; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import vtk.vtkActor; -import vtk.vtkDataSetMapper; -import vtk.vtkPoints; -import vtk.vtkPolyData; -import vtk.vtkProp; -import vtk.vtkTriangle; - -public class TranslateGizmo extends vtkGizmo { - - - - private List parts; - - @Override - public Collection getGizmo() { - if (parts == null) { - parts = new ArrayList(); - - - float size = 2.f; - float sizeD2 = 1.f; - float offset = 0.2f; - - double[] colorX = new double[]{0.5,0.0,0.0}; - double[] colorY = new double[]{0.0,0.5,0.0}; - double[] colorZ = new double[]{0.0,0.0,0.5}; - - double[] colorXY = add(colorX, colorY); - double[] colorXZ = add(colorX, colorZ); - double[] colorYZ = add(colorY, colorZ); - double[] colorP = add(colorX,colorY,colorZ); - - vtkActor actorX = new vtkActor(); - vtkActor actorY = new vtkActor(); - vtkActor actorZ = new vtkActor(); - vtkActor actorXY = new vtkActor(); - vtkActor actorXZ = new vtkActor(); - vtkActor actorYZ = new vtkActor(); - vtkActor actorP = new vtkActor(); - - actorX.GetProperty().SetColor(colorX); - actorY.GetProperty().SetColor(colorY); - actorZ.GetProperty().SetColor(colorZ); - actorXY.GetProperty().SetColor(colorXY); - actorXZ.GetProperty().SetColor(colorXZ); - actorYZ.GetProperty().SetColor(colorYZ); - actorP.GetProperty().SetColor(colorP); - - actorX.GetProperty().SetOpacity(0.5); - actorY.GetProperty().SetOpacity(0.5); - actorZ.GetProperty().SetOpacity(0.5); - actorXY.GetProperty().SetOpacity(0.5); - actorXZ.GetProperty().SetOpacity(0.5); - actorYZ.GetProperty().SetOpacity(0.5); - actorP.GetProperty().SetOpacity(0.5); - - actorX.GetProperty().BackfaceCullingOff(); - actorY.GetProperty().BackfaceCullingOff(); - actorZ.GetProperty().BackfaceCullingOff(); - actorXY.GetProperty().BackfaceCullingOff(); - actorXZ.GetProperty().BackfaceCullingOff(); - actorYZ.GetProperty().BackfaceCullingOff(); - actorP.GetProperty().BackfaceCullingOff(); - - actorX.SetPickable(1); - actorY.SetPickable(1); - actorZ.SetPickable(1); - actorXY.SetPickable(1); - actorXZ.SetPickable(1); - actorYZ.SetPickable(1); - actorP.SetPickable(1); - - - actorX.GetProperty().LightingOff(); - actorY.GetProperty().LightingOff(); - actorZ.GetProperty().LightingOff(); - actorXY.GetProperty().LightingOff(); - actorXZ.GetProperty().LightingOff(); - actorYZ.GetProperty().LightingOff(); - actorP.GetProperty().LightingOff(); - - - vtkTriangle triangle = new vtkTriangle(); - - // X - vtkPolyData actorXData = new vtkPolyData(); - actorXData.Allocate(6, 6); - - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 1); - triangle.GetPointIds().SetId(1, 2); - triangle.GetPointIds().SetId(2, 3); - actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 3); - triangle.GetPointIds().SetId(2, 5); - actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 3); - triangle.GetPointIds().SetId(1, 4); - triangle.GetPointIds().SetId(2, 5); - actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - - vtkPoints partPoints = new vtkPoints(); - partPoints.InsertPoint(0, new double[]{size,0.,0.}); - partPoints.InsertPoint(1, new double[]{size-offset,offset,0.}); - partPoints.InsertPoint(2, new double[]{sizeD2-offset,offset,0.}); - partPoints.InsertPoint(3, new double[]{sizeD2,0.,0.}); - partPoints.InsertPoint(4, new double[]{sizeD2-offset,0.,offset}); - partPoints.InsertPoint(5, new double[]{size-offset,0.,offset}); - actorXData.SetPoints(partPoints); - partPoints.Delete(); - - // Y - vtkPolyData actorYData = new vtkPolyData(); - actorYData.Allocate(6, 6); - - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 1); - triangle.GetPointIds().SetId(1, 2); - triangle.GetPointIds().SetId(2, 3); - actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 3); - triangle.GetPointIds().SetId(2, 5); - actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 3); - triangle.GetPointIds().SetId(1, 4); - triangle.GetPointIds().SetId(2, 5); - actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - - partPoints = new vtkPoints(); - partPoints.InsertPoint(0, new double[]{0., size, 0.}); - partPoints.InsertPoint(1, new double[]{offset, size - offset, 0.}); - partPoints.InsertPoint(2, new double[]{offset, sizeD2 - offset, 0.}); - partPoints.InsertPoint(3, new double[]{0., sizeD2, 0.}); - partPoints.InsertPoint(4, new double[]{0., sizeD2 - offset, offset}); - partPoints.InsertPoint(5, new double[]{0., size - offset, offset}); - actorYData.SetPoints(partPoints); - partPoints.Delete(); - - // Z - vtkPolyData actorZData = new vtkPolyData(); - actorZData.Allocate(6, 6); - - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 1); - triangle.GetPointIds().SetId(1, 2); - triangle.GetPointIds().SetId(2, 3); - actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 3); - triangle.GetPointIds().SetId(2, 5); - actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 3); - triangle.GetPointIds().SetId(1, 4); - triangle.GetPointIds().SetId(2, 5); - actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - - partPoints = new vtkPoints(); - partPoints.InsertPoint(0, new double[]{0., 0.,size}); - partPoints.InsertPoint(1, new double[]{offset, 0., size - offset}); - partPoints.InsertPoint(2, new double[]{offset, 0., sizeD2 - offset}); - partPoints.InsertPoint(3, new double[]{0., 0., sizeD2}); - partPoints.InsertPoint(4, new double[]{0., offset, sizeD2 - offset}); - partPoints.InsertPoint(5, new double[]{0., offset, size - offset}); - actorZData.SetPoints(partPoints); - partPoints.Delete(); - - // XY - vtkPolyData actorXYData = new vtkPolyData(); - actorXYData.Allocate(4, 4); - - triangle.GetPointIds().SetId(0, 2); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorXYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorXYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - - partPoints = new vtkPoints(); - partPoints.InsertPoint(0, new double[]{offset, size-offset, 0.f}); - partPoints.InsertPoint(1, new double[]{offset, sizeD2 - offset, 0.f}); - partPoints.InsertPoint(2, new double[]{sizeD2 - offset, offset, 0.f}); - partPoints.InsertPoint(3, new double[]{size-offset, offset, 0.f}); - actorXYData.SetPoints(partPoints); - partPoints.Delete(); - - // XZ - vtkPolyData actorXZData = new vtkPolyData(); - actorXZData.Allocate(4, 4); - - triangle.GetPointIds().SetId(0, 2); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorXZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorXZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - - partPoints = new vtkPoints(); - partPoints.InsertPoint(0, new double[]{offset, 0.f, size-offset}); - partPoints.InsertPoint(1, new double[]{offset, 0.f, sizeD2 - offset}); - partPoints.InsertPoint(2, new double[]{sizeD2 - offset, 0.f, offset}); - partPoints.InsertPoint(3, new double[]{size-offset, 0.f, offset}); - actorXZData.SetPoints(partPoints); - partPoints.Delete(); - - // YZ - vtkPolyData actorYZData = new vtkPolyData(); - actorYZData.Allocate(4, 4); - - triangle.GetPointIds().SetId(0, 2); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorYZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 3); - actorYZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - - partPoints = new vtkPoints(); - partPoints.InsertPoint(0, new double[]{0.f,offset, size-offset}); - partPoints.InsertPoint(1, new double[]{0.f,offset, sizeD2 - offset}); - partPoints.InsertPoint(2, new double[]{0.f,sizeD2 - offset, offset}); - partPoints.InsertPoint(3, new double[]{0.f,size-offset, offset}); - - actorYZData.SetPoints(partPoints); - partPoints.Delete(); - - vtkPolyData actorPData = new vtkPolyData(); - actorPData.Allocate(10, 10); - - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 1); - triangle.GetPointIds().SetId(2, 2); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 2); - triangle.GetPointIds().SetId(2, 3); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 3); - triangle.GetPointIds().SetId(2, 4); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 4); - triangle.GetPointIds().SetId(2, 5); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 5); - triangle.GetPointIds().SetId(2, 6); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 6); - triangle.GetPointIds().SetId(2, 7); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 7); - triangle.GetPointIds().SetId(2, 8); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 8); - triangle.GetPointIds().SetId(2, 9); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - triangle.GetPointIds().SetId(0, 0); - triangle.GetPointIds().SetId(1, 9); - triangle.GetPointIds().SetId(2, 1); - actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); - - partPoints = new vtkPoints(); - partPoints.InsertPoint(0, new double[]{0.f, 0.f, 0.f}); - partPoints.InsertPoint(1, new double[]{sizeD2, 0.f, 0.f}); - partPoints.InsertPoint(2, new double[]{sizeD2 - offset, offset, 0.f}); - partPoints.InsertPoint(3, new double[]{offset, sizeD2 - offset, 0.f}); - partPoints.InsertPoint(4, new double[]{0.f, sizeD2, 0.f}); - partPoints.InsertPoint(5, new double[]{0.f, sizeD2 - offset, offset}); - partPoints.InsertPoint(6, new double[]{0.f, offset, sizeD2-offset}); - partPoints.InsertPoint(7, new double[]{0.f, 0.f, sizeD2}); - partPoints.InsertPoint(8, new double[]{offset, 0.f, sizeD2-offset}); - partPoints.InsertPoint(9, new double[]{sizeD2-offset, 0.f, offset}); - actorPData.SetPoints(partPoints); - partPoints.Delete(); - - - vtkDataSetMapper partMapper = new vtkDataSetMapper(); - partMapper.SetInput(actorXData); - partMapper.ScalarVisibilityOn(); - actorX.SetMapper(partMapper); - partMapper.Delete(); - - partMapper = new vtkDataSetMapper(); - partMapper.SetInput(actorYData); - partMapper.ScalarVisibilityOn(); - actorY.SetMapper(partMapper); - partMapper.Delete(); - - partMapper = new vtkDataSetMapper(); - partMapper.SetInput(actorZData); - partMapper.ScalarVisibilityOn(); - actorZ.SetMapper(partMapper); - partMapper.Delete(); - - partMapper = new vtkDataSetMapper(); - partMapper.SetInput(actorXYData); - partMapper.ScalarVisibilityOn(); - actorXY.SetMapper(partMapper); - partMapper.Delete(); - - partMapper = new vtkDataSetMapper(); - partMapper.SetInput(actorXZData); - partMapper.ScalarVisibilityOn(); - actorXZ.SetMapper(partMapper); - partMapper.Delete(); - - partMapper = new vtkDataSetMapper(); - partMapper.SetInput(actorYZData); - partMapper.ScalarVisibilityOn(); - actorYZ.SetMapper(partMapper); - partMapper.Delete(); - - partMapper = new vtkDataSetMapper(); - partMapper.SetInput(actorPData); - partMapper.ScalarVisibilityOn(); - actorP.SetMapper(partMapper); - partMapper.Delete(); - - - actorXData.Delete(); - actorYData.Delete(); - actorZData.Delete(); - actorXYData.Delete(); - actorXZData.Delete(); - actorYZData.Delete(); - actorPData.Delete(); - - parts.add(actorX); - parts.add(actorY); - parts.add(actorZ); - parts.add(actorXY); - parts.add(actorXZ); - parts.add(actorYZ); - parts.add(actorP); - } - return parts; - } - - public int getTranslateAxis(vtkActor actor) { - if (actor == null) - return -1; - return parts.indexOf(actor); - } - - -} +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g3d.vtk.gizmo; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import vtk.vtkActor; +import vtk.vtkDataSetMapper; +import vtk.vtkPoints; +import vtk.vtkPolyData; +import vtk.vtkProp; +import vtk.vtkTriangle; + +public class TranslateGizmo extends vtkGizmo { + + + + private List parts; + + @Override + public Collection getGizmo() { + if (parts == null) { + parts = new ArrayList(); + + + float size = 2.f; + float sizeD2 = 1.f; + float offset = 0.2f; + + double[] colorX = new double[]{0.5,0.0,0.0}; + double[] colorY = new double[]{0.0,0.5,0.0}; + double[] colorZ = new double[]{0.0,0.0,0.5}; + + double[] colorXY = add(colorX, colorY); + double[] colorXZ = add(colorX, colorZ); + double[] colorYZ = add(colorY, colorZ); + double[] colorP = add(colorX,colorY,colorZ); + + vtkActor actorX = new vtkActor(); + vtkActor actorY = new vtkActor(); + vtkActor actorZ = new vtkActor(); + vtkActor actorXY = new vtkActor(); + vtkActor actorXZ = new vtkActor(); + vtkActor actorYZ = new vtkActor(); + vtkActor actorP = new vtkActor(); + + actorX.GetProperty().SetColor(colorX); + actorY.GetProperty().SetColor(colorY); + actorZ.GetProperty().SetColor(colorZ); + actorXY.GetProperty().SetColor(colorXY); + actorXZ.GetProperty().SetColor(colorXZ); + actorYZ.GetProperty().SetColor(colorYZ); + actorP.GetProperty().SetColor(colorP); + + actorX.GetProperty().SetOpacity(0.5); + actorY.GetProperty().SetOpacity(0.5); + actorZ.GetProperty().SetOpacity(0.5); + actorXY.GetProperty().SetOpacity(0.5); + actorXZ.GetProperty().SetOpacity(0.5); + actorYZ.GetProperty().SetOpacity(0.5); + actorP.GetProperty().SetOpacity(0.5); + + actorX.GetProperty().BackfaceCullingOff(); + actorY.GetProperty().BackfaceCullingOff(); + actorZ.GetProperty().BackfaceCullingOff(); + actorXY.GetProperty().BackfaceCullingOff(); + actorXZ.GetProperty().BackfaceCullingOff(); + actorYZ.GetProperty().BackfaceCullingOff(); + actorP.GetProperty().BackfaceCullingOff(); + + actorX.SetPickable(1); + actorY.SetPickable(1); + actorZ.SetPickable(1); + actorXY.SetPickable(1); + actorXZ.SetPickable(1); + actorYZ.SetPickable(1); + actorP.SetPickable(1); + + + actorX.GetProperty().LightingOff(); + actorY.GetProperty().LightingOff(); + actorZ.GetProperty().LightingOff(); + actorXY.GetProperty().LightingOff(); + actorXZ.GetProperty().LightingOff(); + actorYZ.GetProperty().LightingOff(); + actorP.GetProperty().LightingOff(); + + + vtkTriangle triangle = new vtkTriangle(); + + // X + vtkPolyData actorXData = new vtkPolyData(); + actorXData.Allocate(6, 6); + + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 1); + triangle.GetPointIds().SetId(1, 2); + triangle.GetPointIds().SetId(2, 3); + actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 3); + triangle.GetPointIds().SetId(2, 5); + actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 3); + triangle.GetPointIds().SetId(1, 4); + triangle.GetPointIds().SetId(2, 5); + actorXData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + + vtkPoints partPoints = new vtkPoints(); + partPoints.InsertPoint(0, new double[]{size,0.,0.}); + partPoints.InsertPoint(1, new double[]{size-offset,offset,0.}); + partPoints.InsertPoint(2, new double[]{sizeD2-offset,offset,0.}); + partPoints.InsertPoint(3, new double[]{sizeD2,0.,0.}); + partPoints.InsertPoint(4, new double[]{sizeD2-offset,0.,offset}); + partPoints.InsertPoint(5, new double[]{size-offset,0.,offset}); + actorXData.SetPoints(partPoints); + partPoints.Delete(); + + // Y + vtkPolyData actorYData = new vtkPolyData(); + actorYData.Allocate(6, 6); + + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 1); + triangle.GetPointIds().SetId(1, 2); + triangle.GetPointIds().SetId(2, 3); + actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 3); + triangle.GetPointIds().SetId(2, 5); + actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 3); + triangle.GetPointIds().SetId(1, 4); + triangle.GetPointIds().SetId(2, 5); + actorYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + + partPoints = new vtkPoints(); + partPoints.InsertPoint(0, new double[]{0., size, 0.}); + partPoints.InsertPoint(1, new double[]{offset, size - offset, 0.}); + partPoints.InsertPoint(2, new double[]{offset, sizeD2 - offset, 0.}); + partPoints.InsertPoint(3, new double[]{0., sizeD2, 0.}); + partPoints.InsertPoint(4, new double[]{0., sizeD2 - offset, offset}); + partPoints.InsertPoint(5, new double[]{0., size - offset, offset}); + actorYData.SetPoints(partPoints); + partPoints.Delete(); + + // Z + vtkPolyData actorZData = new vtkPolyData(); + actorZData.Allocate(6, 6); + + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 1); + triangle.GetPointIds().SetId(1, 2); + triangle.GetPointIds().SetId(2, 3); + actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 3); + triangle.GetPointIds().SetId(2, 5); + actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 3); + triangle.GetPointIds().SetId(1, 4); + triangle.GetPointIds().SetId(2, 5); + actorZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + + partPoints = new vtkPoints(); + partPoints.InsertPoint(0, new double[]{0., 0.,size}); + partPoints.InsertPoint(1, new double[]{offset, 0., size - offset}); + partPoints.InsertPoint(2, new double[]{offset, 0., sizeD2 - offset}); + partPoints.InsertPoint(3, new double[]{0., 0., sizeD2}); + partPoints.InsertPoint(4, new double[]{0., offset, sizeD2 - offset}); + partPoints.InsertPoint(5, new double[]{0., offset, size - offset}); + actorZData.SetPoints(partPoints); + partPoints.Delete(); + + // XY + vtkPolyData actorXYData = new vtkPolyData(); + actorXYData.Allocate(4, 4); + + triangle.GetPointIds().SetId(0, 2); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorXYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorXYData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + + partPoints = new vtkPoints(); + partPoints.InsertPoint(0, new double[]{offset, size-offset, 0.f}); + partPoints.InsertPoint(1, new double[]{offset, sizeD2 - offset, 0.f}); + partPoints.InsertPoint(2, new double[]{sizeD2 - offset, offset, 0.f}); + partPoints.InsertPoint(3, new double[]{size-offset, offset, 0.f}); + actorXYData.SetPoints(partPoints); + partPoints.Delete(); + + // XZ + vtkPolyData actorXZData = new vtkPolyData(); + actorXZData.Allocate(4, 4); + + triangle.GetPointIds().SetId(0, 2); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorXZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorXZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + + partPoints = new vtkPoints(); + partPoints.InsertPoint(0, new double[]{offset, 0.f, size-offset}); + partPoints.InsertPoint(1, new double[]{offset, 0.f, sizeD2 - offset}); + partPoints.InsertPoint(2, new double[]{sizeD2 - offset, 0.f, offset}); + partPoints.InsertPoint(3, new double[]{size-offset, 0.f, offset}); + actorXZData.SetPoints(partPoints); + partPoints.Delete(); + + // YZ + vtkPolyData actorYZData = new vtkPolyData(); + actorYZData.Allocate(4, 4); + + triangle.GetPointIds().SetId(0, 2); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorYZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 3); + actorYZData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + + partPoints = new vtkPoints(); + partPoints.InsertPoint(0, new double[]{0.f,offset, size-offset}); + partPoints.InsertPoint(1, new double[]{0.f,offset, sizeD2 - offset}); + partPoints.InsertPoint(2, new double[]{0.f,sizeD2 - offset, offset}); + partPoints.InsertPoint(3, new double[]{0.f,size-offset, offset}); + + actorYZData.SetPoints(partPoints); + partPoints.Delete(); + + vtkPolyData actorPData = new vtkPolyData(); + actorPData.Allocate(10, 10); + + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 1); + triangle.GetPointIds().SetId(2, 2); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 2); + triangle.GetPointIds().SetId(2, 3); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 3); + triangle.GetPointIds().SetId(2, 4); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 4); + triangle.GetPointIds().SetId(2, 5); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 5); + triangle.GetPointIds().SetId(2, 6); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 6); + triangle.GetPointIds().SetId(2, 7); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 7); + triangle.GetPointIds().SetId(2, 8); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 8); + triangle.GetPointIds().SetId(2, 9); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + triangle.GetPointIds().SetId(0, 0); + triangle.GetPointIds().SetId(1, 9); + triangle.GetPointIds().SetId(2, 1); + actorPData.InsertNextCell(triangle.GetCellType(), triangle.GetPointIds()); + + partPoints = new vtkPoints(); + partPoints.InsertPoint(0, new double[]{0.f, 0.f, 0.f}); + partPoints.InsertPoint(1, new double[]{sizeD2, 0.f, 0.f}); + partPoints.InsertPoint(2, new double[]{sizeD2 - offset, offset, 0.f}); + partPoints.InsertPoint(3, new double[]{offset, sizeD2 - offset, 0.f}); + partPoints.InsertPoint(4, new double[]{0.f, sizeD2, 0.f}); + partPoints.InsertPoint(5, new double[]{0.f, sizeD2 - offset, offset}); + partPoints.InsertPoint(6, new double[]{0.f, offset, sizeD2-offset}); + partPoints.InsertPoint(7, new double[]{0.f, 0.f, sizeD2}); + partPoints.InsertPoint(8, new double[]{offset, 0.f, sizeD2-offset}); + partPoints.InsertPoint(9, new double[]{sizeD2-offset, 0.f, offset}); + actorPData.SetPoints(partPoints); + partPoints.Delete(); + + + vtkDataSetMapper partMapper = new vtkDataSetMapper(); + partMapper.SetInputData(actorXData); + partMapper.ScalarVisibilityOn(); + actorX.SetMapper(partMapper); + partMapper.Delete(); + + partMapper = new vtkDataSetMapper(); + partMapper.SetInputData(actorYData); + partMapper.ScalarVisibilityOn(); + actorY.SetMapper(partMapper); + partMapper.Delete(); + + partMapper = new vtkDataSetMapper(); + partMapper.SetInputData(actorZData); + partMapper.ScalarVisibilityOn(); + actorZ.SetMapper(partMapper); + partMapper.Delete(); + + partMapper = new vtkDataSetMapper(); + partMapper.SetInputData(actorXYData); + partMapper.ScalarVisibilityOn(); + actorXY.SetMapper(partMapper); + partMapper.Delete(); + + partMapper = new vtkDataSetMapper(); + partMapper.SetInputData(actorXZData); + partMapper.ScalarVisibilityOn(); + actorXZ.SetMapper(partMapper); + partMapper.Delete(); + + partMapper = new vtkDataSetMapper(); + partMapper.SetInputData(actorYZData); + partMapper.ScalarVisibilityOn(); + actorYZ.SetMapper(partMapper); + partMapper.Delete(); + + partMapper = new vtkDataSetMapper(); + partMapper.SetInputData(actorPData); + partMapper.ScalarVisibilityOn(); + actorP.SetMapper(partMapper); + partMapper.Delete(); + + + actorXData.Delete(); + actorYData.Delete(); + actorZData.Delete(); + actorXYData.Delete(); + actorXZData.Delete(); + actorYZData.Delete(); + actorPData.Delete(); + + parts.add(actorX); + parts.add(actorY); + parts.add(actorZ); + parts.add(actorXY); + parts.add(actorXZ); + parts.add(actorYZ); + parts.add(actorP); + } + return parts; + } + + public int getTranslateAxis(vtkActor actor) { + if (actor == null) + return -1; + return parts.indexOf(actor); + } + + +}