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 ReducerGeometryProvider extends BuiltinGeometryProvider {
14 public ReducerGeometryProvider(Resource resource) {
18 private double radius = 0.01;
19 private double radius2 = 0.02;
22 public Collection<TopoDS_Shape> getModel() throws Exception {
23 // GP_Circ circ = new GP_Circ(new double[]{-length*0.5, 0.0, 0.0,1.0,0.0,0.0}, radius);
24 // GP_Circ circ2 = new GP_Circ(new double[]{length*0.5, 0.0, 0.0,1.0,0.0,0.0}, radius2);
25 // System.out.println("Reducer " + length + " " + radius + " " + radius2);
26 double length = Math.max(0.1, Math.abs(radius-radius2)*4.0);
28 if (Math.abs(radius-radius2) < MathTools.NEAR_ZERO) {
29 shape = OccTriangulator.makeCylinder(new double[] {-length*0.5, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, length);
31 shape = OccTriangulator.makeCone(new double[] {-length*0.5, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius,radius2, length);
33 return Collections.singletonList(shape);
37 public void setProperties(Map<String, Object> props) {
40 if (props.containsKey("radius")) {
41 radius = (Double)props.get("radius");
43 if (props.containsKey("radius2")) {
44 radius2 = (Double)props.get("radius2");
52 public void updateCalculatedProperties(Map<String, Object> returnProps) {
53 returnProps.put("length", Math.max(0.1, Math.abs(radius-radius2)*4.0));