package org.jcae.opencascade.jni; import static org.junit.Assert.*; import org.junit.Test; import java.util.HashMap; /** * Workshop JINA 2006, Finite tilted Grid in front of a cavity * @author Jerome Robert and Guillaume Sylvand */ public class Jina2006 { // Size of the grid public final static int I_MAX=1; public final static int J_MAX=10; public final static int K_MAX=10; /** * Used as index of edges of the grid */ static class IntEdge { int i, j, k, i2, j2, k2; public IntEdge(int i, int j, int k, int i2, int j2, int k2) { this.i=i; this.j=j; this.k=k; this.i2=i2; this.j2=j2; this.k2=k2; } @Override public boolean equals(Object obj) { if (!(obj instanceof IntEdge)) return false; IntEdge other=(IntEdge)obj; return (i==other.i)&&(j==other.j)&&(k==other.k) &&(i2==other.i2)&&(j2==other.j2)&&(k2==other.k2); } @Override public int hashCode() { return i+j+k+i2+j2+k2; } } /** Coordinates on the grid */ static double[] coordinates(int i, int j, int k) { double x=-(k-5)*0.03*Math.sin(15*Math.PI/180)+(i-1)*0.01; double y=(j-5)*0.03; double z=(k-5)*0.03; return new double[]{x, y, z}; } /** Easy creation of vertices */ static TopoDS_Vertex createVertex(double x, double y, double z) { return (TopoDS_Vertex) new BRepBuilderAPI_MakeVertex(new double[]{x, y, z}).shape(); } /** Easy creation of vertices */ static TopoDS_Vertex createVertex(double[] coords) { return (TopoDS_Vertex) new BRepBuilderAPI_MakeVertex(coords).shape(); } /** Easy creation of edges */ static TopoDS_Edge createEdge(TopoDS_Vertex v1, TopoDS_Vertex v2) { return (TopoDS_Edge) new BRepBuilderAPI_MakeEdge(v1, v2).shape(); } /** Easy creation of faces */ static TopoDS_Face createFace(TopoDS_Edge e1, TopoDS_Edge e2, TopoDS_Edge e3, TopoDS_Edge e4) { TopoDS_Wire wirePlate= (TopoDS_Wire) new BRepBuilderAPI_MakeWire(e1, e2, e3, e4).shape(); return (TopoDS_Face) new BRepBuilderAPI_MakeFace(wirePlate, true).shape(); } /** Easy creation of faces */ static TopoDS_Face createFace(TopoDS_Shape wire) { return (TopoDS_Face) new BRepBuilderAPI_MakeFace((TopoDS_Wire)wire, true).shape(); } @Test public void sample() { HashMap int2edges=new HashMap(); TopoDS_Vertex[][][] vertices=new TopoDS_Vertex[I_MAX+2][J_MAX+2][K_MAX+2]; //The compound to return BRep_Builder bb=new BRep_Builder(); TopoDS_Compound compound=new TopoDS_Compound(); bb.makeCompound(compound); //Create vertices of the grid for(int i=0; i