1 package org.simantics.plant3d.geometry;
3 import java.util.Collection;
4 import java.util.Collections;
7 import org.jcae.opencascade.jni.TopoDS_Shape;
8 import org.simantics.db.Resource;
9 import org.simantics.opencascade.OccTriangulator;
11 public class PumpGeometryProvider extends BuiltinGeometryProvider {
13 public PumpGeometryProvider(Resource resource) {
17 private double length = 0.5;
18 private double width = 0.25;
21 public Collection<TopoDS_Shape> getModel() throws Exception {
22 double h = width * 0.5;
23 double h2 = width * 0.1;
24 double ld2 = length * 0.5;
25 double wd2 = width * 0.5;
27 double r1 = width * 0.5;
31 double l1 = length * 0.2;
32 double l2 = length * 0.2;
33 double l2b = l2 + length * 0.1;
34 double l3 = length * 0.6;
36 double dir[] = new double[]{1.0,0.0,0.0};
38 TopoDS_Shape foundation = OccTriangulator.makeBox(-ld2, 0.0, -wd2, ld2, h2, wd2);
39 TopoDS_Shape rotator = OccTriangulator.makeCylinder(new double[]{-ld2,h+h2,0.0}, dir, r1, l1);
40 TopoDS_Shape axis = OccTriangulator.makeCylinder(new double[]{-ld2+l1,h+h2,0.0}, dir, r2, l2b);
41 TopoDS_Shape motor = OccTriangulator.makeCylinder(new double[]{-ld2+l1+l2,h+h2,0.0}, dir, r3, l3);
42 TopoDS_Shape motorBox = OccTriangulator.makeBox(-ld2+l1+l2, h2, -r3, ld2, h2+h-r3, r3);
44 TopoDS_Shape shape = OccTriangulator.makeCompound(new TopoDS_Shape[]{foundation,rotator,axis,motor,motorBox});
50 return Collections.singletonList(shape);
54 public void setProperties(Map<String, Object> props) {
55 if (props.containsKey("length"))
56 length = (Double)props.get("length");
57 if (props.containsKey("width")) {
58 width = (Double)props.get("width");