Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ On headless Linux the viewer test needs `xvfb-run ctest …`. CI on all three pl

**Error reporting.** Functions return `NULL`/`false` and write a message to `thread_local std::string g_last_error`. Callers retrieve it via `occt_templot_last_error()`. All public-facing implementations should `try { … } catch (Standard_Failure& e) { g_last_error = …; return …; }` around OCCT calls — OCCT throws on bad input.

**Diagnostic tracing.** Off by default. Enable via `OCCT_TEMPLOT_TRACE=1` env var or by calling `ot_set_trace(true)` from a host language. When on, `OT_TRACE(...)` lines from `occt_templot_*.cpp` flush to stderr immediately (so a hung call is still visible), and OCCT's own `Message::DefaultMessenger()` is wired to stderr so internal `ShapeFix` / `Sewing` / `BRepCheck` output surfaces too. Helper lives in `src/occt_templot_trace.{h,cpp}`. When adding a new long-running function, bracket the OCCT call with `OT_TRACE("ot_foo: phase X start")` / `OT_TRACE("ot_foo: phase X done")` so a stuck call is localisable from the log.

**Memory ownership.** Anything returned from `ot_*` that isn't a primitive must be paired with a free function: `ot_shape_free`, `ot_mesh_free`, `ot_edge_mesh_free`, `ot_viewer_destroy`, `ot_camera_destroy`, `ot_drawer_destroy`. The `OTMeshData` / `OTEdgeMeshData` structs hold heap-allocated arrays — the corresponding free functions zero out the struct so double-free is safe.

## OCCT dependency
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(SOURCES
src/occt_templot_mesh.cpp
src/occt_templot_viewer.cpp
src/occt_templot_render_data.cpp
src/occt_templot_trace.cpp
)

add_library(simpleOCCTVP SHARED ${SOURCES})
Expand Down
4 changes: 4 additions & 0 deletions pascal/occt_templot.pas
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ procedure occt_templot_shutdown; cdecl; external OCCT_LIB;
function occt_templot_version: PAnsiChar; cdecl; external OCCT_LIB;
function occt_templot_last_error: PAnsiChar; cdecl; external OCCT_LIB;

{ Diagnostic tracing — also gated by env var OCCT_TEMPLOT_TRACE=1 }
procedure ot_set_trace(enable: Boolean); cdecl; external OCCT_LIB;
function ot_get_trace: Boolean; cdecl; external OCCT_LIB;

{ ================================================================
Shape Handle
================================================================ }
Expand Down
9 changes: 9 additions & 0 deletions src/occt_templot.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ OT_EXPORT const char* occt_templot_version(void);
/** Return the last error message, or NULL if no error. Thread-local. */
OT_EXPORT const char* occt_templot_last_error(void);

/** Enable/disable diagnostic tracing to stderr at runtime.
* Also activated by setting the OCCT_TEMPLOT_TRACE=1 environment variable
* before the library loads. When on, ot_* function entry/exit lines and
* OCCT's internal Messenger output are flushed to stderr. */
OT_EXPORT void ot_set_trace(bool enable);

/** Returns the current trace state. */
OT_EXPORT bool ot_get_trace(void);

/* ================================================================
* Shape Handle (opaque)
* ================================================================ */
Expand Down
Loading
Loading