Example #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++;
            }
        }
Example #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++;
            }
        }
Example #3
0
        public static IfcAreaMeasure Area(this IfcPolyLoop loop, IfcDirection normal)
        {
            var sum = new XbimPoint3D(0, 0, 0);
            var pts = loop.Polygon;

            for (var i = 0; i < pts.Count - 1; i++)
            {
                sum = XbimPoint3D.Add(sum, pts[i].CrossProduct(pts[i + 1]));
            }
            var n = normal.Normalise();

            return(n.DotProduct(new XbimVector3D(sum.X, sum.Y, sum.Z)) / 2);
        }