]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SphereNode.java
3D framework (Simca 2012)
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / SphereNode.java
diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SphereNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SphereNode.java
new file mode 100644 (file)
index 0000000..a2cc658
--- /dev/null
@@ -0,0 +1,35 @@
+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.Sphere)\r
+public class SphereNode extends CSGnode {\r
+\r
+       private double r = 1.0;\r
+       \r
+       @RelatedSetValue(CSG.URIs.HasRadius)\r
+       @SetPropertyValue(CSG.URIs.HasRadius)\r
+       public void setR(double r) {\r
+               this.r = r;\r
+               firePropertyChanged(CSG.URIs.HasRadius);\r
+       }\r
+       \r
+       @RelatedGetValue(CSG.URIs.HasRadius)\r
+       @GetPropertyValue(value=CSG.URIs.HasRadius, name="Radius")\r
+       public double getR() {\r
+               return r;\r
+       }\r
+       \r
+       @Override\r
+       public TopoDS_Shape getBaseGeometry() {\r
+               return OccTriangulator.makeSphere(0, 0, 0, r);\r
+       }\r
+\r
+}\r