/******************************************************************************* * Copyright (c) 2012, 2013 Association for Decentralized Information Management in * Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ 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.Torus) public class TorusNode extends CSGnode { private double r1 = 1.0; private double r2 = 1.0; @RelatedSetValue(CSG.URIs.HasMinorRadius) @SetPropertyValue(CSG.URIs.HasMinorRadius) public void setR1(double r1) { this.r1 = r1; firePropertyChanged(CSG.URIs.HasMinorRadius); } @RelatedSetValue(CSG.URIs.HasMajorRadius) @SetPropertyValue(CSG.URIs.HasMajorRadius) public void setR2(double r2) { this.r2 = r2; firePropertyChanged(CSG.URIs.HasMajorRadius); } @RelatedGetValue(CSG.URIs.HasMinorRadius) @GetPropertyValue(value=CSG.URIs.HasMinorRadius, name="Minor Radius") public double getR1() { return r1; } @RelatedGetValue(CSG.URIs.HasMajorRadius) @GetPropertyValue(value=CSG.URIs.HasMajorRadius, name="Major Radius") public double getR2() { return r2; } @Override public TopoDS_Shape getBaseGeometry() { return OccTriangulator.makeTorus(new double[] { 0.0, 0.0, 0.0 }, new double[] { 0.0, 1.0, 0.0 }, r2, r1); } }