From: luukkainen Date: Wed, 28 Oct 2015 12:23:19 +0000 (+0000) Subject: fixes #6054 X-Git-Tag: simantics-1.20.0~3 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=29fae4d8a7b0609ce245eff6f84b7e6f2542b9e2;p=simantics%2F3d.git fixes #6054 git-svn-id: https://www.simantics.org/svn/simantics/3d/trunk@31881 ac1ea38d-2e2b-0410-8846-a27921b304fc --- 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 index 00000000..6fab2b80 --- /dev/null +++ b/org.simantics.g3d/src/org/simantics/g3d/shape/Box.java @@ -0,0 +1,96 @@ +package org.simantics.g3d.shape; + +import java.util.ArrayList; +import java.util.List; + +import javax.vecmath.Vector3d; + +public class Box { + + Vector3d min; + Vector3d max; + + public Vector3d getMin() { + return min; + } + public Vector3d getMax() { + return max; + } + + public Box(Vector3d min, Vector3d max) { + this.max = max; + this.min = min; + } + + public Box(double minx, double miny, double minz, double maxx, double maxy, double maxz) { + min = new Vector3d(minx, miny, minz); + max = new Vector3d(maxx, maxy, maxz); + } + + public Box(double min[], double max[]) { + this.min = new Vector3d(min); + this.max = new Vector3d(max); + } + + public Mesh createMesh() { + List vertices = new ArrayList(); + vertices.add(new Vector3d(min.x, min.y, min.z)); + vertices.add(new Vector3d(min.x, min.y, max.z)); + vertices.add(new Vector3d(min.x, max.y, min.z)); + vertices.add(new Vector3d(min.x, max.y, max.z)); + vertices.add(new Vector3d(max.x, min.y, min.z)); + vertices.add(new Vector3d(max.x, min.y, max.z)); + vertices.add(new Vector3d(max.x, max.y, min.z)); + vertices.add(new Vector3d(max.x, max.y, max.z)); + List indices = new ArrayList(); + indices.add(0); + indices.add(2); + indices.add(1); + + indices.add(1); + indices.add(2); + indices.add(3); + + indices.add(2); + indices.add(6); + indices.add(3); + + indices.add(3); + indices.add(6); + indices.add(7); + + indices.add(5); + indices.add(1); + indices.add(7); + + indices.add(1); + indices.add(3); + indices.add(7); + + indices.add(4); + indices.add(5); + indices.add(6); + + indices.add(5); + indices.add(7); + indices.add(6); + + indices.add(0); + indices.add(4); + indices.add(2); + + indices.add(2); + indices.add(4); + indices.add(6); + + indices.add(0); + indices.add(1); + indices.add(4); + + indices.add(5); + indices.add(4); + indices.add(1); + return new Mesh(vertices, indices); + } + +} diff --git a/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java b/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java index 9cbf71a9..3cc0ff4d 100644 --- a/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java +++ b/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java @@ -114,6 +114,18 @@ public class OccTriangulator { return tds; } + + public static TopoDS_Shape makeTorus(double[] pointStruct, double[] dirStruct, double[] dirStruct2, double r1, double r2) { + double[] axe = new double[9]; + System.arraycopy(pointStruct, 0, axe, 0, 3); + System.arraycopy(dirStruct, 0, axe, 3, 3); + System.arraycopy(dirStruct2, 0, axe, 6, 3); + BRepPrimAPI_MakeTorus torus = new BRepPrimAPI_MakeTorus(axe, r1, r2); + org.jcae.opencascade.jni.TopoDS_Shape tds = torus.shape(); + torus.delete(); + return tds; + } + public static TopoDS_Shape makeTorus(double[] pointStruct, double[] dirStruct, double r1, double r2, double angle1, double angle2, double angle) { double[] axe = new double[6]; System.arraycopy(pointStruct, 0, axe, 0, 3); @@ -123,6 +135,17 @@ public class OccTriangulator { torus.delete(); return tds; } + + public static TopoDS_Shape makeTorus(double[] pointStruct, double[] dirStruct, double[] dirStruct2, double r1, double r2, double angle1, double angle2, double angle) { + double[] axe = new double[9]; + System.arraycopy(pointStruct, 0, axe, 0, 3); + System.arraycopy(dirStruct, 0, axe, 3, 3); + System.arraycopy(dirStruct2, 0, axe, 6, 3); + BRepPrimAPI_MakeTorus torus = new BRepPrimAPI_MakeTorus(axe, r1, r2,angle1,angle2,angle); + org.jcae.opencascade.jni.TopoDS_Shape tds = torus.shape(); + torus.delete(); + return tds; + } public static TopoDS_Shape makeSphere(double x, double y, double z, double radius) { double[] c = new double[] { x, y, z };