From 889890fb9b5f5a0d1917aa712122cadb8a46d2e5 Mon Sep 17 00:00:00 2001 From: Vijai Kumar Date: Wed, 8 Jul 2026 15:58:05 +0200 Subject: [PATCH 1/2] Add BooleanObject::MergeToMeshObject() to materialize a boolean shape as a new mesh resource --- Autogenerated/Bindings/C/lib3mf.h | 9 +++++ .../Bindings/CDynamic/lib3mf_dynamic.cc | 10 +++++ .../Bindings/CDynamic/lib3mf_dynamic.h | 10 +++++ Autogenerated/Bindings/CSharp/Lib3MF.cs | 11 ++++++ Autogenerated/Bindings/Cpp/lib3mf_abi.hpp | 9 +++++ .../Bindings/Cpp/lib3mf_implicit.hpp | 16 ++++++++ .../Bindings/CppDynamic/lib3mf_dynamic.h | 10 +++++ .../Bindings/CppDynamic/lib3mf_dynamic.hpp | 30 +++++++++++++++ Autogenerated/Bindings/Go/lib3mf.go | 10 +++++ Autogenerated/Bindings/Go/lib3mf_dynamic.c | 19 ++++++++++ Autogenerated/Bindings/Go/lib3mf_dynamic.h | 13 +++++++ .../Bindings/Java8/lib3mf/BooleanObject.java | 18 +++++++++ .../Bindings/Java8/lib3mf/Lib3MFWrapper.java | 3 ++ .../Bindings/Java9/lib3mf/BooleanObject.java | 18 +++++++++ .../Bindings/Java9/lib3mf/Lib3MFWrapper.java | 3 ++ .../Bindings/NodeJS/lib3mf_dynamic.cc | 10 +++++ .../Bindings/NodeJS/lib3mf_dynamic.h | 10 +++++ .../Bindings/NodeJS/lib3mf_nodewrapper.cc | 24 ++++++++++++ .../Bindings/NodeJS/lib3mf_nodewrapper.h | 1 + Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas | 27 +++++++++++++ Autogenerated/Bindings/Python/Lib3MF.py | 20 ++++++++++ .../Bindings/WASM/lib3mf_bindings.cpp | 1 + Autogenerated/Source/lib3mf_abi.hpp | 9 +++++ Autogenerated/Source/lib3mf_interfaces.hpp | 6 +++ .../Source/lib3mf_interfacewrapper.cpp | 38 +++++++++++++++++++ AutomaticComponentToolkit/lib3mf.xml | 5 +++ Include/API/lib3mf_booleanobject.hpp | 2 + Source/API/lib3mf_booleanobject.cpp | 17 +++++++++ Tests/CPP_Bindings/Source/Boolean.cpp | 19 ++++++++++ patch_wasm_bindings.py | 3 +- 30 files changed, 380 insertions(+), 1 deletion(-) diff --git a/Autogenerated/Bindings/C/lib3mf.h b/Autogenerated/Bindings/C/lib3mf.h index a084d270..c6713a40 100644 --- a/Autogenerated/Bindings/C/lib3mf.h +++ b/Autogenerated/Bindings/C/lib3mf.h @@ -1708,6 +1708,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_addoperand(Lib3MF_BooleanObjec */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_getoperand(Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, sLib3MFTransform * pTransform); +/** +* Materializes the boolean shape into a newly created mesh object. +* +* @param[in] pBooleanObject - BooleanObject instance. +* @param[out] pMeshObject - new mesh object containing the tessellated boolean shape +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_mergetomeshobject(Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc index 55382593..550350f3 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc @@ -210,6 +210,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_BooleanObject_GetOperandCount = NULL; pWrapperTable->m_BooleanObject_AddOperand = NULL; pWrapperTable->m_BooleanObject_GetOperand = NULL; + pWrapperTable->m_BooleanObject_MergeToMeshObject = NULL; pWrapperTable->m_BeamLattice_GetMinLength = NULL; pWrapperTable->m_BeamLattice_SetMinLength = NULL; pWrapperTable->m_BeamLattice_GetClipping = NULL; @@ -2224,6 +2225,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_BooleanObject_GetOperand == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) GetProcAddress(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + #else // _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) dlsym(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_BooleanObject_MergeToMeshObject == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_BeamLattice_GetMinLength = (PLib3MFBeamLattice_GetMinLengthPtr) GetProcAddress(hLibrary, "lib3mf_beamlattice_getminlength"); #else // _WIN32 diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h index 778010c7..d18f473b 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h @@ -1695,6 +1695,15 @@ typedef Lib3MFResult (*PLib3MFBooleanObject_AddOperandPtr) (Lib3MF_BooleanObject */ typedef Lib3MFResult (*PLib3MFBooleanObject_GetOperandPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, sLib3MFTransform * pTransform); +/** +* Materializes the boolean shape into a newly created mesh object. +* +* @param[in] pBooleanObject - BooleanObject instance. +* @param[out] pMeshObject - new mesh object containing the tessellated boolean shape +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFBooleanObject_MergeToMeshObjectPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ @@ -7223,6 +7232,7 @@ typedef struct { PLib3MFBooleanObject_GetOperandCountPtr m_BooleanObject_GetOperandCount; PLib3MFBooleanObject_AddOperandPtr m_BooleanObject_AddOperand; PLib3MFBooleanObject_GetOperandPtr m_BooleanObject_GetOperand; + PLib3MFBooleanObject_MergeToMeshObjectPtr m_BooleanObject_MergeToMeshObject; PLib3MFBeamLattice_GetMinLengthPtr m_BeamLattice_GetMinLength; PLib3MFBeamLattice_SetMinLengthPtr m_BeamLattice_SetMinLength; PLib3MFBeamLattice_GetClippingPtr m_BeamLattice_GetClipping; diff --git a/Autogenerated/Bindings/CSharp/Lib3MF.cs b/Autogenerated/Bindings/CSharp/Lib3MF.cs index 162fa5c0..cc9cf06c 100644 --- a/Autogenerated/Bindings/CSharp/Lib3MF.cs +++ b/Autogenerated/Bindings/CSharp/Lib3MF.cs @@ -1219,6 +1219,9 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_booleanobject_getoperand", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 BooleanObject_GetOperand (IntPtr Handle, UInt32 AIndex, out IntPtr AOperandObject, out InternalTransform ATransform); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_booleanobject_mergetomeshobject", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 BooleanObject_MergeToMeshObject (IntPtr Handle, out IntPtr AMeshObject); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_beamlattice_getminlength", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 BeamLattice_GetMinLength (IntPtr Handle, out Double AMinLength); @@ -4843,6 +4846,14 @@ public sTransform GetOperand (UInt32 AIndex, out CMeshObject AOperandObject) return Internal.Lib3MFWrapper.convertInternalToStruct_Transform (intresultTransform); } + public CMeshObject MergeToMeshObject () + { + IntPtr newMeshObject = IntPtr.Zero; + + CheckError(Internal.Lib3MFWrapper.BooleanObject_MergeToMeshObject (Handle, out newMeshObject)); + return Internal.Lib3MFWrapper.PolymorphicFactory(newMeshObject); + } + } public class CBeamLattice : CBase diff --git a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp index d8ee4524..b247b735 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp @@ -1708,6 +1708,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_addoperand(Lib3MF_BooleanObjec */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_getoperand(Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, Lib3MF::sTransform * pTransform); +/** +* Materializes the boolean shape into a newly created mesh object. +* +* @param[in] pBooleanObject - BooleanObject instance. +* @param[out] pMeshObject - new mesh object containing the tessellated boolean shape +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_mergetomeshobject(Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp index 155fca4b..c0a282ad 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp @@ -1612,6 +1612,7 @@ class CBooleanObject : public CObject { inline Lib3MF_uint32 GetOperandCount(); inline void AddOperand(classParam pOperandObject, const sTransform & Transform); inline sTransform GetOperand(const Lib3MF_uint32 nIndex, PMeshObject & pOperandObject); + inline PMeshObject MergeToMeshObject(); }; /************************************************************************************************************************* @@ -6092,6 +6093,21 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) return resultTransform; } + /** + * CBooleanObject::MergeToMeshObject - Materializes the boolean shape into a newly created mesh object. + * @return new mesh object containing the tessellated boolean shape + */ + PMeshObject CBooleanObject::MergeToMeshObject() + { + Lib3MFHandle hMeshObject = (Lib3MFHandle)nullptr; + CheckError(lib3mf_booleanobject_mergetomeshobject(m_pHandle, &hMeshObject)); + + if (!hMeshObject) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hMeshObject))); + } + /** * Method definitions for class CBeamLattice */ diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h index ecbea3fc..b645518d 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h @@ -1695,6 +1695,15 @@ typedef Lib3MFResult (*PLib3MFBooleanObject_AddOperandPtr) (Lib3MF_BooleanObject */ typedef Lib3MFResult (*PLib3MFBooleanObject_GetOperandPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, Lib3MF::sTransform * pTransform); +/** +* Materializes the boolean shape into a newly created mesh object. +* +* @param[in] pBooleanObject - BooleanObject instance. +* @param[out] pMeshObject - new mesh object containing the tessellated boolean shape +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFBooleanObject_MergeToMeshObjectPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ @@ -7223,6 +7232,7 @@ typedef struct { PLib3MFBooleanObject_GetOperandCountPtr m_BooleanObject_GetOperandCount; PLib3MFBooleanObject_AddOperandPtr m_BooleanObject_AddOperand; PLib3MFBooleanObject_GetOperandPtr m_BooleanObject_GetOperand; + PLib3MFBooleanObject_MergeToMeshObjectPtr m_BooleanObject_MergeToMeshObject; PLib3MFBeamLattice_GetMinLengthPtr m_BeamLattice_GetMinLength; PLib3MFBeamLattice_SetMinLengthPtr m_BeamLattice_SetMinLength; PLib3MFBeamLattice_GetClippingPtr m_BeamLattice_GetClipping; diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp index e6484c37..63da359c 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp @@ -1636,6 +1636,7 @@ class CBooleanObject : public CObject { inline Lib3MF_uint32 GetOperandCount(); inline void AddOperand(classParam pOperandObject, const sTransform & Transform); inline sTransform GetOperand(const Lib3MF_uint32 nIndex, PMeshObject & pOperandObject); + inline PMeshObject MergeToMeshObject(); }; /************************************************************************************************************************* @@ -4210,6 +4211,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_BooleanObject_GetOperandCount = nullptr; pWrapperTable->m_BooleanObject_AddOperand = nullptr; pWrapperTable->m_BooleanObject_GetOperand = nullptr; + pWrapperTable->m_BooleanObject_MergeToMeshObject = nullptr; pWrapperTable->m_BeamLattice_GetMinLength = nullptr; pWrapperTable->m_BeamLattice_SetMinLength = nullptr; pWrapperTable->m_BeamLattice_GetClipping = nullptr; @@ -6220,6 +6222,15 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_BooleanObject_GetOperand == nullptr) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) GetProcAddress(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + #else // _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) dlsym(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_BooleanObject_MergeToMeshObject == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_BeamLattice_GetMinLength = (PLib3MFBeamLattice_GetMinLengthPtr) GetProcAddress(hLibrary, "lib3mf_beamlattice_getminlength"); #else // _WIN32 @@ -11402,6 +11413,10 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_BooleanObject_GetOperand == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_booleanobject_mergetomeshobject", (void**)&(pWrapperTable->m_BooleanObject_MergeToMeshObject)); + if ( (eLookupError != 0) || (pWrapperTable->m_BooleanObject_MergeToMeshObject == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_beamlattice_getminlength", (void**)&(pWrapperTable->m_BeamLattice_GetMinLength)); if ( (eLookupError != 0) || (pWrapperTable->m_BeamLattice_GetMinLength == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -15487,6 +15502,21 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) return resultTransform; } + /** + * CBooleanObject::MergeToMeshObject - Materializes the boolean shape into a newly created mesh object. + * @return new mesh object containing the tessellated boolean shape + */ + PMeshObject CBooleanObject::MergeToMeshObject() + { + Lib3MFHandle hMeshObject = (Lib3MFHandle)nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_BooleanObject_MergeToMeshObject(m_pHandle, &hMeshObject)); + + if (!hMeshObject) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hMeshObject))); + } + /** * Method definitions for class CBeamLattice */ diff --git a/Autogenerated/Bindings/Go/lib3mf.go b/Autogenerated/Bindings/Go/lib3mf.go index 96acdfb7..c83e7300 100644 --- a/Autogenerated/Bindings/Go/lib3mf.go +++ b/Autogenerated/Bindings/Go/lib3mf.go @@ -2718,6 +2718,16 @@ func (inst BooleanObject) GetOperand(index uint32) (MeshObject, Transform, error return inst.wrapperRef.NewMeshObject(operandObject), *(*Transform)(unsafe.Pointer(&transform)), nil } +// MergeToMeshObject materializes the boolean shape into a newly created mesh object. +func (inst BooleanObject) MergeToMeshObject() (MeshObject, error) { + var meshObject ref + ret := C.CCall_lib3mf_booleanobject_mergetomeshobject(inst.wrapperRef.LibraryHandle, inst.Ref, &meshObject) + if ret != 0 { + return MeshObject{}, makeError(uint32(ret)) + } + return inst.wrapperRef.NewMeshObject(meshObject), nil +} + // BeamLattice represents a Lib3MF class. type BeamLattice struct { diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.c b/Autogenerated/Bindings/Go/lib3mf_dynamic.c index a03226a4..57be8680 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.c +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.c @@ -210,6 +210,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_BooleanObject_GetOperandCount = NULL; pWrapperTable->m_BooleanObject_AddOperand = NULL; pWrapperTable->m_BooleanObject_GetOperand = NULL; + pWrapperTable->m_BooleanObject_MergeToMeshObject = NULL; pWrapperTable->m_BeamLattice_GetMinLength = NULL; pWrapperTable->m_BeamLattice_SetMinLength = NULL; pWrapperTable->m_BeamLattice_GetClipping = NULL; @@ -2224,6 +2225,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_BooleanObject_GetOperand == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) GetProcAddress(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + #else // _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) dlsym(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_BooleanObject_MergeToMeshObject == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_BeamLattice_GetMinLength = (PLib3MFBeamLattice_GetMinLengthPtr) GetProcAddress(hLibrary, "lib3mf_beamlattice_getminlength"); #else // _WIN32 @@ -8235,6 +8245,15 @@ Lib3MFResult CCall_lib3mf_booleanobject_getoperand(Lib3MFHandle libraryHandle, L } +Lib3MFResult CCall_lib3mf_booleanobject_mergetomeshobject(Lib3MFHandle libraryHandle, Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_BooleanObject_MergeToMeshObject (pBooleanObject, pMeshObject); +} + + Lib3MFResult CCall_lib3mf_beamlattice_getminlength(Lib3MFHandle libraryHandle, Lib3MF_BeamLattice pBeamLattice, Lib3MF_double * pMinLength) { if (libraryHandle == 0) diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.h b/Autogenerated/Bindings/Go/lib3mf_dynamic.h index a7a4de87..f0d950a6 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.h @@ -1695,6 +1695,15 @@ typedef Lib3MFResult (*PLib3MFBooleanObject_AddOperandPtr) (Lib3MF_BooleanObject */ typedef Lib3MFResult (*PLib3MFBooleanObject_GetOperandPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, sLib3MFTransform * pTransform); +/** +* Materializes the boolean shape into a newly created mesh object. +* +* @param[in] pBooleanObject - BooleanObject instance. +* @param[out] pMeshObject - new mesh object containing the tessellated boolean shape +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFBooleanObject_MergeToMeshObjectPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ @@ -7223,6 +7232,7 @@ typedef struct { PLib3MFBooleanObject_GetOperandCountPtr m_BooleanObject_GetOperandCount; PLib3MFBooleanObject_AddOperandPtr m_BooleanObject_AddOperand; PLib3MFBooleanObject_GetOperandPtr m_BooleanObject_GetOperand; + PLib3MFBooleanObject_MergeToMeshObjectPtr m_BooleanObject_MergeToMeshObject; PLib3MFBeamLattice_GetMinLengthPtr m_BeamLattice_GetMinLength; PLib3MFBeamLattice_SetMinLengthPtr m_BeamLattice_SetMinLength; PLib3MFBeamLattice_GetClippingPtr m_BeamLattice_GetClipping; @@ -8226,6 +8236,9 @@ Lib3MFResult CCall_lib3mf_booleanobject_addoperand(Lib3MFHandle libraryHandle, L Lib3MFResult CCall_lib3mf_booleanobject_getoperand(Lib3MFHandle libraryHandle, Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, sLib3MFTransform * pTransform); +Lib3MFResult CCall_lib3mf_booleanobject_mergetomeshobject(Lib3MFHandle libraryHandle, Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + + Lib3MFResult CCall_lib3mf_beamlattice_getminlength(Lib3MFHandle libraryHandle, Lib3MF_BeamLattice pBeamLattice, Lib3MF_double * pMinLength); diff --git a/Autogenerated/Bindings/Java8/lib3mf/BooleanObject.java b/Autogenerated/Bindings/Java8/lib3mf/BooleanObject.java index 79d619b6..8340db35 100644 --- a/Autogenerated/Bindings/Java8/lib3mf/BooleanObject.java +++ b/Autogenerated/Bindings/Java8/lib3mf/BooleanObject.java @@ -248,6 +248,24 @@ public static class GetOperandResult { public Transform Transform; } + /** + * Materializes the boolean shape into a newly created mesh object. + * + * @return new mesh object containing the tessellated boolean shape + * @throws Lib3MFException + */ + public MeshObject mergeToMeshObject() throws Lib3MFException { + Pointer bufferMeshObject = new Memory(8); + mWrapper.checkError(this, mWrapper.lib3mf_booleanobject_mergetomeshobject.invokeInt(new java.lang.Object[]{mHandle, bufferMeshObject})); + Pointer valueMeshObject = bufferMeshObject.getPointer(0); + MeshObject meshObject = null; + if (valueMeshObject == Pointer.NULL) { + throw new Lib3MFException(Lib3MFException.LIB3MF_ERROR_INVALIDPARAM, "MeshObject was a null pointer"); + } + meshObject = mWrapper.PolymorphicFactory(valueMeshObject, MeshObject.class); + return meshObject; + } + } diff --git a/Autogenerated/Bindings/Java8/lib3mf/Lib3MFWrapper.java b/Autogenerated/Bindings/Java8/lib3mf/Lib3MFWrapper.java index 780c8ef5..6ef31c15 100644 --- a/Autogenerated/Bindings/Java8/lib3mf/Lib3MFWrapper.java +++ b/Autogenerated/Bindings/Java8/lib3mf/Lib3MFWrapper.java @@ -1260,6 +1260,7 @@ public interface ContentEncryptionCallback extends Callback { protected com.sun.jna.Function lib3mf_booleanobject_getoperandcount; protected com.sun.jna.Function lib3mf_booleanobject_addoperand; protected com.sun.jna.Function lib3mf_booleanobject_getoperand; + protected com.sun.jna.Function lib3mf_booleanobject_mergetomeshobject; protected com.sun.jna.Function lib3mf_beamlattice_getminlength; protected com.sun.jna.Function lib3mf_beamlattice_setminlength; protected com.sun.jna.Function lib3mf_beamlattice_getclipping; @@ -1929,6 +1930,7 @@ public Lib3MFWrapper(String libraryPath) { lib3mf_booleanobject_getoperandcount = mLibrary.getFunction("lib3mf_booleanobject_getoperandcount"); lib3mf_booleanobject_addoperand = mLibrary.getFunction("lib3mf_booleanobject_addoperand"); lib3mf_booleanobject_getoperand = mLibrary.getFunction("lib3mf_booleanobject_getoperand"); + lib3mf_booleanobject_mergetomeshobject = mLibrary.getFunction("lib3mf_booleanobject_mergetomeshobject"); lib3mf_beamlattice_getminlength = mLibrary.getFunction("lib3mf_beamlattice_getminlength"); lib3mf_beamlattice_setminlength = mLibrary.getFunction("lib3mf_beamlattice_setminlength"); lib3mf_beamlattice_getclipping = mLibrary.getFunction("lib3mf_beamlattice_getclipping"); @@ -2597,6 +2599,7 @@ public Lib3MFWrapper(Pointer lookupPointer) throws Lib3MFException { lib3mf_booleanobject_getoperandcount = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_getoperandcount"); lib3mf_booleanobject_addoperand = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_addoperand"); lib3mf_booleanobject_getoperand = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_getoperand"); + lib3mf_booleanobject_mergetomeshobject = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_mergetomeshobject"); lib3mf_beamlattice_getminlength = loadFunctionByLookup(lookupMethod, "lib3mf_beamlattice_getminlength"); lib3mf_beamlattice_setminlength = loadFunctionByLookup(lookupMethod, "lib3mf_beamlattice_setminlength"); lib3mf_beamlattice_getclipping = loadFunctionByLookup(lookupMethod, "lib3mf_beamlattice_getclipping"); diff --git a/Autogenerated/Bindings/Java9/lib3mf/BooleanObject.java b/Autogenerated/Bindings/Java9/lib3mf/BooleanObject.java index 386fc407..cea50871 100644 --- a/Autogenerated/Bindings/Java9/lib3mf/BooleanObject.java +++ b/Autogenerated/Bindings/Java9/lib3mf/BooleanObject.java @@ -249,6 +249,24 @@ public static class GetOperandResult { public Transform Transform; } + /** + * Materializes the boolean shape into a newly created mesh object. + * + * @return new mesh object containing the tessellated boolean shape + * @throws Lib3MFException + */ + public MeshObject mergeToMeshObject() throws Lib3MFException { + Pointer bufferMeshObject = new Memory(8); + mWrapper.checkError(this, mWrapper.lib3mf_booleanobject_mergetomeshobject.invokeInt(new java.lang.Object[]{mHandle, bufferMeshObject})); + Pointer valueMeshObject = bufferMeshObject.getPointer(0); + MeshObject meshObject = null; + if (valueMeshObject == Pointer.NULL) { + throw new Lib3MFException(Lib3MFException.LIB3MF_ERROR_INVALIDPARAM, "MeshObject was a null pointer"); + } + meshObject = mWrapper.PolymorphicFactory(valueMeshObject, MeshObject.class); + return meshObject; + } + } diff --git a/Autogenerated/Bindings/Java9/lib3mf/Lib3MFWrapper.java b/Autogenerated/Bindings/Java9/lib3mf/Lib3MFWrapper.java index 780c8ef5..6ef31c15 100644 --- a/Autogenerated/Bindings/Java9/lib3mf/Lib3MFWrapper.java +++ b/Autogenerated/Bindings/Java9/lib3mf/Lib3MFWrapper.java @@ -1260,6 +1260,7 @@ public interface ContentEncryptionCallback extends Callback { protected com.sun.jna.Function lib3mf_booleanobject_getoperandcount; protected com.sun.jna.Function lib3mf_booleanobject_addoperand; protected com.sun.jna.Function lib3mf_booleanobject_getoperand; + protected com.sun.jna.Function lib3mf_booleanobject_mergetomeshobject; protected com.sun.jna.Function lib3mf_beamlattice_getminlength; protected com.sun.jna.Function lib3mf_beamlattice_setminlength; protected com.sun.jna.Function lib3mf_beamlattice_getclipping; @@ -1929,6 +1930,7 @@ public Lib3MFWrapper(String libraryPath) { lib3mf_booleanobject_getoperandcount = mLibrary.getFunction("lib3mf_booleanobject_getoperandcount"); lib3mf_booleanobject_addoperand = mLibrary.getFunction("lib3mf_booleanobject_addoperand"); lib3mf_booleanobject_getoperand = mLibrary.getFunction("lib3mf_booleanobject_getoperand"); + lib3mf_booleanobject_mergetomeshobject = mLibrary.getFunction("lib3mf_booleanobject_mergetomeshobject"); lib3mf_beamlattice_getminlength = mLibrary.getFunction("lib3mf_beamlattice_getminlength"); lib3mf_beamlattice_setminlength = mLibrary.getFunction("lib3mf_beamlattice_setminlength"); lib3mf_beamlattice_getclipping = mLibrary.getFunction("lib3mf_beamlattice_getclipping"); @@ -2597,6 +2599,7 @@ public Lib3MFWrapper(Pointer lookupPointer) throws Lib3MFException { lib3mf_booleanobject_getoperandcount = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_getoperandcount"); lib3mf_booleanobject_addoperand = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_addoperand"); lib3mf_booleanobject_getoperand = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_getoperand"); + lib3mf_booleanobject_mergetomeshobject = loadFunctionByLookup(lookupMethod, "lib3mf_booleanobject_mergetomeshobject"); lib3mf_beamlattice_getminlength = loadFunctionByLookup(lookupMethod, "lib3mf_beamlattice_getminlength"); lib3mf_beamlattice_setminlength = loadFunctionByLookup(lookupMethod, "lib3mf_beamlattice_setminlength"); lib3mf_beamlattice_getclipping = loadFunctionByLookup(lookupMethod, "lib3mf_beamlattice_getclipping"); diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc index 55382593..550350f3 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc @@ -210,6 +210,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_BooleanObject_GetOperandCount = NULL; pWrapperTable->m_BooleanObject_AddOperand = NULL; pWrapperTable->m_BooleanObject_GetOperand = NULL; + pWrapperTable->m_BooleanObject_MergeToMeshObject = NULL; pWrapperTable->m_BeamLattice_GetMinLength = NULL; pWrapperTable->m_BeamLattice_SetMinLength = NULL; pWrapperTable->m_BeamLattice_GetClipping = NULL; @@ -2224,6 +2225,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_BooleanObject_GetOperand == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) GetProcAddress(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + #else // _WIN32 + pWrapperTable->m_BooleanObject_MergeToMeshObject = (PLib3MFBooleanObject_MergeToMeshObjectPtr) dlsym(hLibrary, "lib3mf_booleanobject_mergetomeshobject"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_BooleanObject_MergeToMeshObject == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_BeamLattice_GetMinLength = (PLib3MFBeamLattice_GetMinLengthPtr) GetProcAddress(hLibrary, "lib3mf_beamlattice_getminlength"); #else // _WIN32 diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h index 778010c7..d18f473b 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h @@ -1695,6 +1695,15 @@ typedef Lib3MFResult (*PLib3MFBooleanObject_AddOperandPtr) (Lib3MF_BooleanObject */ typedef Lib3MFResult (*PLib3MFBooleanObject_GetOperandPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, sLib3MFTransform * pTransform); +/** +* Materializes the boolean shape into a newly created mesh object. +* +* @param[in] pBooleanObject - BooleanObject instance. +* @param[out] pMeshObject - new mesh object containing the tessellated boolean shape +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFBooleanObject_MergeToMeshObjectPtr) (Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ @@ -7223,6 +7232,7 @@ typedef struct { PLib3MFBooleanObject_GetOperandCountPtr m_BooleanObject_GetOperandCount; PLib3MFBooleanObject_AddOperandPtr m_BooleanObject_AddOperand; PLib3MFBooleanObject_GetOperandPtr m_BooleanObject_GetOperand; + PLib3MFBooleanObject_MergeToMeshObjectPtr m_BooleanObject_MergeToMeshObject; PLib3MFBeamLattice_GetMinLengthPtr m_BeamLattice_GetMinLength; PLib3MFBeamLattice_SetMinLengthPtr m_BeamLattice_SetMinLength; PLib3MFBeamLattice_GetClippingPtr m_BeamLattice_GetClipping; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc index 0abfe25f..e7978aa7 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc @@ -6671,6 +6671,7 @@ void CLib3MFBooleanObject::Init() NODE_SET_PROTOTYPE_METHOD(tpl, "GetOperandCount", GetOperandCount); NODE_SET_PROTOTYPE_METHOD(tpl, "AddOperand", AddOperand); NODE_SET_PROTOTYPE_METHOD(tpl, "GetOperand", GetOperand); + NODE_SET_PROTOTYPE_METHOD(tpl, "MergeToMeshObject", MergeToMeshObject); constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); } @@ -7027,6 +7028,29 @@ void CLib3MFBooleanObject::GetOperand(const FunctionCallbackInfo& args) } } + +void CLib3MFBooleanObject::MergeToMeshObject(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + Lib3MFHandle hReturnMeshObject = nullptr; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method MergeToMeshObject."); + if (wrapperTable->m_BooleanObject_MergeToMeshObject == nullptr) + throw std::runtime_error("Could not call Lib3MF method BooleanObject::MergeToMeshObject."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_BooleanObject_MergeToMeshObject(instanceHandle, &hReturnMeshObject); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + Local instanceObjMeshObject = CLib3MFMeshObject::NewInstance(args.Holder(), hReturnMeshObject); + args.GetReturnValue().Set(instanceObjMeshObject); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + /************************************************************************************************************************* Class CLib3MFBeamLattice Implementation **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h index 4e2abed2..93f62743 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h @@ -680,6 +680,7 @@ class CLib3MFBooleanObject : public CLib3MFBaseClass { static void GetOperandCount(const v8::FunctionCallbackInfo& args); static void AddOperand(const v8::FunctionCallbackInfo& args); static void GetOperand(const v8::FunctionCallbackInfo& args); + static void MergeToMeshObject(const v8::FunctionCallbackInfo& args); public: CLib3MFBooleanObject(); diff --git a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas index 18fc878e..68cada15 100644 --- a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas +++ b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas @@ -2289,6 +2289,15 @@ TLib3MFModel = class; *) TLib3MFBooleanObject_GetOperandFunc = function(pBooleanObject: TLib3MFHandle; const nIndex: Cardinal; out pOperandObject: TLib3MFHandle; pTransform: PLib3MFTransform): TLib3MFResult; cdecl; + (** + * Materializes the boolean shape into a newly created mesh object. + * + * @param[in] pBooleanObject - BooleanObject instance. + * @param[out] pMeshObject - new mesh object containing the tessellated boolean shape + * @return error code or 0 (success) + *) + TLib3MFBooleanObject_MergeToMeshObjectFunc = function(pBooleanObject: TLib3MFHandle; out pMeshObject: TLib3MFHandle): TLib3MFResult; cdecl; + (************************************************************************************************************************* Function type definitions for BeamLattice @@ -8225,6 +8234,7 @@ TLib3MFBooleanObject = class(TLib3MFObject) function GetOperandCount(): Cardinal; procedure AddOperand(const AOperandObject: TLib3MFMeshObject; const ATransform: TLib3MFTransform); function GetOperand(const AIndex: Cardinal; out AOperandObject: TLib3MFMeshObject): TLib3MFTransform; + function MergeToMeshObject(): TLib3MFMeshObject; end; @@ -9913,6 +9923,7 @@ TLib3MFWrapper = class(TObject) FLib3MFBooleanObject_GetOperandCountFunc: TLib3MFBooleanObject_GetOperandCountFunc; FLib3MFBooleanObject_AddOperandFunc: TLib3MFBooleanObject_AddOperandFunc; FLib3MFBooleanObject_GetOperandFunc: TLib3MFBooleanObject_GetOperandFunc; + FLib3MFBooleanObject_MergeToMeshObjectFunc: TLib3MFBooleanObject_MergeToMeshObjectFunc; FLib3MFBeamLattice_GetMinLengthFunc: TLib3MFBeamLattice_GetMinLengthFunc; FLib3MFBeamLattice_SetMinLengthFunc: TLib3MFBeamLattice_SetMinLengthFunc; FLib3MFBeamLattice_GetClippingFunc: TLib3MFBeamLattice_GetClippingFunc; @@ -10587,6 +10598,7 @@ TLib3MFWrapper = class(TObject) property Lib3MFBooleanObject_GetOperandCountFunc: TLib3MFBooleanObject_GetOperandCountFunc read FLib3MFBooleanObject_GetOperandCountFunc; property Lib3MFBooleanObject_AddOperandFunc: TLib3MFBooleanObject_AddOperandFunc read FLib3MFBooleanObject_AddOperandFunc; property Lib3MFBooleanObject_GetOperandFunc: TLib3MFBooleanObject_GetOperandFunc read FLib3MFBooleanObject_GetOperandFunc; + property Lib3MFBooleanObject_MergeToMeshObjectFunc: TLib3MFBooleanObject_MergeToMeshObjectFunc read FLib3MFBooleanObject_MergeToMeshObjectFunc; property Lib3MFBeamLattice_GetMinLengthFunc: TLib3MFBeamLattice_GetMinLengthFunc read FLib3MFBeamLattice_GetMinLengthFunc; property Lib3MFBeamLattice_SetMinLengthFunc: TLib3MFBeamLattice_SetMinLengthFunc read FLib3MFBeamLattice_SetMinLengthFunc; property Lib3MFBeamLattice_GetClippingFunc: TLib3MFBeamLattice_GetClippingFunc read FLib3MFBeamLattice_GetClippingFunc; @@ -14506,6 +14518,17 @@ implementation AOperandObject := TLib3MFMeshObject.Create(FWrapper, HOperandObject); end; + function TLib3MFBooleanObject.MergeToMeshObject(): TLib3MFMeshObject; + var + HMeshObject: TLib3MFHandle; + begin + Result := nil; + HMeshObject := nil; + FWrapper.CheckError(Self, FWrapper.Lib3MFBooleanObject_MergeToMeshObjectFunc(FHandle, HMeshObject)); + if Assigned(HMeshObject) then + Result := TLib3MFPolymorphicFactory.Make(FWrapper, HMeshObject); + end; + (************************************************************************************************************************* Class implementation for BeamLattice **************************************************************************************************************************) @@ -20732,6 +20755,7 @@ implementation FLib3MFBooleanObject_GetOperandCountFunc := LoadFunction('lib3mf_booleanobject_getoperandcount'); FLib3MFBooleanObject_AddOperandFunc := LoadFunction('lib3mf_booleanobject_addoperand'); FLib3MFBooleanObject_GetOperandFunc := LoadFunction('lib3mf_booleanobject_getoperand'); + FLib3MFBooleanObject_MergeToMeshObjectFunc := LoadFunction('lib3mf_booleanobject_mergetomeshobject'); FLib3MFBeamLattice_GetMinLengthFunc := LoadFunction('lib3mf_beamlattice_getminlength'); FLib3MFBeamLattice_SetMinLengthFunc := LoadFunction('lib3mf_beamlattice_setminlength'); FLib3MFBeamLattice_GetClippingFunc := LoadFunction('lib3mf_beamlattice_getclipping'); @@ -21729,6 +21753,9 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_booleanobject_getoperand'), @FLib3MFBooleanObject_GetOperandFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_booleanobject_mergetomeshobject'), @FLib3MFBooleanObject_MergeToMeshObjectFunc); if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_beamlattice_getminlength'), @FLib3MFBeamLattice_GetMinLengthFunc); diff --git a/Autogenerated/Bindings/Python/Lib3MF.py b/Autogenerated/Bindings/Python/Lib3MF.py index caeed505..9eccb935 100644 --- a/Autogenerated/Bindings/Python/Lib3MF.py +++ b/Autogenerated/Bindings/Python/Lib3MF.py @@ -541,6 +541,7 @@ class FunctionTable: lib3mf_booleanobject_getoperandcount = None lib3mf_booleanobject_addoperand = None lib3mf_booleanobject_getoperand = None + lib3mf_booleanobject_mergetomeshobject = None lib3mf_beamlattice_getminlength = None lib3mf_beamlattice_setminlength = None lib3mf_beamlattice_getclipping = None @@ -2530,6 +2531,12 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint32, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(Transform)) self.lib.lib3mf_booleanobject_getoperand = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_booleanobject_mergetomeshobject")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)) + self.lib.lib3mf_booleanobject_mergetomeshobject = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_beamlattice_getminlength")), methodAddress) if err != 0: raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) @@ -5976,6 +5983,9 @@ def _loadFunctionTable(self): self.lib.lib3mf_booleanobject_getoperand.restype = ctypes.c_int32 self.lib.lib3mf_booleanobject_getoperand.argtypes = [ctypes.c_void_p, ctypes.c_uint32, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(Transform)] + self.lib.lib3mf_booleanobject_mergetomeshobject.restype = ctypes.c_int32 + self.lib.lib3mf_booleanobject_mergetomeshobject.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)] + self.lib.lib3mf_beamlattice_getminlength.restype = ctypes.c_int32 self.lib.lib3mf_beamlattice_getminlength.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_double)] @@ -9295,6 +9305,16 @@ def GetOperand(self, Index, OperandObjectObject = None): return OperandObjectObject, pTransform + def MergeToMeshObject(self): + MeshObjectHandle = ctypes.c_void_p() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_booleanobject_mergetomeshobject(self._handle, MeshObjectHandle)) + if MeshObjectHandle: + MeshObjectObject = self._wrapper._polymorphicFactory(MeshObjectHandle) + else: + raise ELib3MFException(ErrorCodes.INVALIDCAST, 'Invalid return/output value') + + return MeshObjectObject + ''' Class Implementation for BeamLattice diff --git a/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp b/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp index 67e8f0e0..5754fcad 100644 --- a/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp +++ b/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp @@ -2001,6 +2001,7 @@ EMSCRIPTEN_BINDINGS(Lib3MF) { .function("GetOperandCount", &CBooleanObject::GetOperandCount) .function("AddOperand", &wrap_BooleanObject_AddOperand) .function("GetOperand", &wrap_BooleanObject_GetOperand) + .function("MergeToMeshObject", &CBooleanObject::MergeToMeshObject) ; class_>("CBeamLattice") .smart_ptr>("shared_ptr") diff --git a/Autogenerated/Source/lib3mf_abi.hpp b/Autogenerated/Source/lib3mf_abi.hpp index d8ee4524..b247b735 100644 --- a/Autogenerated/Source/lib3mf_abi.hpp +++ b/Autogenerated/Source/lib3mf_abi.hpp @@ -1708,6 +1708,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_addoperand(Lib3MF_BooleanObjec */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_getoperand(Lib3MF_BooleanObject pBooleanObject, Lib3MF_uint32 nIndex, Lib3MF_MeshObject * pOperandObject, Lib3MF::sTransform * pTransform); +/** +* Materializes the boolean shape into a newly created mesh object. +* +* @param[in] pBooleanObject - BooleanObject instance. +* @param[out] pMeshObject - new mesh object containing the tessellated boolean shape +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_booleanobject_mergetomeshobject(Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ diff --git a/Autogenerated/Source/lib3mf_interfaces.hpp b/Autogenerated/Source/lib3mf_interfaces.hpp index c536bb42..9a71c58f 100644 --- a/Autogenerated/Source/lib3mf_interfaces.hpp +++ b/Autogenerated/Source/lib3mf_interfaces.hpp @@ -1920,6 +1920,12 @@ class IBooleanObject : public virtual IObject { */ virtual Lib3MF::sTransform GetOperand(const Lib3MF_uint32 nIndex, IMeshObject*& pOperandObject) = 0; + /** + * IBooleanObject::MergeToMeshObject - Materializes the boolean shape into a newly created mesh object. + * @return new mesh object containing the tessellated boolean shape + */ + virtual IMeshObject * MergeToMeshObject() = 0; + }; typedef IBaseSharedPtr PIBooleanObject; diff --git a/Autogenerated/Source/lib3mf_interfacewrapper.cpp b/Autogenerated/Source/lib3mf_interfacewrapper.cpp index dfcb1755..d428a826 100644 --- a/Autogenerated/Source/lib3mf_interfacewrapper.cpp +++ b/Autogenerated/Source/lib3mf_interfacewrapper.cpp @@ -6117,6 +6117,42 @@ Lib3MFResult lib3mf_booleanobject_getoperand(Lib3MF_BooleanObject pBooleanObject } } +Lib3MFResult lib3mf_booleanobject_mergetomeshobject(Lib3MF_BooleanObject pBooleanObject, Lib3MF_MeshObject * pMeshObject) +{ + IBase* pIBaseClass = (IBase *)pBooleanObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pBooleanObject, "BooleanObject", "MergeToMeshObject"); + } + if (pMeshObject == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseMeshObject(nullptr); + IBooleanObject* pIBooleanObject = dynamic_cast(pIBaseClass); + if (!pIBooleanObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseMeshObject = pIBooleanObject->MergeToMeshObject(); + + *pMeshObject = (IBase*)(pBaseMeshObject); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("MeshObject", *pMeshObject); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + /************************************************************************************************************************* Class implementation for BeamLattice @@ -25351,6 +25387,8 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_booleanobject_addoperand; if (sProcName == "lib3mf_booleanobject_getoperand") *ppProcAddress = (void*) &lib3mf_booleanobject_getoperand; + if (sProcName == "lib3mf_booleanobject_mergetomeshobject") + *ppProcAddress = (void*) &lib3mf_booleanobject_mergetomeshobject; if (sProcName == "lib3mf_beamlattice_getminlength") *ppProcAddress = (void*) &lib3mf_beamlattice_getminlength; if (sProcName == "lib3mf_beamlattice_setminlength") diff --git a/AutomaticComponentToolkit/lib3mf.xml b/AutomaticComponentToolkit/lib3mf.xml index 07ee18dd..704df7c5 100644 --- a/AutomaticComponentToolkit/lib3mf.xml +++ b/AutomaticComponentToolkit/lib3mf.xml @@ -1241,6 +1241,11 @@ + + + diff --git a/Include/API/lib3mf_booleanobject.hpp b/Include/API/lib3mf_booleanobject.hpp index ae07c40a..d39dcd00 100644 --- a/Include/API/lib3mf_booleanobject.hpp +++ b/Include/API/lib3mf_booleanobject.hpp @@ -112,6 +112,8 @@ class CBooleanObject : public virtual IBooleanObject, public virtual CObject { Lib3MF::sTransform GetOperand(const Lib3MF_uint32 nIndex, IMeshObject*& pOperandObject) override; + IMeshObject * MergeToMeshObject() override; + }; } // namespace Impl diff --git a/Source/API/lib3mf_booleanobject.cpp b/Source/API/lib3mf_booleanobject.cpp index 7fb868e2..6b2b32a0 100644 --- a/Source/API/lib3mf_booleanobject.cpp +++ b/Source/API/lib3mf_booleanobject.cpp @@ -36,6 +36,7 @@ Abstract: This is a stub class definition of CBooleanObject #include "Model/Classes/NMR_ModelBooleanObject.h" #include "Model/Classes/NMR_ModelComponentsObject.h" #include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_Model.h" #include "lib3mf_utils.hpp" using namespace Lib3MF::Impl; @@ -181,3 +182,19 @@ Lib3MF::sTransform CBooleanObject::GetOperand(const Lib3MF_uint32 nIndex, IMeshO pObject.release(); return Lib3MF::MatrixToTransform(operand->getTransform()); } + +IMeshObject * CBooleanObject::MergeToMeshObject() +{ + auto pBooleanObject = booleanObject(); + auto pModel = pBooleanObject->getModel(); + if (!pModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT); + + NMR::PMesh pMesh = std::make_shared(); + pBooleanObject->mergeToMesh(pMesh.get(), NMR::fnMATRIX3_identity()); + + NMR::PModelMeshObject pMeshObject = std::make_shared(pModel->generateResourceID(), pModel, pMesh); + pModel->addResource(pMeshObject); + + return new CMeshObject(pMeshObject); +} diff --git a/Tests/CPP_Bindings/Source/Boolean.cpp b/Tests/CPP_Bindings/Source/Boolean.cpp index 8bd670a2..a5aadd42 100644 --- a/Tests/CPP_Bindings/Source/Boolean.cpp +++ b/Tests/CPP_Bindings/Source/Boolean.cpp @@ -407,6 +407,25 @@ TEST_F(BooleanRead, STLWriterMaterializesUnionBooleanObject) ASSERT_FALSE(buffer.empty()); } +TEST_F(BooleanRead, MergeToMeshObjectMaterializesUnionBooleanObject) +{ + auto model = wrapper->CreateModel(); + auto baseMesh = addBoxMesh(model); + auto operandMesh = addBoxMesh(model); + auto booleanObject = model->AddBooleanObject(); + + booleanObject->SetBaseObject(baseMesh.get(), wrapper->GetIdentityTransform()); + booleanObject->SetOperation(Lib3MF::eBooleanOperation::Union); + booleanObject->AddOperand(operandMesh.get(), wrapper->GetTranslationTransform(1.0, 0.0, 0.0)); + + auto mergedMesh = booleanObject->MergeToMeshObject(); + ASSERT_TRUE(mergedMesh->IsMeshObject()); + ASSERT_NE(mergedMesh->GetResourceID(), booleanObject->GetResourceID()); + ASSERT_GT(mergedMesh->GetVertexCount(), 0u); + ASSERT_GT(mergedMesh->GetTriangleCount(), 0u); + ASSERT_EQ(model->GetMeshObjects()->Count(), 3u); +} + TEST_F(BooleanRead, STLWriterRejectsNonUnionBooleanWithoutCSG) { auto testOperation = [&](Lib3MF::eBooleanOperation operation) { diff --git a/patch_wasm_bindings.py b/patch_wasm_bindings.py index eaf6fde3..e7cbecc2 100644 --- a/patch_wasm_bindings.py +++ b/patch_wasm_bindings.py @@ -5,7 +5,8 @@ from pathlib import Path -DEFAULT_BINDING = Path("Autogenerated/Bindings/WASM/lib3mf_bindings.cpp") +SCRIPT_DIR = Path(__file__).resolve().parent +DEFAULT_BINDING = SCRIPT_DIR / "Autogenerated/Bindings/WASM/lib3mf_bindings.cpp" BOOLEAN_BROKEN = """static emscripten::val wrap_BooleanObject_GetOperand(CBooleanObject &self, const Lib3MF_uint32& Index) { From 659fbbebbbf78a83d3d71c4d9f00ae6dddc97906 Mon Sep 17 00:00:00 2001 From: Vijai Kumar Date: Tue, 14 Jul 2026 20:46:08 +0200 Subject: [PATCH 2/2] Patch lib3mf bindings temporarily. GetVertex() is missing for slice stack. Makes it extrmely hard to implement anything in viewer side --- .github/workflows/build.yml | 2 + .../Bindings/WASM/lib3mf_bindings.cpp | 7 ++ Tests/SliceVertex.mjs | 97 +++++++++++++++++++ patch_wasm_bindings.py | 34 +++++++ 4 files changed, 140 insertions(+) create mode 100644 Tests/SliceVertex.mjs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27de8d79..43616724 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -169,6 +169,8 @@ jobs: run: | emcmake cmake -S . -B build/wasm -DLIB3MF_BUILD_WASM=ON -DCMAKE_BUILD_TYPE=Release cmake --build build/wasm --target lib3mf_wasm -j"$(nproc)" + - name: Test indexed WASM slice vertices + run: node Tests/SliceVertex.mjs Tests/TestFiles/Slice/MultiSliceStack_TwoFiles.3mf - name: Package WASM artifact run: | mkdir -p build/wasm-artifact diff --git a/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp b/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp index 5754fcad..2b938474 100644 --- a/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp +++ b/Autogenerated/Bindings/WASM/lib3mf_bindings.cpp @@ -1191,6 +1191,12 @@ static emscripten::val wrap_Slice_GetVertices(CSlice &self) { return output; } +static sPosition2DWrapper wrap_Slice_GetVertex(CSlice &self, const Lib3MF_uint64& Index) { + std::vector vertices; + self.GetVertices(vertices); + return sPosition2DWrapper{vertices.at(static_cast(Index))}; +} + static emscripten::val wrap_Slice_GetPolygonIndices(CSlice &self, const Lib3MF_uint64& Index) { emscripten::val output = emscripten::val::object(); std::vector Indices; @@ -2612,6 +2618,7 @@ EMSCRIPTEN_BINDINGS(Lib3MF) { .function("SetVertices", &wrap_Slice_SetVertices) .function("GetVertices", &wrap_Slice_GetVertices) .function("GetVertexCount", &CSlice::GetVertexCount) + .function("GetVertex", &wrap_Slice_GetVertex) .function("AddPolygon", &CSlice::AddPolygon) .function("GetPolygonCount", &CSlice::GetPolygonCount) .function("SetPolygonIndices", &CSlice::SetPolygonIndices) diff --git a/Tests/SliceVertex.mjs b/Tests/SliceVertex.mjs new file mode 100644 index 00000000..8aab4c38 --- /dev/null +++ b/Tests/SliceVertex.mjs @@ -0,0 +1,97 @@ +import assert from "node:assert/strict"; +import fs from "node:fs"; +import path from "node:path"; +import { pathToFileURL } from "node:url"; + +const repoRoot = path.resolve(import.meta.dirname, ".."); +const modulePath = path.join(repoRoot, "build/wasm/lib3mf.js"); +const inputPaths = process.argv.slice(2); + +if (!inputPaths.length) { + console.error("Usage: node Tests/SliceVertex.mjs [file.3mf ...]"); + process.exit(1); +} + +const { default: createLib3mf } = await import(pathToFileURL(modulePath)); +const lib = await createLib3mf(); + +const safeDelete = (value) => { + try { + value?.delete?.(); + } catch { + // Cleanup must not hide the assertion that caused a test failure. + } +}; + +const toNumber = (value) => typeof value === "bigint" ? Number(value) : Number(value); + +for (const inputPath of inputPaths) { + const absolutePath = path.resolve(inputPath); + const virtualPath = `/slice-vertex-${path.basename(inputPath)}`; + const wrapper = new lib.CWrapper(); + const model = wrapper.CreateModel(); + const reader = model.QueryReader("3mf"); + let iterator; + let stackCount = 0; + let sliceCount = 0; + let sampledVertexCount = 0; + + try { + lib.FS.writeFile(virtualPath, new Uint8Array(fs.readFileSync(absolutePath))); + reader.ReadFromFile(virtualPath); + iterator = model.GetSliceStacks(); + + while (iterator.MoveNext()) { + const stack = iterator.GetCurrentSliceStack(); + try { + stackCount += 1; + const count = toNumber(stack.GetSliceCount()); + for (let sliceIndex = 0; sliceIndex < count; sliceIndex += 1) { + const slice = stack.GetSlice(sliceIndex); + try { + sliceCount += 1; + const vertexCount = toNumber(slice.GetVertexCount()); + if (!vertexCount) continue; + + const sampleIndices = [...new Set([ + 0, + Math.floor(vertexCount / 2), + vertexCount - 1, + ])]; + + for (const vertexIndex of sampleIndices) { + const vertex = slice.GetVertex(vertexIndex); + try { + assert.ok(vertex, `Missing vertex ${vertexIndex} in slice ${sliceIndex}`); + assert.ok(Number.isFinite(vertex.get_Coordinates0()), "Slice vertex X must be finite"); + assert.ok(Number.isFinite(vertex.get_Coordinates1()), "Slice vertex Y must be finite"); + sampledVertexCount += 1; + } finally { + safeDelete(vertex); + } + } + } finally { + safeDelete(slice); + } + } + } finally { + safeDelete(stack); + } + } + + assert.ok(stackCount > 0, `${inputPath} must contain a slice stack`); + assert.ok(sliceCount > 0, `${inputPath} must contain slices`); + assert.ok(sampledVertexCount > 0, `${inputPath} must expose indexed slice vertices`); + console.log(`${path.basename(inputPath)}: ${stackCount} stacks, ${sliceCount} slices, ${sampledVertexCount} indexed vertices sampled`); + } finally { + try { + lib.FS.unlink(virtualPath); + } catch { + // The virtual file may not exist if setup failed. + } + safeDelete(iterator); + safeDelete(reader); + safeDelete(model); + safeDelete(wrapper); + } +} diff --git a/patch_wasm_bindings.py b/patch_wasm_bindings.py index e7cbecc2..2864ff18 100644 --- a/patch_wasm_bindings.py +++ b/patch_wasm_bindings.py @@ -166,6 +166,24 @@ ] +SLICE_GET_VERTEX_ANCHOR = """static emscripten::val wrap_Slice_GetPolygonIndices(CSlice &self, const Lib3MF_uint64& Index) {""" + +SLICE_GET_VERTEX_WRAPPER = """static sPosition2DWrapper wrap_Slice_GetVertex(CSlice &self, const Lib3MF_uint64& Index) { + std::vector vertices; + self.GetVertices(vertices); + return sPosition2DWrapper{vertices.at(static_cast(Index))}; +} + +static emscripten::val wrap_Slice_GetPolygonIndices(CSlice &self, const Lib3MF_uint64& Index) {""" + +SLICE_GET_VERTEX_BINDING_ANCHOR = """ .function("GetVertexCount", &CSlice::GetVertexCount) + .function("AddPolygon", &CSlice::AddPolygon)""" + +SLICE_GET_VERTEX_BINDING = """ .function("GetVertexCount", &CSlice::GetVertexCount) + .function("GetVertex", &wrap_Slice_GetVertex) + .function("AddPolygon", &CSlice::AddPolygon)""" + + def apply_literal_patch(contents: str, old: str, new: str, description: str) -> tuple[str, bool]: if new in contents: return contents, False @@ -196,6 +214,22 @@ def main() -> int: ) changed = changed or local_changed + contents, local_changed = apply_literal_patch( + contents, + SLICE_GET_VERTEX_ANCHOR, + SLICE_GET_VERTEX_WRAPPER, + "Slice_GetVertex wrapper", + ) + changed = changed or local_changed + + contents, local_changed = apply_literal_patch( + contents, + SLICE_GET_VERTEX_BINDING_ANCHOR, + SLICE_GET_VERTEX_BINDING, + "Slice.GetVertex binding", + ) + changed = changed or local_changed + if changed: target.write_text(contents, encoding="utf-8") print(f"{target}: patched WASM bindings")