コード例 #1
0
ファイル: Perimeter.cs プロジェクト: HoareLea/SAM_Tas
        public static TBD.Perimeter ToTBD_Perimeter(this Polygon3D polygon3D)
        {
            if (polygon3D == null)
            {
                return(null);
            }

            TBD.Perimeter result  = new TBD.Perimeter();
            TBD.Polygon   polygon = result.CreateFace();

            List <Point3D> point3Ds = polygon3D.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);
        }
コード例 #2
0
        public static TBD.Perimeter ToTAS(this BHG.Polyline polyline, TBD.Perimeter tbdPerimeter)
        {
            if (polyline == null)
            {
                return(tbdPerimeter);
            }

            TBD.Polygon poly = tbdPerimeter.CreateFace();
            poly = polyline.ToTASPolygon(poly);

            return(tbdPerimeter);
        }
コード例 #3
0
ファイル: Face3D.cs プロジェクト: HoareLea/SAM_Tas
        public static Face3D ToSAM(this TBD.Perimeter perimeter)
        {
            if (perimeter == null)
            {
                return(null);
            }

            Polygon3D externalEdge3D = perimeter.GetFace()?.ToSAM();

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

            Plane plane = externalEdge3D.GetPlane();

            List <Planar.IClosed2D> internalEdge2Ds = null;

            List <TBD.Polygon> holes = perimeter.Holes();

            if (holes != null)
            {
                internalEdge2Ds = new List <Planar.IClosed2D>();
                foreach (TBD.Polygon hole in holes)
                {
                    Polygon3D internalEdge3D = hole?.ToSAM();
                    if (internalEdge3D == null)
                    {
                        continue;
                    }

                    Planar.Polygon2D internalEdge2D = plane.Convert(internalEdge3D);

                    internalEdge2Ds.Add(internalEdge2D);
                }
            }

            Planar.Face2D face2D = Planar.Create.Face2D(plane.Convert(externalEdge3D), internalEdge2Ds);
            if (face2D == null)
            {
                return(null);
            }

            return(plane.Convert(face2D));
        }
コード例 #4
0
        /***************************************************/

        public static float MinElevation(TBD.Perimeter tbdPerimeter)
        {
            TBD.Polygon tbdPolygon   = tbdPerimeter.GetFace();
            int         indexepoints = 0;
            float       aZvalue      = float.MaxValue;

            TBD.TasPoint TasPoint = tbdPolygon.GetPoint(indexepoints);
            while (TasPoint != null)
            {
                if (TasPoint.z < aZvalue)
                {
                    aZvalue = TasPoint.z;
                }
                indexepoints++;
                TasPoint = tbdPolygon.GetPoint(indexepoints);
            }

            return(aZvalue);
        }
コード例 #5
0
ファイル: Holes.cs プロジェクト: HoareLea/SAM_Tas
        public static List <TBD.Polygon> Holes(this TBD.Perimeter perimeter)
        {
            if (perimeter == null)
            {
                return(null);
            }

            List <TBD.Polygon> result = new List <TBD.Polygon>();

            int index = 0;

            TBD.Polygon polygon = perimeter.GetHole(index);
            while (polygon != null)
            {
                result.Add(polygon);
                index++;

                polygon = perimeter.GetHole(index);
            }

            return(result);
        }
コード例 #6
0
 public static BHG.Polyline FromTAS(this TBD.Perimeter tbdPerimeter)
 {
     return(tbdPerimeter.GetFace().FromTAS());
 }
コード例 #7
0
ファイル: Perimeter.cs プロジェクト: HoareLea/SAM_Tas
        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);
        }
