Skip to content

Commit

Permalink
Merge branch 'master' into dmuravskyi/adaptive-grid-clone
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroMuravskyi authored Dec 1, 2023
2 parents 45f940a + 27cda66 commit c5a8577
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 121 deletions.
4 changes: 2 additions & 2 deletions Elements.Serialization.IFC/src/IFCElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ private static IfcDoor ToIfc(this Door door, Guid id, IfcLocalPlacement localPla
localPlacement,
shape,
null,
new IfcPositiveLengthMeasure(new IfcLengthMeasure(door.ClearHeight)),
new IfcPositiveLengthMeasure(new IfcLengthMeasure(door.ClearWidth)),
new IfcPositiveLengthMeasure(new IfcLengthMeasure(door.DoorHeight)),
new IfcPositiveLengthMeasure(new IfcLengthMeasure(door.DoorWidth)),
IfcDoorTypeEnum.DOOR,
door.GetIfcDoorTypeOperation(),
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ public GeometricElement ConvertToElement(IfcProduct ifcProduct, RepresentationDa
//var wall = GetWallFromDoor(ifcDoor, allWalls);
var doorWidth = (IfcLengthMeasure)ifcDoor.OverallWidth;
var doorHeight = (IfcLengthMeasure)ifcDoor.OverallHeight;
var doorThickness = Door.DEFAULT_DOOR_THICKNESS;

var result = new Door(doorWidth,
doorHeight,
Door.DOOR_THICKNESS,
doorThickness,
openingSide,
openingType,
repData.Transform,
Expand Down
8 changes: 4 additions & 4 deletions Elements.Serialization.IFC/test/IFCTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public IfcTests(ITestOutputHelper output)
// [InlineData("rac_sample", "../../../models/IFC4/rac_advanced_sample_project.ifc")]
// [InlineData("rme_sample", "../../../models/IFC4/rme_advanced_sample_project.ifc")]
// [InlineData("rst_sample", "../../../models/IFC4/rst_advanced_sample_project.ifc")]
[InlineData("AC-20-Smiley-West-10-Bldg", "../../../models/IFC4/AC-20-Smiley-West-10-Bldg.ifc", 1963, 120, 530, 270, 9, 140, 10, 2)]
[InlineData("AC-20-Smiley-West-10-Bldg", "../../../models/IFC4/AC-20-Smiley-West-10-Bldg.ifc", 1972, 120, 530, 270, 9, 140, 10, 2)]
// TODO: Some walls are extracted incorrectly and intersecting the roof. It happens because
// IfcBooleanClippingResultParser doesn't handle the boolean clipping operation.
// In order to fix it surface support is required.
Expand All @@ -39,7 +39,7 @@ public IfcTests(ITestOutputHelper output)
// TODO: The entrance door has an incorrect representation. It happens because during
// the UpdateRepresentation the default representation of a door is created instead of
// the extracted one.
[InlineData("AC20-Institute-Var-2", "../../../models/IFC4/AC20-Institute-Var-2.ifc", 1506, 5, 570, 121, 7, 82, 0, 21)]
[InlineData("AC20-Institute-Var-2", "../../../models/IFC4/AC20-Institute-Var-2.ifc", 1513, 5, 570, 121, 7, 82, 0, 21)]
// [InlineData("20160125WestRiverSide Hospital - IFC4-Autodesk_Hospital_Sprinkle", "../../../models/IFC4/20160125WestRiverSide Hospital - IFC4-Autodesk_Hospital_Sprinkle.ifc")]
public void FromIFC4(string name,
string ifcPath,
Expand Down Expand Up @@ -138,8 +138,8 @@ public void Doors()
var wall1 = new StandardWall(wallLine1, 0.2, 3, name: "Wall1");
var wall2 = new StandardWall(wallLine2, 0.2, 2, name: "Wall2");

var door1 = new Door(wallLine1, 0.5, 1.5, 2.0, Door.DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing);
var door2 = new Door(wallLine2, 0.5, 1.5, 1.8, Door.DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing);
var door1 = new Door(wallLine1, 0.5, 1.5, 2.0, Door.DEFAULT_DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing);
var door2 = new Door(wallLine2, 0.5, 1.5, 1.8, Door.DEFAULT_DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing);

wall1.AddDoorOpening(door1);
wall2.AddDoorOpening(door2);
Expand Down
245 changes: 139 additions & 106 deletions Elements/src/BIM/Door/Door.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Elements/src/BIM/Door/DoorRepresentationStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Elements
{
static class DoorRepresentationStorage
public static class DoorRepresentationStorage
{
private static readonly Dictionary<string, List<RepresentationInstance>> _doors = new Dictionary<string, List<RepresentationInstance>>();
public static Dictionary<string, List<RepresentationInstance>> Doors => _doors;
Expand Down
22 changes: 21 additions & 1 deletion Elements/src/CoreModels/ElementRepresentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/// </summary>
public abstract class ElementRepresentation : SharedObject
{
protected List<SnappingPoints> _snapPoints;

/// <summary>
/// Get graphics buffers and other metadata required to modify a GLB.
/// </summary>
Expand All @@ -28,12 +30,30 @@ internal virtual List<NodeExtension> GetNodeExtensions(GeometricElement element)
return new List<NodeExtension>();
}

/// <summary>
/// Set the snapping points for this representation.
/// </summary>
public void SetSnappingPoints(List<SnappingPoints> snapPoints)
{
_snapPoints = snapPoints;
}

/// <summary>
/// Get the snapping points for this representation. Uses CreateSnappingPoints if _snapPoints is null.
/// </summary>
public List<SnappingPoints> GetSnappingPoints(GeometricElement element)
{
if (_snapPoints == null) return CreateSnappingPoints(element);
return _snapPoints;
}


/// <summary>
///Creates the set of snapping points
/// </summary>
/// <param name="element">The element with this representation.</param>
/// <returns></returns>
public virtual List<SnappingPoints> CreateSnappingPoints(GeometricElement element)
protected virtual List<SnappingPoints> CreateSnappingPoints(GeometricElement element)
{
return new List<SnappingPoints>();
}
Expand Down
3 changes: 2 additions & 1 deletion Elements/src/Representations/CurveRepresentation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Elements.Geometry;
using glTFLoader.Schema;

Expand Down Expand Up @@ -47,7 +48,7 @@ public override bool TryToGraphicsBuffers(GeometricElement element, out List<Gra
}

/// <inheritdoc/>
public override List<SnappingPoints> CreateSnappingPoints(GeometricElement element)
protected override List<SnappingPoints> CreateSnappingPoints(GeometricElement element)
{
var snappingPoints = new List<SnappingPoints>();
var curvePoints = _curve.RenderVertices();
Expand Down
4 changes: 2 additions & 2 deletions Elements/src/Representations/SolidRepresentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Elements
{
/// <summary>
///
/// A solid representation of an element.
/// </summary>
public class SolidRepresentation : ElementRepresentation
{
Expand Down Expand Up @@ -193,7 +193,7 @@ public List<List<Vector3>> CalculateIntersectionPoints(GeometricElement element,
}

/// <inheritdoc/>
public override List<SnappingPoints> CreateSnappingPoints(GeometricElement element)
protected override List<SnappingPoints> CreateSnappingPoints(GeometricElement element)
{
var snappingPoints = new List<SnappingPoints>();

Expand Down
5 changes: 3 additions & 2 deletions Elements/src/Serialization/glTF/GltfExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,9 @@ private static void GetRenderDataForElement(Element e,
var meshIdList = new List<int> { meshId };
representationsMap.Add(combinedId, meshIdList);
addedNodes.AddRange(NodeUtilities.AddNodes(nodes, meshIdList, elementNodeId));
var snappingPoints = representation.Representation.CreateSnappingPoints(element);
if (snappingPoints.Any())
var snappingPoints = representation.Representation.GetSnappingPoints(element);

if (snappingPoints != null)
{
AddExtension(gltf, meshes[meshId], "HYPAR_snapping_points", new Dictionary<string, object>() { { "points", snappingPoints } });
}
Expand Down
2 changes: 1 addition & 1 deletion Elements/test/DoorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void MakeDoorElement()

var line = new Line(new Vector3(0, 0, 0), new Vector3(10, 10, 0));
var wall = new StandardWall(line, 0.1, 3.0);
var door = new Door(wall.CenterLine, 0.5, 2.0, 2.0, Door.DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.SingleSwing);
var door = new Door(wall.CenterLine, 0.5, 2.0, 2.0, Door.DEFAULT_DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.SingleSwing);
wall.AddDoorOpening(door);

Assert.Single(wall.Openings);
Expand Down

0 comments on commit c5a8577

Please sign in to comment.