Example #1
0
        /// <summary>
        /// Calculates the area of an object
        /// </summary>
        public static double GetArea(IRhinoObject obj, double tol)
        {
            if (null != obj)
            {
                IOnCurve crv = OnCurve.ConstCast(obj.Geometry());
                if (null != crv)
                {
                    return(GetCurveArea(crv, tol));
                }

                IOnSurface srf = OnSurface.ConstCast(obj.Geometry());
                if (null != srf)
                {
                    return(GetSurfaceArea(srf));
                }

                IOnBrep brep = OnBrep.ConstCast(obj.Geometry());
                if (null != brep)
                {
                    return(GetBrepArea(brep));
                }

                IOnMesh mesh = OnMesh.ConstCast(obj.Geometry());
                if (null != mesh)
                {
                    return(GetMeshArea(mesh));
                }
            }
            return(0.0);
        }
        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);
        }
Example #3
0
        /// <summary>
        /// Calculates the volume of an object
        /// </summary>
        public static double GetVolume(IRhinoObject obj)
        {
            if (null != obj && obj.IsSolid())
            {
                IOnSurface srf = OnSurface.ConstCast(obj.Geometry());
                if (null != srf)
                {
                    return(GetSurfaceVolume(srf));
                }

                IOnBrep brep = OnBrep.ConstCast(obj.Geometry());
                if (null != brep)
                {
                    return(GetBrepVolume(brep));
                }

                IOnMesh mesh = OnMesh.ConstCast(obj.Geometry());
                if (null != mesh)
                {
                    return(GetMeshVolume(mesh));
                }
            }
            return(0.0);
        }