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.g3d.math.MathTools;
10 import org.simantics.opencascade.OccTriangulator;
12 public class PumpGeometryProvider extends BuiltinGeometryProvider {
14 public PumpGeometryProvider(Resource resource) {
18 private double length = 0.5;
19 private double width = 0.25;
22 public Collection<TopoDS_Shape> getModel() throws Exception {
23 if (width < MathTools.NEAR_ZERO || length < MathTools.NEAR_ZERO)
24 return Collections.emptyList();
25 double h = width * 0.5;
26 double h2 = width * 0.1;
27 double ld2 = length * 0.5;
28 double wd2 = width * 0.5;
30 double r1 = width * 0.5;
34 double l1 = length * 0.2;
35 double l2 = length * 0.2;
36 double l2b = l2 + length * 0.1;
37 double l3 = length * 0.6;
39 double dir[] = new double[]{1.0,0.0,0.0};
41 TopoDS_Shape foundation = OccTriangulator.makeBox(-ld2, 0.0, -wd2, ld2, h2, wd2);
42 TopoDS_Shape rotator = OccTriangulator.makeCylinder(new double[]{-ld2,h+h2,0.0}, dir, r1, l1);
43 TopoDS_Shape axis = OccTriangulator.makeCylinder(new double[]{-ld2+l1,h+h2,0.0}, dir, r2, l2b);
44 TopoDS_Shape motor = OccTriangulator.makeCylinder(new double[]{-ld2+l1+l2,h+h2,0.0}, dir, r3, l3);
45 TopoDS_Shape motorBox = OccTriangulator.makeBox(-ld2+l1+l2, h2, -r3, ld2, h2+h-r3, r3);
47 TopoDS_Shape shape = OccTriangulator.makeCompound(new TopoDS_Shape[]{foundation,rotator,axis,motor,motorBox});
53 return Collections.singletonList(shape);
57 public void setProperties(Map<String, Object> props) {
58 if (props.containsKey("length"))
59 length = (Double)props.get("length");
60 if (props.containsKey("width")) {
61 width = (Double)props.get("width");