コード例 #1
0
        private void CreateCorridorWalls(XPreviewBuildingStory story)
        {
            XbimPoint3D p1 = new XbimPoint3D(0, parameters.CorridorWidth, 0);
            XbimPoint3D p2 = new XbimPoint3D(parameters.ReferenceLine.Length, parameters.CorridorWidth, 0);

            XPolygon wallProfile = CreateWallProfile(p1.Distance(p2));

            XPreviewWall wall = new XPreviewWall
            {
                Name        = "Wall ",
                Location    = new XbimPoint3D(0, -parameters.CorridorWidth / 2, 0),
                ProfilePath = wallProfile.Clone(),
                Thickness   = parameters.InteriorWallThickness,
                Height      = parameters.CeilingElevation,
                Container   = story
            };

            wall = new XPreviewWall
            {
                Name        = "Wall ",
                Location    = new XbimPoint3D(0, parameters.CorridorWidth / 2, 0),
                ProfilePath = wallProfile.Clone(),
                Thickness   = parameters.InteriorWallThickness,
                Height      = parameters.CeilingElevation,
                Container   = story
            };
        }
コード例 #2
0
        private XPreviewBuilding CreateGarageStructure(XParameters parameters)
        {
            XbimPoint3D location  = parameters.Perimeter.First();
            XPolygon    perimeter = parameters.Perimeter.Normalized(location);
            // Create the building
            XPreviewBuilding garage = new XPreviewBuilding()
            {
                Name               = parameters.BuildingName,
                Location           = location,
                ReferenceDirection = new XbimVector3D(1, 0, 0),
                Axis               = new XbimVector3D(0, 0, 1)
            };

            // Building stories
            for (int i = 0; i < parameters.NumberOfFloors; i++)
            {
                XPreviewBuildingStory story = new XPreviewBuildingStory
                {
                    Name               = "Floor " + (i + 1).ToString(),
                    Location           = new XbimPoint3D(0, 0, i * parameters.FloorToFloor),
                    ReferenceDirection = new XbimVector3D(1, 0, 0),
                    Axis               = new XbimVector3D(0, 0, 1),
                    Container          = garage,
                    StoryNumber        = (i + 1),
                };
            }

            return(garage);
        }
コード例 #3
0
        /// <summary>
        /// Creates the building and buildinh stories
        /// </summary>
        private void CreateBuildingStructure()
        {
            // Create the building
            building = new XPreviewBuilding()
            {
                Name               = parameters.BuildingName,
                Location           = new XbimPoint3D(parameters.ReferenceLine.sp.X, parameters.ReferenceLine.sp.Y, parameters.ReferenceLine.sp.Z),
                ReferenceDirection = parameters.ReferenceLine.NormalizedVector,
                Axis               = new XbimVector3D(0, 0, 1)
            };

            // Building stories
            for (int i = 0; i < parameters.NumberOfFloors; i++)
            {
                XPreviewBuildingStory story = new XPreviewBuildingStory
                {
                    Name               = "Floor " + (i + 1).ToString(),
                    Location           = new XbimPoint3D(0, 0, i * parameters.FloorToFloor),
                    ReferenceDirection = new XbimVector3D(1, 0, 0),
                    Axis               = new XbimVector3D(0, 0, 1),
                    Container          = building,
                    StoryNumber        = (i + 1),
                };
            }
        }
