Exemple #1
0
        public void AddUVSideNames(Surface srf, IsoStatus activeSide = IsoStatus.None)
        {
            if (!IS_ENABLED)
            {
                return;
            }

            var domainU = srf.Domain(0);
            var domainV = srf.Domain(1);
            var uColor  = UCOLOR;
            var vColor  = VCOLOR;

            var uCurveMid = srf._GetUCurve(domainV.Mid);
            var vCurveMid = srf._GetVCurve(domainU.Mid);
            var shift     = Math.Min(uCurveMid._GetLength_ThreadSafe(), vCurveMid._GetLength_ThreadSafe()) / 10;

            // add: West, East, North, South
            var pWest  = srf._GetUCurve(domainV.Mid)._GetCurveExtEndPoint(CurveEnd.Start, shift * 3);
            var pEast  = srf._GetUCurve(domainV.Mid)._GetCurveExtEndPoint(CurveEnd.End, shift * 3);
            var pSouth = srf._GetVCurve(domainU.Mid)._GetCurveExtEndPoint(CurveEnd.Start, shift * 3);
            var pNorth = srf._GetVCurve(domainU.Mid)._GetCurveExtEndPoint(CurveEnd.End, shift * 3);

            AddTextPoint("West", pWest, activeSide == IsoStatus.West ? Color.Red : Color.Silver);
            AddTextPoint("East", pEast, activeSide == IsoStatus.East ? Color.Red : Color.Silver);
            AddTextPoint("South", pSouth, activeSide == IsoStatus.South ? Color.Red : Color.Silver);
            AddTextPoint("North", pNorth, activeSide == IsoStatus.North ? Color.Red : Color.Silver);
        }
Exemple #2
0
        public static string _UVToString(this Surface srf, double u, double v, IsoStatus singularOn = IsoStatus.None)
        {
            var us = u._ToStringX(2);
            var vs = v._ToStringX(2);

            if (singularOn == IsoStatus.X ||
                singularOn == IsoStatus.South ||
                singularOn == IsoStatus.North)
            {
                us = String.Format("{0:0.00}..{1:0.00}", srf.Domain(0).T0, srf.Domain(0).T1);
            }
            if (singularOn == IsoStatus.Y ||
                singularOn == IsoStatus.West ||
                singularOn == IsoStatus.East)
            {
                vs = String.Format("{0:0.00}..{1:0.00}", srf.Domain(1).T0, srf.Domain(1).T1);
            }
            var text = us + " * " + vs;

            text = text.Replace(",00", "").Replace(".00", "");
            return(text);
        }
Exemple #3
0
        private static Surface ExtendSurfaceByPercent_Recurs(Surface srf, IsoStatus extensionDirection, double percent, bool recurs = true)
        {
            var srfExt = srf.Extend(extensionDirection, percent, true); // true - same as CurveExtensionStyle.Arc, false - same as CurveExtensionStyle.Smooth

            if (srfExt == null)
            {
                return(srf);
            }
            var domainSrf    = new Interval();
            var domainSrfExt = new Interval();

            switch (extensionDirection)
            {
            case IsoStatus.West:
            case IsoStatus.East:
            case IsoStatus.X:
                domainSrf    = srf.Domain(0);
                domainSrfExt = srfExt.Domain(0);
                break;

            case IsoStatus.North:
            case IsoStatus.South:
            case IsoStatus.Y:
                domainSrf    = srf.Domain(1);
                domainSrfExt = srfExt.Domain(1);
                break;
            }

            var increased = ((domainSrfExt.Length - domainSrf.Length) / domainSrf.Length) * 100;

            if (increased > 0.00000001 && recurs)
            {
                return(ExtendSurfaceByPercent_Recurs(srf, extensionDirection, (percent * percent) / increased, false));
            }

            return(srfExt);
        }
 /// <summary>
 /// Extends an untrimmed surface along one edge.
 /// </summary>
 /// <param name="edge">
 /// Edge to extend.  Must be North, South, East, or West.
 /// </param>
 /// <param name="extensionLength">distance to extend.</param>
 /// <param name="smooth">
 /// true for smooth (C-infinity) extension. 
 /// false for a C1- ruled extension.
 /// </param>
 /// <returns>New extended surface on success.</returns>
 public Surface Extend(IsoStatus edge, double extensionLength, bool smooth)
 {
   IntPtr pConstThis = ConstPointer();
   IntPtr pNewSurface = UnsafeNativeMethods.RHC_RhinoExtendSurface(pConstThis, (int)edge, extensionLength, smooth);
   return GeometryBase.CreateGeometryHelper(pNewSurface, null) as Surface;
 }
