Example #1
0
        /***************************************************/

        public static bool IsEqual(this BHG.NurbsCurve bhCurve, RHG.NurbsCurve rhCurve, double tolerance = BHG.Tolerance.Distance)
        {
            if (bhCurve == null & rhCurve == null)
            {
                return(true);
            }

            List <BHG.Point> bhPoints  = bhCurve.ControlPoints;
            List <double>    bhWeights = bhCurve.Weights;
            List <double>    bhKnots   = bhCurve.Knots;

            RHG.Collections.NurbsCurvePointList rhPoints = rhCurve.Points;

            bool pointsEqual  = true;
            bool weightsEqual = true;
            bool knotsEqual   = true;

            for (int i = 0; i < bhPoints.Count; i++)
            {
                pointsEqual &= bhPoints[i].IsEqual(rhPoints[i], tolerance);
            }
            for (int i = 0; i < bhWeights.Count; i++)
            {
                weightsEqual &= Math.Abs(bhWeights[i] - rhPoints[i].Weight) < tolerance;
            }
            for (int i = 0; i < bhKnots.Count; i++)
            {
                knotsEqual &= Math.Abs(bhKnots[i] - rhCurve.Knots[i]) < tolerance;
            }

            return(pointsEqual && weightsEqual && knotsEqual);
        }
Example #2
0
        public static RHG.NurbsCurve ToRhino5(this BHG.NurbsCurve bCurve)
        {
            if (bCurve == null)
            {
                return(null);
            }

            List <double>    knots   = bCurve.Knots;
            List <double>    weights = bCurve.Weights;
            List <BHG.Point> ctrlPts = bCurve.ControlPoints;

            RHG.NurbsCurve rCurve = new RHG.NurbsCurve(3, false, bCurve.Degree() + 1, ctrlPts.Count);

            for (int i = 0; i < knots.Count; i++)
            {
                rCurve.Knots[i] = knots[i];
            }

            for (int i = 0; i < ctrlPts.Count; i++)
            {
                BHG.Point pt = ctrlPts[i];
                rCurve.Points.SetPoint(i, pt.X, pt.Y, pt.Z, weights[i]);
            }

            return(rCurve);
        }
Example #3
0
        /***************************************************/

        public static RHG.NurbsCurve ToRhino(this BHG.NurbsCurve bCurve)
        {
            switch (Rhino.RhinoApp.Version.Major)
            {
            case 5:
                return(ToRhino5(bCurve));

            case 6:
                return(ToRhino6(bCurve));

            default:
                throw new NotImplementedException($"Rhino {Rhino.RhinoApp.Version.ToString()} version not supported.");
            }
        }
Example #4
0
        internal static global::Topologic.Edge EdgeByNurbsCurve(BH.oM.Geometry.NurbsCurve bhomNurbsCurve)
        {
            throw new NotImplementedException("NurbsCurves are not yet supported.");

            //List<Point> bhomControlPoints = bhomNurbsCurve.ControlPoints;
            //List<double> bhomKnots = bhomNurbsCurve.Knots;
            //List<double> bhomWeights = bhomNurbsCurve.Weights;

            //List<global::Topologic.Vertex> controlPoints = new List<global::Topologic.Vertex>();
            //foreach(Point bhomControlPoint in bhomControlPoints)
            //{
            //    controlPoints.Add(Vertex.Create.ByPoint(bhomControlPoint));
            //}

            //return global::Topologic.Utilities.EdgeUtility.ByNurbsCurve(
            //    controlPoints, bhomKnots, bhomWeights,
            //    3, // minimum degree
            //    true, false // OCCT default
            //    );
        }
Example #5
0
        internal static global::Topologic.Edge EdgeByCurve(ICurve bhomCurve)
        {
            // Currently only handle lines
            BH.oM.Geometry.Line bhomLine = bhomCurve as BH.oM.Geometry.Line;
            if (bhomLine != null)
            {
                return(EdgeByLine(bhomLine));
            }

            Arc bhomArc = bhomCurve as Arc;

            if (bhomArc != null)
            {
                return(EdgeByArc(bhomArc));
            }

            Circle bhomCircle = bhomCurve as Circle;

            if (bhomCircle != null)
            {
                return(EdgeByCircle(bhomCircle));
            }

            Ellipse bhomEllipse = bhomCurve as Ellipse;

            if (bhomEllipse != null)
            {
                return(EdgeByEllipse(bhomEllipse));
            }

            BH.oM.Geometry.NurbsCurve bhomNurbsCurve = bhomCurve as BH.oM.Geometry.NurbsCurve;
            if (bhomNurbsCurve != null)
            {
                return(EdgeByNurbsCurve(bhomNurbsCurve));
            }

            throw new NotImplementedException("This type of Curve is not supported.");
        }
Example #6
0
        /***************************************************/

        public static void RenderMeshes(BHG.NurbsCurve curve, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material)
        {
            return;
        }
Example #7
0
        /***************************************************/

        public static void RenderWires(BHG.NurbsCurve curve, Rhino.Display.DisplayPipeline pipeline, Color bhColour)
        {
            pipeline.DrawCurve(curve.ToRhino(), bhColour, 2);
        }