Пример #1
0
        public static Curve OffsetBoundary(PanelFrame panelFrame, double dist)
        {
            //panelFrame.parameters.cellGap / 2.0 - 1
            NurbsCurve         boundary = GetPlanarPanelBoundary(panelFrame);
            AreaMassProperties amp      = AreaMassProperties.Compute(boundary);

            if (amp == null)
            {
                return(null);
            }
            //RhinoDoc.ActiveDoc.Objects.AddCurve(boundary);
            Curve[] offsets = boundary.Offset(CaveTools.averagePoint(boundary.Points.Select(x => x.Location).ToList()), panelFrame.localPlane.Normal, dist, 5, CurveOffsetCornerStyle.Sharp);
            if (offsets == null)
            {
                offsets = boundary.Offset(CaveTools.averagePoint(boundary.Points.Select(x => x.Location).ToList()), panelFrame.localPlane.Normal, -(dist), 5, CurveOffsetCornerStyle.Sharp);
            }

            AreaMassProperties amp2 = AreaMassProperties.Compute(offsets[0]);

            if (amp2 == null || amp2.Area > amp.Area)
            {
                offsets = boundary.Offset(CaveTools.averagePoint(boundary.Points.Select(x => x.Location).ToList()), panelFrame.localPlane.Normal, -(dist), 5, CurveOffsetCornerStyle.Sharp);
            }
            amp2 = AreaMassProperties.Compute(offsets[0]);
            if (amp2 == null || amp2.Area < 10000)
            {
                offsets = boundary.Offset(panelFrame.localPlane, -(dist), 5, CurveOffsetCornerStyle.Sharp);
            }
            if (offsets == null)
            {
                return(null);
            }
            return(offsets[0]);
        }
Пример #2
0
 private Mesh SelectClosestPanel(Mesh m, Plane plane)
 {
     if (m.DisjointMeshCount > 1)
     {
         double minDist = double.MaxValue;
         Mesh   closest = new Mesh();
         foreach (Mesh d in m.SplitDisjointPieces())
         {
             Point3d centroid = CaveTools.averagePoint(d);
             if (centroid.DistanceTo(plane.ClosestPoint(centroid)) < minDist)
             {
                 minDist = centroid.DistanceTo(plane.ClosestPoint(centroid));
                 closest = d;
             }
         }
         return(closest);
     }
     else
     {
         return(m);
     }
 }