Exemple #5
0
    static void MakeTwistedCubeTrimmingLoop(ref Brep brep, ref BrepFace face, // 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
                                            )
    {
        Surface srf  = brep.Surfaces[face.SurfaceIndex];
        var     loop = brep.Loops.Add(BrepLoopType.Outer, face);

        // Create trimming curves running counter clockwise around the surface's domain.
        // Start at the south side
        // side: 0=south, 1=east, 2=north, 3=west
        for (int side = 0; side < 4; side++)
        {
            Curve trimming_curve = TwistedCubeTrimmingCurve(srf, side);
            int   curve_index    = brep.Curves2D.Add(trimming_curve);

            int       ei      = 0;
            bool      reverse = false;
            IsoStatus iso     = IsoStatus.None;
            switch (side)
            {
            case 0: // south
                ei      = eSi;
                reverse = (eS_dir == -1);
                iso     = IsoStatus.South;
                break;

            case 1: // east
                ei      = eEi;
                reverse = (eE_dir == -1);
                iso     = IsoStatus.East;
                break;

            case 2: // north
                ei      = eNi;
                reverse = (eN_dir == -1);
                iso     = IsoStatus.North;
                break;

            case 3: // west
                ei      = eWi;
                reverse = (eW_dir == -1);
                iso     = IsoStatus.West;
                break;
            }

            BrepEdge edge = brep.Edges[ei];
            BrepTrim trim = brep.Trims.Add(edge, reverse, loop, curve_index);
            trim.IsoStatus = iso;
            trim.TrimType  = BrepTrimType.Mated; // This b-rep is closed, so all trims have mates.
            trim.SetTolerances(0, 0);            // This simple example is exact - for models with
            // non-exact data, set tolerance as explained in
            // definition of BrepTrim.
        }
    }
Exemple #6
0
 /// <summary>
 /// Extend surface by some percent in some direction.
 /// to extend by 50% pass parameter 'percent=50'
 /// </summary>
 /// <param name="srf"></param>
 /// <param name="extensionDirection"></param>
 /// <param name="percent">value '50' will be 50%</param>
 /// <returns></returns>
 public static Surface _ExtendSurfaceByPercent(this Surface srf, IsoStatus extensionDirection, double percent)
 {
     return(ExtendSurfaceByPercent_Recurs(srf, extensionDirection, percent));
 }
 /// <summary>
 /// Extends an untrimmed surface along one edge.
 /// </summary>
 /// <param name="edge">
 /// Edge to extend.  Must be North, South, East, or West.
 /// </param>
 /// <param name="extensionLength">distance to extend.</param>
 /// <param name="smooth">
 /// true for smooth (C-infinity) extension. 
 /// false for a C1- ruled extension.
 /// </param>
 /// <returns>New extended surface on success.</returns>
 public Surface Extend(IsoStatus edge, double extensionLength, bool smooth)
 {
   IntPtr const_ptr_this = ConstPointer();
   IntPtr ptr_new_surface = UnsafeNativeMethods.RHC_RhinoExtendSurface(const_ptr_this, (int)edge, extensionLength, smooth);
   return CreateGeometryHelper(ptr_new_surface, null) as Surface;
 }