]> gerrit.simantics Code Review - simantics/3d.git/blob - 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
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.Cone)\r
13 public class ConeNode extends CSGnode {\r
14 \r
15         private double r1 = 1.0;\r
16         private double r2 = 0.5;\r
17         private double h = 1.0;\r
18         \r
19         \r
20         @RelatedSetValue(CSG.URIs.HasBottomRadius)\r
21         @SetPropertyValue(CSG.URIs.HasBottomRadius)\r
22         public void setR1(double r1) {\r
23                 this.r1 = r1;\r
24                 firePropertyChanged(CSG.URIs.HasBottomRadius);\r
25         }\r
26         \r
27         @RelatedSetValue(CSG.URIs.HasTopRadius)\r
28         @SetPropertyValue(CSG.URIs.HasTopRadius)\r
29         public void setR2(double r2) {\r
30                 this.r2 = r2;\r
31                 firePropertyChanged(CSG.URIs.HasTopRadius);\r
32         }\r
33         \r
34         @RelatedSetValue(CSG.URIs.HasHeight)\r
35         @SetPropertyValue(CSG.URIs.HasHeight)\r
36         public void setH(double h) {\r
37                 this.h = h;\r
38                 firePropertyChanged(CSG.URIs.HasHeight);\r
39         }\r
40         \r
41         @RelatedGetValue(CSG.URIs.HasHeight)\r
42         @GetPropertyValue(value=CSG.URIs.HasHeight, name = "Height")\r
43         public double getH() {\r
44                 return h;\r
45         }\r
46         \r
47         @RelatedGetValue(CSG.URIs.HasBottomRadius)\r
48         @GetPropertyValue(value=CSG.URIs.HasBottomRadius, name = "Bottom Radius")\r
49         public double getR1() {\r
50                 return r1;\r
51         }\r
52         \r
53         @RelatedGetValue(CSG.URIs.HasTopRadius)\r
54         @GetPropertyValue(value=CSG.URIs.HasTopRadius, name = "Top Radius")\r
55         public double getR2() {\r
56                 return r2;\r
57         }\r
58         \r
59         @Override\r
60         public TopoDS_Shape getBaseGeometry() {\r
61                 if (Math.abs(r1-r2) > MIN_VALUE) {\r
62 //                      if (r1 < MIN_VALUE)\r
63 //                              return null;\r
64                         return OccTriangulator.makeCone(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1,r2, h);\r
65                 } else\r
66                         return OccTriangulator.makeCylinder(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1, h);\r
67         }\r
68 \r
69 \r
70 }\r