X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.csg%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fcsg%2Fscenegraph2%2FRegularPrismNode.java;fp=org.simantics.g3d.csg%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fcsg%2Fscenegraph2%2FRegularPrismNode.java;h=ebb9345dd70e4a511397e61a8aa797c5748c8206;hb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;hp=0000000000000000000000000000000000000000;hpb=1f0bcd66274375f2278d2e6c486cb28257a5f7b2;p=simantics%2F3d.git diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java new file mode 100644 index 00000000..ebb9345d --- /dev/null +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java @@ -0,0 +1,67 @@ +package org.simantics.g3d.csg.scenegraph2; + +import org.jcae.opencascade.jni.TopoDS_Shape; +import org.simantics.g3d.csg.ontology.CSG; +import org.simantics.g3d.property.annotations.GetPropertyValue; +import org.simantics.g3d.property.annotations.SetPropertyValue; +import org.simantics.objmap.graph.annotations.GraphType; +import org.simantics.objmap.graph.annotations.RelatedGetValue; +import org.simantics.objmap.graph.annotations.RelatedSetValue; +import org.simantics.opencascade.OccTriangulator; + +@GraphType(CSG.URIs.RegularPrism) +public class RegularPrismNode extends CSGnode { + + private double r = 1.0; + private double h = 1.0; + private int n = 3; + + @RelatedSetValue(CSG.URIs.HasRadius) + @SetPropertyValue(CSG.URIs.HasRadius) + public void setR(double r) { + this.r = r; + firePropertyChanged(CSG.URIs.HasRadius); + } + + + @RelatedSetValue(CSG.URIs.HasHeight) + @SetPropertyValue(CSG.URIs.HasHeight) + public void setH(double h) { + this.h = h; + firePropertyChanged(CSG.URIs.HasHeight); + } + + @RelatedSetValue(CSG.URIs.HasCorners) + @SetPropertyValue(CSG.URIs.HasCorners) + public void setN(int n) { + if (n < 3) + n = 3; + this.n = n; + firePropertyChanged(CSG.URIs.HasCorners); + } + + @RelatedGetValue(CSG.URIs.HasHeight) + @GetPropertyValue(value=CSG.URIs.HasHeight, name="Height") + public double getH() { + return h; + } + + @RelatedGetValue(CSG.URIs.HasCorners) + @GetPropertyValue(value=CSG.URIs.HasCorners, name="Corners") + public int getN() { + return n; + } + + @RelatedGetValue(CSG.URIs.HasRadius) + @GetPropertyValue(value=CSG.URIs.HasRadius, name="Radius") + public double getR() { + return r; + } + + @Override + public TopoDS_Shape getBaseGeometry() { + return OccTriangulator.makeReqularPrism(h, r, n); + } + + +}