]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.plant3d/src/org/simantics/plant3d/geometry/CheckValveGeometryProvider.java
Changed Check Valve to point flow (pipeline definition) direction
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / geometry / CheckValveGeometryProvider.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.TopoDS_Shape;
8 import org.simantics.db.Resource;
9 import org.simantics.g3d.math.MathTools;
10 import org.simantics.opencascade.OccTriangulator;
11
12 public class CheckValveGeometryProvider extends BuiltinGeometryProvider {
13         
14         public CheckValveGeometryProvider(Resource resource) {
15                 super(resource);
16         }
17
18         private double radius = 0.01;
19         
20         @Override
21         public Collection<TopoDS_Shape> getModel() throws Exception {
22                 double l = radius*0.2;
23                 TopoDS_Shape cyl = OccTriangulator.makeCylinder(new double[] {radius-l, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, l);
24                 TopoDS_Shape con = OccTriangulator.makeCone(new double[] {-radius, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, radius*0.1,radius*2);
25                 TopoDS_Shape shape = OccTriangulator.makeFuse(cyl, con);
26                 cyl.delete();
27                 con.delete();
28                 return Collections.singletonList(shape);
29         }
30         
31         @Override
32         public void setProperties(Map<String, Object> props) {
33                 if (props.containsKey("radius")) {
34                         radius = (Double)props.get("radius");
35                 }
36                 if (radius < MathTools.NEAR_ZERO)
37                         radius = MathTools.NEAR_ZERO;
38                 
39         }
40         
41         @Override
42         public void updateCalculatedProperties(Map<String, Object> returnProps) {
43                 returnProps.put("length", radius*2);
44                 
45         }
46
47 }