private static void MakeTrimmedFace(ref OnBrep brep, int si, // index of 3d surface int s_dir, // orientation of surface with respect to surfce int v0, int v1, int v2, // Indices of corner vertices int e0, // index of first edge int e0_dir, // orientation of edge int e1, // index of second edge int e1_dir, // orientation of edge int e2, // index of third edge int e2_dir // orientation of edge ) { //Add new face to brep OnBrepFace face = brep.NewFace(si); //Create loop and trims for the face MakeTrimmingLoop(ref brep, ref face, v0, v1, v2, e0, e0_dir, e1, e1_dir, e2, e2_dir ); //Set face direction relative to surface direction face.m_bRev = (s_dir == -1); }
/// <summary> /// MakeTwistedCubeFace /// </summary> static void MakeTwistedCubeFace( ref OnBrep brep, int si, // index of 3d surface int s_dir, // orientation of surface with respect to brep int vSWi, int vSEi, int vNEi, int vNWi, // Indices of corner vertices listed in SW, SE, NW, NE order int eSi, // index of edge on south side of surface int eS_dir, // orientation of edge with respect to surface trim int eEi, // index of edge on south side of surface int eE_dir, // orientation of edge with respect to surface trim int eNi, // index of edge on south side of surface int eN_dir, // orientation of edge with respect to surface trim int eWi, // index of edge on south side of surface int eW_dir // orientation of edge with respect to surface trim ) { OnBrepFace face = brep.NewFace(si); MakeTwistedCubeTrimmingLoop( ref brep, ref face, vSWi, vSEi, vNEi, vNWi, eSi, eS_dir, eEi, eE_dir, eNi, eN_dir, eWi, eW_dir ); face.m_bRev = (s_dir == -1); }
private static void CreateFace(ref OnBrep brep, int si) { //Add new face to brep OnBrepFace face = brep.NewFace(si); //Create outer loop and trims for the face MakeOuterTrimmingLoop(ref brep, ref face, A, B, C, D, // Indices of vertices listed in SW,SE,NW,NE order AB, +1, // South side edge and its orientation with respect to // to the trimming curve. (AB) BC, +1, // East side edge and its orientation with respect to // to the trimming curve. (BC) CD, +1, // North side edge and its orientation with respect to // to the trimming curve (CD) AD, -1 // West side edge and its orientation with respect to // to the trimming curve (AD) ); //Create loop and trims for the face MakeInnerTrimmingLoop(ref brep, ref face, E, F, G, H, // Indices of hole vertices EF, +1, // Parallel to south side edge and its orientation with respect to // to the trimming curve. (EF) FG, +1, // Parallel to east side edge and its orientation with respect to // to the trimming curve. (FG) GH, +1, // Parallel to north side edge and its orientation with respect to // to the trimming curve (GH) EH, -1 // Parallel to west side edge and its orientation with respect to // to the trimming curve (EH) ); //Set face direction relative to surface direction face.m_bRev = false; }
/// <summary> /// The one and only MakeBox /// </summary> static OnBrep MakeBox() { /* This example demonstrates how to construct a OnBrep with the topology shown below. v7_______e6_____v6 |\ |\ | e7 | e5 | \ ______e4_____\ e11 v4 | v5 | | e10 | | | | | v3---|---e2----v2 e9 \ e8 \ | e3 | e1 | \ | \ | \v0_____e0_____\v1 */ On3dPoint[] points = new On3dPoint[8]; points[0] = new On3dPoint(0.0, 0.0, 0.0); points[1] = new On3dPoint(10.0, 0.0, 0.0); points[2] = new On3dPoint(10.0, 10.0, 0.0); points[3] = new On3dPoint(0.0, 10.0, 0.0); points[4] = new On3dPoint(0.0, 0.0, 10.0); points[5] = new On3dPoint(10.0, 0.0, 10.0); points[6] = new On3dPoint(10.0, 10.0, 10.0); points[7] = new On3dPoint(0.0, 10.0, 10.0); OnBrep brep = new OnBrep(); int vi = 0, ei = 0, fi = 0, si = 0, c2i = 0; for (vi = 0; vi < 8; vi++) brep.NewVertex(points[vi], 0.0); for (ei = 0; ei < 4; ei++) { OnBrepVertex v0 = brep.m_V[ei]; OnBrepVertex v1 = brep.m_V[(ei + 1) % 4]; brep.m_C3.Append(new OnLineCurve(v0.point, v1.point)); brep.NewEdge(ref v0, ref v1, ei, null, 0.0); } for (ei = 4; ei < 8; ei++) { OnBrepVertex v0 = brep.m_V[ei]; OnBrepVertex v1 = brep.m_V[ei == 7 ? 4 : (ei + 1)]; brep.m_C3.Append(new OnLineCurve(v0.point, v1.point)); brep.NewEdge(ref v0, ref v1, ei, null, 0.0); } for (ei = 8; ei < 12; ei++) { OnBrepVertex v0 = brep.m_V[ei - 8]; OnBrepVertex v1 = brep.m_V[ei - 4]; brep.m_C3.Append(new OnLineCurve(v0.point, v1.point)); brep.NewEdge(ref v0, ref v1, ei, null, 0.0); } OnBrepBoxFaceInfo[] f = new OnBrepBoxFaceInfo[6]; f[0] = new OnBrepBoxFaceInfo(0, 9, 4, 8, false, false, true, true); f[1] = new OnBrepBoxFaceInfo(1, 10, 5, 9, false, false, true, true); f[2] = new OnBrepBoxFaceInfo(2, 11, 6, 10, false, false, true, true); f[3] = new OnBrepBoxFaceInfo(3, 8, 7, 11, false, false, true, true); f[4] = new OnBrepBoxFaceInfo(3, 2, 1, 0, true, true, true, true); f[5] = new OnBrepBoxFaceInfo(4, 5, 6, 7, false, false, false, false); for (fi = 0; fi < 6; fi++ ) { OnBrepEdge e0 = brep.m_E[f[fi].e[0]]; OnBrepEdge e1 = brep.m_E[f[fi].e[1]]; OnBrepEdge e2 = brep.m_E[f[fi].e[2]]; OnBrepEdge e3 = brep.m_E[f[fi].e[3]]; OnBrepVertex v0 = brep.m_V[e0.get_m_vi(f[fi].bRev[0] ? 1 : 0)]; OnBrepVertex v1 = brep.m_V[e1.get_m_vi(f[fi].bRev[1] ? 1 : 0)]; OnBrepVertex v2 = brep.m_V[e2.get_m_vi(f[fi].bRev[2] ? 1 : 0)]; OnBrepVertex v3 = brep.m_V[e3.get_m_vi(f[fi].bRev[3] ? 1 : 0)]; si = brep.AddSurface(OnUtil.ON_NurbsSurfaceQuadrilateral(v0.point, v1.point, v2.point, v3.point)); OnInterval s = brep.m_S[si].Domain(0); OnInterval t = brep.m_S[si].Domain(1); On2dPoint p0 = new On2dPoint(s[0], t[0]); On2dPoint p1 = new On2dPoint(s[1], t[0]); On2dPoint p2 = new On2dPoint(s[1], t[1]); On2dPoint p3 = new On2dPoint(s[0], t[1]); OnBrepFace face = brep.NewFace(si); OnBrepLoop loop = brep.NewLoop(IOnBrepLoop.TYPE.outer, ref face); loop.m_pbox.m_min.x = s[0]; loop.m_pbox.m_min.y = t[0]; loop.m_pbox.m_min.z = 0.0; loop.m_pbox.m_max.x = s[1]; loop.m_pbox.m_max.y = t[1]; loop.m_pbox.m_max.z = 0.0; // south side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p0, p1)); OnBrepTrim trim0 = brep.NewTrim(ref e0, f[fi].bRev[0], ref loop, c2i); trim0.set_m_tolerance(0, 0.0); trim0.set_m_tolerance(1, 0.0); trim0.m_type = (trim0.get_m_vi(0) != trim0.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim0.m_iso = IOnSurface.ISO.S_iso; // east side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p1, p2)); OnBrepTrim trim1 = brep.NewTrim(ref e1, f[fi].bRev[1], ref loop, c2i); trim1.set_m_tolerance(0, 0.0); trim1.set_m_tolerance(1, 0.0); trim1.m_type = (trim1.get_m_vi(0) != trim1.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim1.m_iso = IOnSurface.ISO.E_iso; // north side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p2, p3)); OnBrepTrim trim2 = brep.NewTrim(ref e2, f[fi].bRev[2], ref loop, c2i); trim2.set_m_tolerance(0, 0.0); trim2.set_m_tolerance(1, 0.0); trim2.m_type = (trim2.get_m_vi(0) != trim2.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim2.m_iso = IOnSurface.ISO.N_iso; // west side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p3, p0)); OnBrepTrim trim3 = brep.NewTrim(ref e3, f[fi].bRev[3], ref loop, c2i); trim3.set_m_tolerance(0, 0.0); trim3.set_m_tolerance(1, 0.0); trim3.m_type = (trim3.get_m_vi(0) != trim3.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim3.m_iso = IOnSurface.ISO.W_iso; } if (!brep.IsValid()) return null; return brep; }
/// <summary> /// The one and only MakeBox /// </summary> static OnBrep MakeBox() { /* * This example demonstrates how to construct a OnBrep * with the topology shown below. * * v7_______e6_____v6 |\ |\ | e7 | e5 | \ ______e4_____\ | e11 v4 | v5 | | e10 | | | | | | v3---|---e2----v2 e9 \ e8 \ | \ e3 | e1 | \ | \ | \ \v0_____e0_____\v1 \ */ On3dPoint[] points = new On3dPoint[8]; points[0] = new On3dPoint(0.0, 0.0, 0.0); points[1] = new On3dPoint(10.0, 0.0, 0.0); points[2] = new On3dPoint(10.0, 10.0, 0.0); points[3] = new On3dPoint(0.0, 10.0, 0.0); points[4] = new On3dPoint(0.0, 0.0, 10.0); points[5] = new On3dPoint(10.0, 0.0, 10.0); points[6] = new On3dPoint(10.0, 10.0, 10.0); points[7] = new On3dPoint(0.0, 10.0, 10.0); OnBrep brep = new OnBrep(); int vi = 0, ei = 0, fi = 0, si = 0, c2i = 0; for (vi = 0; vi < 8; vi++) { brep.NewVertex(points[vi], 0.0); } for (ei = 0; ei < 4; ei++) { OnBrepVertex v0 = brep.m_V[ei]; OnBrepVertex v1 = brep.m_V[(ei + 1) % 4]; brep.m_C3.Append(new OnLineCurve(v0.point, v1.point)); brep.NewEdge(ref v0, ref v1, ei, null, 0.0); } for (ei = 4; ei < 8; ei++) { OnBrepVertex v0 = brep.m_V[ei]; OnBrepVertex v1 = brep.m_V[ei == 7 ? 4 : (ei + 1)]; brep.m_C3.Append(new OnLineCurve(v0.point, v1.point)); brep.NewEdge(ref v0, ref v1, ei, null, 0.0); } for (ei = 8; ei < 12; ei++) { OnBrepVertex v0 = brep.m_V[ei - 8]; OnBrepVertex v1 = brep.m_V[ei - 4]; brep.m_C3.Append(new OnLineCurve(v0.point, v1.point)); brep.NewEdge(ref v0, ref v1, ei, null, 0.0); } OnBrepBoxFaceInfo[] f = new OnBrepBoxFaceInfo[6]; f[0] = new OnBrepBoxFaceInfo(0, 9, 4, 8, false, false, true, true); f[1] = new OnBrepBoxFaceInfo(1, 10, 5, 9, false, false, true, true); f[2] = new OnBrepBoxFaceInfo(2, 11, 6, 10, false, false, true, true); f[3] = new OnBrepBoxFaceInfo(3, 8, 7, 11, false, false, true, true); f[4] = new OnBrepBoxFaceInfo(3, 2, 1, 0, true, true, true, true); f[5] = new OnBrepBoxFaceInfo(4, 5, 6, 7, false, false, false, false); for (fi = 0; fi < 6; fi++) { OnBrepEdge e0 = brep.m_E[f[fi].e[0]]; OnBrepEdge e1 = brep.m_E[f[fi].e[1]]; OnBrepEdge e2 = brep.m_E[f[fi].e[2]]; OnBrepEdge e3 = brep.m_E[f[fi].e[3]]; OnBrepVertex v0 = brep.m_V[e0.get_m_vi(f[fi].bRev[0] ? 1 : 0)]; OnBrepVertex v1 = brep.m_V[e1.get_m_vi(f[fi].bRev[1] ? 1 : 0)]; OnBrepVertex v2 = brep.m_V[e2.get_m_vi(f[fi].bRev[2] ? 1 : 0)]; OnBrepVertex v3 = brep.m_V[e3.get_m_vi(f[fi].bRev[3] ? 1 : 0)]; si = brep.AddSurface(OnUtil.ON_NurbsSurfaceQuadrilateral(v0.point, v1.point, v2.point, v3.point)); OnInterval s = brep.m_S[si].Domain(0); OnInterval t = brep.m_S[si].Domain(1); On2dPoint p0 = new On2dPoint(s[0], t[0]); On2dPoint p1 = new On2dPoint(s[1], t[0]); On2dPoint p2 = new On2dPoint(s[1], t[1]); On2dPoint p3 = new On2dPoint(s[0], t[1]); OnBrepFace face = brep.NewFace(si); OnBrepLoop loop = brep.NewLoop(IOnBrepLoop.TYPE.outer, ref face); loop.m_pbox.m_min.x = s[0]; loop.m_pbox.m_min.y = t[0]; loop.m_pbox.m_min.z = 0.0; loop.m_pbox.m_max.x = s[1]; loop.m_pbox.m_max.y = t[1]; loop.m_pbox.m_max.z = 0.0; // south side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p0, p1)); OnBrepTrim trim0 = brep.NewTrim(ref e0, f[fi].bRev[0], ref loop, c2i); trim0.set_m_tolerance(0, 0.0); trim0.set_m_tolerance(1, 0.0); trim0.m_type = (trim0.get_m_vi(0) != trim0.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim0.m_iso = IOnSurface.ISO.S_iso; // east side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p1, p2)); OnBrepTrim trim1 = brep.NewTrim(ref e1, f[fi].bRev[1], ref loop, c2i); trim1.set_m_tolerance(0, 0.0); trim1.set_m_tolerance(1, 0.0); trim1.m_type = (trim1.get_m_vi(0) != trim1.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim1.m_iso = IOnSurface.ISO.E_iso; // north side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p2, p3)); OnBrepTrim trim2 = brep.NewTrim(ref e2, f[fi].bRev[2], ref loop, c2i); trim2.set_m_tolerance(0, 0.0); trim2.set_m_tolerance(1, 0.0); trim2.m_type = (trim2.get_m_vi(0) != trim2.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim2.m_iso = IOnSurface.ISO.N_iso; // west side of surface c2i = brep.AddTrimCurve(new OnLineCurve(p3, p0)); OnBrepTrim trim3 = brep.NewTrim(ref e3, f[fi].bRev[3], ref loop, c2i); trim3.set_m_tolerance(0, 0.0); trim3.set_m_tolerance(1, 0.0); trim3.m_type = (trim3.get_m_vi(0) != trim3.get_m_vi(1)) ? IOnBrepTrim.TYPE.mated : IOnBrepTrim.TYPE.singular; trim3.m_iso = IOnSurface.ISO.W_iso; } if (!brep.IsValid()) { return(null); } return(brep); }