]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.plant3d/src/org/simantics/plant3d/geometry/PumpGeometryProvider.java
Support for fillets and chamfers
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / geometry / PumpGeometryProvider.java
1 package org.simantics.plant3d.geometry;
2
3 import java.util.Collection;
4 import java.util.Collections;
5 import java.util.Map;
6
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;
19
20 public class PumpGeometryProvider extends BuiltinGeometryProvider  {
21         
22         public PumpGeometryProvider(Resource resource) {
23                 super(resource);
24         }
25
26         private double length = 0.5;
27         private double width = 0.25;
28         
29         @Override
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;
35                 
36                 double r1 = width * 0.5;
37                 double r2 = r1 *0.2;
38                 double r3 = r1 *0.5;
39                 
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;
44                 
45                 double dir[] = new double[]{1.0,0.0,0.0};
46                 
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);
52                 
53                 TopoDS_Shape shape = OccTriangulator.makeCompound(new TopoDS_Shape[]{foundation,rotator,axis,motor,motorBox});
54                 foundation.delete();
55                 rotator.delete();
56                 axis.delete();
57                 motor.delete();
58                 motorBox.delete();
59                 return Collections.singletonList(shape);
60         }
61         
62         @Override
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");
68                 }
69                 
70         }
71
72 }