コード例 #8
0
ファイル: Panel.cs プロジェクト: BHoM/TAS_Toolkit
        public static BHE.Panel FromTAS(this TBD.buildingElement tbdElement, TBD.zoneSurface tbdSurface, TASSettings tasSettings)
        {
            BHE.Panel element = new BHE.Panel();

            TBD.BuildingElementType tbdElementType = ((TBD.BuildingElementType)tbdElement.BEType);
            TASPanelData            tasData        = new TASPanelData();

            tasData.PanelIsOpening = tbdElementType.ElementIsOpening();

            //Add a flag on the element for the final read
            if (tbdElementType.ElementIsOpening())
            {
                //Find out what the fix was - frame or pane?
                BHE.OpeningType fixedOpeningType = tbdElementType.FromTASOpeningType().FixBuildingElementType(tbdElement, tbdSurface);
                tasData.OpeningIsFrame = fixedOpeningType.OpeningIsFrame();
            }

            BHE.PanelType     elementType         = ((TBD.BuildingElementType)tbdElement.BEType).FromTAS();
            BHPC.Construction elementConstruction = tbdElement.GetConstruction().FromTAS();

            element.Name         = tbdElement.name;
            element.Type         = elementType;
            element.Construction = elementConstruction;

            element.Fragments.Add(tasData);

            //EnvironmentContextProperties
            BHP.OriginContextFragment environmentContextProperties = new BHP.OriginContextFragment();
            environmentContextProperties.ElementID   = tbdSurface.GUID.RemoveBrackets();
            environmentContextProperties.Description = tbdElement.description;
            environmentContextProperties.TypeName    = tbdSurface.buildingElement.name;
            element.Fragments.Add(environmentContextProperties);

            //BuildingElementContextProperties
            BHP.PanelContextFragment buildingElementContextProperties = new BHP.PanelContextFragment();
            element.ConnectedSpaces.Add(tbdSurface.zone.name);
            if ((int)tbdSurface.type == 3)
            {
                element.ConnectedSpaces.Add(tbdSurface.linkSurface.zone.name);
            }
            else
            {
                element.ConnectedSpaces.Add("-1");
            }

            buildingElementContextProperties.IsAir    = tbdElement.ghost != 0;
            buildingElementContextProperties.IsGround = tbdElement.ground != 0;
            buildingElementContextProperties.Colour   = BH.Engine.Adapters.TAS.Query.GetRGB(tbdElement.colour).ToString();
            buildingElementContextProperties.Reversed = tbdSurface.reversed != 0;
            element.Fragments.Add(buildingElementContextProperties);

            //BuildingElementAnalyticalProperties
            BHP.PanelAnalyticalFragment buildingElementAnalyticalProperties = new BHP.PanelAnalyticalFragment();
            buildingElementAnalyticalProperties.Altitude      = tbdSurface.altitude.Round();
            buildingElementAnalyticalProperties.AltitudeRange = tbdSurface.altitudeRange.Round();
            buildingElementAnalyticalProperties.Inclination   = tbdSurface.inclination.Round();
            buildingElementAnalyticalProperties.Orientation   = tbdSurface.orientation.Round();
            buildingElementAnalyticalProperties.GValue        = tbdElement.GValue().Round();
            buildingElementAnalyticalProperties.LTValue       = tbdElement.LTValue().Round();
            buildingElementAnalyticalProperties.UValue        = tbdElement.UValue().Round();
            element.Fragments.Add(buildingElementAnalyticalProperties);

            List <BHG.Polyline> panelCurve = new List <BHG.Polyline>();
            int surfaceIndex = 0;

            TBD.RoomSurface roomSurface = null;

            while ((roomSurface = tbdSurface.GetRoomSurface(surfaceIndex)) != null)
            {
                TBD.Perimeter tbdPerimeter = roomSurface.GetPerimeter();
                if (tbdPerimeter != null)
                {
                    panelCurve.Add(tbdPerimeter.FromTAS());

                    //Add openings
                    int         openingIndex   = 0;
                    TBD.Polygon openingPolygon = null;
                    while ((openingPolygon = tbdPerimeter.GetHole(openingIndex)) != null)
                    {
                        element.Openings.Add(openingPolygon.FromTASOpening(roomSurface, tasSettings));
                        openingIndex++;
                    }
                }

                surfaceIndex++;
            }

            if (panelCurve.Count == 1)
            {
                element.ExternalEdges = panelCurve.First().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges();
            }
            else
            {
                try
                {
                    List <BHG.Polyline> polylines = Geometry.Compute.BooleanUnion(panelCurve, 1e-3);
                    if (polylines.Count == 1)
                    {
                        element.ExternalEdges = polylines.First().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges();
                    }
                    else
                    {
                        element.ExternalEdges = Geometry.Create.PolyCurve(polylines).ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges();
                    }
                }
                catch (Exception e)
                {
                    BH.Engine.Base.Compute.RecordWarning("An error occurred in building buildingElement ID - " + element.BHoM_Guid + " - error was: " + e.ToString());
                    element.ExternalEdges = Geometry.Create.PolyCurve(panelCurve).ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges();
                }
            }

            tasData.TASID                   = tbdSurface.GUID.RemoveBrackets();
            tasData.TASName                 = "Z_" + tbdSurface.zone.number + "_" + tbdSurface.number + "_" + tbdSurface.zone.name;
            tasData.Type                    = System.Convert.ToString(tbdSurface.type);
            tasData.Area                    = tbdSurface.area.Round();
            tasData.InternalArea            = tbdSurface.internalArea.Round();
            tasData.Width                   = tbdElement.width.Round();
            tasData.MaterialLayersThickness = tbdElement.GetConstruction().ConstructionThickness().Round();

            element.Fragments.Add(tasData);

            //AddingExtended Properties for a frame
            BHE.OpeningType elementOpeningType = tbdElementType.FromTASOpeningType().FixBuildingElementType(tbdElement, tbdSurface);
            if (elementOpeningType == BHE.OpeningType.RooflightWithFrame || elementOpeningType == BHE.OpeningType.WindowWithFrame)
            {
                if (element.Openings.FirstOrDefault() != null)
                {
                    element.Openings[0].FrameConstruction = elementConstruction;
                }
            }

            return(element);
        }
