10C Inc 1: core modeling
Binds the modeling core the app builds every feature out of — 93 of its 138 symbols now resolve, up from 34. New modules: GeomAbs, Geom2d, Geom, TCollection, TColgp, TColStd, GProp, BRepGProp, Bnd, BRepBndLib, Adaptor3d, BRepAdaptor, GeomLProp, GeomAPI, BRepBuilderAPI, BOPAlgo, BRepAlgoAPI, BRepPrimAPI, GC, BRepMesh; gp and BRep_Tool completed. Three structural decisions: - BRepBuilderAPI_MakeShape carries Build/Shape/Generated/Modified/IsDeleted for every maker in the binding, so the booleans, the primitives and (later) the fillet builders all answer the app's duck-typed provenance layer through ordinary virtual dispatch. History lists come back copied, so they outlive the builder. - The executing two-argument BRepAlgoAPI constructors stay unbound; operands go in through SetArguments/SetTools. Section keeps Init1/Init2, which are plain setters. BOPAlgo moved up from Inc 2 — SetGlue needs its enum. - Adaptor3d is registered although the app never imports it: every method it calls on BRepAdaptor_Curve/Surface is a virtual declared there, so binding them once on the bases leaves mod_BRepAdaptor.cpp with just constructors. Gate: tests/test_inc1_modeling.py against reference values gen_fixtures.py now records from the stock wheel — measurements, per-face area/centroid in map order, mesh counts, and the boolean history map compared exactly, since that is the substrate the app's topological naming is built on. tools/sigdiff.py compares our bound surface against stock's, because a wrong nb::init<> is silent: MakePrism's five-argument form bound OCCT's semi-infinite gp_Dir overload (gp_Dir converts from gp_Vec), producing a valid solid of the wrong shape with the flags shifted along. The fixture digest caught it; sigdiff finds the class of bug directly, and now reports only one deliberate deviation.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
OCP.GeomAPI — point projection and surface fitting.
|
||||
|
||||
Both compute in their constructor and expose no deferred Build(), so they
|
||||
are bound exactly as stock does. The no-executing-constructor rule targets
|
||||
the BRepAlgoAPI booleans, where a deferred SetX/Build form exists and the
|
||||
constructor silently duplicates it; it does not apply here (see
|
||||
adding-symbols.md).
|
||||
|
||||
LowerDistanceParameters returns its two scalars as a tuple, which is how
|
||||
the app unpacks it. ProjectPointOnSurf keeps the GIL: it is measured in
|
||||
microseconds and runs inside per-face Python loops, where the release
|
||||
handshake would cost more than the call.
|
||||
*/
|
||||
|
||||
#include "../common/occt_module.h"
|
||||
#include "../common/occt_policies.h"
|
||||
|
||||
#include <nanobind/stl/tuple.h>
|
||||
|
||||
#include <GeomAPI_PointsToBSplineSurface.hxx>
|
||||
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
|
||||
void register_GeomAPI(nb::module_ &root) {
|
||||
nb::module_ m = ocp_submodule(root, "GeomAPI");
|
||||
|
||||
nb::class_<GeomAPI_ProjectPointOnSurf>(m, "GeomAPI_ProjectPointOnSurf")
|
||||
// The Extrema_ExtAlgo overload is left out: binding it would drag in
|
||||
// the Extrema enum only to carry a default the app never overrides,
|
||||
// and an unregistered default argument fails at module-init time.
|
||||
.def(nb::init<const gp_Pnt &, const opencascade::handle<Geom_Surface> &>(),
|
||||
"P"_a, "Surface"_a)
|
||||
.def("IsDone", &GeomAPI_ProjectPointOnSurf::IsDone)
|
||||
.def("NbPoints", &GeomAPI_ProjectPointOnSurf::NbPoints)
|
||||
.def("LowerDistance", &GeomAPI_ProjectPointOnSurf::LowerDistance)
|
||||
.def("NearestPoint", &GeomAPI_ProjectPointOnSurf::NearestPoint,
|
||||
OCP_RETURN_COPY)
|
||||
.def("LowerDistanceParameters",
|
||||
[](const GeomAPI_ProjectPointOnSurf &self) {
|
||||
Standard_Real u = 0.0, v = 0.0;
|
||||
self.LowerDistanceParameters(u, v);
|
||||
return std::make_tuple(u, v);
|
||||
});
|
||||
|
||||
nb::class_<GeomAPI_PointsToBSplineSurface>(m, "GeomAPI_PointsToBSplineSurface")
|
||||
.def(nb::init<>())
|
||||
.def(nb::init<const TColgp_Array2OfPnt &, const Standard_Integer,
|
||||
const Standard_Integer, const GeomAbs_Shape,
|
||||
const Standard_Real>(),
|
||||
"Points"_a, "DegMin"_a = 3, "DegMax"_a = 8,
|
||||
"Continuity"_a = GeomAbs_C2, "Tol3D"_a = 1.0e-3, OCP_NOGIL)
|
||||
.def("IsDone", &GeomAPI_PointsToBSplineSurface::IsDone)
|
||||
.def("Surface", &GeomAPI_PointsToBSplineSurface::Surface);
|
||||
}
|
||||
Reference in New Issue
Block a user