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 NozzleGeometryProvider extends BuiltinGeometryProvider { public NozzleGeometryProvider(Resource resource) { super(resource); } private double length = 0.1; private double radius = 0.01; @Override public Collection getModel() throws Exception { if (radius < MathTools.NEAR_ZERO || length < MathTools.NEAR_ZERO) return Collections.emptyList(); TopoDS_Shape shape = OccTriangulator.makeCylinder(new double[] {-length, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, length); 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); TopoDS_Shape shape3 = OccTriangulator.makeCompound(new TopoDS_Shape[]{shape,shape2}); shape.delete(); shape2.delete(); return Collections.singletonList(shape3); } @Override public void setProperties(Map props) { if (props.containsKey("length")) length = (Double)props.get("length"); if (props.containsKey("radius")) { radius = (Double)props.get("radius"); } } }