]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CylinderNode.java
Copyrights
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / CylinderNode.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g3d.csg.scenegraph2;\r
13 \r
14 import org.jcae.opencascade.jni.TopoDS_Shape;\r
15 import org.simantics.g3d.csg.ontology.CSG;\r
16 import org.simantics.g3d.property.annotations.GetPropertyValue;\r
17 import org.simantics.g3d.property.annotations.SetPropertyValue;\r
18 import org.simantics.objmap.graph.annotations.GraphType;\r
19 import org.simantics.objmap.graph.annotations.RelatedGetValue;\r
20 import org.simantics.objmap.graph.annotations.RelatedSetValue;\r
21 import org.simantics.opencascade.OccTriangulator;\r
22 \r
23 @GraphType(CSG.URIs.Cylinder)\r
24 public class CylinderNode extends CSGnode {\r
25 \r
26         private double r = 1.0;\r
27         private double h = 1.0;\r
28         \r
29         @RelatedSetValue(CSG.URIs.HasRadius)\r
30         @SetPropertyValue(CSG.URIs.HasRadius)\r
31         public void setR(double r) {\r
32                 this.r = r;\r
33                 firePropertyChanged(CSG.URIs.HasRadius);\r
34         }\r
35 \r
36         @RelatedSetValue(CSG.URIs.HasHeight)\r
37         @SetPropertyValue(CSG.URIs.HasHeight)\r
38         public void setH(double h) {\r
39                 this.h = h;\r
40                 firePropertyChanged(CSG.URIs.HasHeight);\r
41         }\r
42         \r
43         @RelatedGetValue(CSG.URIs.HasHeight)\r
44         @GetPropertyValue(value=CSG.URIs.HasHeight, name = "Height")\r
45         public double getH() {\r
46                 return h;\r
47         }\r
48         \r
49         @RelatedGetValue(CSG.URIs.HasRadius)\r
50         @GetPropertyValue(value=CSG.URIs.HasRadius, name = "Radius")\r
51         public double getR() {\r
52                 return r;\r
53         }\r
54         \r
55         @Override\r
56         public TopoDS_Shape getBaseGeometry() {\r
57                 return OccTriangulator.makeCylinder(new double[] { 0.0, -h * 0.5, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r, h);\r
58         }\r
59 \r
60 }\r