Ejemplo n.º 1
0
        public static Spatial.Shell ToSAM(this global::Topologic.Shell shell)
        {
            if (shell == null)
            {
                return(null);
            }

            IList <global::Topologic.Face> faces = shell.Faces;

            if (faces == null || faces.Count == 0)
            {
                return(null);
            }

            List <Face3D> face3Ds = new List <Face3D>();

            foreach (global::Topologic.Face face in faces)
            {
                Face3D face3D = face.ToSAM();
                if (face3D == null)
                {
                    continue;
                }

                face3Ds.Add(face3D);
            }

            return(new Spatial.Shell(face3Ds));
        }
Ejemplo n.º 2
0
        public static global::Topologic.Shell ToTopologic(this Spatial.Shell shell, double tolerance = Core.Tolerance.Distance)
        {
            List <Face3D> face3Ds = shell?.Face3Ds;

            if (face3Ds == null || face3Ds.Count == 0)
            {
                return(null);
            }

            global::Topologic.Shell result = global::Topologic.Shell.ByFaces(face3Ds.ConvertAll(x => x.ToTopologic()), tolerance);

            return(result);
        }
Ejemplo n.º 3
0
        internal static PolySurface PolySurface(global::Topologic.Shell shell)
        {
            List <global::Topologic.Face> faces = shell.Faces;
            List <ISurface> bhomSurfaces        = new List <ISurface>();

            foreach (global::Topologic.Face face in faces)
            {
                bhomSurfaces.Add(Convert.PlanarSurface(face));
            }
            return(new PolySurface {
                Surfaces = bhomSurfaces
            });
        }
Ejemplo n.º 4
0
        public static Cell ToTopologic_Cell(this Spatial.Shell shell, double tolerance = Core.Tolerance.Distance)
        {
            List <Face3D> face3Ds = shell?.Face3Ds;

            if (face3Ds == null || face3Ds.Count == 0)
            {
                return(null);
            }

            Cell result = null;

            try
            {
                result = Cell.ByFaces(face3Ds.ConvertAll(x => x.ToTopologic()), tolerance);
            }
            catch
            {
                result = null;
            }

            if (result != null)
            {
                return(result);
            }

            global::Topologic.Shell shell_Topologic = shell.ToTopologic(tolerance);
            if (shell_Topologic == null)
            {
                return(result);
            }

            try
            {
                result = Cell.ByShell(shell_Topologic);
            }
            catch
            {
                result = null;
            }

            return(result);
        }
Ejemplo n.º 5
0
        private static global::Topologic.Topology TopologyByMesh(Mesh bhomMesh)
        {
            global::Topologic.Shell shell = Create.ShellByMesh(bhomMesh);
            if (shell == null)
            {
                return(null);
            }

            List <global::Topologic.Face> faces = shell.Faces;

            if (faces.Count == 0)
            {
                return(null);
            }
            else if (faces.Count == 1)
            {
                return(faces[0]);
            }

            // else
            return(shell);
        }
Ejemplo n.º 6
0
        public static Topology ToTopologic(this Brep brep, double tolerance = Core.Tolerance.Distance)
        {
            if (brep == null)
            {
                return(null);
            }

            BrepFaceList ghBrepFaces            = brep.Faces;
            List <global::Topologic.Face> faces = new List <global::Topologic.Face>();

            foreach (BrepFace ghBrepFace in ghBrepFaces)
            {
                global::Topologic.Face face = ghBrepFace.ToTopologic();
                faces.Add(face);
            }

            if (faces.Count == 0)
            {
                return(null);
            }
            else if (faces.Count == 1)
            {
                return(faces[0]);
            }
            else
            {
                global::Topologic.Shell shell = global::Topologic.Shell.ByFaces(faces, tolerance);
                if (brep.IsSolid)
                {
                    Cell cell = Cell.ByShell(shell);
                    return(cell);
                }

                return(shell);
            }
        }
Ejemplo n.º 7
0
        internal static IGeometry BasicGeometry(global::Topologic.Topology topology)
        {
            if (topology == null)
            {
                return(null);
            }

            global::Topologic.Vertex vertex = topology as global::Topologic.Vertex;
            if (vertex != null)
            {
                return(Convert.BasicGeometry(vertex));
            }

            global::Topologic.Edge edge = topology as global::Topologic.Edge;
            if (edge != null)
            {
                return(Convert.BasicGeometry(edge));
            }

            global::Topologic.Wire wire = topology as global::Topologic.Wire;
            if (wire != null)
            {
                return(Convert.BasicGeometry(wire));
            }

            global::Topologic.Face face = topology as global::Topologic.Face;
            if (face != null)
            {
                return(Convert.BasicGeometry(face));
            }

            global::Topologic.Shell shell = topology as global::Topologic.Shell;
            if (shell != null)
            {
                return(Convert.BasicGeometry(shell));
            }

            global::Topologic.Cell cell = topology as global::Topologic.Cell;
            if (cell != null)
            {
                return(Convert.BasicGeometry(cell));
            }

            global::Topologic.CellComplex cellComplex = topology as global::Topologic.CellComplex;
            if (cellComplex != null)
            {
                return(Convert.BasicGeometry(cellComplex));
            }

            global::Topologic.Cluster cluster = topology as global::Topologic.Cluster;
            if (cluster != null)
            {
                return(Convert.BasicGeometry(cluster));
            }

            //global::Topologic.Aperture aperture = topology as global::Topologic.Aperture;
            //if (aperture != null)
            //{
            //    return Aperture.Convert.BasicGeometry(aperture);
            //}

            throw new NotImplementedException("Geometry for this shape is not supported yet");
        }
Ejemplo n.º 8
0
 public static List <global::Topologic.Vertex> Vertices(global::Topologic.Shell shell)
 {
     return(shell.Vertices);
 }
Ejemplo n.º 9
0
 public static bool IsClosed(global::Topologic.Shell shell)
 {
     return(shell.IsClosed);
 }
Ejemplo n.º 10
0
 public static List <global::Topologic.Edge> Edges(global::Topologic.Shell shell)
 {
     return(shell.Edges);
 }
Ejemplo n.º 11
0
 public static List <global::Topologic.Wire> Wires(global::Topologic.Shell shell)
 {
     return(shell.Wires);
 }
Ejemplo n.º 12
0
 public static List <global::Topologic.Face> Faces(global::Topologic.Shell shell)
 {
     return(shell.Faces);
 }
Ejemplo n.º 13
0
 public static List <global::Topologic.Cell> Cells(global::Topologic.Shell shell)
 {
     return(shell.Cells);
 }
Ejemplo n.º 14
0
 internal static IGeometry BasicGeometry(global::Topologic.Shell shell)
 {
     return(PolySurface(shell));
 }
Ejemplo n.º 15
0
 public static global::Topologic.Cell CellByShell(global::Topologic.Shell shell)
 {
     return(global::Topologic.Cell.ByShell(shell));
 }