1 package org.simantics.plant3d.geometry;
3 import java.util.Collection;
4 import java.util.Collections;
7 import org.jcae.opencascade.jni.BRepBuilderAPI_MakeEdge;
8 import org.jcae.opencascade.jni.BRepBuilderAPI_MakeFace;
9 import org.jcae.opencascade.jni.BRepBuilderAPI_MakeWire;
10 import org.jcae.opencascade.jni.BRepPrimAPI_MakeRevol;
11 import org.jcae.opencascade.jni.GC_MakeArcOfCircle;
12 import org.jcae.opencascade.jni.GC_MakeSegment;
13 import org.jcae.opencascade.jni.TopoDS_Edge;
14 import org.jcae.opencascade.jni.TopoDS_Face;
15 import org.jcae.opencascade.jni.TopoDS_Shape;
16 import org.jcae.opencascade.jni.TopoDS_Wire;
17 import org.simantics.db.Resource;
18 import org.simantics.opencascade.OccTriangulator;
20 public class PumpGeometryProvider extends BuiltinGeometryProvider {
22 public PumpGeometryProvider(Resource resource) {
26 private double length = 0.5;
27 private double width = 0.25;
30 public Collection<TopoDS_Shape> getModel() throws Exception {
31 double h = width * 0.5;
32 double h2 = width * 0.1;
33 double ld2 = length * 0.5;
34 double wd2 = width * 0.5;
36 double r1 = width * 0.5;
40 double l1 = length * 0.2;
41 double l2 = length * 0.2;
42 double l2b = l2 + length * 0.1;
43 double l3 = length * 0.6;
45 double dir[] = new double[]{1.0,0.0,0.0};
47 TopoDS_Shape foundation = OccTriangulator.makeBox(-ld2, 0.0, -wd2, ld2, h2, wd2);
48 TopoDS_Shape rotator = OccTriangulator.makeCylinder(new double[]{-ld2,h+h2,0.0}, dir, r1, l1);
49 TopoDS_Shape axis = OccTriangulator.makeCylinder(new double[]{-ld2+l1,h+h2,0.0}, dir, r2, l2b);
50 TopoDS_Shape motor = OccTriangulator.makeCylinder(new double[]{-ld2+l1+l2,h+h2,0.0}, dir, r3, l3);
51 TopoDS_Shape motorBox = OccTriangulator.makeBox(-ld2+l1+l2, h2, -r3, ld2, h2+h-r3, r3);
53 TopoDS_Shape shape = OccTriangulator.makeCompound(new TopoDS_Shape[]{foundation,rotator,axis,motor,motorBox});
59 return Collections.singletonList(shape);
63 public void setProperties(Map<String, Object> props) {
64 if (props.containsKey("length"))
65 length = (Double)props.get("length");
66 if (props.containsKey("width")) {
67 width = (Double)props.get("width");