X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.g3d.csg%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fcsg%2Fscenegraph2%2FConeNode.java;fp=org.simantics.g3d.csg%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fcsg%2Fscenegraph2%2FConeNode.java;h=e392be6d053524f62820f2bebef84a3aa4972e68;hb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;hp=0000000000000000000000000000000000000000;hpb=1f0bcd66274375f2278d2e6c486cb28257a5f7b2;p=simantics%2F3d.git diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java new file mode 100644 index 00000000..e392be6d --- /dev/null +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java @@ -0,0 +1,70 @@ +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); + } + + +}