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 GateValveGeometryProvider extends BuiltinGeometryProvider {
14 public GateValveGeometryProvider(Resource resource) {
18 private double radius = 0.01;
21 public Collection<TopoDS_Shape> getModel() throws Exception {
22 if (radius < MathTools.NEAR_ZERO)
23 return Collections.emptyList();
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);
25 TopoDS_Shape con2 = OccTriangulator.makeCone(new double[] {radius, 0.0, 0.0}, new double[] { -1.0, 0.0, 0.0 }, radius, radius*0.1,radius);
26 //TopoDS_Shape sph = OccTriangulator.makeSphere(0, 0, 0, radius*0.75);
27 //TopoDS_Shape cyl = OccTriangulator.makeCylinder(new double[] {0.0, 0.0, 0.0}, new double[] { 0.0, 1.0, 0.0 }, radius*0.75, radius*2);
28 TopoDS_Shape cyl = OccTriangulator.makeFillet(OccTriangulator.makeBox(-radius*0.5, -radius*0.5, -radius*0.75, radius*0.5, radius*1.25, radius*0.75), radius*0.25);
29 //TopoDS_Shape cyl = OccTriangulator.makeChamfer(OccTriangulator.makeBox(-radius*0.5, -radius*0.5, -radius*0.75, radius*0.5, radius*1.25, radius*0.75), radius*0.25);
30 TopoDS_Shape cyl2 = OccTriangulator.makeCylinder(new double[] {0.0, 0.0, 0.0}, new double[] { 0.0, 1.0, 0.0 }, radius*0.125, radius*2);
31 TopoDS_Shape tor = OccTriangulator.makeTorus(new double[] { 0.0, radius*2, 0.0}, new double[] { 0.0, 1.0, 0.0 }, radius*0.5, radius*0.125);
33 TopoDS_Shape shape = OccTriangulator.makeCompound(new TopoDS_Shape[] {con,con2,cyl,cyl2,tor});
39 return Collections.singletonList(shape);
43 public void setProperties(Map<String, Object> props) {
44 if (props.containsKey("radius")) {
45 radius = (Double)props.get("radius");
47 if (radius < MathTools.NEAR_ZERO)
48 radius = MathTools.NEAR_ZERO;
53 public void updateCalculatedProperties(Map<String, Object> returnProps) {
54 returnProps.put("length", radius*2);