static DB.GeometryObject ToShape(SubD subD, double factor)
        {
            // Try using DB.BRepBuilder
            if (SubDEncoder.ToSolid(subD, factor) is DB.Solid solid)
            {
                return(solid);
            }

            Debug.WriteLine("Try meshing the subD.");
            return(SubDEncoder.ToMesh(subD, factor));
        }
        public static DB.GeometryObject[] ToShape(this GeometryBase geometry, double factor)
        {
            switch (geometry)
            {
            case Point point:
                return(new DB.GeometryObject[] { point.ToPoint(factor) });

            case PointCloud pointCloud:
                return(pointCloud.ToPoints(factor));

            case Curve curve:
                return(curve.ToCurveMany(factor).SelectMany(x => x.ToBoundedCurves()).OfType <DB.GeometryObject>().ToArray());

            case Brep brep:
                return(ToGeometryObjectMany(BrepEncoder.ToRawBrep(brep, factor)).OfType <DB.GeometryObject>().ToArray());

            case Extrusion extrusion:
                return(ToGeometryObjectMany(ExtrusionEncoder.ToRawBrep(extrusion, factor)).OfType <DB.GeometryObject>().ToArray());

            case SubD subD:
                return(ToGeometryObjectMany(SubDEncoder.ToRawBrep(subD, factor)).OfType <DB.GeometryObject>().ToArray());;

            case Mesh mesh:
                return(new DB.GeometryObject[] { MeshEncoder.ToMesh(MeshEncoder.ToRawMesh(mesh, factor)) });

            default:
                if (geometry.HasBrepForm)
                {
                    var brepForm = Brep.TryConvertBrep(geometry);
                    if (BrepEncoder.EncodeRaw(ref brepForm, factor))
                    {
                        return(ToGeometryObjectMany(brepForm).OfType <DB.GeometryObject>().ToArray());
                    }
                }

                return(new DB.GeometryObject[0]);
            }
        }