public override bool CustomGeometryFilter(IRhinoObject obj, IOnGeometry geo, OnCOMPONENT_INDEX ci)
        {
            if (geo != null)
            {
                IOnCurve crv = OnCurve.ConstCast(geo);
                if (crv != null)
                {
                    if (crv.IsClosed() && crv.IsPlanar())
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                IOnBrep brep = OnBrep.ConstCast(geo);
                if (brep != null)
                {
                    if (brep.m_F.Count() == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                IOnSurface srf = OnSurface.ConstCast(geo);
                if (srf != null)
                {
                    return(true);
                }

                IOnMesh mesh = OnMesh.ConstCast(geo);
                if (mesh != null)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        private static double GetCurveArea(IOnCurve crv, double tol)
        {
            double area = 0.0;

            if (null != crv && crv.IsClosed())
            {
                OnPlane plane = new OnPlane();
                if (crv.IsPlanar(plane, tol))
                {
                    OnBoundingBox    bbox  = crv.BoundingBox();
                    On3dPoint        point = plane.ClosestPointTo(bbox.Center());
                    OnMassProperties mp    = new OnMassProperties();
                    if (crv.AreaMassProperties(point, plane.Normal(), ref mp))
                    {
                        area = Math.Abs(mp.Area());
                    }
                }
            }
            return(area);
        }
 private static double GetCurveArea(IOnCurve crv, double tol)
 {
     double area = 0.0;
       if (null != crv && crv.IsClosed())
       {
     OnPlane plane = new OnPlane();
     if (crv.IsPlanar(plane, tol))
     {
       OnBoundingBox bbox = crv.BoundingBox();
       On3dPoint point = plane.ClosestPointTo(bbox.Center());
       OnMassProperties mp = new OnMassProperties();
       if (crv.AreaMassProperties(point, plane.Normal(), ref mp))
     area = Math.Abs(mp.Area());
     }
       }
       return area;
 }