/// <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++; } }
/// <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++; } }
private XPolygon CreateCorridorSpaceProfile(double wallThickness) { double width = parameters.CorridorWidth - wallThickness; // Transform the line to be in building coordinates; XLine refLine = parameters.ReferenceLine.Transformed(building.InverseGlobalTransform); // Create the profile. To be consistent the profile is centered at the mid point // starts upper left and is oriented clockwise XPolygon profile = new XPolygon { new XbimPoint3D(-refLine.Length / 2, width / 2, 0), new XbimPoint3D(refLine.Length / 2, width / 2, 0), new XbimPoint3D(refLine.Length / 2, -width / 2, 0), new XbimPoint3D(-refLine.Length / 2, -width / 2, 0) }; return(profile); }
/// <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" }; }
public XLine Transformed(XbimMatrix3D transform) { XLine temp = new XLine(transform.Transform(sp), transform.Transform(ep)); return(temp); }