private static int MakeTrimmingLoop(ref OnBrep brep,        // returns index of loop
                                            ref OnBrepFace face,    // face loop is on
                                            int v0, int v1, int v2, // Indices of corner vertices listed in A,B,C order
                                            int e0,                 // index of first edge
                                            int e0_dir,             // orientation of edge
                                            int e1,                 // index second edgee
                                            int e1_dir,             // orientation of edge
                                            int e2,                 // index third edge
                                            int e2_dir              // orientation of edge
                                            )
        {
            OnSurface srf = brep.m_S[face.m_si];

            //Create new loop
            OnBrepLoop loop = brep.NewLoop(IOnBrepLoop.TYPE.outer, ref face);

            // Create trimming curves running counter clockwise around the surface's domain.
            // Note that trims of outer loops run counter clockwise while trims of inner loops (holes) run anti-clockwise.
            // Also note that when trims locate on surface N,S,E or W ends, then trim_iso becomes N_iso, S_iso, E_iso and W_iso respectfully.
            // While if trim is parallel to surface N,S or E,W, then trim is becomes y_iso and x_iso respectfully.

            // Start at the south side
            OnCurve c2;
            int     c2i, ei = 0;
            bool    bRev3d = false;

            IOnSurface.ISO iso = IOnSurface.ISO.not_iso;

            for (int side = 0; side < 3; side++)
            {
                // side: 0=south, 1=east, 2=north, 3=west

                c2 = CreateTrimmingCurve(srf, side);

                //Add trimming curve to brep trmming curves array
                c2i = brep.m_C2.Count();
                brep.m_C2.Append(c2);

                switch (side)
                {
                case 0: // south
                    ei     = e0;
                    bRev3d = (e0_dir == -1);
                    iso    = IOnSurface.ISO.S_iso;
                    break;

                case 1: // diagonal
                    ei     = e1;
                    bRev3d = (e1_dir == -1);
                    iso    = IOnSurface.ISO.not_iso;
                    break;

                case 2: // diagonal
                    ei     = e2;
                    bRev3d = (e2_dir == -1);
                    iso    = IOnSurface.ISO.not_iso;
                    break;
                }

                //Create new trim topology that references edge, direction reletive to edge, loop and trim curve geometry
                OnBrepEdge edge = brep.m_E[ei];
                OnBrepTrim trim = brep.NewTrim(ref edge, bRev3d, ref loop, c2i);
                if (trim != null)
                {
                    trim.m_iso  = iso;
                    trim.m_type = IOnBrepTrim.TYPE.boundary; // This one b-rep face, so all trims are boundary ones.
                    trim.set_m_tolerance(0, 0.0);            // This simple example is exact - for models with non-exact
                    trim.set_m_tolerance(1, 0.0);            // data, set tolerance as explained in definition of ON_BrepTrim.
                }
            }
            return(loop.m_loop_index);
        }
