Beispiel #1
0
        public void genBaseMass()
        {
            PolylineCurve outerCrv    = new PolylineCurve(outerPtLi);
            double        outerAr     = AreaMassProperties.Compute(outerCrv).Area;
            PolylineCurve innerCrv    = new PolylineCurve(innerPtLi);
            double        innerAr     = AreaMassProperties.Compute(innerCrv).Area;
            double        diffAr      = outerAr - innerAr;
            int           numBaseFlrs = (int)(SITE_AR * baseFsr / diffAr) + 1;
            double        baseHt      = numBaseFlrs * flrHt;
            Extrusion     outerExtr   = Extrusion.Create(outerCrv, baseHt, true);
            Extrusion     innerExtr   = Extrusion.Create(innerCrv, baseHt, true);

            Brep[] outerBrep = { outerExtr.ToBrep() };
            Brep[] innerBrep = { innerExtr.ToBrep() };
            Brep[] diffBrep  = Brep.CreateBooleanDifference(outerBrep, innerBrep, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
            for (int i = 0; i < diffBrep.Length; i++)
            {
                globalBrepLi.Add(diffBrep[i]);
            }

            globalBaseCrvLi = new List <Curve>();
            double spineHt = 0.0;

            for (int i = 0; i < numBaseFlrs; i++)
            {
                Curve outerCrvDup = outerCrv.DuplicateCurve();
                Rhino.Geometry.Transform xform = Rhino.Geometry.Transform.Translation(0, 0, spineHt);
                outerCrvDup.Transform(xform);
                Curve innerCrvDup = innerCrv.DuplicateCurve();
                innerCrvDup.Transform(xform);
                globalBaseCrvLi.Add(innerCrvDup);
                globalBaseCrvLi.Add(outerCrvDup);
                spineHt += flrHt;
            }
            BaseMassHt = baseHt;
        }
Beispiel #2
0
// ===============================================================================================
// splits curve at kinks (discontinuity)
// ===============================================================================================
        public static bool CurveDiscontinuity(List <Curve> L, Curve crv, int continuity, bool recursive)
        {
            if (crv == null)
            {
                return(false);
            }

            PolyCurve polycurve = crv as PolyCurve;

            if (polycurve != null)
            {
                if (recursive)
                {
                    polycurve.RemoveNesting();
                }

                Curve[] segments = polycurve.Explode();

                if (segments == null)
                {
                    return(false);
                }
                if (segments.Length == 0)
                {
                    return(false);
                }

                if (recursive)
                {
                    foreach (Curve S in segments)
                    {
                        return(CurveDiscontinuity(L, S, continuity, recursive));
                    }
                }
                else
                {
                    foreach (Curve S in segments)
                    {
                        L.Add(S.DuplicateShallow() as Curve);
                    }
                }

                return(true);
            }

            PolylineCurve polyline = crv as PolylineCurve;

            if (polyline != null)
            {
                if (recursive)
                {
                    for (int i = 0; i < (polyline.PointCount - 1); i++)
                    {
                        L.Add(new LineCurve(polyline.Point(i), polyline.Point(i + 1)));
                    }
                }
                else
                {
                    L.Add(polyline.DuplicateCurve());
                }
                return(true);
            }

            Polyline p;

            if (crv.TryGetPolyline(out p))
            {
                if (recursive)
                {
                    for (int i = 0; i < (p.Count - 1); i++)
                    {
                        L.Add(new LineCurve(p[i], p[i + 1]));
                    }
                }
                else
                {
                    L.Add(new PolylineCurve());
                }
                return(true);
            }

            //Maybe it’s a LineCurve?
            LineCurve line = crv as LineCurve;

            if (line != null)
            {
                L.Add(line.DuplicateCurve());
                return(true);
            }

            //It might still be an ArcCurve…
            ArcCurve arc = crv as ArcCurve;

            if (arc != null)
            {
                L.Add(arc.DuplicateCurve());
                return(true);
            }

            //Nothing else worked, lets assume it’s a nurbs curve and go from there…
            NurbsCurve nurbs = crv.ToNurbsCurve();

            if (nurbs == null)
            {
                return(false);
            }

            double t0 = nurbs.Domain.Min;
            double t1 = nurbs.Domain.Max;
            double t;

            int LN = L.Count;

            do
            {
                if (!nurbs.GetNextDiscontinuity((Continuity)continuity, t0, t1, out t))
                {
                    break;
                }

                Interval trim = new Interval(t0, t);
                if (trim.Length < 1e-10)
                {
                    t0 = t;
                    continue;
                }

                Curve M = nurbs.DuplicateCurve();
                M = M.Trim(trim);
                if (M.IsValid)
                {
                    L.Add(M);
                }

                t0 = t;
            } while (true);

            if (L.Count == LN)
            {
                L.Add(nurbs);
            }

            return(true);
        }