コード例 #1
0
        public static List <TopoDS_CompSolid> CompSolids(this TopoDS_Shape shape, bool distinct = true)
        {
            var compSolids = new List <TopoDS_CompSolid>();

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

            while (exp.More())
            {
                var compSolid = TopoDS.CompSolid(exp.Current());
                exp.Next();

                if (distinct)
                {
                    if (compSolids.Any(e => e.IsSame(compSolid)))
                    {
                        continue;
                    }
                }
                compSolids.Add(compSolid);
            }
            return(compSolids);
        }