X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fgeometry%2FCheckValveGeometryProvider.java;fp=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fgeometry%2FCheckValveGeometryProvider.java;h=85f4c7aa01146a44781bc2c9b81560eb0bda88b1;hb=a460e609147d064dd3da464bcf1626845e0f93b4;hp=0000000000000000000000000000000000000000;hpb=3e2205a22ddee674f7936da114f5d520bd83e0ff;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/geometry/CheckValveGeometryProvider.java b/org.simantics.plant3d/src/org/simantics/plant3d/geometry/CheckValveGeometryProvider.java new file mode 100644 index 00000000..85f4c7aa --- /dev/null +++ b/org.simantics.plant3d/src/org/simantics/plant3d/geometry/CheckValveGeometryProvider.java @@ -0,0 +1,47 @@ +package org.simantics.plant3d.geometry; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import org.jcae.opencascade.jni.TopoDS_Shape; +import org.simantics.db.Resource; +import org.simantics.g3d.math.MathTools; +import org.simantics.opencascade.OccTriangulator; + +public class CheckValveGeometryProvider extends BuiltinGeometryProvider { + + public CheckValveGeometryProvider(Resource resource) { + super(resource); + } + + private double radius = 0.01; + + @Override + public Collection getModel() throws Exception { + double l = radius*0.2; + TopoDS_Shape cyl = OccTriangulator.makeCylinder(new double[] {-radius, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, l); + TopoDS_Shape con = OccTriangulator.makeCone(new double[] {-radius, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius*0.1, radius,radius*2); + TopoDS_Shape shape = OccTriangulator.makeFuse(cyl, con); + cyl.delete(); + con.delete(); + return Collections.singletonList(shape); + } + + @Override + public void setProperties(Map props) { + if (props.containsKey("radius")) { + radius = (Double)props.get("radius"); + } + if (radius < MathTools.NEAR_ZERO) + radius = MathTools.NEAR_ZERO; + + } + + @Override + public void updateCalculatedProperties(Map returnProps) { + returnProps.put("length", radius*2); + + } + +}