Exemple #1
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++;
            }
        }
Exemple #2
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++;
            }
        }
Exemple #3
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
            };
        }