Files
ocp/src/modules/mod_IGESControl.cpp
T
stroblme a01b1de26c 10C Inc 3 + 4: I/O and text — the app's whole OCP surface is bound
138/138 symbols across 53 modules. New: IFSelect, Interface, XSControl,
IGESData, STEPControl, IGESControl, RWStl, Graphic3d, NCollection, StdPrs.

**The full app suite passes against this wheel: 1797 passed, 1 skipped — the
same result as the stock wheel**, run from the parity venv.

Getting there needed six methods that no static analysis could have found:
`inventory --check` only sees symbols reached through an import, so a method
called on an instance is invisible to it. The suite found them in one pass, and
one of them (gp_Vec.Reverse, which every outward-normal probe calls) accounted
for 311 of the 255 failing tests on its own. The others: gp_Trsf.SetMirror over
a plane and a point, Geom_Surface.D0, BRep_Builder.MakeFace from a
triangulation, MakePipeShell.SetMode with a fixed binormal, and MakeFace from a
surface plus tolerance.

Open question **S5 is settled: no**. The wheel does not need OCCT's share/
resources. test_inc3_io.py asserts no CSF_* variable is set and then round-trips
STEP and IGES, reading the declared units back off both — which is exactly the
resource-less container the question was about.

The XSTEP readers keep the GIL, amending the blanket "file readers and writers"
line in design.md's GIL policy. STEP and IGES traffic in process-global
Interface_Static state, the IGES reader is documented as not thread-safe, and
the app already serialises imports behind a lock — so holding it costs nothing
and removes a class of question. RWStl, which touches no global state, releases.

XSControl_Reader and IGESData are registered although the app imports neither:
they are the reader base both concrete readers inherit their transfer surface
from, and the model-to-global-section chain the IGES unit probe walks.
2026-08-10 20:31:15 +02:00

58 lines
2.2 KiB
C++

/*
OCP.IGESControl — IGES read and write.
The reader inherits its transfer surface from XSControl_Reader. What is
specific here is the unit probe: the app reads the file's declared units
off the model's global section (IGESModel().GlobalSection().UnitName()),
which is why IGESData_IGESModel and IGESData_GlobalSection have to be
registered even though the app imports neither by name.
The writer is used only by the test suite, to produce IGES payloads to
import back; it is bound because those tests are part of the Inc 4 gate.
GIL held, per mod_XSControl.cpp — the IGES reader is explicitly documented
as not thread-safe.
*/
#include "../common/occt_module.h"
#include "../common/occt_policies.h"
#include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx>
#include <IGESControl_Writer.hxx>
#include <IGESData_GlobalSection.hxx>
#include <IGESData_IGESModel.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <XSControl_Reader.hxx>
void register_IGESControl(nb::module_ &root) {
nb::module_ m = ocp_submodule(root, "IGESControl");
nb::class_<IGESControl_Controller> controller(m, "IGESControl_Controller");
OCP_DEF_S(
controller, "Init", []() { return IGESControl_Controller::Init(); });
nb::class_<IGESControl_Reader, XSControl_Reader>(m, "IGESControl_Reader")
.def(nb::init<>())
.def("IGESModel", &IGESControl_Reader::IGESModel);
nb::class_<IGESControl_Writer>(m, "IGESControl_Writer")
.def(nb::init<>())
.def(nb::init<const Standard_CString, const Standard_Integer>(),
"unit_name"_a, "modecr"_a = 0)
// AddShape carries a Message_ProgressRange the app never supplies.
.def(
"AddShape",
[](IGESControl_Writer &self, const TopoDS_Shape &sh) {
return self.AddShape(sh);
},
"sh"_a, OCP_NOGIL)
.def("ComputeModel", &IGESControl_Writer::ComputeModel, OCP_NOGIL)
.def(
"Write",
[](IGESControl_Writer &self, const Standard_CString file,
const Standard_Boolean fnes) { return self.Write(file, fnes); },
"file"_a, "fnes"_a = Standard_False);
}