1 package org.simantics.g3d.csg.scenegraph2;
\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
12 @GraphType(CSG.URIs.Cone)
\r
13 public class ConeNode extends CSGnode {
\r
15 private double r1 = 1.0;
\r
16 private double r2 = 0.5;
\r
17 private double h = 1.0;
\r
20 @RelatedSetValue(CSG.URIs.HasBottomRadius)
\r
21 @SetPropertyValue(CSG.URIs.HasBottomRadius)
\r
22 public void setR1(double r1) {
\r
24 firePropertyChanged(CSG.URIs.HasBottomRadius);
\r
27 @RelatedSetValue(CSG.URIs.HasTopRadius)
\r
28 @SetPropertyValue(CSG.URIs.HasTopRadius)
\r
29 public void setR2(double r2) {
\r
31 firePropertyChanged(CSG.URIs.HasTopRadius);
\r
34 @RelatedSetValue(CSG.URIs.HasHeight)
\r
35 @SetPropertyValue(CSG.URIs.HasHeight)
\r
36 public void setH(double h) {
\r
38 firePropertyChanged(CSG.URIs.HasHeight);
\r
41 @RelatedGetValue(CSG.URIs.HasHeight)
\r
42 @GetPropertyValue(value=CSG.URIs.HasHeight, name = "Height")
\r
43 public double getH() {
\r
47 @RelatedGetValue(CSG.URIs.HasBottomRadius)
\r
48 @GetPropertyValue(value=CSG.URIs.HasBottomRadius, name = "Bottom Radius")
\r
49 public double getR1() {
\r
53 @RelatedGetValue(CSG.URIs.HasTopRadius)
\r
54 @GetPropertyValue(value=CSG.URIs.HasTopRadius, name = "Top Radius")
\r
55 public double getR2() {
\r
60 public TopoDS_Shape getBaseGeometry() {
\r
61 if (Math.abs(r1-r2) > MIN_VALUE) {
\r
62 // if (r1 < MIN_VALUE)
\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
66 return OccTriangulator.makeCylinder(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r1, h);
\r