]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java
3D framework (Simca 2012)
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / TorusNode.java
diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java
new file mode 100644 (file)
index 0000000..a76a504
--- /dev/null
@@ -0,0 +1,50 @@
+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.Torus)\r
+public class TorusNode extends CSGnode {\r
+\r
+       private double r1 = 1.0;\r
+       private double r2 = 1.0;\r
+       \r
+       \r
+       @RelatedSetValue(CSG.URIs.HasMinorRadius)\r
+       @SetPropertyValue(CSG.URIs.HasMinorRadius)\r
+       public void setR1(double r1) {\r
+               this.r1 = r1;\r
+               firePropertyChanged(CSG.URIs.HasMinorRadius);\r
+       }\r
+       \r
+       @RelatedSetValue(CSG.URIs.HasMajorRadius)\r
+       @SetPropertyValue(CSG.URIs.HasMajorRadius)\r
+       public void setR2(double r2) {\r
+               this.r2 = r2;\r
+               firePropertyChanged(CSG.URIs.HasMajorRadius);\r
+       }\r
+       \r
+       @RelatedGetValue(CSG.URIs.HasMinorRadius)\r
+       @GetPropertyValue(value=CSG.URIs.HasMinorRadius, name="Minor Radius")\r
+       public double getR1() {\r
+               return r1;\r
+       }\r
+       \r
+       @RelatedGetValue(CSG.URIs.HasMajorRadius)\r
+       @GetPropertyValue(value=CSG.URIs.HasMajorRadius, name="Major Radius")   \r
+       public double getR2() {\r
+               return r2;\r
+       }\r
+       \r
+       @Override\r
+       public TopoDS_Shape getBaseGeometry() {\r
+               return OccTriangulator.makeTorus(new double[] { 0.0, 0.0, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r2, r1);\r
+       }\r
+\r
+}\r