From 1e7d22ee68b165b9e7d2f8674e65b0385071529b Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:38:34 +0100 Subject: [PATCH] Adding fallback value to volume data elements --- Autogenerated/Bindings/C/lib3mf.h | 18 +++++ .../Bindings/CDynamic/lib3mf_dynamic.cc | 20 ++++++ .../Bindings/CDynamic/lib3mf_dynamic.h | 20 ++++++ Autogenerated/Bindings/CSharp/Lib3MF.cs | 20 ++++++ Autogenerated/Bindings/Cpp/lib3mf_abi.hpp | 18 +++++ .../Bindings/Cpp/lib3mf_implicit.hpp | 23 ++++++ .../Bindings/CppDynamic/lib3mf_dynamic.h | 20 ++++++ .../Bindings/CppDynamic/lib3mf_dynamic.hpp | 51 ++++++++++++++ Autogenerated/Bindings/Go/lib3mf.go | 37 ++++++++++ Autogenerated/Bindings/Go/lib3mf_dynamic.cc | 20 ++++++ Autogenerated/Bindings/Go/lib3mf_dynamic.h | 20 ++++++ .../Bindings/NodeJS/lib3mf_dynamic.cc | 20 ++++++ .../Bindings/NodeJS/lib3mf_dynamic.h | 20 ++++++ .../Bindings/NodeJS/lib3mf_nodewrapper.cc | 48 +++++++++++++ .../Bindings/NodeJS/lib3mf_nodewrapper.h | 2 + Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas | 42 +++++++++++ Autogenerated/Bindings/Python/Lib3MF.py | 31 ++++++++ Autogenerated/Source/lib3mf_abi.hpp | 18 +++++ Autogenerated/Source/lib3mf_interfaces.hpp | 12 ++++ .../Source/lib3mf_interfacewrapper.cpp | 70 +++++++++++++++++++ AutomaticComponentToolkit/lib3mf.xml | 43 ++++++++---- Include/API/lib3mf_functionreference.hpp | 14 ++++ Include/Common/NMR_ErrorConst.h | 3 + Include/Common/NMR_FunctionReference.h | 5 ++ Include/Model/Classes/NMR_ModelConstants.h | 1 + ..._ModelReaderNode_Volumetric2201_Boundary.h | 3 + ...NMR_ModelReaderNode_Volumetric2201_Color.h | 3 + ..._ModelReaderNode_Volumetric2201_Property.h | 3 + Source/API/lib3mf_functionreference.cpp | 11 +++ Source/Common/NMR_Exception.cpp | 1 + Source/Common/NMR_FunctionReference.cpp | 9 +++ ...odelReaderNode_Volumetric2201_Boundary.cpp | 13 +++- ...R_ModelReaderNode_Volumetric2201_Color.cpp | 15 +++- ...odelReaderNode_Volumetric2201_Property.cpp | 14 ++++ .../v100/NMR_ModelWriterNode100_Mesh.cpp | 14 ++++ Tests/CPP_Bindings/Source/Volumetric.cpp | 12 ++++ 36 files changed, 676 insertions(+), 18 deletions(-) diff --git a/Autogenerated/Bindings/C/lib3mf.h b/Autogenerated/Bindings/C/lib3mf.h index 40fb8ab7b..60ec42eb8 100644 --- a/Autogenerated/Bindings/C/lib3mf.h +++ b/Autogenerated/Bindings/C/lib3mf.h @@ -1508,6 +1508,24 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setminfeaturesize(Lib3MF_F */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getminfeaturesize(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + /************************************************************************************************************************* Class definition for VolumeDataBoundary **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc index c22fb1f38..9adb21a77 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc @@ -189,6 +189,8 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_FunctionReference_SetChannelName = NULL; pWrapperTable->m_FunctionReference_SetMinFeatureSize = NULL; pWrapperTable->m_FunctionReference_GetMinFeatureSize = NULL; + pWrapperTable->m_FunctionReference_SetFallBackValue = NULL; + pWrapperTable->m_FunctionReference_GetFallBackValue = NULL; pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = NULL; pWrapperTable->m_VolumeDataBoundary_GetMeshBBoxOnly = NULL; pWrapperTable->m_VolumeDataComposite_GetBaseMaterialGroup = NULL; @@ -1954,6 +1956,24 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_FunctionReference_GetMinFeatureSize == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_SetFallBackValue == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_GetFallBackValue == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = (PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr) GetProcAddress(hLibrary, "lib3mf_volumedataboundary_setmeshbboxonly"); #else // _WIN32 diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h index 061af9888..9af28d044 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h @@ -1495,6 +1495,24 @@ typedef Lib3MFResult (*PLib3MFFunctionReference_SetMinFeatureSizePtr) (Lib3MF_Fu */ typedef Lib3MFResult (*PLib3MFFunctionReference_GetMinFeatureSizePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_SetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_GetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + /************************************************************************************************************************* Class definition for VolumeDataBoundary **************************************************************************************************************************/ @@ -6403,6 +6421,8 @@ typedef struct { PLib3MFFunctionReference_SetChannelNamePtr m_FunctionReference_SetChannelName; PLib3MFFunctionReference_SetMinFeatureSizePtr m_FunctionReference_SetMinFeatureSize; PLib3MFFunctionReference_GetMinFeatureSizePtr m_FunctionReference_GetMinFeatureSize; + PLib3MFFunctionReference_SetFallBackValuePtr m_FunctionReference_SetFallBackValue; + PLib3MFFunctionReference_GetFallBackValuePtr m_FunctionReference_GetFallBackValue; PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr m_VolumeDataBoundary_SetMeshBBoxOnly; PLib3MFVolumeDataBoundary_GetMeshBBoxOnlyPtr m_VolumeDataBoundary_GetMeshBBoxOnly; PLib3MFVolumeDataComposite_GetBaseMaterialGroupPtr m_VolumeDataComposite_GetBaseMaterialGroup; diff --git a/Autogenerated/Bindings/CSharp/Lib3MF.cs b/Autogenerated/Bindings/CSharp/Lib3MF.cs index 72c25017b..ca3336478 100644 --- a/Autogenerated/Bindings/CSharp/Lib3MF.cs +++ b/Autogenerated/Bindings/CSharp/Lib3MF.cs @@ -857,6 +857,12 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_functionreference_getminfeaturesize", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 FunctionReference_GetMinFeatureSize (IntPtr Handle, out Double AMinFeatureSize); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_functionreference_setfallbackvalue", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 FunctionReference_SetFallBackValue (IntPtr Handle, Double AFallBackValue); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_functionreference_getfallbackvalue", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 FunctionReference_GetFallBackValue (IntPtr Handle, out Double AFallBackValue); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_volumedataboundary_setmeshbboxonly", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 VolumeDataBoundary_SetMeshBBoxOnly (IntPtr Handle, Byte AMeshBBoxOnly); @@ -4102,6 +4108,20 @@ public Double GetMinFeatureSize () return resultMinFeatureSize; } + public void SetFallBackValue (Double AFallBackValue) + { + + CheckError(Internal.Lib3MFWrapper.FunctionReference_SetFallBackValue (Handle, AFallBackValue)); + } + + public Double GetFallBackValue () + { + Double resultFallBackValue = 0; + + CheckError(Internal.Lib3MFWrapper.FunctionReference_GetFallBackValue (Handle, out resultFallBackValue)); + return resultFallBackValue; + } + } public class CVolumeDataBoundary : CFunctionReference diff --git a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp index dbd09dfb2..ea533fdec 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp @@ -1508,6 +1508,24 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setminfeaturesize(Lib3MF_F */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getminfeaturesize(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + /************************************************************************************************************************* Class definition for VolumeDataBoundary **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp index f6d231065..0ba40ff69 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp @@ -1493,6 +1493,8 @@ class CFunctionReference : public CBase { inline void SetChannelName(const std::string & sChannelName); inline void SetMinFeatureSize(const Lib3MF_double dMinFeatureSize); inline Lib3MF_double GetMinFeatureSize(); + inline void SetFallBackValue(const Lib3MF_double dFallBackValue); + inline Lib3MF_double GetFallBackValue(); }; /************************************************************************************************************************* @@ -5542,6 +5544,27 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) return resultMinFeatureSize; } + /** + * CFunctionReference::SetFallBackValue - Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + void CFunctionReference::SetFallBackValue(const Lib3MF_double dFallBackValue) + { + CheckError(lib3mf_functionreference_setfallbackvalue(m_pHandle, dFallBackValue)); + } + + /** + * CFunctionReference::GetFallBackValue - Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + Lib3MF_double CFunctionReference::GetFallBackValue() + { + Lib3MF_double resultFallBackValue = 0; + CheckError(lib3mf_functionreference_getfallbackvalue(m_pHandle, &resultFallBackValue)); + + return resultFallBackValue; + } + /** * Method definitions for class CVolumeDataBoundary */ diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h index ec4000333..8d5274faa 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h @@ -1495,6 +1495,24 @@ typedef Lib3MFResult (*PLib3MFFunctionReference_SetMinFeatureSizePtr) (Lib3MF_Fu */ typedef Lib3MFResult (*PLib3MFFunctionReference_GetMinFeatureSizePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_SetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_GetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + /************************************************************************************************************************* Class definition for VolumeDataBoundary **************************************************************************************************************************/ @@ -6403,6 +6421,8 @@ typedef struct { PLib3MFFunctionReference_SetChannelNamePtr m_FunctionReference_SetChannelName; PLib3MFFunctionReference_SetMinFeatureSizePtr m_FunctionReference_SetMinFeatureSize; PLib3MFFunctionReference_GetMinFeatureSizePtr m_FunctionReference_GetMinFeatureSize; + PLib3MFFunctionReference_SetFallBackValuePtr m_FunctionReference_SetFallBackValue; + PLib3MFFunctionReference_GetFallBackValuePtr m_FunctionReference_GetFallBackValue; PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr m_VolumeDataBoundary_SetMeshBBoxOnly; PLib3MFVolumeDataBoundary_GetMeshBBoxOnlyPtr m_VolumeDataBoundary_GetMeshBBoxOnly; PLib3MFVolumeDataComposite_GetBaseMaterialGroupPtr m_VolumeDataComposite_GetBaseMaterialGroup; diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp index 3247296a3..d7abbb9db 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp @@ -1517,6 +1517,8 @@ class CFunctionReference : public CBase { inline void SetChannelName(const std::string & sChannelName); inline void SetMinFeatureSize(const Lib3MF_double dMinFeatureSize); inline Lib3MF_double GetMinFeatureSize(); + inline void SetFallBackValue(const Lib3MF_double dFallBackValue); + inline Lib3MF_double GetFallBackValue(); }; /************************************************************************************************************************* @@ -3922,6 +3924,8 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_FunctionReference_SetChannelName = nullptr; pWrapperTable->m_FunctionReference_SetMinFeatureSize = nullptr; pWrapperTable->m_FunctionReference_GetMinFeatureSize = nullptr; + pWrapperTable->m_FunctionReference_SetFallBackValue = nullptr; + pWrapperTable->m_FunctionReference_GetFallBackValue = nullptr; pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = nullptr; pWrapperTable->m_VolumeDataBoundary_GetMeshBBoxOnly = nullptr; pWrapperTable->m_VolumeDataComposite_GetBaseMaterialGroup = nullptr; @@ -5683,6 +5687,24 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_FunctionReference_GetMinFeatureSize == nullptr) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_SetFallBackValue == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_GetFallBackValue == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = (PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr) GetProcAddress(hLibrary, "lib3mf_volumedataboundary_setmeshbboxonly"); #else // _WIN32 @@ -10241,6 +10263,14 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_FunctionReference_GetMinFeatureSize == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_functionreference_setfallbackvalue", (void**)&(pWrapperTable->m_FunctionReference_SetFallBackValue)); + if ( (eLookupError != 0) || (pWrapperTable->m_FunctionReference_SetFallBackValue == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_functionreference_getfallbackvalue", (void**)&(pWrapperTable->m_FunctionReference_GetFallBackValue)); + if ( (eLookupError != 0) || (pWrapperTable->m_FunctionReference_GetFallBackValue == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_volumedataboundary_setmeshbboxonly", (void**)&(pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly)); if ( (eLookupError != 0) || (pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -13804,6 +13834,27 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) return resultMinFeatureSize; } + /** + * CFunctionReference::SetFallBackValue - Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + void CFunctionReference::SetFallBackValue(const Lib3MF_double dFallBackValue) + { + CheckError(m_pWrapper->m_WrapperTable.m_FunctionReference_SetFallBackValue(m_pHandle, dFallBackValue)); + } + + /** + * CFunctionReference::GetFallBackValue - Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + Lib3MF_double CFunctionReference::GetFallBackValue() + { + Lib3MF_double resultFallBackValue = 0; + CheckError(m_pWrapper->m_WrapperTable.m_FunctionReference_GetFallBackValue(m_pHandle, &resultFallBackValue)); + + return resultFallBackValue; + } + /** * Method definitions for class CVolumeDataBoundary */ diff --git a/Autogenerated/Bindings/Go/lib3mf.go b/Autogenerated/Bindings/Go/lib3mf.go index fa42af467..53e5263f9 100644 --- a/Autogenerated/Bindings/Go/lib3mf.go +++ b/Autogenerated/Bindings/Go/lib3mf.go @@ -1341,6 +1341,24 @@ Lib3MFResult CCall_lib3mf_functionreference_getminfeaturesize(Lib3MFHandle libra } +Lib3MFResult CCall_lib3mf_functionreference_setfallbackvalue(Lib3MFHandle libraryHandle, Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_FunctionReference_SetFallBackValue (pFunctionReference, dFallBackValue); +} + + +Lib3MFResult CCall_lib3mf_functionreference_getfallbackvalue(Lib3MFHandle libraryHandle, Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_FunctionReference_GetFallBackValue (pFunctionReference, pFallBackValue); +} + + Lib3MFResult CCall_lib3mf_volumedataboundary_setmeshbboxonly(Lib3MFHandle libraryHandle, Lib3MF_VolumeDataBoundary pVolumeDataBoundary, bool bMeshBBoxOnly) { if (libraryHandle == 0) @@ -7719,6 +7737,25 @@ func (inst FunctionReference) GetMinFeatureSize() (float64, error) { return float64(minFeatureSize), nil } +// SetFallBackValue sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +func (inst FunctionReference) SetFallBackValue(fallBackValue float64) error { + ret := C.CCall_lib3mf_functionreference_setfallbackvalue(inst.wrapperRef.LibraryHandle, inst.Ref, C.double(fallBackValue)) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// GetFallBackValue returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +func (inst FunctionReference) GetFallBackValue() (float64, error) { + var fallBackValue C.double + ret := C.CCall_lib3mf_functionreference_getfallbackvalue(inst.wrapperRef.LibraryHandle, inst.Ref, &fallBackValue) + if ret != 0 { + return 0, makeError(uint32(ret)) + } + return float64(fallBackValue), nil +} + // VolumeDataBoundary represents a Lib3MF class. type VolumeDataBoundary struct { diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc index c22fb1f38..9adb21a77 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.cc @@ -189,6 +189,8 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_FunctionReference_SetChannelName = NULL; pWrapperTable->m_FunctionReference_SetMinFeatureSize = NULL; pWrapperTable->m_FunctionReference_GetMinFeatureSize = NULL; + pWrapperTable->m_FunctionReference_SetFallBackValue = NULL; + pWrapperTable->m_FunctionReference_GetFallBackValue = NULL; pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = NULL; pWrapperTable->m_VolumeDataBoundary_GetMeshBBoxOnly = NULL; pWrapperTable->m_VolumeDataComposite_GetBaseMaterialGroup = NULL; @@ -1954,6 +1956,24 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_FunctionReference_GetMinFeatureSize == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_SetFallBackValue == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_GetFallBackValue == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = (PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr) GetProcAddress(hLibrary, "lib3mf_volumedataboundary_setmeshbboxonly"); #else // _WIN32 diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.h b/Autogenerated/Bindings/Go/lib3mf_dynamic.h index 061af9888..9af28d044 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.h @@ -1495,6 +1495,24 @@ typedef Lib3MFResult (*PLib3MFFunctionReference_SetMinFeatureSizePtr) (Lib3MF_Fu */ typedef Lib3MFResult (*PLib3MFFunctionReference_GetMinFeatureSizePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_SetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_GetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + /************************************************************************************************************************* Class definition for VolumeDataBoundary **************************************************************************************************************************/ @@ -6403,6 +6421,8 @@ typedef struct { PLib3MFFunctionReference_SetChannelNamePtr m_FunctionReference_SetChannelName; PLib3MFFunctionReference_SetMinFeatureSizePtr m_FunctionReference_SetMinFeatureSize; PLib3MFFunctionReference_GetMinFeatureSizePtr m_FunctionReference_GetMinFeatureSize; + PLib3MFFunctionReference_SetFallBackValuePtr m_FunctionReference_SetFallBackValue; + PLib3MFFunctionReference_GetFallBackValuePtr m_FunctionReference_GetFallBackValue; PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr m_VolumeDataBoundary_SetMeshBBoxOnly; PLib3MFVolumeDataBoundary_GetMeshBBoxOnlyPtr m_VolumeDataBoundary_GetMeshBBoxOnly; PLib3MFVolumeDataComposite_GetBaseMaterialGroupPtr m_VolumeDataComposite_GetBaseMaterialGroup; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc index c22fb1f38..9adb21a77 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc @@ -189,6 +189,8 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_FunctionReference_SetChannelName = NULL; pWrapperTable->m_FunctionReference_SetMinFeatureSize = NULL; pWrapperTable->m_FunctionReference_GetMinFeatureSize = NULL; + pWrapperTable->m_FunctionReference_SetFallBackValue = NULL; + pWrapperTable->m_FunctionReference_GetFallBackValue = NULL; pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = NULL; pWrapperTable->m_VolumeDataBoundary_GetMeshBBoxOnly = NULL; pWrapperTable->m_VolumeDataComposite_GetBaseMaterialGroup = NULL; @@ -1954,6 +1956,24 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_FunctionReference_GetMinFeatureSize == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_SetFallBackValue = (PLib3MFFunctionReference_SetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_setfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_SetFallBackValue == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) GetProcAddress(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + #else // _WIN32 + pWrapperTable->m_FunctionReference_GetFallBackValue = (PLib3MFFunctionReference_GetFallBackValuePtr) dlsym(hLibrary, "lib3mf_functionreference_getfallbackvalue"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_FunctionReference_GetFallBackValue == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_VolumeDataBoundary_SetMeshBBoxOnly = (PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr) GetProcAddress(hLibrary, "lib3mf_volumedataboundary_setmeshbboxonly"); #else // _WIN32 diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h index 061af9888..9af28d044 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h @@ -1495,6 +1495,24 @@ typedef Lib3MFResult (*PLib3MFFunctionReference_SetMinFeatureSizePtr) (Lib3MF_Fu */ typedef Lib3MFResult (*PLib3MFFunctionReference_GetMinFeatureSizePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_SetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFFunctionReference_GetFallBackValuePtr) (Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + /************************************************************************************************************************* Class definition for VolumeDataBoundary **************************************************************************************************************************/ @@ -6403,6 +6421,8 @@ typedef struct { PLib3MFFunctionReference_SetChannelNamePtr m_FunctionReference_SetChannelName; PLib3MFFunctionReference_SetMinFeatureSizePtr m_FunctionReference_SetMinFeatureSize; PLib3MFFunctionReference_GetMinFeatureSizePtr m_FunctionReference_GetMinFeatureSize; + PLib3MFFunctionReference_SetFallBackValuePtr m_FunctionReference_SetFallBackValue; + PLib3MFFunctionReference_GetFallBackValuePtr m_FunctionReference_GetFallBackValue; PLib3MFVolumeDataBoundary_SetMeshBBoxOnlyPtr m_VolumeDataBoundary_SetMeshBBoxOnly; PLib3MFVolumeDataBoundary_GetMeshBBoxOnlyPtr m_VolumeDataBoundary_GetMeshBBoxOnly; PLib3MFVolumeDataComposite_GetBaseMaterialGroupPtr m_VolumeDataComposite_GetBaseMaterialGroup; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc index c0a01f4d2..4609937ee 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc @@ -6081,6 +6081,8 @@ void CLib3MFFunctionReference::Init() NODE_SET_PROTOTYPE_METHOD(tpl, "SetChannelName", SetChannelName); NODE_SET_PROTOTYPE_METHOD(tpl, "SetMinFeatureSize", SetMinFeatureSize); NODE_SET_PROTOTYPE_METHOD(tpl, "GetMinFeatureSize", GetMinFeatureSize); + NODE_SET_PROTOTYPE_METHOD(tpl, "SetFallBackValue", SetFallBackValue); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetFallBackValue", GetFallBackValue); constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); } @@ -6303,6 +6305,52 @@ void CLib3MFFunctionReference::GetMinFeatureSize(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsNumber()) { + throw std::runtime_error("Expected double parameter 0 (FallBackValue)"); + } + double dFallBackValue = (double) args[0]->NumberValue(isolate->GetCurrentContext()).ToChecked(); + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method SetFallBackValue."); + if (wrapperTable->m_FunctionReference_SetFallBackValue == nullptr) + throw std::runtime_error("Could not call Lib3MF method FunctionReference::SetFallBackValue."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_FunctionReference_SetFallBackValue(instanceHandle, dFallBackValue); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFFunctionReference::GetFallBackValue(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + double dReturnFallBackValue = 0.0; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetFallBackValue."); + if (wrapperTable->m_FunctionReference_GetFallBackValue == nullptr) + throw std::runtime_error("Could not call Lib3MF method FunctionReference::GetFallBackValue."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_FunctionReference_GetFallBackValue(instanceHandle, &dReturnFallBackValue); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(Number::New(isolate, dReturnFallBackValue)); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + /************************************************************************************************************************* Class CLib3MFVolumeDataBoundary Implementation **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h index ac8f4604b..708390b1c 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h @@ -608,6 +608,8 @@ class CLib3MFFunctionReference : public CLib3MFBaseClass { static void SetChannelName(const v8::FunctionCallbackInfo& args); static void SetMinFeatureSize(const v8::FunctionCallbackInfo& args); static void GetMinFeatureSize(const v8::FunctionCallbackInfo& args); + static void SetFallBackValue(const v8::FunctionCallbackInfo& args); + static void GetFallBackValue(const v8::FunctionCallbackInfo& args); public: CLib3MFFunctionReference(); diff --git a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas index 10f00e837..5e2755afb 100644 --- a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas +++ b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas @@ -2064,6 +2064,24 @@ TLib3MFModel = class; *) TLib3MFFunctionReference_GetMinFeatureSizeFunc = function(pFunctionReference: TLib3MFHandle; out pMinFeatureSize: Double): TLib3MFResult; cdecl; + (** + * Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * + * @param[in] pFunctionReference - FunctionReference instance. + * @param[in] dFallBackValue - fallback value + * @return error code or 0 (success) + *) + TLib3MFFunctionReference_SetFallBackValueFunc = function(pFunctionReference: TLib3MFHandle; const dFallBackValue: Double): TLib3MFResult; cdecl; + + (** + * Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * + * @param[in] pFunctionReference - FunctionReference instance. + * @param[out] pFallBackValue - fallback value + * @return error code or 0 (success) + *) + TLib3MFFunctionReference_GetFallBackValueFunc = function(pFunctionReference: TLib3MFHandle; out pFallBackValue: Double): TLib3MFResult; cdecl; + (************************************************************************************************************************* Function type definitions for VolumeDataBoundary @@ -7342,6 +7360,8 @@ TLib3MFFunctionReference = class(TLib3MFBase) procedure SetChannelName(const AChannelName: String); procedure SetMinFeatureSize(const AMinFeatureSize: Double); function GetMinFeatureSize(): Double; + procedure SetFallBackValue(const AFallBackValue: Double); + function GetFallBackValue(): Double; end; @@ -8894,6 +8914,8 @@ TLib3MFWrapper = class(TObject) FLib3MFFunctionReference_SetChannelNameFunc: TLib3MFFunctionReference_SetChannelNameFunc; FLib3MFFunctionReference_SetMinFeatureSizeFunc: TLib3MFFunctionReference_SetMinFeatureSizeFunc; FLib3MFFunctionReference_GetMinFeatureSizeFunc: TLib3MFFunctionReference_GetMinFeatureSizeFunc; + FLib3MFFunctionReference_SetFallBackValueFunc: TLib3MFFunctionReference_SetFallBackValueFunc; + FLib3MFFunctionReference_GetFallBackValueFunc: TLib3MFFunctionReference_GetFallBackValueFunc; FLib3MFVolumeDataBoundary_SetMeshBBoxOnlyFunc: TLib3MFVolumeDataBoundary_SetMeshBBoxOnlyFunc; FLib3MFVolumeDataBoundary_GetMeshBBoxOnlyFunc: TLib3MFVolumeDataBoundary_GetMeshBBoxOnlyFunc; FLib3MFVolumeDataComposite_GetBaseMaterialGroupFunc: TLib3MFVolumeDataComposite_GetBaseMaterialGroupFunc; @@ -9487,6 +9509,8 @@ TLib3MFWrapper = class(TObject) property Lib3MFFunctionReference_SetChannelNameFunc: TLib3MFFunctionReference_SetChannelNameFunc read FLib3MFFunctionReference_SetChannelNameFunc; property Lib3MFFunctionReference_SetMinFeatureSizeFunc: TLib3MFFunctionReference_SetMinFeatureSizeFunc read FLib3MFFunctionReference_SetMinFeatureSizeFunc; property Lib3MFFunctionReference_GetMinFeatureSizeFunc: TLib3MFFunctionReference_GetMinFeatureSizeFunc read FLib3MFFunctionReference_GetMinFeatureSizeFunc; + property Lib3MFFunctionReference_SetFallBackValueFunc: TLib3MFFunctionReference_SetFallBackValueFunc read FLib3MFFunctionReference_SetFallBackValueFunc; + property Lib3MFFunctionReference_GetFallBackValueFunc: TLib3MFFunctionReference_GetFallBackValueFunc read FLib3MFFunctionReference_GetFallBackValueFunc; property Lib3MFVolumeDataBoundary_SetMeshBBoxOnlyFunc: TLib3MFVolumeDataBoundary_SetMeshBBoxOnlyFunc read FLib3MFVolumeDataBoundary_SetMeshBBoxOnlyFunc; property Lib3MFVolumeDataBoundary_GetMeshBBoxOnlyFunc: TLib3MFVolumeDataBoundary_GetMeshBBoxOnlyFunc read FLib3MFVolumeDataBoundary_GetMeshBBoxOnlyFunc; property Lib3MFVolumeDataComposite_GetBaseMaterialGroupFunc: TLib3MFVolumeDataComposite_GetBaseMaterialGroupFunc read FLib3MFVolumeDataComposite_GetBaseMaterialGroupFunc; @@ -12994,6 +13018,16 @@ implementation FWrapper.CheckError(Self, FWrapper.Lib3MFFunctionReference_GetMinFeatureSizeFunc(FHandle, Result)); end; + procedure TLib3MFFunctionReference.SetFallBackValue(const AFallBackValue: Double); + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFFunctionReference_SetFallBackValueFunc(FHandle, AFallBackValue)); + end; + + function TLib3MFFunctionReference.GetFallBackValue(): Double; + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFFunctionReference_GetFallBackValueFunc(FHandle, Result)); + end; + (************************************************************************************************************************* Class implementation for VolumeDataBoundary **************************************************************************************************************************) @@ -18613,6 +18647,8 @@ implementation FLib3MFFunctionReference_SetChannelNameFunc := LoadFunction('lib3mf_functionreference_setchannelname'); FLib3MFFunctionReference_SetMinFeatureSizeFunc := LoadFunction('lib3mf_functionreference_setminfeaturesize'); FLib3MFFunctionReference_GetMinFeatureSizeFunc := LoadFunction('lib3mf_functionreference_getminfeaturesize'); + FLib3MFFunctionReference_SetFallBackValueFunc := LoadFunction('lib3mf_functionreference_setfallbackvalue'); + FLib3MFFunctionReference_GetFallBackValueFunc := LoadFunction('lib3mf_functionreference_getfallbackvalue'); FLib3MFVolumeDataBoundary_SetMeshBBoxOnlyFunc := LoadFunction('lib3mf_volumedataboundary_setmeshbboxonly'); FLib3MFVolumeDataBoundary_GetMeshBBoxOnlyFunc := LoadFunction('lib3mf_volumedataboundary_getmeshbboxonly'); FLib3MFVolumeDataComposite_GetBaseMaterialGroupFunc := LoadFunction('lib3mf_volumedatacomposite_getbasematerialgroup'); @@ -19487,6 +19523,12 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_functionreference_getminfeaturesize'), @FLib3MFFunctionReference_GetMinFeatureSizeFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_functionreference_setfallbackvalue'), @FLib3MFFunctionReference_SetFallBackValueFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_functionreference_getfallbackvalue'), @FLib3MFFunctionReference_GetFallBackValueFunc); if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_volumedataboundary_setmeshbboxonly'), @FLib3MFVolumeDataBoundary_SetMeshBBoxOnlyFunc); diff --git a/Autogenerated/Bindings/Python/Lib3MF.py b/Autogenerated/Bindings/Python/Lib3MF.py index 1aaeddfb3..da80f2f00 100644 --- a/Autogenerated/Bindings/Python/Lib3MF.py +++ b/Autogenerated/Bindings/Python/Lib3MF.py @@ -275,6 +275,8 @@ class FunctionTable: lib3mf_functionreference_setchannelname = None lib3mf_functionreference_setminfeaturesize = None lib3mf_functionreference_getminfeaturesize = None + lib3mf_functionreference_setfallbackvalue = None + lib3mf_functionreference_getfallbackvalue = None lib3mf_volumedataboundary_setmeshbboxonly = None lib3mf_volumedataboundary_getmeshbboxonly = None lib3mf_volumedatacomposite_getbasematerialgroup = None @@ -2067,6 +2069,18 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_double)) self.lib.lib3mf_functionreference_getminfeaturesize = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_functionreference_setfallbackvalue")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_double) + self.lib.lib3mf_functionreference_setfallbackvalue = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_functionreference_getfallbackvalue")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_double)) + self.lib.lib3mf_functionreference_getfallbackvalue = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_volumedataboundary_setmeshbboxonly")), methodAddress) if err != 0: raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) @@ -5090,6 +5104,12 @@ def _loadFunctionTable(self): self.lib.lib3mf_functionreference_getminfeaturesize.restype = ctypes.c_int32 self.lib.lib3mf_functionreference_getminfeaturesize.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_double)] + self.lib.lib3mf_functionreference_setfallbackvalue.restype = ctypes.c_int32 + self.lib.lib3mf_functionreference_setfallbackvalue.argtypes = [ctypes.c_void_p, ctypes.c_double] + + self.lib.lib3mf_functionreference_getfallbackvalue.restype = ctypes.c_int32 + self.lib.lib3mf_functionreference_getfallbackvalue.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_double)] + self.lib.lib3mf_volumedataboundary_setmeshbboxonly.restype = ctypes.c_int32 self.lib.lib3mf_volumedataboundary_setmeshbboxonly.argtypes = [ctypes.c_void_p, ctypes.c_bool] @@ -8002,6 +8022,17 @@ def GetMinFeatureSize(self): return pMinFeatureSize.value + def SetFallBackValue(self, FallBackValue): + dFallBackValue = ctypes.c_double(FallBackValue) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_functionreference_setfallbackvalue(self._handle, dFallBackValue)) + + + def GetFallBackValue(self): + pFallBackValue = ctypes.c_double() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_functionreference_getfallbackvalue(self._handle, pFallBackValue)) + + return pFallBackValue.value + ''' Class Implementation for VolumeDataBoundary diff --git a/Autogenerated/Source/lib3mf_abi.hpp b/Autogenerated/Source/lib3mf_abi.hpp index dbd09dfb2..ea533fdec 100644 --- a/Autogenerated/Source/lib3mf_abi.hpp +++ b/Autogenerated/Source/lib3mf_abi.hpp @@ -1508,6 +1508,24 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setminfeaturesize(Lib3MF_F */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getminfeaturesize(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + /************************************************************************************************************************* Class definition for VolumeDataBoundary **************************************************************************************************************************/ diff --git a/Autogenerated/Source/lib3mf_interfaces.hpp b/Autogenerated/Source/lib3mf_interfaces.hpp index c62345e94..0b84f6644 100644 --- a/Autogenerated/Source/lib3mf_interfaces.hpp +++ b/Autogenerated/Source/lib3mf_interfaces.hpp @@ -1731,6 +1731,18 @@ class IFunctionReference : public virtual IBase { */ virtual Lib3MF_double GetMinFeatureSize() = 0; + /** + * IFunctionReference::SetFallBackValue - Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + virtual void SetFallBackValue(const Lib3MF_double dFallBackValue) = 0; + + /** + * IFunctionReference::GetFallBackValue - Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + virtual Lib3MF_double GetFallBackValue() = 0; + }; typedef IBaseSharedPtr PIFunctionReference; diff --git a/Autogenerated/Source/lib3mf_interfacewrapper.cpp b/Autogenerated/Source/lib3mf_interfacewrapper.cpp index 061c1782d..231c14e40 100644 --- a/Autogenerated/Source/lib3mf_interfacewrapper.cpp +++ b/Autogenerated/Source/lib3mf_interfacewrapper.cpp @@ -5302,6 +5302,72 @@ Lib3MFResult lib3mf_functionreference_getminfeaturesize(Lib3MF_FunctionReference } } +Lib3MFResult lib3mf_functionreference_setfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "SetFallBackValue"); + pJournalEntry->addDoubleParameter("FallBackValue", dFallBackValue); + } + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionReference->SetFallBackValue(dFallBackValue); + + 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()); + } +} + +Lib3MFResult lib3mf_functionreference_getfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "GetFallBackValue"); + } + if (pFallBackValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pFallBackValue = pIFunctionReference->GetFallBackValue(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("FallBackValue", *pFallBackValue); + 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 VolumeDataBoundary @@ -22253,6 +22319,10 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_functionreference_setminfeaturesize; if (sProcName == "lib3mf_functionreference_getminfeaturesize") *ppProcAddress = (void*) &lib3mf_functionreference_getminfeaturesize; + if (sProcName == "lib3mf_functionreference_setfallbackvalue") + *ppProcAddress = (void*) &lib3mf_functionreference_setfallbackvalue; + if (sProcName == "lib3mf_functionreference_getfallbackvalue") + *ppProcAddress = (void*) &lib3mf_functionreference_getfallbackvalue; if (sProcName == "lib3mf_volumedataboundary_setmeshbboxonly") *ppProcAddress = (void*) &lib3mf_volumedataboundary_setmeshbboxonly; if (sProcName == "lib3mf_volumedataboundary_getmeshbboxonly") diff --git a/AutomaticComponentToolkit/lib3mf.xml b/AutomaticComponentToolkit/lib3mf.xml index 2f16c14f6..00e01c565 100644 --- a/AutomaticComponentToolkit/lib3mf.xml +++ b/AutomaticComponentToolkit/lib3mf.xml @@ -112,10 +112,12 @@ - - - + description="Link could not be added, the port types are incompatible" /> + + + @@ -1138,6 +1140,16 @@ + + + + + + + + @@ -1836,7 +1848,8 @@ @@ -2312,7 +2325,7 @@ - + @@ -2381,7 +2394,8 @@ - + @@ -2398,7 +2412,8 @@ - + @@ -2766,7 +2781,7 @@ + description="the identifier of the node" /> - - + description="the identifier of the node" /> + + diff --git a/Include/API/lib3mf_functionreference.hpp b/Include/API/lib3mf_functionreference.hpp index 0c3386dd1..b2c7b8295 100644 --- a/Include/API/lib3mf_functionreference.hpp +++ b/Include/API/lib3mf_functionreference.hpp @@ -124,6 +124,20 @@ class CFunctionReference : public virtual IFunctionReference, public virtual CBa * @return minimal feature size */ Lib3MF_double GetMinFeatureSize() override; + + /** + * IFunctionReference::SetFallBackValue - Sets the fallback value to use + * if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + void SetFallBackValue(const Lib3MF_double dFallBackValue) override; + + /** + * IFunctionReference::GetFallBackValue - Returns the fallback value to + * use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + Lib3MF_double GetFallBackValue(); }; } // namespace Impl diff --git a/Include/Common/NMR_ErrorConst.h b/Include/Common/NMR_ErrorConst.h index 3bfc3447c..315ec05dd 100644 --- a/Include/Common/NMR_ErrorConst.h +++ b/Include/Common/NMR_ErrorConst.h @@ -1428,6 +1428,9 @@ Model error codes (0x8XXX) // Function graph is not a directed acyclic graph #define NMR_ERROR_IMPLICIT_FUNCTION_CYCLIC_GRAPH 0x8841 +// Duplicate attribute fallbackvalue in volumedata element +#define NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE 0x8842 + /*------------------------------------------------------------------- XML Parser Error Constants (0x9XXX) -------------------------------------------------------------------*/ diff --git a/Include/Common/NMR_FunctionReference.h b/Include/Common/NMR_FunctionReference.h index 0927c06d9..a5cb2447f 100644 --- a/Include/Common/NMR_FunctionReference.h +++ b/Include/Common/NMR_FunctionReference.h @@ -51,6 +51,8 @@ namespace NMR { bool m_bHasTransform = false; double m_minFeatureSize = 0.0; + + double m_fallBackValue = 0.0; public: CFunctionReference() = delete; explicit CFunctionReference(UniqueResourceID functionResourceId); @@ -69,6 +71,9 @@ namespace NMR { void setMinFeatureSize(double minFeatureSize); double getMinFeatureSize() const; + + void setFallBackValue(double fallBackValue); + double getFallBackValue() const; }; typedef std::shared_ptr PFunctionReference; diff --git a/Include/Model/Classes/NMR_ModelConstants.h b/Include/Model/Classes/NMR_ModelConstants.h index 94737da8c..bc22d2db9 100644 --- a/Include/Model/Classes/NMR_ModelConstants.h +++ b/Include/Model/Classes/NMR_ModelConstants.h @@ -350,6 +350,7 @@ These are given by the 3MF Standard #define XML_3MF_ATTRIBUTE_VOLUMEDATA_CHANNEL "channel" #define XML_3MF_ATTRIBUTE_VOLUMEDATA_SOLIDTHRESHOLD "solidthreshold" #define XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE "minfeaturesize" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE "fallbackvalue" #define XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY "name" #define XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY_REQUIRED "required" diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.h index e43fcd22f..f52f82248 100644 --- a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.h +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.h @@ -50,6 +50,9 @@ namespace NMR { double m_dMinFeatureSize = 0.0; nfBool m_bHasMinFeatureSize = false; + double m_dFallBackValue = 0.0; + nfBool m_bHasFallBackValue = false; + ModelResourceID m_nFunctionID; NMATRIX3 m_Transform; diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h index e807a4575..13edd1a9c 100644 --- a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h @@ -52,6 +52,9 @@ namespace NMR { double m_dMinFeatureSize = 0.0; nfBool m_bHasMinFeatureSize = false; + double m_dFallBackValue = 0.0; + nfBool m_bHasFallBackValue = false; + protected: virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); public: diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h index 5b9fd437b..c118b0e59 100644 --- a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h @@ -54,6 +54,9 @@ namespace NMR { double m_dMinFeatureSize = 0.0; nfBool m_bHasMinFeatureSize = false; + + double m_dFallBackValue = 0.0; + nfBool m_bHasFallBackValue = false; protected: virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); public: diff --git a/Source/API/lib3mf_functionreference.cpp b/Source/API/lib3mf_functionreference.cpp index c9c8976c7..b9e0da67a 100644 --- a/Source/API/lib3mf_functionreference.cpp +++ b/Source/API/lib3mf_functionreference.cpp @@ -92,4 +92,15 @@ void CFunctionReference::SetMinFeatureSize( Lib3MF_double CFunctionReference::GetMinFeatureSize() { return m_pFunctionReference->getMinFeatureSize(); +} + +void CFunctionReference::SetFallBackValue( + const Lib3MF_double dFallBackValue) +{ + m_pFunctionReference->setFallBackValue(dFallBackValue); +} + +Lib3MF_double CFunctionReference::GetFallBackValue() +{ + return m_pFunctionReference->getFallBackValue(); } \ No newline at end of file diff --git a/Source/Common/NMR_Exception.cpp b/Source/Common/NMR_Exception.cpp index 9b8e7df1e..1331a736c 100644 --- a/Source/Common/NMR_Exception.cpp +++ b/Source/Common/NMR_Exception.cpp @@ -503,6 +503,7 @@ namespace NMR { case NMR_ERROR_DUPLICATE_VOLUMEDATA_MESHBBOXONLY : return "Duplicate VolumeData MeshBBoxOnly"; case NMR_ERROR_DUPLICATE_VOLUMEDATA_MINFEATURESIZE : return "Duplicate VolumeData MinFeatureSize"; case NMR_ERROR_IMPLICIT_FUNCTION_CYCLIC_GRAPH : return "Cyclic graph in implicit function"; + case NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE : return "Duplicate VolumeData FallbackValue"; // XML Parser Error Constants(0x9XXX) case NMR_ERROR_XMLPARSER_INVALIDATTRIBVALUE: return "Invalid XML attribute value"; diff --git a/Source/Common/NMR_FunctionReference.cpp b/Source/Common/NMR_FunctionReference.cpp index dcc8cdc37..602d5f5d1 100644 --- a/Source/Common/NMR_FunctionReference.cpp +++ b/Source/Common/NMR_FunctionReference.cpp @@ -96,4 +96,13 @@ namespace NMR return m_minFeatureSize; } + void CFunctionReference::setFallBackValue(double fallBackValue) + { + m_fallBackValue = fallBackValue; + } + + double CFunctionReference::getFallBackValue() const + { + return m_fallBackValue; + } } // namespace NMR diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.cpp index c3ccda858..0277d0835 100644 --- a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.cpp +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Boundary.cpp @@ -89,6 +89,8 @@ namespace NMR { pBoundary->setMeshBBoxOnly(m_meshBBoxOnly); if (m_bHasMinFeatureSize) pBoundary->setMinFeatureSize(m_dMinFeatureSize); + if (m_bHasFallBackValue) + pBoundary->setFallBackValue(m_dFallBackValue); return pBoundary; } @@ -122,15 +124,20 @@ namespace NMR { throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_MINFEATURESIZE); m_bHasMinFeatureSize = true; - m_dMinFeatureSize = strtod(pAttributeValue, nullptr); + m_dMinFeatureSize = fnStringToDouble(pAttributeValue); } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE) == 0) { + if (m_bHasFallBackValue) + throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE); - if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID) == 0) { + m_bHasFallBackValue = true; + m_dFallBackValue = fnStringToDouble(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID) == 0) { if (m_bHasFunctionID) throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATAFIELDID); m_bHasFunctionID = true; - m_nFunctionID = fnStringToUint32(pAttributeValue); } } diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.cpp index b68171681..e4c4eaa95 100644 --- a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.cpp +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.cpp @@ -95,6 +95,11 @@ namespace NMR { { pColor->setMinFeatureSize(m_dMinFeatureSize); } + + if (m_bHasFallBackValue) + { + pColor->setFallBackValue(m_dFallBackValue); + } return pColor; } @@ -129,7 +134,15 @@ namespace NMR { throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_MINFEATURESIZE); m_bHasMinFeatureSize = true; - m_dMinFeatureSize = strtod(pAttributeValue, nullptr); + m_dMinFeatureSize = fnStringToDouble(pAttributeValue); + } + + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE) == 0) { + if (m_bHasFallBackValue) + throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE); + + m_bHasFallBackValue = true; + m_dFallBackValue = fnStringToDouble(pAttributeValue); } } diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.cpp index 1069fdb86..3548eedfd 100644 --- a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.cpp +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.cpp @@ -105,6 +105,12 @@ namespace NMR { { pProperty->setMinFeatureSize(m_dMinFeatureSize); } + + if (m_bHasFallBackValue) + { + pProperty->setFallBackValue(m_dFallBackValue); + } + return pProperty; } @@ -159,6 +165,14 @@ namespace NMR { m_bHasMinFeatureSize = true; m_dMinFeatureSize = strtod(pAttributeValue, nullptr); } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE) == 0) { + if (m_bHasFallBackValue) + throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE); + + m_bHasFallBackValue = true; + m_dFallBackValue = fnStringToDouble(pAttributeValue); + } } void CModelReaderNode_Volumetric2201_Property::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) diff --git a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp index e0b5e2386..2b1b86a6f 100644 --- a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp +++ b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp @@ -398,6 +398,10 @@ namespace NMR { writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE, float(pBoundary->getMinFeatureSize())); } + if (pBoundary->getFallBackValue() != 0.0) { + writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE, float(pBoundary->getFallBackValue())); + } + writeEndElement(); } @@ -428,6 +432,11 @@ namespace NMR { if (pProperty->getMinFeatureSize() != 0.0) { writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE, float(pProperty->getMinFeatureSize())); } + + if (pProperty->getFallBackValue() != 0.0) { + writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE, float(pProperty->getFallBackValue())); + } + writeEndElement(); } } @@ -454,6 +463,11 @@ namespace NMR { if (pColor->getMinFeatureSize() != 0.0) { writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE, float(pColor->getMinFeatureSize())); } + + if (pColor->getFallBackValue() != 0.0) { + writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE, float(pColor->getFallBackValue())); + } + writeEndElement(); } diff --git a/Tests/CPP_Bindings/Source/Volumetric.cpp b/Tests/CPP_Bindings/Source/Volumetric.cpp index 93766981b..eb87bbaa2 100644 --- a/Tests/CPP_Bindings/Source/Volumetric.cpp +++ b/Tests/CPP_Bindings/Source/Volumetric.cpp @@ -479,6 +479,7 @@ namespace Lib3MF auto theMesh = GetMesh(); auto volumeData = theMesh->VolumeData(); auto theBoundary = volumeData->CreateNewBoundary(newFunction.get()); + theBoundary->SetFallBackValue(-1.2345); // Write to file writer3MF->WriteToFile(Volumetric::OutFolder + "ImplicitSphere.3mf"); @@ -497,6 +498,17 @@ namespace Lib3MF EXPECT_EQ(functionIterator->GetCurrentFunction()->GetModelResourceID(), expectedResourceId); + // Get the first Mesh of ioModel + auto meshesFromWrittenFile = ioModel->GetMeshObjects(); + meshesFromWrittenFile->MoveNext(); + auto meshFromWrittenFile = meshesFromWrittenFile->GetCurrentMeshObject(); + + // Check the fallback value + auto volumeDataFromWrittenFile = meshFromWrittenFile->VolumeData(); + auto boundaryFromWrittenFile = volumeDataFromWrittenFile->GetBoundary(); + EXPECT_EQ(boundaryFromWrittenFile->GetFallBackValue(), -1.2345); + + // Compare the functions helper::compareFunctions(model, newFunction, ioModel, functionIterator->GetCurrentFunction());