]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java
a76a504515248201c0eba8f563eb8b7cf7a7957c
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / TorusNode.java
1 package org.simantics.g3d.csg.scenegraph2;\r
2 \r
3 import org.jcae.opencascade.jni.TopoDS_Shape;\r
4 import org.simantics.g3d.csg.ontology.CSG;\r
5 import org.simantics.g3d.property.annotations.GetPropertyValue;\r
6 import org.simantics.g3d.property.annotations.SetPropertyValue;\r
7 import org.simantics.objmap.graph.annotations.GraphType;\r
8 import org.simantics.objmap.graph.annotations.RelatedGetValue;\r
9 import org.simantics.objmap.graph.annotations.RelatedSetValue;\r
10 import org.simantics.opencascade.OccTriangulator;\r
11 \r
12 @GraphType(CSG.URIs.Torus)\r
13 public class TorusNode extends CSGnode {\r
14 \r
15         private double r1 = 1.0;\r
16         private double r2 = 1.0;\r
17         \r
18         \r
19         @RelatedSetValue(CSG.URIs.HasMinorRadius)\r
20         @SetPropertyValue(CSG.URIs.HasMinorRadius)\r
21         public void setR1(double r1) {\r
22                 this.r1 = r1;\r
23                 firePropertyChanged(CSG.URIs.HasMinorRadius);\r
24         }\r
25         \r
26         @RelatedSetValue(CSG.URIs.HasMajorRadius)\r
27         @SetPropertyValue(CSG.URIs.HasMajorRadius)\r
28         public void setR2(double r2) {\r
29                 this.r2 = r2;\r
30                 firePropertyChanged(CSG.URIs.HasMajorRadius);\r
31         }\r
32         \r
33         @RelatedGetValue(CSG.URIs.HasMinorRadius)\r
34         @GetPropertyValue(value=CSG.URIs.HasMinorRadius, name="Minor Radius")\r
35         public double getR1() {\r
36                 return r1;\r
37         }\r
38         \r
39         @RelatedGetValue(CSG.URIs.HasMajorRadius)\r
40         @GetPropertyValue(value=CSG.URIs.HasMajorRadius, name="Major Radius")   \r
41         public double getR2() {\r
42                 return r2;\r
43         }\r
44         \r
45         @Override\r
46         public TopoDS_Shape getBaseGeometry() {\r
47                 return OccTriangulator.makeTorus(new double[] { 0.0, 0.0, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r2, r1);\r
48         }\r
49 \r
50 }\r