Repository navigation
Add a public API for the triangle meshes of the model elements - #197
Merged
Merged
Conversation
The instance expansion now notes on the element's geometry whether the tight box of the GRep cut a placed symbol or left it out (ClipGeometryToBounds reports whether it changed the faces), whether a rescaled component was replaced by its box, and whether a GInstance resolved to nothing. The reader also notes whether the geometry of a 64-bit-id file was left undecoded because it was read without the R22 rewrite. The flags are internal and change no output.
The phase reference, type element, transform-only family, non-physical category, wall opening and export phase checks of the product loop become internal members so that another export can apply the same rules. The IFC output is unchanged.
ElementMeshes.Extract returns, for an opened document, the triangles of every drawable element in feet: its own triangles per material, or the placements of shared symbol meshes when the element is shown to be exactly its symbols placed (no own faces, nothing clipped, every symbol resolved, no box substitute, rigid transforms). A mirrored placement keeps the winding of its symbol and carries the mirror in its transform; own triangles are wound around the normals of their faces. Hidden Geometry nodes, face materials and the element selection follow the IFC export of the current profile. Each element reports its coverage, and the set reports a document whose geometry was not decoded.
…into ProductRules ElementMeshes no longer builds an IfcExporter for the export phase filter. The rules are moved without change; IFC and compact JSON output of the samples is identical to the base.
The IFC export drops the faces of untaken nodes only when the geometry has no ghost node; the meshes now apply the same condition, a symbol is shared only when it drops the same nodes as the element, and an element or symbol with ghost nodes is reported as Partial. Document the positional properties of MeshVector and MeshTransform, give ElementMeshOptions a settable property like the other options types, and name the IFC product rules that ElementMeshes does not apply.
The reader keeps its own Revit 2022 layout only for Revit 2022 files; every other file it reads by the file's own class schema and decodes no element geometry without the option. Measured on the Revit 2020 and 2025 samples, which the docs had left out by naming Revit 2023 and later.
The release notes are extracted before anything is published, the push runs before gh release create so that a refused first publication can be fixed and the job run again, and a tag with a hyphen creates a pre-release.
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes and why
Adds a public mesh API in
RvtIO.Meshes, so that adapters can read the triangle meshes of a document withoutInternalsVisibleTo.ElementMeshes.Extract(document, options)returns aMeshSetfor an openedRvtDocument, made from the faces the document already holds (the file is not read again), in feet, Revit internal coordinates, Z up.ElementMesh): its own triangles, oneTriangleMeshper material (flat normals, counter-clockwise around them), or placements (SymbolPlacement: symbol id andMeshTransform) of shared symbol meshes inMeshSet.Symbols; plus aMeshCoverageand the number of faces that did not triangulate.Determinant).ElementMeshOptions.UseSymbolPlacements = falsegives every element its own triangles.Partialwhen a placed symbol, or a symbol nested in one at any depth, has no geometry, in both modes. The instance expansion passes a nested symbol that placed nothing up to the element, the same way it passes a box substitute.ElementMeshesremarks, so the meshes can include elements the IFC leaves out.RvtReaderOptions.R22Layout; without itMeshSet.GeometryUndecodedis true and its elements areUndecoded. TheR22Layoutdoc comment and the docs now say so (they named only Revit 2023 and later).IfcExporterinto the internalProductRules(andExportPhaseFilterintoRvtIO.Model), soElementMeshesdoes not build anIfcExporter.[Unreleased]/ Added. Existing public types are unchanged; IFC and JSON output is unchanged.Also in this branch, not part of the mesh API:
release.yml: the release notes are extracted before anything is published, the NuGet push runs beforegh release create(a refused first publication can be fixed and the job run again), and a tag with a hyphen creates a pre-release.docs/test-fixtures.md: the counts of the tests that run without the private fixtures are updated, including the sample test classes added to main since the last count.Tests
Restored with IOScene from a local package folder; RvtIO itself needs nothing unpublished.
dotnet build RvtIO.slnx -c Release): 0 errors, 191 warnings, the same warning set as on main and before the merge of main.docs/test-fixtures.md, and the skipped classes match its table row for row.ApiTests.Proxy289128_*x3,ValidatedTests.FamilyInstance289128_BBox_MatchesReference,ValidatedTests.Wall263597_BBox_MatchesReference,ElementHeaderBoundingBoxTests.StoredOutline_IsTheElementBoxOfEveryRelease(release: 2022)) fail with the same messages on main (fdb75ca); they are not caused by this branch.ElementMeshesTests(synthetic, part of the counts above): 37/37 on both TFMs. Triangulation with holes and winding, untaken and ghost Geometry nodes, materials, placement versus own triangles for clipped, scaled, mirrored and box-substitute instances, coverage (including a symbol without geometry nested one and two levels down in a placed symbol, for a family instance and a transform-only instance, in both modes, and nested symbols that all have geometry staying complete), definitions and containers left out,MeshTransformfrom the row-major instance transform, null document.ComputedSymbolGeometryTestsgains a case for a computed symbol that places a symbol without geometry. Of the 9 nested-symbol cases, 7 fail before that fix and 2 guard against a false partial.ElementMeshesSampleTests(a private Revit 2022 sample, a private Revit 2025 sample and a private door-in-wall sample): 5/5 on both TFMs with the private files, skipped without them.ProductRules: identical to the base (recorded in that commit).R22Layout: measured on private Revit 2020 and 2025 samples (no element geometry decoded without it); the private Revit 2022 samples give the same meshes either way.Notes
fdb75ca, Add --strict option and exit code 6 for partial reads #194).ElementMeshes,ElementMeshOptions,MeshSet,ElementMesh,TriangleMesh,SymbolPlacement,MeshTransform,MeshVector,MeshCoverage).InternalsVisibleTocan move toElementMeshesonce a release contains it.