Esempio n. 2
0
        /// <summary>
        /// MakeTwistedCubeTrimmingLoop
        /// </summary>
        static int MakeTwistedCubeTrimmingLoop(
            ref OnBrep brep,                        // returns index of loop
            ref OnBrepFace face,                    // face loop is on
            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
            )
        {
            IOnSurface srf = brep.m_S[face.m_si];

            OnBrepLoop loop = brep.NewLoop(IOnBrepLoop.TYPE.outer, ref face);

            // Create trimming curves running counter clockwise around the surface's domain.
            // Start at the south side
            int  c2i = 0, ei = 0;
            bool bRev3d = false;

            IOnSurface.ISO iso = IOnSurface.ISO.not_iso;

            for (int side = 0; side < 4; side++)
            {
                // side: 0=south, 1=east, 2=north, 3=west
                OnCurve c2 = TwistedCubeTrimmingCurve(srf, side);
                c2i = brep.m_C2.Count();
                brep.m_C2.Append(c2);

                switch (side)
                {
                case 0: // south
                    ei     = eSi;
                    bRev3d = (eS_dir == -1);
                    iso    = IOnSurface.ISO.S_iso;
                    break;

                case 1: // east
                    ei     = eEi;
                    bRev3d = (eE_dir == -1);
                    iso    = IOnSurface.ISO.E_iso;
                    break;

                case 2: // north
                    ei     = eNi;
                    bRev3d = (eN_dir == -1);
                    iso    = IOnSurface.ISO.N_iso;
                    break;

                case 3: // west
                    ei     = eWi;
                    bRev3d = (eW_dir == -1);
                    iso    = IOnSurface.ISO.W_iso;
                    break;
                }

                OnBrepEdge edge = brep.m_E[ei];
                OnBrepTrim trim = brep.NewTrim(ref edge, bRev3d, ref loop, c2i);
                trim.m_iso  = iso;
                trim.m_type = IOnBrepTrim.TYPE.mated; // This b-rep is closed, so all trims have mates.
                trim.set_m_tolerance(0, 0.0);         // This simple example is exact - for models with
                trim.set_m_tolerance(1, 0.0);         // non-exact data, set tolerance as explained in
                                                      // definition of OnBrepTrim.
            }

            return(loop.m_loop_index);
        }
        private static int MakeInnerTrimmingLoop(ref OnBrep brep,                        // returns index of loop
                                                 ref OnBrepFace face,                    // face loop is on
                                                 int vSWi, int vSEi, int vNEi, int vNWi, // Indices of hole vertices
                                                 int eSi,                                // index of edge close to south side of surface
                                                 int eS_dir,                             // orientation of edge with respect to surface trim
                                                 int eEi,                                // index of edge close to east side of surface
                                                 int eE_dir,                             // orientation of edge with respect to surface trim
                                                 int eNi,                                // index of edge close to north side of surface
                                                 int eN_dir,                             // orientation of edge with respect to surface trim
                                                 int eWi,                                // index of edge close to west side of surface
                                                 int eW_dir                              // orientation of edge with respect to surface trim
                                                 )
        {
            OnSurface srf = brep.m_S[face.m_si];
            //Create new inner loop
            OnBrepLoop loop = brep.NewLoop(IOnBrepLoop.TYPE.inner, ref face);

            // Create trimming curves running counter clockwise around the surface's domain.
            // Note that trims of outer loops run counter clockwise while trims of inner loops (holes) run clockwise.
            // Also note that when trims locate on surface N,S,E or W ends, then trim_iso becomes N_iso, S_iso, E_iso and W_iso respectfully.
            // While if trim is parallel to surface N,S or E,W, then trim iso becomes y_iso and x_iso respectfully.
            // All other cases, iso is set to not_iso

            // Start near the south side
            OnCurve c2;
            int     c2i, ei = 0;
            bool    bRev3d = false;

            IOnSurface.ISO iso = IOnSurface.ISO.not_iso;

            for (int side = 0; side < 4; side++)
            {
                // side: 0=near south(y_iso), 1=near west(x_iso), 2=near north(y_iso), 3=near east(x_iso)

                //Create trim 2d curve
                c2 = CreateInnerTrimmingCurve(srf, side);

                //Add trimming curve to brep trmming curves array
                c2i = brep.m_C2.Count();
                brep.m_C2.Append(c2);

                switch (side)
                {
                case 0: // near south
                    ei     = eSi;
                    bRev3d = (eS_dir == -1);
                    iso    = IOnSurface.ISO.y_iso;
                    break;

                case 1: // near west
                    ei     = eEi;
                    bRev3d = (eE_dir == -1);
                    iso    = IOnSurface.ISO.x_iso;
                    break;

                case 2: // near north
                    ei     = eNi;
                    bRev3d = (eN_dir == -1);
                    iso    = IOnSurface.ISO.y_iso;
                    break;

                case 3: // near east
                    ei     = eWi;
                    bRev3d = (eW_dir == -1);
                    iso    = IOnSurface.ISO.x_iso;
                    break;
                }

                //Create new trim topology that references edge, direction reletive to edge, loop and trim curve geometry
                OnBrepEdge edge = brep.m_E[ei];
                OnBrepTrim trim = brep.NewTrim(ref edge, bRev3d, ref loop, c2i);
                if (trim != null)
                {
                    trim.m_iso  = iso;
                    trim.m_type = IOnBrepTrim.TYPE.boundary; // This one b-rep face, so all trims are boundary ones.
                    trim.set_m_tolerance(0, 0.0);            // This simple example is exact - for models with non-exact
                    trim.set_m_tolerance(1, 0.0);            // data, set tolerance as explained in definition of ON_BrepTrim.
                }
            }

            return(loop.m_loop_index);
        }