--- /dev/null
+package org.simantics.g3d.shape;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import javax.vecmath.Vector3d;\r
+\r
+public class Box {\r
+ \r
+ Vector3d min;\r
+ Vector3d max;\r
+ \r
+ public Vector3d getMin() {\r
+ return min;\r
+ }\r
+ public Vector3d getMax() {\r
+ return max;\r
+ }\r
+ \r
+ public Box(Vector3d min, Vector3d max) {\r
+ this.max = max;\r
+ this.min = min;\r
+ }\r
+ \r
+ public Box(double minx, double miny, double minz, double maxx, double maxy, double maxz) {\r
+ min = new Vector3d(minx, miny, minz);\r
+ max = new Vector3d(maxx, maxy, maxz);\r
+ }\r
+ \r
+ public Box(double min[], double max[]) {\r
+ this.min = new Vector3d(min);\r
+ this.max = new Vector3d(max);\r
+ }\r
+ \r
+ public Mesh createMesh() {\r
+ List<Vector3d> vertices = new ArrayList<Vector3d>();\r
+ vertices.add(new Vector3d(min.x, min.y, min.z));\r
+ vertices.add(new Vector3d(min.x, min.y, max.z));\r
+ vertices.add(new Vector3d(min.x, max.y, min.z));\r
+ vertices.add(new Vector3d(min.x, max.y, max.z));\r
+ vertices.add(new Vector3d(max.x, min.y, min.z));\r
+ vertices.add(new Vector3d(max.x, min.y, max.z));\r
+ vertices.add(new Vector3d(max.x, max.y, min.z));\r
+ vertices.add(new Vector3d(max.x, max.y, max.z));\r
+ List<Integer> indices = new ArrayList<Integer>();\r
+ indices.add(0);\r
+ indices.add(2);\r
+ indices.add(1);\r
+ \r
+ indices.add(1);\r
+ indices.add(2);\r
+ indices.add(3);\r
+ \r
+ indices.add(2);\r
+ indices.add(6);\r
+ indices.add(3);\r
+ \r
+ indices.add(3);\r
+ indices.add(6);\r
+ indices.add(7);\r
+ \r
+ indices.add(5);\r
+ indices.add(1);\r
+ indices.add(7);\r
+ \r
+ indices.add(1);\r
+ indices.add(3);\r
+ indices.add(7);\r
+ \r
+ indices.add(4);\r
+ indices.add(5);\r
+ indices.add(6);\r
+ \r
+ indices.add(5);\r
+ indices.add(7);\r
+ indices.add(6);\r
+ \r
+ indices.add(0);\r
+ indices.add(4);\r
+ indices.add(2);\r
+ \r
+ indices.add(2);\r
+ indices.add(4);\r
+ indices.add(6);\r
+ \r
+ indices.add(0);\r
+ indices.add(1);\r
+ indices.add(4);\r
+ \r
+ indices.add(5);\r
+ indices.add(4);\r
+ indices.add(1);\r
+ return new Mesh(vertices, indices);\r
+ }\r
+\r
+}\r
return tds;\r
}\r
\r
+\r
+ public static TopoDS_Shape makeTorus(double[] pointStruct, double[] dirStruct, double[] dirStruct2, double r1, double r2) {\r
+ double[] axe = new double[9];\r
+ System.arraycopy(pointStruct, 0, axe, 0, 3);\r
+ System.arraycopy(dirStruct, 0, axe, 3, 3);\r
+ System.arraycopy(dirStruct2, 0, axe, 6, 3);\r
+ BRepPrimAPI_MakeTorus torus = new BRepPrimAPI_MakeTorus(axe, r1, r2);\r
+ org.jcae.opencascade.jni.TopoDS_Shape tds = torus.shape();\r
+ torus.delete();\r
+ return tds;\r
+ }\r
+ \r
public static TopoDS_Shape makeTorus(double[] pointStruct, double[] dirStruct, double r1, double r2, double angle1, double angle2, double angle) {\r
double[] axe = new double[6];\r
System.arraycopy(pointStruct, 0, axe, 0, 3);\r
torus.delete();\r
return tds;\r
}\r
+ \r
+ public static TopoDS_Shape makeTorus(double[] pointStruct, double[] dirStruct, double[] dirStruct2, double r1, double r2, double angle1, double angle2, double angle) {\r
+ double[] axe = new double[9];\r
+ System.arraycopy(pointStruct, 0, axe, 0, 3);\r
+ System.arraycopy(dirStruct, 0, axe, 3, 3);\r
+ System.arraycopy(dirStruct2, 0, axe, 6, 3);\r
+ BRepPrimAPI_MakeTorus torus = new BRepPrimAPI_MakeTorus(axe, r1, r2,angle1,angle2,angle);\r
+ org.jcae.opencascade.jni.TopoDS_Shape tds = torus.shape();\r
+ torus.delete();\r
+ return tds;\r
+ }\r
\r
public static TopoDS_Shape makeSphere(double x, double y, double z, double radius) {\r
double[] c = new double[] { x, y, z };\r