]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BoxNode.java
Copyrights
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / BoxNode.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.Box)\r
24 public class BoxNode extends CSGnode {\r
25 \r
26         private double sx = 1.0;\r
27         private double sy = 1.0;\r
28         private double sz = 1.0;\r
29         \r
30         public BoxNode() {\r
31                 System.out.println();\r
32         }\r
33         \r
34         @RelatedSetValue(CSG.URIs.HasXAxisSize)\r
35         @SetPropertyValue(CSG.URIs.HasXAxisSize)\r
36         public void setSX(double d) {\r
37                 this.sx = d;\r
38                 firePropertyChanged(CSG.URIs.HasXAxisSize);\r
39         }\r
40         \r
41         @RelatedSetValue(CSG.URIs.HasYAxisSize)\r
42         @SetPropertyValue(CSG.URIs.HasYAxisSize)\r
43         public void setSY(double d) {\r
44                 this.sy = d;\r
45                 firePropertyChanged(CSG.URIs.HasYAxisSize);\r
46         }\r
47         \r
48         @RelatedSetValue(CSG.URIs.HasZAxisSize)\r
49         @SetPropertyValue(CSG.URIs.HasZAxisSize)\r
50         public void setSZ(double d) {\r
51                 this.sz = d;\r
52                 firePropertyChanged(CSG.URIs.HasZAxisSize);\r
53         }\r
54         \r
55         @RelatedGetValue(CSG.URIs.HasXAxisSize)\r
56         @GetPropertyValue(value=CSG.URIs.HasXAxisSize, name = "X Size")\r
57         public double getSx() {\r
58                 return sx;\r
59         }\r
60         \r
61         @RelatedGetValue(CSG.URIs.HasYAxisSize)\r
62         @GetPropertyValue(value=CSG.URIs.HasYAxisSize, name = "Y Size")\r
63         public double getSy() {\r
64                 return sy;\r
65         }\r
66         \r
67         @RelatedGetValue(CSG.URIs.HasZAxisSize)\r
68         @GetPropertyValue(value=CSG.URIs.HasZAxisSize, name = "Z Size")\r
69         public double getSz() {\r
70                 return sz;\r
71         }\r
72         \r
73         \r
74         @Override\r
75         public TopoDS_Shape getBaseGeometry() {\r
76                 return OccTriangulator.makeBox(-sx * 0.5, -sy * 0.5, -sz * 0.5, sx * 0.5, sy * 0.5, sz * 0.5);\r
77         }\r
78 \r
79 \r
80 }\r