Exemplo n.º 1
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++;
            }
        }
 public XPreviewBuildingStory(IfcBuildingStorey ifcBuildingStory)
     : base(ifcBuildingStory)
 {
     Name = ifcBuildingStory.Name;
     foreach (IfcSpace ifcSpace in ifcBuildingStory.Spaces)
     {
         XPreviewSpace space = new XPreviewSpace(ifcSpace);
         space.Container = this;
     }
 }
Exemplo n.º 3
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"
            };
        }