Пример #1
0
        public static Face3D Transform(this Transform transform, Face3D face3D, bool convertUnits = true)
        {
            if (transform == null || face3D == null)
                return null;

            if (transform.IsIdentity)
                return new Face3D(face3D);

            Spatial.Plane plane = Transform(transform, face3D.GetPlane());
            if (plane == null)
                return null;

            Planar.IClosed2D externalEdge2D = plane.Convert(Transform(transform, face3D.GetExternalEdge3D(), convertUnits));
            if (externalEdge2D == null)
                return null;

            List<Planar.IClosed2D> internalEdges2D = null;

            List<IClosedPlanar3D> internalEdges3D = face3D.GetInternalEdge3Ds();
            if(internalEdges3D != null)
            {
                internalEdges2D = new List<Planar.IClosed2D>();
                foreach (IClosedPlanar3D internalEdge3D in internalEdges3D)
                {
                    Planar.IClosed2D internalEdge2D = plane.Convert(Transform(transform, internalEdge3D, convertUnits));
                    if (internalEdge2D == null)
                        continue;

                    internalEdges2D.Add(internalEdge2D);
                }
            }

            return Face3D.Create(plane, externalEdge2D, internalEdges2D, EdgeOrientationMethod.Undefined);
        }
Пример #2
0
        public static HoneybeeSchema.Face3D ToLadybugTools(this Face3D face3D)
        {
            if (face3D == null)
            {
                return(null);
            }

            ISegmentable3D externalEdge = face3D.GetExternalEdge3D() as ISegmentable3D;

            if (externalEdge == null)
            {
                throw new System.NotImplementedException();
            }

            List <Point3D> point3Ds = externalEdge.GetPoints();

            if (point3Ds == null || point3Ds.Count < 3)
            {
                return(null);
            }

            List <List <double> > boundary = ToLadybugTools(point3Ds);

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

            List <List <List <double> > > holes         = new List <List <List <double> > >();
            List <IClosedPlanar3D>        internalEdges = face3D.GetInternalEdge3Ds();

            if (internalEdges != null && internalEdges.Count > 0)
            {
                foreach (IClosedPlanar3D internalEdge_Temp in internalEdges)
                {
                    ISegmentable3D internalEdge = internalEdge_Temp as ISegmentable3D;
                    if (internalEdge == null)
                    {
                        throw new System.NotImplementedException();
                    }

                    point3Ds = internalEdge.GetPoints();
                    if (point3Ds == null || point3Ds.Count < 3)
                    {
                        continue;
                    }

                    List <List <double> > hole = ToLadybugTools(point3Ds);
                    if (hole == null || hole.Count == 0)
                    {
                        continue;
                    }

                    holes.Add(hole);
                }
            }

            return(new HoneybeeSchema.Face3D(boundary, holes));
        }
Пример #3
0
        public static HashSet <Point3D> ExternalEdgePoint3Ds(this Face3D face3D, double tolerance = Core.Tolerance.Distance)
        {
            if (face3D == null)
            {
                return(null);
            }

            Face3D face3D_Temp = new Face3D(face3D);

            face3D_Temp.Normalize(tolerance);

            ISegmentable3D externalEdge = face3D_Temp.GetExternalEdge3D() as ISegmentable3D;

            if (externalEdge == null)
            {
                throw new NotImplementedException();
            }

            List <Point3D> point3Ds = externalEdge.GetPoints();

            if (point3Ds == null)
            {
                return(null);
            }

            //Vector3D normal = face3D.GetPlane().Normal;
            //if (normal == null)
            //    return null;

            //ISegmentable3D externalEdge = face3D.GetExternalEdge3D() as ISegmentable3D;
            //if (externalEdge == null)
            //    throw new NotImplementedException();

            //List<Point3D> point3Ds = externalEdge.GetPoints();
            //if (point3Ds == null)
            //    return null;

            //if (!Spatial.Query.Clockwise(point3Ds, normal, Core.Tolerance.Angle, tolerance))
            //    point3Ds.Reverse();

            HashSet <Point3D> result = new HashSet <Point3D>();

            if (point3Ds.Count == 0)
            {
                return(result);
            }

            for (int i = 0; i < point3Ds.Count; i++)
            {
                point3Ds[i].Round(tolerance);
                result.Add(point3Ds[i]);
            }

            return(result);
        }
Пример #4
0
        public static global::Topologic.Face ToTopologic(this Face3D face3D)
        {
            IClosedPlanar3D closedPlanar3D = face3D.GetExternalEdge3D();

            if (closedPlanar3D is ICurvable3D)
            {
                List <Edge> edges = new List <Edge>();
                foreach (ICurve3D curve3D in ((ICurvable3D)closedPlanar3D).GetCurves())
                {
                    Edge edge = Edge.ByStartVertexEndVertex(ToTopologic(curve3D.GetStart()), ToTopologic(curve3D.GetEnd()));
                    edges.Add(edge);
                }

                return(global::Topologic.Face.ByEdges(edges));
            }
            return(null);
        }
Пример #5
0
        public static TBD.Perimeter ToTBD(this Face3D face3D, TBD.RoomSurface roomSurface = null)
        {
            if (face3D == null)
            {
                return(null);
            }

            IClosedPlanar3D externalEdge3D = face3D.GetExternalEdge3D();

            if (externalEdge3D == null)
            {
                return(null);
            }

            ISegmentable3D segmentable3D = externalEdge3D as ISegmentable3D;

            if (segmentable3D == null)
            {
                throw new System.NotImplementedException();
            }

            TBD.Perimeter result = roomSurface?.CreatePerimeter();
            if (result == null)
            {
                result = new TBD.Perimeter();
            }

            TBD.Polygon polygon = result.CreateFace();

            List <Point3D> point3Ds = segmentable3D.GetPoints();

            if (point3Ds != null)
            {
                foreach (Point3D point3D in point3Ds)
                {
                    if (point3D == null)
                    {
                        continue;
                    }

                    polygon.AddCoordinate(System.Convert.ToSingle(point3D.X), System.Convert.ToSingle(point3D.Y), System.Convert.ToSingle(point3D.Z));
                }
            }

            List <IClosedPlanar3D> internalEdge3Ds = face3D.GetInternalEdge3Ds();

            if (internalEdge3Ds != null && internalEdge3Ds.Count != 0)
            {
                foreach (IClosedPlanar3D closedPlanar3D in internalEdge3Ds)
                {
                    if (closedPlanar3D == null)
                    {
                        continue;
                    }

                    segmentable3D = closedPlanar3D as ISegmentable3D;
                    if (segmentable3D == null)
                    {
                        throw new System.NotImplementedException();
                    }

                    polygon = result.AddHole();

                    point3Ds = segmentable3D.GetPoints();
                    if (point3Ds != null)
                    {
                        foreach (Point3D point3D in point3Ds)
                        {
                            if (point3D == null)
                            {
                                continue;
                            }

                            polygon.AddCoordinate(System.Convert.ToSingle(point3D.X), System.Convert.ToSingle(point3D.Y), System.Convert.ToSingle(point3D.Z));
                        }
                    }
                }
            }

            return(result);
        }