diff --git a/Autogenerated/Bindings/C/lib3mf.h b/Autogenerated/Bindings/C/lib3mf.h index 26848d950..37dc70a1c 100644 --- a/Autogenerated/Bindings/C/lib3mf.h +++ b/Autogenerated/Bindings/C/lib3mf.h @@ -1215,7 +1215,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_ismanifoldandoriented(Lib3MF_Mesh LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); /** -* Retrieves the VolumeData this MeshObject. +* Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1224,7 +1224,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMe LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); /** -* Sets the VolumeData this MeshObject. +* Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6244,6 +6244,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addlevelset(Lib3MF_Model pModel, Lib3M */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc index 7016fba24..2bef1bdf1 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc @@ -630,6 +630,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddVolumeData = NULL; pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; + pWrapperTable->m_Model_RemoveResource = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5941,6 +5942,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_GetLevelSets == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) GetProcAddress(hLibrary, "lib3mf_model_removeresource"); + #else // _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) dlsym(hLibrary, "lib3mf_model_removeresource"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_RemoveResource == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h index 9baaad589..21febe2f5 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h @@ -1202,7 +1202,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_IsManifoldAndOrientedPtr) (Lib3MF_MeshO typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); /** -* Retrieves the VolumeData this MeshObject. +* Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1211,7 +1211,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMes typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); /** -* Sets the VolumeData this MeshObject. +* Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6231,6 +6231,15 @@ typedef Lib3MFResult (*PLib3MFModel_AddLevelSetPtr) (Lib3MF_Model pModel, Lib3MF */ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -7017,6 +7026,7 @@ typedef struct { PLib3MFModel_AddVolumeDataPtr m_Model_AddVolumeData; PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; + PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/CSharp/Lib3MF.cs b/Autogenerated/Bindings/CSharp/Lib3MF.cs index 26c4261c4..b860630f8 100644 --- a/Autogenerated/Bindings/CSharp/Lib3MF.cs +++ b/Autogenerated/Bindings/CSharp/Lib3MF.cs @@ -2181,6 +2181,9 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_model_getlevelsets", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 Model_GetLevelSets (IntPtr Handle, out IntPtr AResourceIterator); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_model_removeresource", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 Model_RemoveResource (IntPtr Handle, IntPtr AResource); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_getlibraryversion", CharSet = CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)] public extern static Int32 GetLibraryVersion (out UInt32 AMajor, out UInt32 AMinor, out UInt32 AMicro); @@ -8907,6 +8910,15 @@ public CLevelSetIterator GetLevelSets () return Internal.Lib3MFWrapper.PolymorphicFactory(newResourceIterator); } + public void RemoveResource (CResource AResource) + { + IntPtr AResourceHandle = IntPtr.Zero; + if (AResource != null) + AResourceHandle = AResource.GetHandle(); + + CheckError(Internal.Lib3MFWrapper.Model_RemoveResource (Handle, AResourceHandle)); + } + } class Wrapper diff --git a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp index c27922c02..e58484675 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp @@ -1215,7 +1215,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_ismanifoldandoriented(Lib3MF_Mesh LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); /** -* Retrieves the VolumeData this MeshObject. +* Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1224,7 +1224,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMe LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); /** -* Sets the VolumeData this MeshObject. +* Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6244,6 +6244,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addlevelset(Lib3MF_Model pModel, Lib3M */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp index 33ee5e364..4056c1e6c 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp @@ -3402,6 +3402,7 @@ class CModel : public CBase { inline PVolumeData AddVolumeData(); inline PLevelSet AddLevelSet(); inline PLevelSetIterator GetLevelSets(); + inline void RemoveResource(classParam pResource); }; /************************************************************************************************************************* @@ -5262,7 +5263,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CMeshObject::GetVolumeData - Retrieves the VolumeData this MeshObject. + * CMeshObject::GetVolumeData - Retrieves the VolumeData of this MeshObject. * @return the VolumeData of this MeshObject */ PVolumeData CMeshObject::GetVolumeData() @@ -5278,7 +5279,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CMeshObject::SetVolumeData - Sets the VolumeData this MeshObject. + * CMeshObject::SetVolumeData - Sets the VolumeData of this MeshObject. * @param[in] pTheVolumeData - the VolumeData of this MeshObject */ void CMeshObject::SetVolumeData(classParam pTheVolumeData) @@ -12078,6 +12079,16 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hResourceIterator))); } + + /** + * CModel::RemoveResource - Removes a resource from the model + * @param[in] pResource - The resource to remove + */ + void CModel::RemoveResource(classParam pResource) + { + Lib3MFHandle hResource = pResource.GetHandle(); + CheckError(lib3mf_model_removeresource(m_pHandle, hResource)); + } } // namespace Lib3MF diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h index e3238b113..1a31acf95 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h @@ -1202,7 +1202,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_IsManifoldAndOrientedPtr) (Lib3MF_MeshO typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); /** -* Retrieves the VolumeData this MeshObject. +* Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1211,7 +1211,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMes typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); /** -* Sets the VolumeData this MeshObject. +* Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6231,6 +6231,15 @@ typedef Lib3MFResult (*PLib3MFModel_AddLevelSetPtr) (Lib3MF_Model pModel, Lib3MF */ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -7017,6 +7026,7 @@ typedef struct { PLib3MFModel_AddVolumeDataPtr m_Model_AddVolumeData; PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; + PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp index 8d86fb4af..d742a99e0 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp @@ -3426,6 +3426,7 @@ class CModel : public CBase { inline PVolumeData AddVolumeData(); inline PLevelSet AddLevelSet(); inline PLevelSetIterator GetLevelSets(); + inline void RemoveResource(classParam pResource); }; /************************************************************************************************************************* @@ -4427,6 +4428,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_Model_AddVolumeData = nullptr; pWrapperTable->m_Model_AddLevelSet = nullptr; pWrapperTable->m_Model_GetLevelSets = nullptr; + pWrapperTable->m_Model_RemoveResource = nullptr; pWrapperTable->m_GetLibraryVersion = nullptr; pWrapperTable->m_GetPrereleaseInformation = nullptr; pWrapperTable->m_GetBuildInformation = nullptr; @@ -9734,6 +9736,15 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_Model_GetLevelSets == nullptr) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) GetProcAddress(hLibrary, "lib3mf_model_removeresource"); + #else // _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) dlsym(hLibrary, "lib3mf_model_removeresource"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_RemoveResource == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 @@ -12249,6 +12260,10 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_Model_GetLevelSets == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_model_removeresource", (void**)&(pWrapperTable->m_Model_RemoveResource)); + if ( (eLookupError != 0) || (pWrapperTable->m_Model_RemoveResource == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_getlibraryversion", (void**)&(pWrapperTable->m_GetLibraryVersion)); if ( (eLookupError != 0) || (pWrapperTable->m_GetLibraryVersion == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -13776,7 +13791,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CMeshObject::GetVolumeData - Retrieves the VolumeData this MeshObject. + * CMeshObject::GetVolumeData - Retrieves the VolumeData of this MeshObject. * @return the VolumeData of this MeshObject */ PVolumeData CMeshObject::GetVolumeData() @@ -13792,7 +13807,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } /** - * CMeshObject::SetVolumeData - Sets the VolumeData this MeshObject. + * CMeshObject::SetVolumeData - Sets the VolumeData of this MeshObject. * @param[in] pTheVolumeData - the VolumeData of this MeshObject */ void CMeshObject::SetVolumeData(classParam pTheVolumeData) @@ -20592,6 +20607,16 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) } return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hResourceIterator))); } + + /** + * CModel::RemoveResource - Removes a resource from the model + * @param[in] pResource - The resource to remove + */ + void CModel::RemoveResource(classParam pResource) + { + Lib3MFHandle hResource = pResource.GetHandle(); + CheckError(m_pWrapper->m_WrapperTable.m_Model_RemoveResource(m_pHandle, hResource)); + } } // namespace Lib3MF diff --git a/Autogenerated/Bindings/Go/lib3mf.go b/Autogenerated/Bindings/Go/lib3mf.go index 19e20ce2e..262f25452 100644 --- a/Autogenerated/Bindings/Go/lib3mf.go +++ b/Autogenerated/Bindings/Go/lib3mf.go @@ -5310,6 +5310,15 @@ Lib3MFResult CCall_lib3mf_model_getlevelsets(Lib3MFHandle libraryHandle, Lib3MF_ } +Lib3MFResult CCall_lib3mf_model_removeresource(Lib3MFHandle libraryHandle, Lib3MF_Model pModel, Lib3MF_Resource pResource) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_Model_RemoveResource (pModel, pResource); +} + + Lib3MFResult CCall_lib3mf_getlibraryversion(Lib3MFHandle libraryHandle, Lib3MF_uint32 * pMajor, Lib3MF_uint32 * pMinor, Lib3MF_uint32 * pMicro) { if (libraryHandle == 0) @@ -7563,7 +7572,7 @@ func (inst MeshObject) BeamLattice() (BeamLattice, error) { return inst.wrapperRef.NewBeamLattice(theBeamLattice), nil } -// GetVolumeData retrieves the VolumeData this MeshObject. +// GetVolumeData retrieves the VolumeData of this MeshObject. func (inst MeshObject) GetVolumeData() (*VolumeData, error) { var theVolumeData ref ret := C.CCall_lib3mf_meshobject_getvolumedata(inst.wrapperRef.LibraryHandle, inst.Ref, &theVolumeData) @@ -7578,7 +7587,7 @@ func (inst MeshObject) GetVolumeData() (*VolumeData, error) { return _theVolumeDataPtr, nil } -// SetVolumeData sets the VolumeData this MeshObject. +// SetVolumeData sets the VolumeData of this MeshObject. func (inst MeshObject) SetVolumeData(theVolumeData VolumeData) error { ret := C.CCall_lib3mf_meshobject_setvolumedata(inst.wrapperRef.LibraryHandle, inst.Ref, theVolumeData.Ref) if ret != 0 { @@ -13500,6 +13509,15 @@ func (inst Model) GetLevelSets() (LevelSetIterator, error) { return inst.wrapperRef.NewLevelSetIterator(resourceIterator), nil } +// RemoveResource removes a resource from the model. +func (inst Model) RemoveResource(resource Resource) error { + ret := C.CCall_lib3mf_model_removeresource(inst.wrapperRef.LibraryHandle, inst.Ref, resource.Ref) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + // GetLibraryVersion retrieves the binary version of this library. func (wrapper Wrapper) GetLibraryVersion() (uint32, uint32, uint32, error) { diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc index 7016fba24..2bef1bdf1 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc @@ -630,6 +630,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddVolumeData = NULL; pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; + pWrapperTable->m_Model_RemoveResource = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5941,6 +5942,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_GetLevelSets == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) GetProcAddress(hLibrary, "lib3mf_model_removeresource"); + #else // _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) dlsym(hLibrary, "lib3mf_model_removeresource"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_RemoveResource == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.h b/Autogenerated/Bindings/Go/lib3mf_dynamic.h index 9baaad589..21febe2f5 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.h @@ -1202,7 +1202,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_IsManifoldAndOrientedPtr) (Lib3MF_MeshO typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); /** -* Retrieves the VolumeData this MeshObject. +* Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1211,7 +1211,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMes typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); /** -* Sets the VolumeData this MeshObject. +* Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6231,6 +6231,15 @@ typedef Lib3MFResult (*PLib3MFModel_AddLevelSetPtr) (Lib3MF_Model pModel, Lib3MF */ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -7017,6 +7026,7 @@ typedef struct { PLib3MFModel_AddVolumeDataPtr m_Model_AddVolumeData; PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; + PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc index 7016fba24..2bef1bdf1 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc @@ -630,6 +630,7 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_Model_AddVolumeData = NULL; pWrapperTable->m_Model_AddLevelSet = NULL; pWrapperTable->m_Model_GetLevelSets = NULL; + pWrapperTable->m_Model_RemoveResource = NULL; pWrapperTable->m_GetLibraryVersion = NULL; pWrapperTable->m_GetPrereleaseInformation = NULL; pWrapperTable->m_GetBuildInformation = NULL; @@ -5941,6 +5942,15 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_Model_GetLevelSets == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) GetProcAddress(hLibrary, "lib3mf_model_removeresource"); + #else // _WIN32 + pWrapperTable->m_Model_RemoveResource = (PLib3MFModel_RemoveResourcePtr) dlsym(hLibrary, "lib3mf_model_removeresource"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Model_RemoveResource == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_GetLibraryVersion = (PLib3MFGetLibraryVersionPtr) GetProcAddress(hLibrary, "lib3mf_getlibraryversion"); #else // _WIN32 diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h index 9baaad589..21febe2f5 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h @@ -1202,7 +1202,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_IsManifoldAndOrientedPtr) (Lib3MF_MeshO typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); /** -* Retrieves the VolumeData this MeshObject. +* Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1211,7 +1211,7 @@ typedef Lib3MFResult (*PLib3MFMeshObject_BeamLatticePtr) (Lib3MF_MeshObject pMes typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); /** -* Sets the VolumeData this MeshObject. +* Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6231,6 +6231,15 @@ typedef Lib3MFResult (*PLib3MFModel_AddLevelSetPtr) (Lib3MF_Model pModel, Lib3MF */ typedef Lib3MFResult (*PLib3MFModel_GetLevelSetsPtr) (Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFModel_RemoveResourcePtr) (Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -7017,6 +7026,7 @@ typedef struct { PLib3MFModel_AddVolumeDataPtr m_Model_AddVolumeData; PLib3MFModel_AddLevelSetPtr m_Model_AddLevelSet; PLib3MFModel_GetLevelSetsPtr m_Model_GetLevelSets; + PLib3MFModel_RemoveResourcePtr m_Model_RemoveResource; PLib3MFGetLibraryVersionPtr m_GetLibraryVersion; PLib3MFGetPrereleaseInformationPtr m_GetPrereleaseInformation; PLib3MFGetBuildInformationPtr m_GetBuildInformation; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc index 7072a898c..8e5051385 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc @@ -21636,6 +21636,7 @@ void CLib3MFModel::Init() NODE_SET_PROTOTYPE_METHOD(tpl, "AddVolumeData", AddVolumeData); NODE_SET_PROTOTYPE_METHOD(tpl, "AddLevelSet", AddLevelSet); NODE_SET_PROTOTYPE_METHOD(tpl, "GetLevelSets", GetLevelSets); + NODE_SET_PROTOTYPE_METHOD(tpl, "RemoveResource", RemoveResource); constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); } @@ -23483,6 +23484,34 @@ void CLib3MFModel::GetLevelSets(const FunctionCallbackInfo& args) } } + +void CLib3MFModel::RemoveResource(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsObject()) { + throw std::runtime_error("Expected class parameter 0 (Resource)"); + } + Local objResource = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + CLib3MFResource * instanceResource = ObjectWrap::Unwrap(objResource); + if (instanceResource == nullptr) + throw std::runtime_error("Invalid Object parameter 0 (Resource)"); + Lib3MFHandle hResource = instanceResource->getHandle( objResource ); + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method RemoveResource."); + if (wrapperTable->m_Model_RemoveResource == nullptr) + throw std::runtime_error("Could not call Lib3MF method Model::RemoveResource."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_Model_RemoveResource(instanceHandle, hResource); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + /************************************************************************************************************************* Class CLib3MFWrapper Implementation **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h index 02ccb6ac3..bbc2e8ffc 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h @@ -2596,6 +2596,7 @@ class CLib3MFModel : public CLib3MFBaseClass { static void AddVolumeData(const v8::FunctionCallbackInfo& args); static void AddLevelSet(const v8::FunctionCallbackInfo& args); static void GetLevelSets(const v8::FunctionCallbackInfo& args); + static void RemoveResource(const v8::FunctionCallbackInfo& args); public: CLib3MFModel(); diff --git a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas index 0a5718e04..ff0e56fb0 100644 --- a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas +++ b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas @@ -1774,7 +1774,7 @@ TLib3MFModel = class; TLib3MFMeshObject_BeamLatticeFunc = function(pMeshObject: TLib3MFHandle; out pTheBeamLattice: TLib3MFHandle): TLib3MFResult; cdecl; (** - * Retrieves the VolumeData this MeshObject. + * Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1783,7 +1783,7 @@ TLib3MFModel = class; TLib3MFMeshObject_GetVolumeDataFunc = function(pMeshObject: TLib3MFHandle; out pTheVolumeData: TLib3MFHandle): TLib3MFResult; cdecl; (** - * Sets the VolumeData this MeshObject. + * Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6895,6 +6895,15 @@ TLib3MFModel = class; *) TLib3MFModel_GetLevelSetsFunc = function(pModel: TLib3MFHandle; out pResourceIterator: TLib3MFHandle): TLib3MFResult; cdecl; + (** + * Removes a resource from the model + * + * @param[in] pModel - Model instance. + * @param[in] pResource - The resource to remove + * @return error code or 0 (success) + *) + TLib3MFModel_RemoveResourceFunc = function(pModel: TLib3MFHandle; const pResource: TLib3MFHandle): TLib3MFResult; cdecl; + (************************************************************************************************************************* Global function definitions **************************************************************************************************************************) @@ -8963,6 +8972,7 @@ TLib3MFModel = class(TLib3MFBase) function AddVolumeData(): TLib3MFVolumeData; function AddLevelSet(): TLib3MFLevelSet; function GetLevelSets(): TLib3MFLevelSetIterator; + procedure RemoveResource(const AResource: TLib3MFResource); end; (************************************************************************************************************************* @@ -9554,6 +9564,7 @@ TLib3MFWrapper = class(TObject) FLib3MFModel_AddVolumeDataFunc: TLib3MFModel_AddVolumeDataFunc; FLib3MFModel_AddLevelSetFunc: TLib3MFModel_AddLevelSetFunc; FLib3MFModel_GetLevelSetsFunc: TLib3MFModel_GetLevelSetsFunc; + FLib3MFModel_RemoveResourceFunc: TLib3MFModel_RemoveResourceFunc; FLib3MFGetLibraryVersionFunc: TLib3MFGetLibraryVersionFunc; FLib3MFGetPrereleaseInformationFunc: TLib3MFGetPrereleaseInformationFunc; FLib3MFGetBuildInformationFunc: TLib3MFGetBuildInformationFunc; @@ -10165,6 +10176,7 @@ TLib3MFWrapper = class(TObject) property Lib3MFModel_AddVolumeDataFunc: TLib3MFModel_AddVolumeDataFunc read FLib3MFModel_AddVolumeDataFunc; property Lib3MFModel_AddLevelSetFunc: TLib3MFModel_AddLevelSetFunc read FLib3MFModel_AddLevelSetFunc; property Lib3MFModel_GetLevelSetsFunc: TLib3MFModel_GetLevelSetsFunc read FLib3MFModel_GetLevelSetsFunc; + property Lib3MFModel_RemoveResourceFunc: TLib3MFModel_RemoveResourceFunc read FLib3MFModel_RemoveResourceFunc; property Lib3MFGetLibraryVersionFunc: TLib3MFGetLibraryVersionFunc read FLib3MFGetLibraryVersionFunc; property Lib3MFGetPrereleaseInformationFunc: TLib3MFGetPrereleaseInformationFunc read FLib3MFGetPrereleaseInformationFunc; property Lib3MFGetBuildInformationFunc: TLib3MFGetBuildInformationFunc read FLib3MFGetBuildInformationFunc; @@ -18894,6 +18906,17 @@ implementation Result := TLib3MFPolymorphicFactory.Make(FWrapper, HResourceIterator); end; + procedure TLib3MFModel.RemoveResource(const AResource: TLib3MFResource); + var + AResourceHandle: TLib3MFHandle; + begin + if Assigned(AResource) then + AResourceHandle := AResource.TheHandle + else + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_INVALIDPARAM, 'AResource is a nil value.'); + FWrapper.CheckError(Self, FWrapper.Lib3MFModel_RemoveResourceFunc(FHandle, AResourceHandle)); + end; + (************************************************************************************************************************* Wrapper class implementation **************************************************************************************************************************) @@ -19498,6 +19521,7 @@ implementation FLib3MFModel_AddVolumeDataFunc := LoadFunction('lib3mf_model_addvolumedata'); FLib3MFModel_AddLevelSetFunc := LoadFunction('lib3mf_model_addlevelset'); FLib3MFModel_GetLevelSetsFunc := LoadFunction('lib3mf_model_getlevelsets'); + FLib3MFModel_RemoveResourceFunc := LoadFunction('lib3mf_model_removeresource'); FLib3MFGetLibraryVersionFunc := LoadFunction('lib3mf_getlibraryversion'); FLib3MFGetPrereleaseInformationFunc := LoadFunction('lib3mf_getprereleaseinformation'); FLib3MFGetBuildInformationFunc := LoadFunction('lib3mf_getbuildinformation'); @@ -21272,6 +21296,9 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_model_getlevelsets'), @FLib3MFModel_GetLevelSetsFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_model_removeresource'), @FLib3MFModel_RemoveResourceFunc); if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_getlibraryversion'), @FLib3MFGetLibraryVersionFunc); diff --git a/Autogenerated/Bindings/Python/Lib3MF.py b/Autogenerated/Bindings/Python/Lib3MF.py index 165cd56d0..82862c49f 100644 --- a/Autogenerated/Bindings/Python/Lib3MF.py +++ b/Autogenerated/Bindings/Python/Lib3MF.py @@ -717,6 +717,7 @@ class FunctionTable: lib3mf_model_addvolumedata = None lib3mf_model_addlevelset = None lib3mf_model_getlevelsets = None + lib3mf_model_removeresource = None '''Definition of Enumerations ''' @@ -4733,6 +4734,12 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)) self.lib.lib3mf_model_getlevelsets = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_model_removeresource")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_void_p) + self.lib.lib3mf_model_removeresource = methodType(int(methodAddress.value)) + except AttributeError as ae: raise ELib3MFException(ErrorCodes.COULDNOTFINDLIBRARYEXPORT, ae.args[0]) @@ -6541,6 +6548,9 @@ def _loadFunctionTable(self): self.lib.lib3mf_model_getlevelsets.restype = ctypes.c_int32 self.lib.lib3mf_model_getlevelsets.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)] + self.lib.lib3mf_model_removeresource.restype = ctypes.c_int32 + self.lib.lib3mf_model_removeresource.argtypes = [ctypes.c_void_p, ctypes.c_void_p] + except AttributeError as ae: raise ELib3MFException(ErrorCodes.COULDNOTFINDLIBRARYEXPORT, ae.args[0]) @@ -12867,4 +12877,13 @@ def GetLevelSets(self): return ResourceIteratorObject + def RemoveResource(self, ResourceObject): + ResourceHandle = None + if ResourceObject: + ResourceHandle = ResourceObject._handle + else: + raise ELib3MFException(ErrorCodes.INVALIDPARAM, 'Invalid return/output value') + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_model_removeresource(self._handle, ResourceHandle)) + + diff --git a/Autogenerated/Source/lib3mf_abi.hpp b/Autogenerated/Source/lib3mf_abi.hpp index c27922c02..e58484675 100644 --- a/Autogenerated/Source/lib3mf_abi.hpp +++ b/Autogenerated/Source/lib3mf_abi.hpp @@ -1215,7 +1215,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_ismanifoldandoriented(Lib3MF_Mesh LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); /** -* Retrieves the VolumeData this MeshObject. +* Retrieves the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[out] pTheVolumeData - the VolumeData of this MeshObject @@ -1224,7 +1224,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMe LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); /** -* Sets the VolumeData this MeshObject. +* Sets the VolumeData of this MeshObject. * * @param[in] pMeshObject - MeshObject instance. * @param[in] pTheVolumeData - the VolumeData of this MeshObject @@ -6244,6 +6244,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addlevelset(Lib3MF_Model pModel, Lib3M */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ diff --git a/Autogenerated/Source/lib3mf_interfaces.hpp b/Autogenerated/Source/lib3mf_interfaces.hpp index 08a95f027..b9edf2061 100644 --- a/Autogenerated/Source/lib3mf_interfaces.hpp +++ b/Autogenerated/Source/lib3mf_interfaces.hpp @@ -1516,13 +1516,13 @@ class IMeshObject : public virtual IObject { virtual IBeamLattice * BeamLattice() = 0; /** - * IMeshObject::GetVolumeData - Retrieves the VolumeData this MeshObject. + * IMeshObject::GetVolumeData - Retrieves the VolumeData of this MeshObject. * @return the VolumeData of this MeshObject */ virtual IVolumeData * GetVolumeData() = 0; /** - * IMeshObject::SetVolumeData - Sets the VolumeData this MeshObject. + * IMeshObject::SetVolumeData - Sets the VolumeData of this MeshObject. * @param[in] pTheVolumeData - the VolumeData of this MeshObject */ virtual void SetVolumeData(IVolumeData* pTheVolumeData) = 0; @@ -6546,6 +6546,12 @@ class IModel : public virtual IBase { */ virtual ILevelSetIterator * GetLevelSets() = 0; + /** + * IModel::RemoveResource - Removes a resource from the model + * @param[in] pResource - The resource to remove + */ + virtual void RemoveResource(IResource* pResource) = 0; + }; typedef IBaseSharedPtr PIModel; diff --git a/Autogenerated/Source/lib3mf_interfacewrapper.cpp b/Autogenerated/Source/lib3mf_interfacewrapper.cpp index 2f171eda9..c4e50c07e 100644 --- a/Autogenerated/Source/lib3mf_interfacewrapper.cpp +++ b/Autogenerated/Source/lib3mf_interfacewrapper.cpp @@ -22607,6 +22607,43 @@ Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3MF_LevelSetItera } } +Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "RemoveResource"); + pJournalEntry->addHandleParameter("Resource", pResource); + } + IBase* pIBaseClassResource = (IBase *)pResource; + IResource* pIResource = dynamic_cast(pIBaseClassResource); + if (!pIResource) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIModel->RemoveResource(pIResource); + + if (pJournalEntry.get() != nullptr) { + 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()); + } +} + /************************************************************************************************************************* @@ -23786,6 +23823,8 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_model_addlevelset; if (sProcName == "lib3mf_model_getlevelsets") *ppProcAddress = (void*) &lib3mf_model_getlevelsets; + if (sProcName == "lib3mf_model_removeresource") + *ppProcAddress = (void*) &lib3mf_model_removeresource; if (sProcName == "lib3mf_getlibraryversion") *ppProcAddress = (void*) &lib3mf_getlibraryversion; if (sProcName == "lib3mf_getprereleaseinformation") diff --git a/AutomaticComponentToolkit/lib3mf.xml b/AutomaticComponentToolkit/lib3mf.xml index 500102d98..d345b8b05 100644 --- a/AutomaticComponentToolkit/lib3mf.xml +++ b/AutomaticComponentToolkit/lib3mf.xml @@ -4129,17 +4129,30 @@ - + + + + + + + + + + + PModel; diff --git a/Source/API/lib3mf_model.cpp b/Source/API/lib3mf_model.cpp index 52f028594..8bffb590f 100644 --- a/Source/API/lib3mf_model.cpp +++ b/Source/API/lib3mf_model.cpp @@ -939,3 +939,10 @@ ILevelSetIterator * CModel::GetLevelSets() return pResult.release(); } +void CModel::RemoveResource(IResource* pResource) +{ + CResource* pLib3MFResource = dynamic_cast (pResource); + if (!pLib3MFResource) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDRESOURCE); + model().removeResource(pLib3MFResource->resource()); +} diff --git a/Source/Model/Classes/NMR_Model.cpp b/Source/Model/Classes/NMR_Model.cpp index 2417d968d..3b8bb84fd 100644 --- a/Source/Model/Classes/NMR_Model.cpp +++ b/Source/Model/Classes/NMR_Model.cpp @@ -1689,5 +1689,119 @@ namespace NMR { return dynamic_cast(pResource.get()); } + + + void CModel::removeResource(PModelResource pResource) + { + if (pResource.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + // Remove from resource list + auto resourceIterator = std::find(m_Resources.begin(), m_Resources.end(), pResource); + if (resourceIterator == m_Resources.end()) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + + } + + m_Resources.erase(resourceIterator); + + // Remove from Resource map + auto resourceMapIterator = m_ResourceMap.find(pResource->getPackageResourceID()->getUniqueID()); + if (resourceMapIterator == m_ResourceMap.end()) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } + + m_ResourceMap.erase(resourceMapIterator); + + // Remove from specific resource lists + + auto objectIterator = std::find(m_ObjectLookup.begin(), m_ObjectLookup.end(), pResource); + if (objectIterator != m_ObjectLookup.end()) + { + m_ObjectLookup.erase(objectIterator); + return; + } + + auto baseMaterialIterator = std::find(m_BaseMaterialLookup.begin(), m_BaseMaterialLookup.end(), pResource); + if (baseMaterialIterator != m_BaseMaterialLookup.end()) + { + m_BaseMaterialLookup.erase(baseMaterialIterator); + return; + } + + auto textureIterator = std::find(m_TextureLookup.begin(), m_TextureLookup.end(), pResource); + if (textureIterator != m_TextureLookup.end()) + { + m_TextureLookup.erase(textureIterator); + return; + } + + auto sliceStackIterator = std::find(m_SliceStackLookup.begin(), m_SliceStackLookup.end(), pResource); + if (sliceStackIterator != m_SliceStackLookup.end()) + { + m_SliceStackLookup.erase(sliceStackIterator); + return; + } + + auto colorGroupIterator = std::find(m_ColorGroupLookup.begin(), m_ColorGroupLookup.end(), pResource); + if (colorGroupIterator != m_ColorGroupLookup.end()) + { + m_ColorGroupLookup.erase(colorGroupIterator); + return; + } + + auto texture2DGroupIterator = std::find(m_Texture2DGroupLookup.begin(), m_Texture2DGroupLookup.end(), pResource); + if (texture2DGroupIterator != m_Texture2DGroupLookup.end()) + { + m_Texture2DGroupLookup.erase(texture2DGroupIterator); + return; + } + + auto compositeMaterialsIterator = std::find(m_CompositeMaterialsLookup.begin(), m_CompositeMaterialsLookup.end(), pResource); + if (compositeMaterialsIterator != m_CompositeMaterialsLookup.end()) + { + m_CompositeMaterialsLookup.erase(compositeMaterialsIterator); + return; + } + + auto multiPropertyGroupIterator = std::find(m_MultiPropertyGroupLookup.begin(), m_MultiPropertyGroupLookup.end(), pResource); + if (multiPropertyGroupIterator != m_MultiPropertyGroupLookup.end()) + { + m_MultiPropertyGroupLookup.erase(multiPropertyGroupIterator); + return; + } + + auto image3DIterator = std::find(m_Image3DLookup.begin(), m_Image3DLookup.end(), pResource); + if (image3DIterator != m_Image3DLookup.end()) + { + m_Image3DLookup.erase(image3DIterator); + return; + } + + auto functionIterator = std::find(m_FunctionLookup.begin(), m_FunctionLookup.end(), pResource); + if (functionIterator != m_FunctionLookup.end()) + { + m_FunctionLookup.erase(functionIterator); + return; + } + + auto volumeDataIterator = std::find(m_VolumeDataLookup.begin(), m_VolumeDataLookup.end(), pResource); + if (volumeDataIterator != m_VolumeDataLookup.end()) + { + m_VolumeDataLookup.erase(volumeDataIterator); + return; + } + + auto levelSetObjectIterator = std::find(m_levelSetObjectLookup.begin(), m_levelSetObjectLookup.end(), pResource); + if (levelSetObjectIterator != m_levelSetObjectLookup.end()) + { + m_levelSetObjectLookup.erase(levelSetObjectIterator); + return; + } + + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } } // namespace NMR diff --git a/Tests/CPP_Bindings/Source/Model.cpp b/Tests/CPP_Bindings/Source/Model.cpp index 75768635a..67af619a9 100644 --- a/Tests/CPP_Bindings/Source/Model.cpp +++ b/Tests/CPP_Bindings/Source/Model.cpp @@ -175,4 +175,92 @@ namespace Lib3MF ASSERT_EQ(oldID, newId); } + TEST_F(Model, RemoveResource_MaterialGroup) + { + auto baseMaterial = m_pModel->AddBaseMaterialGroup(); + Lib3MF_uint32 id = baseMaterial->GetResourceID(); + m_pModel->RemoveResource(baseMaterial.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetBaseMaterialGroups()->Count(), 0); + EXPECT_THROW(m_pModel->GetBaseMaterialGroupByID(id), Lib3MF::ELib3MFException); + } + + TEST_F(Model, RemoveResource_MeshObject) + { + auto meshObject = m_pModel->AddMeshObject(); + Lib3MF_uint32 id = meshObject->GetResourceID(); + m_pModel->RemoveResource(meshObject.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetMeshObjects()->Count(), 0); + EXPECT_THROW(m_pModel->GetMeshObjectByID(id), Lib3MF::ELib3MFException); + } + + TEST_F(Model, RemoveResource_ComponentsObject) + { + auto componentsObject = m_pModel->AddComponentsObject(); + Lib3MF_uint32 id = componentsObject->GetResourceID(); + m_pModel->RemoveResource(componentsObject.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetComponentsObjects()->Count(), 0); + EXPECT_THROW(m_pModel->GetComponentsObjectByID(id), Lib3MF::ELib3MFException); + } + + TEST_F(Model, RemoveResource_ColorGroup) + { + auto colorGroup = m_pModel->AddColorGroup(); + Lib3MF_uint32 id = colorGroup->GetResourceID(); + m_pModel->RemoveResource(colorGroup.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetColorGroups()->Count(), 0); + EXPECT_THROW(m_pModel->GetColorGroupByID(id), Lib3MF::ELib3MFException); + } + + TEST_F(Model, RemoveResource_MultiPropertyGroup) + { + auto multiPropertyGroup = m_pModel->AddMultiPropertyGroup(); + Lib3MF_uint32 id = multiPropertyGroup->GetResourceID(); + m_pModel->RemoveResource(multiPropertyGroup.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetMultiPropertyGroups()->Count(), 0); + EXPECT_THROW(m_pModel->GetMultiPropertyGroupByID(id), Lib3MF::ELib3MFException); + + } + + TEST_F(Model, RemoveResource_SliceStack) + { + auto sliceStack = m_pModel->AddSliceStack(0.); + Lib3MF_uint32 id = sliceStack->GetResourceID(); + m_pModel->RemoveResource(sliceStack.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetSliceStacks()->Count(), 0); + EXPECT_THROW(m_pModel->GetSliceStackByID(id), Lib3MF::ELib3MFException); + } + + TEST_F(Model, RemoveResource_LevelSet) + { + auto levelSet = m_pModel->AddLevelSet(); + Lib3MF_uint32 id = levelSet->GetResourceID(); + m_pModel->RemoveResource(levelSet.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetLevelSets()->Count(), 0); + EXPECT_THROW(m_pModel->GetLevelSetByID(id), Lib3MF::ELib3MFException); + } + + TEST_F(Model, RemoveResource_Function) + { + auto function = m_pModel->AddImplicitFunction(); + Lib3MF_uint32 id = function->GetResourceID(); + m_pModel->RemoveResource(function.get()); + + /// Now the resource should be gone + EXPECT_EQ(m_pModel->GetFunctions()->Count(), 0); + EXPECT_THROW(m_pModel->GetResourceByID(id), Lib3MF::ELib3MFException); + } }