Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ instance included, gets its own triangles. The shared symbol triangles keep the
faces reverses the winding of a placement with a negative determinant. The own triangles of an element, those of a mirrored
instance included, are wound around the normals of their faces.

The drawable elements follow a subset of the product rules of the IFC export of the current profile, and the materials and the
hidden Geometry nodes follow its rules: they are listed in the documentation comment of `ElementMeshes`, with the product rules
that are not applied (the "export to IFC" flag, topography, walls that are not visible and others), so the meshes can include
elements that the IFC leaves out. Curved surfaces are the dense polygons the reader decodes for them.
The drawable elements follow a subset of the product rules of the current IFC profile, including exclusion of topography stored
in model-group definitions. `ElementMeshes` documents these rules, its material and hidden Geometry node handling, and IFC
rules specific to export, such as the export flag and assembly of the site. Curved surfaces are the dense polygons the reader
decodes for them.

## Writing and save-as

Expand Down
5 changes: 1 addition & 4 deletions src/RvtIO/Ifc/IfcExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,7 @@ private void ExportDocument(RevitFileInfo info, TextWriter output)
var elementByIdForTerrain = info.Elements.GroupBy(element => element.Id)
.ToDictionary(group => group.Key, group => group.First());
var groupDefinitionTopographyIds = info.Elements
.Where(element => element.CategoryId == -2001340
&& (element.References ?? Enumerable.Empty<int>()).Any(referenceId =>
elementByIdForTerrain.TryGetValue(referenceId, out var referenced)
&& referenced.CategoryId == -2000095))
.Where(element => ProductRules.IsGroupDefinitionTopography(element, elementByIdForTerrain))
.Select(element => element.Id).ToHashSet();
var placedTopographies = info.Elements
.Where(element => element.CategoryId == -2001340
Expand Down
3 changes: 2 additions & 1 deletion src/RvtIO/Meshes/ElementMeshes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace RvtIO.Meshes;
/// elements are listed themselves; a placement of a drawable element is likewise left out of an element's placements. A
/// drawable element is listed when it has a geometry record, or, in a document whose geometry was not decoded, a bounding box.
/// Other product rules of the IFC export are not applied, so the meshes can include elements that the IFC leaves out: the
/// "export to IFC" flag, topography, walls that are not visible, curtain panels that are walls, family instances whose level is
/// "export to IFC" flag, IFC site assembly, walls that are not visible, curtain panels that are walls, family instances whose level is
/// not a project level, curtain children without bounds, openings of hidden walls, and the rebar rules.</para>
/// <para>Faces of Geometry nodes that Revit does not take (another detail level) are left out when the element has faces of
/// nodes it takes and no ghost node (a node Revit exports that has no decoded polygon, which also makes the element
Expand Down Expand Up @@ -255,6 +255,7 @@ private static bool DropsUntakenNodes(IReadOnlyList<GeoFace> faces, bool hasGhos
|| designOptions.InNonPrimaryOption(element) == true || phaseFilter?.Excludes(element) == true
|| element.CategoryId == RevealsCategoryId || ProductRules.IsWallRectangularOpening(element)
|| ProductRules.IsValidatedStackedWallContainer(element, elementsById)
|| ProductRules.IsGroupDefinitionTopography(element, elementsById)
|| info.ElemTableIsExact && element.IsDiscovered
|| element.SerializedFamilyId is > 0
|| (!modelLine && !areaReinforcement && ProductRules.IsNonPhysicalCategory(element.Category)))
Expand Down
8 changes: 8 additions & 0 deletions src/RvtIO/Model/ProductRules.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using RvtIO.BuiltIns;

namespace RvtIO.Model;

/// <summary>
Expand Down Expand Up @@ -79,6 +81,12 @@ internal static bool IsNonPhysicalCategory(string? category)
internal static bool IsWallRectangularOpening(Element element) =>
element.Category?.Contains("OST_SWallRectOpening", StringComparison.OrdinalIgnoreCase) == true;

/// <summary>Topography stored with a model-group definition rather than placed on the site.</summary>
internal static bool IsGroupDefinitionTopography(Element element, IReadOnlyDictionary<int, Element> elementsById) =>
element.CategoryId == (int)BuiltInCategory.OST_Topography
&& element.References?.Any(id => elementsById.TryGetValue(id, out var referenced)
&& referenced.CategoryId == (int)BuiltInCategory.OST_IOSModelGroups) == true;

/// <summary>A StackedWall parent, whose member walls are the products; not its source record or children.</summary>
internal static bool IsValidatedStackedWallContainer(
Element element, IReadOnlyDictionary<int, Element> elementsById) =>
Expand Down
19 changes: 19 additions & 0 deletions tests/RvtIO.Tests/ElementMeshesTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using RvtIO.BuiltIns;
using RvtIO.Internal;
using RvtIO.Meshes;
using RvtIO.Model;
Expand Down Expand Up @@ -667,6 +668,24 @@ public void DefinitionsAndContainers_AreNotListed()
Assert.Equal([1, 6], set.Elements.Select(element => element.ElementId));
}

[Fact]
public void GroupDefinitionTopography_IsExcludedFromSceneMeshes()
{
static GeometryData Triangle() => new() { Faces = [Face([[0, 0, 0], [1, 0, 0], [1, 1, 0]], [0, 0, 1])] };
var placed = Product(1, Triangle());
placed.CategoryId = (int)BuiltInCategory.OST_Topography;
var groupTerrain = Product(2, Triangle());
groupTerrain.CategoryId = placed.CategoryId;
groupTerrain.References = [4];
var groupMember = Product(3, Triangle());
groupMember.References = [4];
var groupType = new Element { Id = 4, CategoryId = (int)BuiltInCategory.OST_IOSModelGroups };

var set = ElementMeshes.Extract(Document(placed, groupTerrain, groupMember, groupType));

Assert.Equal([1, 3], set.Elements.Select(element => element.ElementId));
}

[Fact]
public void PlacementOfADrawableElement_IsLeftToThatElement()
{
Expand Down
Loading