Skip to content

Location not updated by BRep_Tool.Triangulation? #1444

@inducer

Description

@inducer

I am reimplementing the logic in the upstream STL writer in pythonocc-core in order to obtain a surface mesh without having to resort to File I/O, and it seems that calling BRep_Tool.Triangulation should update the TopLoc_Location it is passed, but, at least according to its DumpJSON method, this is not happening. Here's the core of my traversal loop:

    exp = TopExp_Explorer(shape, TopAbs_FACE)
    while exp.More():
        face = exp.Current()
        if face.Orientation() == TopAbs_REVERSED:
            print("FIXME Reversed face")

        loc = TopLoc_Location()
        tri = BRep_Tool.Triangulation(face, loc)
        if tri:
            trsf = loc.Transformation()
            for i in range(tri.NbNodes()):
                p = tri.Node(1+i)
                p.Transform(trsf)
                nodes.append([p.X(), p.Y(), p.Z()])

A full self-contained example is also available.

In the full example, I am trying to mesh a box. STL export (ostensibly using the OCCT C++ code above) works fine, but with my reimplementation, I get a mesh that looks like this:

Image

I.e. all faces of the box seem to coincide in one plane, seemingly consistent with lack of transformation information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions