1 package org.jcae.opencascade.jni;
3 import static org.junit.Assert.*;
7 * Example of BRepGProp and BRepBndLib
8 * @author Jerome Robert
10 public class Dimensions
12 @Test public void torus()
14 // Create a shape for the example (a torus)
15 double[] axis=new double[]{
20 TopoDS_Shape torus=new BRepPrimAPI_MakeTorus(axis, R, r).shape();
22 // Compute the bounding box of the shape
23 Bnd_Box bbox = new Bnd_Box();
24 BRepBndLib.add(torus, bbox);
25 double[] bboxValues = bbox.get();
27 // Display the bounding box
28 System.out.println("Xmin="+bboxValues[0]);
29 System.out.println("Ymin="+bboxValues[1]);
30 System.out.println("Zmin="+bboxValues[2]);
31 System.out.println("Xmax="+bboxValues[3]);
32 System.out.println("Ymax="+bboxValues[4]);
33 System.out.println("Zmax="+bboxValues[5]);
35 // Display various other properties
36 GProp_GProps property=new GProp_GProps();
37 BRepGProp.linearProperties(torus, property);
38 System.out.println("length="+property.mass());
39 assertEquals(property.mass(), 4.0*Math.PI*(R+2.0*r), 1.e-6);
41 // If Eps is argument is absent, precision is quite poor
42 BRepGProp.surfaceProperties(torus, property, 1.e-2);
43 System.out.println("surface="+property.mass());
44 assertEquals(property.mass(), 4.0*Math.PI*Math.PI*R*r, 1.e-6);
46 BRepGProp.volumeProperties(torus, property);
47 System.out.println("volume="+property.mass());
48 assertEquals(property.mass(), 2.0*Math.PI*Math.PI*R*r*r, 1.e-6);