1 package org.jcae.opencascade.jni;
3 import static org.junit.Assert.*;
6 import java.util.HashSet;
7 import javax.swing.JFrame;
8 import javax.swing.WindowConstants;
10 /*import org.jcae.viewer3d.View;
11 import org.jcae.viewer3d.cad.ViewableCAD;
12 import org.jcae.viewer3d.cad.occ.OCCProvider;*/
15 * Show how to split faces to make them smaller than a given
16 * area. This is useful with Amibe as the size of the largest
17 * face is the parameter which limit the size of possible meshes
18 * @author Jerome Robert
20 public class SplitFace
22 private static TopoDS_Edge[] getEdges(TopoDS_Shape face)
24 HashSet toReturn=new HashSet();
25 TopExp_Explorer exp=new TopExp_Explorer(face, TopAbs_ShapeEnum.EDGE);
28 toReturn.add(exp.current());
31 return (TopoDS_Edge[]) toReturn.toArray(new TopoDS_Edge[toReturn.size()]);
34 private static TopoDS_Shape createCuttedBox()
36 TopoDS_Shape box1 = new BRepPrimAPI_MakeBox(
37 new double[3], new double[]{4, 3, 2}).shape();
39 TopoDS_Shape box2 = new BRepPrimAPI_MakeBox(
40 new double[]{-1,-1,-1}, new double[]{3, 2, 1}).shape();
42 return new BRepAlgoAPI_Cut(box1, box2).shape();
45 @Test public void sample()
47 TopoDS_Shape cuttedBox=createCuttedBox();
48 BRepFilletAPI_MakeFillet fillet = new BRepFilletAPI_MakeFillet(cuttedBox);
49 TopoDS_Edge[] edges = getEdges(cuttedBox);
50 for(int i=0; i<edges.length; i++)
52 fillet.add(0.1, edges[i]);
55 ShapeUpgrade_ShapeDivideArea ss=new ShapeUpgrade_ShapeDivideArea(fillet.shape());
58 //display(ss.getResult());
61 /*public static void display(TopoDS_Shape shape)
63 JFrame cadFrame=new JFrame("jcae-viewer3d-cad demo");
64 cadFrame.setSize(800,600);
65 cadFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
66 final View cadView=new View(cadFrame);
68 ViewableCAD fcad=new ViewableCAD(new OCCProvider(shape));
71 cadFrame.getContentPane().add(cadView);
72 cadFrame.setVisible(true);
73 cadView.setOriginAxisVisible(true);