Example #1
0
        //--------------------------------------------------------------------------------------------------

        public static List <TopoDS_Solid> Solids(this TopoDS_Shape shape, bool distinct = true)
        {
            var solids = new List <TopoDS_Solid>();

            var exp = new TopExp_Explorer(shape, TopAbs_ShapeEnum.TopAbs_SOLID, TopAbs_ShapeEnum.TopAbs_SHAPE);

            while (exp.More())
            {
                var solid = TopoDS.Solid(exp.Current());
                exp.Next();

                if (distinct)
                {
                    if (solids.Any(e => e.IsSame(solid)))
                    {
                        continue;
                    }
                }
                solids.Add(solid);
            }
            return(solids);
        }
Example #2
0
        //--------------------------------------------------------------------------------------------------

        public static TopoDS_Solid ToSolid(this TopoDS_Shape shape)
        {
            return(shape == null ? null : TopoDS.Solid(shape));
        }