]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java
6f959d31d0eb9d15100271d0ee4bf379432cba65
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / RegularPrismNode.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.RegularPrism)\r
24 public class RegularPrismNode extends CSGnode {\r
25 \r
26         private double r = 1.0;\r
27         private double h = 1.0;\r
28         private int n = 3;\r
29         \r
30         @RelatedSetValue(CSG.URIs.HasRadius)\r
31         @SetPropertyValue(CSG.URIs.HasRadius)\r
32         public void setR(double r) {\r
33                 this.r = r;\r
34                 firePropertyChanged(CSG.URIs.HasRadius);\r
35         }\r
36 \r
37         \r
38         @RelatedSetValue(CSG.URIs.HasHeight)\r
39         @SetPropertyValue(CSG.URIs.HasHeight)\r
40         public void setH(double h) {\r
41                 this.h = h;\r
42                 firePropertyChanged(CSG.URIs.HasHeight);\r
43         }\r
44         \r
45         @RelatedSetValue(CSG.URIs.HasCorners)\r
46         @SetPropertyValue(CSG.URIs.HasCorners)\r
47         public void setN(int n) {\r
48                 if (n < 3)\r
49                         n = 3;\r
50                 this.n = n;\r
51                 firePropertyChanged(CSG.URIs.HasCorners);\r
52         }\r
53         \r
54         @RelatedGetValue(CSG.URIs.HasHeight)\r
55         @GetPropertyValue(value=CSG.URIs.HasHeight, name="Height")\r
56         public double getH() {\r
57                 return h;\r
58         }\r
59         \r
60         @RelatedGetValue(CSG.URIs.HasCorners)\r
61         @GetPropertyValue(value=CSG.URIs.HasCorners, name="Corners")\r
62         public int getN() {\r
63                 return n;\r
64         }\r
65         \r
66         @RelatedGetValue(CSG.URIs.HasRadius)\r
67         @GetPropertyValue(value=CSG.URIs.HasRadius, name="Radius")\r
68         public double getR() {\r
69                 return r;\r
70         }\r
71         \r
72         @Override\r
73         public TopoDS_Shape getBaseGeometry() {\r
74                 return OccTriangulator.makeReqularPrism(h, r, n);\r
75         }\r
76 \r
77 \r
78 }\r