Skip to content

feat(DXF): load DXF as independent surfaces; Assimp formats as one surface per object - #235

Merged
BenPinet merged 2 commits into
nextfrom
feat/dxf-surfaces
Nov 20, 2026
Merged

BenPinet merged 2 commits into
nextfrom
feat/dxf-surfaces

Conversation

@BotellaA

Copy link
Copy Markdown
Member

Why

A DXF made of polyface meshes (triangles stored as quads repeating their first vertex, a,b,c,a) loaded with 0 polygons. Assimp kept the faces as 4-vertex polygons, then SurfaceMeshMerger dropped every polygon with a repeated vertex. Assimp's DXF importer also groups everything per layer and drops handles/XDATA, so individual objects could not be recovered.

What

DXF: own reader (no Assimp)

  • One PolygonalSurface3D per polyface POLYLINE; 3DFACEs grouped into one surface per layer (vertices colocated).
  • Consecutive duplicate corners removed (incl. wrap-around); a 3DFACE without a 4th corner is a triangle. Invalid faces (fewer than 3 distinct vertices, out-of-range indices, repeated vertices, incomplete corners) are skipped and reported in one warning.
  • Surface names: XDATA Name, then Nom de Galerie, else <layer>_<handle>, with \U+XXXX escapes decoded.
  • Reading stops at the end of ENTITIES / EOF. A leading comment, a UTF-8 BOM or a missing SEQEND is tolerated. Binary DXF is a data error. Unsupported entities (LINE, POINT, INSERT…) are skipped with a warning; VIEWPORT is skipped silently.

OBJ / STL / PLY (Assimp)

  • One surface per Assimp object (OBJ g/o, STL solid), named after it. The meshes of an object (one per material) are still merged, so a multi-material object stays one surface with all its textures.
  • Consecutive duplicate corners removed before polygon creation.

Behavior changes

  • load_one on a multi-object OBJ or multi-solid STL now raises a data error: use load_all and iterate.
  • A file without any polygon (points/lines only) gives no surface instead of an empty one.
  • DXF INSERT/blocks are no longer expanded (warned).

Tests

  • test-dxf: new polyface_surfaces.dxf, 3D_faces.dxf per layer (expected counts computed independently), plus inline cases for trailing content, missing corners, the minimum int index, missing SEQEND, BOM, comments, unicode layer names and VIEWPORT.
  • test-obj: per-object surfaces, a multi-material object (placed after another group, so its position in the file differs from its index in the object), repeated corners, an unnamed object.
  • test-stl / test-ply: names.
  • Python: new generic-api row for the DXF; doc updated.
  • Local: Release ctest 20/20. The real 15 MB file loads as 89 surfaces / 43066 polygons.
  • Not run locally: Python tests (bindings off) and an assertions-on build. CI covers both.

🤖 Generated with Claude Code

BotellaA and others added 2 commits November 19, 2026 16:50
…CE layer

DXF files are no longer read through Assimp, which merged the entities of a
layer and dropped the polyface faces written as quads with a repeated vertex
(2,1,4,2), loading such files with 0 polygons. Each polyface mesh POLYLINE
becomes a surface named after its XDATA "Name" or "Nom de Galerie" (else
<layer>_<handle>), the 3DFACE entities give one surface per layer, and
degenerate faces and unsupported entities are skipped with a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed corners

The OBJ, STL and PLY readers merged every Assimp mesh of the file into one
surface. They now return one surface per scene node holding meshes (an OBJ
g/o object, an STL solid; a PLY file stays one surface), named after it,
each with the textures of its materials. Objects without polygons are
dropped. Consecutive corners on the same vertex or on equal points
(including last/first) are merged before building a polygon, so f 1 2 3 1
gives a triangle instead of a dropped degenerate polygon; faces left with
less than 3 corners are skipped with the other unsupported faces.

load_one on a multi-object OBJ (or multi-solid STL) file now raises a data
error: callers must iterate the returned surfaces (load_all in Python).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BotellaA
BotellaA requested a review from panquez November 19, 2026 16:02
@BenPinet
BenPinet merged commit 6596989 into next Nov 20, 2026
15 checks passed
@BenPinet
BenPinet deleted the feat/dxf-surfaces branch November 20, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants