]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java
3D framework (Simca 2012)
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / ConeNode.java
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 (file)
index 0000000..e392be6
--- /dev/null
@@ -0,0 +1,70 @@
+package org.simantics.g3d.csg.scenegraph2;\r
+\r
+import org.jcae.opencascade.jni.TopoDS_Shape;\r
+import org.simantics.g3d.csg.ontology.CSG;\r
+import org.simantics.g3d.property.annotations.GetPropertyValue;\r
+import org.simantics.g3d.property.annotations.SetPropertyValue;\r
+import org.simantics.objmap.graph.annotations.GraphType;\r
+import org.simantics.objmap.graph.annotations.RelatedGetValue;\r
+import org.simantics.objmap.graph.annotations.RelatedSetValue;\r
+import org.simantics.opencascade.OccTriangulator;\r
+\r
+@GraphType(CSG.URIs.Cone)\r
+public class ConeNode extends CSGnode {\r
+\r
+       private double r1 = 1.0;\r
+       private double r2 = 0.5;\r
+       private double h = 1.0;\r
+       \r
+       \r
+       @RelatedSetValue(CSG.URIs.HasBottomRadius)\r
+       @SetPropertyValue(CSG.URIs.HasBottomRadius)\r
+       public void setR1(double r1) {\r
+               this.r1 = r1;\r
+               firePropertyChanged(CSG.URIs.HasBottomRadius);\r
+       }\r
+       \r
+       @RelatedSetValue(CSG.URIs.HasTopRadius)\r
+       @SetPropertyValue(CSG.URIs.HasTopRadius)\r
+       public void setR2(double r2) {\r
+               this.r2 = r2;\r
+               firePropertyChanged(CSG.URIs.HasTopRadius);\r
+       }\r
+       \r
+       @RelatedSetValue(CSG.URIs.HasHeight)\r
+       @SetPropertyValue(CSG.URIs.HasHeight)\r
+       public void setH(double h) {\r
+               this.h = h;\r
+               firePropertyChanged(CSG.URIs.HasHeight);\r
+       }\r
+       \r
+       @RelatedGetValue(CSG.URIs.HasHeight)\r
+       @GetPropertyValue(value=CSG.URIs.HasHeight, name = "Height")\r
+       public double getH() {\r
+               return h;\r
+       }\r
+       \r
+       @RelatedGetValue(CSG.URIs.HasBottomRadius)\r
+       @GetPropertyValue(value=CSG.URIs.HasBottomRadius, name = "Bottom Radius")\r
+       public double getR1() {\r
+               return r1;\r
+       }\r
+       \r
+       @RelatedGetValue(CSG.URIs.HasTopRadius)\r
+       @GetPropertyValue(value=CSG.URIs.HasTopRadius, name = "Top Radius")\r
+       public double getR2() {\r
+               return r2;\r
+       }\r
+       \r
+       @Override\r
+       public TopoDS_Shape getBaseGeometry() {\r
+               if (Math.abs(r1-r2) > MIN_VALUE) {\r
+//                     if (r1 < MIN_VALUE)\r
+//                             return null;\r
+                       return OccTriangulator.makeCone(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1,r2, h);\r
+               } else\r
+                       return OccTriangulator.makeCylinder(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1, h);\r
+       }\r
+\r
+\r
+}\r