コード例 #9
0
        public static TBD.Building ToTBD(this AnalyticalModel analyticalModel, TBD.TBDDocument tBDDocument)
        {
            if (analyticalModel == null)
            {
                return(null);
            }

            TBD.Building result = tBDDocument.Building;
            if (result == null)
            {
                return(null);
            }

            AdjacencyCluster adjacencyCluster = analyticalModel.AdjacencyCluster;

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

            List <Space> spaces = adjacencyCluster.GetSpaces();

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

            MaterialLibrary materialLibrary = analyticalModel.MaterialLibrary;

            Plane plane = Plane.WorldXY;

            List <TBD.DaysShade> daysShades = new List <TBD.DaysShade>();

            result.ClearShadingData();

            Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Panel    = new Dictionary <System.Guid, List <TBD.zoneSurface> >();
            Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Aperture = new Dictionary <System.Guid, List <TBD.zoneSurface> >();

            foreach (Space space in spaces)
            {
                Shell shell = adjacencyCluster.Shell(space);
                if (shell == null)
                {
                    return(null);
                }

                TBD.zone zone = result.AddZone();
                zone.name   = space.Name;
                zone.volume = System.Convert.ToSingle(shell.Volume());

                if (space.TryGetValue(SpaceParameter.Color, out SAMColor sAMColor) && sAMColor != null)
                {
                    zone.colour = Core.Convert.ToUint(sAMColor.ToColor());
                }

                List <Face3D> face3Ds = Geometry.Spatial.Query.Section(shell, 0.01, false);
                if (face3Ds != null && face3Ds.Count != 0)
                {
                    face3Ds.RemoveAll(x => x == null || !x.IsValid());
                    zone.floorArea        = System.Convert.ToSingle(face3Ds.ConvertAll(x => x.GetArea()).Sum());
                    zone.exposedPerimeter = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Planar.Query.Perimeter(x.ExternalEdge2D)).Sum());
                    zone.length           = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Tas.Query.Length(x)).Sum());
                }

                TBD.room room = zone.AddRoom();

                List <TBD.buildingElement> buildingElements = result.BuildingElements();
                List <TBD.Construction>    constructions    = result.Constructions();

                List <Panel> panels = adjacencyCluster?.GetPanels(space);
                if (panels != null || panels.Count != 0)
                {
                    foreach (Panel panel in panels)
                    {
                        string name_Panel = panel.Name;
                        if (string.IsNullOrWhiteSpace(name_Panel))
                        {
                            continue;
                        }

                        Face3D face3D_Panel = panel.Face3D;
                        if (face3D_Panel == null)
                        {
                            continue;
                        }

                        BoundingBox3D boundingBox3D_Panel = face3D_Panel.GetBoundingBox();

                        TBD.zoneSurface zoneSurface_Panel = zone.AddSurface();
                        zoneSurface_Panel.orientation = System.Convert.ToSingle(Geometry.Spatial.Query.Azimuth(panel, Vector3D.WorldY));
                        zoneSurface_Panel.inclination = System.Convert.ToSingle(Geometry.Spatial.Query.Tilt(panel));

                        zoneSurface_Panel.altitude              = System.Convert.ToSingle(boundingBox3D_Panel.GetCentroid().Z);
                        zoneSurface_Panel.altitudeRange         = System.Convert.ToSingle(boundingBox3D_Panel.Max.Z - boundingBox3D_Panel.Min.Z);
                        zoneSurface_Panel.area                  = System.Convert.ToSingle(face3D_Panel.GetArea());
                        zoneSurface_Panel.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Panel));

                        TBD.RoomSurface roomSurface_Panel = room.AddSurface();
                        roomSurface_Panel.area        = zoneSurface_Panel.area;
                        roomSurface_Panel.zoneSurface = zoneSurface_Panel;

                        Geometry.SolarCalculator.SolarFaceSimulationResult solarFaceSimulationResult = analyticalModel.GetResults <Geometry.SolarCalculator.SolarFaceSimulationResult>(panel)?.FirstOrDefault();
                        if (solarFaceSimulationResult != null)
                        {
                            List <TBD.SurfaceShade> surfaceShades = Modify.UpdateSurfaceShades(result, daysShades, zoneSurface_Panel, analyticalModel, solarFaceSimulationResult);
                        }

                        TBD.Perimeter perimeter_Panel = Geometry.Tas.Convert.ToTBD(panel.GetFace3D(true), roomSurface_Panel);
                        if (perimeter_Panel == null)
                        {
                            continue;
                        }

                        PanelType panelType = panel.PanelType;

                        TBD.buildingElement buildingElement_Panel = buildingElements.Find(x => x.name == name_Panel);
                        if (buildingElement_Panel == null)
                        {
                            TBD.Construction construction_TBD = null;

                            Construction construction = panel.Construction;
                            if (construction != null)
                            {
                                construction_TBD = constructions.Find(x => x.name == construction.Name);
                                if (construction_TBD == null)
                                {
                                    construction_TBD      = result.AddConstruction(null);
                                    construction_TBD.name = construction.Name;

                                    if (construction.Transparent(materialLibrary))
                                    {
                                        construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                                    }

                                    List <ConstructionLayer> constructionLayers = construction.ConstructionLayers;
                                    if (constructionLayers != null && constructionLayers.Count != 0)
                                    {
                                        int index = 1;
                                        foreach (ConstructionLayer constructionLayer in constructionLayers)
                                        {
                                            Material material = analyticalModel?.MaterialLibrary?.GetMaterial(constructionLayer.Name) as Core.Material;
                                            if (material == null)
                                            {
                                                continue;
                                            }

                                            TBD.material material_TBD = construction_TBD.AddMaterial(material);
                                            if (material_TBD != null)
                                            {
                                                material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness);
                                                construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness);
                                                index++;
                                            }
                                        }
                                    }

                                    constructions.Add(construction_TBD);
                                }

                                if (panelType == PanelType.Undefined && construction != null)
                                {
                                    panelType = construction.PanelType();
                                    if (panelType == PanelType.Undefined && construction.TryGetValue(ConstructionParameter.DefaultPanelType, out string panelTypeString))
                                    {
                                        panelType = Core.Query.Enum <PanelType>(panelTypeString);
                                    }
                                }
                            }

                            buildingElement_Panel        = result.AddBuildingElement();
                            buildingElement_Panel.name   = name_Panel;
                            buildingElement_Panel.colour = Core.Convert.ToUint(Analytical.Query.Color(panelType));
                            buildingElement_Panel.BEType = Query.BEType(panelType.Text());
                            buildingElement_Panel.AssignConstruction(construction_TBD);
                            buildingElements.Add(buildingElement_Panel);
                        }

                        if (buildingElement_Panel != null)
                        {
                            zoneSurface_Panel.buildingElement = buildingElement_Panel;
                        }

                        zoneSurface_Panel.type = TBD.SurfaceType.tbdExposed;

                        List <Aperture> apertures = panel.Apertures;
                        if (apertures != null && apertures.Count != 0)
                        {
                            bool @internal = adjacencyCluster.Internal(panel);

                            foreach (Aperture aperture in apertures)
                            {
                                string name_Aperture = aperture.Name;
                                if (string.IsNullOrWhiteSpace(name_Aperture))
                                {
                                    continue;
                                }

                                name_Aperture = string.Format("{0} -pane", aperture.Name);

                                Face3D face3D_Aperture = aperture.Face3D;
                                if (face3D_Aperture == null)
                                {
                                    continue;
                                }

                                BoundingBox3D boundingBox3D_Aperture = face3D_Aperture.GetBoundingBox();

                                float area = System.Convert.ToSingle(face3D_Aperture.GetArea());

                                TBD.zoneSurface zoneSurface_Aperture = zoneSurface_Panel.AddChildSurface(area);
                                if (zoneSurface_Aperture == null)
                                {
                                    continue;
                                }

                                zoneSurface_Aperture.orientation           = zoneSurface_Panel.orientation;
                                zoneSurface_Aperture.inclination           = zoneSurface_Panel.inclination;
                                zoneSurface_Aperture.altitude              = System.Convert.ToSingle(boundingBox3D_Aperture.GetCentroid().Z);
                                zoneSurface_Aperture.altitudeRange         = System.Convert.ToSingle(boundingBox3D_Aperture.Max.Z - boundingBox3D_Aperture.Min.Z);
                                zoneSurface_Aperture.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Aperture));
                                //zoneSurface_Aperture.area = System.Convert.ToSingle(face3D_Aperture.GetArea());

                                zoneSurface_Aperture.type = @internal ? TBD.SurfaceType.tbdLink : zoneSurface_Panel.type;

                                TBD.RoomSurface roomSurface_Aperture = room.AddSurface();
                                roomSurface_Aperture.area        = zoneSurface_Aperture.area;
                                roomSurface_Aperture.zoneSurface = zoneSurface_Aperture;

                                TBD.Perimeter perimeter_Aperture = Geometry.Tas.Convert.ToTBD(face3D_Aperture, roomSurface_Aperture);
                                if (perimeter_Aperture == null)
                                {
                                    continue;
                                }

                                TBD.buildingElement buildingElement_Aperture = buildingElements.Find(x => x.name == name_Aperture);
                                if (buildingElement_Aperture == null)
                                {
                                    TBD.Construction construction_TBD = null;

                                    ApertureConstruction apertureConstruction = aperture.ApertureConstruction;
                                    if (apertureConstruction != null)
                                    {
                                        construction_TBD = constructions.Find(x => x.name == apertureConstruction.Name);
                                        if (construction_TBD == null)
                                        {
                                            construction_TBD      = result.AddConstruction(null);
                                            construction_TBD.name = name_Aperture;

                                            if (apertureConstruction.Transparent(materialLibrary))
                                            {
                                                construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                                            }

                                            List <ConstructionLayer> constructionLayers = apertureConstruction.PaneConstructionLayers;
                                            if (constructionLayers != null && constructionLayers.Count != 0)
                                            {
                                                int index = 1;
                                                foreach (ConstructionLayer constructionLayer in constructionLayers)
                                                {
                                                    Core.Material material = materialLibrary?.GetMaterial(constructionLayer.Name) as Material;
                                                    if (material == null)
                                                    {
                                                        continue;
                                                    }

                                                    TBD.material material_TBD = construction_TBD.AddMaterial(material);
                                                    if (material_TBD != null)
                                                    {
                                                        material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness);
                                                        construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness);
                                                        index++;
                                                    }
                                                }
                                            }

                                            constructions.Add(construction_TBD);
                                        }
                                    }

                                    ApertureType apertureType = aperture.ApertureType;

                                    buildingElement_Aperture        = result.AddBuildingElement();
                                    buildingElement_Aperture.name   = name_Aperture;
                                    buildingElement_Aperture.colour = Core.Convert.ToUint(Analytical.Query.Color(apertureType));
                                    buildingElement_Aperture.BEType = Query.BEType(apertureType, false);
                                    buildingElement_Aperture.AssignConstruction(construction_TBD);
                                    buildingElements.Add(buildingElement_Aperture);
                                }

                                if (buildingElement_Aperture != null)
                                {
                                    zoneSurface_Aperture.buildingElement = buildingElement_Aperture;
                                }

                                if (!dictionary_Aperture.TryGetValue(aperture.Guid, out List <TBD.zoneSurface> zoneSurfaces_Aperture) || zoneSurfaces_Aperture == null)
                                {
                                    zoneSurfaces_Aperture = new List <TBD.zoneSurface>();
                                    dictionary_Aperture[aperture.Guid] = zoneSurfaces_Aperture;
                                }

                                zoneSurfaces_Aperture.Add(zoneSurface_Aperture);
                            }
                        }

                        zoneSurface_Panel.type = Query.SurfaceType(panelType);

                        if (!dictionary_Panel.TryGetValue(panel.Guid, out List <TBD.zoneSurface> zoneSurfaces_Panel) || zoneSurfaces_Panel == null)
                        {
                            zoneSurfaces_Panel           = new List <TBD.zoneSurface>();
                            dictionary_Panel[panel.Guid] = zoneSurfaces_Panel;
                        }

                        zoneSurfaces_Panel.Add(zoneSurface_Panel);
                    }
                }
            }

            foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Panel)
            {
                if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1)
                {
                    continue;
                }

                keyValuePair.Value[1].linkSurface = keyValuePair.Value[0];
                keyValuePair.Value[0].linkSurface = keyValuePair.Value[1];

                if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180)
                {
                    float inclination = keyValuePair.Value[1].inclination;
                    inclination -= 180;
                    if (inclination < 0)
                    {
                        inclination += 360;
                    }

                    keyValuePair.Value[1].inclination = inclination;
                    keyValuePair.Value[1].reversed    = 1;
                }
                else
                {
                    float orientation = keyValuePair.Value[1].orientation;
                    orientation += 180;
                    if (orientation >= 360)
                    {
                        orientation -= 360;
                    }

                    keyValuePair.Value[1].orientation = orientation;
                    keyValuePair.Value[1].reversed    = 1;

                    float inclination = keyValuePair.Value[1].inclination;
                    if (inclination > 180)
                    {
                        inclination -= 180;
                    }
                    keyValuePair.Value[1].inclination = inclination;
                }
            }

            foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Aperture)
            {
                if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1)
                {
                    continue;
                }

                keyValuePair.Value[1].linkSurface = keyValuePair.Value[0];
                keyValuePair.Value[0].linkSurface = keyValuePair.Value[1];

                if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180)
                {
                    float inclination = keyValuePair.Value[0].inclination;
                    inclination -= 180;
                    if (inclination < 0)
                    {
                        inclination += 360;
                    }

                    keyValuePair.Value[0].inclination = inclination;
                    keyValuePair.Value[0].reversed    = 1;
                }
                else
                {
                    float orientation = keyValuePair.Value[1].orientation;
                    orientation += 180;
                    if (orientation >= 360)
                    {
                        orientation -= 360;
                    }

                    keyValuePair.Value[1].orientation = orientation;
                    keyValuePair.Value[1].reversed    = 1;
                }
            }

            return(result);
        }