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 NozzleGeometryProvider extends BuiltinGeometryProvider {
14 public NozzleGeometryProvider(Resource resource) {
18 private double length = 0.1;
19 private double radius = 0.01;
22 public Collection<TopoDS_Shape> getModel() throws Exception {
23 if (radius < MathTools.NEAR_ZERO || length < MathTools.NEAR_ZERO)
24 return Collections.emptyList();
25 TopoDS_Shape shape = OccTriangulator.makeCylinder(new double[] {-length, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, length);
26 TopoDS_Shape shape2 = OccTriangulator.makeCylinder(new double[] {-length*0.25, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius*1.2, length*0.25);
27 TopoDS_Shape shape3 = OccTriangulator.makeCompound(new TopoDS_Shape[]{shape,shape2});
30 return Collections.singletonList(shape3);
34 public void setProperties(Map<String, Object> props) {
35 if (props.containsKey("length"))
36 length = (Double)props.get("length");
37 if (props.containsKey("radius")) {
38 radius = (Double)props.get("radius");