diff --git a/Autogenerated/Bindings/C/lib3mf.h b/Autogenerated/Bindings/C/lib3mf.h index cae6e016e..03814e42d 100644 --- a/Autogenerated/Bindings/C/lib3mf.h +++ b/Autogenerated/Bindings/C/lib3mf.h @@ -793,6 +793,135 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_removemetadata(Lib3MF_MetaData */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_addmetadata(Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +/************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setname(Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getname(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setidentifier(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getidentifier(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_removetriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_clear(Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_settrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_gettrianglelist(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_merge(Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_deleteset(Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_duplicate(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -1232,6 +1361,56 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject p */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_addtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_hastriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_findtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettrianglesetcount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettriangleset(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + /************************************************************************************************************************* Class definition for LevelSet **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/C/lib3mf_types.h b/Autogenerated/Bindings/C/lib3mf_types.h index a5d436da0..241f77f87 100644 --- a/Autogenerated/Bindings/C/lib3mf_types.h +++ b/Autogenerated/Bindings/C/lib3mf_types.h @@ -131,6 +131,8 @@ typedef void * Lib3MF_pvoid; #define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ #define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ #define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ #define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ #define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ #define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ @@ -187,6 +189,8 @@ inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -227,6 +231,7 @@ typedef Lib3MFHandle Lib3MF_FunctionIterator; typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; typedef Lib3MFHandle Lib3MF_LevelSet; diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc index e15559ef4..2bd0c4527 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.cc @@ -116,6 +116,19 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_MetaDataGroup_RemoveMetaDataByIndex = NULL; pWrapperTable->m_MetaDataGroup_RemoveMetaData = NULL; pWrapperTable->m_MetaDataGroup_AddMetaData = NULL; + pWrapperTable->m_TriangleSet_SetName = NULL; + pWrapperTable->m_TriangleSet_GetName = NULL; + pWrapperTable->m_TriangleSet_SetIdentifier = NULL; + pWrapperTable->m_TriangleSet_GetIdentifier = NULL; + pWrapperTable->m_TriangleSet_AddTriangle = NULL; + pWrapperTable->m_TriangleSet_RemoveTriangle = NULL; + pWrapperTable->m_TriangleSet_Clear = NULL; + pWrapperTable->m_TriangleSet_SetTriangleList = NULL; + pWrapperTable->m_TriangleSet_GetTriangleList = NULL; + pWrapperTable->m_TriangleSet_AddTriangleList = NULL; + pWrapperTable->m_TriangleSet_Merge = NULL; + pWrapperTable->m_TriangleSet_DeleteSet = NULL; + pWrapperTable->m_TriangleSet_Duplicate = NULL; pWrapperTable->m_Object_GetType = NULL; pWrapperTable->m_Object_SetType = NULL; pWrapperTable->m_Object_GetName = NULL; @@ -161,6 +174,11 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_MeshObject_BeamLattice = NULL; pWrapperTable->m_MeshObject_GetVolumeData = NULL; pWrapperTable->m_MeshObject_SetVolumeData = NULL; + pWrapperTable->m_MeshObject_AddTriangleSet = NULL; + pWrapperTable->m_MeshObject_HasTriangleSet = NULL; + pWrapperTable->m_MeshObject_FindTriangleSet = NULL; + pWrapperTable->m_MeshObject_GetTriangleSetCount = NULL; + pWrapperTable->m_MeshObject_GetTriangleSet = NULL; pWrapperTable->m_LevelSet_GetFunction = NULL; pWrapperTable->m_LevelSet_SetFunction = NULL; pWrapperTable->m_LevelSet_GetTransform = NULL; @@ -1316,6 +1334,123 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_MetaDataGroup_AddMetaData == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_setname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetName == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_getname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetName == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_setidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetIdentifier == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_getidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetIdentifier == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_addtriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangle == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_removetriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_removetriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_RemoveTriangle == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_clear"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) dlsym(hLibrary, "lib3mf_triangleset_clear"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Clear == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_settrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_settrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_gettrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_gettrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_addtrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_merge"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) dlsym(hLibrary, "lib3mf_triangleset_merge"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Merge == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_deleteset"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) dlsym(hLibrary, "lib3mf_triangleset_deleteset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_DeleteSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_duplicate"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) dlsym(hLibrary, "lib3mf_triangleset_duplicate"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Duplicate == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Object_GetType = (PLib3MFObject_GetTypePtr) GetProcAddress(hLibrary, "lib3mf_object_gettype"); #else // _WIN32 @@ -1721,6 +1856,51 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_MeshObject_SetVolumeData == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_addtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_addtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_AddTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_hastriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_hastriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_HasTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_findtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_findtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_FindTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) dlsym(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSetCount == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_gettriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_LevelSet_GetFunction = (PLib3MFLevelSet_GetFunctionPtr) GetProcAddress(hLibrary, "lib3mf_levelset_getfunction"); #else // _WIN32 diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h index 0211b290f..972d36377 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_dynamic.h @@ -780,6 +780,135 @@ typedef Lib3MFResult (*PLib3MFMetaDataGroup_RemoveMetaDataPtr) (Lib3MF_MetaDataG */ typedef Lib3MFResult (*PLib3MFMetaDataGroup_AddMetaDataPtr) (Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +/************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_RemoveTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_ClearPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_MergePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DeleteSetPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DuplicatePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -1219,6 +1348,56 @@ typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pM */ typedef Lib3MFResult (*PLib3MFMeshObject_SetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_AddTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_HasTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_FindTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetCountPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + /************************************************************************************************************************* Class definition for LevelSet **************************************************************************************************************************/ @@ -6512,6 +6691,19 @@ typedef struct { PLib3MFMetaDataGroup_RemoveMetaDataByIndexPtr m_MetaDataGroup_RemoveMetaDataByIndex; PLib3MFMetaDataGroup_RemoveMetaDataPtr m_MetaDataGroup_RemoveMetaData; PLib3MFMetaDataGroup_AddMetaDataPtr m_MetaDataGroup_AddMetaData; + PLib3MFTriangleSet_SetNamePtr m_TriangleSet_SetName; + PLib3MFTriangleSet_GetNamePtr m_TriangleSet_GetName; + PLib3MFTriangleSet_SetIdentifierPtr m_TriangleSet_SetIdentifier; + PLib3MFTriangleSet_GetIdentifierPtr m_TriangleSet_GetIdentifier; + PLib3MFTriangleSet_AddTrianglePtr m_TriangleSet_AddTriangle; + PLib3MFTriangleSet_RemoveTrianglePtr m_TriangleSet_RemoveTriangle; + PLib3MFTriangleSet_ClearPtr m_TriangleSet_Clear; + PLib3MFTriangleSet_SetTriangleListPtr m_TriangleSet_SetTriangleList; + PLib3MFTriangleSet_GetTriangleListPtr m_TriangleSet_GetTriangleList; + PLib3MFTriangleSet_AddTriangleListPtr m_TriangleSet_AddTriangleList; + PLib3MFTriangleSet_MergePtr m_TriangleSet_Merge; + PLib3MFTriangleSet_DeleteSetPtr m_TriangleSet_DeleteSet; + PLib3MFTriangleSet_DuplicatePtr m_TriangleSet_Duplicate; PLib3MFObject_GetTypePtr m_Object_GetType; PLib3MFObject_SetTypePtr m_Object_SetType; PLib3MFObject_GetNamePtr m_Object_GetName; @@ -6557,6 +6749,11 @@ typedef struct { PLib3MFMeshObject_BeamLatticePtr m_MeshObject_BeamLattice; PLib3MFMeshObject_GetVolumeDataPtr m_MeshObject_GetVolumeData; PLib3MFMeshObject_SetVolumeDataPtr m_MeshObject_SetVolumeData; + PLib3MFMeshObject_AddTriangleSetPtr m_MeshObject_AddTriangleSet; + PLib3MFMeshObject_HasTriangleSetPtr m_MeshObject_HasTriangleSet; + PLib3MFMeshObject_FindTriangleSetPtr m_MeshObject_FindTriangleSet; + PLib3MFMeshObject_GetTriangleSetCountPtr m_MeshObject_GetTriangleSetCount; + PLib3MFMeshObject_GetTriangleSetPtr m_MeshObject_GetTriangleSet; PLib3MFLevelSet_GetFunctionPtr m_LevelSet_GetFunction; PLib3MFLevelSet_SetFunctionPtr m_LevelSet_SetFunction; PLib3MFLevelSet_GetTransformPtr m_LevelSet_GetTransform; diff --git a/Autogenerated/Bindings/CDynamic/lib3mf_types.h b/Autogenerated/Bindings/CDynamic/lib3mf_types.h index a5d436da0..241f77f87 100644 --- a/Autogenerated/Bindings/CDynamic/lib3mf_types.h +++ b/Autogenerated/Bindings/CDynamic/lib3mf_types.h @@ -131,6 +131,8 @@ typedef void * Lib3MF_pvoid; #define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ #define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ #define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ #define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ #define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ #define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ @@ -187,6 +189,8 @@ inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -227,6 +231,7 @@ typedef Lib3MFHandle Lib3MF_FunctionIterator; typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; typedef Lib3MFHandle Lib3MF_LevelSet; diff --git a/Autogenerated/Bindings/CSharp/Lib3MF.cs b/Autogenerated/Bindings/CSharp/Lib3MF.cs index b43b8beb1..40166c038 100644 --- a/Autogenerated/Bindings/CSharp/Lib3MF.cs +++ b/Autogenerated/Bindings/CSharp/Lib3MF.cs @@ -639,6 +639,45 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_metadatagroup_addmetadata", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 MetaDataGroup_AddMetaData (IntPtr Handle, byte[] ANameSpace, byte[] AName, byte[] AValue, byte[] AType, Byte AMustPreserve, out IntPtr AMetaData); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_setname", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_SetName (IntPtr Handle, byte[] AName); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_getname", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_GetName (IntPtr Handle, UInt32 sizeName, out UInt32 neededName, IntPtr dataName); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_setidentifier", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_SetIdentifier (IntPtr Handle, byte[] AIdentifier); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_getidentifier", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_GetIdentifier (IntPtr Handle, UInt32 sizeIdentifier, out UInt32 neededIdentifier, IntPtr dataIdentifier); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_addtriangle", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_AddTriangle (IntPtr Handle, UInt32 ATriangleIndex); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_removetriangle", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_RemoveTriangle (IntPtr Handle, UInt32 ATriangleIndex); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_clear", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_Clear (IntPtr Handle); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_settrianglelist", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_SetTriangleList (IntPtr Handle, UInt64 sizeTriangleIndices, IntPtr dataTriangleIndices); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_gettrianglelist", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_GetTriangleList (IntPtr Handle, UInt64 sizeTriangleIndices, out UInt64 neededTriangleIndices, IntPtr dataTriangleIndices); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_addtrianglelist", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_AddTriangleList (IntPtr Handle, UInt64 sizeTriangleIndices, IntPtr dataTriangleIndices); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_merge", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_Merge (IntPtr Handle, IntPtr AOtherTriangleSet, Byte ADeleteOther); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_deleteset", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_DeleteSet (IntPtr Handle); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_triangleset_duplicate", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 TriangleSet_Duplicate (IntPtr Handle, byte[] AIdentifier, out IntPtr ANewSet); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_object_gettype", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 Object_GetType (IntPtr Handle, out Int32 AObjectType); @@ -774,6 +813,21 @@ public class Lib3MFWrapper [DllImport("lib3mf.dll", EntryPoint = "lib3mf_meshobject_setvolumedata", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 MeshObject_SetVolumeData (IntPtr Handle, IntPtr ATheVolumeData); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_meshobject_addtriangleset", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 MeshObject_AddTriangleSet (IntPtr Handle, byte[] AIdentifier, byte[] AName, out IntPtr ATheTriangleSet); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_meshobject_hastriangleset", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 MeshObject_HasTriangleSet (IntPtr Handle, byte[] AIdentifier, out Byte ATriangleSetExists); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_meshobject_findtriangleset", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 MeshObject_FindTriangleSet (IntPtr Handle, byte[] AIdentifier, out IntPtr ATheTriangleSet); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_meshobject_gettrianglesetcount", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 MeshObject_GetTriangleSetCount (IntPtr Handle, out UInt32 ACount); + + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_meshobject_gettriangleset", CallingConvention=CallingConvention.Cdecl)] + public unsafe extern static Int32 MeshObject_GetTriangleSet (IntPtr Handle, UInt32 AIndex, out IntPtr ATheTriangleSet); + [DllImport("lib3mf.dll", EntryPoint = "lib3mf_levelset_getfunction", CallingConvention=CallingConvention.Cdecl)] public unsafe extern static Int32 LevelSet_GetFunction (IntPtr Handle, out IntPtr ATheFunction); @@ -2617,6 +2671,7 @@ public static T PolymorphicFactory(IntPtr Handle) where T : class case 0xA0C005C035D5371D: Object = new CLevelSetIterator(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSetIterator" case 0xD17716D063DE2C22: Object = new CMetaData(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::MetaData" case 0x0C3B85369E9B25D3: Object = new CMetaDataGroup(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::MetaDataGroup" + case 0x5950BB3EE8A82090: Object = new CTriangleSet(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::TriangleSet" case 0x2DA2136F577A779C: Object = new CObject(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::Object" case 0x3B3A6DC6EC610497: Object = new CMeshObject(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::MeshObject" case 0xE8A7D9C192EFD0E2: Object = new CLevelSet(Handle) as T; break; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSet" @@ -3497,6 +3552,127 @@ public CMetaData AddMetaData (String ANameSpace, String AName, String AValue, St } + public class CTriangleSet : CBase + { + public CTriangleSet (IntPtr NewHandle) : base (NewHandle) + { + } + + public void SetName (String AName) + { + byte[] byteName = Encoding.UTF8.GetBytes(AName + char.MinValue); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_SetName (Handle, byteName)); + } + + public String GetName () + { + UInt32 sizeName = 0; + UInt32 neededName = 0; + CheckError(Internal.Lib3MFWrapper.TriangleSet_GetName (Handle, sizeName, out neededName, IntPtr.Zero)); + sizeName = neededName; + byte[] bytesName = new byte[sizeName]; + GCHandle dataName = GCHandle.Alloc(bytesName, GCHandleType.Pinned); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_GetName (Handle, sizeName, out neededName, dataName.AddrOfPinnedObject())); + dataName.Free(); + return Encoding.UTF8.GetString(bytesName).TrimEnd(char.MinValue); + } + + public void SetIdentifier (String AIdentifier) + { + byte[] byteIdentifier = Encoding.UTF8.GetBytes(AIdentifier + char.MinValue); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_SetIdentifier (Handle, byteIdentifier)); + } + + public String GetIdentifier () + { + UInt32 sizeIdentifier = 0; + UInt32 neededIdentifier = 0; + CheckError(Internal.Lib3MFWrapper.TriangleSet_GetIdentifier (Handle, sizeIdentifier, out neededIdentifier, IntPtr.Zero)); + sizeIdentifier = neededIdentifier; + byte[] bytesIdentifier = new byte[sizeIdentifier]; + GCHandle dataIdentifier = GCHandle.Alloc(bytesIdentifier, GCHandleType.Pinned); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_GetIdentifier (Handle, sizeIdentifier, out neededIdentifier, dataIdentifier.AddrOfPinnedObject())); + dataIdentifier.Free(); + return Encoding.UTF8.GetString(bytesIdentifier).TrimEnd(char.MinValue); + } + + public void AddTriangle (UInt32 ATriangleIndex) + { + + CheckError(Internal.Lib3MFWrapper.TriangleSet_AddTriangle (Handle, ATriangleIndex)); + } + + public void RemoveTriangle (UInt32 ATriangleIndex) + { + + CheckError(Internal.Lib3MFWrapper.TriangleSet_RemoveTriangle (Handle, ATriangleIndex)); + } + + public void Clear () + { + + CheckError(Internal.Lib3MFWrapper.TriangleSet_Clear (Handle)); + } + + public void SetTriangleList (UInt32[] ATriangleIndices) + { + GCHandle dataTriangleIndices = GCHandle.Alloc(ATriangleIndices, GCHandleType.Pinned); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_SetTriangleList (Handle, (UInt64) ATriangleIndices.Length, dataTriangleIndices.AddrOfPinnedObject())); + dataTriangleIndices.Free (); + } + + public void GetTriangleList (out UInt32[] ATriangleIndices) + { + UInt64 sizeTriangleIndices = 0; + UInt64 neededTriangleIndices = 0; + CheckError(Internal.Lib3MFWrapper.TriangleSet_GetTriangleList (Handle, sizeTriangleIndices, out neededTriangleIndices, IntPtr.Zero)); + sizeTriangleIndices = neededTriangleIndices; + ATriangleIndices = new UInt32[sizeTriangleIndices]; + GCHandle dataTriangleIndices = GCHandle.Alloc(ATriangleIndices, GCHandleType.Pinned); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_GetTriangleList (Handle, sizeTriangleIndices, out neededTriangleIndices, dataTriangleIndices.AddrOfPinnedObject())); + dataTriangleIndices.Free(); + } + + public void AddTriangleList (UInt32[] ATriangleIndices) + { + GCHandle dataTriangleIndices = GCHandle.Alloc(ATriangleIndices, GCHandleType.Pinned); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_AddTriangleList (Handle, (UInt64) ATriangleIndices.Length, dataTriangleIndices.AddrOfPinnedObject())); + dataTriangleIndices.Free (); + } + + public void Merge (CTriangleSet AOtherTriangleSet, bool ADeleteOther) + { + IntPtr AOtherTriangleSetHandle = IntPtr.Zero; + if (AOtherTriangleSet != null) + AOtherTriangleSetHandle = AOtherTriangleSet.GetHandle(); + + CheckError(Internal.Lib3MFWrapper.TriangleSet_Merge (Handle, AOtherTriangleSetHandle, (Byte)( ADeleteOther ? 1 : 0 ))); + } + + public void DeleteSet () + { + + CheckError(Internal.Lib3MFWrapper.TriangleSet_DeleteSet (Handle)); + } + + public CTriangleSet Duplicate (String AIdentifier) + { + byte[] byteIdentifier = Encoding.UTF8.GetBytes(AIdentifier + char.MinValue); + IntPtr newNewSet = IntPtr.Zero; + + CheckError(Internal.Lib3MFWrapper.TriangleSet_Duplicate (Handle, byteIdentifier, out newNewSet)); + return Internal.Lib3MFWrapper.PolymorphicFactory(newNewSet); + } + + } + public class CObject : CResource { public CObject (IntPtr NewHandle) : base (NewHandle) @@ -3915,6 +4091,50 @@ public void SetVolumeData (CVolumeData ATheVolumeData) CheckError(Internal.Lib3MFWrapper.MeshObject_SetVolumeData (Handle, ATheVolumeDataHandle)); } + public CTriangleSet AddTriangleSet (String AIdentifier, String AName) + { + byte[] byteIdentifier = Encoding.UTF8.GetBytes(AIdentifier + char.MinValue); + byte[] byteName = Encoding.UTF8.GetBytes(AName + char.MinValue); + IntPtr newTheTriangleSet = IntPtr.Zero; + + CheckError(Internal.Lib3MFWrapper.MeshObject_AddTriangleSet (Handle, byteIdentifier, byteName, out newTheTriangleSet)); + return Internal.Lib3MFWrapper.PolymorphicFactory(newTheTriangleSet); + } + + public bool HasTriangleSet (String AIdentifier) + { + byte[] byteIdentifier = Encoding.UTF8.GetBytes(AIdentifier + char.MinValue); + Byte resultTriangleSetExists = 0; + + CheckError(Internal.Lib3MFWrapper.MeshObject_HasTriangleSet (Handle, byteIdentifier, out resultTriangleSetExists)); + return (resultTriangleSetExists != 0); + } + + public CTriangleSet FindTriangleSet (String AIdentifier) + { + byte[] byteIdentifier = Encoding.UTF8.GetBytes(AIdentifier + char.MinValue); + IntPtr newTheTriangleSet = IntPtr.Zero; + + CheckError(Internal.Lib3MFWrapper.MeshObject_FindTriangleSet (Handle, byteIdentifier, out newTheTriangleSet)); + return Internal.Lib3MFWrapper.PolymorphicFactory(newTheTriangleSet); + } + + public UInt32 GetTriangleSetCount () + { + UInt32 resultCount = 0; + + CheckError(Internal.Lib3MFWrapper.MeshObject_GetTriangleSetCount (Handle, out resultCount)); + return resultCount; + } + + public CTriangleSet GetTriangleSet (UInt32 AIndex) + { + IntPtr newTheTriangleSet = IntPtr.Zero; + + CheckError(Internal.Lib3MFWrapper.MeshObject_GetTriangleSet (Handle, AIndex, out newTheTriangleSet)); + return Internal.Lib3MFWrapper.PolymorphicFactory(newTheTriangleSet); + } + } public class CLevelSet : CObject diff --git a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp index 1e3907a69..608d1bd02 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_abi.hpp @@ -793,6 +793,135 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_removemetadata(Lib3MF_MetaData */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_addmetadata(Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +/************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setname(Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getname(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setidentifier(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getidentifier(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_removetriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_clear(Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_settrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_gettrianglelist(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_merge(Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_deleteset(Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_duplicate(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -1232,6 +1361,56 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject p */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_addtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_hastriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_findtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettrianglesetcount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettriangleset(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + /************************************************************************************************************************* Class definition for LevelSet **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp index cc9e59baa..3de401e0d 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_implicit.hpp @@ -78,6 +78,7 @@ class CFunctionIterator; class CLevelSetIterator; class CMetaData; class CMetaDataGroup; +class CTriangleSet; class CObject; class CMeshObject; class CLevelSet; @@ -198,6 +199,7 @@ typedef CFunctionIterator CLib3MFFunctionIterator; typedef CLevelSetIterator CLib3MFLevelSetIterator; typedef CMetaData CLib3MFMetaData; typedef CMetaDataGroup CLib3MFMetaDataGroup; +typedef CTriangleSet CLib3MFTriangleSet; typedef CObject CLib3MFObject; typedef CMeshObject CLib3MFMeshObject; typedef CLevelSet CLib3MFLevelSet; @@ -318,6 +320,7 @@ typedef std::shared_ptr PFunctionIterator; typedef std::shared_ptr PLevelSetIterator; typedef std::shared_ptr PMetaData; typedef std::shared_ptr PMetaDataGroup; +typedef std::shared_ptr PTriangleSet; typedef std::shared_ptr PObject; typedef std::shared_ptr PMeshObject; typedef std::shared_ptr PLevelSet; @@ -438,6 +441,7 @@ typedef PFunctionIterator PLib3MFFunctionIterator; typedef PLevelSetIterator PLib3MFLevelSetIterator; typedef PMetaData PLib3MFMetaData; typedef PMetaDataGroup PLib3MFMetaDataGroup; +typedef PTriangleSet PLib3MFTriangleSet; typedef PObject PLib3MFObject; typedef PMeshObject PLib3MFMeshObject; typedef PLevelSet PLib3MFLevelSet; @@ -650,6 +654,8 @@ class ELib3MFException : public std::exception { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "ELEMENTCOUNTEXCEEDSLIMIT"; case LIB3MF_ERROR_INVALIDRESOURCE: return "INVALIDRESOURCE"; case LIB3MF_ERROR_INVALIDLEVELSET: return "INVALIDLEVELSET"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "COULDNOTFINDTRIANGLESET"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "INVALIDTRIANGLESETINDEX"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "BEAMLATTICE_INVALID_OBJECTTYPE"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "INVALIDKEYSTORE"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "INVALIDKEYSTORECONSUMER"; @@ -706,6 +712,8 @@ class ELib3MFException : public std::exception { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -846,6 +854,7 @@ class CWrapper { friend class CLevelSetIterator; friend class CMetaData; friend class CMetaDataGroup; + friend class CTriangleSet; friend class CObject; friend class CMeshObject; friend class CLevelSet; @@ -1388,6 +1397,35 @@ class CMetaDataGroup : public CBase { inline PMetaData AddMetaData(const std::string & sNameSpace, const std::string & sName, const std::string & sValue, const std::string & sType, const bool bMustPreserve); }; +/************************************************************************************************************************* + Class CTriangleSet +**************************************************************************************************************************/ +class CTriangleSet : public CBase { +public: + + /** + * CTriangleSet::CTriangleSet - Constructor for TriangleSet class. + */ + CTriangleSet(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void SetName(const std::string & sName); + inline std::string GetName(); + inline void SetIdentifier(const std::string & sIdentifier); + inline std::string GetIdentifier(); + inline void AddTriangle(const Lib3MF_uint32 nTriangleIndex); + inline void RemoveTriangle(const Lib3MF_uint32 nTriangleIndex); + inline void Clear(); + inline void SetTriangleList(const CInputVector & TriangleIndicesBuffer); + inline void GetTriangleList(std::vector & TriangleIndicesBuffer); + inline void AddTriangleList(const CInputVector & TriangleIndicesBuffer); + inline void Merge(classParam pOtherTriangleSet, const bool bDeleteOther); + inline void DeleteSet(); + inline PTriangleSet Duplicate(const std::string & sIdentifier); +}; + /************************************************************************************************************************* Class CObject **************************************************************************************************************************/ @@ -1463,6 +1501,11 @@ class CMeshObject : public CObject { inline PBeamLattice BeamLattice(); inline PVolumeData GetVolumeData(); inline void SetVolumeData(classParam pTheVolumeData); + inline PTriangleSet AddTriangleSet(const std::string & sIdentifier, const std::string & sName); + inline bool HasTriangleSet(const std::string & sIdentifier); + inline PTriangleSet FindTriangleSet(const std::string & sIdentifier); + inline Lib3MF_uint32 GetTriangleSetCount(); + inline PTriangleSet GetTriangleSet(const Lib3MF_uint32 nIndex); }; /************************************************************************************************************************* @@ -3444,6 +3487,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) case 0xA0C005C035D5371DUL: return new CLevelSetIterator(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSetIterator" case 0xD17716D063DE2C22UL: return new CMetaData(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::MetaData" case 0x0C3B85369E9B25D3UL: return new CMetaDataGroup(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::MetaDataGroup" + case 0x5950BB3EE8A82090UL: return new CTriangleSet(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::TriangleSet" case 0x2DA2136F577A779CUL: return new CObject(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::Object" case 0x3B3A6DC6EC610497UL: return new CMeshObject(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::MeshObject" case 0xE8A7D9C192EFD0E2UL: return new CLevelSet(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSet" @@ -4754,6 +4798,152 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hMetaData))); } + /** + * Method definitions for class CTriangleSet + */ + + /** + * CTriangleSet::SetName - sets the name of the triangle set + * @param[in] sName - the new name + */ + void CTriangleSet::SetName(const std::string & sName) + { + CheckError(lib3mf_triangleset_setname(m_pHandle, sName.c_str())); + } + + /** + * CTriangleSet::GetName - returns the name of the triangle set + * @return returns the name + */ + std::string CTriangleSet::GetName() + { + Lib3MF_uint32 bytesNeededName = 0; + Lib3MF_uint32 bytesWrittenName = 0; + CheckError(lib3mf_triangleset_getname(m_pHandle, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(lib3mf_triangleset_getname(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CTriangleSet::SetIdentifier - sets the identifier of the triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + */ + void CTriangleSet::SetIdentifier(const std::string & sIdentifier) + { + CheckError(lib3mf_triangleset_setidentifier(m_pHandle, sIdentifier.c_str())); + } + + /** + * CTriangleSet::GetIdentifier - returns the identifier of the triangle set + * @return returns the identifier + */ + std::string CTriangleSet::GetIdentifier() + { + Lib3MF_uint32 bytesNeededIdentifier = 0; + Lib3MF_uint32 bytesWrittenIdentifier = 0; + CheckError(lib3mf_triangleset_getidentifier(m_pHandle, 0, &bytesNeededIdentifier, nullptr)); + std::vector bufferIdentifier(bytesNeededIdentifier); + CheckError(lib3mf_triangleset_getidentifier(m_pHandle, bytesNeededIdentifier, &bytesWrittenIdentifier, &bufferIdentifier[0])); + + return std::string(&bufferIdentifier[0]); + } + + /** + * CTriangleSet::AddTriangle - adds a triangle to the set. Does nothing if triangle is already in the set. + * @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::AddTriangle(const Lib3MF_uint32 nTriangleIndex) + { + CheckError(lib3mf_triangleset_addtriangle(m_pHandle, nTriangleIndex)); + } + + /** + * CTriangleSet::RemoveTriangle - removes a triangle from the set + * @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) + { + CheckError(lib3mf_triangleset_removetriangle(m_pHandle, nTriangleIndex)); + } + + /** + * CTriangleSet::Clear - clears all triangles from the list + */ + void CTriangleSet::Clear() + { + CheckError(lib3mf_triangleset_clear(m_pHandle)); + } + + /** + * CTriangleSet::SetTriangleList - Sets all triangles in the list, while clearing old values. Duplicates will be merged. + * @param[in] TriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::SetTriangleList(const CInputVector & TriangleIndicesBuffer) + { + Lib3MF_uint64 nTriangleIndicesSize = TriangleIndicesBuffer.size(); + CheckError(lib3mf_triangleset_settrianglelist(m_pHandle, nTriangleIndicesSize, TriangleIndicesBuffer.data())); + } + + /** + * CTriangleSet::GetTriangleList - Retrieves all the triangles in the TriangleSet + * @param[out] TriangleIndicesBuffer - retrieves the indices of the triangles in this TriangleSet + */ + void CTriangleSet::GetTriangleList(std::vector & TriangleIndicesBuffer) + { + Lib3MF_uint64 elementsNeededTriangleIndices = 0; + Lib3MF_uint64 elementsWrittenTriangleIndices = 0; + CheckError(lib3mf_triangleset_gettrianglelist(m_pHandle, 0, &elementsNeededTriangleIndices, nullptr)); + TriangleIndicesBuffer.resize((size_t) elementsNeededTriangleIndices); + CheckError(lib3mf_triangleset_gettrianglelist(m_pHandle, elementsNeededTriangleIndices, &elementsWrittenTriangleIndices, TriangleIndicesBuffer.data())); + } + + /** + * CTriangleSet::AddTriangleList - Adds multiple triangles in the list. Duplicates will be merged. + * @param[in] TriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::AddTriangleList(const CInputVector & TriangleIndicesBuffer) + { + Lib3MF_uint64 nTriangleIndicesSize = TriangleIndicesBuffer.size(); + CheckError(lib3mf_triangleset_addtrianglelist(m_pHandle, nTriangleIndicesSize, TriangleIndicesBuffer.data())); + } + + /** + * CTriangleSet::Merge - Merges another Triangle set. + * @param[in] pOtherTriangleSet - Other triangle set to merge. + * @param[in] bDeleteOther - Flag if other triangle set is getting removed. + */ + void CTriangleSet::Merge(classParam pOtherTriangleSet, const bool bDeleteOther) + { + Lib3MFHandle hOtherTriangleSet = pOtherTriangleSet.GetHandle(); + CheckError(lib3mf_triangleset_merge(m_pHandle, hOtherTriangleSet, bDeleteOther)); + } + + /** + * CTriangleSet::DeleteSet - Deletes the whole set from the mesh. + */ + void CTriangleSet::DeleteSet() + { + CheckError(lib3mf_triangleset_deleteset(m_pHandle)); + } + + /** + * CTriangleSet::Duplicate - Duplicates the set in the mesh. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @return Copy of the triangle set. + */ + PTriangleSet CTriangleSet::Duplicate(const std::string & sIdentifier) + { + Lib3MFHandle hNewSet = (Lib3MFHandle)nullptr; + CheckError(lib3mf_triangleset_duplicate(m_pHandle, sIdentifier.c_str(), &hNewSet)); + + if (!hNewSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hNewSet))); + } + /** * Method definitions for class CObject */ @@ -5294,6 +5484,80 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) CheckError(lib3mf_meshobject_setvolumedata(m_pHandle, hTheVolumeData)); } + /** + * CMeshObject::AddTriangleSet - Adds a new triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @param[in] sName - the human readable name. MUST NOT be an empty string + * @return the new Triangle Set Instance. + */ + PTriangleSet CMeshObject::AddTriangleSet(const std::string & sIdentifier, const std::string & sName) + { + Lib3MFHandle hTheTriangleSet = (Lib3MFHandle)nullptr; + CheckError(lib3mf_meshobject_addtriangleset(m_pHandle, sIdentifier.c_str(), sName.c_str(), &hTheTriangleSet)); + + if (!hTheTriangleSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hTheTriangleSet))); + } + + /** + * CMeshObject::HasTriangleSet - Checks if a triangle set exists. + * @param[in] sIdentifier - the identifier to be found. + * @return flag if the triangles set exists. + */ + bool CMeshObject::HasTriangleSet(const std::string & sIdentifier) + { + bool resultTriangleSetExists = 0; + CheckError(lib3mf_meshobject_hastriangleset(m_pHandle, sIdentifier.c_str(), &resultTriangleSetExists)); + + return resultTriangleSetExists; + } + + /** + * CMeshObject::FindTriangleSet - Finds a new triangle set by identifier. Fails if not existing. + * @param[in] sIdentifier - the identifier to be found. + * @return the triangle Set Instance. + */ + PTriangleSet CMeshObject::FindTriangleSet(const std::string & sIdentifier) + { + Lib3MFHandle hTheTriangleSet = (Lib3MFHandle)nullptr; + CheckError(lib3mf_meshobject_findtriangleset(m_pHandle, sIdentifier.c_str(), &hTheTriangleSet)); + + if (!hTheTriangleSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hTheTriangleSet))); + } + + /** + * CMeshObject::GetTriangleSetCount - Returns number of triangle sets. + * @return the number of triangle sets of this mesh. + */ + Lib3MF_uint32 CMeshObject::GetTriangleSetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_meshobject_gettrianglesetcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CMeshObject::GetTriangleSet - Returns a specific triangle set by index. + * @param[in] nIndex - the index of the triangle set. + * @return the triangle Set Instance. + */ + PTriangleSet CMeshObject::GetTriangleSet(const Lib3MF_uint32 nIndex) + { + Lib3MFHandle hTheTriangleSet = (Lib3MFHandle)nullptr; + CheckError(lib3mf_meshobject_gettriangleset(m_pHandle, nIndex, &hTheTriangleSet)); + + if (!hTheTriangleSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hTheTriangleSet))); + } + /** * Method definitions for class CLevelSet */ diff --git a/Autogenerated/Bindings/Cpp/lib3mf_types.hpp b/Autogenerated/Bindings/Cpp/lib3mf_types.hpp index 4ba959150..0d520b820 100644 --- a/Autogenerated/Bindings/Cpp/lib3mf_types.hpp +++ b/Autogenerated/Bindings/Cpp/lib3mf_types.hpp @@ -130,6 +130,8 @@ typedef void * Lib3MF_pvoid; #define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ #define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ #define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ #define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ #define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ #define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ @@ -186,6 +188,8 @@ inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -226,6 +230,7 @@ typedef Lib3MFHandle Lib3MF_FunctionIterator; typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; typedef Lib3MFHandle Lib3MF_LevelSet; diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h index 217e55618..3189ac21f 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.h @@ -780,6 +780,135 @@ typedef Lib3MFResult (*PLib3MFMetaDataGroup_RemoveMetaDataPtr) (Lib3MF_MetaDataG */ typedef Lib3MFResult (*PLib3MFMetaDataGroup_AddMetaDataPtr) (Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +/************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_RemoveTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_ClearPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_MergePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DeleteSetPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DuplicatePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -1219,6 +1348,56 @@ typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pM */ typedef Lib3MFResult (*PLib3MFMeshObject_SetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_AddTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_HasTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_FindTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetCountPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + /************************************************************************************************************************* Class definition for LevelSet **************************************************************************************************************************/ @@ -6512,6 +6691,19 @@ typedef struct { PLib3MFMetaDataGroup_RemoveMetaDataByIndexPtr m_MetaDataGroup_RemoveMetaDataByIndex; PLib3MFMetaDataGroup_RemoveMetaDataPtr m_MetaDataGroup_RemoveMetaData; PLib3MFMetaDataGroup_AddMetaDataPtr m_MetaDataGroup_AddMetaData; + PLib3MFTriangleSet_SetNamePtr m_TriangleSet_SetName; + PLib3MFTriangleSet_GetNamePtr m_TriangleSet_GetName; + PLib3MFTriangleSet_SetIdentifierPtr m_TriangleSet_SetIdentifier; + PLib3MFTriangleSet_GetIdentifierPtr m_TriangleSet_GetIdentifier; + PLib3MFTriangleSet_AddTrianglePtr m_TriangleSet_AddTriangle; + PLib3MFTriangleSet_RemoveTrianglePtr m_TriangleSet_RemoveTriangle; + PLib3MFTriangleSet_ClearPtr m_TriangleSet_Clear; + PLib3MFTriangleSet_SetTriangleListPtr m_TriangleSet_SetTriangleList; + PLib3MFTriangleSet_GetTriangleListPtr m_TriangleSet_GetTriangleList; + PLib3MFTriangleSet_AddTriangleListPtr m_TriangleSet_AddTriangleList; + PLib3MFTriangleSet_MergePtr m_TriangleSet_Merge; + PLib3MFTriangleSet_DeleteSetPtr m_TriangleSet_DeleteSet; + PLib3MFTriangleSet_DuplicatePtr m_TriangleSet_Duplicate; PLib3MFObject_GetTypePtr m_Object_GetType; PLib3MFObject_SetTypePtr m_Object_SetType; PLib3MFObject_GetNamePtr m_Object_GetName; @@ -6557,6 +6749,11 @@ typedef struct { PLib3MFMeshObject_BeamLatticePtr m_MeshObject_BeamLattice; PLib3MFMeshObject_GetVolumeDataPtr m_MeshObject_GetVolumeData; PLib3MFMeshObject_SetVolumeDataPtr m_MeshObject_SetVolumeData; + PLib3MFMeshObject_AddTriangleSetPtr m_MeshObject_AddTriangleSet; + PLib3MFMeshObject_HasTriangleSetPtr m_MeshObject_HasTriangleSet; + PLib3MFMeshObject_FindTriangleSetPtr m_MeshObject_FindTriangleSet; + PLib3MFMeshObject_GetTriangleSetCountPtr m_MeshObject_GetTriangleSetCount; + PLib3MFMeshObject_GetTriangleSetPtr m_MeshObject_GetTriangleSet; PLib3MFLevelSet_GetFunctionPtr m_LevelSet_GetFunction; PLib3MFLevelSet_SetFunctionPtr m_LevelSet_SetFunction; PLib3MFLevelSet_GetTransformPtr m_LevelSet_GetTransform; diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp index ce245d95f..b763295e3 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_dynamic.hpp @@ -78,6 +78,7 @@ class CFunctionIterator; class CLevelSetIterator; class CMetaData; class CMetaDataGroup; +class CTriangleSet; class CObject; class CMeshObject; class CLevelSet; @@ -198,6 +199,7 @@ typedef CFunctionIterator CLib3MFFunctionIterator; typedef CLevelSetIterator CLib3MFLevelSetIterator; typedef CMetaData CLib3MFMetaData; typedef CMetaDataGroup CLib3MFMetaDataGroup; +typedef CTriangleSet CLib3MFTriangleSet; typedef CObject CLib3MFObject; typedef CMeshObject CLib3MFMeshObject; typedef CLevelSet CLib3MFLevelSet; @@ -318,6 +320,7 @@ typedef std::shared_ptr PFunctionIterator; typedef std::shared_ptr PLevelSetIterator; typedef std::shared_ptr PMetaData; typedef std::shared_ptr PMetaDataGroup; +typedef std::shared_ptr PTriangleSet; typedef std::shared_ptr PObject; typedef std::shared_ptr PMeshObject; typedef std::shared_ptr PLevelSet; @@ -438,6 +441,7 @@ typedef PFunctionIterator PLib3MFFunctionIterator; typedef PLevelSetIterator PLib3MFLevelSetIterator; typedef PMetaData PLib3MFMetaData; typedef PMetaDataGroup PLib3MFMetaDataGroup; +typedef PTriangleSet PLib3MFTriangleSet; typedef PObject PLib3MFObject; typedef PMeshObject PLib3MFMeshObject; typedef PLevelSet PLib3MFLevelSet; @@ -650,6 +654,8 @@ class ELib3MFException : public std::exception { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "ELEMENTCOUNTEXCEEDSLIMIT"; case LIB3MF_ERROR_INVALIDRESOURCE: return "INVALIDRESOURCE"; case LIB3MF_ERROR_INVALIDLEVELSET: return "INVALIDLEVELSET"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "COULDNOTFINDTRIANGLESET"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "INVALIDTRIANGLESETINDEX"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "BEAMLATTICE_INVALID_OBJECTTYPE"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "INVALIDKEYSTORE"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "INVALIDKEYSTORECONSUMER"; @@ -706,6 +712,8 @@ class ELib3MFException : public std::exception { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -870,6 +878,7 @@ class CWrapper { friend class CLevelSetIterator; friend class CMetaData; friend class CMetaDataGroup; + friend class CTriangleSet; friend class CObject; friend class CMeshObject; friend class CLevelSet; @@ -1412,6 +1421,35 @@ class CMetaDataGroup : public CBase { inline PMetaData AddMetaData(const std::string & sNameSpace, const std::string & sName, const std::string & sValue, const std::string & sType, const bool bMustPreserve); }; +/************************************************************************************************************************* + Class CTriangleSet +**************************************************************************************************************************/ +class CTriangleSet : public CBase { +public: + + /** + * CTriangleSet::CTriangleSet - Constructor for TriangleSet class. + */ + CTriangleSet(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void SetName(const std::string & sName); + inline std::string GetName(); + inline void SetIdentifier(const std::string & sIdentifier); + inline std::string GetIdentifier(); + inline void AddTriangle(const Lib3MF_uint32 nTriangleIndex); + inline void RemoveTriangle(const Lib3MF_uint32 nTriangleIndex); + inline void Clear(); + inline void SetTriangleList(const CInputVector & TriangleIndicesBuffer); + inline void GetTriangleList(std::vector & TriangleIndicesBuffer); + inline void AddTriangleList(const CInputVector & TriangleIndicesBuffer); + inline void Merge(classParam pOtherTriangleSet, const bool bDeleteOther); + inline void DeleteSet(); + inline PTriangleSet Duplicate(const std::string & sIdentifier); +}; + /************************************************************************************************************************* Class CObject **************************************************************************************************************************/ @@ -1487,6 +1525,11 @@ class CMeshObject : public CObject { inline PBeamLattice BeamLattice(); inline PVolumeData GetVolumeData(); inline void SetVolumeData(classParam pTheVolumeData); + inline PTriangleSet AddTriangleSet(const std::string & sIdentifier, const std::string & sName); + inline bool HasTriangleSet(const std::string & sIdentifier); + inline PTriangleSet FindTriangleSet(const std::string & sIdentifier); + inline Lib3MF_uint32 GetTriangleSetCount(); + inline PTriangleSet GetTriangleSet(const Lib3MF_uint32 nIndex); }; /************************************************************************************************************************* @@ -3468,6 +3511,7 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) case 0xA0C005C035D5371DUL: return new CLevelSetIterator(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSetIterator" case 0xD17716D063DE2C22UL: return new CMetaData(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::MetaData" case 0x0C3B85369E9B25D3UL: return new CMetaDataGroup(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::MetaDataGroup" + case 0x5950BB3EE8A82090UL: return new CTriangleSet(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::TriangleSet" case 0x2DA2136F577A779CUL: return new CObject(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::Object" case 0x3B3A6DC6EC610497UL: return new CMeshObject(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::MeshObject" case 0xE8A7D9C192EFD0E2UL: return new CLevelSet(this, pHandle); break; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSet" @@ -3916,6 +3960,19 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_MetaDataGroup_RemoveMetaDataByIndex = nullptr; pWrapperTable->m_MetaDataGroup_RemoveMetaData = nullptr; pWrapperTable->m_MetaDataGroup_AddMetaData = nullptr; + pWrapperTable->m_TriangleSet_SetName = nullptr; + pWrapperTable->m_TriangleSet_GetName = nullptr; + pWrapperTable->m_TriangleSet_SetIdentifier = nullptr; + pWrapperTable->m_TriangleSet_GetIdentifier = nullptr; + pWrapperTable->m_TriangleSet_AddTriangle = nullptr; + pWrapperTable->m_TriangleSet_RemoveTriangle = nullptr; + pWrapperTable->m_TriangleSet_Clear = nullptr; + pWrapperTable->m_TriangleSet_SetTriangleList = nullptr; + pWrapperTable->m_TriangleSet_GetTriangleList = nullptr; + pWrapperTable->m_TriangleSet_AddTriangleList = nullptr; + pWrapperTable->m_TriangleSet_Merge = nullptr; + pWrapperTable->m_TriangleSet_DeleteSet = nullptr; + pWrapperTable->m_TriangleSet_Duplicate = nullptr; pWrapperTable->m_Object_GetType = nullptr; pWrapperTable->m_Object_SetType = nullptr; pWrapperTable->m_Object_GetName = nullptr; @@ -3961,6 +4018,11 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) pWrapperTable->m_MeshObject_BeamLattice = nullptr; pWrapperTable->m_MeshObject_GetVolumeData = nullptr; pWrapperTable->m_MeshObject_SetVolumeData = nullptr; + pWrapperTable->m_MeshObject_AddTriangleSet = nullptr; + pWrapperTable->m_MeshObject_HasTriangleSet = nullptr; + pWrapperTable->m_MeshObject_FindTriangleSet = nullptr; + pWrapperTable->m_MeshObject_GetTriangleSetCount = nullptr; + pWrapperTable->m_MeshObject_GetTriangleSet = nullptr; pWrapperTable->m_LevelSet_GetFunction = nullptr; pWrapperTable->m_LevelSet_SetFunction = nullptr; pWrapperTable->m_LevelSet_GetTransform = nullptr; @@ -5112,6 +5174,123 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_MetaDataGroup_AddMetaData == nullptr) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_setname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetName == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_getname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetName == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_setidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetIdentifier == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_getidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetIdentifier == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_addtriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangle == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_removetriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_removetriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_RemoveTriangle == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_clear"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) dlsym(hLibrary, "lib3mf_triangleset_clear"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Clear == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_settrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_settrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetTriangleList == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_gettrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_gettrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetTriangleList == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_addtrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangleList == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_merge"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) dlsym(hLibrary, "lib3mf_triangleset_merge"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Merge == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_deleteset"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) dlsym(hLibrary, "lib3mf_triangleset_deleteset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_DeleteSet == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_duplicate"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) dlsym(hLibrary, "lib3mf_triangleset_duplicate"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Duplicate == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Object_GetType = (PLib3MFObject_GetTypePtr) GetProcAddress(hLibrary, "lib3mf_object_gettype"); #else // _WIN32 @@ -5517,6 +5696,51 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if (pWrapperTable->m_MeshObject_SetVolumeData == nullptr) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_addtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_addtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_AddTriangleSet == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_hastriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_hastriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_HasTriangleSet == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_findtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_findtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_FindTriangleSet == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) dlsym(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSetCount == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_gettriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSet == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_LevelSet_GetFunction = (PLib3MFLevelSet_GetFunctionPtr) GetProcAddress(hLibrary, "lib3mf_levelset_getfunction"); #else // _WIN32 @@ -10206,6 +10430,58 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_MetaDataGroup_AddMetaData == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_triangleset_setname", (void**)&(pWrapperTable->m_TriangleSet_SetName)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_SetName == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_getname", (void**)&(pWrapperTable->m_TriangleSet_GetName)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_GetName == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_setidentifier", (void**)&(pWrapperTable->m_TriangleSet_SetIdentifier)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_SetIdentifier == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_getidentifier", (void**)&(pWrapperTable->m_TriangleSet_GetIdentifier)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_GetIdentifier == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_addtriangle", (void**)&(pWrapperTable->m_TriangleSet_AddTriangle)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_AddTriangle == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_removetriangle", (void**)&(pWrapperTable->m_TriangleSet_RemoveTriangle)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_RemoveTriangle == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_clear", (void**)&(pWrapperTable->m_TriangleSet_Clear)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_Clear == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_settrianglelist", (void**)&(pWrapperTable->m_TriangleSet_SetTriangleList)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_SetTriangleList == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_gettrianglelist", (void**)&(pWrapperTable->m_TriangleSet_GetTriangleList)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_GetTriangleList == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_addtrianglelist", (void**)&(pWrapperTable->m_TriangleSet_AddTriangleList)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_AddTriangleList == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_merge", (void**)&(pWrapperTable->m_TriangleSet_Merge)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_Merge == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_deleteset", (void**)&(pWrapperTable->m_TriangleSet_DeleteSet)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_DeleteSet == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_triangleset_duplicate", (void**)&(pWrapperTable->m_TriangleSet_Duplicate)); + if ( (eLookupError != 0) || (pWrapperTable->m_TriangleSet_Duplicate == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_object_gettype", (void**)&(pWrapperTable->m_Object_GetType)); if ( (eLookupError != 0) || (pWrapperTable->m_Object_GetType == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -10386,6 +10662,26 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) if ( (eLookupError != 0) || (pWrapperTable->m_MeshObject_SetVolumeData == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_meshobject_addtriangleset", (void**)&(pWrapperTable->m_MeshObject_AddTriangleSet)); + if ( (eLookupError != 0) || (pWrapperTable->m_MeshObject_AddTriangleSet == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_meshobject_hastriangleset", (void**)&(pWrapperTable->m_MeshObject_HasTriangleSet)); + if ( (eLookupError != 0) || (pWrapperTable->m_MeshObject_HasTriangleSet == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_meshobject_findtriangleset", (void**)&(pWrapperTable->m_MeshObject_FindTriangleSet)); + if ( (eLookupError != 0) || (pWrapperTable->m_MeshObject_FindTriangleSet == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_meshobject_gettrianglesetcount", (void**)&(pWrapperTable->m_MeshObject_GetTriangleSetCount)); + if ( (eLookupError != 0) || (pWrapperTable->m_MeshObject_GetTriangleSetCount == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("lib3mf_meshobject_gettriangleset", (void**)&(pWrapperTable->m_MeshObject_GetTriangleSet)); + if ( (eLookupError != 0) || (pWrapperTable->m_MeshObject_GetTriangleSet == nullptr) ) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("lib3mf_levelset_getfunction", (void**)&(pWrapperTable->m_LevelSet_GetFunction)); if ( (eLookupError != 0) || (pWrapperTable->m_LevelSet_GetFunction == nullptr) ) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -13281,6 +13577,152 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hMetaData))); } + /** + * Method definitions for class CTriangleSet + */ + + /** + * CTriangleSet::SetName - sets the name of the triangle set + * @param[in] sName - the new name + */ + void CTriangleSet::SetName(const std::string & sName) + { + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_SetName(m_pHandle, sName.c_str())); + } + + /** + * CTriangleSet::GetName - returns the name of the triangle set + * @return returns the name + */ + std::string CTriangleSet::GetName() + { + Lib3MF_uint32 bytesNeededName = 0; + Lib3MF_uint32 bytesWrittenName = 0; + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_GetName(m_pHandle, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_GetName(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CTriangleSet::SetIdentifier - sets the identifier of the triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + */ + void CTriangleSet::SetIdentifier(const std::string & sIdentifier) + { + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_SetIdentifier(m_pHandle, sIdentifier.c_str())); + } + + /** + * CTriangleSet::GetIdentifier - returns the identifier of the triangle set + * @return returns the identifier + */ + std::string CTriangleSet::GetIdentifier() + { + Lib3MF_uint32 bytesNeededIdentifier = 0; + Lib3MF_uint32 bytesWrittenIdentifier = 0; + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_GetIdentifier(m_pHandle, 0, &bytesNeededIdentifier, nullptr)); + std::vector bufferIdentifier(bytesNeededIdentifier); + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_GetIdentifier(m_pHandle, bytesNeededIdentifier, &bytesWrittenIdentifier, &bufferIdentifier[0])); + + return std::string(&bufferIdentifier[0]); + } + + /** + * CTriangleSet::AddTriangle - adds a triangle to the set. Does nothing if triangle is already in the set. + * @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::AddTriangle(const Lib3MF_uint32 nTriangleIndex) + { + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_AddTriangle(m_pHandle, nTriangleIndex)); + } + + /** + * CTriangleSet::RemoveTriangle - removes a triangle from the set + * @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) + { + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_RemoveTriangle(m_pHandle, nTriangleIndex)); + } + + /** + * CTriangleSet::Clear - clears all triangles from the list + */ + void CTriangleSet::Clear() + { + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_Clear(m_pHandle)); + } + + /** + * CTriangleSet::SetTriangleList - Sets all triangles in the list, while clearing old values. Duplicates will be merged. + * @param[in] TriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::SetTriangleList(const CInputVector & TriangleIndicesBuffer) + { + Lib3MF_uint64 nTriangleIndicesSize = TriangleIndicesBuffer.size(); + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_SetTriangleList(m_pHandle, nTriangleIndicesSize, TriangleIndicesBuffer.data())); + } + + /** + * CTriangleSet::GetTriangleList - Retrieves all the triangles in the TriangleSet + * @param[out] TriangleIndicesBuffer - retrieves the indices of the triangles in this TriangleSet + */ + void CTriangleSet::GetTriangleList(std::vector & TriangleIndicesBuffer) + { + Lib3MF_uint64 elementsNeededTriangleIndices = 0; + Lib3MF_uint64 elementsWrittenTriangleIndices = 0; + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_GetTriangleList(m_pHandle, 0, &elementsNeededTriangleIndices, nullptr)); + TriangleIndicesBuffer.resize((size_t) elementsNeededTriangleIndices); + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_GetTriangleList(m_pHandle, elementsNeededTriangleIndices, &elementsWrittenTriangleIndices, TriangleIndicesBuffer.data())); + } + + /** + * CTriangleSet::AddTriangleList - Adds multiple triangles in the list. Duplicates will be merged. + * @param[in] TriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + void CTriangleSet::AddTriangleList(const CInputVector & TriangleIndicesBuffer) + { + Lib3MF_uint64 nTriangleIndicesSize = TriangleIndicesBuffer.size(); + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_AddTriangleList(m_pHandle, nTriangleIndicesSize, TriangleIndicesBuffer.data())); + } + + /** + * CTriangleSet::Merge - Merges another Triangle set. + * @param[in] pOtherTriangleSet - Other triangle set to merge. + * @param[in] bDeleteOther - Flag if other triangle set is getting removed. + */ + void CTriangleSet::Merge(classParam pOtherTriangleSet, const bool bDeleteOther) + { + Lib3MFHandle hOtherTriangleSet = pOtherTriangleSet.GetHandle(); + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_Merge(m_pHandle, hOtherTriangleSet, bDeleteOther)); + } + + /** + * CTriangleSet::DeleteSet - Deletes the whole set from the mesh. + */ + void CTriangleSet::DeleteSet() + { + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_DeleteSet(m_pHandle)); + } + + /** + * CTriangleSet::Duplicate - Duplicates the set in the mesh. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @return Copy of the triangle set. + */ + PTriangleSet CTriangleSet::Duplicate(const std::string & sIdentifier) + { + Lib3MFHandle hNewSet = (Lib3MFHandle)nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_TriangleSet_Duplicate(m_pHandle, sIdentifier.c_str(), &hNewSet)); + + if (!hNewSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hNewSet))); + } + /** * Method definitions for class CObject */ @@ -13821,6 +14263,80 @@ inline CBase* CWrapper::polymorphicFactory(Lib3MFHandle pHandle) CheckError(m_pWrapper->m_WrapperTable.m_MeshObject_SetVolumeData(m_pHandle, hTheVolumeData)); } + /** + * CMeshObject::AddTriangleSet - Adds a new triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @param[in] sName - the human readable name. MUST NOT be an empty string + * @return the new Triangle Set Instance. + */ + PTriangleSet CMeshObject::AddTriangleSet(const std::string & sIdentifier, const std::string & sName) + { + Lib3MFHandle hTheTriangleSet = (Lib3MFHandle)nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_MeshObject_AddTriangleSet(m_pHandle, sIdentifier.c_str(), sName.c_str(), &hTheTriangleSet)); + + if (!hTheTriangleSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hTheTriangleSet))); + } + + /** + * CMeshObject::HasTriangleSet - Checks if a triangle set exists. + * @param[in] sIdentifier - the identifier to be found. + * @return flag if the triangles set exists. + */ + bool CMeshObject::HasTriangleSet(const std::string & sIdentifier) + { + bool resultTriangleSetExists = 0; + CheckError(m_pWrapper->m_WrapperTable.m_MeshObject_HasTriangleSet(m_pHandle, sIdentifier.c_str(), &resultTriangleSetExists)); + + return resultTriangleSetExists; + } + + /** + * CMeshObject::FindTriangleSet - Finds a new triangle set by identifier. Fails if not existing. + * @param[in] sIdentifier - the identifier to be found. + * @return the triangle Set Instance. + */ + PTriangleSet CMeshObject::FindTriangleSet(const std::string & sIdentifier) + { + Lib3MFHandle hTheTriangleSet = (Lib3MFHandle)nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_MeshObject_FindTriangleSet(m_pHandle, sIdentifier.c_str(), &hTheTriangleSet)); + + if (!hTheTriangleSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hTheTriangleSet))); + } + + /** + * CMeshObject::GetTriangleSetCount - Returns number of triangle sets. + * @return the number of triangle sets of this mesh. + */ + Lib3MF_uint32 CMeshObject::GetTriangleSetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(m_pWrapper->m_WrapperTable.m_MeshObject_GetTriangleSetCount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CMeshObject::GetTriangleSet - Returns a specific triangle set by index. + * @param[in] nIndex - the index of the triangle set. + * @return the triangle Set Instance. + */ + PTriangleSet CMeshObject::GetTriangleSet(const Lib3MF_uint32 nIndex) + { + Lib3MFHandle hTheTriangleSet = (Lib3MFHandle)nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_MeshObject_GetTriangleSet(m_pHandle, nIndex, &hTheTriangleSet)); + + if (!hTheTriangleSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::shared_ptr(dynamic_cast(m_pWrapper->polymorphicFactory(hTheTriangleSet))); + } + /** * Method definitions for class CLevelSet */ diff --git a/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp b/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp index 4ba959150..0d520b820 100644 --- a/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp +++ b/Autogenerated/Bindings/CppDynamic/lib3mf_types.hpp @@ -130,6 +130,8 @@ typedef void * Lib3MF_pvoid; #define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ #define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ #define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ #define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ #define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ #define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ @@ -186,6 +188,8 @@ inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -226,6 +230,7 @@ typedef Lib3MFHandle Lib3MF_FunctionIterator; typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; typedef Lib3MFHandle Lib3MF_LevelSet; diff --git a/Autogenerated/Bindings/Go/lib3mf.go b/Autogenerated/Bindings/Go/lib3mf.go index 5adcaee18..9fcab2a75 100644 --- a/Autogenerated/Bindings/Go/lib3mf.go +++ b/Autogenerated/Bindings/Go/lib3mf.go @@ -455,6 +455,8 @@ const LIB3MF_ERROR_UNKOWNPROGRESSIDENTIFIER = 140; const LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT = 141; const LIB3MF_ERROR_INVALIDRESOURCE = 142; const LIB3MF_ERROR_INVALIDLEVELSET = 143; +const LIB3MF_ERROR_COULDNOTFINDTRIANGLESET = 144; +const LIB3MF_ERROR_INVALIDTRIANGLESETINDEX = 145; const LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE = 2000; const LIB3MF_ERROR_INVALIDKEYSTORE = 3000; const LIB3MF_ERROR_INVALIDKEYSTORECONSUMER = 3001; @@ -553,6 +555,10 @@ func errorMessage(errorcode uint32) string { return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: + return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: + return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: @@ -1641,6 +1647,158 @@ func (inst MetaDataGroup) AddMetaData(nameSpace string, name string, value strin } +// TriangleSet represents a Lib3MF class. +type TriangleSet struct { + Base +} + +func (wrapper Wrapper) NewTriangleSet(r ref) TriangleSet { + return TriangleSet{wrapper.NewBase(r)} +} + +// SetName sets the name of the triangle set. +func (inst TriangleSet) SetName(name string) error { + ret := C.CCall_lib3mf_triangleset_setname(inst.wrapperRef.LibraryHandle, inst.Ref, (*C.char)(unsafe.Pointer(&[]byte(name)[0]))) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// GetName returns the name of the triangle set. +func (inst TriangleSet) GetName() (string, error) { + var neededforname C.uint32_t + var filledinname C.uint32_t + ret := C.CCall_lib3mf_triangleset_getname(inst.wrapperRef.LibraryHandle, inst.Ref, 0, &neededforname, nil) + if ret != 0 { + return "", makeError(uint32(ret)) + } + bufferSizename := neededforname + buffername := make([]byte, bufferSizename) + ret = C.CCall_lib3mf_triangleset_getname(inst.wrapperRef.LibraryHandle, inst.Ref, bufferSizename, &filledinname, (*C.char)(unsafe.Pointer(&buffername[0]))) + if ret != 0 { + return "", makeError(uint32(ret)) + } + return string(buffername[:(filledinname-1)]), nil +} + +// SetIdentifier sets the identifier of the triangle set. +func (inst TriangleSet) SetIdentifier(identifier string) error { + ret := C.CCall_lib3mf_triangleset_setidentifier(inst.wrapperRef.LibraryHandle, inst.Ref, (*C.char)(unsafe.Pointer(&[]byte(identifier)[0]))) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// GetIdentifier returns the identifier of the triangle set. +func (inst TriangleSet) GetIdentifier() (string, error) { + var neededforidentifier C.uint32_t + var filledinidentifier C.uint32_t + ret := C.CCall_lib3mf_triangleset_getidentifier(inst.wrapperRef.LibraryHandle, inst.Ref, 0, &neededforidentifier, nil) + if ret != 0 { + return "", makeError(uint32(ret)) + } + bufferSizeidentifier := neededforidentifier + bufferidentifier := make([]byte, bufferSizeidentifier) + ret = C.CCall_lib3mf_triangleset_getidentifier(inst.wrapperRef.LibraryHandle, inst.Ref, bufferSizeidentifier, &filledinidentifier, (*C.char)(unsafe.Pointer(&bufferidentifier[0]))) + if ret != 0 { + return "", makeError(uint32(ret)) + } + return string(bufferidentifier[:(filledinidentifier-1)]), nil +} + +// AddTriangle adds a triangle to the set. Does nothing if triangle is already in the set. +func (inst TriangleSet) AddTriangle(triangleIndex uint32) error { + ret := C.CCall_lib3mf_triangleset_addtriangle(inst.wrapperRef.LibraryHandle, inst.Ref, C.uint32_t(triangleIndex)) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// RemoveTriangle removes a triangle from the set. +func (inst TriangleSet) RemoveTriangle(triangleIndex uint32) error { + ret := C.CCall_lib3mf_triangleset_removetriangle(inst.wrapperRef.LibraryHandle, inst.Ref, C.uint32_t(triangleIndex)) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// Clear clears all triangles from the list. +func (inst TriangleSet) Clear() error { + ret := C.CCall_lib3mf_triangleset_clear(inst.wrapperRef.LibraryHandle, inst.Ref) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// SetTriangleList sets all triangles in the list, while clearing old values. Duplicates will be merged. +func (inst TriangleSet) SetTriangleList(triangleIndices []uint32) error { + ret := C.CCall_lib3mf_triangleset_settrianglelist(inst.wrapperRef.LibraryHandle, inst.Ref, C.uint64_t(len(triangleIndices)), (*C.uint32_t)(unsafe.Pointer(&triangleIndices[0]))) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// GetTriangleList retrieves all the triangles in the TriangleSet. +func (inst TriangleSet) GetTriangleList(triangleIndices []uint32) ([]uint32, error) { + var neededfortriangleIndices C.uint64_t + ret := C.CCall_lib3mf_triangleset_gettrianglelist(inst.wrapperRef.LibraryHandle, inst.Ref, 0, &neededfortriangleIndices, nil) + if ret != 0 { + return nil, makeError(uint32(ret)) + } + if len(triangleIndices) < int(neededfortriangleIndices) { + triangleIndices = append(triangleIndices, make([]uint32, int(neededfortriangleIndices)-len(triangleIndices))...) + } + ret = C.CCall_lib3mf_triangleset_gettrianglelist(inst.wrapperRef.LibraryHandle, inst.Ref, neededfortriangleIndices, nil, (*C.uint32_t)(unsafe.Pointer(&triangleIndices[0]))) + if ret != 0 { + return nil, makeError(uint32(ret)) + } + return triangleIndices[:int(neededfortriangleIndices)], nil +} + +// AddTriangleList adds multiple triangles in the list. Duplicates will be merged. +func (inst TriangleSet) AddTriangleList(triangleIndices []uint32) error { + ret := C.CCall_lib3mf_triangleset_addtrianglelist(inst.wrapperRef.LibraryHandle, inst.Ref, C.uint64_t(len(triangleIndices)), (*C.uint32_t)(unsafe.Pointer(&triangleIndices[0]))) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// Merge merges another Triangle set. +func (inst TriangleSet) Merge(otherTriangleSet TriangleSet, deleteOther bool) error { + ret := C.CCall_lib3mf_triangleset_merge(inst.wrapperRef.LibraryHandle, inst.Ref, otherTriangleSet.Ref, C.bool(deleteOther)) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// DeleteSet deletes the whole set from the mesh. +func (inst TriangleSet) DeleteSet() error { + ret := C.CCall_lib3mf_triangleset_deleteset(inst.wrapperRef.LibraryHandle, inst.Ref) + if ret != 0 { + return makeError(uint32(ret)) + } + return nil +} + +// Duplicate duplicates the set in the mesh. +func (inst TriangleSet) Duplicate(identifier string) (TriangleSet, error) { + var newSet ref + ret := C.CCall_lib3mf_triangleset_duplicate(inst.wrapperRef.LibraryHandle, inst.Ref, (*C.char)(unsafe.Pointer(&[]byte(identifier)[0])), &newSet) + if ret != 0 { + return TriangleSet{}, makeError(uint32(ret)) + } + return inst.wrapperRef.NewTriangleSet(newSet), nil +} + + // Object represents a Lib3MF class. type Object struct { Resource @@ -2148,6 +2306,56 @@ func (inst MeshObject) SetVolumeData(theVolumeData VolumeData) error { return nil } +// AddTriangleSet adds a new triangle set. +func (inst MeshObject) AddTriangleSet(identifier string, name string) (TriangleSet, error) { + var theTriangleSet ref + ret := C.CCall_lib3mf_meshobject_addtriangleset(inst.wrapperRef.LibraryHandle, inst.Ref, (*C.char)(unsafe.Pointer(&[]byte(identifier)[0])), (*C.char)(unsafe.Pointer(&[]byte(name)[0])), &theTriangleSet) + if ret != 0 { + return TriangleSet{}, makeError(uint32(ret)) + } + return inst.wrapperRef.NewTriangleSet(theTriangleSet), nil +} + +// HasTriangleSet checks if a triangle set exists. +func (inst MeshObject) HasTriangleSet(identifier string) (bool, error) { + var triangleSetExists C.bool + ret := C.CCall_lib3mf_meshobject_hastriangleset(inst.wrapperRef.LibraryHandle, inst.Ref, (*C.char)(unsafe.Pointer(&[]byte(identifier)[0])), &triangleSetExists) + if ret != 0 { + return false, makeError(uint32(ret)) + } + return bool(triangleSetExists), nil +} + +// FindTriangleSet finds a new triangle set by identifier. Fails if not existing. +func (inst MeshObject) FindTriangleSet(identifier string) (TriangleSet, error) { + var theTriangleSet ref + ret := C.CCall_lib3mf_meshobject_findtriangleset(inst.wrapperRef.LibraryHandle, inst.Ref, (*C.char)(unsafe.Pointer(&[]byte(identifier)[0])), &theTriangleSet) + if ret != 0 { + return TriangleSet{}, makeError(uint32(ret)) + } + return inst.wrapperRef.NewTriangleSet(theTriangleSet), nil +} + +// GetTriangleSetCount returns number of triangle sets. +func (inst MeshObject) GetTriangleSetCount() (uint32, error) { + var count C.uint32_t + ret := C.CCall_lib3mf_meshobject_gettrianglesetcount(inst.wrapperRef.LibraryHandle, inst.Ref, &count) + if ret != 0 { + return 0, makeError(uint32(ret)) + } + return uint32(count), nil +} + +// GetTriangleSet returns a specific triangle set by index. +func (inst MeshObject) GetTriangleSet(index uint32) (TriangleSet, error) { + var theTriangleSet ref + ret := C.CCall_lib3mf_meshobject_gettriangleset(inst.wrapperRef.LibraryHandle, inst.Ref, C.uint32_t(index), &theTriangleSet) + if ret != 0 { + return TriangleSet{}, makeError(uint32(ret)) + } + return inst.wrapperRef.NewTriangleSet(theTriangleSet), nil +} + // LevelSet represents a Lib3MF class. type LevelSet struct { diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.c b/Autogenerated/Bindings/Go/lib3mf_dynamic.c index 2e0735ec1..467e334d0 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.c +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.c @@ -116,6 +116,19 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_MetaDataGroup_RemoveMetaDataByIndex = NULL; pWrapperTable->m_MetaDataGroup_RemoveMetaData = NULL; pWrapperTable->m_MetaDataGroup_AddMetaData = NULL; + pWrapperTable->m_TriangleSet_SetName = NULL; + pWrapperTable->m_TriangleSet_GetName = NULL; + pWrapperTable->m_TriangleSet_SetIdentifier = NULL; + pWrapperTable->m_TriangleSet_GetIdentifier = NULL; + pWrapperTable->m_TriangleSet_AddTriangle = NULL; + pWrapperTable->m_TriangleSet_RemoveTriangle = NULL; + pWrapperTable->m_TriangleSet_Clear = NULL; + pWrapperTable->m_TriangleSet_SetTriangleList = NULL; + pWrapperTable->m_TriangleSet_GetTriangleList = NULL; + pWrapperTable->m_TriangleSet_AddTriangleList = NULL; + pWrapperTable->m_TriangleSet_Merge = NULL; + pWrapperTable->m_TriangleSet_DeleteSet = NULL; + pWrapperTable->m_TriangleSet_Duplicate = NULL; pWrapperTable->m_Object_GetType = NULL; pWrapperTable->m_Object_SetType = NULL; pWrapperTable->m_Object_GetName = NULL; @@ -161,6 +174,11 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_MeshObject_BeamLattice = NULL; pWrapperTable->m_MeshObject_GetVolumeData = NULL; pWrapperTable->m_MeshObject_SetVolumeData = NULL; + pWrapperTable->m_MeshObject_AddTriangleSet = NULL; + pWrapperTable->m_MeshObject_HasTriangleSet = NULL; + pWrapperTable->m_MeshObject_FindTriangleSet = NULL; + pWrapperTable->m_MeshObject_GetTriangleSetCount = NULL; + pWrapperTable->m_MeshObject_GetTriangleSet = NULL; pWrapperTable->m_LevelSet_GetFunction = NULL; pWrapperTable->m_LevelSet_SetFunction = NULL; pWrapperTable->m_LevelSet_GetTransform = NULL; @@ -1316,6 +1334,123 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_MetaDataGroup_AddMetaData == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_setname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetName == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_getname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetName == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_setidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetIdentifier == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_getidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetIdentifier == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_addtriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangle == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_removetriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_removetriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_RemoveTriangle == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_clear"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) dlsym(hLibrary, "lib3mf_triangleset_clear"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Clear == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_settrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_settrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_gettrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_gettrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_addtrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_merge"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) dlsym(hLibrary, "lib3mf_triangleset_merge"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Merge == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_deleteset"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) dlsym(hLibrary, "lib3mf_triangleset_deleteset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_DeleteSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_duplicate"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) dlsym(hLibrary, "lib3mf_triangleset_duplicate"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Duplicate == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Object_GetType = (PLib3MFObject_GetTypePtr) GetProcAddress(hLibrary, "lib3mf_object_gettype"); #else // _WIN32 @@ -1721,6 +1856,51 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_MeshObject_SetVolumeData == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_addtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_addtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_AddTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_hastriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_hastriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_HasTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_findtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_findtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_FindTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) dlsym(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSetCount == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_gettriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_LevelSet_GetFunction = (PLib3MFLevelSet_GetFunctionPtr) GetProcAddress(hLibrary, "lib3mf_levelset_getfunction"); #else // _WIN32 @@ -6769,6 +6949,123 @@ Lib3MFResult CCall_lib3mf_metadatagroup_addmetadata(Lib3MFHandle libraryHandle, } +Lib3MFResult CCall_lib3mf_triangleset_setname(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const char * pName) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_SetName (pTriangleSet, pName); +} + + +Lib3MFResult CCall_lib3mf_triangleset_getname(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_GetName (pTriangleSet, nNameBufferSize, pNameNeededChars, pNameBuffer); +} + + +Lib3MFResult CCall_lib3mf_triangleset_setidentifier(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_SetIdentifier (pTriangleSet, pIdentifier); +} + + +Lib3MFResult CCall_lib3mf_triangleset_getidentifier(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_GetIdentifier (pTriangleSet, nIdentifierBufferSize, pIdentifierNeededChars, pIdentifierBuffer); +} + + +Lib3MFResult CCall_lib3mf_triangleset_addtriangle(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_AddTriangle (pTriangleSet, nTriangleIndex); +} + + +Lib3MFResult CCall_lib3mf_triangleset_removetriangle(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_RemoveTriangle (pTriangleSet, nTriangleIndex); +} + + +Lib3MFResult CCall_lib3mf_triangleset_clear(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_Clear (pTriangleSet); +} + + +Lib3MFResult CCall_lib3mf_triangleset_settrianglelist(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_SetTriangleList (pTriangleSet, nTriangleIndicesBufferSize, pTriangleIndicesBuffer); +} + + +Lib3MFResult CCall_lib3mf_triangleset_gettrianglelist(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_GetTriangleList (pTriangleSet, nTriangleIndicesBufferSize, pTriangleIndicesNeededCount, pTriangleIndicesBuffer); +} + + +Lib3MFResult CCall_lib3mf_triangleset_addtrianglelist(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_AddTriangleList (pTriangleSet, nTriangleIndicesBufferSize, pTriangleIndicesBuffer); +} + + +Lib3MFResult CCall_lib3mf_triangleset_merge(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_Merge (pTriangleSet, pOtherTriangleSet, bDeleteOther); +} + + +Lib3MFResult CCall_lib3mf_triangleset_deleteset(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_DeleteSet (pTriangleSet); +} + + +Lib3MFResult CCall_lib3mf_triangleset_duplicate(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_TriangleSet_Duplicate (pTriangleSet, pIdentifier, pNewSet); +} + + Lib3MFResult CCall_lib3mf_object_gettype(Lib3MFHandle libraryHandle, Lib3MF_Object pObject, eLib3MFObjectType * pObjectType) { if (libraryHandle == 0) @@ -7174,6 +7471,51 @@ Lib3MFResult CCall_lib3mf_meshobject_setvolumedata(Lib3MFHandle libraryHandle, L } +Lib3MFResult CCall_lib3mf_meshobject_addtriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_MeshObject_AddTriangleSet (pMeshObject, pIdentifier, pName, pTheTriangleSet); +} + + +Lib3MFResult CCall_lib3mf_meshobject_hastriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_MeshObject_HasTriangleSet (pMeshObject, pIdentifier, pTriangleSetExists); +} + + +Lib3MFResult CCall_lib3mf_meshobject_findtriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_MeshObject_FindTriangleSet (pMeshObject, pIdentifier, pTheTriangleSet); +} + + +Lib3MFResult CCall_lib3mf_meshobject_gettrianglesetcount(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_MeshObject_GetTriangleSetCount (pMeshObject, pCount); +} + + +Lib3MFResult CCall_lib3mf_meshobject_gettriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet) +{ + if (libraryHandle == 0) + return LIB3MF_ERROR_INVALIDCAST; + sLib3MFDynamicWrapperTable * wrapperTable = (sLib3MFDynamicWrapperTable *) libraryHandle; + return wrapperTable->m_MeshObject_GetTriangleSet (pMeshObject, nIndex, pTheTriangleSet); +} + + Lib3MFResult CCall_lib3mf_levelset_getfunction(Lib3MFHandle libraryHandle, Lib3MF_LevelSet pLevelSet, Lib3MF_Function * pTheFunction) { if (libraryHandle == 0) diff --git a/Autogenerated/Bindings/Go/lib3mf_dynamic.h b/Autogenerated/Bindings/Go/lib3mf_dynamic.h index 4442a20a8..2e4356901 100644 --- a/Autogenerated/Bindings/Go/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/Go/lib3mf_dynamic.h @@ -780,6 +780,135 @@ typedef Lib3MFResult (*PLib3MFMetaDataGroup_RemoveMetaDataPtr) (Lib3MF_MetaDataG */ typedef Lib3MFResult (*PLib3MFMetaDataGroup_AddMetaDataPtr) (Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +/************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_RemoveTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_ClearPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_MergePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DeleteSetPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DuplicatePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -1219,6 +1348,56 @@ typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pM */ typedef Lib3MFResult (*PLib3MFMeshObject_SetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_AddTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_HasTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_FindTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetCountPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + /************************************************************************************************************************* Class definition for LevelSet **************************************************************************************************************************/ @@ -6512,6 +6691,19 @@ typedef struct { PLib3MFMetaDataGroup_RemoveMetaDataByIndexPtr m_MetaDataGroup_RemoveMetaDataByIndex; PLib3MFMetaDataGroup_RemoveMetaDataPtr m_MetaDataGroup_RemoveMetaData; PLib3MFMetaDataGroup_AddMetaDataPtr m_MetaDataGroup_AddMetaData; + PLib3MFTriangleSet_SetNamePtr m_TriangleSet_SetName; + PLib3MFTriangleSet_GetNamePtr m_TriangleSet_GetName; + PLib3MFTriangleSet_SetIdentifierPtr m_TriangleSet_SetIdentifier; + PLib3MFTriangleSet_GetIdentifierPtr m_TriangleSet_GetIdentifier; + PLib3MFTriangleSet_AddTrianglePtr m_TriangleSet_AddTriangle; + PLib3MFTriangleSet_RemoveTrianglePtr m_TriangleSet_RemoveTriangle; + PLib3MFTriangleSet_ClearPtr m_TriangleSet_Clear; + PLib3MFTriangleSet_SetTriangleListPtr m_TriangleSet_SetTriangleList; + PLib3MFTriangleSet_GetTriangleListPtr m_TriangleSet_GetTriangleList; + PLib3MFTriangleSet_AddTriangleListPtr m_TriangleSet_AddTriangleList; + PLib3MFTriangleSet_MergePtr m_TriangleSet_Merge; + PLib3MFTriangleSet_DeleteSetPtr m_TriangleSet_DeleteSet; + PLib3MFTriangleSet_DuplicatePtr m_TriangleSet_Duplicate; PLib3MFObject_GetTypePtr m_Object_GetType; PLib3MFObject_SetTypePtr m_Object_SetType; PLib3MFObject_GetNamePtr m_Object_GetName; @@ -6557,6 +6749,11 @@ typedef struct { PLib3MFMeshObject_BeamLatticePtr m_MeshObject_BeamLattice; PLib3MFMeshObject_GetVolumeDataPtr m_MeshObject_GetVolumeData; PLib3MFMeshObject_SetVolumeDataPtr m_MeshObject_SetVolumeData; + PLib3MFMeshObject_AddTriangleSetPtr m_MeshObject_AddTriangleSet; + PLib3MFMeshObject_HasTriangleSetPtr m_MeshObject_HasTriangleSet; + PLib3MFMeshObject_FindTriangleSetPtr m_MeshObject_FindTriangleSet; + PLib3MFMeshObject_GetTriangleSetCountPtr m_MeshObject_GetTriangleSetCount; + PLib3MFMeshObject_GetTriangleSetPtr m_MeshObject_GetTriangleSet; PLib3MFLevelSet_GetFunctionPtr m_LevelSet_GetFunction; PLib3MFLevelSet_SetFunctionPtr m_LevelSet_SetFunction; PLib3MFLevelSet_GetTransformPtr m_LevelSet_GetTransform; @@ -7265,6 +7462,45 @@ Lib3MFResult CCall_lib3mf_metadatagroup_removemetadata(Lib3MFHandle libraryHandl Lib3MFResult CCall_lib3mf_metadatagroup_addmetadata(Lib3MFHandle libraryHandle, Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +Lib3MFResult CCall_lib3mf_triangleset_setname(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const char * pName); + + +Lib3MFResult CCall_lib3mf_triangleset_getname(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + + +Lib3MFResult CCall_lib3mf_triangleset_setidentifier(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + + +Lib3MFResult CCall_lib3mf_triangleset_getidentifier(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + + +Lib3MFResult CCall_lib3mf_triangleset_addtriangle(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + + +Lib3MFResult CCall_lib3mf_triangleset_removetriangle(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + + +Lib3MFResult CCall_lib3mf_triangleset_clear(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet); + + +Lib3MFResult CCall_lib3mf_triangleset_settrianglelist(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + + +Lib3MFResult CCall_lib3mf_triangleset_gettrianglelist(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + + +Lib3MFResult CCall_lib3mf_triangleset_addtrianglelist(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + + +Lib3MFResult CCall_lib3mf_triangleset_merge(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + + +Lib3MFResult CCall_lib3mf_triangleset_deleteset(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet); + + +Lib3MFResult CCall_lib3mf_triangleset_duplicate(Lib3MFHandle libraryHandle, Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + + Lib3MFResult CCall_lib3mf_object_gettype(Lib3MFHandle libraryHandle, Lib3MF_Object pObject, eLib3MFObjectType * pObjectType); @@ -7400,6 +7636,21 @@ Lib3MFResult CCall_lib3mf_meshobject_getvolumedata(Lib3MFHandle libraryHandle, L Lib3MFResult CCall_lib3mf_meshobject_setvolumedata(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +Lib3MFResult CCall_lib3mf_meshobject_addtriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + + +Lib3MFResult CCall_lib3mf_meshobject_hastriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + + +Lib3MFResult CCall_lib3mf_meshobject_findtriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + + +Lib3MFResult CCall_lib3mf_meshobject_gettrianglesetcount(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + + +Lib3MFResult CCall_lib3mf_meshobject_gettriangleset(Lib3MFHandle libraryHandle, Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + + Lib3MFResult CCall_lib3mf_levelset_getfunction(Lib3MFHandle libraryHandle, Lib3MF_LevelSet pLevelSet, Lib3MF_Function * pTheFunction); diff --git a/Autogenerated/Bindings/Go/lib3mf_types.h b/Autogenerated/Bindings/Go/lib3mf_types.h index a5d436da0..241f77f87 100644 --- a/Autogenerated/Bindings/Go/lib3mf_types.h +++ b/Autogenerated/Bindings/Go/lib3mf_types.h @@ -131,6 +131,8 @@ typedef void * Lib3MF_pvoid; #define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ #define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ #define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ #define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ #define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ #define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ @@ -187,6 +189,8 @@ inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -227,6 +231,7 @@ typedef Lib3MFHandle Lib3MF_FunctionIterator; typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; typedef Lib3MFHandle Lib3MF_LevelSet; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc index e15559ef4..2bd0c4527 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.cc @@ -116,6 +116,19 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_MetaDataGroup_RemoveMetaDataByIndex = NULL; pWrapperTable->m_MetaDataGroup_RemoveMetaData = NULL; pWrapperTable->m_MetaDataGroup_AddMetaData = NULL; + pWrapperTable->m_TriangleSet_SetName = NULL; + pWrapperTable->m_TriangleSet_GetName = NULL; + pWrapperTable->m_TriangleSet_SetIdentifier = NULL; + pWrapperTable->m_TriangleSet_GetIdentifier = NULL; + pWrapperTable->m_TriangleSet_AddTriangle = NULL; + pWrapperTable->m_TriangleSet_RemoveTriangle = NULL; + pWrapperTable->m_TriangleSet_Clear = NULL; + pWrapperTable->m_TriangleSet_SetTriangleList = NULL; + pWrapperTable->m_TriangleSet_GetTriangleList = NULL; + pWrapperTable->m_TriangleSet_AddTriangleList = NULL; + pWrapperTable->m_TriangleSet_Merge = NULL; + pWrapperTable->m_TriangleSet_DeleteSet = NULL; + pWrapperTable->m_TriangleSet_Duplicate = NULL; pWrapperTable->m_Object_GetType = NULL; pWrapperTable->m_Object_SetType = NULL; pWrapperTable->m_Object_GetName = NULL; @@ -161,6 +174,11 @@ Lib3MFResult InitLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable) pWrapperTable->m_MeshObject_BeamLattice = NULL; pWrapperTable->m_MeshObject_GetVolumeData = NULL; pWrapperTable->m_MeshObject_SetVolumeData = NULL; + pWrapperTable->m_MeshObject_AddTriangleSet = NULL; + pWrapperTable->m_MeshObject_HasTriangleSet = NULL; + pWrapperTable->m_MeshObject_FindTriangleSet = NULL; + pWrapperTable->m_MeshObject_GetTriangleSetCount = NULL; + pWrapperTable->m_MeshObject_GetTriangleSet = NULL; pWrapperTable->m_LevelSet_GetFunction = NULL; pWrapperTable->m_LevelSet_SetFunction = NULL; pWrapperTable->m_LevelSet_GetTransform = NULL; @@ -1316,6 +1334,123 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_MetaDataGroup_AddMetaData == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetName = (PLib3MFTriangleSet_SetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_setname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetName == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getname"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetName = (PLib3MFTriangleSet_GetNamePtr) dlsym(hLibrary, "lib3mf_triangleset_getname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetName == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_setidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetIdentifier = (PLib3MFTriangleSet_SetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_setidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetIdentifier == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_getidentifier"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetIdentifier = (PLib3MFTriangleSet_GetIdentifierPtr) dlsym(hLibrary, "lib3mf_triangleset_getidentifier"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetIdentifier == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangle = (PLib3MFTriangleSet_AddTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_addtriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangle == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_removetriangle"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_RemoveTriangle = (PLib3MFTriangleSet_RemoveTrianglePtr) dlsym(hLibrary, "lib3mf_triangleset_removetriangle"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_RemoveTriangle == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_clear"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Clear = (PLib3MFTriangleSet_ClearPtr) dlsym(hLibrary, "lib3mf_triangleset_clear"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Clear == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_settrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_SetTriangleList = (PLib3MFTriangleSet_SetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_settrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_SetTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_gettrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_GetTriangleList = (PLib3MFTriangleSet_GetTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_gettrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_GetTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_addtrianglelist"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_AddTriangleList = (PLib3MFTriangleSet_AddTriangleListPtr) dlsym(hLibrary, "lib3mf_triangleset_addtrianglelist"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_AddTriangleList == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_merge"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Merge = (PLib3MFTriangleSet_MergePtr) dlsym(hLibrary, "lib3mf_triangleset_merge"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Merge == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) GetProcAddress(hLibrary, "lib3mf_triangleset_deleteset"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_DeleteSet = (PLib3MFTriangleSet_DeleteSetPtr) dlsym(hLibrary, "lib3mf_triangleset_deleteset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_DeleteSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) GetProcAddress(hLibrary, "lib3mf_triangleset_duplicate"); + #else // _WIN32 + pWrapperTable->m_TriangleSet_Duplicate = (PLib3MFTriangleSet_DuplicatePtr) dlsym(hLibrary, "lib3mf_triangleset_duplicate"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_TriangleSet_Duplicate == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Object_GetType = (PLib3MFObject_GetTypePtr) GetProcAddress(hLibrary, "lib3mf_object_gettype"); #else // _WIN32 @@ -1721,6 +1856,51 @@ Lib3MFResult LoadLib3MFWrapperTable(sLib3MFDynamicWrapperTable * pWrapperTable, if (pWrapperTable->m_MeshObject_SetVolumeData == NULL) return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_addtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_AddTriangleSet = (PLib3MFMeshObject_AddTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_addtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_AddTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_hastriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_HasTriangleSet = (PLib3MFMeshObject_HasTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_hastriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_HasTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_findtriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_FindTriangleSet = (PLib3MFMeshObject_FindTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_findtriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_FindTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSetCount = (PLib3MFMeshObject_GetTriangleSetCountPtr) dlsym(hLibrary, "lib3mf_meshobject_gettrianglesetcount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSetCount == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) GetProcAddress(hLibrary, "lib3mf_meshobject_gettriangleset"); + #else // _WIN32 + pWrapperTable->m_MeshObject_GetTriangleSet = (PLib3MFMeshObject_GetTriangleSetPtr) dlsym(hLibrary, "lib3mf_meshobject_gettriangleset"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_MeshObject_GetTriangleSet == NULL) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_LevelSet_GetFunction = (PLib3MFLevelSet_GetFunctionPtr) GetProcAddress(hLibrary, "lib3mf_levelset_getfunction"); #else // _WIN32 diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h index 0211b290f..972d36377 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_dynamic.h @@ -780,6 +780,135 @@ typedef Lib3MFResult (*PLib3MFMetaDataGroup_RemoveMetaDataPtr) (Lib3MF_MetaDataG */ typedef Lib3MFResult (*PLib3MFMetaDataGroup_AddMetaDataPtr) (Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +/************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetNamePtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetIdentifierPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_RemoveTrianglePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_ClearPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_SetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_GetTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_AddTriangleListPtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_MergePtr) (Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DeleteSetPtr) (Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFTriangleSet_DuplicatePtr) (Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -1219,6 +1348,56 @@ typedef Lib3MFResult (*PLib3MFMeshObject_GetVolumeDataPtr) (Lib3MF_MeshObject pM */ typedef Lib3MFResult (*PLib3MFMeshObject_SetVolumeDataPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_AddTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_HasTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_FindTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetCountPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +typedef Lib3MFResult (*PLib3MFMeshObject_GetTriangleSetPtr) (Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + /************************************************************************************************************************* Class definition for LevelSet **************************************************************************************************************************/ @@ -6512,6 +6691,19 @@ typedef struct { PLib3MFMetaDataGroup_RemoveMetaDataByIndexPtr m_MetaDataGroup_RemoveMetaDataByIndex; PLib3MFMetaDataGroup_RemoveMetaDataPtr m_MetaDataGroup_RemoveMetaData; PLib3MFMetaDataGroup_AddMetaDataPtr m_MetaDataGroup_AddMetaData; + PLib3MFTriangleSet_SetNamePtr m_TriangleSet_SetName; + PLib3MFTriangleSet_GetNamePtr m_TriangleSet_GetName; + PLib3MFTriangleSet_SetIdentifierPtr m_TriangleSet_SetIdentifier; + PLib3MFTriangleSet_GetIdentifierPtr m_TriangleSet_GetIdentifier; + PLib3MFTriangleSet_AddTrianglePtr m_TriangleSet_AddTriangle; + PLib3MFTriangleSet_RemoveTrianglePtr m_TriangleSet_RemoveTriangle; + PLib3MFTriangleSet_ClearPtr m_TriangleSet_Clear; + PLib3MFTriangleSet_SetTriangleListPtr m_TriangleSet_SetTriangleList; + PLib3MFTriangleSet_GetTriangleListPtr m_TriangleSet_GetTriangleList; + PLib3MFTriangleSet_AddTriangleListPtr m_TriangleSet_AddTriangleList; + PLib3MFTriangleSet_MergePtr m_TriangleSet_Merge; + PLib3MFTriangleSet_DeleteSetPtr m_TriangleSet_DeleteSet; + PLib3MFTriangleSet_DuplicatePtr m_TriangleSet_Duplicate; PLib3MFObject_GetTypePtr m_Object_GetType; PLib3MFObject_SetTypePtr m_Object_SetType; PLib3MFObject_GetNamePtr m_Object_GetName; @@ -6557,6 +6749,11 @@ typedef struct { PLib3MFMeshObject_BeamLatticePtr m_MeshObject_BeamLattice; PLib3MFMeshObject_GetVolumeDataPtr m_MeshObject_GetVolumeData; PLib3MFMeshObject_SetVolumeDataPtr m_MeshObject_SetVolumeData; + PLib3MFMeshObject_AddTriangleSetPtr m_MeshObject_AddTriangleSet; + PLib3MFMeshObject_HasTriangleSetPtr m_MeshObject_HasTriangleSet; + PLib3MFMeshObject_FindTriangleSetPtr m_MeshObject_FindTriangleSet; + PLib3MFMeshObject_GetTriangleSetCountPtr m_MeshObject_GetTriangleSetCount; + PLib3MFMeshObject_GetTriangleSetPtr m_MeshObject_GetTriangleSet; PLib3MFLevelSet_GetFunctionPtr m_LevelSet_GetFunction; PLib3MFLevelSet_SetFunctionPtr m_LevelSet_SetFunction; PLib3MFLevelSet_GetTransformPtr m_LevelSet_GetTransform; diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc b/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc index 5e403cfd6..7ebb5ffb0 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodeaddon.cc @@ -69,6 +69,7 @@ void InitAll(v8::Local exports, v8::Local module) CLib3MFLevelSetIterator::Init(); CLib3MFMetaData::Init(); CLib3MFMetaDataGroup::Init(); + CLib3MFTriangleSet::Init(); CLib3MFObject::Init(); CLib3MFMeshObject::Init(); CLib3MFLevelSet::Init(); diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc index 1914e2c29..6d5c5f0d6 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.cc @@ -62,6 +62,7 @@ Persistent CLib3MFFunctionIterator::constructor; Persistent CLib3MFLevelSetIterator::constructor; Persistent CLib3MFMetaData::constructor; Persistent CLib3MFMetaDataGroup::constructor; +Persistent CLib3MFTriangleSet::constructor; Persistent CLib3MFObject::constructor; Persistent CLib3MFMeshObject::constructor; Persistent CLib3MFLevelSet::constructor; @@ -4307,6 +4308,386 @@ void CLib3MFMetaDataGroup::AddMetaData(const FunctionCallbackInfo& args) } } +/************************************************************************************************************************* + Class CLib3MFTriangleSet Implementation +**************************************************************************************************************************/ + +CLib3MFTriangleSet::CLib3MFTriangleSet() + : CLib3MFBaseClass() +{ +} + +CLib3MFTriangleSet::~CLib3MFTriangleSet() +{ +} + +void CLib3MFTriangleSet::Init() +{ + Isolate* isolate = Isolate::GetCurrent(); + + // Prepare constructor template + Local tpl = FunctionTemplate::New(isolate, New); + tpl->SetClassName(String::NewFromUtf8(isolate, "Lib3MFTriangleSet")); + tpl->InstanceTemplate()->SetInternalFieldCount(NODEWRAPPER_FIELDCOUNT); + + // Prototype + NODE_SET_PROTOTYPE_METHOD(tpl, "SetName", SetName); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetName", GetName); + NODE_SET_PROTOTYPE_METHOD(tpl, "SetIdentifier", SetIdentifier); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetIdentifier", GetIdentifier); + NODE_SET_PROTOTYPE_METHOD(tpl, "AddTriangle", AddTriangle); + NODE_SET_PROTOTYPE_METHOD(tpl, "RemoveTriangle", RemoveTriangle); + NODE_SET_PROTOTYPE_METHOD(tpl, "Clear", Clear); + NODE_SET_PROTOTYPE_METHOD(tpl, "SetTriangleList", SetTriangleList); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetTriangleList", GetTriangleList); + NODE_SET_PROTOTYPE_METHOD(tpl, "AddTriangleList", AddTriangleList); + NODE_SET_PROTOTYPE_METHOD(tpl, "Merge", Merge); + NODE_SET_PROTOTYPE_METHOD(tpl, "DeleteSet", DeleteSet); + NODE_SET_PROTOTYPE_METHOD(tpl, "Duplicate", Duplicate); + constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); + +} + +void CLib3MFTriangleSet::New(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + + if (args.IsConstructCall()) { + CLib3MFBaseClass * holderObj = ObjectWrap::Unwrap(args.Holder()); + CLib3MFTriangleSet * trianglesetInstance = new CLib3MFTriangleSet(); + trianglesetInstance->Wrap(args.This()); + args.GetReturnValue().Set(args.This()); + } else { + RaiseError(isolate, "Lib3MFTriangleSet: Invalid call to Constructor"); + } +} + +Local CLib3MFTriangleSet::NewInstance(Local pParent, Lib3MFHandle pHandle) +{ + Isolate* isolate = Isolate::GetCurrent(); + HandleScope scope(isolate); + Local cons = Local::New(isolate, constructor); + Local instance; + if (cons->NewInstance(isolate->GetCurrentContext()).ToLocal(&instance)) { + instance->SetInternalField(NODEWRAPPER_TABLEINDEX, External::New(isolate, CLib3MFBaseClass::getDynamicWrapperTable(pParent))); + instance->SetInternalField(NODEWRAPPER_HANDLEINDEX, External::New(isolate, pHandle)); + } + return instance; +} + + +void CLib3MFTriangleSet::SetName(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsString()) { + throw std::runtime_error("Expected string parameter 0 (Name)"); + } + v8::String::Utf8Value sutf8Name(isolate, args[0]); + std::string sName = *sutf8Name; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method SetName."); + if (wrapperTable->m_TriangleSet_SetName == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::SetName."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_SetName(instanceHandle, sName.c_str()); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::GetName(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + unsigned int bytesNeededName = 0; + unsigned int bytesWrittenName = 0; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetName."); + if (wrapperTable->m_TriangleSet_GetName == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::GetName."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult initErrorCode = wrapperTable->m_TriangleSet_GetName(instanceHandle, 0, &bytesNeededName, nullptr); + CheckError(isolate, wrapperTable, instanceHandle, initErrorCode); + std::vector bufferName; + bufferName.resize(bytesNeededName); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_GetName(instanceHandle, bytesNeededName, &bytesWrittenName, &bufferName[0]); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(String::NewFromUtf8(isolate, &bufferName[0])); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::SetIdentifier(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsString()) { + throw std::runtime_error("Expected string parameter 0 (Identifier)"); + } + v8::String::Utf8Value sutf8Identifier(isolate, args[0]); + std::string sIdentifier = *sutf8Identifier; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method SetIdentifier."); + if (wrapperTable->m_TriangleSet_SetIdentifier == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::SetIdentifier."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_SetIdentifier(instanceHandle, sIdentifier.c_str()); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::GetIdentifier(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + unsigned int bytesNeededIdentifier = 0; + unsigned int bytesWrittenIdentifier = 0; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetIdentifier."); + if (wrapperTable->m_TriangleSet_GetIdentifier == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::GetIdentifier."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult initErrorCode = wrapperTable->m_TriangleSet_GetIdentifier(instanceHandle, 0, &bytesNeededIdentifier, nullptr); + CheckError(isolate, wrapperTable, instanceHandle, initErrorCode); + std::vector bufferIdentifier; + bufferIdentifier.resize(bytesNeededIdentifier); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_GetIdentifier(instanceHandle, bytesNeededIdentifier, &bytesWrittenIdentifier, &bufferIdentifier[0]); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(String::NewFromUtf8(isolate, &bufferIdentifier[0])); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::AddTriangle(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsUint32()) { + throw std::runtime_error("Expected uint32 parameter 0 (TriangleIndex)"); + } + unsigned int nTriangleIndex = (unsigned int) args[0]->IntegerValue(isolate->GetCurrentContext()).ToChecked(); + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method AddTriangle."); + if (wrapperTable->m_TriangleSet_AddTriangle == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::AddTriangle."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_AddTriangle(instanceHandle, nTriangleIndex); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::RemoveTriangle(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsUint32()) { + throw std::runtime_error("Expected uint32 parameter 0 (TriangleIndex)"); + } + unsigned int nTriangleIndex = (unsigned int) args[0]->IntegerValue(isolate->GetCurrentContext()).ToChecked(); + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method RemoveTriangle."); + if (wrapperTable->m_TriangleSet_RemoveTriangle == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::RemoveTriangle."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_RemoveTriangle(instanceHandle, nTriangleIndex); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::Clear(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method Clear."); + if (wrapperTable->m_TriangleSet_Clear == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::Clear."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_Clear(instanceHandle); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::SetTriangleList(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method SetTriangleList."); + if (wrapperTable->m_TriangleSet_SetTriangleList == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::SetTriangleList."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_SetTriangleList(instanceHandle, 0, nullptr); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::GetTriangleList(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetTriangleList."); + if (wrapperTable->m_TriangleSet_GetTriangleList == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::GetTriangleList."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_GetTriangleList(instanceHandle, 0, nullptr, nullptr); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::AddTriangleList(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method AddTriangleList."); + if (wrapperTable->m_TriangleSet_AddTriangleList == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::AddTriangleList."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_AddTriangleList(instanceHandle, 0, nullptr); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::Merge(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsObject()) { + throw std::runtime_error("Expected class parameter 0 (OtherTriangleSet)"); + } + if (!args[1]->IsBoolean()) { + throw std::runtime_error("Expected bool parameter 1 (DeleteOther)"); + } + Local objOtherTriangleSet = args[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); + CLib3MFTriangleSet * instanceOtherTriangleSet = ObjectWrap::Unwrap(objOtherTriangleSet); + if (instanceOtherTriangleSet == nullptr) + throw std::runtime_error("Invalid Object parameter 0 (OtherTriangleSet)"); + Lib3MFHandle hOtherTriangleSet = instanceOtherTriangleSet->getHandle( objOtherTriangleSet ); + bool bDeleteOther = args[1]->BooleanValue(isolate->GetCurrentContext()).ToChecked(); + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method Merge."); + if (wrapperTable->m_TriangleSet_Merge == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::Merge."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_Merge(instanceHandle, hOtherTriangleSet, bDeleteOther); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::DeleteSet(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method DeleteSet."); + if (wrapperTable->m_TriangleSet_DeleteSet == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::DeleteSet."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_DeleteSet(instanceHandle); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFTriangleSet::Duplicate(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsString()) { + throw std::runtime_error("Expected string parameter 0 (Identifier)"); + } + v8::String::Utf8Value sutf8Identifier(isolate, args[0]); + std::string sIdentifier = *sutf8Identifier; + Lib3MFHandle hReturnNewSet = nullptr; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method Duplicate."); + if (wrapperTable->m_TriangleSet_Duplicate == nullptr) + throw std::runtime_error("Could not call Lib3MF method TriangleSet::Duplicate."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_TriangleSet_Duplicate(instanceHandle, sIdentifier.c_str(), &hReturnNewSet); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + Local instanceObjNewSet = CLib3MFTriangleSet::NewInstance(args.Holder(), hReturnNewSet); + args.GetReturnValue().Set(instanceObjNewSet); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + /************************************************************************************************************************* Class CLib3MFObject Implementation **************************************************************************************************************************/ @@ -4983,6 +5364,11 @@ void CLib3MFMeshObject::Init() NODE_SET_PROTOTYPE_METHOD(tpl, "BeamLattice", BeamLattice); NODE_SET_PROTOTYPE_METHOD(tpl, "GetVolumeData", GetVolumeData); NODE_SET_PROTOTYPE_METHOD(tpl, "SetVolumeData", SetVolumeData); + NODE_SET_PROTOTYPE_METHOD(tpl, "AddTriangleSet", AddTriangleSet); + NODE_SET_PROTOTYPE_METHOD(tpl, "HasTriangleSet", HasTriangleSet); + NODE_SET_PROTOTYPE_METHOD(tpl, "FindTriangleSet", FindTriangleSet); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetTriangleSetCount", GetTriangleSetCount); + NODE_SET_PROTOTYPE_METHOD(tpl, "GetTriangleSet", GetTriangleSet); constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); } @@ -5545,6 +5931,143 @@ void CLib3MFMeshObject::SetVolumeData(const FunctionCallbackInfo& args) } } + +void CLib3MFMeshObject::AddTriangleSet(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsString()) { + throw std::runtime_error("Expected string parameter 0 (Identifier)"); + } + if (!args[1]->IsString()) { + throw std::runtime_error("Expected string parameter 1 (Name)"); + } + v8::String::Utf8Value sutf8Identifier(isolate, args[0]); + std::string sIdentifier = *sutf8Identifier; + v8::String::Utf8Value sutf8Name(isolate, args[1]); + std::string sName = *sutf8Name; + Lib3MFHandle hReturnTheTriangleSet = nullptr; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method AddTriangleSet."); + if (wrapperTable->m_MeshObject_AddTriangleSet == nullptr) + throw std::runtime_error("Could not call Lib3MF method MeshObject::AddTriangleSet."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_MeshObject_AddTriangleSet(instanceHandle, sIdentifier.c_str(), sName.c_str(), &hReturnTheTriangleSet); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + Local instanceObjTheTriangleSet = CLib3MFTriangleSet::NewInstance(args.Holder(), hReturnTheTriangleSet); + args.GetReturnValue().Set(instanceObjTheTriangleSet); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFMeshObject::HasTriangleSet(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsString()) { + throw std::runtime_error("Expected string parameter 0 (Identifier)"); + } + v8::String::Utf8Value sutf8Identifier(isolate, args[0]); + std::string sIdentifier = *sutf8Identifier; + bool bReturnTriangleSetExists = false; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method HasTriangleSet."); + if (wrapperTable->m_MeshObject_HasTriangleSet == nullptr) + throw std::runtime_error("Could not call Lib3MF method MeshObject::HasTriangleSet."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_MeshObject_HasTriangleSet(instanceHandle, sIdentifier.c_str(), &bReturnTriangleSetExists); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(Boolean::New(isolate, bReturnTriangleSetExists)); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFMeshObject::FindTriangleSet(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsString()) { + throw std::runtime_error("Expected string parameter 0 (Identifier)"); + } + v8::String::Utf8Value sutf8Identifier(isolate, args[0]); + std::string sIdentifier = *sutf8Identifier; + Lib3MFHandle hReturnTheTriangleSet = nullptr; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method FindTriangleSet."); + if (wrapperTable->m_MeshObject_FindTriangleSet == nullptr) + throw std::runtime_error("Could not call Lib3MF method MeshObject::FindTriangleSet."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_MeshObject_FindTriangleSet(instanceHandle, sIdentifier.c_str(), &hReturnTheTriangleSet); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + Local instanceObjTheTriangleSet = CLib3MFTriangleSet::NewInstance(args.Holder(), hReturnTheTriangleSet); + args.GetReturnValue().Set(instanceObjTheTriangleSet); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFMeshObject::GetTriangleSetCount(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + unsigned int nReturnCount = 0; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetTriangleSetCount."); + if (wrapperTable->m_MeshObject_GetTriangleSetCount == nullptr) + throw std::runtime_error("Could not call Lib3MF method MeshObject::GetTriangleSetCount."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_MeshObject_GetTriangleSetCount(instanceHandle, &nReturnCount); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + args.GetReturnValue().Set(Integer::NewFromUnsigned(isolate, nReturnCount)); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + + +void CLib3MFMeshObject::GetTriangleSet(const FunctionCallbackInfo& args) +{ + Isolate* isolate = args.GetIsolate(); + HandleScope scope(isolate); + try { + if (!args[0]->IsUint32()) { + throw std::runtime_error("Expected uint32 parameter 0 (Index)"); + } + unsigned int nIndex = (unsigned int) args[0]->IntegerValue(isolate->GetCurrentContext()).ToChecked(); + Lib3MFHandle hReturnTheTriangleSet = nullptr; + sLib3MFDynamicWrapperTable * wrapperTable = CLib3MFBaseClass::getDynamicWrapperTable(args.Holder()); + if (wrapperTable == nullptr) + throw std::runtime_error("Could not get wrapper table for Lib3MF method GetTriangleSet."); + if (wrapperTable->m_MeshObject_GetTriangleSet == nullptr) + throw std::runtime_error("Could not call Lib3MF method MeshObject::GetTriangleSet."); + Lib3MFHandle instanceHandle = CLib3MFBaseClass::getHandle(args.Holder()); + Lib3MFResult errorCode = wrapperTable->m_MeshObject_GetTriangleSet(instanceHandle, nIndex, &hReturnTheTriangleSet); + CheckError(isolate, wrapperTable, instanceHandle, errorCode); + Local instanceObjTheTriangleSet = CLib3MFTriangleSet::NewInstance(args.Holder(), hReturnTheTriangleSet); + args.GetReturnValue().Set(instanceObjTheTriangleSet); + + } catch (std::exception & E) { + RaiseError(isolate, E.what()); + } +} + /************************************************************************************************************************* Class CLib3MFLevelSet Implementation **************************************************************************************************************************/ diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h index abc0e0a7f..7de14221e 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_nodewrapper.h @@ -494,6 +494,36 @@ class CLib3MFMetaDataGroup : public CLib3MFBaseClass { }; +/************************************************************************************************************************* + Class CLib3MFTriangleSet +**************************************************************************************************************************/ +class CLib3MFTriangleSet : public CLib3MFBaseClass { +private: + static void New(const v8::FunctionCallbackInfo& args); + static v8::Persistent constructor; + static void SetName(const v8::FunctionCallbackInfo& args); + static void GetName(const v8::FunctionCallbackInfo& args); + static void SetIdentifier(const v8::FunctionCallbackInfo& args); + static void GetIdentifier(const v8::FunctionCallbackInfo& args); + static void AddTriangle(const v8::FunctionCallbackInfo& args); + static void RemoveTriangle(const v8::FunctionCallbackInfo& args); + static void Clear(const v8::FunctionCallbackInfo& args); + static void SetTriangleList(const v8::FunctionCallbackInfo& args); + static void GetTriangleList(const v8::FunctionCallbackInfo& args); + static void AddTriangleList(const v8::FunctionCallbackInfo& args); + static void Merge(const v8::FunctionCallbackInfo& args); + static void DeleteSet(const v8::FunctionCallbackInfo& args); + static void Duplicate(const v8::FunctionCallbackInfo& args); + +public: + CLib3MFTriangleSet(); + ~CLib3MFTriangleSet(); + + static void Init(); + static v8::Local NewInstance(v8::Local, Lib3MFHandle pHandle); + +}; + /************************************************************************************************************************* Class CLib3MFObject **************************************************************************************************************************/ @@ -563,6 +593,11 @@ class CLib3MFMeshObject : public CLib3MFBaseClass { static void BeamLattice(const v8::FunctionCallbackInfo& args); static void GetVolumeData(const v8::FunctionCallbackInfo& args); static void SetVolumeData(const v8::FunctionCallbackInfo& args); + static void AddTriangleSet(const v8::FunctionCallbackInfo& args); + static void HasTriangleSet(const v8::FunctionCallbackInfo& args); + static void FindTriangleSet(const v8::FunctionCallbackInfo& args); + static void GetTriangleSetCount(const v8::FunctionCallbackInfo& args); + static void GetTriangleSet(const v8::FunctionCallbackInfo& args); public: CLib3MFMeshObject(); diff --git a/Autogenerated/Bindings/NodeJS/lib3mf_types.h b/Autogenerated/Bindings/NodeJS/lib3mf_types.h index a5d436da0..241f77f87 100644 --- a/Autogenerated/Bindings/NodeJS/lib3mf_types.h +++ b/Autogenerated/Bindings/NodeJS/lib3mf_types.h @@ -131,6 +131,8 @@ typedef void * Lib3MF_pvoid; #define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ #define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ #define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ #define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ #define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ #define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ @@ -187,6 +189,8 @@ inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -227,6 +231,7 @@ typedef Lib3MFHandle Lib3MF_FunctionIterator; typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; typedef Lib3MFHandle Lib3MF_LevelSet; diff --git a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas index 98b5dd223..ada6145ba 100644 --- a/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas +++ b/Autogenerated/Bindings/Pascal/Unit_Lib3MF.pas @@ -114,6 +114,8 @@ interface LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT = 141; LIB3MF_ERROR_INVALIDRESOURCE = 142; LIB3MF_ERROR_INVALIDLEVELSET = 143; + LIB3MF_ERROR_COULDNOTFINDTRIANGLESET = 144; + LIB3MF_ERROR_INVALIDTRIANGLESETINDEX = 145; LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE = 2000; LIB3MF_ERROR_INVALIDKEYSTORE = 3000; LIB3MF_ERROR_INVALIDKEYSTORECONSUMER = 3001; @@ -494,6 +496,7 @@ TLib3MFFunctionIterator = class; TLib3MFLevelSetIterator = class; TLib3MFMetaData = class; TLib3MFMetaDataGroup = class; + TLib3MFTriangleSet = class; TLib3MFObject = class; TLib3MFMeshObject = class; TLib3MFLevelSet = class; @@ -1351,6 +1354,136 @@ TLib3MFModel = class; TLib3MFMetaDataGroup_AddMetaDataFunc = function(pMetaDataGroup: TLib3MFHandle; const pNameSpace: PAnsiChar; const pName: PAnsiChar; const pValue: PAnsiChar; const pType: PAnsiChar; const bMustPreserve: Byte; out pMetaData: TLib3MFHandle): TLib3MFResult; cdecl; +(************************************************************************************************************************* + Function type definitions for TriangleSet +**************************************************************************************************************************) + + (** + * sets the name of the triangle set + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] pName - the new name + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_SetNameFunc = function(pTriangleSet: TLib3MFHandle; const pName: PAnsiChar): TLib3MFResult; cdecl; + + (** + * returns the name of the triangle set + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] nNameBufferSize - size of the buffer (including trailing 0) + * @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. + * @param[out] pNameBuffer - buffer of returns the name, may be NULL + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_GetNameFunc = function(pTriangleSet: TLib3MFHandle; const nNameBufferSize: Cardinal; out pNameNeededChars: Cardinal; pNameBuffer: PAnsiChar): TLib3MFResult; cdecl; + + (** + * sets the identifier of the triangle set. + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_SetIdentifierFunc = function(pTriangleSet: TLib3MFHandle; const pIdentifier: PAnsiChar): TLib3MFResult; cdecl; + + (** + * returns the identifier of the triangle set + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) + * @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. + * @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_GetIdentifierFunc = function(pTriangleSet: TLib3MFHandle; const nIdentifierBufferSize: Cardinal; out pIdentifierNeededChars: Cardinal; pIdentifierBuffer: PAnsiChar): TLib3MFResult; cdecl; + + (** + * adds a triangle to the set. Does nothing if triangle is already in the set. + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_AddTriangleFunc = function(pTriangleSet: TLib3MFHandle; const nTriangleIndex: Cardinal): TLib3MFResult; cdecl; + + (** + * removes a triangle from the set + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_RemoveTriangleFunc = function(pTriangleSet: TLib3MFHandle; const nTriangleIndex: Cardinal): TLib3MFResult; cdecl; + + (** + * clears all triangles from the list + * + * @param[in] pTriangleSet - TriangleSet instance. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_ClearFunc = function(pTriangleSet: TLib3MFHandle): TLib3MFResult; cdecl; + + (** + * Sets all triangles in the list, while clearing old values. Duplicates will be merged. + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] nTriangleIndicesCount - Number of elements in buffer + * @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_SetTriangleListFunc = function(pTriangleSet: TLib3MFHandle; const nTriangleIndicesCount: QWord; const pTriangleIndicesBuffer: PCardinal): TLib3MFResult; cdecl; + + (** + * Retrieves all the triangles in the TriangleSet + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] nTriangleIndicesCount - Number of elements in buffer + * @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. + * @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_GetTriangleListFunc = function(pTriangleSet: TLib3MFHandle; const nTriangleIndicesCount: QWord; out pTriangleIndicesNeededCount: QWord; pTriangleIndicesBuffer: PCardinal): TLib3MFResult; cdecl; + + (** + * Adds multiple triangles in the list. Duplicates will be merged. + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] nTriangleIndicesCount - Number of elements in buffer + * @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_AddTriangleListFunc = function(pTriangleSet: TLib3MFHandle; const nTriangleIndicesCount: QWord; const pTriangleIndicesBuffer: PCardinal): TLib3MFResult; cdecl; + + (** + * Merges another Triangle set. + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] pOtherTriangleSet - Other triangle set to merge. + * @param[in] bDeleteOther - Flag if other triangle set is getting removed. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_MergeFunc = function(pTriangleSet: TLib3MFHandle; const pOtherTriangleSet: TLib3MFHandle; const bDeleteOther: Byte): TLib3MFResult; cdecl; + + (** + * Deletes the whole set from the mesh. + * + * @param[in] pTriangleSet - TriangleSet instance. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_DeleteSetFunc = function(pTriangleSet: TLib3MFHandle): TLib3MFResult; cdecl; + + (** + * Duplicates the set in the mesh. + * + * @param[in] pTriangleSet - TriangleSet instance. + * @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @param[out] pNewSet - Copy of the triangle set. + * @return error code or 0 (success) + *) + TLib3MFTriangleSet_DuplicateFunc = function(pTriangleSet: TLib3MFHandle; const pIdentifier: PAnsiChar; out pNewSet: TLib3MFHandle): TLib3MFResult; cdecl; + + (************************************************************************************************************************* Function type definitions for Object **************************************************************************************************************************) @@ -1791,6 +1924,56 @@ TLib3MFModel = class; *) TLib3MFMeshObject_SetVolumeDataFunc = function(pMeshObject: TLib3MFHandle; const pTheVolumeData: TLib3MFHandle): TLib3MFResult; cdecl; + (** + * Adds a new triangle set. + * + * @param[in] pMeshObject - MeshObject instance. + * @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @param[in] pName - the human readable name. MUST NOT be an empty string + * @param[out] pTheTriangleSet - the new Triangle Set Instance. + * @return error code or 0 (success) + *) + TLib3MFMeshObject_AddTriangleSetFunc = function(pMeshObject: TLib3MFHandle; const pIdentifier: PAnsiChar; const pName: PAnsiChar; out pTheTriangleSet: TLib3MFHandle): TLib3MFResult; cdecl; + + (** + * Checks if a triangle set exists. + * + * @param[in] pMeshObject - MeshObject instance. + * @param[in] pIdentifier - the identifier to be found. + * @param[out] pTriangleSetExists - flag if the triangles set exists. + * @return error code or 0 (success) + *) + TLib3MFMeshObject_HasTriangleSetFunc = function(pMeshObject: TLib3MFHandle; const pIdentifier: PAnsiChar; out pTriangleSetExists: Byte): TLib3MFResult; cdecl; + + (** + * Finds a new triangle set by identifier. Fails if not existing. + * + * @param[in] pMeshObject - MeshObject instance. + * @param[in] pIdentifier - the identifier to be found. + * @param[out] pTheTriangleSet - the triangle Set Instance. + * @return error code or 0 (success) + *) + TLib3MFMeshObject_FindTriangleSetFunc = function(pMeshObject: TLib3MFHandle; const pIdentifier: PAnsiChar; out pTheTriangleSet: TLib3MFHandle): TLib3MFResult; cdecl; + + (** + * Returns number of triangle sets. + * + * @param[in] pMeshObject - MeshObject instance. + * @param[out] pCount - the number of triangle sets of this mesh. + * @return error code or 0 (success) + *) + TLib3MFMeshObject_GetTriangleSetCountFunc = function(pMeshObject: TLib3MFHandle; out pCount: Cardinal): TLib3MFResult; cdecl; + + (** + * Returns a specific triangle set by index. + * + * @param[in] pMeshObject - MeshObject instance. + * @param[in] nIndex - the index of the triangle set. + * @param[out] pTheTriangleSet - the triangle Set Instance. + * @return error code or 0 (success) + *) + TLib3MFMeshObject_GetTriangleSetFunc = function(pMeshObject: TLib3MFHandle; const nIndex: Cardinal; out pTheTriangleSet: TLib3MFHandle): TLib3MFResult; cdecl; + (************************************************************************************************************************* Function type definitions for LevelSet @@ -7427,6 +7610,30 @@ TLib3MFMetaDataGroup = class(TLib3MFBase) end; +(************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************) + + TLib3MFTriangleSet = class(TLib3MFBase) + public + constructor Create(AWrapper: TLib3MFWrapper; AHandle: TLib3MFHandle); + destructor Destroy; override; + procedure SetName(const AName: String); + function GetName(): String; + procedure SetIdentifier(const AIdentifier: String); + function GetIdentifier(): String; + procedure AddTriangle(const ATriangleIndex: Cardinal); + procedure RemoveTriangle(const ATriangleIndex: Cardinal); + procedure Clear(); + procedure SetTriangleList(const ATriangleIndices: TCardinalDynArray); + procedure GetTriangleList(out ATriangleIndices: TCardinalDynArray); + procedure AddTriangleList(const ATriangleIndices: TCardinalDynArray); + procedure Merge(const AOtherTriangleSet: TLib3MFTriangleSet; const ADeleteOther: Boolean); + procedure DeleteSet(); + function Duplicate(const AIdentifier: String): TLib3MFTriangleSet; + end; + + (************************************************************************************************************************* Class definition for Object **************************************************************************************************************************) @@ -7491,6 +7698,11 @@ TLib3MFMeshObject = class(TLib3MFObject) function BeamLattice(): TLib3MFBeamLattice; function GetVolumeData(): TLib3MFVolumeData; procedure SetVolumeData(const ATheVolumeData: TLib3MFVolumeData); + function AddTriangleSet(const AIdentifier: String; const AName: String): TLib3MFTriangleSet; + function HasTriangleSet(const AIdentifier: String): Boolean; + function FindTriangleSet(const AIdentifier: String): TLib3MFTriangleSet; + function GetTriangleSetCount(): Cardinal; + function GetTriangleSet(const AIndex: Cardinal): TLib3MFTriangleSet; end; @@ -9050,6 +9262,19 @@ TLib3MFWrapper = class(TObject) FLib3MFMetaDataGroup_RemoveMetaDataByIndexFunc: TLib3MFMetaDataGroup_RemoveMetaDataByIndexFunc; FLib3MFMetaDataGroup_RemoveMetaDataFunc: TLib3MFMetaDataGroup_RemoveMetaDataFunc; FLib3MFMetaDataGroup_AddMetaDataFunc: TLib3MFMetaDataGroup_AddMetaDataFunc; + FLib3MFTriangleSet_SetNameFunc: TLib3MFTriangleSet_SetNameFunc; + FLib3MFTriangleSet_GetNameFunc: TLib3MFTriangleSet_GetNameFunc; + FLib3MFTriangleSet_SetIdentifierFunc: TLib3MFTriangleSet_SetIdentifierFunc; + FLib3MFTriangleSet_GetIdentifierFunc: TLib3MFTriangleSet_GetIdentifierFunc; + FLib3MFTriangleSet_AddTriangleFunc: TLib3MFTriangleSet_AddTriangleFunc; + FLib3MFTriangleSet_RemoveTriangleFunc: TLib3MFTriangleSet_RemoveTriangleFunc; + FLib3MFTriangleSet_ClearFunc: TLib3MFTriangleSet_ClearFunc; + FLib3MFTriangleSet_SetTriangleListFunc: TLib3MFTriangleSet_SetTriangleListFunc; + FLib3MFTriangleSet_GetTriangleListFunc: TLib3MFTriangleSet_GetTriangleListFunc; + FLib3MFTriangleSet_AddTriangleListFunc: TLib3MFTriangleSet_AddTriangleListFunc; + FLib3MFTriangleSet_MergeFunc: TLib3MFTriangleSet_MergeFunc; + FLib3MFTriangleSet_DeleteSetFunc: TLib3MFTriangleSet_DeleteSetFunc; + FLib3MFTriangleSet_DuplicateFunc: TLib3MFTriangleSet_DuplicateFunc; FLib3MFObject_GetTypeFunc: TLib3MFObject_GetTypeFunc; FLib3MFObject_SetTypeFunc: TLib3MFObject_SetTypeFunc; FLib3MFObject_GetNameFunc: TLib3MFObject_GetNameFunc; @@ -9095,6 +9320,11 @@ TLib3MFWrapper = class(TObject) FLib3MFMeshObject_BeamLatticeFunc: TLib3MFMeshObject_BeamLatticeFunc; FLib3MFMeshObject_GetVolumeDataFunc: TLib3MFMeshObject_GetVolumeDataFunc; FLib3MFMeshObject_SetVolumeDataFunc: TLib3MFMeshObject_SetVolumeDataFunc; + FLib3MFMeshObject_AddTriangleSetFunc: TLib3MFMeshObject_AddTriangleSetFunc; + FLib3MFMeshObject_HasTriangleSetFunc: TLib3MFMeshObject_HasTriangleSetFunc; + FLib3MFMeshObject_FindTriangleSetFunc: TLib3MFMeshObject_FindTriangleSetFunc; + FLib3MFMeshObject_GetTriangleSetCountFunc: TLib3MFMeshObject_GetTriangleSetCountFunc; + FLib3MFMeshObject_GetTriangleSetFunc: TLib3MFMeshObject_GetTriangleSetFunc; FLib3MFLevelSet_GetFunctionFunc: TLib3MFLevelSet_GetFunctionFunc; FLib3MFLevelSet_SetFunctionFunc: TLib3MFLevelSet_SetFunctionFunc; FLib3MFLevelSet_GetTransformFunc: TLib3MFLevelSet_GetTransformFunc; @@ -9662,6 +9892,19 @@ TLib3MFWrapper = class(TObject) property Lib3MFMetaDataGroup_RemoveMetaDataByIndexFunc: TLib3MFMetaDataGroup_RemoveMetaDataByIndexFunc read FLib3MFMetaDataGroup_RemoveMetaDataByIndexFunc; property Lib3MFMetaDataGroup_RemoveMetaDataFunc: TLib3MFMetaDataGroup_RemoveMetaDataFunc read FLib3MFMetaDataGroup_RemoveMetaDataFunc; property Lib3MFMetaDataGroup_AddMetaDataFunc: TLib3MFMetaDataGroup_AddMetaDataFunc read FLib3MFMetaDataGroup_AddMetaDataFunc; + property Lib3MFTriangleSet_SetNameFunc: TLib3MFTriangleSet_SetNameFunc read FLib3MFTriangleSet_SetNameFunc; + property Lib3MFTriangleSet_GetNameFunc: TLib3MFTriangleSet_GetNameFunc read FLib3MFTriangleSet_GetNameFunc; + property Lib3MFTriangleSet_SetIdentifierFunc: TLib3MFTriangleSet_SetIdentifierFunc read FLib3MFTriangleSet_SetIdentifierFunc; + property Lib3MFTriangleSet_GetIdentifierFunc: TLib3MFTriangleSet_GetIdentifierFunc read FLib3MFTriangleSet_GetIdentifierFunc; + property Lib3MFTriangleSet_AddTriangleFunc: TLib3MFTriangleSet_AddTriangleFunc read FLib3MFTriangleSet_AddTriangleFunc; + property Lib3MFTriangleSet_RemoveTriangleFunc: TLib3MFTriangleSet_RemoveTriangleFunc read FLib3MFTriangleSet_RemoveTriangleFunc; + property Lib3MFTriangleSet_ClearFunc: TLib3MFTriangleSet_ClearFunc read FLib3MFTriangleSet_ClearFunc; + property Lib3MFTriangleSet_SetTriangleListFunc: TLib3MFTriangleSet_SetTriangleListFunc read FLib3MFTriangleSet_SetTriangleListFunc; + property Lib3MFTriangleSet_GetTriangleListFunc: TLib3MFTriangleSet_GetTriangleListFunc read FLib3MFTriangleSet_GetTriangleListFunc; + property Lib3MFTriangleSet_AddTriangleListFunc: TLib3MFTriangleSet_AddTriangleListFunc read FLib3MFTriangleSet_AddTriangleListFunc; + property Lib3MFTriangleSet_MergeFunc: TLib3MFTriangleSet_MergeFunc read FLib3MFTriangleSet_MergeFunc; + property Lib3MFTriangleSet_DeleteSetFunc: TLib3MFTriangleSet_DeleteSetFunc read FLib3MFTriangleSet_DeleteSetFunc; + property Lib3MFTriangleSet_DuplicateFunc: TLib3MFTriangleSet_DuplicateFunc read FLib3MFTriangleSet_DuplicateFunc; property Lib3MFObject_GetTypeFunc: TLib3MFObject_GetTypeFunc read FLib3MFObject_GetTypeFunc; property Lib3MFObject_SetTypeFunc: TLib3MFObject_SetTypeFunc read FLib3MFObject_SetTypeFunc; property Lib3MFObject_GetNameFunc: TLib3MFObject_GetNameFunc read FLib3MFObject_GetNameFunc; @@ -9707,6 +9950,11 @@ TLib3MFWrapper = class(TObject) property Lib3MFMeshObject_BeamLatticeFunc: TLib3MFMeshObject_BeamLatticeFunc read FLib3MFMeshObject_BeamLatticeFunc; property Lib3MFMeshObject_GetVolumeDataFunc: TLib3MFMeshObject_GetVolumeDataFunc read FLib3MFMeshObject_GetVolumeDataFunc; property Lib3MFMeshObject_SetVolumeDataFunc: TLib3MFMeshObject_SetVolumeDataFunc read FLib3MFMeshObject_SetVolumeDataFunc; + property Lib3MFMeshObject_AddTriangleSetFunc: TLib3MFMeshObject_AddTriangleSetFunc read FLib3MFMeshObject_AddTriangleSetFunc; + property Lib3MFMeshObject_HasTriangleSetFunc: TLib3MFMeshObject_HasTriangleSetFunc read FLib3MFMeshObject_HasTriangleSetFunc; + property Lib3MFMeshObject_FindTriangleSetFunc: TLib3MFMeshObject_FindTriangleSetFunc read FLib3MFMeshObject_FindTriangleSetFunc; + property Lib3MFMeshObject_GetTriangleSetCountFunc: TLib3MFMeshObject_GetTriangleSetCountFunc read FLib3MFMeshObject_GetTriangleSetCountFunc; + property Lib3MFMeshObject_GetTriangleSetFunc: TLib3MFMeshObject_GetTriangleSetFunc read FLib3MFMeshObject_GetTriangleSetFunc; property Lib3MFLevelSet_GetFunctionFunc: TLib3MFLevelSet_GetFunctionFunc read FLib3MFLevelSet_GetFunctionFunc; property Lib3MFLevelSet_SetFunctionFunc: TLib3MFLevelSet_SetFunctionFunc read FLib3MFLevelSet_SetFunctionFunc; property Lib3MFLevelSet_GetTransformFunc: TLib3MFLevelSet_GetTransformFunc read FLib3MFLevelSet_GetTransformFunc; @@ -10297,6 +10545,7 @@ TLib3MFPolymorphicFactory<_T:class; _B> = record function TLib3MFPolymorphicFactoryMakeLevelSetIterator(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFLevelSetIterator; function TLib3MFPolymorphicFactoryMakeMetaData(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFMetaData; function TLib3MFPolymorphicFactoryMakeMetaDataGroup(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFMetaDataGroup; + function TLib3MFPolymorphicFactoryMakeTriangleSet(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFTriangleSet; function TLib3MFPolymorphicFactoryMakeObject(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFObject; function TLib3MFPolymorphicFactoryMakeMeshObject(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFMeshObject; function TLib3MFPolymorphicFactoryMakeLevelSet(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFLevelSet; @@ -11121,6 +11370,7 @@ implementation QWord($A0C005C035D5371D): begin Obj := TLIB3MFLevelSetIterator.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSetIterator" QWord($D17716D063DE2C22): begin Obj := TLIB3MFMetaData.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::MetaData" QWord($0C3B85369E9B25D3): begin Obj := TLIB3MFMetaDataGroup.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::MetaDataGroup" + QWord($5950BB3EE8A82090): begin Obj := TLIB3MFTriangleSet.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::TriangleSet" QWord($2DA2136F577A779C): begin Obj := TLIB3MFObject.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::Object" QWord($3B3A6DC6EC610497): begin Obj := TLIB3MFMeshObject.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::MeshObject" QWord($E8A7D9C192EFD0E2): begin Obj := TLIB3MFLevelSet.Create(Wrapper, Handle); if Obj.inheritsFrom(_T) then Result := Obj as _T; end; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSet" @@ -11302,6 +11552,10 @@ implementation begin Result := TLib3MFPolymorphicFactory.Make(Wrapper, Handle); end; + function TLib3MFPolymorphicFactoryMakeTriangleSet(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFTriangleSet; + begin + Result := TLib3MFPolymorphicFactory.Make(Wrapper, Handle); + end; function TLib3MFPolymorphicFactoryMakeObject(Wrapper: TLib3MFWrapper; Handle: TLib3MFHandle): TLIB3MFObject; begin Result := TLib3MFPolymorphicFactory.Make(Wrapper, Handle); @@ -11726,6 +11980,8 @@ implementation LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: ADescription := 'An element buffer exceeds its spec limit'; LIB3MF_ERROR_INVALIDRESOURCE: ADescription := 'A resource is invalid'; LIB3MF_ERROR_INVALIDLEVELSET: ADescription := 'A level set is invalid'; + LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: ADescription := 'Could not find triangle set'; + LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: ADescription := 'Invalid triangle set index'; LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: ADescription := 'This object type is not valid for beamlattices'; LIB3MF_ERROR_INVALIDKEYSTORE: ADescription := 'The keystore object is invalid'; LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: ADescription := 'The consumer keystore object is invalid'; @@ -12649,6 +12905,144 @@ implementation Result := TLib3MFPolymorphicFactory.Make(FWrapper, HMetaData); end; +(************************************************************************************************************************* + Class implementation for TriangleSet +**************************************************************************************************************************) + + constructor TLib3MFTriangleSet.Create(AWrapper: TLib3MFWrapper; AHandle: TLib3MFHandle); + begin + inherited Create(AWrapper, AHandle); + end; + + destructor TLib3MFTriangleSet.Destroy; + begin + inherited; + end; + + procedure TLib3MFTriangleSet.SetName(const AName: String); + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_SetNameFunc(FHandle, PAnsiChar(AName))); + end; + + function TLib3MFTriangleSet.GetName(): String; + var + bytesNeededName: Cardinal; + bytesWrittenName: Cardinal; + bufferName: array of Char; + begin + bytesNeededName:= 0; + bytesWrittenName:= 0; + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_GetNameFunc(FHandle, 0, bytesNeededName, nil)); + SetLength(bufferName, bytesNeededName); + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_GetNameFunc(FHandle, bytesNeededName, bytesWrittenName, @bufferName[0])); + Result := StrPas(@bufferName[0]); + end; + + procedure TLib3MFTriangleSet.SetIdentifier(const AIdentifier: String); + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_SetIdentifierFunc(FHandle, PAnsiChar(AIdentifier))); + end; + + function TLib3MFTriangleSet.GetIdentifier(): String; + var + bytesNeededIdentifier: Cardinal; + bytesWrittenIdentifier: Cardinal; + bufferIdentifier: array of Char; + begin + bytesNeededIdentifier:= 0; + bytesWrittenIdentifier:= 0; + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_GetIdentifierFunc(FHandle, 0, bytesNeededIdentifier, nil)); + SetLength(bufferIdentifier, bytesNeededIdentifier); + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_GetIdentifierFunc(FHandle, bytesNeededIdentifier, bytesWrittenIdentifier, @bufferIdentifier[0])); + Result := StrPas(@bufferIdentifier[0]); + end; + + procedure TLib3MFTriangleSet.AddTriangle(const ATriangleIndex: Cardinal); + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_AddTriangleFunc(FHandle, ATriangleIndex)); + end; + + procedure TLib3MFTriangleSet.RemoveTriangle(const ATriangleIndex: Cardinal); + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_RemoveTriangleFunc(FHandle, ATriangleIndex)); + end; + + procedure TLib3MFTriangleSet.Clear(); + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_ClearFunc(FHandle)); + end; + + procedure TLib3MFTriangleSet.SetTriangleList(const ATriangleIndices: TCardinalDynArray); + var + PtrTriangleIndices: PCardinal; + LenTriangleIndices: QWord; + begin + LenTriangleIndices := Length(ATriangleIndices); + if LenTriangleIndices > $FFFFFFFF then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_INVALIDPARAM, 'array has too many entries.'); + if LenTriangleIndices > 0 then + PtrTriangleIndices := @ATriangleIndices[0] + else + PtrTriangleIndices := nil; + + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_SetTriangleListFunc(FHandle, QWord(LenTriangleIndices), PtrTriangleIndices)); + end; + + procedure TLib3MFTriangleSet.GetTriangleList(out ATriangleIndices: TCardinalDynArray); + var + countNeededTriangleIndices: QWord; + countWrittenTriangleIndices: QWord; + begin + countNeededTriangleIndices:= 0; + countWrittenTriangleIndices:= 0; + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_GetTriangleListFunc(FHandle, 0, countNeededTriangleIndices, nil)); + SetLength(ATriangleIndices, countNeededTriangleIndices); + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_GetTriangleListFunc(FHandle, countNeededTriangleIndices, countWrittenTriangleIndices, @ATriangleIndices[0])); + end; + + procedure TLib3MFTriangleSet.AddTriangleList(const ATriangleIndices: TCardinalDynArray); + var + PtrTriangleIndices: PCardinal; + LenTriangleIndices: QWord; + begin + LenTriangleIndices := Length(ATriangleIndices); + if LenTriangleIndices > $FFFFFFFF then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_INVALIDPARAM, 'array has too many entries.'); + if LenTriangleIndices > 0 then + PtrTriangleIndices := @ATriangleIndices[0] + else + PtrTriangleIndices := nil; + + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_AddTriangleListFunc(FHandle, QWord(LenTriangleIndices), PtrTriangleIndices)); + end; + + procedure TLib3MFTriangleSet.Merge(const AOtherTriangleSet: TLib3MFTriangleSet; const ADeleteOther: Boolean); + var + AOtherTriangleSetHandle: TLib3MFHandle; + begin + if Assigned(AOtherTriangleSet) then + AOtherTriangleSetHandle := AOtherTriangleSet.TheHandle + else + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_INVALIDPARAM, 'AOtherTriangleSet is a nil value.'); + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_MergeFunc(FHandle, AOtherTriangleSetHandle, Ord(ADeleteOther))); + end; + + procedure TLib3MFTriangleSet.DeleteSet(); + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_DeleteSetFunc(FHandle)); + end; + + function TLib3MFTriangleSet.Duplicate(const AIdentifier: String): TLib3MFTriangleSet; + var + HNewSet: TLib3MFHandle; + begin + Result := nil; + HNewSet := nil; + FWrapper.CheckError(Self, FWrapper.Lib3MFTriangleSet_DuplicateFunc(FHandle, PAnsiChar(AIdentifier), HNewSet)); + if Assigned(HNewSet) then + Result := TLib3MFPolymorphicFactory.Make(FWrapper, HNewSet); + end; + (************************************************************************************************************************* Class implementation for Object **************************************************************************************************************************) @@ -13069,6 +13463,53 @@ implementation FWrapper.CheckError(Self, FWrapper.Lib3MFMeshObject_SetVolumeDataFunc(FHandle, ATheVolumeDataHandle)); end; + function TLib3MFMeshObject.AddTriangleSet(const AIdentifier: String; const AName: String): TLib3MFTriangleSet; + var + HTheTriangleSet: TLib3MFHandle; + begin + Result := nil; + HTheTriangleSet := nil; + FWrapper.CheckError(Self, FWrapper.Lib3MFMeshObject_AddTriangleSetFunc(FHandle, PAnsiChar(AIdentifier), PAnsiChar(AName), HTheTriangleSet)); + if Assigned(HTheTriangleSet) then + Result := TLib3MFPolymorphicFactory.Make(FWrapper, HTheTriangleSet); + end; + + function TLib3MFMeshObject.HasTriangleSet(const AIdentifier: String): Boolean; + var + ResultTriangleSetExists: Byte; + begin + ResultTriangleSetExists := 0; + FWrapper.CheckError(Self, FWrapper.Lib3MFMeshObject_HasTriangleSetFunc(FHandle, PAnsiChar(AIdentifier), ResultTriangleSetExists)); + Result := (ResultTriangleSetExists <> 0); + end; + + function TLib3MFMeshObject.FindTriangleSet(const AIdentifier: String): TLib3MFTriangleSet; + var + HTheTriangleSet: TLib3MFHandle; + begin + Result := nil; + HTheTriangleSet := nil; + FWrapper.CheckError(Self, FWrapper.Lib3MFMeshObject_FindTriangleSetFunc(FHandle, PAnsiChar(AIdentifier), HTheTriangleSet)); + if Assigned(HTheTriangleSet) then + Result := TLib3MFPolymorphicFactory.Make(FWrapper, HTheTriangleSet); + end; + + function TLib3MFMeshObject.GetTriangleSetCount(): Cardinal; + begin + FWrapper.CheckError(Self, FWrapper.Lib3MFMeshObject_GetTriangleSetCountFunc(FHandle, Result)); + end; + + function TLib3MFMeshObject.GetTriangleSet(const AIndex: Cardinal): TLib3MFTriangleSet; + var + HTheTriangleSet: TLib3MFHandle; + begin + Result := nil; + HTheTriangleSet := nil; + FWrapper.CheckError(Self, FWrapper.Lib3MFMeshObject_GetTriangleSetFunc(FHandle, AIndex, HTheTriangleSet)); + if Assigned(HTheTriangleSet) then + Result := TLib3MFPolymorphicFactory.Make(FWrapper, HTheTriangleSet); + end; + (************************************************************************************************************************* Class implementation for LevelSet **************************************************************************************************************************) @@ -19007,6 +19448,19 @@ implementation FLib3MFMetaDataGroup_RemoveMetaDataByIndexFunc := LoadFunction('lib3mf_metadatagroup_removemetadatabyindex'); FLib3MFMetaDataGroup_RemoveMetaDataFunc := LoadFunction('lib3mf_metadatagroup_removemetadata'); FLib3MFMetaDataGroup_AddMetaDataFunc := LoadFunction('lib3mf_metadatagroup_addmetadata'); + FLib3MFTriangleSet_SetNameFunc := LoadFunction('lib3mf_triangleset_setname'); + FLib3MFTriangleSet_GetNameFunc := LoadFunction('lib3mf_triangleset_getname'); + FLib3MFTriangleSet_SetIdentifierFunc := LoadFunction('lib3mf_triangleset_setidentifier'); + FLib3MFTriangleSet_GetIdentifierFunc := LoadFunction('lib3mf_triangleset_getidentifier'); + FLib3MFTriangleSet_AddTriangleFunc := LoadFunction('lib3mf_triangleset_addtriangle'); + FLib3MFTriangleSet_RemoveTriangleFunc := LoadFunction('lib3mf_triangleset_removetriangle'); + FLib3MFTriangleSet_ClearFunc := LoadFunction('lib3mf_triangleset_clear'); + FLib3MFTriangleSet_SetTriangleListFunc := LoadFunction('lib3mf_triangleset_settrianglelist'); + FLib3MFTriangleSet_GetTriangleListFunc := LoadFunction('lib3mf_triangleset_gettrianglelist'); + FLib3MFTriangleSet_AddTriangleListFunc := LoadFunction('lib3mf_triangleset_addtrianglelist'); + FLib3MFTriangleSet_MergeFunc := LoadFunction('lib3mf_triangleset_merge'); + FLib3MFTriangleSet_DeleteSetFunc := LoadFunction('lib3mf_triangleset_deleteset'); + FLib3MFTriangleSet_DuplicateFunc := LoadFunction('lib3mf_triangleset_duplicate'); FLib3MFObject_GetTypeFunc := LoadFunction('lib3mf_object_gettype'); FLib3MFObject_SetTypeFunc := LoadFunction('lib3mf_object_settype'); FLib3MFObject_GetNameFunc := LoadFunction('lib3mf_object_getname'); @@ -19052,6 +19506,11 @@ implementation FLib3MFMeshObject_BeamLatticeFunc := LoadFunction('lib3mf_meshobject_beamlattice'); FLib3MFMeshObject_GetVolumeDataFunc := LoadFunction('lib3mf_meshobject_getvolumedata'); FLib3MFMeshObject_SetVolumeDataFunc := LoadFunction('lib3mf_meshobject_setvolumedata'); + FLib3MFMeshObject_AddTriangleSetFunc := LoadFunction('lib3mf_meshobject_addtriangleset'); + FLib3MFMeshObject_HasTriangleSetFunc := LoadFunction('lib3mf_meshobject_hastriangleset'); + FLib3MFMeshObject_FindTriangleSetFunc := LoadFunction('lib3mf_meshobject_findtriangleset'); + FLib3MFMeshObject_GetTriangleSetCountFunc := LoadFunction('lib3mf_meshobject_gettrianglesetcount'); + FLib3MFMeshObject_GetTriangleSetFunc := LoadFunction('lib3mf_meshobject_gettriangleset'); FLib3MFLevelSet_GetFunctionFunc := LoadFunction('lib3mf_levelset_getfunction'); FLib3MFLevelSet_SetFunctionFunc := LoadFunction('lib3mf_levelset_setfunction'); FLib3MFLevelSet_GetTransformFunc := LoadFunction('lib3mf_levelset_gettransform'); @@ -19754,6 +20213,45 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_metadatagroup_addmetadata'), @FLib3MFMetaDataGroup_AddMetaDataFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_setname'), @FLib3MFTriangleSet_SetNameFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_getname'), @FLib3MFTriangleSet_GetNameFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_setidentifier'), @FLib3MFTriangleSet_SetIdentifierFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_getidentifier'), @FLib3MFTriangleSet_GetIdentifierFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_addtriangle'), @FLib3MFTriangleSet_AddTriangleFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_removetriangle'), @FLib3MFTriangleSet_RemoveTriangleFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_clear'), @FLib3MFTriangleSet_ClearFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_settrianglelist'), @FLib3MFTriangleSet_SetTriangleListFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_gettrianglelist'), @FLib3MFTriangleSet_GetTriangleListFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_addtrianglelist'), @FLib3MFTriangleSet_AddTriangleListFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_merge'), @FLib3MFTriangleSet_MergeFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_deleteset'), @FLib3MFTriangleSet_DeleteSetFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_triangleset_duplicate'), @FLib3MFTriangleSet_DuplicateFunc); if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_object_gettype'), @FLib3MFObject_GetTypeFunc); @@ -19889,6 +20387,21 @@ implementation if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_meshobject_setvolumedata'), @FLib3MFMeshObject_SetVolumeDataFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_meshobject_addtriangleset'), @FLib3MFMeshObject_AddTriangleSetFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_meshobject_hastriangleset'), @FLib3MFMeshObject_HasTriangleSetFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_meshobject_findtriangleset'), @FLib3MFMeshObject_FindTriangleSetFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_meshobject_gettrianglesetcount'), @FLib3MFMeshObject_GetTriangleSetCountFunc); + if AResult <> LIB3MF_SUCCESS then + raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); + AResult := ALookupMethod(PAnsiChar('lib3mf_meshobject_gettriangleset'), @FLib3MFMeshObject_GetTriangleSetFunc); if AResult <> LIB3MF_SUCCESS then raise ELib3MFException.CreateCustomMessage(LIB3MF_ERROR_COULDNOTLOADLIBRARY, ''); AResult := ALookupMethod(PAnsiChar('lib3mf_levelset_getfunction'), @FLib3MFLevelSet_GetFunctionFunc); diff --git a/Autogenerated/Bindings/Python/Lib3MF.py b/Autogenerated/Bindings/Python/Lib3MF.py index 9469dda45..0d5d2740f 100644 --- a/Autogenerated/Bindings/Python/Lib3MF.py +++ b/Autogenerated/Bindings/Python/Lib3MF.py @@ -101,6 +101,8 @@ class ErrorCodes(enum.IntEnum): ELEMENTCOUNTEXCEEDSLIMIT = 141 INVALIDRESOURCE = 142 INVALIDLEVELSET = 143 + COULDNOTFINDTRIANGLESET = 144 + INVALIDTRIANGLESETINDEX = 145 BEAMLATTICE_INVALID_OBJECTTYPE = 2000 INVALIDKEYSTORE = 3000 INVALIDKEYSTORECONSUMER = 3001 @@ -203,6 +205,19 @@ class FunctionTable: lib3mf_metadatagroup_removemetadatabyindex = None lib3mf_metadatagroup_removemetadata = None lib3mf_metadatagroup_addmetadata = None + lib3mf_triangleset_setname = None + lib3mf_triangleset_getname = None + lib3mf_triangleset_setidentifier = None + lib3mf_triangleset_getidentifier = None + lib3mf_triangleset_addtriangle = None + lib3mf_triangleset_removetriangle = None + lib3mf_triangleset_clear = None + lib3mf_triangleset_settrianglelist = None + lib3mf_triangleset_gettrianglelist = None + lib3mf_triangleset_addtrianglelist = None + lib3mf_triangleset_merge = None + lib3mf_triangleset_deleteset = None + lib3mf_triangleset_duplicate = None lib3mf_object_gettype = None lib3mf_object_settype = None lib3mf_object_getname = None @@ -248,6 +263,11 @@ class FunctionTable: lib3mf_meshobject_beamlattice = None lib3mf_meshobject_getvolumedata = None lib3mf_meshobject_setvolumedata = None + lib3mf_meshobject_addtriangleset = None + lib3mf_meshobject_hastriangleset = None + lib3mf_meshobject_findtriangleset = None + lib3mf_meshobject_gettrianglesetcount = None + lib3mf_meshobject_gettriangleset = None lib3mf_levelset_getfunction = None lib3mf_levelset_setfunction = None lib3mf_levelset_gettransform = None @@ -1650,6 +1670,84 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_bool, ctypes.POINTER(ctypes.c_void_p)) self.lib.lib3mf_metadatagroup_addmetadata = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_setname")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p) + self.lib.lib3mf_triangleset_setname = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_getname")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.c_char_p) + self.lib.lib3mf_triangleset_getname = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_setidentifier")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p) + self.lib.lib3mf_triangleset_setidentifier = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_getidentifier")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.c_char_p) + self.lib.lib3mf_triangleset_getidentifier = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_addtriangle")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint32) + self.lib.lib3mf_triangleset_addtriangle = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_removetriangle")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint32) + self.lib.lib3mf_triangleset_removetriangle = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_clear")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p) + self.lib.lib3mf_triangleset_clear = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_settrianglelist")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint32)) + self.lib.lib3mf_triangleset_settrianglelist = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_gettrianglelist")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint32)) + self.lib.lib3mf_triangleset_gettrianglelist = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_addtrianglelist")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint32)) + self.lib.lib3mf_triangleset_addtrianglelist = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_merge")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_bool) + self.lib.lib3mf_triangleset_merge = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_deleteset")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p) + self.lib.lib3mf_triangleset_deleteset = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_triangleset_duplicate")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_void_p)) + self.lib.lib3mf_triangleset_duplicate = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_object_gettype")), methodAddress) if err != 0: raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) @@ -1920,6 +2018,36 @@ def _loadFunctionTableFromMethod(self, symbolLookupMethodAddress): methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_void_p) self.lib.lib3mf_meshobject_setvolumedata = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_meshobject_addtriangleset")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_void_p)) + self.lib.lib3mf_meshobject_addtriangleset = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_meshobject_hastriangleset")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_bool)) + self.lib.lib3mf_meshobject_hastriangleset = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_meshobject_findtriangleset")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_void_p)) + self.lib.lib3mf_meshobject_findtriangleset = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_meshobject_gettrianglesetcount")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint32)) + self.lib.lib3mf_meshobject_gettrianglesetcount = methodType(int(methodAddress.value)) + + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_meshobject_gettriangleset")), methodAddress) + if err != 0: + raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) + methodType = ctypes.CFUNCTYPE(ctypes.c_int32, ctypes.c_void_p, ctypes.c_uint32, ctypes.POINTER(ctypes.c_void_p)) + self.lib.lib3mf_meshobject_gettriangleset = methodType(int(methodAddress.value)) + err = symbolLookupMethod(ctypes.c_char_p(str.encode("lib3mf_levelset_getfunction")), methodAddress) if err != 0: raise ELib3MFException(ErrorCodes.COULDNOTLOADLIBRARY, str(err)) @@ -5006,6 +5134,45 @@ def _loadFunctionTable(self): self.lib.lib3mf_metadatagroup_addmetadata.restype = ctypes.c_int32 self.lib.lib3mf_metadatagroup_addmetadata.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_bool, ctypes.POINTER(ctypes.c_void_p)] + self.lib.lib3mf_triangleset_setname.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_setname.argtypes = [ctypes.c_void_p, ctypes.c_char_p] + + self.lib.lib3mf_triangleset_getname.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_getname.argtypes = [ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.c_char_p] + + self.lib.lib3mf_triangleset_setidentifier.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_setidentifier.argtypes = [ctypes.c_void_p, ctypes.c_char_p] + + self.lib.lib3mf_triangleset_getidentifier.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_getidentifier.argtypes = [ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.c_char_p] + + self.lib.lib3mf_triangleset_addtriangle.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_addtriangle.argtypes = [ctypes.c_void_p, ctypes.c_uint32] + + self.lib.lib3mf_triangleset_removetriangle.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_removetriangle.argtypes = [ctypes.c_void_p, ctypes.c_uint32] + + self.lib.lib3mf_triangleset_clear.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_clear.argtypes = [ctypes.c_void_p] + + self.lib.lib3mf_triangleset_settrianglelist.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_settrianglelist.argtypes = [ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint32)] + + self.lib.lib3mf_triangleset_gettrianglelist.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_gettrianglelist.argtypes = [ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint32)] + + self.lib.lib3mf_triangleset_addtrianglelist.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_addtrianglelist.argtypes = [ctypes.c_void_p, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint32)] + + self.lib.lib3mf_triangleset_merge.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_merge.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_bool] + + self.lib.lib3mf_triangleset_deleteset.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_deleteset.argtypes = [ctypes.c_void_p] + + self.lib.lib3mf_triangleset_duplicate.restype = ctypes.c_int32 + self.lib.lib3mf_triangleset_duplicate.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_void_p)] + self.lib.lib3mf_object_gettype.restype = ctypes.c_int32 self.lib.lib3mf_object_gettype.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32)] @@ -5141,6 +5308,21 @@ def _loadFunctionTable(self): self.lib.lib3mf_meshobject_setvolumedata.restype = ctypes.c_int32 self.lib.lib3mf_meshobject_setvolumedata.argtypes = [ctypes.c_void_p, ctypes.c_void_p] + self.lib.lib3mf_meshobject_addtriangleset.restype = ctypes.c_int32 + self.lib.lib3mf_meshobject_addtriangleset.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_void_p)] + + self.lib.lib3mf_meshobject_hastriangleset.restype = ctypes.c_int32 + self.lib.lib3mf_meshobject_hastriangleset.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_bool)] + + self.lib.lib3mf_meshobject_findtriangleset.restype = ctypes.c_int32 + self.lib.lib3mf_meshobject_findtriangleset.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_void_p)] + + self.lib.lib3mf_meshobject_gettrianglesetcount.restype = ctypes.c_int32 + self.lib.lib3mf_meshobject_gettrianglesetcount.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint32)] + + self.lib.lib3mf_meshobject_gettriangleset.restype = ctypes.c_int32 + self.lib.lib3mf_meshobject_gettriangleset.argtypes = [ctypes.c_void_p, ctypes.c_uint32, ctypes.POINTER(ctypes.c_void_p)] + self.lib.lib3mf_levelset_getfunction.restype = ctypes.c_int32 self.lib.lib3mf_levelset_getfunction.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)] @@ -6799,6 +6981,8 @@ def getObjectById_D17716D063DE2C22(self, handle, wrapper): # First 64 bits of SH return MetaData(handle, wrapper) def getObjectById_0C3B85369E9B25D3(self, handle, wrapper): # First 64 bits of SHA1 of a string: "Lib3MF::MetaDataGroup" return MetaDataGroup(handle, wrapper) + def getObjectById_5950BB3EE8A82090(self, handle, wrapper): # First 64 bits of SHA1 of a string: "Lib3MF::TriangleSet" + return TriangleSet(handle, wrapper) def getObjectById_2DA2136F577A779C(self, handle, wrapper): # First 64 bits of SHA1 of a string: "Lib3MF::Object" return Object(handle, wrapper) def getObjectById_3B3A6DC6EC610497(self, handle, wrapper): # First 64 bits of SHA1 of a string: "Lib3MF::MeshObject" @@ -7678,6 +7862,107 @@ def AddMetaData(self, NameSpace, Name, Value, Type, MustPreserve): +''' Class Implementation for TriangleSet +''' +class TriangleSet(Base): + def __init__(self, handle, wrapper): + Base.__init__(self, handle, wrapper) + def SetName(self, Name): + pName = ctypes.c_char_p(str.encode(Name)) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_setname(self._handle, pName)) + + + def GetName(self): + nNameBufferSize = ctypes.c_uint64(0) + nNameNeededChars = ctypes.c_uint64(0) + pNameBuffer = ctypes.c_char_p(None) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_getname(self._handle, nNameBufferSize, nNameNeededChars, pNameBuffer)) + nNameBufferSize = ctypes.c_uint64(nNameNeededChars.value) + pNameBuffer = (ctypes.c_char * (nNameNeededChars.value))() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_getname(self._handle, nNameBufferSize, nNameNeededChars, pNameBuffer)) + + return pNameBuffer.value.decode() + + def SetIdentifier(self, Identifier): + pIdentifier = ctypes.c_char_p(str.encode(Identifier)) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_setidentifier(self._handle, pIdentifier)) + + + def GetIdentifier(self): + nIdentifierBufferSize = ctypes.c_uint64(0) + nIdentifierNeededChars = ctypes.c_uint64(0) + pIdentifierBuffer = ctypes.c_char_p(None) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_getidentifier(self._handle, nIdentifierBufferSize, nIdentifierNeededChars, pIdentifierBuffer)) + nIdentifierBufferSize = ctypes.c_uint64(nIdentifierNeededChars.value) + pIdentifierBuffer = (ctypes.c_char * (nIdentifierNeededChars.value))() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_getidentifier(self._handle, nIdentifierBufferSize, nIdentifierNeededChars, pIdentifierBuffer)) + + return pIdentifierBuffer.value.decode() + + def AddTriangle(self, TriangleIndex): + nTriangleIndex = ctypes.c_uint32(TriangleIndex) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_addtriangle(self._handle, nTriangleIndex)) + + + def RemoveTriangle(self, TriangleIndex): + nTriangleIndex = ctypes.c_uint32(TriangleIndex) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_removetriangle(self._handle, nTriangleIndex)) + + + def Clear(self): + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_clear(self._handle)) + + + def SetTriangleList(self, TriangleIndices): + nTriangleIndicesCount = ctypes.c_uint64(len(TriangleIndices)) + pTriangleIndicesBuffer = (ctypes.c_uint32*len(TriangleIndices))(*TriangleIndices) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_settrianglelist(self._handle, nTriangleIndicesCount, pTriangleIndicesBuffer)) + + + def GetTriangleList(self): + nTriangleIndicesCount = ctypes.c_uint64(0) + nTriangleIndicesNeededCount = ctypes.c_uint64(0) + pTriangleIndicesBuffer = (ctypes.c_uint32*0)() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_gettrianglelist(self._handle, nTriangleIndicesCount, nTriangleIndicesNeededCount, pTriangleIndicesBuffer)) + nTriangleIndicesCount = ctypes.c_uint64(nTriangleIndicesNeededCount.value) + pTriangleIndicesBuffer = (ctypes.c_uint32 * nTriangleIndicesNeededCount.value)() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_gettrianglelist(self._handle, nTriangleIndicesCount, nTriangleIndicesNeededCount, pTriangleIndicesBuffer)) + + return [pTriangleIndicesBuffer[i] for i in range(nTriangleIndicesNeededCount.value)] + + def AddTriangleList(self, TriangleIndices): + nTriangleIndicesCount = ctypes.c_uint64(len(TriangleIndices)) + pTriangleIndicesBuffer = (ctypes.c_uint32*len(TriangleIndices))(*TriangleIndices) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_addtrianglelist(self._handle, nTriangleIndicesCount, pTriangleIndicesBuffer)) + + + def Merge(self, OtherTriangleSetObject, DeleteOther): + OtherTriangleSetHandle = None + if OtherTriangleSetObject: + OtherTriangleSetHandle = OtherTriangleSetObject._handle + else: + raise ELib3MFException(ErrorCodes.INVALIDPARAM, 'Invalid return/output value') + bDeleteOther = ctypes.c_bool(DeleteOther) + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_merge(self._handle, OtherTriangleSetHandle, bDeleteOther)) + + + def DeleteSet(self): + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_deleteset(self._handle)) + + + def Duplicate(self, Identifier): + pIdentifier = ctypes.c_char_p(str.encode(Identifier)) + NewSetHandle = ctypes.c_void_p() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_triangleset_duplicate(self._handle, pIdentifier, NewSetHandle)) + if NewSetHandle: + NewSetObject = self._wrapper._polymorphicFactory(NewSetHandle) + else: + raise ELib3MFException(ErrorCodes.INVALIDCAST, 'Invalid return/output value') + + return NewSetObject + + + ''' Class Implementation for Object ''' class Object(Resource): @@ -8012,6 +8297,53 @@ def SetVolumeData(self, TheVolumeDataObject): self._wrapper.checkError(self, self._wrapper.lib.lib3mf_meshobject_setvolumedata(self._handle, TheVolumeDataHandle)) + def AddTriangleSet(self, Identifier, Name): + pIdentifier = ctypes.c_char_p(str.encode(Identifier)) + pName = ctypes.c_char_p(str.encode(Name)) + TheTriangleSetHandle = ctypes.c_void_p() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_meshobject_addtriangleset(self._handle, pIdentifier, pName, TheTriangleSetHandle)) + if TheTriangleSetHandle: + TheTriangleSetObject = self._wrapper._polymorphicFactory(TheTriangleSetHandle) + else: + raise ELib3MFException(ErrorCodes.INVALIDCAST, 'Invalid return/output value') + + return TheTriangleSetObject + + def HasTriangleSet(self, Identifier): + pIdentifier = ctypes.c_char_p(str.encode(Identifier)) + pTriangleSetExists = ctypes.c_bool() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_meshobject_hastriangleset(self._handle, pIdentifier, pTriangleSetExists)) + + return pTriangleSetExists.value + + def FindTriangleSet(self, Identifier): + pIdentifier = ctypes.c_char_p(str.encode(Identifier)) + TheTriangleSetHandle = ctypes.c_void_p() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_meshobject_findtriangleset(self._handle, pIdentifier, TheTriangleSetHandle)) + if TheTriangleSetHandle: + TheTriangleSetObject = self._wrapper._polymorphicFactory(TheTriangleSetHandle) + else: + raise ELib3MFException(ErrorCodes.INVALIDCAST, 'Invalid return/output value') + + return TheTriangleSetObject + + def GetTriangleSetCount(self): + pCount = ctypes.c_uint32() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_meshobject_gettrianglesetcount(self._handle, pCount)) + + return pCount.value + + def GetTriangleSet(self, Index): + nIndex = ctypes.c_uint32(Index) + TheTriangleSetHandle = ctypes.c_void_p() + self._wrapper.checkError(self, self._wrapper.lib.lib3mf_meshobject_gettriangleset(self._handle, nIndex, TheTriangleSetHandle)) + if TheTriangleSetHandle: + TheTriangleSetObject = self._wrapper._polymorphicFactory(TheTriangleSetHandle) + else: + raise ELib3MFException(ErrorCodes.INVALIDCAST, 'Invalid return/output value') + + return TheTriangleSetObject + ''' Class Implementation for LevelSet diff --git a/Autogenerated/Source/lib3mf_abi.hpp b/Autogenerated/Source/lib3mf_abi.hpp index 1e3907a69..608d1bd02 100644 --- a/Autogenerated/Source/lib3mf_abi.hpp +++ b/Autogenerated/Source/lib3mf_abi.hpp @@ -793,6 +793,135 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_removemetadata(Lib3MF_MetaData */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_addmetadata(Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, const char * pValue, const char * pType, bool bMustPreserve, Lib3MF_MetaData * pMetaData); +/************************************************************************************************************************* + Class definition for TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setname(Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getname(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setidentifier(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getidentifier(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_removetriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_clear(Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_settrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_gettrianglelist(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_merge(Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_deleteset(Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_duplicate(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -1232,6 +1361,56 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject p */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_addtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_hastriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_findtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettrianglesetcount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettriangleset(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + /************************************************************************************************************************* Class definition for LevelSet **************************************************************************************************************************/ diff --git a/Autogenerated/Source/lib3mf_interfaces.hpp b/Autogenerated/Source/lib3mf_interfaces.hpp index ac3083443..ddaf53e65 100644 --- a/Autogenerated/Source/lib3mf_interfaces.hpp +++ b/Autogenerated/Source/lib3mf_interfaces.hpp @@ -72,6 +72,7 @@ class IFunctionIterator; class ILevelSetIterator; class IMetaData; class IMetaDataGroup; +class ITriangleSet; class IObject; class IMeshObject; class ILevelSet; @@ -1202,6 +1203,108 @@ class IMetaDataGroup : public virtual IBase { typedef IBaseSharedPtr PIMetaDataGroup; +/************************************************************************************************************************* + Class interface for TriangleSet +**************************************************************************************************************************/ + +class ITriangleSet : public virtual IBase { +public: + /** + * ITriangleSet::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x5950BB3EE8A82090UL; // First 64 bits of SHA1 of a string: "Lib3MF::TriangleSet" + } + + /** + * ITriangleSet::SetName - sets the name of the triangle set + * @param[in] sName - the new name + */ + virtual void SetName(const std::string & sName) = 0; + + /** + * ITriangleSet::GetName - returns the name of the triangle set + * @return returns the name + */ + virtual std::string GetName() = 0; + + /** + * ITriangleSet::SetIdentifier - sets the identifier of the triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + */ + virtual void SetIdentifier(const std::string & sIdentifier) = 0; + + /** + * ITriangleSet::GetIdentifier - returns the identifier of the triangle set + * @return returns the identifier + */ + virtual std::string GetIdentifier() = 0; + + /** + * ITriangleSet::AddTriangle - adds a triangle to the set. Does nothing if triangle is already in the set. + * @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. + */ + virtual void AddTriangle(const Lib3MF_uint32 nTriangleIndex) = 0; + + /** + * ITriangleSet::RemoveTriangle - removes a triangle from the set + * @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. + */ + virtual void RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) = 0; + + /** + * ITriangleSet::Clear - clears all triangles from the list + */ + virtual void Clear() = 0; + + /** + * ITriangleSet::SetTriangleList - Sets all triangles in the list, while clearing old values. Duplicates will be merged. + * @param[in] nTriangleIndicesBufferSize - Number of elements in buffer + * @param[in] pTriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + virtual void SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) = 0; + + /** + * ITriangleSet::GetTriangleList - Retrieves all the triangles in the TriangleSet + * @param[in] nTriangleIndicesBufferSize - Number of elements in buffer + * @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written structs, or needed buffer size. + * @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet + */ + virtual void GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) = 0; + + /** + * ITriangleSet::AddTriangleList - Adds multiple triangles in the list. Duplicates will be merged. + * @param[in] nTriangleIndicesBufferSize - Number of elements in buffer + * @param[in] pTriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + virtual void AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) = 0; + + /** + * ITriangleSet::Merge - Merges another Triangle set. + * @param[in] pOtherTriangleSet - Other triangle set to merge. + * @param[in] bDeleteOther - Flag if other triangle set is getting removed. + */ + virtual void Merge(ITriangleSet* pOtherTriangleSet, const bool bDeleteOther) = 0; + + /** + * ITriangleSet::DeleteSet - Deletes the whole set from the mesh. + */ + virtual void DeleteSet() = 0; + + /** + * ITriangleSet::Duplicate - Duplicates the set in the mesh. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @return Copy of the triangle set. + */ + virtual ITriangleSet * Duplicate(const std::string & sIdentifier) = 0; + +}; + +typedef IBaseSharedPtr PITriangleSet; + + /************************************************************************************************************************* Class interface for Object **************************************************************************************************************************/ @@ -1527,6 +1630,41 @@ class IMeshObject : public virtual IObject { */ virtual void SetVolumeData(IVolumeData* pTheVolumeData) = 0; + /** + * IMeshObject::AddTriangleSet - Adds a new triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @param[in] sName - the human readable name. MUST NOT be an empty string + * @return the new Triangle Set Instance. + */ + virtual ITriangleSet * AddTriangleSet(const std::string & sIdentifier, const std::string & sName) = 0; + + /** + * IMeshObject::HasTriangleSet - Checks if a triangle set exists. + * @param[in] sIdentifier - the identifier to be found. + * @return flag if the triangles set exists. + */ + virtual bool HasTriangleSet(const std::string & sIdentifier) = 0; + + /** + * IMeshObject::FindTriangleSet - Finds a new triangle set by identifier. Fails if not existing. + * @param[in] sIdentifier - the identifier to be found. + * @return the triangle Set Instance. + */ + virtual ITriangleSet * FindTriangleSet(const std::string & sIdentifier) = 0; + + /** + * IMeshObject::GetTriangleSetCount - Returns number of triangle sets. + * @return the number of triangle sets of this mesh. + */ + virtual Lib3MF_uint32 GetTriangleSetCount() = 0; + + /** + * IMeshObject::GetTriangleSet - Returns a specific triangle set by index. + * @param[in] nIndex - the index of the triangle set. + * @return the triangle Set Instance. + */ + virtual ITriangleSet * GetTriangleSet(const Lib3MF_uint32 nIndex) = 0; + }; typedef IBaseSharedPtr PIMeshObject; diff --git a/Autogenerated/Source/lib3mf_interfacewrapper.cpp b/Autogenerated/Source/lib3mf_interfacewrapper.cpp index 183e16f8e..a9807c356 100644 --- a/Autogenerated/Source/lib3mf_interfacewrapper.cpp +++ b/Autogenerated/Source/lib3mf_interfacewrapper.cpp @@ -2725,6 +2725,495 @@ Lib3MFResult lib3mf_metadatagroup_addmetadata(Lib3MF_MetaDataGroup pMetaDataGrou } +/************************************************************************************************************************* + Class implementation for TriangleSet +**************************************************************************************************************************/ +Lib3MFResult lib3mf_triangleset_setname(Lib3MF_TriangleSet pTriangleSet, const char * pName) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "SetName"); + pJournalEntry->addStringParameter("Name", pName); + } + if (pName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sName(pName); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->SetName(sName); + + 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_triangleset_getname(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "GetName"); + } + if ( (!pNameBuffer) && !(pNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sName(""); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pITriangleSet->GetName(); + + pITriangleSet->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pITriangleSet->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pITriangleSet->_setCache (nullptr); + } + + if (pNameNeededChars) + *pNameNeededChars = (Lib3MF_uint32) (sName.size()+1); + if (pNameBuffer) { + if (sName.size() >= nNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iName = 0; iName < sName.size(); iName++) + pNameBuffer[iName] = sName[iName]; + pNameBuffer[sName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Name", sName.c_str()); + 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_triangleset_setidentifier(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "SetIdentifier"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->SetIdentifier(sIdentifier); + + 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_triangleset_getidentifier(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "GetIdentifier"); + } + if ( (!pIdentifierBuffer) && !(pIdentifierNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(""); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pIdentifierBuffer == nullptr); + if (isCacheCall) { + sIdentifier = pITriangleSet->GetIdentifier(); + + pITriangleSet->_setCache (new ParameterCache_1 (sIdentifier)); + } + else { + auto cache = dynamic_cast*> (pITriangleSet->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sIdentifier); + pITriangleSet->_setCache (nullptr); + } + + if (pIdentifierNeededChars) + *pIdentifierNeededChars = (Lib3MF_uint32) (sIdentifier.size()+1); + if (pIdentifierBuffer) { + if (sIdentifier.size() >= nIdentifierBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iIdentifier = 0; iIdentifier < sIdentifier.size(); iIdentifier++) + pIdentifierBuffer[iIdentifier] = sIdentifier[iIdentifier]; + pIdentifierBuffer[sIdentifier.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Identifier", sIdentifier.c_str()); + 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_triangleset_addtriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "AddTriangle"); + pJournalEntry->addUInt32Parameter("TriangleIndex", nTriangleIndex); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->AddTriangle(nTriangleIndex); + + 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_triangleset_removetriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "RemoveTriangle"); + pJournalEntry->addUInt32Parameter("TriangleIndex", nTriangleIndex); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->RemoveTriangle(nTriangleIndex); + + 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_triangleset_clear(Lib3MF_TriangleSet pTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "Clear"); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->Clear(); + + 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_triangleset_settrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "SetTriangleList"); + } + if ( (!pTriangleIndicesBuffer) && (nTriangleIndicesBufferSize>0)) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->SetTriangleList(nTriangleIndicesBufferSize, pTriangleIndicesBuffer); + + 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_triangleset_gettrianglelist(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "GetTriangleList"); + } + if ((!pTriangleIndicesBuffer) && !(pTriangleIndicesNeededCount)) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->GetTriangleList(nTriangleIndicesBufferSize, pTriangleIndicesNeededCount, pTriangleIndicesBuffer); + + 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_triangleset_addtrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "AddTriangleList"); + } + if ( (!pTriangleIndicesBuffer) && (nTriangleIndicesBufferSize>0)) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->AddTriangleList(nTriangleIndicesBufferSize, pTriangleIndicesBuffer); + + 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_triangleset_merge(Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "Merge"); + pJournalEntry->addHandleParameter("OtherTriangleSet", pOtherTriangleSet); + pJournalEntry->addBooleanParameter("DeleteOther", bDeleteOther); + } + IBase* pIBaseClassOtherTriangleSet = (IBase *)pOtherTriangleSet; + ITriangleSet* pIOtherTriangleSet = dynamic_cast(pIBaseClassOtherTriangleSet); + if (!pIOtherTriangleSet) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->Merge(pIOtherTriangleSet, bDeleteOther); + + 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_triangleset_deleteset(Lib3MF_TriangleSet pTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "DeleteSet"); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->DeleteSet(); + + 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_triangleset_duplicate(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "Duplicate"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNewSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseNewSet(nullptr); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNewSet = pITriangleSet->Duplicate(sIdentifier); + + *pNewSet = (IBase*)(pBaseNewSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("NewSet", *pNewSet); + 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 Object **************************************************************************************************************************/ @@ -4336,6 +4825,199 @@ Lib3MFResult lib3mf_meshobject_setvolumedata(Lib3MF_MeshObject pMeshObject, Lib3 } } +Lib3MFResult lib3mf_meshobject_addtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "AddTriangleSet"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("Name", pName); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTheTriangleSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sName(pName); + IBase* pBaseTheTriangleSet(nullptr); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheTriangleSet = pIMeshObject->AddTriangleSet(sIdentifier, sName); + + *pTheTriangleSet = (IBase*)(pBaseTheTriangleSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheTriangleSet", *pTheTriangleSet); + 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_meshobject_hastriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "HasTriangleSet"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTriangleSetExists == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pTriangleSetExists = pIMeshObject->HasTriangleSet(sIdentifier); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("TriangleSetExists", *pTriangleSetExists); + 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_meshobject_findtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "FindTriangleSet"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTheTriangleSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseTheTriangleSet(nullptr); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheTriangleSet = pIMeshObject->FindTriangleSet(sIdentifier); + + *pTheTriangleSet = (IBase*)(pBaseTheTriangleSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheTriangleSet", *pTheTriangleSet); + 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_meshobject_gettrianglesetcount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "GetTriangleSetCount"); + } + if (pCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pCount = pIMeshObject->GetTriangleSetCount(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("Count", *pCount); + 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_meshobject_gettriangleset(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "GetTriangleSet"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + } + if (pTheTriangleSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheTriangleSet(nullptr); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheTriangleSet = pIMeshObject->GetTriangleSet(nIndex); + + *pTheTriangleSet = (IBase*)(pBaseTheTriangleSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheTriangleSet", *pTheTriangleSet); + 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 LevelSet @@ -22795,6 +23477,32 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_metadatagroup_removemetadata; if (sProcName == "lib3mf_metadatagroup_addmetadata") *ppProcAddress = (void*) &lib3mf_metadatagroup_addmetadata; + if (sProcName == "lib3mf_triangleset_setname") + *ppProcAddress = (void*) &lib3mf_triangleset_setname; + if (sProcName == "lib3mf_triangleset_getname") + *ppProcAddress = (void*) &lib3mf_triangleset_getname; + if (sProcName == "lib3mf_triangleset_setidentifier") + *ppProcAddress = (void*) &lib3mf_triangleset_setidentifier; + if (sProcName == "lib3mf_triangleset_getidentifier") + *ppProcAddress = (void*) &lib3mf_triangleset_getidentifier; + if (sProcName == "lib3mf_triangleset_addtriangle") + *ppProcAddress = (void*) &lib3mf_triangleset_addtriangle; + if (sProcName == "lib3mf_triangleset_removetriangle") + *ppProcAddress = (void*) &lib3mf_triangleset_removetriangle; + if (sProcName == "lib3mf_triangleset_clear") + *ppProcAddress = (void*) &lib3mf_triangleset_clear; + if (sProcName == "lib3mf_triangleset_settrianglelist") + *ppProcAddress = (void*) &lib3mf_triangleset_settrianglelist; + if (sProcName == "lib3mf_triangleset_gettrianglelist") + *ppProcAddress = (void*) &lib3mf_triangleset_gettrianglelist; + if (sProcName == "lib3mf_triangleset_addtrianglelist") + *ppProcAddress = (void*) &lib3mf_triangleset_addtrianglelist; + if (sProcName == "lib3mf_triangleset_merge") + *ppProcAddress = (void*) &lib3mf_triangleset_merge; + if (sProcName == "lib3mf_triangleset_deleteset") + *ppProcAddress = (void*) &lib3mf_triangleset_deleteset; + if (sProcName == "lib3mf_triangleset_duplicate") + *ppProcAddress = (void*) &lib3mf_triangleset_duplicate; if (sProcName == "lib3mf_object_gettype") *ppProcAddress = (void*) &lib3mf_object_gettype; if (sProcName == "lib3mf_object_settype") @@ -22885,6 +23593,16 @@ Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void * *ppProcAddress = (void*) &lib3mf_meshobject_getvolumedata; if (sProcName == "lib3mf_meshobject_setvolumedata") *ppProcAddress = (void*) &lib3mf_meshobject_setvolumedata; + if (sProcName == "lib3mf_meshobject_addtriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_addtriangleset; + if (sProcName == "lib3mf_meshobject_hastriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_hastriangleset; + if (sProcName == "lib3mf_meshobject_findtriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_findtriangleset; + if (sProcName == "lib3mf_meshobject_gettrianglesetcount") + *ppProcAddress = (void*) &lib3mf_meshobject_gettrianglesetcount; + if (sProcName == "lib3mf_meshobject_gettriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_gettriangleset; if (sProcName == "lib3mf_levelset_getfunction") *ppProcAddress = (void*) &lib3mf_levelset_getfunction; if (sProcName == "lib3mf_levelset_setfunction") diff --git a/Autogenerated/Source/lib3mf_types.hpp b/Autogenerated/Source/lib3mf_types.hpp index 4ba959150..0d520b820 100644 --- a/Autogenerated/Source/lib3mf_types.hpp +++ b/Autogenerated/Source/lib3mf_types.hpp @@ -130,6 +130,8 @@ typedef void * Lib3MF_pvoid; #define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ #define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ #define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ #define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ #define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ #define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ @@ -186,6 +188,8 @@ inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; @@ -226,6 +230,7 @@ typedef Lib3MFHandle Lib3MF_FunctionIterator; typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; typedef Lib3MFHandle Lib3MF_LevelSet; diff --git a/AutomaticComponentToolkit/lib3mf.xml b/AutomaticComponentToolkit/lib3mf.xml index e88dcac8b..a1215bbac 100644 --- a/AutomaticComponentToolkit/lib3mf.xml +++ b/AutomaticComponentToolkit/lib3mf.xml @@ -97,6 +97,8 @@ description="An element buffer exceeds its spec limit" /> + + @@ -755,6 +757,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Include/API/lib3mf_meshobject.hpp b/Include/API/lib3mf_meshobject.hpp index b5630a2dc..c2d4c4b6f 100644 --- a/Include/API/lib3mf_meshobject.hpp +++ b/Include/API/lib3mf_meshobject.hpp @@ -63,6 +63,7 @@ class CMeshObject : public virtual IMeshObject, public virtual CObject { NMR::CMeshInformation_Properties* getMeshInformationProperties(); + protected: /** @@ -81,57 +82,67 @@ class CMeshObject : public virtual IMeshObject, public virtual CObject { * Public member functions to implement. */ - Lib3MF_uint32 GetVertexCount (); + Lib3MF_uint32 GetVertexCount () override; - Lib3MF_uint32 GetTriangleCount (); + Lib3MF_uint32 GetTriangleCount () override; - void SetVertex (const Lib3MF_uint32 nIndex, const sLib3MFPosition Coordinates); + void SetVertex (const Lib3MF_uint32 nIndex, const sLib3MFPosition Coordinates) override; - sLib3MFPosition GetVertex(const Lib3MF_uint32 nIndex); + sLib3MFPosition GetVertex(const Lib3MF_uint32 nIndex) override; - Lib3MF_uint32 AddVertex (const sLib3MFPosition Coordinates); + Lib3MF_uint32 AddVertex (const sLib3MFPosition Coordinates) override; - virtual void GetVertices(Lib3MF_uint64 nVerticesBufferSize, Lib3MF_uint64* pVerticesNeededCount, sLib3MFPosition * pVerticesBuffer); + virtual void GetVertices(Lib3MF_uint64 nVerticesBufferSize, Lib3MF_uint64* pVerticesNeededCount, sLib3MFPosition * pVerticesBuffer) override; - sLib3MFTriangle GetTriangle (const Lib3MF_uint32 nIndex); + sLib3MFTriangle GetTriangle (const Lib3MF_uint32 nIndex) override; - void SetTriangle (const Lib3MF_uint32 nIndex, const sLib3MFTriangle Indices); + void SetTriangle (const Lib3MF_uint32 nIndex, const sLib3MFTriangle Indices) override; - Lib3MF_uint32 AddTriangle (const sLib3MFTriangle Indices); + Lib3MF_uint32 AddTriangle (const sLib3MFTriangle Indices) override; - void GetTriangleIndices (Lib3MF_uint64 nIndicesBufferSize, Lib3MF_uint64* pIndicesNeededCount, sLib3MFTriangle * pIndicesBuffer); + void GetTriangleIndices (Lib3MF_uint64 nIndicesBufferSize, Lib3MF_uint64* pIndicesNeededCount, sLib3MFTriangle * pIndicesBuffer) override; - void SetGeometry(const Lib3MF_uint64 nVerticesBufferSize, const sLib3MFPosition * pVerticesBuffer, const Lib3MF_uint64 nIndicesBufferSize, const sLib3MFTriangle * pIndicesBuffer); + void SetGeometry(const Lib3MF_uint64 nVerticesBufferSize, const sLib3MFPosition * pVerticesBuffer, const Lib3MF_uint64 nIndicesBufferSize, const sLib3MFTriangle * pIndicesBuffer) override; - bool IsManifoldAndOriented(); + bool IsManifoldAndOriented() override; - bool IsMeshObject(); + bool IsMeshObject() override; - bool IsComponentsObject(); + bool IsComponentsObject() override; bool IsLevelSetObject() override; bool IsValid(); - virtual IBeamLattice * BeamLattice(); + virtual IBeamLattice * BeamLattice() override; - void SetObjectLevelProperty(const Lib3MF_uint32 nUniqueResourceID, const Lib3MF_uint32 nPropertyID); + void SetObjectLevelProperty(const Lib3MF_uint32 nUniqueResourceID, const Lib3MF_uint32 nPropertyID) override; - bool GetObjectLevelProperty(Lib3MF_uint32 & nUniqueResourceID, Lib3MF_uint32 & nPropertyID); + bool GetObjectLevelProperty(Lib3MF_uint32 & nUniqueResourceID, Lib3MF_uint32 & nPropertyID) override; - void SetTriangleProperties(const Lib3MF_uint32 nIndex, const sLib3MFTriangleProperties Properties); + void SetTriangleProperties(const Lib3MF_uint32 nIndex, const sLib3MFTriangleProperties Properties) override; - void GetTriangleProperties(const Lib3MF_uint32 nIndex, sLib3MFTriangleProperties & sProperty); + void GetTriangleProperties(const Lib3MF_uint32 nIndex, sLib3MFTriangleProperties & sProperty) override; - void SetAllTriangleProperties(const Lib3MF_uint64 nPropertiesArrayBufferSize, const sLib3MFTriangleProperties * pPropertiesArrayBuffer); + void SetAllTriangleProperties(const Lib3MF_uint64 nPropertiesArrayBufferSize, const sLib3MFTriangleProperties * pPropertiesArrayBuffer) override; - void GetAllTriangleProperties(Lib3MF_uint64 nPropertiesArrayBufferSize, Lib3MF_uint64* pPropertiesArrayNeededCount, sLib3MFTriangleProperties * pPropertiesArrayBuffer); + void GetAllTriangleProperties(Lib3MF_uint64 nPropertiesArrayBufferSize, Lib3MF_uint64* pPropertiesArrayNeededCount, sLib3MFTriangleProperties * pPropertiesArrayBuffer) override; - void ClearAllProperties(); + void ClearAllProperties() override; IVolumeData * GetVolumeData() override; void SetVolumeData(IVolumeData* pTheVolumeData) override; + + ITriangleSet* AddTriangleSet(const std::string& sIdentifier, const std::string& sName) override; + + bool HasTriangleSet(const std::string& sIdentifier) override; + + ITriangleSet* FindTriangleSet(const std::string& sIdentifier) override; + + Lib3MF_uint32 GetTriangleSetCount() override; + + ITriangleSet* GetTriangleSet(const Lib3MF_uint32 nIndex) override; }; } diff --git a/Include/API/lib3mf_triangleset.hpp b/Include/API/lib3mf_triangleset.hpp new file mode 100644 index 000000000..c15833aca --- /dev/null +++ b/Include/API/lib3mf_triangleset.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMeshObject + +*/ + + +#ifndef __LIB3MF_TRIANGLESET +#define __LIB3MF_TRIANGLESET + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_object.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" + +namespace Lib3MF { +namespace Impl { + +/************************************************************************************************************************* + Class declaration of CMeshObject +**************************************************************************************************************************/ + +class CTriangleSet : public virtual ITriangleSet, public virtual CBase { +protected: + NMR::PModelTriangleSet m_pTriangleSet; + NMR::PModelMeshObject m_pMeshObject; + +public: + /** + * Put additional public members here. They will not be visible in the external API. + */ + CTriangleSet(NMR::PModelTriangleSet pTriangleSet, NMR::PModelMeshObject pMeshObject); + + virtual ~CTriangleSet(); + + void SetName(const std::string& sName) override; + + std::string GetName() override; + + void SetIdentifier(const std::string& sIdentifier) override; + + std::string GetIdentifier() override; + + void AddTriangle(const Lib3MF_uint32 nTriangleIndex) override; + + void RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) override; + + void Clear() override; + + void SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) override; + + void GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64 * pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) override; + + void AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) override; + + void Merge(ITriangleSet* pOtherTriangleSet, const bool bDeleteOther) override; + + void DeleteSet() override; + + ITriangleSet* Duplicate(const std::string& sIdentifier) override; + + NMR::PModelTriangleSet triangleSet(); + +}; + +} +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_TRIANGLESET diff --git a/Include/Common/Mesh/NMR_Mesh.h b/Include/Common/Mesh/NMR_Mesh.h index adef011c6..1297bff2e 100644 --- a/Include/Common/Mesh/NMR_Mesh.h +++ b/Include/Common/Mesh/NMR_Mesh.h @@ -57,6 +57,8 @@ namespace NMR { MESHFACES m_Faces; CBeamLattice m_BeamLattice; + + PMeshInformationHandler m_pMeshInformationHandler; public: CMesh(); diff --git a/Include/Common/NMR_ErrorConst.h b/Include/Common/NMR_ErrorConst.h index 9a772e5d2..007b4f7e7 100644 --- a/Include/Common/NMR_ErrorConst.h +++ b/Include/Common/NMR_ErrorConst.h @@ -498,6 +498,25 @@ Core framework error codes (0x2XXX) // Invalid slice vertex index #define NMR_ERROR_INVALIDSLICEVERTEX 0x2041 +// Duplicate triangle set +#define NMR_ERROR_DUPLICATETRIANGLESET 0x2042 + +// Too many triangle sets +#define NMR_ERROR_TOOMANYTRIANGLESETS 0x2043 + +// Invalid triangle set attribute +#define NMR_ERROR_TRIANGLESETINVALIDATTRIBUTE 0x2044 + +// Missing triangle set reference index +#define NMR_ERROR_TRIANGLESETMISSINGREFERENCEINDEX 0x2045 + +// Triangle set name missing +#define NMR_ERROR_TRIANGLESETNAMEMISSING 0x2046 + +// Triangle set identifier missing +#define NMR_ERROR_TRIANGLESETIDENTIFIERMISSING 0x2047 + + /*------------------------------------------------------------------- Model error codes (0x8XXX) -------------------------------------------------------------------*/ diff --git a/Include/Model/Classes/NMR_ModelConstants.h b/Include/Model/Classes/NMR_ModelConstants.h index 7778b9905..b110fd649 100644 --- a/Include/Model/Classes/NMR_ModelConstants.h +++ b/Include/Model/Classes/NMR_ModelConstants.h @@ -80,6 +80,7 @@ These are given by the 3MF Standard #define XML_3MF_NAMESPACE_MATERIALSPEC "http://schemas.microsoft.com/3dmanufacturing/material/2015/02" #define XML_3MF_NAMESPACE_PRODUCTIONSPEC "http://schemas.microsoft.com/3dmanufacturing/production/2015/06" #define XML_3MF_NAMESPACE_BEAMLATTICESPEC "http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02" +#define XML_3MF_NAMESPACE_TRIANGLESETS "http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07" #define XML_3MF_NAMESPACE_SLICESPEC "http://schemas.microsoft.com/3dmanufacturing/slice/2015/07" #define XML_3MF_NAMESPACE_SECURECONTENTSPEC "http://schemas.microsoft.com/3dmanufacturing/securecontent/2019/04" #define XML_3MF_NAMESPACE_DIGITALSIGNATURESPEC "http://www.w3.org/2000/09/xmldsig#" @@ -94,6 +95,7 @@ These are given by the 3MF Standard #define XML_3MF_NAMESPACEPREFIX_SECURECONTENT "sc" #define XML_3MF_NAMESPACEPREFIX_VOLUMETRIC "v" #define XML_3MF_NAMESPACEPREFIX_IMPLICIT "i" +#define XML_3MF_NAMESPACEPREFIX_TRIANGLESETS "t" #define XML_3MF_ATTRIBUTE_XMLNS "xmlns" #define XML_3MF_ATTRIBUTE_PREFIX_XML "xml" @@ -149,6 +151,8 @@ These are given by the 3MF Standard #define XML_3MF_ELEMENT_BEAMSET "beamset" #define XML_3MF_ELEMENT_REF "ref" #define XML_3MF_ELEMENT_BALLREF "ballref" +#define XML_3MF_ELEMENT_TRIANGLESETS "trianglesets" +#define XML_3MF_ELEMENT_TRIANGLESET "triangleset" // Triangle element. #define XML_3MF_ELEMENT_TRIANGLE "triangle" @@ -188,6 +192,9 @@ These are given by the 3MF Standard // deprecated (has been used in draft version of the specification): #define XML_3MF_ATTRIBUTE_BEAMLATTICE_ACCURACY "accuracy" #define XML_3MF_ATTRIBUTE_BEAMLATTICE_PRECISION "precision" +#define XML_3MF_ATTRIBUTE_TRIANGLESET_IDENTIFIER "identifier" +#define XML_3MF_ATTRIBUTE_TRIANGLESET_NAME "name" +#define XML_3MF_ATTRIBUTE_TRIANGLESETREF_INDEX "index" // Vertex element. #define XML_3MF_ELEMENT_VERTEX "vertex" diff --git a/Include/Model/Classes/NMR_ModelMeshObject.h b/Include/Model/Classes/NMR_ModelMeshObject.h index f3cbf34af..cc0ce6b37 100644 --- a/Include/Model/Classes/NMR_ModelMeshObject.h +++ b/Include/Model/Classes/NMR_ModelMeshObject.h @@ -38,6 +38,7 @@ mesh object. #include "Common/Mesh/NMR_Mesh.h" #include "Model/Classes/NMR_ModelVolumeData.h" #include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" #include "Model/Classes/NMR_ModelMeshBeamLatticeAttributes.h" namespace NMR { @@ -54,6 +55,10 @@ namespace NMR { PModelVolumeData m_pVolumeData; PModelMeshBeamLatticeAttributes m_pBeamLatticeAttributes; + + std::map m_TriangleSetMap; + std::vector m_TriangleSets; + public: CModelMeshObject() = delete; CModelMeshObject(_In_ const ModelResourceID sID, _In_ CModel * pModel); @@ -87,6 +92,14 @@ namespace NMR { void setVolumeData(_In_ PModelVolumeData pVolumeData); ResourceDependencies getDependencies() override; + void deleteTriangleSet (_In_ CModelTriangleSet * pTriangleSet); + PModelTriangleSet addTriangleSet(const std::string& sIdentifier, const std::string& sName); + PModelTriangleSet addTriangleSet(PModelTriangleSet pModelTriangleSet); + PModelTriangleSet findTriangleSet (const std::string & sIdentifier); + uint32_t getTriangleSetCount(); + PModelTriangleSet getTriangleSet(const uint32_t nIndex); + + }; typedef std::shared_ptr PModelMeshObject; diff --git a/Include/Model/Classes/NMR_ModelTriangleSet.h b/Include/Model/Classes/NMR_ModelTriangleSet.h new file mode 100644 index 000000000..111a56a48 --- /dev/null +++ b/Include/Model/Classes/NMR_ModelTriangleSet.h @@ -0,0 +1,84 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELTRIANGLESET +#define __NMR_MODELTRIANGLESET + +#include "Common/NMR_Types.h" + +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_Model.h" +#include "Common/Platform/NMR_ImportStream.h" +#include + + +namespace NMR { + + class CModelTriangleSet; + typedef std::shared_ptr PModelTriangleSet; + + class CModelTriangleSet { + private: + + std::string m_sName; + std::string m_sIdentifier; + + std::set m_sTriangles; + + protected: + + + public: + CModelTriangleSet(_In_ const std::string& sName, _In_ const std::string& sIdentifier); + + CModelTriangleSet() = delete; + + static PModelTriangleSet make(_In_ const std::string & sName, _In_ const std::string & sIdentifier); + + std::string getName (); + std::string getIdentifier (); + + void setName (_In_ const std::string & sName); + void setIdentifier (_In_ const std::string & sIdentifier); + + void clear(); + void addTriangle(const uint32_t nTriangleIndex); + void removeTriangle(const uint32_t nTriangleIndex); + + PModelTriangleSet duplicate(const std::string & sIdentifier); + void merge (PModelTriangleSet pTriangleSet); + + std::set & getTriangles (); + + }; + +} + +#endif // __NMR_MODELTRIANGLESET + + diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h index 2bbb24dfd..51b50ac90 100644 --- a/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h @@ -40,6 +40,7 @@ A mesh reader model node is a parser for the mesh node of an XML Model Stream. #include "Model/Classes/NMR_ModelObject.h" #include "Model/Classes/NMR_ModelVolumeData.h" #include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" namespace NMR { @@ -47,6 +48,7 @@ namespace NMR { private: PModelMeshObject m_pMesh; CModel * m_pModel; + std::vector m_pTriangleSets; ModelResourceID m_nObjectLevelPropertyID; PPackageResourceID m_pObjectLevelPropertyID; @@ -72,6 +74,8 @@ namespace NMR { virtual void parseXML(_In_ CXmlReader * pXMLReader); void retrieveClippingInfo(_Out_ eModelBeamLatticeClipMode &eClipMode, _Out_ nfBool & bHasClippingMode, _Out_ ModelResourceID & nClippingMeshID); void retrieveRepresentationInfo(_Out_ nfBool & bHasRepresentation, _Out_ ModelResourceID & nRepresentationMeshID); + + std::vector getTriangleSets (); }; typedef std::shared_ptr PModelReaderNode100_Mesh; } diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h new file mode 100644 index 000000000..86a8c64b7 --- /dev/null +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h @@ -0,0 +1,63 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELREADERNODE100_TRIANGLESET +#define __NMR_MODELREADERNODE100_TRIANGLESET + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelComponent.h" +#include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" + +namespace NMR { + + class CModelReaderNode100_TriangleSet : public CModelReaderNode { + protected: + + std::string m_sName; + std::string m_sIdentifier; + + PModelTriangleSet m_pTriangleSet; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + virtual void OnNSChildElement(_In_z_ const nfChar* pChildName, _In_z_ const nfChar* pNameSpace, _In_ CXmlReader* pXMLReader); + + public: + CModelReaderNode100_TriangleSet() = delete; + CModelReaderNode100_TriangleSet(_In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + PModelTriangleSet createTriangleSet(); + }; + + typedef std::shared_ptr PModelReaderNode100_TriangleSet; + +} + +#endif // __NMR_MODELREADERNODE100_TRIANGLESET diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h new file mode 100644 index 000000000..2be0cc329 --- /dev/null +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h @@ -0,0 +1,55 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELREADERNODE100_TRIANGLESETREF +#define __NMR_MODELREADERNODE100_TRIANGLESETREF + +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR { + + class CModelReaderNode100_TriangleSetRef : public CModelReaderNode { + protected: + + uint32_t m_nIndex; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + public: + CModelReaderNode100_TriangleSetRef() = delete; + CModelReaderNode100_TriangleSetRef(_In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + uint32_t getIndex(); + }; + + typedef std::shared_ptr PModelReaderNode100_TriangleSetRef; + +} + +#endif // __NMR_MODELREADERNODE100_TRIANGLESETREF diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h new file mode 100644 index 000000000..d357c8eed --- /dev/null +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h @@ -0,0 +1,62 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELREADERNODE100_TRIANGLESETS +#define __NMR_MODELREADERNODE100_TRIANGLESETS + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelComponent.h" +#include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" + +namespace NMR { + + class CModelReaderNode100_TriangleSets : public CModelReaderNode { + protected: + CMesh * m_pMesh; + CModel * m_pModel; + + std::vector m_TriangleSets; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader); + + public: + CModelReaderNode100_TriangleSets() = delete; + CModelReaderNode100_TriangleSets(_In_ CModel * pModel, _In_ CMesh * pMesh, _In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + std::vector getTriangleSets (); + }; + + typedef std::shared_ptr PModelReaderNode100_TriangleSets; + +} + +#endif // __NMR_MODELREADERNODE100_TRIANGLESETS diff --git a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h index 94715edcd..072de84c3 100644 --- a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h +++ b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h @@ -56,6 +56,8 @@ This is the class for exporting the 3mf mesh node. #define MODELWRITERMESH100_BEAMLATTICE_REFSTARTLENGTH 14 #define MODELWRITERMESH100_BEAMLATTICE_BALLREFLINESTART " m_VertexLine; @@ -77,12 +80,14 @@ namespace NMR { std::array m_BallLine; std::array m_BeamRefLine; std::array m_BallRefLine; + std::array m_TriangleSetRefLine; nfUint32 m_nVertexBufferPos; nfUint32 m_nTriangleBufferPos; nfUint32 m_nBeamBufferPos; nfUint32 m_nBallBufferPos; nfUint32 m_nBeamRefBufferPos; nfUint32 m_nBallRefBufferPos; + nfUint32 m_nTriangleSetRefBufferPos; private: const int m_nPosAfterDecPoint; const nfInt64 m_nPutDoubleFactor; @@ -110,6 +115,9 @@ namespace NMR { __NMR_INLINE void putBallRefString(_In_ const nfChar * pszString); __NMR_INLINE void putBallRefUInt32(_In_ const nfUint32 nValue); + __NMR_INLINE void putTriangleSetRefString(_In_ const nfChar* pszString); + __NMR_INLINE void putTriangleSetRefUInt32(_In_ const nfUint32 nValue); + __NMR_INLINE void writeVertexData(_In_ MESHNODE * pNode); __NMR_INLINE void writeFaceData_Plain(_In_ MESHFACE * pFace, _In_opt_ const nfChar * pszAdditionalString); __NMR_INLINE void writeFaceData_OneProperty(_In_ MESHFACE * pFace, _In_ const ModelResourceID nPropertyID, _In_ const ModelResourceIndex nPropertyIndex, _In_opt_ const nfChar * pszAdditionalString); @@ -118,11 +126,12 @@ namespace NMR { __NMR_INLINE void writeBallData(_In_ MESHBALL * pBall, _In_ eModelBeamLatticeBallMode eBallMode, _In_ nfDouble dRadius); __NMR_INLINE void writeRefData(_In_ INT nRefID); __NMR_INLINE void writeBallRefData(_In_ INT nRefID); + __NMR_INLINE void writeTriangleSetRefData(_In_ INT nRefID); public: CModelWriterNode100_Mesh() = delete; CModelWriterNode100_Mesh(_In_ CModelMeshObject * pModelMeshObject, _In_ CXmlWriter * pXMLWriter, _In_ PProgressMonitor pProgressMonitor, _In_ PMeshInformation_PropertyIndexMapping pPropertyIndexMapping, _In_ int nPosAfterDecPoint, _In_ nfBool bWriteMaterialExtension, _In_ nfBool m_bWriteBeamLatticeExtension, - _In_ nfBool bWriteVolumetricExtension); + _In_ nfBool bWriteVolumetricExtension, _In_ nfBool bWriteTriangleSetExtension); virtual void writeToXML(); }; diff --git a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h index d4eecb5de..6d6689714 100644 --- a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h +++ b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h @@ -54,6 +54,7 @@ namespace NMR { nfBool m_bWriteMaterialExtension; nfBool m_bWriteProductionExtension; nfBool m_bWriteBeamLatticeExtension; + nfBool m_bWriteTriangleSetExtension; nfBool m_bWriteNurbsExtension; nfBool m_bWriteSliceExtension; nfBool m_bWriteSecureContentExtension; diff --git a/Source/API/lib3mf_meshobject.cpp b/Source/API/lib3mf_meshobject.cpp index ca2f92a2d..d8d71d977 100644 --- a/Source/API/lib3mf_meshobject.cpp +++ b/Source/API/lib3mf_meshobject.cpp @@ -29,6 +29,7 @@ Abstract: This is a stub class definition of CMeshObject */ #include "lib3mf_meshobject.hpp" #include "lib3mf_interfaceexception.hpp" +#include "lib3mf_triangleset.hpp" #include "lib3mf_beamlattice.hpp" #include "lib3mf_volumedata.hpp" @@ -424,4 +425,44 @@ void CMeshObject::SetVolumeData(IVolumeData* pTheVolumeData) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT, "Referenced Resource is not of type VolumeData"); meshObject()->setVolumeData(pVolumeData); -} \ No newline at end of file +} + +ITriangleSet* CMeshObject::AddTriangleSet(const std::string& sIdentifier, const std::string& sName) +{ + return new CTriangleSet(meshObject()->addTriangleSet(sIdentifier, sName), meshObject()); +} + +bool CMeshObject::HasTriangleSet(const std::string& sIdentifier) +{ + auto pTriangleSet = meshObject()->findTriangleSet(sIdentifier); + return (pTriangleSet.get() != nullptr); +} + +ITriangleSet* CMeshObject::FindTriangleSet(const std::string& sIdentifier) +{ + auto pMeshObject = meshObject(); + auto pTriangleSet = pMeshObject->findTriangleSet(sIdentifier); + if (pTriangleSet.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_COULDNOTFINDTRIANGLESET); + + return new CTriangleSet(pTriangleSet, pMeshObject); + +} + +Lib3MF_uint32 CMeshObject::GetTriangleSetCount() +{ + return meshObject()->getTriangleSetCount(); +} + +ITriangleSet* CMeshObject::GetTriangleSet(const Lib3MF_uint32 nIndex) +{ + auto pMeshObject = meshObject(); + auto nTriangleSetCount = pMeshObject->getTriangleSetCount(); + if (nIndex >= nTriangleSetCount) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDTRIANGLESETINDEX); + + auto pTriangleSet = meshObject()->getTriangleSet (nIndex); + + return new CTriangleSet(pTriangleSet, pMeshObject); +} + diff --git a/Source/API/lib3mf_triangleset.cpp b/Source/API/lib3mf_triangleset.cpp new file mode 100644 index 000000000..7c84df6a3 --- /dev/null +++ b/Source/API/lib3mf_triangleset.cpp @@ -0,0 +1,161 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMeshObject + +*/ +#include "lib3mf_triangleset.hpp" +#include "lib3mf_interfaceexception.hpp" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" +#include "Model/Classes/NMR_ModelMeshObject.h" + +#include + +using namespace Lib3MF::Impl; + +CTriangleSet::CTriangleSet(NMR::PModelTriangleSet pTriangleSet, NMR::PModelMeshObject pMeshObject) + : m_pTriangleSet (pTriangleSet), m_pMeshObject (pMeshObject) +{ + if (pTriangleSet.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + if (pMeshObject.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + +} + +CTriangleSet::~CTriangleSet() +{ + +} + +void CTriangleSet::SetName(const std::string& sName) +{ + m_pTriangleSet->setName(sName); +} + +std::string CTriangleSet::GetName() +{ + return m_pTriangleSet->getName(); +} + +void CTriangleSet::SetIdentifier(const std::string& sIdentifier) +{ + m_pTriangleSet->setIdentifier(sIdentifier); +} + +std::string CTriangleSet::GetIdentifier() +{ + return m_pTriangleSet->getIdentifier(); +} + +void CTriangleSet::AddTriangle(const Lib3MF_uint32 nTriangleIndex) +{ + m_pTriangleSet->addTriangle(nTriangleIndex); +} + +void CTriangleSet::RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) +{ + m_pTriangleSet->removeTriangle(nTriangleIndex); +} + +void CTriangleSet::Clear() +{ + m_pTriangleSet->clear(); +} + +void CTriangleSet::SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) +{ + if (pTriangleIndicesBuffer) { + m_pTriangleSet->clear(); + const uint32_t* pPtr = pTriangleIndicesBuffer; + for (uint64_t nIndex = 0; nIndex < nTriangleIndicesBufferSize; nIndex++) { + m_pTriangleSet->addTriangle(*pPtr); + pPtr++; + } + } +} + +void CTriangleSet::GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64 * pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + auto triangleIndicesSet = m_pTriangleSet->getTriangles(); + Lib3MF_uint32 count = (Lib3MF_uint32)triangleIndicesSet.size(); + if (pTriangleIndicesNeededCount) + *pTriangleIndicesNeededCount = count; + + if (nTriangleIndicesBufferSize >= count && pTriangleIndicesBuffer) + { + Lib3MF_uint32* pIndex = pTriangleIndicesBuffer; + for (auto index : triangleIndicesSet) + { + *pIndex = index; + pIndex++; + } + } +} + +void CTriangleSet::AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) +{ + if (pTriangleIndicesBuffer) { + const uint32_t* pPtr = pTriangleIndicesBuffer; + for (uint64_t nIndex = 0; nIndex < nTriangleIndicesBufferSize; nIndex++) { + m_pTriangleSet->addTriangle(*pPtr); + pPtr++; + } + } + +} + +void CTriangleSet::Merge(ITriangleSet* pOtherTriangleSet, const bool bDeleteOther) +{ + if (pOtherTriangleSet == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + auto pOtherTriangleSetInstance = dynamic_cast (pOtherTriangleSet); + if (pOtherTriangleSetInstance == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + m_pTriangleSet->merge (pOtherTriangleSetInstance->triangleSet()); + + if (bDeleteOther) + pOtherTriangleSet->DeleteSet(); +} + +void CTriangleSet::DeleteSet() +{ + m_pMeshObject->deleteTriangleSet (m_pTriangleSet.get ()); +} + +ITriangleSet* CTriangleSet::Duplicate(const std::string& sIdentifier) +{ + return new CTriangleSet(m_pTriangleSet->duplicate (sIdentifier), m_pMeshObject); +} + +NMR::PModelTriangleSet CTriangleSet::triangleSet() +{ + return m_pTriangleSet; +} \ No newline at end of file diff --git a/Source/Common/NMR_Exception.cpp b/Source/Common/NMR_Exception.cpp index 8a45470a1..706f8bb83 100644 --- a/Source/Common/NMR_Exception.cpp +++ b/Source/Common/NMR_Exception.cpp @@ -192,6 +192,15 @@ namespace NMR { case NMR_ERROR_INVALIDMESHINFORMATIONDATA: return "Mesh Information Block was not assigned"; case NMR_ERROR_INVALIDMESHINFORMATION: return "Mesh Information Object was not assigned"; case NMR_ERROR_TOOMANYBEAMS: return "The mesh exceeds more than NMR_MESH_MAXBEAMCOUNT (2^31-1, around two billion) beams"; + case NMR_ERROR_TOOMANYBALLS: return "The mesh exceeds more than NMR_MESH_MAXBALLCOUNT (2^31-1, around two billion) balls"; + case NMR_ERROR_INVALIDSLICEPOLYGON: return "Invalid slice polygon index"; + case NMR_ERROR_INVALIDSLICEVERTEX: return "Invalid slice vertex index"; + case NMR_ERROR_DUPLICATETRIANGLESET: return "Duplicate triangle set"; + case NMR_ERROR_TOOMANYTRIANGLESETS: return "Too many triangle sets"; + case NMR_ERROR_TRIANGLESETINVALIDATTRIBUTE: return "Invalid triangle set attribute"; + case NMR_ERROR_TRIANGLESETMISSINGREFERENCEINDEX: return "Missing triangle set reference index"; + case NMR_ERROR_TRIANGLESETNAMEMISSING: return "Triangle set name missing"; + case NMR_ERROR_TRIANGLESETIDENTIFIERMISSING : return "Triangle set identifier missing"; // Model error codes (0x8XXX) case NMR_ERROR_OPCREADFAILED: return "3MF Loading - OPC could not be loaded"; diff --git a/Source/Model/Classes/NMR_ModelMeshObject.cpp b/Source/Model/Classes/NMR_ModelMeshObject.cpp index 8100bd280..c318f1604 100644 --- a/Source/Model/Classes/NMR_ModelMeshObject.cpp +++ b/Source/Model/Classes/NMR_ModelMeshObject.cpp @@ -36,6 +36,8 @@ mesh object. #include "Model/Classes/NMR_ModelMeshObject.h" #include "Common/Math/NMR_PairMatchingTree.h" +#define TRIANGLESET_MAXCOUNT (1024 * 1024 * 1024) + namespace NMR { CModelMeshObject::CModelMeshObject(_In_ const ModelResourceID sID, _In_ CModel * pModel) @@ -250,6 +252,81 @@ namespace NMR { return dependencies; } + + void CModelMeshObject::deleteTriangleSet(_In_ CModelTriangleSet* pTriangleSet) + { + if (pTriangleSet != nullptr) { + auto sIdentifier = pTriangleSet->getIdentifier(); + m_TriangleSets.erase(std::remove_if( + m_TriangleSets.begin(), + m_TriangleSets.end(), + [sIdentifier](PModelTriangleSet const& pSet) { return (pSet->getIdentifier() == sIdentifier); } + )); + + m_TriangleSetMap.erase(sIdentifier); + + } + } + + PModelTriangleSet CModelMeshObject::findTriangleSet(const std::string& sIdentifier) + { + auto iIterator = m_TriangleSetMap.find(sIdentifier); + if (iIterator == m_TriangleSetMap.end()) + return nullptr; + + return iIterator->second; + + } + + PModelTriangleSet CModelMeshObject::addTriangleSet(const std::string& sIdentifier, const std::string& sName) + { + auto iIterator = m_TriangleSetMap.find(sIdentifier); + if (iIterator != m_TriangleSetMap.end()) + throw CNMRException(NMR_ERROR_DUPLICATETRIANGLESET); + + if (m_TriangleSets.size() >= TRIANGLESET_MAXCOUNT) + throw CNMRException(NMR_ERROR_TOOMANYTRIANGLESETS); + + auto pTriangleSet = std::make_shared(sName, sIdentifier); + m_TriangleSets.push_back(pTriangleSet); + m_TriangleSetMap.insert(std::make_pair (sIdentifier, pTriangleSet)); + + return pTriangleSet; + + } + + PModelTriangleSet CModelMeshObject::addTriangleSet(PModelTriangleSet pModelTriangleSet) + { + if (pModelTriangleSet.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + auto iIterator = m_TriangleSetMap.find(pModelTriangleSet->getIdentifier()); + if (iIterator != m_TriangleSetMap.end()) + throw CNMRException(NMR_ERROR_DUPLICATETRIANGLESET); + + if (m_TriangleSets.size() >= TRIANGLESET_MAXCOUNT) + throw CNMRException(NMR_ERROR_TOOMANYTRIANGLESETS); + + m_TriangleSets.push_back(pModelTriangleSet); + m_TriangleSetMap.insert(std::make_pair(pModelTriangleSet->getIdentifier(), pModelTriangleSet)); + + return pModelTriangleSet; + } + + uint32_t CModelMeshObject::getTriangleSetCount() + { + return (uint32_t)m_TriangleSets.size(); + } + + PModelTriangleSet CModelMeshObject::getTriangleSet(const uint32_t nIndex) + { + if (nIndex >= m_TriangleSets.size()) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return m_TriangleSets[nIndex]; + + } + } diff --git a/Source/Model/Classes/NMR_ModelTriangleSet.cpp b/Source/Model/Classes/NMR_ModelTriangleSet.cpp new file mode 100644 index 000000000..b25bdf666 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelTriangleSet.cpp @@ -0,0 +1,115 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +--*/ + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + + CModelTriangleSet::CModelTriangleSet(_In_ const std::string& sName, _In_ const std::string& sIdentifier) + : m_sName (sName), m_sIdentifier (sIdentifier) + { + + } + + PModelTriangleSet CModelTriangleSet::make(_In_ const std::string& sName, _In_ const std::string& sIdentifier) + { + return std::make_shared(sName, sIdentifier); + } + + std::string CModelTriangleSet::getName() + { + return m_sName; + } + + std::string CModelTriangleSet::getIdentifier() + { + return m_sIdentifier; + } + + void CModelTriangleSet::setName(_In_ const std::string& sName) + { + m_sName = sName; + } + + void CModelTriangleSet::setIdentifier(_In_ const std::string& sIdentifier) + { + m_sIdentifier = sIdentifier; + } + + void CModelTriangleSet::clear() + { + m_sTriangles.clear(); + } + + void CModelTriangleSet::addTriangle(const uint32_t nTriangleIndex) + { + m_sTriangles.insert(nTriangleIndex); + } + + void CModelTriangleSet::removeTriangle(const uint32_t nTriangleIndex) + { + m_sTriangles.erase(nTriangleIndex); + } + + PModelTriangleSet CModelTriangleSet::duplicate(const std::string& sIdentifier) + { + auto pTriangleSet = std::make_shared(m_sName, sIdentifier); + + for (auto nTriangleIndex : m_sTriangles) + { + pTriangleSet->m_sTriangles.insert(nTriangleIndex); + } + + return pTriangleSet; + } + + void CModelTriangleSet::merge(PModelTriangleSet pTriangleSet) + { + if (pTriangleSet.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + for (auto nTriangleIndex : pTriangleSet->m_sTriangles) + { + m_sTriangles.insert(nTriangleIndex); + } + + } + + std::set& CModelTriangleSet::getTriangles() + { + return m_sTriangles; + + } +} diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp index 35bad5fd0..13e891d3e 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp @@ -34,6 +34,7 @@ A mesh reader model node is a parser for the mesh node of an XML Model Stream. #include "Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h" #include "Model/Reader/v100/NMR_ModelReaderNode100_Vertices.h" #include "Model/Reader/v100/NMR_ModelReaderNode100_Triangles.h" +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h" #include "Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_BeamLattice.h" #include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.h" @@ -194,6 +195,23 @@ namespace NMR { m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); } + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_TRIANGLESETS) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_TRIANGLESETS) == 0) + { + PModelReaderNode100_TriangleSets pXMLNode = std::make_shared(m_pModel, m_pMesh->getMesh(), m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + m_pTriangleSets = pXMLNode->getTriangleSets (); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + + } + + std::vector CModelReaderNode100_Mesh::getTriangleSets() + { + return m_pTriangleSets; } } diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp index ef1d0d84f..2fca11dfa 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp @@ -250,6 +250,11 @@ namespace NMR { m_pWarnings, m_pProgressMonitor, m_pObjectLevelPropertyID, m_nObjectLevelPropertyIndex); pXMLNode->parseXML(pXMLReader); + // store triangle sets in memory model + auto triangleSets = pXMLNode->getTriangleSets(); + for (auto triangleSet : triangleSets) + meshObject->addTriangleSet(triangleSet); + // Add Object to Parent m_pModel->addResource(m_pObject); diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.cpp new file mode 100644 index 000000000..171a1d376 --- /dev/null +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.cpp @@ -0,0 +1,100 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h" +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + CModelReaderNode100_TriangleSet::CModelReaderNode100_TriangleSet(_In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + } + + void CModelReaderNode100_TriangleSet::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + m_pTriangleSet = std::make_shared(m_sName, m_sIdentifier); + + // Parse Content + parseContent(pXMLReader); + } + + + void CModelReaderNode100_TriangleSet::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + __NMRASSERT(pAttributeName); + __NMRASSERT(pAttributeValue); + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TRIANGLESET_NAME) == 0) { + m_sName = pAttributeValue; + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TRIANGLESET_IDENTIFIER) == 0) { + m_sIdentifier = pAttributeValue; + } + } + + void CModelReaderNode100_TriangleSet::OnNSChildElement(_In_z_ const nfChar* pChildName, _In_z_ const nfChar* pNameSpace, _In_ CXmlReader* pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_TRIANGLESETS) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_REF) == 0) + { + PModelReaderNode100_TriangleSetRef pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + m_pTriangleSet->addTriangle(pXMLNode->getIndex()); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + + } + + + PModelTriangleSet CModelReaderNode100_TriangleSet::createTriangleSet() + { + return m_pTriangleSet; + } + +} diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.cpp new file mode 100644 index 000000000..4e5468706 --- /dev/null +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.cpp @@ -0,0 +1,89 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelReaderNode100_Triangle.cpp implements the Model Reader Triangle Node +Class. A triangle reader model node is a parser for the triangle node of an +XML Model Stream. + +--*/ + +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + CModelReaderNode100_TriangleSetRef::CModelReaderNode100_TriangleSetRef(_In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings), m_nIndex (0xffffffff) + { + } + + void CModelReaderNode100_TriangleSetRef::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + + void CModelReaderNode100_TriangleSetRef::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + __NMRASSERT(pAttributeName); + __NMRASSERT(pAttributeValue); + + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TRIANGLESETREF_INDEX) == 0) { + nfInt32 nValue = fnStringToInt32(pAttributeValue); + if ((nValue >= 0) && (nValue < XML_3MF_MAXRESOURCEINDEX)) + m_nIndex = nValue; + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_TRIANGLESETINVALIDATTRIBUTE), mrwInvalidMandatoryValue); + + } + + + uint32_t CModelReaderNode100_TriangleSetRef::getIndex() + { + if (m_nIndex >= XML_3MF_MAXRESOURCEINDEX) + m_pWarnings->addException(CNMRException(NMR_ERROR_TRIANGLESETMISSINGREFERENCEINDEX), mrwInvalidMandatoryValue); + + return m_nIndex; + } + +} diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.cpp new file mode 100644 index 000000000..593608bb6 --- /dev/null +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.cpp @@ -0,0 +1,102 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelReaderNode100_Triangles.cpp implements the Model Reader Triangles Node +Class. A triangles reader model node is a parser for the triangles node of an +XML Model Stream. + +--*/ + +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h" +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Common/NMR_StringUtils.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" + +namespace NMR { + + CModelReaderNode100_TriangleSets::CModelReaderNode100_TriangleSets(_In_ CModel * pModel, _In_ CMesh * pMesh, + _In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + __NMRASSERT(pMesh); + __NMRASSERT(pModel); + + m_pModel = pModel; + m_pMesh = pMesh; + } + + void CModelReaderNode100_TriangleSets::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse Name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + void CModelReaderNode100_TriangleSets::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + __NMRASSERT(pAttributeName); + __NMRASSERT(pAttributeValue); + } + + + + void CModelReaderNode100_TriangleSets::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_TRIANGLESETS) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_TRIANGLESET) == 0) + { + PModelReaderNode100_TriangleSet pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + m_TriangleSets.push_back(pXMLNode->createTriangleSet ()); + + + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + + } + + std::vector CModelReaderNode100_TriangleSets::getTriangleSets() + { + return m_TriangleSets; + } +} diff --git a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp index 0cdeb444a..6894fd12e 100644 --- a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp +++ b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp @@ -51,7 +51,7 @@ This is the class for exporting the 3mf mesh node. namespace NMR { CModelWriterNode100_Mesh::CModelWriterNode100_Mesh(_In_ CModelMeshObject * pModelMeshObject, _In_ CXmlWriter * pXMLWriter, _In_ PProgressMonitor pProgressMonitor, - _In_ PMeshInformation_PropertyIndexMapping pPropertyIndexMapping, _In_ int nPosAfterDecPoint, _In_ nfBool bWriteMaterialExtension, _In_ nfBool bWriteBeamLatticeExtension, _In_ nfBool bWriteVolumetricExtension) + _In_ PMeshInformation_PropertyIndexMapping pPropertyIndexMapping, _In_ int nPosAfterDecPoint, _In_ nfBool bWriteMaterialExtension, _In_ nfBool bWriteBeamLatticeExtension, _In_ nfBool bWriteVolumetricExtension, _In_ nfBool bWriteTriangleSetExtension) :CModelWriterNode_ModelBase(pModelMeshObject->getModel(), pXMLWriter, pProgressMonitor), m_nPosAfterDecPoint(nPosAfterDecPoint), m_nPutDoubleFactor((nfInt64)(pow(10, CModelWriterNode100_Mesh::m_nPosAfterDecPoint))) { __NMRASSERT(pModelMeshObject != nullptr); @@ -61,6 +61,7 @@ namespace NMR { m_bWriteMaterialExtension = bWriteMaterialExtension; m_bWriteBeamLatticeExtension = bWriteBeamLatticeExtension; m_bWriteVolumetricExtension = bWriteVolumetricExtension; + m_bWriteTriangleSetExtension = bWriteTriangleSetExtension; m_pModelMeshObject = pModelMeshObject; m_pPropertyIndexMapping = pPropertyIndexMapping; @@ -72,12 +73,14 @@ namespace NMR { m_nBallBufferPos = 0; m_nBeamRefBufferPos = 0; m_nBallRefBufferPos = 0; + m_nTriangleSetRefBufferPos = 0; putVertexString(MODELWRITERMESH100_VERTEXLINESTART); putTriangleString(MODELWRITERMESH100_TRIANGLELINESTART); putBeamString(MODELWRITERMESH100_BEAMLATTICE_BEAMLINESTART); putBallString(MODELWRITERMESH100_BEAMLATTICE_BALLLINESTART); putBeamRefString(MODELWRITERMESH100_BEAMLATTICE_REFLINESTART); putBallRefString(MODELWRITERMESH100_BEAMLATTICE_BALLREFLINESTART); + putTriangleSetRefString(MODELWRITERMESH100_TRIANGLESETS_REFLINESTART); } bool stringRepresentationsDiffer(double a, double b, nfInt64 putFactor) { @@ -262,6 +265,32 @@ namespace NMR { } writeFullEndElement(); + + if (m_bWriteTriangleSetExtension) { + uint32_t nTriangleSetCount = m_pModelMeshObject->getTriangleSetCount(); + + if (nTriangleSetCount > 0) { + writeStartElementWithPrefix(XML_3MF_ELEMENT_TRIANGLESETS, XML_3MF_NAMESPACEPREFIX_TRIANGLESETS); + + for (uint32_t nTriangleSetIndex = 0; nTriangleSetIndex < nTriangleSetCount; nTriangleSetIndex++) { + auto pTriangleSet = m_pModelMeshObject->getTriangleSet(nTriangleSetIndex); + writeStartElementWithPrefix(XML_3MF_ELEMENT_TRIANGLESET, XML_3MF_NAMESPACEPREFIX_TRIANGLESETS); + writeStringAttribute(XML_3MF_ATTRIBUTE_TRIANGLESET_IDENTIFIER, pTriangleSet->getIdentifier ()); + writeStringAttribute(XML_3MF_ATTRIBUTE_TRIANGLESET_NAME, pTriangleSet->getName()); + + auto triangleRefs = pTriangleSet->getTriangles(); + for (auto triangleRef : triangleRefs) { + writeTriangleSetRefData (triangleRef); + } + + writeFullEndElement(); + } + + writeFullEndElement(); + } + } + + if (bMeshHasAProperty && !(nObjectLevelPropertyID != 0)) { throw CNMRException(NMR_ERROR_MISSINGOBJECTLEVELPID); } @@ -610,6 +639,34 @@ namespace NMR { m_nBeamRefBufferPos += nCount; } + void CModelWriterNode100_Mesh::putTriangleSetRefString(_In_ const nfChar* pszString) + { + __NMRASSERT(pszString); + const nfChar* pChar = pszString; + nfChar* pTarget = &m_TriangleSetRefLine[m_nTriangleSetRefBufferPos]; + + while (*pChar != 0) { + *pTarget = *pChar; + pTarget++; + pChar++; + m_nTriangleSetRefBufferPos++; + } + } + + void CModelWriterNode100_Mesh::putTriangleSetRefUInt32(_In_ const nfUint32 nValue) + { +#ifdef __GNUC__ + int nCount = sprintf(&m_TriangleSetRefLine[m_nTriangleSetRefBufferPos], "%d", nValue); +#else + int nCount = sprintf_s(&m_TriangleSetRefLine[m_nTriangleSetRefBufferPos], MODELWRITERMESH100_LINEBUFFERSIZE - m_nTriangleSetRefBufferPos, "%d", nValue); +#endif // __GNUC__ + + if (nCount < 1) + throw CNMRException(NMR_ERROR_COULDNOTCONVERTNUMBER); + m_nTriangleSetRefBufferPos += nCount; + } + + void CModelWriterNode100_Mesh::putBallRefString(_In_ const nfChar* pszString) { __NMRASSERT(pszString); @@ -792,4 +849,12 @@ namespace NMR { m_pXMLWriter->WriteRawLine(&m_BallRefLine[0], m_nBallRefBufferPos); } + __NMR_INLINE void CModelWriterNode100_Mesh::writeTriangleSetRefData(_In_ INT nRefID) + { + m_nTriangleSetRefBufferPos = MODELWRITERMESH100_TRIANGLESETS_REFSTARTLENGTH; + putTriangleSetRefUInt32(nRefID); + putTriangleSetRefString("\"/>"); + m_pXMLWriter->WriteRawLine(&m_TriangleSetRefLine[0], m_nTriangleSetRefBufferPos); + } + } diff --git a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp index 35b9965de..fc586f66d 100644 --- a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp +++ b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp @@ -80,6 +80,7 @@ namespace NMR { m_bWriteBeamLatticeExtension = true; m_bWriteSliceExtension = true; m_bWriteSecureContentExtension = true; + m_bWriteTriangleSetExtension = true; m_bWriteBaseMaterials = true; m_bWriteObjects = true; m_bWriteVolumetricExtension = true; @@ -166,6 +167,15 @@ namespace NMR { } } + if (m_bWriteTriangleSetExtension) { + writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_TRIANGLESETS, XML_3MF_NAMESPACE_TRIANGLESETS); + if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_TRIANGLESETS)) { + if (sRequiredExtensions.size() > 0) + sRequiredExtensions = sRequiredExtensions + " "; + sRequiredExtensions = sRequiredExtensions + XML_3MF_NAMESPACEPREFIX_TRIANGLESETS; + } + } + if (m_bWriteSecureContentExtension) { writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_SECURECONTENT, XML_3MF_NAMESPACE_SECURECONTENTSPEC); if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_SECURECONTENTSPEC)) { @@ -603,7 +613,7 @@ namespace NMR { pMeshObject, m_pXMLWriter, m_pProgressMonitor, m_pPropertyIndexMapping, m_nDecimalPrecision, m_bWriteMaterialExtension, m_bWriteBeamLatticeExtension, - m_bWriteVolumetricExtension); + m_bWriteVolumetricExtension, m_bWriteTriangleSetExtension); ModelWriter_Mesh.writeToXML(); } diff --git a/Tests/CPP_Bindings/CMakeLists.txt b/Tests/CPP_Bindings/CMakeLists.txt index 63daeeff4..ffdceb7a8 100644 --- a/Tests/CPP_Bindings/CMakeLists.txt +++ b/Tests/CPP_Bindings/CMakeLists.txt @@ -40,6 +40,7 @@ set(SRCS_UNITTEST ./Source/Volumetric.cpp ./Source/Wrapper.cpp ./Source/Writer.cpp + ./Source/TriangleSets.cpp ) set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_BINARY_DIR}) diff --git a/Tests/CPP_Bindings/Source/TriangleSets.cpp b/Tests/CPP_Bindings/Source/TriangleSets.cpp new file mode 100644 index 000000000..42427937b --- /dev/null +++ b/Tests/CPP_Bindings/Source/TriangleSets.cpp @@ -0,0 +1,190 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +UnitTest_MeshObject.cpp: Defines Unittests for the mesh object class + +--*/ + +#include "UnitTest_Utilities.h" +#include "lib3mf_implicit.hpp" + +namespace Lib3MF +{ + class TriangleSet : public Lib3MFTest { + protected: + virtual void SetUp() { + float fSizeX = 100.0f; + float fSizeY = 200.0f; + float fSizeZ = 300.0f; + + // Manually create vertices + pVertices[0] = fnCreateVertex(0.0f, 0.0f, 0.0f); + pVertices[1] = fnCreateVertex(fSizeX, 0.0f, 0.0f); + pVertices[2] = fnCreateVertex(fSizeX, fSizeY, 0.0f); + pVertices[3] = fnCreateVertex(0.0f, fSizeY, 0.0f); + pVertices[4] = fnCreateVertex(0.0f, 0.0f, fSizeZ); + pVertices[5] = fnCreateVertex(fSizeX, 0.0f, fSizeZ); + pVertices[6] = fnCreateVertex(fSizeX, fSizeY, fSizeZ); + pVertices[7] = fnCreateVertex(0.0f, fSizeY, fSizeZ); + + // Manually create triangles + pTriangles[0] = fnCreateTriangle(2, 1, 0); + pTriangles[1] = fnCreateTriangle(0, 3, 2); + pTriangles[2] = fnCreateTriangle(4, 5, 6); + pTriangles[3] = fnCreateTriangle(6, 7, 4); + pTriangles[4] = fnCreateTriangle(0, 1, 5); + pTriangles[5] = fnCreateTriangle(5, 4, 0); + pTriangles[6] = fnCreateTriangle(2, 3, 7); + pTriangles[7] = fnCreateTriangle(7, 6, 2); + pTriangles[8] = fnCreateTriangle(1, 2, 6); + pTriangles[9] = fnCreateTriangle(6, 5, 1); + pTriangles[10] = fnCreateTriangle(3, 0, 4); + pTriangles[11] = fnCreateTriangle(4, 7, 3); + + model = wrapper->CreateModel(); + mesh = model->AddMeshObject(); + } + virtual void TearDown() { + model.reset(); + } + + static PModel model; + static PMeshObject mesh; + static PTriangleSet triangleSet; + static sPosition pVertices[8]; + static sTriangle pTriangles[12]; + static std::string InFolder; + static std::string OutFolder; + static PWrapper wrapper; + + static void SetUpTestCase() { + wrapper = CWrapper::loadLibrary(); + } + }; + + PWrapper TriangleSet::wrapper; + PModel TriangleSet::model; + PMeshObject TriangleSet::mesh; + sPosition TriangleSet::pVertices[8]; + sTriangle TriangleSet::pTriangles[12]; + std::string TriangleSet::InFolder(sTestFilesPath + "/TriangleSets/"); + std::string TriangleSet::OutFolder(sOutFilesPath + "/TriangleSets/"); + + TEST_F(TriangleSet, meshTriangleSet) + { + mesh->SetGeometry(CLib3MFInputVector(pVertices, 8), CLib3MFInputVector(pTriangles, 12)); + ASSERT_EQ(mesh->GetVertexCount(), 8); + ASSERT_EQ(mesh->GetTriangleCount(), 12); + + auto numTriangles = mesh->GetTriangleCount(); + mesh->AddTriangleSet("test_id", "test_name"); + PTriangleSet triSet = mesh->GetTriangleSet(0); + for (Lib3MF_uint32 i = 0; i < numTriangles; i += 2) + { + triSet->AddTriangle(i); + } + std::vector triangleIndices; + triSet->GetTriangleList(triangleIndices); + ASSERT_EQ(triSet->GetName(), "test_name"); + ASSERT_EQ(triSet->GetIdentifier(), "test_id"); + ASSERT_EQ(triangleIndices.size(), 6); + + // check adding duplicate + triSet->AddTriangle(0); + std::vector triangleIndices2; + triSet->GetTriangleList(triangleIndices2); + ASSERT_EQ(triangleIndices2.size(), 6); + + mesh->AddTriangleSet("test_id_1", "test_name"); + auto triSet1 = mesh->FindTriangleSet("test_id_1"); + triSet1->AddTriangle(1); + triSet1->AddTriangle(3); + std::vector triangleIndices3; + triSet1->GetTriangleList(triangleIndices3); + ASSERT_EQ(triangleIndices3.size(), 2); + + ASSERT_EQ(mesh->GetTriangleSetCount(), 2); + + ASSERT_FALSE(mesh->HasTriangleSet("test")); + + triSet1->DeleteSet(); + + ASSERT_EQ(mesh->GetTriangleSetCount(), 1); + + ASSERT_FALSE(mesh->HasTriangleSet("test_id_1")); + + mesh->AddTriangleSet("test_id_2", "test_name_2"); + auto triSet2 = mesh->FindTriangleSet("test_id_2"); + triSet2->AddTriangle(1); + triSet2->AddTriangle(3); + + triSet2->Merge(triSet, false); + + std::vector triangleIndices4; + triSet2->GetTriangleList(triangleIndices4); + ASSERT_EQ(triangleIndices4.size(), 8); + + } + + TEST_F(TriangleSet, meshTriangleSetReaderWriter) + { + mesh->SetGeometry(CLib3MFInputVector(pVertices, 8), CLib3MFInputVector(pTriangles, 12)); + auto numTriangles = mesh->GetTriangleCount(); + mesh->AddTriangleSet("test_id", "test_name"); + PTriangleSet triSet = mesh->GetTriangleSet(0); + for (Lib3MF_uint32 i = 0; i < numTriangles; i++) + { + triSet->AddTriangle(i); + } + PWriter writer = model->QueryWriter("3mf"); + std::vector buffer; + writer->WriteToBuffer(buffer); + + PModel model2 = wrapper->CreateModel(); + PReader reader3 = model2->QueryReader("3mf"); + reader3->ReadFromBuffer(buffer); + + ASSERT_EQ(model2->GetMeshObjects()->Count(), 1); + + PMeshObject mesh2 = model2->GetMeshObjectByID(1); + ASSERT_TRUE(mesh2->HasTriangleSet("test_id")); + ASSERT_EQ(mesh2->GetTriangleSetCount(), 1); + + PTriangleSet triSet2 = mesh2->GetTriangleSet(0); + ASSERT_EQ(triSet2->GetName(), "test_name"); + + std::vector triangleIndices; + triSet2->GetTriangleList(triangleIndices); + ASSERT_EQ(triangleIndices.size(), 12); + } + + + +} + +