コード例 #4
0
        /// <summary>
        /// Creates the partition walls between the units. Not surprisingly uses similar logic to
        /// creating units
        /// </summary>
        /// <param name="story"></param>
        private void CreatePartitionWalls(XPreviewBuildingStory story)
        {
            UnitParameters firstUnit = unitsToCreate.First();
            XLine          refLine   = parameters.ReferenceLine.Transformed(building.InverseGlobalTransform);
            XbimVector3D   cross     = refLine.NormalizedVector.CrossProduct(new XbimVector3D(0, 0, 1));
            // The reference point on the center line from which the insertion points will be calculated
            XbimPoint3D referencePoint = new XbimPoint3D(refLine.sp.X + (firstUnit.UnitWidth - parameters.InteriorWallThickness / 2), refLine.sp.Y, refLine.sp.Z);

            int unitCount = 0;
            int wallcount = 0;

            foreach (UnitParameters unit in unitsToCreate)
            {
                if (unitCount != unitsToCreate.Count - 1)
                {
                    // the length of the wall is going to be the minimum of the dwpth of the two units the wall is between
                    double length = Math.Min(unit.UnitDepth, unitsToCreate[unitCount + 1].UnitDepth);
                    if (parameters.CorridorMode != CorridorMode.Left)
                    {
                        // Right of the corridor
                        XbimPoint3D  location = cross.GetPoint(referencePoint, parameters.CorridorWidth / 2 + parameters.InteriorWallThickness / 2);
                        XPreviewWall wall     = new XPreviewWall
                        {
                            Name               = "Wall " + (story.StoryNumber * 100 + wallcount).ToString(),
                            Location           = location,
                            Container          = story,
                            ProfilePath        = CreateWallProfile(length),
                            Height             = parameters.CeilingElevation,
                            ReferenceDirection = new XbimVector3D(0, -1, 0)
                        };
                        wallcount++;
                    }
                    if (parameters.CorridorMode != CorridorMode.Right)
                    {
                        // Left of the corridor
                        XbimPoint3D  location = cross.GetPoint(referencePoint, -parameters.CorridorWidth / 2 - parameters.InteriorWallThickness / 2);
                        XPreviewWall wall     = new XPreviewWall
                        {
                            Name               = "Wall " + (story.StoryNumber * 100 + wallcount).ToString(),
                            Location           = location,
                            Container          = story,
                            ProfilePath        = CreateWallProfile(length),
                            Height             = parameters.CeilingElevation,
                            ReferenceDirection = new XbimVector3D(0, 1, 0),
                        };
                        wallcount++;
                    }

                    // Increment the location. Must use next unit width too as units may be different sizes
                    if (unitCount != unitsToCreate.Count - 1)
                    {
                        UnitParameters nextUnit = unitsToCreate[unitCount + 1];
                        XbimPoint3D    delta    = new XbimPoint3D(nextUnit.UnitWidth, 0, 0);
                        referencePoint = XbimPoint3D.Add(referencePoint, delta);
                    }
                }
                unitCount++;
            }
        }
