1 package org.jcae.opencascade.jni;
3 import static org.junit.Assert.*;
8 /** Example to show how to get the curvature of a surface */
9 @Test public void sample()
11 //Create an cone for the example
12 double[] axis=new double[]{
16 TopoDS_Shape shape=new BRepPrimAPI_MakeCone(
17 axis, 3, 1, 4, Math.PI*2).shape();
19 // Select the side of the cone
20 TopExp_Explorer exp=new TopExp_Explorer(shape, TopAbs_ShapeEnum.FACE);
21 TopoDS_Face face=(TopoDS_Face) exp.current();
23 // Get the geometry associated to the previously selected face
24 Geom_Surface geom = BRep_Tool.surface(face);
26 // Get parameters intervals
27 double[] paramBounds=new double[4];
28 geom.bounds(paramBounds);
29 double umin=paramBounds[0];
30 double umax=paramBounds[1];
31 double vmin=paramBounds[2];
32 double vmax=paramBounds[3];
34 // Handle the case of infinite geometry
47 // Create the object which allow to ask for various local geometry
49 GeomLProp_SLProps props=new GeomLProp_SLProps(2, 1E-7);
50 props.setSurface(geom);
53 // Iterate on u and v and display various properties at each point
54 double ustep=(umax-umin)/10;
55 double vstep=(vmax-vmin)/10;
57 for(double u=umin; u<umax; u+=ustep)
59 for(double v=vmin; v<vmax; v+=vstep)
61 props.setParameters(u, v);
62 //The 3D coordinate associated to the u,v coordinate
63 double[] p = props.value();
64 //The first derivative allong U
65 double[] d1u = props.d1U();
66 //The second derivative allong U
67 double[] d2u = props.d2U();
69 System.out.println("M: ("+p[0]+", "+p[1]+", "+p[2]+")");
70 System.out.println("dM/dU: ("+d1u[0]+", "+d1u[1]+", "+d1u[2]+")");
71 System.out.println("d2M/d2U: ("+d2u[0]+", "+d2u[1]+", "+d2u[2]+")");