package org.simantics.g3d.csg.scenegraph2; import org.jcae.opencascade.jni.TopoDS_Shape; import org.simantics.g3d.csg.ontology.CSG; import org.simantics.g3d.property.annotations.GetPropertyValue; import org.simantics.g3d.property.annotations.SetPropertyValue; import org.simantics.objmap.graph.annotations.GraphType; import org.simantics.objmap.graph.annotations.RelatedGetValue; import org.simantics.objmap.graph.annotations.RelatedSetValue; import org.simantics.opencascade.OccTriangulator; @GraphType(CSG.URIs.Cone) public class ConeNode extends CSGnode { private double r1 = 1.0; private double r2 = 0.5; private double h = 1.0; @RelatedSetValue(CSG.URIs.HasBottomRadius) @SetPropertyValue(CSG.URIs.HasBottomRadius) public void setR1(double r1) { this.r1 = r1; firePropertyChanged(CSG.URIs.HasBottomRadius); } @RelatedSetValue(CSG.URIs.HasTopRadius) @SetPropertyValue(CSG.URIs.HasTopRadius) public void setR2(double r2) { this.r2 = r2; firePropertyChanged(CSG.URIs.HasTopRadius); } @RelatedSetValue(CSG.URIs.HasHeight) @SetPropertyValue(CSG.URIs.HasHeight) public void setH(double h) { this.h = h; firePropertyChanged(CSG.URIs.HasHeight); } @RelatedGetValue(CSG.URIs.HasHeight) @GetPropertyValue(value=CSG.URIs.HasHeight, name = "Height") public double getH() { return h; } @RelatedGetValue(CSG.URIs.HasBottomRadius) @GetPropertyValue(value=CSG.URIs.HasBottomRadius, name = "Bottom Radius") public double getR1() { return r1; } @RelatedGetValue(CSG.URIs.HasTopRadius) @GetPropertyValue(value=CSG.URIs.HasTopRadius, name = "Top Radius") public double getR2() { return r2; } @Override public TopoDS_Shape getBaseGeometry() { if (Math.abs(r1-r2) > MIN_VALUE) { // if (r1 < MIN_VALUE) // return null; return OccTriangulator.makeCone(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1,r2, h); } else return OccTriangulator.makeCylinder(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1, h); } }