コード例 #5
0
        /// <summary>
        /// Creates the units.
        /// </summary>
        /// <remarks>
        /// The units are inserted at their bounding box center, so what we need to do is calculate where that center should be.
        /// Take a point along the corridor center line, using the cross product vector get a point to the right and to the left
        /// The units profile is already adjusted for whether we are FullDetail or not.
        /// </remarks>
        /// <param name="story"></param>
        private void CreateUnits(XPreviewBuildingStory story)
        {
            UnitParameters firstUnit = unitsToCreate.First();
            XLine          refLine   = parameters.ReferenceLine.Transformed(building.InverseGlobalTransform);
            XbimVector3D   cross     = refLine.NormalizedVector.CrossProduct(new XbimVector3D(0, 0, 1));
            // The reference point on the center line from which the insertion points will be calculated
            XbimPoint3D referencePoint = new XbimPoint3D(refLine.sp.X + (firstUnit.UnitWidth - parameters.InteriorWallThickness) / 2, refLine.sp.Y, refLine.sp.Z);

            int unitNumber = 1;     // The sequence number used to generate the unit name (incremented for every unit)
            int unitCount  = 0;     // The count of units to create, increment every two units (for both sides)

            foreach (UnitParameters unit in unitsToCreate)
            {
                if (parameters.CorridorMode != CorridorMode.Left)
                {
                    XbimPoint3D location = cross.GetPoint(referencePoint, (unit.UnitDepth + parameters.CorridorWidth) / 2);
                    // Create units to the right
                    XPreviewSpace space = new XPreviewSpace
                    {
                        Name               = "Unit " + (story.StoryNumber * 100 + unitNumber).ToString(), // "101, 102, 103" etc.
                        ProfilePath        = unit.Profile.Clone(),
                        LongName           = unit.UnitType,
                        Height             = parameters.CeilingElevation,
                        Location           = location,
                        ReferenceDirection = new XbimVector3D(-1, 0, 0),
                        Container          = story,
                        Color              = unit.Color,
                    };
                    unitNumber++;
                }
                if (parameters.CorridorMode != CorridorMode.Right)
                {
                    XbimPoint3D location = cross.GetPoint(referencePoint, -(unit.UnitDepth + parameters.CorridorWidth) / 2);
                    // Create units to the left
                    XPreviewSpace space = new XPreviewSpace
                    {
                        Name        = "Unit " + (story.StoryNumber * 100 + unitNumber).ToString(), // "101, 102, 103" etc.
                        ProfilePath = unit.Profile.Clone(),
                        LongName    = unit.UnitType,
                        Height      = parameters.CeilingElevation,
                        Location    = location,
                        Container   = story,
                        Color       = unit.Color
                    };
                    unitNumber++;
                }

                // Increment the location. Must use next unit width too as units may be different sizes
                if (unitCount != unitsToCreate.Count - 1)
                {
                    UnitParameters nextUnit = unitsToCreate[unitCount + 1];
                    XbimPoint3D    delta    = new XbimPoint3D(unit.UnitWidth / 2 + nextUnit.UnitWidth / 2, 0, 0);
                    referencePoint = XbimPoint3D.Add(referencePoint, delta);
                }
                unitCount++;
            }
        }
コード例 #6
0
        /// <summary>
        /// Creates the corridor space
        /// </summary>
        /// <param name="story"></param>
        private void CreateCorridorSpace(XPreviewBuildingStory story)
        {
            // Transform the line to be in building coordinates;
            XLine refLine = parameters.ReferenceLine.Transformed(building.InverseGlobalTransform);

            // Craete the profile
            XPolygon profile = CreateCorridorSpaceProfile(parameters.InteriorWallThickness);
            // Location will be at the center of the reference line
            XbimPoint3D   location = refLine.MidPoint;
            XPreviewSpace space    = new XPreviewSpace
            {
                Name        = "Corridor " + story.StoryNumber.ToString(),
                ProfilePath = profile,
                Height      = parameters.CeilingElevation,
                Location    = location,
                Container   = story,
                Color       = "#afafaf"
            };
        }
コード例 #7
0
        private void CreateSlabs(XPreviewBuildingStory story)
        {
            // For which we need the total footprint as defined by the units. But we can't boolean them together
            // because there are gaps between the spaces now - arrrghhhh!

            // Make the corridor polygon and then make each unit and boolean add them.
            XPolygon        corridor = CreateCorridorSpaceProfile(0).Transformed(story.Elements.First().LocalTransform);
            List <XPolygon> results  = new List <XPolygon>()
            {
                corridor
            };

            foreach (XPreviewSpace space in story.Elements.Where(elem => elem is XPreviewSpace space && space.LongName != null))
            {
                // Find the relating unit definition so we can create a polygon the extents of width and depth
                UnitParameters unitdef = unitsToCreate.Find(u => u.UnitType == space.LongName);
                if (unitdef != null)
                {
                    XPolygon fullProfile = unitdef.CreateFullSizeProfile().Transformed(space.LocalTransform);
                    results = XPolygon.Clip(ClipType.ctUnion, results, new List <XPolygon>()
                    {
                        fullProfile
                    });
                }
            }

            // We will place the slab at 0,0,0 on the story
            XPreviewSlab slab = new XPreviewSlab
            {
                Name        = "Slab " + story.StoryNumber,
                ProfilePath = results.First(),
                Thickness   = parameters.InterzoneSlabThickness,
                Container   = story,
                Height      = -parameters.InterzoneSlabThickness
            };
        }