]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
fixes #6054
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 28 Oct 2015 12:23:19 +0000 (12:23 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 28 Oct 2015 12:23:19 +0000 (12:23 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/3d/trunk@31881 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.g3d/src/org/simantics/g3d/shape/Box.java [new file with mode: 0644]
org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java

diff --git a/org.simantics.g3d/src/org/simantics/g3d/shape/Box.java b/org.simantics.g3d/src/org/simantics/g3d/shape/Box.java
new file mode 100644 (file)
index 0000000..6fab2b8
--- /dev/null
@@ -0,0 +1,96 @@
+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
index 9cbf71a9c970721f3cda0b470d88bfe6846d4596..3cc0ff4dd5af0bbbca829a300b890ee8b9a90415 100644 (file)
@@ -114,6 +114,18 @@ public class OccTriangulator {
         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
@@ -123,6 +135,17 @@ public class OccTriangulator {
         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