Four mechanical binding edits; the bound Python surface is unchanged (sigdiff compared the 7.9.3.1 dump against 8.0.1.1's in both directions and found no class, member or constructor arity moved), so the app needs no change. - NCollection_Utf8String is gone; NCollection_String is the same UTF-8 type. Python name kept, since the app imports it. - Standard_Failure lost its Standard_Transient RTTI when it moved to deriving std::exception; ExceptionType() replaced DynamicType()->Name() and returns the same class names the exception dispatch keys on. - FindKey gained a size_t overload beside the int one, so the plain member pointer is ambiguous; overload_cast picks the int form, which keeps the negative-index guard. - StdPrs moved from TKService to TKV3d, so CMakeLists links both. The byte-identity fixtures did NOT retire, contrary to the watchlist: all six round-trip to the same digests under the new kernel, as do the measurement, history and mesh-count blocks, so tests/data is untouched and the app's content-addressed BREP payloads stay valid. Gates: binding suite 83 passed, 138/138 symbols, sigdiff clean both directions, ASAN clean, app suite 1798 passed / 1 skipped (unchanged), sweep over 4486 parts with anchors_digest and every status unchanged, -m perf 16% faster on the 32-feature chain.
59 lines
2.3 KiB
C++
59 lines
2.3 KiB
C++
/*
|
|
OCP.StdPrs — glyph outlines as BRep.
|
|
|
|
Text emboss loads a bundled font and asks the builder for the text as a
|
|
compound of face outlines, holes already subtracted, which it then extrudes
|
|
into or out of the model.
|
|
|
|
Both are real classes, and the aliasing runs the opposite way from what the
|
|
8.0 watchlist expected: Font_BRepFont/Font_BRepTextBuilder are the typedefs
|
|
of these, not the reverse. What 8.0 did move is the package — StdPrs went
|
|
from TKService to TKV3d, which is why CMakeLists links both. The builder
|
|
image asserts neither pulls in libGL or libX11, so binding them costs the
|
|
runtime image nothing.
|
|
|
|
Rendering a glyph is FreeType work with no Python in it, so it releases the
|
|
GIL.
|
|
*/
|
|
|
|
#include "../common/occt_module.h"
|
|
#include "../common/occt_policies.h"
|
|
#include "../common/occt_transient.h"
|
|
|
|
#include <NCollection_String.hxx>
|
|
#include <StdPrs_BRepFont.hxx>
|
|
#include <StdPrs_BRepTextBuilder.hxx>
|
|
#include <TopoDS_Shape.hxx>
|
|
#include <gp_Ax3.hxx>
|
|
|
|
void register_StdPrs(nb::module_ &root) {
|
|
nb::module_ m = ocp_submodule(root, "StdPrs");
|
|
|
|
nb::class_<StdPrs_BRepFont, Standard_Transient>(m, "StdPrs_BRepFont")
|
|
.def(ocp_new<StdPrs_BRepFont>())
|
|
.def(
|
|
"Init",
|
|
[](StdPrs_BRepFont &self, const NCollection_String &path,
|
|
const Standard_Real size, const Standard_Integer faceId) {
|
|
return self.Init(path, size, faceId);
|
|
},
|
|
"theFontPath"_a, "theSize"_a, "theFaceId"_a, OCP_NOGIL)
|
|
.def("Release", &StdPrs_BRepFont::Release)
|
|
.def("Ascender", &StdPrs_BRepFont::Ascender)
|
|
.def("Descender", &StdPrs_BRepFont::Descender);
|
|
|
|
nb::class_<StdPrs_BRepTextBuilder>(m, "StdPrs_BRepTextBuilder")
|
|
.def(nb::init<>())
|
|
.def(
|
|
"Perform",
|
|
[](StdPrs_BRepTextBuilder &self, StdPrs_BRepFont &font,
|
|
const NCollection_String &text, const gp_Ax3 &penLoc,
|
|
const Graphic3d_HorizontalTextAlignment hAlign,
|
|
const Graphic3d_VerticalTextAlignment vAlign) {
|
|
return self.Perform(font, text, penLoc, hAlign, vAlign);
|
|
},
|
|
"theFont"_a, "theString"_a, "thePenLoc"_a = gp_Ax3(),
|
|
"theHAlign"_a = Graphic3d_HTA_LEFT,
|
|
"theVAlign"_a = Graphic3d_VTA_BOTTOM, OCP_RETURN_COPY, OCP_NOGIL);
|
|
}
|