]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CylinderNode.java
3D framework (Simca 2012)
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / CylinderNode.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.Cylinder)\r
13 public class CylinderNode extends CSGnode {\r
14 \r
15         private double r = 1.0;\r
16         private double h = 1.0;\r
17         \r
18         @RelatedSetValue(CSG.URIs.HasRadius)\r
19         @SetPropertyValue(CSG.URIs.HasRadius)\r
20         public void setR(double r) {\r
21                 this.r = r;\r
22                 firePropertyChanged(CSG.URIs.HasRadius);\r
23         }\r
24 \r
25         @RelatedSetValue(CSG.URIs.HasHeight)\r
26         @SetPropertyValue(CSG.URIs.HasHeight)\r
27         public void setH(double h) {\r
28                 this.h = h;\r
29                 firePropertyChanged(CSG.URIs.HasHeight);\r
30         }\r
31         \r
32         @RelatedGetValue(CSG.URIs.HasHeight)\r
33         @GetPropertyValue(value=CSG.URIs.HasHeight, name = "Height")\r
34         public double getH() {\r
35                 return h;\r
36         }\r
37         \r
38         @RelatedGetValue(CSG.URIs.HasRadius)\r
39         @GetPropertyValue(value=CSG.URIs.HasRadius, name = "Radius")\r
40         public double getR() {\r
41                 return r;\r
42         }\r
43         \r
44         @Override\r
45         public TopoDS_Shape getBaseGeometry() {\r
46                 return OccTriangulator.makeCylinder(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r, h);\r
47         }\r
48 \r
49 }\r