diff --git a/lib3mf/Include/lib3mf_abi.hpp b/lib3mf/Include/lib3mf_abi.hpp new file mode 100644 index 0000000..16fece3 --- /dev/null +++ b/lib3mf/Include/lib3mf_abi.hpp @@ -0,0 +1,3711 @@ +/*++ + +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. + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of the 3MF Library + +Interface version: 2.2.0 + +*/ + +#ifndef __LIB3MF_HEADER_CPP +#define __LIB3MF_HEADER_CPP + +#ifdef __LIB3MF_EXPORTS +#ifdef _WIN32 +#define LIB3MF_DECLSPEC __declspec (dllexport) +#else // _WIN32 +#define LIB3MF_DECLSPEC __attribute__((visibility("default"))) +#endif // _WIN32 +#else // __LIB3MF_EXPORTS +#define LIB3MF_DECLSPEC +#endif // __LIB3MF_EXPORTS + +#include "lib3mf_types.hpp" + + +extern "C" { + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Writer +**************************************************************************************************************************/ + +/** +* Writes out the model as file. The file type is specified by the Model Writer class. +* +* @param[in] pWriter - Writer instance. +* @param[in] pFilename - Filename to write into +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_writetofile(Lib3MF_Writer pWriter, const char * pFilename); + +/** +* Retrieves the size of the full 3MF file stream. +* +* @param[in] pWriter - Writer instance. +* @param[out] pStreamSize - the stream size +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_getstreamsize(Lib3MF_Writer pWriter, Lib3MF_uint64 * pStreamSize); + +/** +* Writes out the 3MF file into a memory buffer +* +* @param[in] pWriter - Writer instance. +* @param[in] nBufferBufferSize - Number of elements in buffer +* @param[out] pBufferNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pBufferBuffer - uint8 buffer of buffer to write into +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_writetobuffer(Lib3MF_Writer pWriter, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); + +/** +* Writes out the model and passes the data to a provided callback function. The file type is specified by the Model Writer class. +* +* @param[in] pWriter - Writer instance. +* @param[in] pTheWriteCallback - Callback to call for writing a data chunk +* @param[in] pTheSeekCallback - Callback to call for seeking in the stream +* @param[in] pUserData - Userdata that is passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_writetocallback(Lib3MF_Writer pWriter, Lib3MF::WriteCallback pTheWriteCallback, Lib3MF::SeekCallback pTheSeekCallback, Lib3MF_pvoid pUserData); + +/** +* Set the progress callback for calls to this writer +* +* @param[in] pWriter - Writer instance. +* @param[in] pProgressCallback - pointer to the callback function. +* @param[in] pUserData - pointer to arbitrary user data that is passed without modification to the callback. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_setprogresscallback(Lib3MF_Writer pWriter, Lib3MF::ProgressCallback pProgressCallback, Lib3MF_pvoid pUserData); + +/** +* Returns the number of digits after the decimal point to be written in each vertex coordinate-value. +* +* @param[in] pWriter - Writer instance. +* @param[out] pDecimalPrecision - The number of digits to be written in each vertex coordinate-value after the decimal point. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_getdecimalprecision(Lib3MF_Writer pWriter, Lib3MF_uint32 * pDecimalPrecision); + +/** +* Sets the number of digits after the decimal point to be written in each vertex coordinate-value. +* +* @param[in] pWriter - Writer instance. +* @param[in] nDecimalPrecision - The number of digits to be written in each vertex coordinate-value after the decimal point. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_setdecimalprecision(Lib3MF_Writer pWriter, Lib3MF_uint32 nDecimalPrecision); + +/** +* Activates (deactivates) the strict mode of the reader. +* +* @param[in] pWriter - Writer instance. +* @param[in] bStrictModeActive - flag whether strict mode is active or not. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_setstrictmodeactive(Lib3MF_Writer pWriter, bool bStrictModeActive); + +/** +* Queries whether the strict mode of the reader is active or not +* +* @param[in] pWriter - Writer instance. +* @param[out] pStrictModeActive - returns flag whether strict mode is active or not. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_getstrictmodeactive(Lib3MF_Writer pWriter, bool * pStrictModeActive); + +/** +* Returns Warning and Error Information of the read process +* +* @param[in] pWriter - Writer instance. +* @param[in] nIndex - Index of the Warning. Valid values are 0 to WarningCount - 1 +* @param[out] pErrorCode - filled with the error code of the warning +* @param[in] nWarningBufferSize - size of the buffer (including trailing 0) +* @param[out] pWarningNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pWarningBuffer - buffer of the message of the warning, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_getwarning(Lib3MF_Writer pWriter, Lib3MF_uint32 nIndex, Lib3MF_uint32 * pErrorCode, const Lib3MF_uint32 nWarningBufferSize, Lib3MF_uint32* pWarningNeededChars, char * pWarningBuffer); + +/** +* Returns Warning and Error Count of the read process +* +* @param[in] pWriter - Writer instance. +* @param[out] pCount - filled with the count of the occurred warnings. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_getwarningcount(Lib3MF_Writer pWriter, Lib3MF_uint32 * pCount); + +/** +* Registers a callback to deal with data key encryption/decryption from keystore +* +* @param[in] pWriter - Writer instance. +* @param[in] pConsumerID - The ConsumerID to register for +* @param[in] pTheCallback - The callback to be callede for wrapping and encryption key +* @param[in] pUserData - Userdata that is passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_addkeywrappingcallback(Lib3MF_Writer pWriter, const char * pConsumerID, Lib3MF::KeyWrappingCallback pTheCallback, Lib3MF_pvoid pUserData); + +/** +* Registers a callback to deal with encryption of content +* +* @param[in] pWriter - Writer instance. +* @param[in] pTheCallback - The callback used to encrypt content +* @param[in] pUserData - Userdata that is passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_writer_setcontentencryptioncallback(Lib3MF_Writer pWriter, Lib3MF::ContentEncryptionCallback pTheCallback, Lib3MF_pvoid pUserData); + +/************************************************************************************************************************* + Class definition for Reader +**************************************************************************************************************************/ + +/** +* Reads a model from a file. The file type is specified by the Model Reader class +* +* @param[in] pReader - Reader instance. +* @param[in] pFilename - Filename to read from +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_readfromfile(Lib3MF_Reader pReader, const char * pFilename); + +/** +* Reads a model from a memory buffer. +* +* @param[in] pReader - Reader instance. +* @param[in] nBufferBufferSize - Number of elements in buffer +* @param[in] pBufferBuffer - uint8 buffer of Buffer to read from +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_readfrombuffer(Lib3MF_Reader pReader, Lib3MF_uint64 nBufferBufferSize, const Lib3MF_uint8 * pBufferBuffer); + +/** +* Reads a model and from the data provided by a callback function +* +* @param[in] pReader - Reader instance. +* @param[in] pTheReadCallback - Callback to call for reading a data chunk +* @param[in] nStreamSize - number of bytes the callback returns +* @param[in] pTheSeekCallback - Callback to call for seeking in the stream. +* @param[in] pUserData - Userdata that is passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_readfromcallback(Lib3MF_Reader pReader, Lib3MF::ReadCallback pTheReadCallback, Lib3MF_uint64 nStreamSize, Lib3MF::SeekCallback pTheSeekCallback, Lib3MF_pvoid pUserData); + +/** +* Set the progress callback for calls to this writer +* +* @param[in] pReader - Reader instance. +* @param[in] pProgressCallback - pointer to the callback function. +* @param[in] pUserData - pointer to arbitrary user data that is passed without modification to the callback. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_setprogresscallback(Lib3MF_Reader pReader, Lib3MF::ProgressCallback pProgressCallback, Lib3MF_pvoid pUserData); + +/** +* Adds a relationship type which shall be read as attachment in memory while loading +* +* @param[in] pReader - Reader instance. +* @param[in] pRelationShipType - String of the relationship type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_addrelationtoread(Lib3MF_Reader pReader, const char * pRelationShipType); + +/** +* Removes a relationship type which shall be read as attachment in memory while loading +* +* @param[in] pReader - Reader instance. +* @param[in] pRelationShipType - String of the relationship type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_removerelationtoread(Lib3MF_Reader pReader, const char * pRelationShipType); + +/** +* Activates (deactivates) the strict mode of the reader. +* +* @param[in] pReader - Reader instance. +* @param[in] bStrictModeActive - flag whether strict mode is active or not. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_setstrictmodeactive(Lib3MF_Reader pReader, bool bStrictModeActive); + +/** +* Queries whether the strict mode of the reader is active or not +* +* @param[in] pReader - Reader instance. +* @param[out] pStrictModeActive - returns flag whether strict mode is active or not. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_getstrictmodeactive(Lib3MF_Reader pReader, bool * pStrictModeActive); + +/** +* Returns Warning and Error Information of the read process +* +* @param[in] pReader - Reader instance. +* @param[in] nIndex - Index of the Warning. Valid values are 0 to WarningCount - 1 +* @param[out] pErrorCode - filled with the error code of the warning +* @param[in] nWarningBufferSize - size of the buffer (including trailing 0) +* @param[out] pWarningNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pWarningBuffer - buffer of the message of the warning, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_getwarning(Lib3MF_Reader pReader, Lib3MF_uint32 nIndex, Lib3MF_uint32 * pErrorCode, const Lib3MF_uint32 nWarningBufferSize, Lib3MF_uint32* pWarningNeededChars, char * pWarningBuffer); + +/** +* Returns Warning and Error Count of the read process +* +* @param[in] pReader - Reader instance. +* @param[out] pCount - filled with the count of the occurred warnings. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_getwarningcount(Lib3MF_Reader pReader, Lib3MF_uint32 * pCount); + +/** +* Registers a callback to deal with key wrapping mechanism from keystore +* +* @param[in] pReader - Reader instance. +* @param[in] pConsumerID - The ConsumerID to register for +* @param[in] pTheCallback - The callback used to decrypt data key +* @param[in] pUserData - Userdata that is passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_addkeywrappingcallback(Lib3MF_Reader pReader, const char * pConsumerID, Lib3MF::KeyWrappingCallback pTheCallback, Lib3MF_pvoid pUserData); + +/** +* Registers a callback to deal with encryption of content +* +* @param[in] pReader - Reader instance. +* @param[in] pTheCallback - The callback used to encrypt content +* @param[in] pUserData - Userdata that is passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_reader_setcontentencryptioncallback(Lib3MF_Reader pReader, Lib3MF::ContentEncryptionCallback pTheCallback, Lib3MF_pvoid pUserData); + +/************************************************************************************************************************* + Class definition for PackagePart +**************************************************************************************************************************/ + +/** +* Returns the absolute path of this PackagePart. +* +* @param[in] pPackagePart - PackagePart instance. +* @param[in] nPathBufferSize - size of the buffer (including trailing 0) +* @param[out] pPathNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPathBuffer - buffer of Returns the absolute path of this PackagePart, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_packagepart_getpath(Lib3MF_PackagePart pPackagePart, const Lib3MF_uint32 nPathBufferSize, Lib3MF_uint32* pPathNeededChars, char * pPathBuffer); + +/** +* Sets the absolute path of this PackagePart. +* +* @param[in] pPackagePart - PackagePart instance. +* @param[in] pPath - Sets the absolute path of this PackagePart. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_packagepart_setpath(Lib3MF_PackagePart pPackagePart, const char * pPath); + +/************************************************************************************************************************* + Class definition for Resource +**************************************************************************************************************************/ + +/** +* Retrieves the unique id of this resource within a package. This function will be removed in a later release in favor of GetUniqueResourceID +* +* @param[in] pResource - Resource instance. +* @param[out] pUniqueResourceID - Retrieves the unique id of this resource within a package. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resource_getresourceid(Lib3MF_Resource pResource, Lib3MF_uint32 * pUniqueResourceID); + +/** +* Retrieves the unique id of this resource within a package. +* +* @param[in] pResource - Resource instance. +* @param[out] pUniqueResourceID - Retrieves the unique id of this resource within a package. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resource_getuniqueresourceid(Lib3MF_Resource pResource, Lib3MF_uint32 * pUniqueResourceID); + +/** +* Returns the PackagePart within which this resource resides +* +* @param[in] pResource - Resource instance. +* @param[out] pPackagePart - the PackagePart within which this resource resides. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resource_packagepart(Lib3MF_Resource pResource, Lib3MF_PackagePart * pPackagePart); + +/** +* Sets the new PackagePart within which this resource resides +* +* @param[in] pResource - Resource instance. +* @param[in] pPackagePart - the new PackagePart within which this resource resides. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resource_setpackagepart(Lib3MF_Resource pResource, Lib3MF_PackagePart pPackagePart); + +/** +* Retrieves the id of this resource within a model. +* +* @param[in] pResource - Resource instance. +* @param[out] pModelResourceId - Retrieves the id of this resource within a model. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resource_getmodelresourceid(Lib3MF_Resource pResource, Lib3MF_uint32 * pModelResourceId); + +/************************************************************************************************************************* + Class definition for ResourceIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next resource in the list. +* +* @param[in] pResourceIterator - ResourceIterator instance. +* @param[out] pHasNext - Iterates to the next resource in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceiterator_movenext(Lib3MF_ResourceIterator pResourceIterator, bool * pHasNext); + +/** +* Iterates to the previous resource in the list. +* +* @param[in] pResourceIterator - ResourceIterator instance. +* @param[out] pHasPrevious - Iterates to the previous resource in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceiterator_moveprevious(Lib3MF_ResourceIterator pResourceIterator, bool * pHasPrevious); + +/** +* Returns the resource the iterator points at. +* +* @param[in] pResourceIterator - ResourceIterator instance. +* @param[out] pResource - returns the resource instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceiterator_getcurrent(Lib3MF_ResourceIterator pResourceIterator, Lib3MF_Resource * pResource); + +/** +* Creates a new resource iterator with the same resource list. +* +* @param[in] pResourceIterator - ResourceIterator instance. +* @param[out] pOutResourceIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceiterator_clone(Lib3MF_ResourceIterator pResourceIterator, Lib3MF_ResourceIterator * pOutResourceIterator); + +/** +* Returns the number of resoucres the iterator captures. +* +* @param[in] pResourceIterator - ResourceIterator instance. +* @param[out] pCount - returns the number of resoucres the iterator captures. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceiterator_count(Lib3MF_ResourceIterator pResourceIterator, Lib3MF_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for SliceStackIterator +**************************************************************************************************************************/ + +/** +* Returns the SliceStack the iterator points at. +* +* @param[in] pSliceStackIterator - SliceStackIterator instance. +* @param[out] pResource - returns the SliceStack instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestackiterator_getcurrentslicestack(Lib3MF_SliceStackIterator pSliceStackIterator, Lib3MF_SliceStack * pResource); + +/************************************************************************************************************************* + Class definition for ObjectIterator +**************************************************************************************************************************/ + +/** +* Returns the Object the iterator points at. +* +* @param[in] pObjectIterator - ObjectIterator instance. +* @param[out] pResource - returns the Object instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_objectiterator_getcurrentobject(Lib3MF_ObjectIterator pObjectIterator, Lib3MF_Object * pResource); + +/************************************************************************************************************************* + Class definition for MeshObjectIterator +**************************************************************************************************************************/ + +/** +* Returns the MeshObject the iterator points at. +* +* @param[in] pMeshObjectIterator - MeshObjectIterator instance. +* @param[out] pResource - returns the MeshObject instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobjectiterator_getcurrentmeshobject(Lib3MF_MeshObjectIterator pMeshObjectIterator, Lib3MF_MeshObject * pResource); + +/************************************************************************************************************************* + Class definition for ComponentsObjectIterator +**************************************************************************************************************************/ + +/** +* Returns the ComponentsObject the iterator points at. +* +* @param[in] pComponentsObjectIterator - ComponentsObjectIterator instance. +* @param[out] pResource - returns the ComponentsObject instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_componentsobjectiterator_getcurrentcomponentsobject(Lib3MF_ComponentsObjectIterator pComponentsObjectIterator, Lib3MF_ComponentsObject * pResource); + +/************************************************************************************************************************* + Class definition for Texture2DIterator +**************************************************************************************************************************/ + +/** +* Returns the Texture2D the iterator points at. +* +* @param[in] pTexture2DIterator - Texture2DIterator instance. +* @param[out] pResource - returns the Texture2D instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2diterator_getcurrenttexture2d(Lib3MF_Texture2DIterator pTexture2DIterator, Lib3MF_Texture2D * pResource); + +/************************************************************************************************************************* + Class definition for BaseMaterialGroupIterator +**************************************************************************************************************************/ + +/** +* Returns the MaterialGroup the iterator points at. +* +* @param[in] pBaseMaterialGroupIterator - BaseMaterialGroupIterator instance. +* @param[out] pResource - returns the BaseMaterialGroup instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroupiterator_getcurrentbasematerialgroup(Lib3MF_BaseMaterialGroupIterator pBaseMaterialGroupIterator, Lib3MF_BaseMaterialGroup * pResource); + +/************************************************************************************************************************* + Class definition for ColorGroupIterator +**************************************************************************************************************************/ + +/** +* Returns the ColorGroup the iterator points at. +* +* @param[in] pColorGroupIterator - ColorGroupIterator instance. +* @param[out] pResource - returns the ColorGroup instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colorgroupiterator_getcurrentcolorgroup(Lib3MF_ColorGroupIterator pColorGroupIterator, Lib3MF_ColorGroup * pResource); + +/************************************************************************************************************************* + Class definition for Texture2DGroupIterator +**************************************************************************************************************************/ + +/** +* Returns the Texture2DGroup the iterator points at. +* +* @param[in] pTexture2DGroupIterator - Texture2DGroupIterator instance. +* @param[out] pResource - returns the Texture2DGroup instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2dgroupiterator_getcurrenttexture2dgroup(Lib3MF_Texture2DGroupIterator pTexture2DGroupIterator, Lib3MF_Texture2DGroup * pResource); + +/************************************************************************************************************************* + Class definition for CompositeMaterialsIterator +**************************************************************************************************************************/ + +/** +* Returns the CompositeMaterials the iterator points at. +* +* @param[in] pCompositeMaterialsIterator - CompositeMaterialsIterator instance. +* @param[out] pResource - returns the CompositeMaterials instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerialsiterator_getcurrentcompositematerials(Lib3MF_CompositeMaterialsIterator pCompositeMaterialsIterator, Lib3MF_CompositeMaterials * pResource); + +/************************************************************************************************************************* + Class definition for MultiPropertyGroupIterator +**************************************************************************************************************************/ + +/** +* Returns the MultiPropertyGroup the iterator points at. +* +* @param[in] pMultiPropertyGroupIterator - MultiPropertyGroupIterator instance. +* @param[out] pResource - returns the MultiPropertyGroup instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup(Lib3MF_MultiPropertyGroupIterator pMultiPropertyGroupIterator, Lib3MF_MultiPropertyGroup * pResource); + +/************************************************************************************************************************* + Class definition for MetaData +**************************************************************************************************************************/ + +/** +* returns the namespace URL of the metadata +* +* @param[in] pMetaData - MetaData instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of the namespace URL of the metadata, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_getnamespace(Lib3MF_MetaData pMetaData, const Lib3MF_uint32 nNameSpaceBufferSize, Lib3MF_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer); + +/** +* sets a new namespace URL of the metadata +* +* @param[in] pMetaData - MetaData instance. +* @param[in] pNameSpace - the new namespace URL of the metadata +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_setnamespace(Lib3MF_MetaData pMetaData, const char * pNameSpace); + +/** +* returns the name of a metadata +* +* @param[in] pMetaData - MetaData 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 the name of the metadata, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_getname(Lib3MF_MetaData pMetaData, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets a new name of a metadata +* +* @param[in] pMetaData - MetaData instance. +* @param[in] pName - the new name of the metadata +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_setname(Lib3MF_MetaData pMetaData, const char * pName); + +/** +* returns the (namespace+name) of a metadata +* +* @param[in] pMetaData - MetaData instance. +* @param[in] nKeyBufferSize - size of the buffer (including trailing 0) +* @param[out] pKeyNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pKeyBuffer - buffer of the key (namespace+name) of the metadata, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_getkey(Lib3MF_MetaData pMetaData, const Lib3MF_uint32 nKeyBufferSize, Lib3MF_uint32* pKeyNeededChars, char * pKeyBuffer); + +/** +* returns, whether a metadata must be preserved +* +* @param[in] pMetaData - MetaData instance. +* @param[out] pMustPreserve - returns, whether a metadata must be preserved +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_getmustpreserve(Lib3MF_MetaData pMetaData, bool * pMustPreserve); + +/** +* sets whether a metadata must be preserved +* +* @param[in] pMetaData - MetaData instance. +* @param[in] bMustPreserve - a new value whether a metadata must be preserved +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_setmustpreserve(Lib3MF_MetaData pMetaData, bool bMustPreserve); + +/** +* returns the type of a metadata +* +* @param[in] pMetaData - MetaData instance. +* @param[in] nTypeBufferSize - size of the buffer (including trailing 0) +* @param[out] pTypeNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTypeBuffer - buffer of the type of the metadata, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_gettype(Lib3MF_MetaData pMetaData, const Lib3MF_uint32 nTypeBufferSize, Lib3MF_uint32* pTypeNeededChars, char * pTypeBuffer); + +/** +* sets a new type of a metadata. This must be a simple XML type +* +* @param[in] pMetaData - MetaData instance. +* @param[in] pType - a new type of the metadata +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_settype(Lib3MF_MetaData pMetaData, const char * pType); + +/** +* returns the value of the metadata +* +* @param[in] pMetaData - MetaData instance. +* @param[in] nValueBufferSize - size of the buffer (including trailing 0) +* @param[out] pValueNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pValueBuffer - buffer of the value of the metadata, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_getvalue(Lib3MF_MetaData pMetaData, const Lib3MF_uint32 nValueBufferSize, Lib3MF_uint32* pValueNeededChars, char * pValueBuffer); + +/** +* sets a new value of the metadata +* +* @param[in] pMetaData - MetaData instance. +* @param[in] pValue - a new value of the metadata +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadata_setvalue(Lib3MF_MetaData pMetaData, const char * pValue); + +/************************************************************************************************************************* + Class definition for MetaDataGroup +**************************************************************************************************************************/ + +/** +* returns the number of metadata in this metadatagroup +* +* @param[in] pMetaDataGroup - MetaDataGroup instance. +* @param[out] pCount - returns the number metadata +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_getmetadatacount(Lib3MF_MetaDataGroup pMetaDataGroup, Lib3MF_uint32 * pCount); + +/** +* returns a metadata value within this metadatagroup +* +* @param[in] pMetaDataGroup - MetaDataGroup instance. +* @param[in] nIndex - Index of the Metadata. +* @param[out] pMetaData - an instance of the metadata +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_getmetadata(Lib3MF_MetaDataGroup pMetaDataGroup, Lib3MF_uint32 nIndex, Lib3MF_MetaData * pMetaData); + +/** +* returns a metadata value within this metadatagroup +* +* @param[in] pMetaDataGroup - MetaDataGroup instance. +* @param[in] pNameSpace - the namespace of the metadata +* @param[in] pName - the name of the Metadata +* @param[out] pMetaData - an instance of the metadata +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_getmetadatabykey(Lib3MF_MetaDataGroup pMetaDataGroup, const char * pNameSpace, const char * pName, Lib3MF_MetaData * pMetaData); + +/** +* removes metadata by index from the model. +* +* @param[in] pMetaDataGroup - MetaDataGroup instance. +* @param[in] nIndex - Index of the metadata to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_removemetadatabyindex(Lib3MF_MetaDataGroup pMetaDataGroup, Lib3MF_uint32 nIndex); + +/** +* removes metadata from the model. +* +* @param[in] pMetaDataGroup - MetaDataGroup instance. +* @param[in] pTheMetaData - The metadata to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_removemetadata(Lib3MF_MetaDataGroup pMetaDataGroup, Lib3MF_MetaData pTheMetaData); + +/** +* adds a new metadata to this metadatagroup +* +* @param[in] pMetaDataGroup - MetaDataGroup instance. +* @param[in] pNameSpace - the namespace of the metadata +* @param[in] pName - the name of the metadata +* @param[in] pValue - the value of the metadata +* @param[in] pType - the type of the metadata +* @param[in] bMustPreserve - shuold the metadata be preserved +* @param[out] pMetaData - a new instance of the metadata +* @return error code or 0 (success) +*/ +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 Object +**************************************************************************************************************************/ + +/** +* Retrieves an object's type +* +* @param[in] pObject - Object instance. +* @param[out] pObjectType - returns object type enum. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_gettype(Lib3MF_Object pObject, Lib3MF::eObjectType * pObjectType); + +/** +* Sets an object's type +* +* @param[in] pObject - Object instance. +* @param[in] eObjectType - object type enum. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_settype(Lib3MF_Object pObject, Lib3MF::eObjectType eObjectType); + +/** +* Retrieves an object's name +* +* @param[in] pObject - Object 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 object name., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getname(Lib3MF_Object pObject, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* Sets an object's name string +* +* @param[in] pObject - Object instance. +* @param[in] pName - new object name. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_setname(Lib3MF_Object pObject, const char * pName); + +/** +* Retrieves an object's part number +* +* @param[in] pObject - Object instance. +* @param[in] nPartNumberBufferSize - size of the buffer (including trailing 0) +* @param[out] pPartNumberNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPartNumberBuffer - buffer of returns object part number., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getpartnumber(Lib3MF_Object pObject, const Lib3MF_uint32 nPartNumberBufferSize, Lib3MF_uint32* pPartNumberNeededChars, char * pPartNumberBuffer); + +/** +* Sets an objects partnumber string +* +* @param[in] pObject - Object instance. +* @param[in] pPartNumber - new object part number. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_setpartnumber(Lib3MF_Object pObject, const char * pPartNumber); + +/** +* Retrieves, if an object is a mesh object +* +* @param[in] pObject - Object instance. +* @param[out] pIsMeshObject - returns, whether the object is a mesh object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_ismeshobject(Lib3MF_Object pObject, bool * pIsMeshObject); + +/** +* Retrieves, if an object is a components object +* +* @param[in] pObject - Object instance. +* @param[out] pIsComponentsObject - returns, whether the object is a components object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_iscomponentsobject(Lib3MF_Object pObject, bool * pIsComponentsObject); + +/** +* Retrieves, if the object is valid according to the core spec. For mesh objects, we distinguish between the type attribute of the object:In case of object type other, this always means false.In case of object type model or solidsupport, this means, if the mesh suffices all requirements of the core spec chapter 4.1.In case of object type support or surface, this always means true.A component objects is valid if and only if it contains at least one component and all child components are valid objects. +* +* @param[in] pObject - Object instance. +* @param[out] pIsValid - returns whether the object is a valid object description +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_isvalid(Lib3MF_Object pObject, bool * pIsValid); + +/** +* Use an existing attachment as thumbnail for this object +* +* @param[in] pObject - Object instance. +* @param[in] pAttachment - Instance of a new or the existing thumbnailattachment object. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_setattachmentasthumbnail(Lib3MF_Object pObject, Lib3MF_Attachment pAttachment); + +/** +* Get the attachment containing the object thumbnail. +* +* @param[in] pObject - Object instance. +* @param[out] pAttachment - Instance of the thumbnailattachment object or NULL. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getthumbnailattachment(Lib3MF_Object pObject, Lib3MF_Attachment * pAttachment); + +/** +* Clears the attachment. The attachment instance is not removed from the package. +* +* @param[in] pObject - Object instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_clearthumbnailattachment(Lib3MF_Object pObject); + +/** +* Returns the outbox of a build item +* +* @param[in] pObject - Object instance. +* @param[out] pOutbox - Outbox of this build item +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getoutbox(Lib3MF_Object pObject, Lib3MF::sBox * pOutbox); + +/** +* Retrieves an object's uuid string (see production extension specification) +* +* @param[in] pObject - Object instance. +* @param[out] pHasUUID - flag whether the build item has a UUID +* @param[in] nUUIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pUUIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pUUIDBuffer - buffer of returns object uuid., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getuuid(Lib3MF_Object pObject, bool * pHasUUID, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer); + +/** +* Sets a build object's uuid string (see production extension specification) +* +* @param[in] pObject - Object instance. +* @param[in] pUUID - new object uuid string. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_setuuid(Lib3MF_Object pObject, const char * pUUID); + +/** +* Returns the metadatagroup of this object +* +* @param[in] pObject - Object instance. +* @param[out] pMetaDataGroup - returns an Instance of the metadatagroup of this object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getmetadatagroup(Lib3MF_Object pObject, Lib3MF_MetaDataGroup * pMetaDataGroup); + +/** +* set the meshresolution of the mesh object +* +* @param[in] pObject - Object instance. +* @param[in] eMeshResolution - meshresolution of this object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_setslicesmeshresolution(Lib3MF_Object pObject, Lib3MF::eSlicesMeshResolution eMeshResolution); + +/** +* get the meshresolution of the mesh object +* +* @param[in] pObject - Object instance. +* @param[out] pMeshResolution - meshresolution of this object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getslicesmeshresolution(Lib3MF_Object pObject, Lib3MF::eSlicesMeshResolution * pMeshResolution); + +/** +* returns whether the Object has a slice stack. If Recursive is true, also checks whether any references object has a slice stack +* +* @param[in] pObject - Object instance. +* @param[in] bRecursive - check also all referenced objects? +* @param[out] pHasSlices - does the object have a slice stack? +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_hasslices(Lib3MF_Object pObject, bool bRecursive, bool * pHasSlices); + +/** +* unlinks the attached slicestack from this object. If no slice stack is attached, do noting. +* +* @param[in] pObject - Object instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_clearslicestack(Lib3MF_Object pObject); + +/** +* get the Slicestack attached to the object +* +* @param[in] pObject - Object instance. +* @param[out] pSliceStackInstance - returns the slicestack instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_getslicestack(Lib3MF_Object pObject, Lib3MF_SliceStack * pSliceStackInstance); + +/** +* assigns a slicestack to the object +* +* @param[in] pObject - Object instance. +* @param[in] pSliceStackInstance - the new slice stack of this Object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_assignslicestack(Lib3MF_Object pObject, Lib3MF_SliceStack pSliceStackInstance); + +/************************************************************************************************************************* + Class definition for MeshObject +**************************************************************************************************************************/ + +/** +* Returns the vertex count of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pVertexCount - filled with the vertex count. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvertexcount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pVertexCount); + +/** +* Returns the triangle count of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pVertexCount - filled with the triangle count. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettrianglecount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pVertexCount); + +/** +* Returns the vertex count of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - Index of the vertex (0 to vertexcount - 1) +* @param[out] pCoordinates - filled with the vertex coordinates. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvertex(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF::sPosition * pCoordinates); + +/** +* Sets the coordinates of a single vertex of a mesh object +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - Index of the vertex (0 to vertexcount - 1) +* @param[in] pCoordinates - contains the vertex coordinates. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setvertex(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, const Lib3MF::sPosition * pCoordinates); + +/** +* Adds a single vertex to a mesh object +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pCoordinates - contains the vertex coordinates. +* @param[out] pNewIndex - Index of the new vertex +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_addvertex(Lib3MF_MeshObject pMeshObject, const Lib3MF::sPosition * pCoordinates, Lib3MF_uint32 * pNewIndex); + +/** +* Obtains all vertex positions of a mesh object +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nVerticesBufferSize - Number of elements in buffer +* @param[out] pVerticesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pVerticesBuffer - Position buffer of contains the vertex coordinates. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvertices(Lib3MF_MeshObject pMeshObject, const Lib3MF_uint64 nVerticesBufferSize, Lib3MF_uint64* pVerticesNeededCount, Lib3MF::sPosition * pVerticesBuffer); + +/** +* Returns indices of a single triangle of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) +* @param[out] pIndices - filled with the triangle indices. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettriangle(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF::sTriangle * pIndices); + +/** +* Sets the indices of a single triangle of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) +* @param[in] pIndices - contains the triangle indices. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_settriangle(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, const Lib3MF::sTriangle * pIndices); + +/** +* Adds a single triangle to a mesh object +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIndices - contains the triangle indices. +* @param[out] pNewIndex - Index of the new triangle +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_addtriangle(Lib3MF_MeshObject pMeshObject, const Lib3MF::sTriangle * pIndices, Lib3MF_uint32 * pNewIndex); + +/** +* Get all triangles of a mesh object +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndicesBufferSize - Number of elements in buffer +* @param[out] pIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pIndicesBuffer - Triangle buffer of contains the triangle indices. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettriangleindices(Lib3MF_MeshObject pMeshObject, const Lib3MF_uint64 nIndicesBufferSize, Lib3MF_uint64* pIndicesNeededCount, Lib3MF::sTriangle * pIndicesBuffer); + +/** +* Sets the property at the object-level of the mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nUniqueResourceID - the object-level Property UniqueResourceID. +* @param[in] nPropertyID - the object-level PropertyID. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setobjectlevelproperty(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nUniqueResourceID, Lib3MF_uint32 nPropertyID); + +/** +* Gets the property at the object-level of the mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pUniqueResourceID - the object-level Property UniqueResourceID. +* @param[out] pPropertyID - the object-level PropertyID. +* @param[out] pHasObjectLevelProperty - Has an object-level property been specified? +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getobjectlevelproperty(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pUniqueResourceID, Lib3MF_uint32 * pPropertyID, bool * pHasObjectLevelProperty); + +/** +* Sets the properties of a single triangle of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) +* @param[in] pProperties - contains the triangle properties. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_settriangleproperties(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, const Lib3MF::sTriangleProperties * pProperties); + +/** +* Gets the properties of a single triangle of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) +* @param[out] pProperty - returns the triangle properties. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettriangleproperties(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF::sTriangleProperties * pProperty); + +/** +* Sets the properties of all triangles of a mesh object. Sets the object level property to the first entry of the passed triangle properties, if not yet specified. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nPropertiesArrayBufferSize - Number of elements in buffer +* @param[in] pPropertiesArrayBuffer - TriangleProperties buffer of contains the triangle properties array. Must have trianglecount elements. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setalltriangleproperties(Lib3MF_MeshObject pMeshObject, Lib3MF_uint64 nPropertiesArrayBufferSize, const Lib3MF::sTriangleProperties * pPropertiesArrayBuffer); + +/** +* Gets the properties of all triangles of a mesh object. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nPropertiesArrayBufferSize - Number of elements in buffer +* @param[out] pPropertiesArrayNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPropertiesArrayBuffer - TriangleProperties buffer of returns the triangle properties array. Must have trianglecount elements. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getalltriangleproperties(Lib3MF_MeshObject pMeshObject, const Lib3MF_uint64 nPropertiesArrayBufferSize, Lib3MF_uint64* pPropertiesArrayNeededCount, Lib3MF::sTriangleProperties * pPropertiesArrayBuffer); + +/** +* Clears all properties of this mesh object (triangle and object-level). +* +* @param[in] pMeshObject - MeshObject instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_clearallproperties(Lib3MF_MeshObject pMeshObject); + +/** +* Set all triangles of a mesh object +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nVerticesBufferSize - Number of elements in buffer +* @param[in] pVerticesBuffer - Position buffer of contains the positions. +* @param[in] nIndicesBufferSize - Number of elements in buffer +* @param[in] pIndicesBuffer - Triangle buffer of contains the triangle indices. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setgeometry(Lib3MF_MeshObject pMeshObject, Lib3MF_uint64 nVerticesBufferSize, const Lib3MF::sPosition * pVerticesBuffer, Lib3MF_uint64 nIndicesBufferSize, const Lib3MF::sTriangle * pIndicesBuffer); + +/** +* Retrieves, if an object describes a topologically oriented and manifold mesh, according to the core spec. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pIsManifoldAndOriented - returns, if the object is oriented and manifold. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_ismanifoldandoriented(Lib3MF_MeshObject pMeshObject, bool * pIsManifoldAndOriented); + +/** +* Retrieves the BeamLattice within this MeshObject. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pTheBeamLattice - the BeamLattice within this MeshObject +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); + +/************************************************************************************************************************* + Class definition for BeamLattice +**************************************************************************************************************************/ + +/** +* Returns the minimal length of beams for the beamlattice. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pMinLength - minimal length of beams for the beamlattice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getminlength(Lib3MF_BeamLattice pBeamLattice, Lib3MF_double * pMinLength); + +/** +* Sets the minimal length of beams for the beamlattice. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] dMinLength - minimal length of beams for the beamlattice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setminlength(Lib3MF_BeamLattice pBeamLattice, Lib3MF_double dMinLength); + +/** +* Returns the clipping mode and the clipping-mesh for the beamlattice of this mesh. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pClipMode - contains the clip mode of this mesh +* @param[out] pUniqueResourceID - filled with the UniqueResourceID of the clipping mesh-object or an undefined value if pClipMode is MODELBEAMLATTICECLIPMODE_NONE +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getclipping(Lib3MF_BeamLattice pBeamLattice, Lib3MF::eBeamLatticeClipMode * pClipMode, Lib3MF_uint32 * pUniqueResourceID); + +/** +* Sets the clipping mode and the clipping-mesh for the beamlattice of this mesh. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] eClipMode - contains the clip mode of this mesh +* @param[in] nUniqueResourceID - the UniqueResourceID of the clipping mesh-object. This mesh-object has to be defined before setting the Clipping. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setclipping(Lib3MF_BeamLattice pBeamLattice, Lib3MF::eBeamLatticeClipMode eClipMode, Lib3MF_uint32 nUniqueResourceID); + +/** +* Returns the representation-mesh for the beamlattice of this mesh. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pHasRepresentation - flag whether the beamlattice has a representation mesh. +* @param[out] pUniqueResourceID - filled with the UniqueResourceID of the clipping mesh-object. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getrepresentation(Lib3MF_BeamLattice pBeamLattice, bool * pHasRepresentation, Lib3MF_uint32 * pUniqueResourceID); + +/** +* Sets the representation-mesh for the beamlattice of this mesh. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nUniqueResourceID - the UniqueResourceID of the representation mesh-object. This mesh-object has to be defined before setting the representation. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setrepresentation(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 nUniqueResourceID); + +/** +* Returns the ball mode and the default ball radius for the beamlattice of this mesh. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pBallMode - contains the ball mode of this mesh +* @param[out] pBallRadius - default ball radius of balls for the beamlattice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getballoptions(Lib3MF_BeamLattice pBeamLattice, Lib3MF::eBeamLatticeBallMode * pBallMode, Lib3MF_double * pBallRadius); + +/** +* Sets the ball mode and thedefault ball radius for the beamlattice. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] eBallMode - contains the ball mode of this mesh +* @param[in] dBallRadius - default ball radius of balls for the beamlattice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setballoptions(Lib3MF_BeamLattice pBeamLattice, Lib3MF::eBeamLatticeBallMode eBallMode, Lib3MF_double dBallRadius); + +/** +* Returns the beam count of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pCount - filled with the beam count. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getbeamcount(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 * pCount); + +/** +* Returns indices, radii and capmodes of a single beam of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nIndex - Index of the beam (0 to beamcount - 1). +* @param[out] pBeamInfo - filled with the beam indices, radii and capmodes. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getbeam(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 nIndex, Lib3MF::sBeam * pBeamInfo); + +/** +* Adds a single beam to a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] pBeamInfo - contains the node indices, radii and capmodes. +* @param[out] pIndex - filled with the new Index of the beam. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_addbeam(Lib3MF_BeamLattice pBeamLattice, const Lib3MF::sBeam * pBeamInfo, Lib3MF_uint32 * pIndex); + +/** +* Sets the indices, radii and capmodes of a single beam of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nIndex - Index of the beam (0 to beamcount - 1). +* @param[in] pBeamInfo - filled with the beam indices, radii and capmodes. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setbeam(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 nIndex, const Lib3MF::sBeam * pBeamInfo); + +/** +* Sets all beam indices, radii and capmodes of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nBeamInfoBufferSize - Number of elements in buffer +* @param[in] pBeamInfoBuffer - Beam buffer of contains information of a number of beams +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setbeams(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint64 nBeamInfoBufferSize, const Lib3MF::sBeam * pBeamInfoBuffer); + +/** +* obtains all beam indices, radii and capmodes of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nBeamInfoBufferSize - Number of elements in buffer +* @param[out] pBeamInfoNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pBeamInfoBuffer - Beam buffer of contains information of all beams +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getbeams(Lib3MF_BeamLattice pBeamLattice, const Lib3MF_uint64 nBeamInfoBufferSize, Lib3MF_uint64* pBeamInfoNeededCount, Lib3MF::sBeam * pBeamInfoBuffer); + +/** +* Returns the ball count of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pCount - filled with the ball count. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getballcount(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 * pCount); + +/** +* Returns index and radius of a single ball of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nIndex - Index of the ball (0 to ballcount - 1). +* @param[out] pBallInfo - filled with the ball node index and radius. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getball(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 nIndex, Lib3MF::sBall * pBallInfo); + +/** +* Adds a single ball to a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] pBallInfo - contains the node index and radius. +* @param[out] pIndex - filled with the new Index of the ball. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_addball(Lib3MF_BeamLattice pBeamLattice, const Lib3MF::sBall * pBallInfo, Lib3MF_uint32 * pIndex); + +/** +* Sets the index and radius of a single ball of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nIndex - Index of the ball (0 to ballcount - 1). +* @param[in] pBallInfo - filled with the ball node index and radius. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setball(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 nIndex, const Lib3MF::sBall * pBallInfo); + +/** +* Sets all ball indices and radii of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nBallInfoBufferSize - Number of elements in buffer +* @param[in] pBallInfoBuffer - Ball buffer of contains information of a number of balls +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_setballs(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint64 nBallInfoBufferSize, const Lib3MF::sBall * pBallInfoBuffer); + +/** +* obtains all ball indices and radii of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nBallInfoBufferSize - Number of elements in buffer +* @param[out] pBallInfoNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pBallInfoBuffer - Ball buffer of contains information of all balls +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getballs(Lib3MF_BeamLattice pBeamLattice, const Lib3MF_uint64 nBallInfoBufferSize, Lib3MF_uint64* pBallInfoNeededCount, Lib3MF::sBall * pBallInfoBuffer); + +/** +* Returns the number of beamsets of a mesh object. +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pCount - filled with the beamset count. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getbeamsetcount(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 * pCount); + +/** +* Adds an empty beamset to a mesh object +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[out] pBeamSet - the new beamset +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_addbeamset(Lib3MF_BeamLattice pBeamLattice, Lib3MF_BeamSet * pBeamSet); + +/** +* Returns a beamset of a mesh object +* +* @param[in] pBeamLattice - BeamLattice instance. +* @param[in] nIndex - index of the requested beamset (0 ... beamsetcount-1). +* @param[out] pBeamSet - the requested beamset +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getbeamset(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 nIndex, Lib3MF_BeamSet * pBeamSet); + +/************************************************************************************************************************* + Class definition for Component +**************************************************************************************************************************/ + +/** +* Returns the Resource Instance of the component. +* +* @param[in] pComponent - Component instance. +* @param[out] pObjectResource - filled with the Resource Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_component_getobjectresource(Lib3MF_Component pComponent, Lib3MF_Object * pObjectResource); + +/** +* Returns the UniqueResourceID of the component. +* +* @param[in] pComponent - Component instance. +* @param[out] pUniqueResourceID - returns the UniqueResourceID. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_component_getobjectresourceid(Lib3MF_Component pComponent, Lib3MF_uint32 * pUniqueResourceID); + +/** +* returns, whether a component has a UUID and, if true, the component's UUID +* +* @param[in] pComponent - Component instance. +* @param[out] pHasUUID - flag whether the component has a UUID +* @param[in] nUUIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pUUIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pUUIDBuffer - buffer of the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx', may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_component_getuuid(Lib3MF_Component pComponent, bool * pHasUUID, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer); + +/** +* sets the component's UUID +* +* @param[in] pComponent - Component instance. +* @param[in] pUUID - the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_component_setuuid(Lib3MF_Component pComponent, const char * pUUID); + +/** +* Returns, if the component has a different transformation than the identity matrix +* +* @param[in] pComponent - Component instance. +* @param[out] pHasTransform - if true is returned, the transformation is not equal than the identity +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_component_hastransform(Lib3MF_Component pComponent, bool * pHasTransform); + +/** +* Returns the transformation matrix of the component. +* +* @param[in] pComponent - Component instance. +* @param[out] pTransform - filled with the component transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_component_gettransform(Lib3MF_Component pComponent, Lib3MF::sTransform * pTransform); + +/** +* Sets the transformation matrix of the component. +* +* @param[in] pComponent - Component instance. +* @param[in] pTransform - new transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_component_settransform(Lib3MF_Component pComponent, const Lib3MF::sTransform * pTransform); + +/************************************************************************************************************************* + Class definition for ComponentsObject +**************************************************************************************************************************/ + +/** +* Adds a new component to a components object. +* +* @param[in] pComponentsObject - ComponentsObject instance. +* @param[in] pObjectResource - object to add as component. Must not lead to circular references! +* @param[in] pTransform - optional transform matrix for the component. +* @param[out] pComponentInstance - new component instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_componentsobject_addcomponent(Lib3MF_ComponentsObject pComponentsObject, Lib3MF_Object pObjectResource, const Lib3MF::sTransform * pTransform, Lib3MF_Component * pComponentInstance); + +/** +* Retrieves a component from a component object. +* +* @param[in] pComponentsObject - ComponentsObject instance. +* @param[in] nIndex - index of the component to retrieve (0 to componentcount - 1) +* @param[out] pComponentInstance - component instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_componentsobject_getcomponent(Lib3MF_ComponentsObject pComponentsObject, Lib3MF_uint32 nIndex, Lib3MF_Component * pComponentInstance); + +/** +* Retrieves a component count of a component object. +* +* @param[in] pComponentsObject - ComponentsObject instance. +* @param[out] pCount - returns the component count +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_componentsobject_getcomponentcount(Lib3MF_ComponentsObject pComponentsObject, Lib3MF_uint32 * pCount); + +/************************************************************************************************************************* + Class definition for BeamSet +**************************************************************************************************************************/ + +/** +* Sets a beamset's name string +* +* @param[in] pBeamSet - BeamSet instance. +* @param[in] pName - new name of the beamset. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_setname(Lib3MF_BeamSet pBeamSet, const char * pName); + +/** +* Retrieves a beamset's name string +* +* @param[in] pBeamSet - BeamSet 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 of the beamset., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_getname(Lib3MF_BeamSet pBeamSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* Sets a beamset's identifier string +* +* @param[in] pBeamSet - BeamSet instance. +* @param[in] pIdentifier - new name of the beamset. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_setidentifier(Lib3MF_BeamSet pBeamSet, const char * pIdentifier); + +/** +* Retrieves a beamset's identifier string +* +* @param[in] pBeamSet - BeamSet 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 of the beamset., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_getidentifier(Lib3MF_BeamSet pBeamSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* Retrieves the reference count of a beamset +* +* @param[in] pBeamSet - BeamSet instance. +* @param[out] pCount - returns the reference count +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_getreferencecount(Lib3MF_BeamSet pBeamSet, Lib3MF_uint32 * pCount); + +/** +* Sets the references of a beamset +* +* @param[in] pBeamSet - BeamSet instance. +* @param[in] nReferencesBufferSize - Number of elements in buffer +* @param[in] pReferencesBuffer - uint32 buffer of the new indices of all beams in this beamset +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_setreferences(Lib3MF_BeamSet pBeamSet, Lib3MF_uint64 nReferencesBufferSize, const Lib3MF_uint32 * pReferencesBuffer); + +/** +* Retrieves the references of a beamset +* +* @param[in] pBeamSet - BeamSet instance. +* @param[in] nReferencesBufferSize - Number of elements in buffer +* @param[out] pReferencesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pReferencesBuffer - uint32 buffer of retrieves the indices of all beams in this beamset +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_getreferences(Lib3MF_BeamSet pBeamSet, const Lib3MF_uint64 nReferencesBufferSize, Lib3MF_uint64* pReferencesNeededCount, Lib3MF_uint32 * pReferencesBuffer); + +/** +* Retrieves the ball reference count of a beamset +* +* @param[in] pBeamSet - BeamSet instance. +* @param[out] pCount - returns the ball reference count +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_getballreferencecount(Lib3MF_BeamSet pBeamSet, Lib3MF_uint32 * pCount); + +/** +* Sets the ball references of a beamset +* +* @param[in] pBeamSet - BeamSet instance. +* @param[in] nBallReferencesBufferSize - Number of elements in buffer +* @param[in] pBallReferencesBuffer - uint32 buffer of the new indices of all balls in this beamset +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_setballreferences(Lib3MF_BeamSet pBeamSet, Lib3MF_uint64 nBallReferencesBufferSize, const Lib3MF_uint32 * pBallReferencesBuffer); + +/** +* Retrieves the ball references of a beamset +* +* @param[in] pBeamSet - BeamSet instance. +* @param[in] nBallReferencesBufferSize - Number of elements in buffer +* @param[out] pBallReferencesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pBallReferencesBuffer - uint32 buffer of retrieves the indices of all balls in this beamset +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamset_getballreferences(Lib3MF_BeamSet pBeamSet, const Lib3MF_uint64 nBallReferencesBufferSize, Lib3MF_uint64* pBallReferencesNeededCount, Lib3MF_uint32 * pBallReferencesBuffer); + +/************************************************************************************************************************* + Class definition for BaseMaterialGroup +**************************************************************************************************************************/ + +/** +* Retrieves the count of base materials in the material group. +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[out] pCount - returns the count of base materials. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_getcount(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, Lib3MF_uint32 * pCount); + +/** +* returns all the PropertyIDs of all materials in this group +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[out] pPropertyIDsNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPropertyIDsBuffer - uint32 buffer of PropertyID of the material in the material group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_getallpropertyids(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, const Lib3MF_uint64 nPropertyIDsBufferSize, Lib3MF_uint64* pPropertyIDsNeededCount, Lib3MF_uint32 * pPropertyIDsBuffer); + +/** +* Adds a new material to the material group +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[in] pName - new name of the base material. +* @param[in] pDisplayColor - Display color of the material +* @param[out] pPropertyID - returns new PropertyID of the new material in the material group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_addmaterial(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, const char * pName, const Lib3MF::sColor * pDisplayColor, Lib3MF_uint32 * pPropertyID); + +/** +* Removes a material from the material group. +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[in] nPropertyID - PropertyID of the material in the material group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_removematerial(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, Lib3MF_uint32 nPropertyID); + +/** +* Returns the base material's name +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[in] nPropertyID - PropertyID of the material in the material group. +* @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 of the base material., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_getname(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, Lib3MF_uint32 nPropertyID, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* Sets a base material's name +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[in] nPropertyID - PropertyID of the material in the material group. +* @param[in] pName - new name of the base material. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_setname(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, Lib3MF_uint32 nPropertyID, const char * pName); + +/** +* Sets a base material's display color. +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[in] nPropertyID - PropertyID of the material in the material group. +* @param[in] pTheColor - The base material's display color +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_setdisplaycolor(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, Lib3MF_uint32 nPropertyID, const Lib3MF::sColor * pTheColor); + +/** +* Returns a base material's display color. +* +* @param[in] pBaseMaterialGroup - BaseMaterialGroup instance. +* @param[in] nPropertyID - PropertyID of the material in the material group. +* @param[out] pTheColor - The base material's display color +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_basematerialgroup_getdisplaycolor(Lib3MF_BaseMaterialGroup pBaseMaterialGroup, Lib3MF_uint32 nPropertyID, Lib3MF::sColor * pTheColor); + +/************************************************************************************************************************* + Class definition for ColorGroup +**************************************************************************************************************************/ + +/** +* Retrieves the count of base materials in this Color Group. +* +* @param[in] pColorGroup - ColorGroup instance. +* @param[out] pCount - returns the count of colors within this color group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colorgroup_getcount(Lib3MF_ColorGroup pColorGroup, Lib3MF_uint32 * pCount); + +/** +* returns all the PropertyIDs of all colors within this group +* +* @param[in] pColorGroup - ColorGroup instance. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[out] pPropertyIDsNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPropertyIDsBuffer - uint32 buffer of PropertyID of the color in the color group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colorgroup_getallpropertyids(Lib3MF_ColorGroup pColorGroup, const Lib3MF_uint64 nPropertyIDsBufferSize, Lib3MF_uint64* pPropertyIDsNeededCount, Lib3MF_uint32 * pPropertyIDsBuffer); + +/** +* Adds a new value. +* +* @param[in] pColorGroup - ColorGroup instance. +* @param[in] pTheColor - The new color +* @param[out] pPropertyID - PropertyID of the new color within this color group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colorgroup_addcolor(Lib3MF_ColorGroup pColorGroup, const Lib3MF::sColor * pTheColor, Lib3MF_uint32 * pPropertyID); + +/** +* Removes a color from the color group. +* +* @param[in] pColorGroup - ColorGroup instance. +* @param[in] nPropertyID - PropertyID of the color to be removed from the color group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colorgroup_removecolor(Lib3MF_ColorGroup pColorGroup, Lib3MF_uint32 nPropertyID); + +/** +* Sets a color value. +* +* @param[in] pColorGroup - ColorGroup instance. +* @param[in] nPropertyID - PropertyID of a color within this color group. +* @param[in] pTheColor - The color +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colorgroup_setcolor(Lib3MF_ColorGroup pColorGroup, Lib3MF_uint32 nPropertyID, const Lib3MF::sColor * pTheColor); + +/** +* Sets a color value. +* +* @param[in] pColorGroup - ColorGroup instance. +* @param[in] nPropertyID - PropertyID of a color within this color group. +* @param[out] pTheColor - The color +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colorgroup_getcolor(Lib3MF_ColorGroup pColorGroup, Lib3MF_uint32 nPropertyID, Lib3MF::sColor * pTheColor); + +/************************************************************************************************************************* + Class definition for Texture2DGroup +**************************************************************************************************************************/ + +/** +* Retrieves the count of tex2coords in the Texture2DGroup. +* +* @param[in] pTexture2DGroup - Texture2DGroup instance. +* @param[out] pCount - returns the count of tex2coords. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2dgroup_getcount(Lib3MF_Texture2DGroup pTexture2DGroup, Lib3MF_uint32 * pCount); + +/** +* returns all the PropertyIDs of all tex2coords in this Texture2DGroup +* +* @param[in] pTexture2DGroup - Texture2DGroup instance. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[out] pPropertyIDsNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPropertyIDsBuffer - uint32 buffer of PropertyID of the tex2coords in the Texture2DGroup. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2dgroup_getallpropertyids(Lib3MF_Texture2DGroup pTexture2DGroup, const Lib3MF_uint64 nPropertyIDsBufferSize, Lib3MF_uint64* pPropertyIDsNeededCount, Lib3MF_uint32 * pPropertyIDsBuffer); + +/** +* Adds a new tex2coord to the Texture2DGroup +* +* @param[in] pTexture2DGroup - Texture2DGroup instance. +* @param[in] pUVCoordinate - The u/v-coordinate within the texture, horizontally right/vertically up from the origin in the lower left of the texture. +* @param[out] pPropertyID - returns new PropertyID of the new tex2coord in the Texture2DGroup. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2dgroup_addtex2coord(Lib3MF_Texture2DGroup pTexture2DGroup, const Lib3MF::sTex2Coord * pUVCoordinate, Lib3MF_uint32 * pPropertyID); + +/** +* Obtains a tex2coord to the Texture2DGroup +* +* @param[in] pTexture2DGroup - Texture2DGroup instance. +* @param[in] nPropertyID - the PropertyID of the tex2coord in the Texture2DGroup. +* @param[out] pUVCoordinate - The u/v-coordinate within the texture, horizontally right/vertically up from the origin in the lower left of the texture. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2dgroup_gettex2coord(Lib3MF_Texture2DGroup pTexture2DGroup, Lib3MF_uint32 nPropertyID, Lib3MF::sTex2Coord * pUVCoordinate); + +/** +* Removes a tex2coords from the Texture2DGroup. +* +* @param[in] pTexture2DGroup - Texture2DGroup instance. +* @param[in] nPropertyID - PropertyID of the tex2coords in the Texture2DGroup. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2dgroup_removetex2coord(Lib3MF_Texture2DGroup pTexture2DGroup, Lib3MF_uint32 nPropertyID); + +/** +* Obtains the texture2D instance of this group. +* +* @param[in] pTexture2DGroup - Texture2DGroup instance. +* @param[out] pTexture2DInstance - the texture2D instance of this group. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2dgroup_gettexture2d(Lib3MF_Texture2DGroup pTexture2DGroup, Lib3MF_Texture2D * pTexture2DInstance); + +/************************************************************************************************************************* + Class definition for CompositeMaterials +**************************************************************************************************************************/ + +/** +* Retrieves the count of Composite-s in the CompositeMaterials. +* +* @param[in] pCompositeMaterials - CompositeMaterials instance. +* @param[out] pCount - returns the count of Composite-s +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerials_getcount(Lib3MF_CompositeMaterials pCompositeMaterials, Lib3MF_uint32 * pCount); + +/** +* returns all the PropertyIDs of all Composite-Mixing Values in this CompositeMaterials +* +* @param[in] pCompositeMaterials - CompositeMaterials instance. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[out] pPropertyIDsNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPropertyIDsBuffer - uint32 buffer of PropertyID of the Composite-Mixing Values in the CompositeMaterials. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerials_getallpropertyids(Lib3MF_CompositeMaterials pCompositeMaterials, const Lib3MF_uint64 nPropertyIDsBufferSize, Lib3MF_uint64* pPropertyIDsNeededCount, Lib3MF_uint32 * pPropertyIDsBuffer); + +/** +* Obtains the BaseMaterialGroup instance of this CompositeMaterials. +* +* @param[in] pCompositeMaterials - CompositeMaterials instance. +* @param[out] pBaseMaterialGroupInstance - returns the BaseMaterialGroup instance of this CompositeMaterials +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerials_getbasematerialgroup(Lib3MF_CompositeMaterials pCompositeMaterials, Lib3MF_BaseMaterialGroup * pBaseMaterialGroupInstance); + +/** +* Adds a new Composite-Mixing Values to the CompositeMaterials. +* +* @param[in] pCompositeMaterials - CompositeMaterials instance. +* @param[in] nCompositeBufferSize - Number of elements in buffer +* @param[in] pCompositeBuffer - CompositeConstituent buffer of The Composite Constituents to be added as composite +* @param[out] pPropertyID - returns new PropertyID of the new Composite in the CompositeMaterials. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerials_addcomposite(Lib3MF_CompositeMaterials pCompositeMaterials, Lib3MF_uint64 nCompositeBufferSize, const Lib3MF::sCompositeConstituent * pCompositeBuffer, Lib3MF_uint32 * pPropertyID); + +/** +* Removes a Composite-Maxing Ratio from the CompositeMaterials. +* +* @param[in] pCompositeMaterials - CompositeMaterials instance. +* @param[in] nPropertyID - PropertyID of the Composite-Mixing Values in the CompositeMaterials to be removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerials_removecomposite(Lib3MF_CompositeMaterials pCompositeMaterials, Lib3MF_uint32 nPropertyID); + +/** +* Obtains a Composite-Maxing Ratio of this CompositeMaterials. +* +* @param[in] pCompositeMaterials - CompositeMaterials instance. +* @param[in] nPropertyID - the PropertyID of the Composite-Maxing Ratio in the CompositeMaterials. +* @param[in] nCompositeBufferSize - Number of elements in buffer +* @param[out] pCompositeNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pCompositeBuffer - CompositeConstituent buffer of The Composite-Mixing Values with the given PropertyID +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerials_getcomposite(Lib3MF_CompositeMaterials pCompositeMaterials, Lib3MF_uint32 nPropertyID, const Lib3MF_uint64 nCompositeBufferSize, Lib3MF_uint64* pCompositeNeededCount, Lib3MF::sCompositeConstituent * pCompositeBuffer); + +/************************************************************************************************************************* + Class definition for MultiPropertyGroup +**************************************************************************************************************************/ + +/** +* Retrieves the count of MultiProperty-s in the MultiPropertyGroup. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[out] pCount - returns the count of MultiProperty-s +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_getcount(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 * pCount); + +/** +* returns all the PropertyIDs of all MultiProperty-s in this MultiPropertyGroup +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[out] pPropertyIDsNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPropertyIDsBuffer - uint32 buffer of PropertyID of the MultiProperty-s in the MultiPropertyGroup. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_getallpropertyids(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, const Lib3MF_uint64 nPropertyIDsBufferSize, Lib3MF_uint64* pPropertyIDsNeededCount, Lib3MF_uint32 * pPropertyIDsBuffer); + +/** +* Adds a new MultiProperty to the MultiPropertyGroup. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[in] pPropertyIDsBuffer - uint32 buffer of The PropertyIDs of the new MultiProperty. +* @param[out] pPropertyID - returns the PropertyID of the new MultiProperty in the MultiPropertyGroup. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_addmultiproperty(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint64 nPropertyIDsBufferSize, const Lib3MF_uint32 * pPropertyIDsBuffer, Lib3MF_uint32 * pPropertyID); + +/** +* Sets the PropertyIDs of a MultiProperty. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] nPropertyID - the PropertyID of the MultiProperty to be changed. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[in] pPropertyIDsBuffer - uint32 buffer of The new PropertyIDs of the MultiProperty +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_setmultiproperty(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 nPropertyID, Lib3MF_uint64 nPropertyIDsBufferSize, const Lib3MF_uint32 * pPropertyIDsBuffer); + +/** +* Obtains the PropertyIDs of a MultiProperty. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] nPropertyID - the PropertyID of the MultiProperty to be queried. +* @param[in] nPropertyIDsBufferSize - Number of elements in buffer +* @param[out] pPropertyIDsNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPropertyIDsBuffer - uint32 buffer of The PropertyIDs of the MultiProperty +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_getmultiproperty(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 nPropertyID, const Lib3MF_uint64 nPropertyIDsBufferSize, Lib3MF_uint64* pPropertyIDsNeededCount, Lib3MF_uint32 * pPropertyIDsBuffer); + +/** +* Removes a MultiProperty from this MultiPropertyGroup. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] nPropertyID - the PropertyID of the MultiProperty to be removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_removemultiproperty(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 nPropertyID); + +/** +* Retrieves the number of layers of this MultiPropertyGroup. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[out] pCount - returns the number of layers +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_getlayercount(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 * pCount); + +/** +* Adds a MultiPropertyLayer to this MultiPropertyGroup. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] pTheLayer - The MultiPropertyLayer to add to this MultiPropertyGroup +* @param[out] pLayerIndex - returns the index of this MultiPropertyLayer +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_addlayer(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, const Lib3MF::sMultiPropertyLayer * pTheLayer, Lib3MF_uint32 * pLayerIndex); + +/** +* Obtains a MultiPropertyLayer of this MultiPropertyGroup. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] nLayerIndex - The Index of the MultiPropertyLayer queried +* @param[out] pTheLayer - The MultiPropertyLayer with index LayerIndex within MultiPropertyGroup +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_getlayer(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 nLayerIndex, Lib3MF::sMultiPropertyLayer * pTheLayer); + +/** +* Removes a MultiPropertyLayer from this MultiPropertyGroup. +* +* @param[in] pMultiPropertyGroup - MultiPropertyGroup instance. +* @param[in] nLayerIndex - The Index of the MultiPropertyLayer to be removed +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_removelayer(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 nLayerIndex); + +/************************************************************************************************************************* + Class definition for Attachment +**************************************************************************************************************************/ + +/** +* Retrieves an attachment's package path. This function will be removed in a later release. +* +* @param[in] pAttachment - Attachment instance. +* @param[in] nPathBufferSize - size of the buffer (including trailing 0) +* @param[out] pPathNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPathBuffer - buffer of returns the attachment's package path string, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_getpath(Lib3MF_Attachment pAttachment, const Lib3MF_uint32 nPathBufferSize, Lib3MF_uint32* pPathNeededChars, char * pPathBuffer); + +/** +* Sets an attachment's package path. This function will be removed in a later release. +* +* @param[in] pAttachment - Attachment instance. +* @param[in] pPath - new path of the attachment. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_setpath(Lib3MF_Attachment pAttachment, const char * pPath); + +/** +* Returns the PackagePart that is this attachment. +* +* @param[in] pAttachment - Attachment instance. +* @param[out] pPackagePart - The PackagePart of this attachment. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_packagepart(Lib3MF_Attachment pAttachment, Lib3MF_PackagePart * pPackagePart); + +/** +* Retrieves an attachment's relationship type +* +* @param[in] pAttachment - Attachment instance. +* @param[in] nPathBufferSize - size of the buffer (including trailing 0) +* @param[out] pPathNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPathBuffer - buffer of returns the attachment's package relationship type string, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_getrelationshiptype(Lib3MF_Attachment pAttachment, const Lib3MF_uint32 nPathBufferSize, Lib3MF_uint32* pPathNeededChars, char * pPathBuffer); + +/** +* Sets an attachment's relationship type. +* +* @param[in] pAttachment - Attachment instance. +* @param[in] pPath - new relationship type string. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_setrelationshiptype(Lib3MF_Attachment pAttachment, const char * pPath); + +/** +* Writes out the attachment as file. +* +* @param[in] pAttachment - Attachment instance. +* @param[in] pFileName - file to write into. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAttachment, const char * pFileName); + +/** +* Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. +* +* @param[in] pAttachment - Attachment instance. +* @param[in] pFileName - file to read from. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_readfromfile(Lib3MF_Attachment pAttachment, const char * pFileName); + +/** +* Reads a model and from the data provided by a callback function +* +* @param[in] pAttachment - Attachment instance. +* @param[in] pTheReadCallback - Callback to call for reading a data chunk +* @param[in] nStreamSize - number of bytes the callback returns +* @param[in] pTheSeekCallback - Callback to call for seeking in the stream. +* @param[in] pUserData - Userdata that is passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_readfromcallback(Lib3MF_Attachment pAttachment, Lib3MF::ReadCallback pTheReadCallback, Lib3MF_uint64 nStreamSize, Lib3MF::SeekCallback pTheSeekCallback, Lib3MF_pvoid pUserData); + +/** +* Retrieves the size of the attachment stream +* +* @param[in] pAttachment - Attachment instance. +* @param[out] pStreamSize - the stream size +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_getstreamsize(Lib3MF_Attachment pAttachment, Lib3MF_uint64 * pStreamSize); + +/** +* Writes out the attachment into a buffer +* +* @param[in] pAttachment - Attachment instance. +* @param[in] nBufferBufferSize - Number of elements in buffer +* @param[out] pBufferNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pBufferBuffer - uint8 buffer of Buffer to write into +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetobuffer(Lib3MF_Attachment pAttachment, const Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer); + +/** +* Reads an attachment from a memory buffer +* +* @param[in] pAttachment - Attachment instance. +* @param[in] nBufferBufferSize - Number of elements in buffer +* @param[in] pBufferBuffer - uint8 buffer of Buffer to read from +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_readfrombuffer(Lib3MF_Attachment pAttachment, Lib3MF_uint64 nBufferBufferSize, const Lib3MF_uint8 * pBufferBuffer); + +/************************************************************************************************************************* + Class definition for Texture2D +**************************************************************************************************************************/ + +/** +* Retrieves the attachment located at the path of the texture. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[out] pAttachment - attachment that holds the texture's image information. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_getattachment(Lib3MF_Texture2D pTexture2D, Lib3MF_Attachment * pAttachment); + +/** +* Sets the texture's package path to the path of the attachment. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[in] pAttachment - attachment that holds the texture's image information. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_setattachment(Lib3MF_Texture2D pTexture2D, Lib3MF_Attachment pAttachment); + +/** +* Retrieves a texture's content type. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[out] pContentType - returns content type enum. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_getcontenttype(Lib3MF_Texture2D pTexture2D, Lib3MF::eTextureType * pContentType); + +/** +* Retrieves a texture's content type. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[in] eContentType - new Content Type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_setcontenttype(Lib3MF_Texture2D pTexture2D, Lib3MF::eTextureType eContentType); + +/** +* Retrieves a texture's tilestyle type. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[out] pTileStyleU - returns tilestyle type enum. +* @param[out] pTileStyleV - returns tilestyle type enum. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_gettilestyleuv(Lib3MF_Texture2D pTexture2D, Lib3MF::eTextureTileStyle * pTileStyleU, Lib3MF::eTextureTileStyle * pTileStyleV); + +/** +* Sets a texture's tilestyle type. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[in] eTileStyleU - new tilestyle type enum. +* @param[in] eTileStyleV - new tilestyle type enum. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_settilestyleuv(Lib3MF_Texture2D pTexture2D, Lib3MF::eTextureTileStyle eTileStyleU, Lib3MF::eTextureTileStyle eTileStyleV); + +/** +* Retrieves a texture's filter type. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[out] pFilter - returns filter type enum. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_getfilter(Lib3MF_Texture2D pTexture2D, Lib3MF::eTextureFilter * pFilter); + +/** +* Sets a texture's filter type. +* +* @param[in] pTexture2D - Texture2D instance. +* @param[in] eFilter - sets new filter type enum. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_setfilter(Lib3MF_Texture2D pTexture2D, Lib3MF::eTextureFilter eFilter); + +/************************************************************************************************************************* + Class definition for BuildItem +**************************************************************************************************************************/ + +/** +* Retrieves the object resource associated to a build item +* +* @param[in] pBuildItem - BuildItem instance. +* @param[out] pObjectResource - returns the associated resource instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_getobjectresource(Lib3MF_BuildItem pBuildItem, Lib3MF_Object * pObjectResource); + +/** +* returns, whether a build item has a UUID and, if true, the build item's UUID +* +* @param[in] pBuildItem - BuildItem instance. +* @param[out] pHasUUID - flag whether the build item has a UUID +* @param[in] nUUIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pUUIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pUUIDBuffer - buffer of the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx', may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_getuuid(Lib3MF_BuildItem pBuildItem, bool * pHasUUID, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer); + +/** +* sets the build item's UUID +* +* @param[in] pBuildItem - BuildItem instance. +* @param[in] pUUID - the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_setuuid(Lib3MF_BuildItem pBuildItem, const char * pUUID); + +/** +* Retrieves the object UniqueResourceID associated to a build item +* +* @param[in] pBuildItem - BuildItem instance. +* @param[out] pUniqueResourceID - returns the UniqueResourceID of the object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_getobjectresourceid(Lib3MF_BuildItem pBuildItem, Lib3MF_uint32 * pUniqueResourceID); + +/** +* Checks, if a build item has a non-identity transformation matrix +* +* @param[in] pBuildItem - BuildItem instance. +* @param[out] pHasTransform - returns true, if the transformation matrix is not the identity +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_hasobjecttransform(Lib3MF_BuildItem pBuildItem, bool * pHasTransform); + +/** +* Retrieves a build item's transformation matrix. +* +* @param[in] pBuildItem - BuildItem instance. +* @param[out] pTransform - returns the transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_getobjecttransform(Lib3MF_BuildItem pBuildItem, Lib3MF::sTransform * pTransform); + +/** +* Sets a build item's transformation matrix. +* +* @param[in] pBuildItem - BuildItem instance. +* @param[in] pTransform - new transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_setobjecttransform(Lib3MF_BuildItem pBuildItem, const Lib3MF::sTransform * pTransform); + +/** +* Retrieves a build item's part number string +* +* @param[in] pBuildItem - BuildItem instance. +* @param[in] nPartNumberBufferSize - size of the buffer (including trailing 0) +* @param[out] pPartNumberNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPartNumberBuffer - buffer of Returns a build item's part number string, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_getpartnumber(Lib3MF_BuildItem pBuildItem, const Lib3MF_uint32 nPartNumberBufferSize, Lib3MF_uint32* pPartNumberNeededChars, char * pPartNumberBuffer); + +/** +* Sets a build item's part number string +* +* @param[in] pBuildItem - BuildItem instance. +* @param[in] pSetPartnumber - new part number string for referencing parts from the outside world +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_setpartnumber(Lib3MF_BuildItem pBuildItem, const char * pSetPartnumber); + +/** +* Returns the metadatagroup of this build item +* +* @param[in] pBuildItem - BuildItem instance. +* @param[out] pMetaDataGroup - returns an Instance of the metadatagroup of this build item +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_getmetadatagroup(Lib3MF_BuildItem pBuildItem, Lib3MF_MetaDataGroup * pMetaDataGroup); + +/** +* Returns the outbox of a build item +* +* @param[in] pBuildItem - BuildItem instance. +* @param[out] pOutbox - Outbox of this build item +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditem_getoutbox(Lib3MF_BuildItem pBuildItem, Lib3MF::sBox * pOutbox); + +/************************************************************************************************************************* + Class definition for BuildItemIterator +**************************************************************************************************************************/ + +/** +* Iterates to the next build item in the list. +* +* @param[in] pBuildItemIterator - BuildItemIterator instance. +* @param[out] pHasNext - Iterates to the next build item in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditemiterator_movenext(Lib3MF_BuildItemIterator pBuildItemIterator, bool * pHasNext); + +/** +* Iterates to the previous build item in the list. +* +* @param[in] pBuildItemIterator - BuildItemIterator instance. +* @param[out] pHasPrevious - Iterates to the previous build item in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditemiterator_moveprevious(Lib3MF_BuildItemIterator pBuildItemIterator, bool * pHasPrevious); + +/** +* Returns the build item the iterator points at. +* +* @param[in] pBuildItemIterator - BuildItemIterator instance. +* @param[out] pBuildItem - returns the build item instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditemiterator_getcurrent(Lib3MF_BuildItemIterator pBuildItemIterator, Lib3MF_BuildItem * pBuildItem); + +/** +* Creates a new build item iterator with the same build item list. +* +* @param[in] pBuildItemIterator - BuildItemIterator instance. +* @param[out] pOutBuildItemIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditemiterator_clone(Lib3MF_BuildItemIterator pBuildItemIterator, Lib3MF_BuildItemIterator * pOutBuildItemIterator); + +/** +* Returns the number of build items the iterator captures. +* +* @param[in] pBuildItemIterator - BuildItemIterator instance. +* @param[out] pCount - returns the number of build items the iterator captures. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_builditemiterator_count(Lib3MF_BuildItemIterator pBuildItemIterator, Lib3MF_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for Slice +**************************************************************************************************************************/ + +/** +* Set all vertices of a slice. All polygons will be cleared. +* +* @param[in] pSlice - Slice instance. +* @param[in] nVerticesBufferSize - Number of elements in buffer +* @param[in] pVerticesBuffer - Position2D buffer of contains the positions. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_setvertices(Lib3MF_Slice pSlice, Lib3MF_uint64 nVerticesBufferSize, const Lib3MF::sPosition2D * pVerticesBuffer); + +/** +* Get all vertices of a slice +* +* @param[in] pSlice - Slice instance. +* @param[in] nVerticesBufferSize - Number of elements in buffer +* @param[out] pVerticesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pVerticesBuffer - Position2D buffer of contains the positions. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_getvertices(Lib3MF_Slice pSlice, const Lib3MF_uint64 nVerticesBufferSize, Lib3MF_uint64* pVerticesNeededCount, Lib3MF::sPosition2D * pVerticesBuffer); + +/** +* Get the number of vertices in a slice +* +* @param[in] pSlice - Slice instance. +* @param[out] pCount - the number of vertices in the slice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_getvertexcount(Lib3MF_Slice pSlice, Lib3MF_uint64 * pCount); + +/** +* Add a new polygon to this slice +* +* @param[in] pSlice - Slice instance. +* @param[in] nIndicesBufferSize - Number of elements in buffer +* @param[in] pIndicesBuffer - uint32 buffer of the new indices of the new polygon +* @param[out] pIndex - the index of the new polygon +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_addpolygon(Lib3MF_Slice pSlice, Lib3MF_uint64 nIndicesBufferSize, const Lib3MF_uint32 * pIndicesBuffer, Lib3MF_uint64 * pIndex); + +/** +* Get the number of polygons in the slice +* +* @param[in] pSlice - Slice instance. +* @param[out] pCount - the number of polygons in the slice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_getpolygoncount(Lib3MF_Slice pSlice, Lib3MF_uint64 * pCount); + +/** +* Set all indices of a polygon +* +* @param[in] pSlice - Slice instance. +* @param[in] nIndex - the index of the polygon to manipulate +* @param[in] nIndicesBufferSize - Number of elements in buffer +* @param[in] pIndicesBuffer - uint32 buffer of the new indices of the index-th polygon +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_setpolygonindices(Lib3MF_Slice pSlice, Lib3MF_uint64 nIndex, Lib3MF_uint64 nIndicesBufferSize, const Lib3MF_uint32 * pIndicesBuffer); + +/** +* Get all vertices of a slice +* +* @param[in] pSlice - Slice instance. +* @param[in] nIndex - the index of the polygon to manipulate +* @param[in] nIndicesBufferSize - Number of elements in buffer +* @param[out] pIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pIndicesBuffer - uint32 buffer of the indices of the index-th polygon +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_getpolygonindices(Lib3MF_Slice pSlice, Lib3MF_uint64 nIndex, const Lib3MF_uint64 nIndicesBufferSize, Lib3MF_uint64* pIndicesNeededCount, Lib3MF_uint32 * pIndicesBuffer); + +/** +* Get the number of vertices in a slice +* +* @param[in] pSlice - Slice instance. +* @param[in] nIndex - the index of the polygon to manipulate +* @param[out] pCount - the number of indices of the index-th polygon +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_getpolygonindexcount(Lib3MF_Slice pSlice, Lib3MF_uint64 nIndex, Lib3MF_uint64 * pCount); + +/** +* Get the upper Z-Coordinate of this slice. +* +* @param[in] pSlice - Slice instance. +* @param[out] pZTop - the upper Z-Coordinate of this slice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slice_getztop(Lib3MF_Slice pSlice, Lib3MF_double * pZTop); + +/************************************************************************************************************************* + Class definition for SliceStack +**************************************************************************************************************************/ + +/** +* Get the lower Z-Coordinate of the slice stack. +* +* @param[in] pSliceStack - SliceStack instance. +* @param[out] pZBottom - the lower Z-Coordinate the slice stack +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_getbottomz(Lib3MF_SliceStack pSliceStack, Lib3MF_double * pZBottom); + +/** +* Returns the number of slices +* +* @param[in] pSliceStack - SliceStack instance. +* @param[out] pCount - the number of slices +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_getslicecount(Lib3MF_SliceStack pSliceStack, Lib3MF_uint64 * pCount); + +/** +* Query a slice from the slice stack +* +* @param[in] pSliceStack - SliceStack instance. +* @param[in] nSliceIndex - the index of the slice +* @param[out] pTheSlice - the Slice instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_getslice(Lib3MF_SliceStack pSliceStack, Lib3MF_uint64 nSliceIndex, Lib3MF_Slice * pTheSlice); + +/** +* Returns the number of slices +* +* @param[in] pSliceStack - SliceStack instance. +* @param[in] dZTop - upper Z coordinate of the slice +* @param[out] pTheSlice - a new Slice instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_addslice(Lib3MF_SliceStack pSliceStack, Lib3MF_double dZTop, Lib3MF_Slice * pTheSlice); + +/** +* Returns the number of slice refs +* +* @param[in] pSliceStack - SliceStack instance. +* @param[out] pCount - the number of slicereferences +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_getslicerefcount(Lib3MF_SliceStack pSliceStack, Lib3MF_uint64 * pCount); + +/** +* Adds another existing slicestack as sliceref in this slicestack +* +* @param[in] pSliceStack - SliceStack instance. +* @param[in] pTheSliceStack - the slicestack to use as sliceref +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_addslicestackreference(Lib3MF_SliceStack pSliceStack, Lib3MF_SliceStack pTheSliceStack); + +/** +* Adds another existing slicestack as sliceref in this slicestack +* +* @param[in] pSliceStack - SliceStack instance. +* @param[in] nSliceRefIndex - the index of the slice ref +* @param[out] pTheSliceStack - the slicestack that is used as sliceref +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_getslicestackreference(Lib3MF_SliceStack pSliceStack, Lib3MF_uint64 nSliceRefIndex, Lib3MF_SliceStack * pTheSliceStack); + +/** +* Removes the indirection of slices via slice-refs, i.e. creates the slices of all slice refs of this SliceStack as actual slices of this SliceStack. All previously existing slices or slicerefs will be removed. +* +* @param[in] pSliceStack - SliceStack instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_collapseslicereferences(Lib3MF_SliceStack pSliceStack); + +/** +* Sets the package path where this Slice should be stored. Input an empty string to reset the path +* +* @param[in] pSliceStack - SliceStack instance. +* @param[in] pPath - the package path where this Slice should be stored +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_setownpath(Lib3MF_SliceStack pSliceStack, const char * pPath); + +/** +* Obtains the package path where this Slice should be stored. Returns an empty string if the slicestack is stored within the root model. +* +* @param[in] pSliceStack - SliceStack instance. +* @param[in] nPathBufferSize - size of the buffer (including trailing 0) +* @param[out] pPathNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPathBuffer - buffer of the package path where this Slice will be stored, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_slicestack_getownpath(Lib3MF_SliceStack pSliceStack, const Lib3MF_uint32 nPathBufferSize, Lib3MF_uint32* pPathNeededChars, char * pPathBuffer); + +/************************************************************************************************************************* + Class definition for Consumer +**************************************************************************************************************************/ + +/** +* Gets the consumerid +* +* @param[in] pConsumer - Consumer instance. +* @param[in] nConsumerIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pConsumerIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pConsumerIDBuffer - buffer of A unique identifier for the consumers, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_consumer_getconsumerid(Lib3MF_Consumer pConsumer, const Lib3MF_uint32 nConsumerIDBufferSize, Lib3MF_uint32* pConsumerIDNeededChars, char * pConsumerIDBuffer); + +/** +* Getts the keyid +* +* @param[in] pConsumer - Consumer instance. +* @param[in] nKeyIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pKeyIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pKeyIDBuffer - buffer of The identifier for the key of this consumer, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_consumer_getkeyid(Lib3MF_Consumer pConsumer, const Lib3MF_uint32 nKeyIDBufferSize, Lib3MF_uint32* pKeyIDNeededChars, char * pKeyIDBuffer); + +/** +* Gets the keyvalue associated with this consumer +* +* @param[in] pConsumer - Consumer instance. +* @param[in] nKeyValueBufferSize - size of the buffer (including trailing 0) +* @param[out] pKeyValueNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pKeyValueBuffer - buffer of The public key, when available, of this consumer, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_consumer_getkeyvalue(Lib3MF_Consumer pConsumer, const Lib3MF_uint32 nKeyValueBufferSize, Lib3MF_uint32* pKeyValueNeededChars, char * pKeyValueBuffer); + +/************************************************************************************************************************* + Class definition for AccessRight +**************************************************************************************************************************/ + +/** +* Gets the consumer associated with this access right +* +* @param[in] pAccessRight - AccessRight instance. +* @param[out] pConsumer - The consumer instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_accessright_getconsumer(Lib3MF_AccessRight pAccessRight, Lib3MF_Consumer * pConsumer); + +/** +* Gets the associated encryption algorithm +* +* @param[in] pAccessRight - AccessRight instance. +* @param[out] pAlgorithm - The algorithm used for the key in this accessright +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_accessright_getwrappingalgorithm(Lib3MF_AccessRight pAccessRight, Lib3MF::eWrappingAlgorithm * pAlgorithm); + +/** +* Gets the associated mask generation function algorithm +* +* @param[in] pAccessRight - AccessRight instance. +* @param[out] pAlgorithm - The MFG1 algorithm +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_accessright_getmgfalgorithm(Lib3MF_AccessRight pAccessRight, Lib3MF::eMgfAlgorithm * pAlgorithm); + +/** +* Gets the digest method assoicated +* +* @param[in] pAccessRight - AccessRight instance. +* @param[out] pAlgorithm - The digest method for this accessright +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_accessright_getdigestmethod(Lib3MF_AccessRight pAccessRight, Lib3MF::eDigestMethod * pAlgorithm); + +/************************************************************************************************************************* + Class definition for ContentEncryptionParams +**************************************************************************************************************************/ + +/** +* Returns the encryption method to be used in this encryption process +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[out] pAlgorithm - +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_getencryptionalgorithm(Lib3MF_ContentEncryptionParams pContentEncryptionParams, Lib3MF::eEncryptionAlgorithm * pAlgorithm); + +/** +* Gets the key for the resource associated +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[in] nByteDataBufferSize - Number of elements in buffer +* @param[out] pByteDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pByteDataBuffer - uint8 buffer of Pointer to a buffer where to place the key. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_getkey(Lib3MF_ContentEncryptionParams pContentEncryptionParams, const Lib3MF_uint64 nByteDataBufferSize, Lib3MF_uint64* pByteDataNeededCount, Lib3MF_uint8 * pByteDataBuffer); + +/** +* Gets the IV data +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[in] nByteDataBufferSize - Number of elements in buffer +* @param[out] pByteDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pByteDataBuffer - uint8 buffer of Pointer to a buffer where to place the data. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_getinitializationvector(Lib3MF_ContentEncryptionParams pContentEncryptionParams, const Lib3MF_uint64 nByteDataBufferSize, Lib3MF_uint64* pByteDataNeededCount, Lib3MF_uint8 * pByteDataBuffer); + +/** +* A handler descriptor that uniquely identifies the context of the resource. Each resource will be assigned a different value +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[in] nByteDataBufferSize - Number of elements in buffer +* @param[out] pByteDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pByteDataBuffer - uint8 buffer of Pointer to a buffer where to place the data. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_getauthenticationtag(Lib3MF_ContentEncryptionParams pContentEncryptionParams, const Lib3MF_uint64 nByteDataBufferSize, Lib3MF_uint64* pByteDataNeededCount, Lib3MF_uint8 * pByteDataBuffer); + +/** +* Sets the authentication tag +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[in] nByteDataBufferSize - Number of elements in buffer +* @param[in] pByteDataBuffer - uint8 buffer of The authentication tag size +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_setauthenticationtag(Lib3MF_ContentEncryptionParams pContentEncryptionParams, Lib3MF_uint64 nByteDataBufferSize, const Lib3MF_uint8 * pByteDataBuffer); + +/** +* A handler descriptor that uniquely identifies the context of the resource. Each resource will be assigned a different value +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[in] nByteDataBufferSize - Number of elements in buffer +* @param[out] pByteDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pByteDataBuffer - uint8 buffer of Buffer where the data will be placed +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_getadditionalauthenticationdata(Lib3MF_ContentEncryptionParams pContentEncryptionParams, const Lib3MF_uint64 nByteDataBufferSize, Lib3MF_uint64* pByteDataNeededCount, Lib3MF_uint8 * pByteDataBuffer); + +/** +* A handler descriptor that uniquely identifies the context of the resource. Each resource will be assigned a different value +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[out] pDescriptor - +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_getdescriptor(Lib3MF_ContentEncryptionParams pContentEncryptionParams, Lib3MF_uint64 * pDescriptor); + +/** +* Gets the resourcedatagroup keyuuid +* +* @param[in] pContentEncryptionParams - ContentEncryptionParams instance. +* @param[in] nUUIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pUUIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pUUIDBuffer - buffer of The resourcedatagroup keyuuid that may be use to reference an external key, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_contentencryptionparams_getkeyuuid(Lib3MF_ContentEncryptionParams pContentEncryptionParams, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer); + +/************************************************************************************************************************* + Class definition for ResourceData +**************************************************************************************************************************/ + +/** +* Gets the encrypted part path +* +* @param[in] pResourceData - ResourceData instance. +* @param[out] pPath - The part path +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedata_getpath(Lib3MF_ResourceData pResourceData, Lib3MF_PackagePart * pPath); + +/** +* Gets the encryption algorithm used to encrypt this ResourceData +* +* @param[in] pResourceData - ResourceData instance. +* @param[out] pEncryptionAlgorithm - The encryption algorithm +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedata_getencryptionalgorithm(Lib3MF_ResourceData pResourceData, Lib3MF::eEncryptionAlgorithm * pEncryptionAlgorithm); + +/** +* Tells whether this ResourceData is compressed or not +* +* @param[in] pResourceData - ResourceData instance. +* @param[out] pCompression - The compression method +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedata_getcompression(Lib3MF_ResourceData pResourceData, Lib3MF::eCompression * pCompression); + +/** +* Tells whether this ResourceData is compressed or not +* +* @param[in] pResourceData - ResourceData instance. +* @param[in] nByteDataBufferSize - Number of elements in buffer +* @param[out] pByteDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pByteDataBuffer - uint8 buffer of The compression method +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedata_getadditionalauthenticationdata(Lib3MF_ResourceData pResourceData, const Lib3MF_uint64 nByteDataBufferSize, Lib3MF_uint64* pByteDataNeededCount, Lib3MF_uint8 * pByteDataBuffer); + +/************************************************************************************************************************* + Class definition for ResourceDataGroup +**************************************************************************************************************************/ + +/** +* Sets the resourcedatagroup keyuuid +* +* @param[in] pResourceDataGroup - ResourceDataGroup instance. +* @param[in] nUUIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pUUIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pUUIDBuffer - buffer of The new resourcedatagroup keyuuid., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedatagroup_getkeyuuid(Lib3MF_ResourceDataGroup pResourceDataGroup, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer); + +/** +* Add accessright to resourcedatagroup element +* +* @param[in] pResourceDataGroup - ResourceDataGroup instance. +* @param[in] pConsumer - The Consumer reference +* @param[in] eWrappingAlgorithm - The key wrapping algorithm to be used +* @param[in] eMgfAlgorithm - The mask generation function to be used +* @param[in] eDigestMethod - The digest mechanism to be used +* @param[out] pTheAccessRight - The acess right instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedatagroup_addaccessright(Lib3MF_ResourceDataGroup pResourceDataGroup, Lib3MF_Consumer pConsumer, Lib3MF::eWrappingAlgorithm eWrappingAlgorithm, Lib3MF::eMgfAlgorithm eMgfAlgorithm, Lib3MF::eDigestMethod eDigestMethod, Lib3MF_AccessRight * pTheAccessRight); + +/** +* Finds the AccessRight associated with a Consumer +* +* @param[in] pResourceDataGroup - ResourceDataGroup instance. +* @param[in] pConsumer - The Consumer instance +* @param[out] pTheAccessRight - The AcessRight instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedatagroup_findaccessrightbyconsumer(Lib3MF_ResourceDataGroup pResourceDataGroup, Lib3MF_Consumer pConsumer, Lib3MF_AccessRight * pTheAccessRight); + +/** +* Removes access from a Consumer on this resource data group +* +* @param[in] pResourceDataGroup - ResourceDataGroup instance. +* @param[in] pConsumer - The Consumer instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourcedatagroup_removeaccessright(Lib3MF_ResourceDataGroup pResourceDataGroup, Lib3MF_Consumer pConsumer); + +/************************************************************************************************************************* + Class definition for KeyStore +**************************************************************************************************************************/ + +/** +* Adds a consumer to the keystore +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pConsumerID - A unique identifier for the consumer +* @param[in] pKeyID - The id of the key of the consumer +* @param[in] pKeyValue - The public key for this consumer in PEM format +* @param[out] pConsumer - The consumer instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_addconsumer(Lib3MF_KeyStore pKeyStore, const char * pConsumerID, const char * pKeyID, const char * pKeyValue, Lib3MF_Consumer * pConsumer); + +/** +* Gets the number of consumers in the keystore +* +* @param[in] pKeyStore - KeyStore instance. +* @param[out] pCount - The consumer count +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getconsumercount(Lib3MF_KeyStore pKeyStore, Lib3MF_uint64 * pCount); + +/** +* Get a consumer from the keystore +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] nConsumerIndex - The index of the consumer +* @param[out] pConsumer - The consumer instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getconsumer(Lib3MF_KeyStore pKeyStore, Lib3MF_uint64 nConsumerIndex, Lib3MF_Consumer * pConsumer); + +/** +* Removes a consumer from the keystore +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pConsumer - The consumer instance to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_removeconsumer(Lib3MF_KeyStore pKeyStore, Lib3MF_Consumer pConsumer); + +/** +* Finds a consumer by ID +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pConsumerID - The ID of the consumer +* @param[out] pConsumer - The consumer instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_findconsumer(Lib3MF_KeyStore pKeyStore, const char * pConsumerID, Lib3MF_Consumer * pConsumer); + +/** +* Gets the number of resource data group in the keysore +* +* @param[in] pKeyStore - KeyStore instance. +* @param[out] pCount - The number of resource data available +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getresourcedatagroupcount(Lib3MF_KeyStore pKeyStore, Lib3MF_uint64 * pCount); + +/** +* Adds a resource data group into the keystore. +* +* @param[in] pKeyStore - KeyStore instance. +* @param[out] pResourceDataGroup - The resource data group instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_addresourcedatagroup(Lib3MF_KeyStore pKeyStore, Lib3MF_ResourceDataGroup * pResourceDataGroup); + +/** +* Gets a resource data group +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] nResourceDataIndex - The index of the resource data +* @param[out] pResourceDataGroup - The resource data group instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getresourcedatagroup(Lib3MF_KeyStore pKeyStore, Lib3MF_uint64 nResourceDataIndex, Lib3MF_ResourceDataGroup * pResourceDataGroup); + +/** +* Removes a resource data group +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pResourceDataGroup - The resource data group instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_removeresourcedatagroup(Lib3MF_KeyStore pKeyStore, Lib3MF_ResourceDataGroup pResourceDataGroup); + +/** +* Finds a resource data group that contains a particular resourcedata +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pPartPath - The target path for the resourcedata hold by the resource data group +* @param[out] pResourceDataGroup - The data resource instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_findresourcedatagroup(Lib3MF_KeyStore pKeyStore, Lib3MF_PackagePart pPartPath, Lib3MF_ResourceDataGroup * pResourceDataGroup); + +/** +* Add resourcedata to resourcedatagroup element +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pResourceDataGroup - The resource data group where to add this resource data +* @param[in] pPartPath - The path of the part to be encrypted +* @param[in] eAlgorithm - The encryption algorithm to be used to encrypt this resource +* @param[in] eCompression - Whether compression should be used prior to encryption +* @param[in] nAdditionalAuthenticationDataBufferSize - Number of elements in buffer +* @param[in] pAdditionalAuthenticationDataBuffer - uint8 buffer of Additional data to be encrypted along the contents for better security +* @param[out] pResourceData - The data resource instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_addresourcedata(Lib3MF_KeyStore pKeyStore, Lib3MF_ResourceDataGroup pResourceDataGroup, Lib3MF_PackagePart pPartPath, Lib3MF::eEncryptionAlgorithm eAlgorithm, Lib3MF::eCompression eCompression, Lib3MF_uint64 nAdditionalAuthenticationDataBufferSize, const Lib3MF_uint8 * pAdditionalAuthenticationDataBuffer, Lib3MF_ResourceData * pResourceData); + +/** +* Removes a resource data +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pResourceData - The resource data to be removed +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_removeresourcedata(Lib3MF_KeyStore pKeyStore, Lib3MF_ResourceData pResourceData); + +/** +* Finds a resource data on this resource group +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pResourcePath - The target path for the resourcedata +* @param[out] pResourceData - The resource data instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_findresourcedata(Lib3MF_KeyStore pKeyStore, Lib3MF_PackagePart pResourcePath, Lib3MF_ResourceData * pResourceData); + +/** +* Gets the number of resource data in the keysore +* +* @param[in] pKeyStore - KeyStore instance. +* @param[out] pCount - The number of resource data available +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getresourcedatacount(Lib3MF_KeyStore pKeyStore, Lib3MF_uint64 * pCount); + +/** +* Gets a resource data +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] nResourceDataIndex - The index of the resource data +* @param[out] pResourceData - The data resource instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getresourcedata(Lib3MF_KeyStore pKeyStore, Lib3MF_uint64 nResourceDataIndex, Lib3MF_ResourceData * pResourceData); + +/** +* Gets the keystore UUID +* +* @param[in] pKeyStore - KeyStore instance. +* @param[out] pHasUUID - flag whether the keystore has a UUID +* @param[in] nUUIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pUUIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pUUIDBuffer - buffer of returns the keystore uuid., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_getuuid(Lib3MF_KeyStore pKeyStore, bool * pHasUUID, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer); + +/** +* Sets the keystore UUID +* +* @param[in] pKeyStore - KeyStore instance. +* @param[in] pUUID - The new keystore uuid. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_keystore_setuuid(Lib3MF_KeyStore pKeyStore, const char * pUUID); + +/************************************************************************************************************************* + Class definition for Model +**************************************************************************************************************************/ + +/** +* Returns the PackagePart within the OPC package that holds the root model. +* +* @param[in] pModel - Model instance. +* @param[out] pRootModelPart - the PackagePart within the OPC package that holds the model-file +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_rootmodelpart(Lib3MF_Model pModel, Lib3MF_PackagePart * pRootModelPart); + +/** +* Returns a new PackagePart for use within the OPC package. +* +* @param[in] pModel - Model instance. +* @param[in] pAbsolutePath - the absolute Path (physical location) within the OPC package +* @param[out] pModelPart - the new PackagePart within the OPC package +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_findorcreatepackagepart(Lib3MF_Model pModel, const char * pAbsolutePath, Lib3MF_PackagePart * pModelPart); + +/** +* sets the units of a model. +* +* @param[in] pModel - Model instance. +* @param[in] eUnit - Unit enum value for the model unit +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setunit(Lib3MF_Model pModel, Lib3MF::eModelUnit eUnit); + +/** +* returns the units of a model. +* +* @param[in] pModel - Model instance. +* @param[out] pUnit - Unit enum value for the model unit +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getunit(Lib3MF_Model pModel, Lib3MF::eModelUnit * pUnit); + +/** +* retrieves the language of a model +* +* @param[in] pModel - Model instance. +* @param[in] nLanguageBufferSize - size of the buffer (including trailing 0) +* @param[out] pLanguageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pLanguageBuffer - buffer of language identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlanguage(Lib3MF_Model pModel, const Lib3MF_uint32 nLanguageBufferSize, Lib3MF_uint32* pLanguageNeededChars, char * pLanguageBuffer); + +/** +* sets the language of a model +* +* @param[in] pModel - Model instance. +* @param[in] pLanguage - language identifier +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setlanguage(Lib3MF_Model pModel, const char * pLanguage); + +/** +* creates a model writer instance for a specific file type +* +* @param[in] pModel - Model instance. +* @param[in] pWriterClass - string identifier for the file type +* @param[out] pWriterInstance - string identifier for the file type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_querywriter(Lib3MF_Model pModel, const char * pWriterClass, Lib3MF_Writer * pWriterInstance); + +/** +* creates a model reader instance for a specific file type +* +* @param[in] pModel - Model instance. +* @param[in] pReaderClass - string identifier for the file type +* @param[out] pReaderInstance - string identifier for the file type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_queryreader(Lib3MF_Model pModel, const char * pReaderClass, Lib3MF_Reader * pReaderInstance); + +/** +* finds a model texture by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pTextureInstance - returns the texture2d instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_gettexture2dbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_Texture2D * pTextureInstance); + +/** +* returns a Property's type +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - Resource ID of the Property to Query +* @param[out] pThePropertyType - returns a Property's type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getpropertytypebyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF::ePropertyType * pThePropertyType); + +/** +* finds a model base material group by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pBaseMaterialGroupInstance - returns the BaseMaterialGroup instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getbasematerialgroupbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_BaseMaterialGroup * pBaseMaterialGroupInstance); + +/** +* finds a model texture2d group by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pTexture2DGroupInstance - returns the Texture2DGroup instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_gettexture2dgroupbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_Texture2DGroup * pTexture2DGroupInstance); + +/** +* finds a model CompositeMaterials by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pCompositeMaterialsInstance - returns the CompositeMaterials instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getcompositematerialsbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_CompositeMaterials * pCompositeMaterialsInstance); + +/** +* finds a model MultiPropertyGroup by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pMultiPropertyGroupInstance - returns the MultiPropertyGroup instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getmultipropertygroupbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_MultiPropertyGroup * pMultiPropertyGroupInstance); + +/** +* finds a mesh object by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pMeshObjectInstance - returns the mesh object instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getmeshobjectbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_MeshObject * pMeshObjectInstance); + +/** +* finds a components object by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pComponentsObjectInstance - returns the components object instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getcomponentsobjectbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_ComponentsObject * pComponentsObjectInstance); + +/** +* finds a model color group by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pColorGroupInstance - returns the ColorGroup instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getcolorgroupbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_ColorGroup * pColorGroupInstance); + +/** +* finds a model slicestack by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pSliceStacInstance - returns the slicestack instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getslicestackbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_SliceStack * pSliceStacInstance); + +/** +* returns, whether a build has a UUID and, if true, the build's UUID +* +* @param[in] pModel - Model instance. +* @param[out] pHasUUID - flag whether the build has a UUID +* @param[in] nUUIDBufferSize - size of the buffer (including trailing 0) +* @param[out] pUUIDNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pUUIDBuffer - buffer of the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx', may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getbuilduuid(Lib3MF_Model pModel, bool * pHasUUID, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer); + +/** +* sets the build's UUID +* +* @param[in] pModel - Model instance. +* @param[in] pUUID - the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setbuilduuid(Lib3MF_Model pModel, const char * pUUID); + +/** +* creates a build item iterator instance with all build items. +* +* @param[in] pModel - Model instance. +* @param[out] pBuildItemIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getbuilditems(Lib3MF_Model pModel, Lib3MF_BuildItemIterator * pBuildItemIterator); + +/** +* Returns the outbox of a Model +* +* @param[in] pModel - Model instance. +* @param[out] pOutbox - Outbox of this Model +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getoutbox(Lib3MF_Model pModel, Lib3MF::sBox * pOutbox); + +/** +* creates a resource iterator instance with all resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getresources(Lib3MF_Model pModel, Lib3MF_ResourceIterator * pResourceIterator); + +/** +* creates a resource iterator instance with all object resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getobjects(Lib3MF_Model pModel, Lib3MF_ObjectIterator * pResourceIterator); + +/** +* creates a resource iterator instance with all mesh object resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getmeshobjects(Lib3MF_Model pModel, Lib3MF_MeshObjectIterator * pResourceIterator); + +/** +* creates a resource iterator instance with all components object resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getcomponentsobjects(Lib3MF_Model pModel, Lib3MF_ComponentsObjectIterator * pResourceIterator); + +/** +* creates a Texture2DIterator instance with all texture2d resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_gettexture2ds(Lib3MF_Model pModel, Lib3MF_Texture2DIterator * pResourceIterator); + +/** +* creates a BaseMaterialGroupIterator instance with all base material resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getbasematerialgroups(Lib3MF_Model pModel, Lib3MF_BaseMaterialGroupIterator * pResourceIterator); + +/** +* creates a ColorGroupIterator instance with all ColorGroup resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getcolorgroups(Lib3MF_Model pModel, Lib3MF_ColorGroupIterator * pResourceIterator); + +/** +* creates a Texture2DGroupIterator instance with all base material resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_gettexture2dgroups(Lib3MF_Model pModel, Lib3MF_Texture2DGroupIterator * pResourceIterator); + +/** +* creates a CompositeMaterialsIterator instance with all CompositeMaterials resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getcompositematerials(Lib3MF_Model pModel, Lib3MF_CompositeMaterialsIterator * pResourceIterator); + +/** +* creates a MultiPropertyGroupsIterator instance with all MultiPropertyGroup resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getmultipropertygroups(Lib3MF_Model pModel, Lib3MF_MultiPropertyGroupIterator * pResourceIterator); + +/** +* creates a resource iterator instance with all slice stack resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getslicestacks(Lib3MF_Model pModel, Lib3MF_SliceStackIterator * pResourceIterator); + +/** +* Merges all components and objects which are referenced by a build item into a mesh. The memory is duplicated and a new model is created. +* +* @param[in] pModel - Model instance. +* @param[out] pMergedModelInstance - returns the merged model instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_mergetomodel(Lib3MF_Model pModel, Lib3MF_Model * pMergedModelInstance); + +/** +* adds an empty mesh object to the model. +* +* @param[in] pModel - Model instance. +* @param[out] pMeshObjectInstance - returns the mesh object instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addmeshobject(Lib3MF_Model pModel, Lib3MF_MeshObject * pMeshObjectInstance); + +/** +* adds an empty component object to the model. +* +* @param[in] pModel - Model instance. +* @param[out] pComponentsObjectInstance - returns the components object instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addcomponentsobject(Lib3MF_Model pModel, Lib3MF_ComponentsObject * pComponentsObjectInstance); + +/** +* creates a new model slicestack by its id +* +* @param[in] pModel - Model instance. +* @param[in] dZBottom - Bottom Z value of the slicestack +* @param[out] pSliceStackInstance - returns the new slicestack instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addslicestack(Lib3MF_Model pModel, Lib3MF_double dZBottom, Lib3MF_SliceStack * pSliceStackInstance); + +/** +* adds a texture2d resource to the model. Its path is given by that of an existing attachment. +* +* @param[in] pModel - Model instance. +* @param[in] pTextureAttachment - attachment containing the image data. +* @param[out] pTexture2DInstance - returns the new texture instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addtexture2dfromattachment(Lib3MF_Model pModel, Lib3MF_Attachment pTextureAttachment, Lib3MF_Texture2D * pTexture2DInstance); + +/** +* adds an empty BaseMaterialGroup resource to the model. +* +* @param[in] pModel - Model instance. +* @param[out] pBaseMaterialGroupInstance - returns the new base material instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addbasematerialgroup(Lib3MF_Model pModel, Lib3MF_BaseMaterialGroup * pBaseMaterialGroupInstance); + +/** +* adds an empty ColorGroup resource to the model. +* +* @param[in] pModel - Model instance. +* @param[out] pColorGroupInstance - returns the new ColorGroup instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addcolorgroup(Lib3MF_Model pModel, Lib3MF_ColorGroup * pColorGroupInstance); + +/** +* adds an empty Texture2DGroup resource to the model. +* +* @param[in] pModel - Model instance. +* @param[in] pTexture2DInstance - The texture2D instance of the created Texture2DGroup. +* @param[out] pTexture2DGroupInstance - returns the new Texture2DGroup instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addtexture2dgroup(Lib3MF_Model pModel, Lib3MF_Texture2D pTexture2DInstance, Lib3MF_Texture2DGroup * pTexture2DGroupInstance); + +/** +* adds an empty CompositeMaterials resource to the model. +* +* @param[in] pModel - Model instance. +* @param[in] pBaseMaterialGroupInstance - The BaseMaterialGroup instance of the created CompositeMaterials. +* @param[out] pCompositeMaterialsInstance - returns the new CompositeMaterials instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addcompositematerials(Lib3MF_Model pModel, Lib3MF_BaseMaterialGroup pBaseMaterialGroupInstance, Lib3MF_CompositeMaterials * pCompositeMaterialsInstance); + +/** +* adds an empty MultiPropertyGroup resource to the model. +* +* @param[in] pModel - Model instance. +* @param[out] pMultiPropertyGroupInstance - returns the new MultiPropertyGroup instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addmultipropertygroup(Lib3MF_Model pModel, Lib3MF_MultiPropertyGroup * pMultiPropertyGroupInstance); + +/** +* adds a build item to the model. +* +* @param[in] pModel - Model instance. +* @param[in] pObject - Object instance. +* @param[in] pTransform - Transformation matrix. +* @param[out] pBuildItemInstance - returns the build item instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addbuilditem(Lib3MF_Model pModel, Lib3MF_Object pObject, const Lib3MF::sTransform * pTransform, Lib3MF_BuildItem * pBuildItemInstance); + +/** +* removes a build item from the model +* +* @param[in] pModel - Model instance. +* @param[in] pBuildItemInstance - Build item to remove. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removebuilditem(Lib3MF_Model pModel, Lib3MF_BuildItem pBuildItemInstance); + +/** +* Returns the metadata of the model as MetaDataGroup +* +* @param[in] pModel - Model instance. +* @param[out] pTheMetaDataGroup - returns an Instance of the metadatagroup of the model +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getmetadatagroup(Lib3MF_Model pModel, Lib3MF_MetaDataGroup * pTheMetaDataGroup); + +/** +* adds an attachment stream to the model. The OPC part will be related to the model stream with a certain relationship type. +* +* @param[in] pModel - Model instance. +* @param[in] pURI - Path of the attachment +* @param[in] pRelationShipType - Relationship type of the attachment +* @param[out] pAttachmentInstance - Instance of the attachment object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addattachment(Lib3MF_Model pModel, const char * pURI, const char * pRelationShipType, Lib3MF_Attachment * pAttachmentInstance); + +/** +* Removes attachment from the model. +* +* @param[in] pModel - Model instance. +* @param[in] pAttachmentInstance - Attachment instance to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeattachment(Lib3MF_Model pModel, Lib3MF_Attachment pAttachmentInstance); + +/** +* retrieves an attachment stream object from the model.. +* +* @param[in] pModel - Model instance. +* @param[in] nIndex - Index of the attachment stream +* @param[out] pAttachmentInstance - Instance of the attachment object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getattachment(Lib3MF_Model pModel, Lib3MF_uint32 nIndex, Lib3MF_Attachment * pAttachmentInstance); + +/** +* retrieves an attachment stream object from the model. +* +* @param[in] pModel - Model instance. +* @param[in] pURI - Path URI in the package +* @param[out] pAttachmentInstance - Instance of the attachment object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_findattachment(Lib3MF_Model pModel, const char * pURI, Lib3MF_Attachment * pAttachmentInstance); + +/** +* retrieves the number of attachments of the model. +* +* @param[in] pModel - Model instance. +* @param[out] pAttachmentCount - Returns the number of attachments. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getattachmentcount(Lib3MF_Model pModel, Lib3MF_uint32 * pAttachmentCount); + +/** +* Retrieve whether the OPC package contains a package thumbnail. +* +* @param[in] pModel - Model instance. +* @param[out] pHasThumbnail - returns whether the OPC package contains a package thumbnail +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_haspackagethumbnailattachment(Lib3MF_Model pModel, bool * pHasThumbnail); + +/** +* Create a new or the existing package thumbnail for the OPC package. +* +* @param[in] pModel - Model instance. +* @param[out] pAttachment - Instance of a new or the existing thumbnailattachment object. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_createpackagethumbnailattachment(Lib3MF_Model pModel, Lib3MF_Attachment * pAttachment); + +/** +* Get the attachment to the OPC package containing the package thumbnail. +* +* @param[in] pModel - Model instance. +* @param[out] pAttachment - Instance of the thumbnailattachment object or NULL. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getpackagethumbnailattachment(Lib3MF_Model pModel, Lib3MF_Attachment * pAttachment); + +/** +* Remove the attachment to the OPC package containing the package thumbnail. +* +* @param[in] pModel - Model instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removepackagethumbnailattachment(Lib3MF_Model pModel); + +/** +* Adds a new Content Type to the model. +* +* @param[in] pModel - Model instance. +* @param[in] pExtension - File Extension +* @param[in] pContentType - Content Type Identifier +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addcustomcontenttype(Lib3MF_Model pModel, const char * pExtension, const char * pContentType); + +/** +* Removes a custom Content Type from the model (UTF8 version). +* +* @param[in] pModel - Model instance. +* @param[in] pExtension - File Extension +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removecustomcontenttype(Lib3MF_Model pModel, const char * pExtension); + +/** +* Sets the random number generator callback for use in the library +* +* @param[in] pModel - Model instance. +* @param[in] pTheCallback - The callback used to generate random numbers +* @param[in] pUserData - Userdata to be passed to the callback function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setrandomnumbercallback(Lib3MF_Model pModel, Lib3MF::RandomNumberCallback pTheCallback, Lib3MF_pvoid pUserData); + +/** +* Gets the keystore associated with this model +* +* @param[in] pModel - Model instance. +* @param[out] pKeyStore - The package keystore +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getkeystore(Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getlibraryversion(Lib3MF_uint32 * pMajor, Lib3MF_uint32 * pMinor, Lib3MF_uint32 * pMicro); + +/** +* retrieves prerelease information of this library. +* +* @param[out] pHasPrereleaseInfo - Does the library provide prerelease version? +* @param[in] nPrereleaseInfoBufferSize - size of the buffer (including trailing 0) +* @param[out] pPrereleaseInfoNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPrereleaseInfoBuffer - buffer of retrieves prerelease information of this library., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getprereleaseinformation(bool * pHasPrereleaseInfo, const Lib3MF_uint32 nPrereleaseInfoBufferSize, Lib3MF_uint32* pPrereleaseInfoNeededChars, char * pPrereleaseInfoBuffer); + +/** +* retrieves build information of this library. +* +* @param[out] pHasBuildInfo - Does the library provide build version? +* @param[in] nBuildInformationBufferSize - size of the buffer (including trailing 0) +* @param[out] pBuildInformationNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBuildInformationBuffer - buffer of retrieves build information of this library., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getbuildinformation(bool * pHasBuildInfo, const Lib3MF_uint32 nBuildInformationBufferSize, Lib3MF_uint32* pBuildInformationNeededChars, char * pBuildInformationBuffer); + +/** +* retrieves whether a specification is supported, and if so, which version. +* +* @param[in] pSpecificationURL - URL of extension to check +* @param[out] pIsSupported - returns whether this specification is supported +* @param[out] pMajor - returns the major version of the extension (if IsSupported) +* @param[out] pMinor - returns the minor version of the extension (if IsSupported) +* @param[out] pMicro - returns the micro version of the extension (if IsSupported) +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getspecificationversion(const char * pSpecificationURL, bool * pIsSupported, Lib3MF_uint32 * pMajor, Lib3MF_uint32 * pMinor, Lib3MF_uint32 * pMicro); + +/** +* creates an empty model instance. +* +* @param[out] pModel - returns an empty model instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_createmodel(Lib3MF_Model * pModel); + +/** +* releases shared ownership of an object instance +* +* @param[in] pInstance - the object instance to release +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_release(Lib3MF_Base pInstance); + +/** +* acquires shared ownership of an object instance +* +* @param[in] pInstance - the object instance to acquire +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_acquire(Lib3MF_Base pInstance); + +/** +* Sets the journal file path +* +* @param[in] pJournalPath - File name of the journal file +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_setjournal(const char * pJournalPath); + +/** +* Retrieves the last error string of an instance +* +* @param[in] pInstance - Object where the error occured. +* @param[in] nLastErrorStringBufferSize - size of the buffer (including trailing 0) +* @param[out] pLastErrorStringNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pLastErrorStringBuffer - buffer of Last Error String, may be NULL +* @param[out] pHasLastError - Returns if the instance has a last error. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getlasterror(Lib3MF_Base pInstance, const Lib3MF_uint32 nLastErrorStringBufferSize, Lib3MF_uint32* pLastErrorStringNeededChars, char * pLastErrorStringBuffer, bool * pHasLastError); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getsymbollookupmethod(Lib3MF_pvoid * pSymbolLookupMethod); + +/** +* Return an English text for a progress identifier.|Note: this is the only function you can call from your callback function. +* +* @param[in] eTheProgressIdentifier - the progress identifier that is passed to the callback function +* @param[in] nProgressMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pProgressMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pProgressMessageBuffer - buffer of English text for the progress identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_retrieveprogressmessage(Lib3MF::eProgressIdentifier eTheProgressIdentifier, const Lib3MF_uint32 nProgressMessageBufferSize, Lib3MF_uint32* pProgressMessageNeededChars, char * pProgressMessageBuffer); + +/** +* Creates a Color from uint8 RGBA values +* +* @param[in] nRed - Red value of color (0-255) +* @param[in] nGreen - Green value of color (0-255) +* @param[in] nBlue - Blue value of color (0-255) +* @param[in] nAlpha - Alpha value of color (0-255) +* @param[out] pTheColor - Assembled color +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_rgbatocolor(Lib3MF_uint8 nRed, Lib3MF_uint8 nGreen, Lib3MF_uint8 nBlue, Lib3MF_uint8 nAlpha, Lib3MF::sColor * pTheColor); + +/** +* Creates a Color from uint8 RGBA values +* +* @param[in] fRed - Red value of color (0-1) +* @param[in] fGreen - Green value of color (0-1) +* @param[in] fBlue - Blue value of color (0-1) +* @param[in] fAlpha - Alpha value of color (0-1) +* @param[out] pTheColor - Assembled color +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_floatrgbatocolor(Lib3MF_single fRed, Lib3MF_single fGreen, Lib3MF_single fBlue, Lib3MF_single fAlpha, Lib3MF::sColor * pTheColor); + +/** +* Calculates uint8-RGBA-values from a Color +* +* @param[in] pTheColor - Color to handle +* @param[out] pRed - Red value of color (0-255) +* @param[out] pGreen - Green value of color (0-255) +* @param[out] pBlue - Blue value of color (0-255) +* @param[out] pAlpha - Alpha value of color (0-255) +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colortorgba(const Lib3MF::sColor * pTheColor, Lib3MF_uint8 * pRed, Lib3MF_uint8 * pGreen, Lib3MF_uint8 * pBlue, Lib3MF_uint8 * pAlpha); + +/** +* Calculates float-RGBA-values from a Color +* +* @param[in] pTheColor - Color to handle +* @param[out] pRed - Red value of color (0-1) +* @param[out] pGreen - Green value of color (0-1) +* @param[out] pBlue - Blue value of color (0-1) +* @param[out] pAlpha - Alpha value of color (0-1) +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_colortofloatrgba(const Lib3MF::sColor * pTheColor, Lib3MF_single * pRed, Lib3MF_single * pGreen, Lib3MF_single * pBlue, Lib3MF_single * pAlpha); + +/** +* Creates an identity transform +* +* @param[out] pTransform - Transformation matrix. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getidentitytransform(Lib3MF::sTransform * pTransform); + +/** +* Creates a uniform scale transform +* +* @param[in] fFactor - Factor in X, Y and Z +* @param[out] pTransform - Transformation matrix. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getuniformscaletransform(Lib3MF_single fFactor, Lib3MF::sTransform * pTransform); + +/** +* Creates a scale transform +* +* @param[in] fFactorX - Factor in X +* @param[in] fFactorY - Factor in Y +* @param[in] fFactorZ - Factor in Z +* @param[out] pTransform - Transformation matrix. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_getscaletransform(Lib3MF_single fFactorX, Lib3MF_single fFactorY, Lib3MF_single fFactorZ, Lib3MF::sTransform * pTransform); + +/** +* Creates an translation transform +* +* @param[in] fVectorX - Translation in X +* @param[in] fVectorY - Translation in Y +* @param[in] fVectorZ - Translation in Z +* @param[out] pTransform - Transformation matrix. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_gettranslationtransform(Lib3MF_single fVectorX, Lib3MF_single fVectorY, Lib3MF_single fVectorZ, Lib3MF::sTransform * pTransform); + +} + +#endif // __LIB3MF_HEADER_CPP + diff --git a/lib3mf/Include/lib3mf_implicit.hpp b/lib3mf/Include/lib3mf_implicit.hpp new file mode 100644 index 0000000..1344a19 --- /dev/null +++ b/lib3mf/Include/lib3mf_implicit.hpp @@ -0,0 +1,6279 @@ +/*++ + +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. + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of the 3MF Library + +Interface version: 2.2.0 + +*/ + +#ifndef __LIB3MF_CPPHEADER_IMPLICIT_CPP +#define __LIB3MF_CPPHEADER_IMPLICIT_CPP + +#include "lib3mf_types.hpp" +#include "lib3mf_abi.hpp" + + +#ifdef _WIN32 +#include +#else // _WIN32 +#include +#endif // _WIN32 +#include +#include +#include +#include + +namespace Lib3MF { + +/************************************************************************************************************************* + Forward Declaration of all classes +**************************************************************************************************************************/ +class CWrapper; +class CBase; +class CWriter; +class CReader; +class CPackagePart; +class CResource; +class CResourceIterator; +class CSliceStackIterator; +class CObjectIterator; +class CMeshObjectIterator; +class CComponentsObjectIterator; +class CTexture2DIterator; +class CBaseMaterialGroupIterator; +class CColorGroupIterator; +class CTexture2DGroupIterator; +class CCompositeMaterialsIterator; +class CMultiPropertyGroupIterator; +class CMetaData; +class CMetaDataGroup; +class CObject; +class CMeshObject; +class CBeamLattice; +class CComponent; +class CComponentsObject; +class CBeamSet; +class CBaseMaterialGroup; +class CColorGroup; +class CTexture2DGroup; +class CCompositeMaterials; +class CMultiPropertyGroup; +class CAttachment; +class CTexture2D; +class CBuildItem; +class CBuildItemIterator; +class CSlice; +class CSliceStack; +class CConsumer; +class CAccessRight; +class CContentEncryptionParams; +class CResourceData; +class CResourceDataGroup; +class CKeyStore; +class CModel; + +/************************************************************************************************************************* + Declaration of deprecated class types +**************************************************************************************************************************/ +typedef CWrapper CLib3MFWrapper; +typedef CBase CLib3MFBase; +typedef CWriter CLib3MFWriter; +typedef CReader CLib3MFReader; +typedef CPackagePart CLib3MFPackagePart; +typedef CResource CLib3MFResource; +typedef CResourceIterator CLib3MFResourceIterator; +typedef CSliceStackIterator CLib3MFSliceStackIterator; +typedef CObjectIterator CLib3MFObjectIterator; +typedef CMeshObjectIterator CLib3MFMeshObjectIterator; +typedef CComponentsObjectIterator CLib3MFComponentsObjectIterator; +typedef CTexture2DIterator CLib3MFTexture2DIterator; +typedef CBaseMaterialGroupIterator CLib3MFBaseMaterialGroupIterator; +typedef CColorGroupIterator CLib3MFColorGroupIterator; +typedef CTexture2DGroupIterator CLib3MFTexture2DGroupIterator; +typedef CCompositeMaterialsIterator CLib3MFCompositeMaterialsIterator; +typedef CMultiPropertyGroupIterator CLib3MFMultiPropertyGroupIterator; +typedef CMetaData CLib3MFMetaData; +typedef CMetaDataGroup CLib3MFMetaDataGroup; +typedef CObject CLib3MFObject; +typedef CMeshObject CLib3MFMeshObject; +typedef CBeamLattice CLib3MFBeamLattice; +typedef CComponent CLib3MFComponent; +typedef CComponentsObject CLib3MFComponentsObject; +typedef CBeamSet CLib3MFBeamSet; +typedef CBaseMaterialGroup CLib3MFBaseMaterialGroup; +typedef CColorGroup CLib3MFColorGroup; +typedef CTexture2DGroup CLib3MFTexture2DGroup; +typedef CCompositeMaterials CLib3MFCompositeMaterials; +typedef CMultiPropertyGroup CLib3MFMultiPropertyGroup; +typedef CAttachment CLib3MFAttachment; +typedef CTexture2D CLib3MFTexture2D; +typedef CBuildItem CLib3MFBuildItem; +typedef CBuildItemIterator CLib3MFBuildItemIterator; +typedef CSlice CLib3MFSlice; +typedef CSliceStack CLib3MFSliceStack; +typedef CConsumer CLib3MFConsumer; +typedef CAccessRight CLib3MFAccessRight; +typedef CContentEncryptionParams CLib3MFContentEncryptionParams; +typedef CResourceData CLib3MFResourceData; +typedef CResourceDataGroup CLib3MFResourceDataGroup; +typedef CKeyStore CLib3MFKeyStore; +typedef CModel CLib3MFModel; + +/************************************************************************************************************************* + Declaration of shared pointer types +**************************************************************************************************************************/ +typedef std::shared_ptr PWrapper; +typedef std::shared_ptr PBase; +typedef std::shared_ptr PWriter; +typedef std::shared_ptr PReader; +typedef std::shared_ptr PPackagePart; +typedef std::shared_ptr PResource; +typedef std::shared_ptr PResourceIterator; +typedef std::shared_ptr PSliceStackIterator; +typedef std::shared_ptr PObjectIterator; +typedef std::shared_ptr PMeshObjectIterator; +typedef std::shared_ptr PComponentsObjectIterator; +typedef std::shared_ptr PTexture2DIterator; +typedef std::shared_ptr PBaseMaterialGroupIterator; +typedef std::shared_ptr PColorGroupIterator; +typedef std::shared_ptr PTexture2DGroupIterator; +typedef std::shared_ptr PCompositeMaterialsIterator; +typedef std::shared_ptr PMultiPropertyGroupIterator; +typedef std::shared_ptr PMetaData; +typedef std::shared_ptr PMetaDataGroup; +typedef std::shared_ptr PObject; +typedef std::shared_ptr PMeshObject; +typedef std::shared_ptr PBeamLattice; +typedef std::shared_ptr PComponent; +typedef std::shared_ptr PComponentsObject; +typedef std::shared_ptr PBeamSet; +typedef std::shared_ptr PBaseMaterialGroup; +typedef std::shared_ptr PColorGroup; +typedef std::shared_ptr PTexture2DGroup; +typedef std::shared_ptr PCompositeMaterials; +typedef std::shared_ptr PMultiPropertyGroup; +typedef std::shared_ptr PAttachment; +typedef std::shared_ptr PTexture2D; +typedef std::shared_ptr PBuildItem; +typedef std::shared_ptr PBuildItemIterator; +typedef std::shared_ptr PSlice; +typedef std::shared_ptr PSliceStack; +typedef std::shared_ptr PConsumer; +typedef std::shared_ptr PAccessRight; +typedef std::shared_ptr PContentEncryptionParams; +typedef std::shared_ptr PResourceData; +typedef std::shared_ptr PResourceDataGroup; +typedef std::shared_ptr PKeyStore; +typedef std::shared_ptr PModel; + +/************************************************************************************************************************* + Declaration of deprecated shared pointer types +**************************************************************************************************************************/ +typedef PWrapper PLib3MFWrapper; +typedef PBase PLib3MFBase; +typedef PWriter PLib3MFWriter; +typedef PReader PLib3MFReader; +typedef PPackagePart PLib3MFPackagePart; +typedef PResource PLib3MFResource; +typedef PResourceIterator PLib3MFResourceIterator; +typedef PSliceStackIterator PLib3MFSliceStackIterator; +typedef PObjectIterator PLib3MFObjectIterator; +typedef PMeshObjectIterator PLib3MFMeshObjectIterator; +typedef PComponentsObjectIterator PLib3MFComponentsObjectIterator; +typedef PTexture2DIterator PLib3MFTexture2DIterator; +typedef PBaseMaterialGroupIterator PLib3MFBaseMaterialGroupIterator; +typedef PColorGroupIterator PLib3MFColorGroupIterator; +typedef PTexture2DGroupIterator PLib3MFTexture2DGroupIterator; +typedef PCompositeMaterialsIterator PLib3MFCompositeMaterialsIterator; +typedef PMultiPropertyGroupIterator PLib3MFMultiPropertyGroupIterator; +typedef PMetaData PLib3MFMetaData; +typedef PMetaDataGroup PLib3MFMetaDataGroup; +typedef PObject PLib3MFObject; +typedef PMeshObject PLib3MFMeshObject; +typedef PBeamLattice PLib3MFBeamLattice; +typedef PComponent PLib3MFComponent; +typedef PComponentsObject PLib3MFComponentsObject; +typedef PBeamSet PLib3MFBeamSet; +typedef PBaseMaterialGroup PLib3MFBaseMaterialGroup; +typedef PColorGroup PLib3MFColorGroup; +typedef PTexture2DGroup PLib3MFTexture2DGroup; +typedef PCompositeMaterials PLib3MFCompositeMaterials; +typedef PMultiPropertyGroup PLib3MFMultiPropertyGroup; +typedef PAttachment PLib3MFAttachment; +typedef PTexture2D PLib3MFTexture2D; +typedef PBuildItem PLib3MFBuildItem; +typedef PBuildItemIterator PLib3MFBuildItemIterator; +typedef PSlice PLib3MFSlice; +typedef PSliceStack PLib3MFSliceStack; +typedef PConsumer PLib3MFConsumer; +typedef PAccessRight PLib3MFAccessRight; +typedef PContentEncryptionParams PLib3MFContentEncryptionParams; +typedef PResourceData PLib3MFResourceData; +typedef PResourceDataGroup PLib3MFResourceDataGroup; +typedef PKeyStore PLib3MFKeyStore; +typedef PModel PLib3MFModel; + + +/************************************************************************************************************************* + Class ELib3MFException +**************************************************************************************************************************/ +class ELib3MFException : public std::exception { +protected: + /** + * Error code for the Exception. + */ + Lib3MFResult m_errorCode; + /** + * Error message for the Exception. + */ + std::string m_errorMessage; + +public: + /** + * Exception Constructor. + */ + ELib3MFException(Lib3MFResult errorCode, const std::string & sErrorMessage) + : m_errorMessage("Lib3MF Error " + std::to_string(errorCode) + " (" + sErrorMessage + ")") + { + m_errorCode = errorCode; + } + + /** + * Returns error code + */ + Lib3MFResult getErrorCode() const + { + return m_errorCode; + } + + /** + * Returns error message + */ + const char* what() const + { + return m_errorMessage.c_str(); + } + +}; + +/************************************************************************************************************************* + Class CInputVector +**************************************************************************************************************************/ +template +class CInputVector { +private: + + const T* m_data; + size_t m_size; + +public: + + CInputVector(const std::vector& vec) + : m_data( vec.data() ), m_size( vec.size() ) + { + } + + CInputVector(const T* in_data, size_t in_size) + : m_data( in_data ), m_size(in_size ) + { + } + + const T* data() const + { + return m_data; + } + + size_t size() const + { + return m_size; + } + +}; + +// declare deprecated class name +template +using CLib3MFInputVector = CInputVector; + +/************************************************************************************************************************* + Class CWrapper +**************************************************************************************************************************/ +class CWrapper { +public: + + CWrapper() + { + } + + ~CWrapper() + { + } + static inline PWrapper loadLibrary() + { + return std::make_shared(); + } + + inline void CheckError(CBase * pBaseClass, Lib3MFResult nResult); + + inline void GetLibraryVersion(Lib3MF_uint32 & nMajor, Lib3MF_uint32 & nMinor, Lib3MF_uint32 & nMicro); + inline bool GetPrereleaseInformation(std::string & sPrereleaseInfo); + inline bool GetBuildInformation(std::string & sBuildInformation); + inline void GetSpecificationVersion(const std::string & sSpecificationURL, bool & bIsSupported, Lib3MF_uint32 & nMajor, Lib3MF_uint32 & nMinor, Lib3MF_uint32 & nMicro); + inline PModel CreateModel(); + inline void Release(CBase * pInstance); + inline void Acquire(CBase * pInstance); + inline void SetJournal(const std::string & sJournalPath); + inline bool GetLastError(CBase * pInstance, std::string & sLastErrorString); + inline Lib3MF_pvoid GetSymbolLookupMethod(); + inline void RetrieveProgressMessage(const eProgressIdentifier eTheProgressIdentifier, std::string & sProgressMessage); + inline sColor RGBAToColor(const Lib3MF_uint8 nRed, const Lib3MF_uint8 nGreen, const Lib3MF_uint8 nBlue, const Lib3MF_uint8 nAlpha); + inline sColor FloatRGBAToColor(const Lib3MF_single fRed, const Lib3MF_single fGreen, const Lib3MF_single fBlue, const Lib3MF_single fAlpha); + inline void ColorToRGBA(const sColor & TheColor, Lib3MF_uint8 & nRed, Lib3MF_uint8 & nGreen, Lib3MF_uint8 & nBlue, Lib3MF_uint8 & nAlpha); + inline void ColorToFloatRGBA(const sColor & TheColor, Lib3MF_single & fRed, Lib3MF_single & fGreen, Lib3MF_single & fBlue, Lib3MF_single & fAlpha); + inline sTransform GetIdentityTransform(); + inline sTransform GetUniformScaleTransform(const Lib3MF_single fFactor); + inline sTransform GetScaleTransform(const Lib3MF_single fFactorX, const Lib3MF_single fFactorY, const Lib3MF_single fFactorZ); + inline sTransform GetTranslationTransform(const Lib3MF_single fVectorX, const Lib3MF_single fVectorY, const Lib3MF_single fVectorZ); + +private: + + Lib3MFResult checkBinaryVersion() + { + Lib3MF_uint32 nMajor, nMinor, nMicro; + GetLibraryVersion(nMajor, nMinor, nMicro); + if ( (nMajor != LIB3MF_VERSION_MAJOR) || (nMinor < LIB3MF_VERSION_MINOR) ) { + return LIB3MF_ERROR_INCOMPATIBLEBINARYVERSION; + } + return LIB3MF_SUCCESS; + } + + friend class CBase; + friend class CWriter; + friend class CReader; + friend class CPackagePart; + friend class CResource; + friend class CResourceIterator; + friend class CSliceStackIterator; + friend class CObjectIterator; + friend class CMeshObjectIterator; + friend class CComponentsObjectIterator; + friend class CTexture2DIterator; + friend class CBaseMaterialGroupIterator; + friend class CColorGroupIterator; + friend class CTexture2DGroupIterator; + friend class CCompositeMaterialsIterator; + friend class CMultiPropertyGroupIterator; + friend class CMetaData; + friend class CMetaDataGroup; + friend class CObject; + friend class CMeshObject; + friend class CBeamLattice; + friend class CComponent; + friend class CComponentsObject; + friend class CBeamSet; + friend class CBaseMaterialGroup; + friend class CColorGroup; + friend class CTexture2DGroup; + friend class CCompositeMaterials; + friend class CMultiPropertyGroup; + friend class CAttachment; + friend class CTexture2D; + friend class CBuildItem; + friend class CBuildItemIterator; + friend class CSlice; + friend class CSliceStack; + friend class CConsumer; + friend class CAccessRight; + friend class CContentEncryptionParams; + friend class CResourceData; + friend class CResourceDataGroup; + friend class CKeyStore; + friend class CModel; + +}; + + +/************************************************************************************************************************* + Class CBase +**************************************************************************************************************************/ +class CBase { +public: + +protected: + /* Wrapper Object that created the class. */ + CWrapper * m_pWrapper; + /* Handle to Instance in library*/ + Lib3MFHandle m_pHandle; + + /* Checks for an Error code and raises Exceptions */ + void CheckError(Lib3MFResult nResult) + { + if (m_pWrapper != nullptr) + m_pWrapper->CheckError(this, nResult); + } +public: + /** + * CBase::CBase - Constructor for Base class. + */ + CBase(CWrapper * pWrapper, Lib3MFHandle pHandle) + : m_pWrapper(pWrapper), m_pHandle(pHandle) + { + } + + /** + * CBase::~CBase - Destructor for Base class. + */ + virtual ~CBase() + { + if (m_pWrapper != nullptr) + m_pWrapper->Release(this); + m_pWrapper = nullptr; + } + + /** + * CBase::GetHandle - Returns handle to instance. + */ + Lib3MFHandle GetHandle() + { + return m_pHandle; + } + + friend class CWrapper; +}; + +/************************************************************************************************************************* + Class CWriter +**************************************************************************************************************************/ +class CWriter : public CBase { +public: + + /** + * CWriter::CWriter - Constructor for Writer class. + */ + CWriter(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void WriteToFile(const std::string & sFilename); + inline Lib3MF_uint64 GetStreamSize(); + inline void WriteToBuffer(std::vector & BufferBuffer); + inline void WriteToCallback(const WriteCallback pTheWriteCallback, const SeekCallback pTheSeekCallback, const Lib3MF_pvoid pUserData); + inline void SetProgressCallback(const ProgressCallback pProgressCallback, const Lib3MF_pvoid pUserData); + inline Lib3MF_uint32 GetDecimalPrecision(); + inline void SetDecimalPrecision(const Lib3MF_uint32 nDecimalPrecision); + inline void SetStrictModeActive(const bool bStrictModeActive); + inline bool GetStrictModeActive(); + inline std::string GetWarning(const Lib3MF_uint32 nIndex, Lib3MF_uint32 & nErrorCode); + inline Lib3MF_uint32 GetWarningCount(); + inline void AddKeyWrappingCallback(const std::string & sConsumerID, const KeyWrappingCallback pTheCallback, const Lib3MF_pvoid pUserData); + inline void SetContentEncryptionCallback(const ContentEncryptionCallback pTheCallback, const Lib3MF_pvoid pUserData); +}; + +/************************************************************************************************************************* + Class CReader +**************************************************************************************************************************/ +class CReader : public CBase { +public: + + /** + * CReader::CReader - Constructor for Reader class. + */ + CReader(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void ReadFromFile(const std::string & sFilename); + inline void ReadFromBuffer(const CInputVector & BufferBuffer); + inline void ReadFromCallback(const ReadCallback pTheReadCallback, const Lib3MF_uint64 nStreamSize, const SeekCallback pTheSeekCallback, const Lib3MF_pvoid pUserData); + inline void SetProgressCallback(const ProgressCallback pProgressCallback, const Lib3MF_pvoid pUserData); + inline void AddRelationToRead(const std::string & sRelationShipType); + inline void RemoveRelationToRead(const std::string & sRelationShipType); + inline void SetStrictModeActive(const bool bStrictModeActive); + inline bool GetStrictModeActive(); + inline std::string GetWarning(const Lib3MF_uint32 nIndex, Lib3MF_uint32 & nErrorCode); + inline Lib3MF_uint32 GetWarningCount(); + inline void AddKeyWrappingCallback(const std::string & sConsumerID, const KeyWrappingCallback pTheCallback, const Lib3MF_pvoid pUserData); + inline void SetContentEncryptionCallback(const ContentEncryptionCallback pTheCallback, const Lib3MF_pvoid pUserData); +}; + +/************************************************************************************************************************* + Class CPackagePart +**************************************************************************************************************************/ +class CPackagePart : public CBase { +public: + + /** + * CPackagePart::CPackagePart - Constructor for PackagePart class. + */ + CPackagePart(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetPath(); + inline void SetPath(const std::string & sPath); +}; + +/************************************************************************************************************************* + Class CResource +**************************************************************************************************************************/ +class CResource : public CBase { +public: + + /** + * CResource::CResource - Constructor for Resource class. + */ + CResource(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetResourceID(); + inline Lib3MF_uint32 GetUniqueResourceID(); + inline PPackagePart PackagePart(); + inline void SetPackagePart(CPackagePart * pPackagePart); + inline Lib3MF_uint32 GetModelResourceID(); +}; + +/************************************************************************************************************************* + Class CResourceIterator +**************************************************************************************************************************/ +class CResourceIterator : public CBase { +public: + + /** + * CResourceIterator::CResourceIterator - Constructor for ResourceIterator class. + */ + CResourceIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline bool MoveNext(); + inline bool MovePrevious(); + inline PResource GetCurrent(); + inline PResourceIterator Clone(); + inline Lib3MF_uint64 Count(); +}; + +/************************************************************************************************************************* + Class CSliceStackIterator +**************************************************************************************************************************/ +class CSliceStackIterator : public CResourceIterator { +public: + + /** + * CSliceStackIterator::CSliceStackIterator - Constructor for SliceStackIterator class. + */ + CSliceStackIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PSliceStack GetCurrentSliceStack(); +}; + +/************************************************************************************************************************* + Class CObjectIterator +**************************************************************************************************************************/ +class CObjectIterator : public CResourceIterator { +public: + + /** + * CObjectIterator::CObjectIterator - Constructor for ObjectIterator class. + */ + CObjectIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PObject GetCurrentObject(); +}; + +/************************************************************************************************************************* + Class CMeshObjectIterator +**************************************************************************************************************************/ +class CMeshObjectIterator : public CResourceIterator { +public: + + /** + * CMeshObjectIterator::CMeshObjectIterator - Constructor for MeshObjectIterator class. + */ + CMeshObjectIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PMeshObject GetCurrentMeshObject(); +}; + +/************************************************************************************************************************* + Class CComponentsObjectIterator +**************************************************************************************************************************/ +class CComponentsObjectIterator : public CResourceIterator { +public: + + /** + * CComponentsObjectIterator::CComponentsObjectIterator - Constructor for ComponentsObjectIterator class. + */ + CComponentsObjectIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PComponentsObject GetCurrentComponentsObject(); +}; + +/************************************************************************************************************************* + Class CTexture2DIterator +**************************************************************************************************************************/ +class CTexture2DIterator : public CResourceIterator { +public: + + /** + * CTexture2DIterator::CTexture2DIterator - Constructor for Texture2DIterator class. + */ + CTexture2DIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PTexture2D GetCurrentTexture2D(); +}; + +/************************************************************************************************************************* + Class CBaseMaterialGroupIterator +**************************************************************************************************************************/ +class CBaseMaterialGroupIterator : public CResourceIterator { +public: + + /** + * CBaseMaterialGroupIterator::CBaseMaterialGroupIterator - Constructor for BaseMaterialGroupIterator class. + */ + CBaseMaterialGroupIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PBaseMaterialGroup GetCurrentBaseMaterialGroup(); +}; + +/************************************************************************************************************************* + Class CColorGroupIterator +**************************************************************************************************************************/ +class CColorGroupIterator : public CResourceIterator { +public: + + /** + * CColorGroupIterator::CColorGroupIterator - Constructor for ColorGroupIterator class. + */ + CColorGroupIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PColorGroup GetCurrentColorGroup(); +}; + +/************************************************************************************************************************* + Class CTexture2DGroupIterator +**************************************************************************************************************************/ +class CTexture2DGroupIterator : public CResourceIterator { +public: + + /** + * CTexture2DGroupIterator::CTexture2DGroupIterator - Constructor for Texture2DGroupIterator class. + */ + CTexture2DGroupIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PTexture2DGroup GetCurrentTexture2DGroup(); +}; + +/************************************************************************************************************************* + Class CCompositeMaterialsIterator +**************************************************************************************************************************/ +class CCompositeMaterialsIterator : public CResourceIterator { +public: + + /** + * CCompositeMaterialsIterator::CCompositeMaterialsIterator - Constructor for CompositeMaterialsIterator class. + */ + CCompositeMaterialsIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PCompositeMaterials GetCurrentCompositeMaterials(); +}; + +/************************************************************************************************************************* + Class CMultiPropertyGroupIterator +**************************************************************************************************************************/ +class CMultiPropertyGroupIterator : public CResourceIterator { +public: + + /** + * CMultiPropertyGroupIterator::CMultiPropertyGroupIterator - Constructor for MultiPropertyGroupIterator class. + */ + CMultiPropertyGroupIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResourceIterator(pWrapper, pHandle) + { + } + + inline PMultiPropertyGroup GetCurrentMultiPropertyGroup(); +}; + +/************************************************************************************************************************* + Class CMetaData +**************************************************************************************************************************/ +class CMetaData : public CBase { +public: + + /** + * CMetaData::CMetaData - Constructor for MetaData class. + */ + CMetaData(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetNameSpace(); + inline void SetNameSpace(const std::string & sNameSpace); + inline std::string GetName(); + inline void SetName(const std::string & sName); + inline std::string GetKey(); + inline bool GetMustPreserve(); + inline void SetMustPreserve(const bool bMustPreserve); + inline std::string GetType(); + inline void SetType(const std::string & sType); + inline std::string GetValue(); + inline void SetValue(const std::string & sValue); +}; + +/************************************************************************************************************************* + Class CMetaDataGroup +**************************************************************************************************************************/ +class CMetaDataGroup : public CBase { +public: + + /** + * CMetaDataGroup::CMetaDataGroup - Constructor for MetaDataGroup class. + */ + CMetaDataGroup(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetMetaDataCount(); + inline PMetaData GetMetaData(const Lib3MF_uint32 nIndex); + inline PMetaData GetMetaDataByKey(const std::string & sNameSpace, const std::string & sName); + inline void RemoveMetaDataByIndex(const Lib3MF_uint32 nIndex); + inline void RemoveMetaData(CMetaData * pTheMetaData); + inline PMetaData AddMetaData(const std::string & sNameSpace, const std::string & sName, const std::string & sValue, const std::string & sType, const bool bMustPreserve); +}; + +/************************************************************************************************************************* + Class CObject +**************************************************************************************************************************/ +class CObject : public CResource { +public: + + /** + * CObject::CObject - Constructor for Object class. + */ + CObject(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline eObjectType GetType(); + inline void SetType(const eObjectType eObjectType); + inline std::string GetName(); + inline void SetName(const std::string & sName); + inline std::string GetPartNumber(); + inline void SetPartNumber(const std::string & sPartNumber); + inline bool IsMeshObject(); + inline bool IsComponentsObject(); + inline bool IsValid(); + inline void SetAttachmentAsThumbnail(CAttachment * pAttachment); + inline PAttachment GetThumbnailAttachment(); + inline void ClearThumbnailAttachment(); + inline sBox GetOutbox(); + inline std::string GetUUID(bool & bHasUUID); + inline void SetUUID(const std::string & sUUID); + inline PMetaDataGroup GetMetaDataGroup(); + inline void SetSlicesMeshResolution(const eSlicesMeshResolution eMeshResolution); + inline eSlicesMeshResolution GetSlicesMeshResolution(); + inline bool HasSlices(const bool bRecursive); + inline void ClearSliceStack(); + inline PSliceStack GetSliceStack(); + inline void AssignSliceStack(CSliceStack * pSliceStackInstance); +}; + +/************************************************************************************************************************* + Class CMeshObject +**************************************************************************************************************************/ +class CMeshObject : public CObject { +public: + + /** + * CMeshObject::CMeshObject - Constructor for MeshObject class. + */ + CMeshObject(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CObject(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetVertexCount(); + inline Lib3MF_uint32 GetTriangleCount(); + inline sPosition GetVertex(const Lib3MF_uint32 nIndex); + inline void SetVertex(const Lib3MF_uint32 nIndex, const sPosition & Coordinates); + inline Lib3MF_uint32 AddVertex(const sPosition & Coordinates); + inline void GetVertices(std::vector & VerticesBuffer); + inline sTriangle GetTriangle(const Lib3MF_uint32 nIndex); + inline void SetTriangle(const Lib3MF_uint32 nIndex, const sTriangle & Indices); + inline Lib3MF_uint32 AddTriangle(const sTriangle & Indices); + inline void GetTriangleIndices(std::vector & IndicesBuffer); + inline void SetObjectLevelProperty(const Lib3MF_uint32 nUniqueResourceID, const Lib3MF_uint32 nPropertyID); + inline bool GetObjectLevelProperty(Lib3MF_uint32 & nUniqueResourceID, Lib3MF_uint32 & nPropertyID); + inline void SetTriangleProperties(const Lib3MF_uint32 nIndex, const sTriangleProperties & Properties); + inline void GetTriangleProperties(const Lib3MF_uint32 nIndex, sTriangleProperties & Property); + inline void SetAllTriangleProperties(const CInputVector & PropertiesArrayBuffer); + inline void GetAllTriangleProperties(std::vector & PropertiesArrayBuffer); + inline void ClearAllProperties(); + inline void SetGeometry(const CInputVector & VerticesBuffer, const CInputVector & IndicesBuffer); + inline bool IsManifoldAndOriented(); + inline PBeamLattice BeamLattice(); +}; + +/************************************************************************************************************************* + Class CBeamLattice +**************************************************************************************************************************/ +class CBeamLattice : public CBase { +public: + + /** + * CBeamLattice::CBeamLattice - Constructor for BeamLattice class. + */ + CBeamLattice(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline Lib3MF_double GetMinLength(); + inline void SetMinLength(const Lib3MF_double dMinLength); + inline void GetClipping(eBeamLatticeClipMode & eClipMode, Lib3MF_uint32 & nUniqueResourceID); + inline void SetClipping(const eBeamLatticeClipMode eClipMode, const Lib3MF_uint32 nUniqueResourceID); + inline bool GetRepresentation(Lib3MF_uint32 & nUniqueResourceID); + inline void SetRepresentation(const Lib3MF_uint32 nUniqueResourceID); + inline void GetBallOptions(eBeamLatticeBallMode & eBallMode, Lib3MF_double & dBallRadius); + inline void SetBallOptions(const eBeamLatticeBallMode eBallMode, const Lib3MF_double dBallRadius); + inline Lib3MF_uint32 GetBeamCount(); + inline sBeam GetBeam(const Lib3MF_uint32 nIndex); + inline Lib3MF_uint32 AddBeam(const sBeam & BeamInfo); + inline void SetBeam(const Lib3MF_uint32 nIndex, const sBeam & BeamInfo); + inline void SetBeams(const CInputVector & BeamInfoBuffer); + inline void GetBeams(std::vector & BeamInfoBuffer); + inline Lib3MF_uint32 GetBallCount(); + inline sBall GetBall(const Lib3MF_uint32 nIndex); + inline Lib3MF_uint32 AddBall(const sBall & BallInfo); + inline void SetBall(const Lib3MF_uint32 nIndex, const sBall & BallInfo); + inline void SetBalls(const CInputVector & BallInfoBuffer); + inline void GetBalls(std::vector & BallInfoBuffer); + inline Lib3MF_uint32 GetBeamSetCount(); + inline PBeamSet AddBeamSet(); + inline PBeamSet GetBeamSet(const Lib3MF_uint32 nIndex); +}; + +/************************************************************************************************************************* + Class CComponent +**************************************************************************************************************************/ +class CComponent : public CBase { +public: + + /** + * CComponent::CComponent - Constructor for Component class. + */ + CComponent(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline PObject GetObjectResource(); + inline Lib3MF_uint32 GetObjectResourceID(); + inline std::string GetUUID(bool & bHasUUID); + inline void SetUUID(const std::string & sUUID); + inline bool HasTransform(); + inline sTransform GetTransform(); + inline void SetTransform(const sTransform & Transform); +}; + +/************************************************************************************************************************* + Class CComponentsObject +**************************************************************************************************************************/ +class CComponentsObject : public CObject { +public: + + /** + * CComponentsObject::CComponentsObject - Constructor for ComponentsObject class. + */ + CComponentsObject(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CObject(pWrapper, pHandle) + { + } + + inline PComponent AddComponent(CObject * pObjectResource, const sTransform & Transform); + inline PComponent GetComponent(const Lib3MF_uint32 nIndex); + inline Lib3MF_uint32 GetComponentCount(); +}; + +/************************************************************************************************************************* + Class CBeamSet +**************************************************************************************************************************/ +class CBeamSet : public CBase { +public: + + /** + * CBeamSet::CBeamSet - Constructor for BeamSet class. + */ + CBeamSet(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 Lib3MF_uint32 GetReferenceCount(); + inline void SetReferences(const CInputVector & ReferencesBuffer); + inline void GetReferences(std::vector & ReferencesBuffer); + inline Lib3MF_uint32 GetBallReferenceCount(); + inline void SetBallReferences(const CInputVector & BallReferencesBuffer); + inline void GetBallReferences(std::vector & BallReferencesBuffer); +}; + +/************************************************************************************************************************* + Class CBaseMaterialGroup +**************************************************************************************************************************/ +class CBaseMaterialGroup : public CResource { +public: + + /** + * CBaseMaterialGroup::CBaseMaterialGroup - Constructor for BaseMaterialGroup class. + */ + CBaseMaterialGroup(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetCount(); + inline void GetAllPropertyIDs(std::vector & PropertyIDsBuffer); + inline Lib3MF_uint32 AddMaterial(const std::string & sName, const sColor & DisplayColor); + inline void RemoveMaterial(const Lib3MF_uint32 nPropertyID); + inline std::string GetName(const Lib3MF_uint32 nPropertyID); + inline void SetName(const Lib3MF_uint32 nPropertyID, const std::string & sName); + inline void SetDisplayColor(const Lib3MF_uint32 nPropertyID, const sColor & TheColor); + inline sColor GetDisplayColor(const Lib3MF_uint32 nPropertyID); +}; + +/************************************************************************************************************************* + Class CColorGroup +**************************************************************************************************************************/ +class CColorGroup : public CResource { +public: + + /** + * CColorGroup::CColorGroup - Constructor for ColorGroup class. + */ + CColorGroup(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetCount(); + inline void GetAllPropertyIDs(std::vector & PropertyIDsBuffer); + inline Lib3MF_uint32 AddColor(const sColor & TheColor); + inline void RemoveColor(const Lib3MF_uint32 nPropertyID); + inline void SetColor(const Lib3MF_uint32 nPropertyID, const sColor & TheColor); + inline sColor GetColor(const Lib3MF_uint32 nPropertyID); +}; + +/************************************************************************************************************************* + Class CTexture2DGroup +**************************************************************************************************************************/ +class CTexture2DGroup : public CResource { +public: + + /** + * CTexture2DGroup::CTexture2DGroup - Constructor for Texture2DGroup class. + */ + CTexture2DGroup(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetCount(); + inline void GetAllPropertyIDs(std::vector & PropertyIDsBuffer); + inline Lib3MF_uint32 AddTex2Coord(const sTex2Coord & UVCoordinate); + inline sTex2Coord GetTex2Coord(const Lib3MF_uint32 nPropertyID); + inline void RemoveTex2Coord(const Lib3MF_uint32 nPropertyID); + inline PTexture2D GetTexture2D(); +}; + +/************************************************************************************************************************* + Class CCompositeMaterials +**************************************************************************************************************************/ +class CCompositeMaterials : public CResource { +public: + + /** + * CCompositeMaterials::CCompositeMaterials - Constructor for CompositeMaterials class. + */ + CCompositeMaterials(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetCount(); + inline void GetAllPropertyIDs(std::vector & PropertyIDsBuffer); + inline PBaseMaterialGroup GetBaseMaterialGroup(); + inline Lib3MF_uint32 AddComposite(const CInputVector & CompositeBuffer); + inline void RemoveComposite(const Lib3MF_uint32 nPropertyID); + inline void GetComposite(const Lib3MF_uint32 nPropertyID, std::vector & CompositeBuffer); +}; + +/************************************************************************************************************************* + Class CMultiPropertyGroup +**************************************************************************************************************************/ +class CMultiPropertyGroup : public CResource { +public: + + /** + * CMultiPropertyGroup::CMultiPropertyGroup - Constructor for MultiPropertyGroup class. + */ + CMultiPropertyGroup(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline Lib3MF_uint32 GetCount(); + inline void GetAllPropertyIDs(std::vector & PropertyIDsBuffer); + inline Lib3MF_uint32 AddMultiProperty(const CInputVector & PropertyIDsBuffer); + inline void SetMultiProperty(const Lib3MF_uint32 nPropertyID, const CInputVector & PropertyIDsBuffer); + inline void GetMultiProperty(const Lib3MF_uint32 nPropertyID, std::vector & PropertyIDsBuffer); + inline void RemoveMultiProperty(const Lib3MF_uint32 nPropertyID); + inline Lib3MF_uint32 GetLayerCount(); + inline Lib3MF_uint32 AddLayer(const sMultiPropertyLayer & TheLayer); + inline sMultiPropertyLayer GetLayer(const Lib3MF_uint32 nLayerIndex); + inline void RemoveLayer(const Lib3MF_uint32 nLayerIndex); +}; + +/************************************************************************************************************************* + Class CAttachment +**************************************************************************************************************************/ +class CAttachment : public CBase { +public: + + /** + * CAttachment::CAttachment - Constructor for Attachment class. + */ + CAttachment(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetPath(); + inline void SetPath(const std::string & sPath); + inline PPackagePart PackagePart(); + inline std::string GetRelationShipType(); + inline void SetRelationShipType(const std::string & sPath); + inline void WriteToFile(const std::string & sFileName); + inline void ReadFromFile(const std::string & sFileName); + inline void ReadFromCallback(const ReadCallback pTheReadCallback, const Lib3MF_uint64 nStreamSize, const SeekCallback pTheSeekCallback, const Lib3MF_pvoid pUserData); + inline Lib3MF_uint64 GetStreamSize(); + inline void WriteToBuffer(std::vector & BufferBuffer); + inline void ReadFromBuffer(const CInputVector & BufferBuffer); +}; + +/************************************************************************************************************************* + Class CTexture2D +**************************************************************************************************************************/ +class CTexture2D : public CResource { +public: + + /** + * CTexture2D::CTexture2D - Constructor for Texture2D class. + */ + CTexture2D(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline PAttachment GetAttachment(); + inline void SetAttachment(CAttachment * pAttachment); + inline eTextureType GetContentType(); + inline void SetContentType(const eTextureType eContentType); + inline void GetTileStyleUV(eTextureTileStyle & eTileStyleU, eTextureTileStyle & eTileStyleV); + inline void SetTileStyleUV(const eTextureTileStyle eTileStyleU, const eTextureTileStyle eTileStyleV); + inline eTextureFilter GetFilter(); + inline void SetFilter(const eTextureFilter eFilter); +}; + +/************************************************************************************************************************* + Class CBuildItem +**************************************************************************************************************************/ +class CBuildItem : public CBase { +public: + + /** + * CBuildItem::CBuildItem - Constructor for BuildItem class. + */ + CBuildItem(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline PObject GetObjectResource(); + inline std::string GetUUID(bool & bHasUUID); + inline void SetUUID(const std::string & sUUID); + inline Lib3MF_uint32 GetObjectResourceID(); + inline bool HasObjectTransform(); + inline sTransform GetObjectTransform(); + inline void SetObjectTransform(const sTransform & Transform); + inline std::string GetPartNumber(); + inline void SetPartNumber(const std::string & sSetPartnumber); + inline PMetaDataGroup GetMetaDataGroup(); + inline sBox GetOutbox(); +}; + +/************************************************************************************************************************* + Class CBuildItemIterator +**************************************************************************************************************************/ +class CBuildItemIterator : public CBase { +public: + + /** + * CBuildItemIterator::CBuildItemIterator - Constructor for BuildItemIterator class. + */ + CBuildItemIterator(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline bool MoveNext(); + inline bool MovePrevious(); + inline PBuildItem GetCurrent(); + inline PBuildItemIterator Clone(); + inline Lib3MF_uint64 Count(); +}; + +/************************************************************************************************************************* + Class CSlice +**************************************************************************************************************************/ +class CSlice : public CBase { +public: + + /** + * CSlice::CSlice - Constructor for Slice class. + */ + CSlice(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void SetVertices(const CInputVector & VerticesBuffer); + inline void GetVertices(std::vector & VerticesBuffer); + inline Lib3MF_uint64 GetVertexCount(); + inline Lib3MF_uint64 AddPolygon(const CInputVector & IndicesBuffer); + inline Lib3MF_uint64 GetPolygonCount(); + inline void SetPolygonIndices(const Lib3MF_uint64 nIndex, const CInputVector & IndicesBuffer); + inline void GetPolygonIndices(const Lib3MF_uint64 nIndex, std::vector & IndicesBuffer); + inline Lib3MF_uint64 GetPolygonIndexCount(const Lib3MF_uint64 nIndex); + inline Lib3MF_double GetZTop(); +}; + +/************************************************************************************************************************* + Class CSliceStack +**************************************************************************************************************************/ +class CSliceStack : public CResource { +public: + + /** + * CSliceStack::CSliceStack - Constructor for SliceStack class. + */ + CSliceStack(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CResource(pWrapper, pHandle) + { + } + + inline Lib3MF_double GetBottomZ(); + inline Lib3MF_uint64 GetSliceCount(); + inline PSlice GetSlice(const Lib3MF_uint64 nSliceIndex); + inline PSlice AddSlice(const Lib3MF_double dZTop); + inline Lib3MF_uint64 GetSliceRefCount(); + inline void AddSliceStackReference(CSliceStack * pTheSliceStack); + inline PSliceStack GetSliceStackReference(const Lib3MF_uint64 nSliceRefIndex); + inline void CollapseSliceReferences(); + inline void SetOwnPath(const std::string & sPath); + inline std::string GetOwnPath(); +}; + +/************************************************************************************************************************* + Class CConsumer +**************************************************************************************************************************/ +class CConsumer : public CBase { +public: + + /** + * CConsumer::CConsumer - Constructor for Consumer class. + */ + CConsumer(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetConsumerID(); + inline std::string GetKeyID(); + inline std::string GetKeyValue(); +}; + +/************************************************************************************************************************* + Class CAccessRight +**************************************************************************************************************************/ +class CAccessRight : public CBase { +public: + + /** + * CAccessRight::CAccessRight - Constructor for AccessRight class. + */ + CAccessRight(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline PConsumer GetConsumer(); + inline eWrappingAlgorithm GetWrappingAlgorithm(); + inline eMgfAlgorithm GetMgfAlgorithm(); + inline eDigestMethod GetDigestMethod(); +}; + +/************************************************************************************************************************* + Class CContentEncryptionParams +**************************************************************************************************************************/ +class CContentEncryptionParams : public CBase { +public: + + /** + * CContentEncryptionParams::CContentEncryptionParams - Constructor for ContentEncryptionParams class. + */ + CContentEncryptionParams(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline eEncryptionAlgorithm GetEncryptionAlgorithm(); + inline void GetKey(std::vector & ByteDataBuffer); + inline void GetInitializationVector(std::vector & ByteDataBuffer); + inline void GetAuthenticationTag(std::vector & ByteDataBuffer); + inline void SetAuthenticationTag(const CInputVector & ByteDataBuffer); + inline void GetAdditionalAuthenticationData(std::vector & ByteDataBuffer); + inline Lib3MF_uint64 GetDescriptor(); + inline std::string GetKeyUUID(); +}; + +/************************************************************************************************************************* + Class CResourceData +**************************************************************************************************************************/ +class CResourceData : public CBase { +public: + + /** + * CResourceData::CResourceData - Constructor for ResourceData class. + */ + CResourceData(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline PPackagePart GetPath(); + inline eEncryptionAlgorithm GetEncryptionAlgorithm(); + inline eCompression GetCompression(); + inline void GetAdditionalAuthenticationData(std::vector & ByteDataBuffer); +}; + +/************************************************************************************************************************* + Class CResourceDataGroup +**************************************************************************************************************************/ +class CResourceDataGroup : public CBase { +public: + + /** + * CResourceDataGroup::CResourceDataGroup - Constructor for ResourceDataGroup class. + */ + CResourceDataGroup(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetKeyUUID(); + inline PAccessRight AddAccessRight(CConsumer * pConsumer, const eWrappingAlgorithm eWrappingAlgorithm, const eMgfAlgorithm eMgfAlgorithm, const eDigestMethod eDigestMethod); + inline PAccessRight FindAccessRightByConsumer(CConsumer * pConsumer); + inline void RemoveAccessRight(CConsumer * pConsumer); +}; + +/************************************************************************************************************************* + Class CKeyStore +**************************************************************************************************************************/ +class CKeyStore : public CBase { +public: + + /** + * CKeyStore::CKeyStore - Constructor for KeyStore class. + */ + CKeyStore(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline PConsumer AddConsumer(const std::string & sConsumerID, const std::string & sKeyID, const std::string & sKeyValue); + inline Lib3MF_uint64 GetConsumerCount(); + inline PConsumer GetConsumer(const Lib3MF_uint64 nConsumerIndex); + inline void RemoveConsumer(CConsumer * pConsumer); + inline PConsumer FindConsumer(const std::string & sConsumerID); + inline Lib3MF_uint64 GetResourceDataGroupCount(); + inline PResourceDataGroup AddResourceDataGroup(); + inline PResourceDataGroup GetResourceDataGroup(const Lib3MF_uint64 nResourceDataIndex); + inline void RemoveResourceDataGroup(CResourceDataGroup * pResourceDataGroup); + inline PResourceDataGroup FindResourceDataGroup(CPackagePart * pPartPath); + inline PResourceData AddResourceData(CResourceDataGroup * pResourceDataGroup, CPackagePart * pPartPath, const eEncryptionAlgorithm eAlgorithm, const eCompression eCompression, const CInputVector & AdditionalAuthenticationDataBuffer); + inline void RemoveResourceData(CResourceData * pResourceData); + inline PResourceData FindResourceData(CPackagePart * pResourcePath); + inline Lib3MF_uint64 GetResourceDataCount(); + inline PResourceData GetResourceData(const Lib3MF_uint64 nResourceDataIndex); + inline std::string GetUUID(bool & bHasUUID); + inline void SetUUID(const std::string & sUUID); +}; + +/************************************************************************************************************************* + Class CModel +**************************************************************************************************************************/ +class CModel : public CBase { +public: + + /** + * CModel::CModel - Constructor for Model class. + */ + CModel(CWrapper* pWrapper, Lib3MFHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline PPackagePart RootModelPart(); + inline PPackagePart FindOrCreatePackagePart(const std::string & sAbsolutePath); + inline void SetUnit(const eModelUnit eUnit); + inline eModelUnit GetUnit(); + inline std::string GetLanguage(); + inline void SetLanguage(const std::string & sLanguage); + inline PWriter QueryWriter(const std::string & sWriterClass); + inline PReader QueryReader(const std::string & sReaderClass); + inline PTexture2D GetTexture2DByID(const Lib3MF_uint32 nUniqueResourceID); + inline ePropertyType GetPropertyTypeByID(const Lib3MF_uint32 nUniqueResourceID); + inline PBaseMaterialGroup GetBaseMaterialGroupByID(const Lib3MF_uint32 nUniqueResourceID); + inline PTexture2DGroup GetTexture2DGroupByID(const Lib3MF_uint32 nUniqueResourceID); + inline PCompositeMaterials GetCompositeMaterialsByID(const Lib3MF_uint32 nUniqueResourceID); + inline PMultiPropertyGroup GetMultiPropertyGroupByID(const Lib3MF_uint32 nUniqueResourceID); + inline PMeshObject GetMeshObjectByID(const Lib3MF_uint32 nUniqueResourceID); + inline PComponentsObject GetComponentsObjectByID(const Lib3MF_uint32 nUniqueResourceID); + inline PColorGroup GetColorGroupByID(const Lib3MF_uint32 nUniqueResourceID); + inline PSliceStack GetSliceStackByID(const Lib3MF_uint32 nUniqueResourceID); + inline std::string GetBuildUUID(bool & bHasUUID); + inline void SetBuildUUID(const std::string & sUUID); + inline PBuildItemIterator GetBuildItems(); + inline sBox GetOutbox(); + inline PResourceIterator GetResources(); + inline PObjectIterator GetObjects(); + inline PMeshObjectIterator GetMeshObjects(); + inline PComponentsObjectIterator GetComponentsObjects(); + inline PTexture2DIterator GetTexture2Ds(); + inline PBaseMaterialGroupIterator GetBaseMaterialGroups(); + inline PColorGroupIterator GetColorGroups(); + inline PTexture2DGroupIterator GetTexture2DGroups(); + inline PCompositeMaterialsIterator GetCompositeMaterials(); + inline PMultiPropertyGroupIterator GetMultiPropertyGroups(); + inline PSliceStackIterator GetSliceStacks(); + inline PModel MergeToModel(); + inline PMeshObject AddMeshObject(); + inline PComponentsObject AddComponentsObject(); + inline PSliceStack AddSliceStack(const Lib3MF_double dZBottom); + inline PTexture2D AddTexture2DFromAttachment(CAttachment * pTextureAttachment); + inline PBaseMaterialGroup AddBaseMaterialGroup(); + inline PColorGroup AddColorGroup(); + inline PTexture2DGroup AddTexture2DGroup(CTexture2D * pTexture2DInstance); + inline PCompositeMaterials AddCompositeMaterials(CBaseMaterialGroup * pBaseMaterialGroupInstance); + inline PMultiPropertyGroup AddMultiPropertyGroup(); + inline PBuildItem AddBuildItem(CObject * pObject, const sTransform & Transform); + inline void RemoveBuildItem(CBuildItem * pBuildItemInstance); + inline PMetaDataGroup GetMetaDataGroup(); + inline PAttachment AddAttachment(const std::string & sURI, const std::string & sRelationShipType); + inline void RemoveAttachment(CAttachment * pAttachmentInstance); + inline PAttachment GetAttachment(const Lib3MF_uint32 nIndex); + inline PAttachment FindAttachment(const std::string & sURI); + inline Lib3MF_uint32 GetAttachmentCount(); + inline bool HasPackageThumbnailAttachment(); + inline PAttachment CreatePackageThumbnailAttachment(); + inline PAttachment GetPackageThumbnailAttachment(); + inline void RemovePackageThumbnailAttachment(); + inline void AddCustomContentType(const std::string & sExtension, const std::string & sContentType); + inline void RemoveCustomContentType(const std::string & sExtension); + inline void SetRandomNumberCallback(const RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData); + inline PKeyStore GetKeyStore(); +}; + + /** + * CWrapper::GetLibraryVersion - retrieves the binary version of this library. + * @param[out] nMajor - returns the major version of this library + * @param[out] nMinor - returns the minor version of this library + * @param[out] nMicro - returns the micro version of this library + */ + inline void CWrapper::GetLibraryVersion(Lib3MF_uint32 & nMajor, Lib3MF_uint32 & nMinor, Lib3MF_uint32 & nMicro) + { + CheckError(nullptr,lib3mf_getlibraryversion(&nMajor, &nMinor, &nMicro)); + } + + /** + * CWrapper::GetPrereleaseInformation - retrieves prerelease information of this library. + * @return Does the library provide prerelease version? + * @param[out] sPrereleaseInfo - retrieves prerelease information of this library. + */ + inline bool CWrapper::GetPrereleaseInformation(std::string & sPrereleaseInfo) + { + bool resultHasPrereleaseInfo = 0; + Lib3MF_uint32 bytesNeededPrereleaseInfo = 0; + Lib3MF_uint32 bytesWrittenPrereleaseInfo = 0; + CheckError(nullptr,lib3mf_getprereleaseinformation(&resultHasPrereleaseInfo, 0, &bytesNeededPrereleaseInfo, nullptr)); + std::vector bufferPrereleaseInfo(bytesNeededPrereleaseInfo); + CheckError(nullptr,lib3mf_getprereleaseinformation(&resultHasPrereleaseInfo, bytesNeededPrereleaseInfo, &bytesWrittenPrereleaseInfo, &bufferPrereleaseInfo[0])); + sPrereleaseInfo = std::string(&bufferPrereleaseInfo[0]); + + return resultHasPrereleaseInfo; + } + + /** + * CWrapper::GetBuildInformation - retrieves build information of this library. + * @return Does the library provide build version? + * @param[out] sBuildInformation - retrieves build information of this library. + */ + inline bool CWrapper::GetBuildInformation(std::string & sBuildInformation) + { + bool resultHasBuildInfo = 0; + Lib3MF_uint32 bytesNeededBuildInformation = 0; + Lib3MF_uint32 bytesWrittenBuildInformation = 0; + CheckError(nullptr,lib3mf_getbuildinformation(&resultHasBuildInfo, 0, &bytesNeededBuildInformation, nullptr)); + std::vector bufferBuildInformation(bytesNeededBuildInformation); + CheckError(nullptr,lib3mf_getbuildinformation(&resultHasBuildInfo, bytesNeededBuildInformation, &bytesWrittenBuildInformation, &bufferBuildInformation[0])); + sBuildInformation = std::string(&bufferBuildInformation[0]); + + return resultHasBuildInfo; + } + + /** + * CWrapper::GetSpecificationVersion - retrieves whether a specification is supported, and if so, which version. + * @param[in] sSpecificationURL - URL of extension to check + * @param[out] bIsSupported - returns whether this specification is supported + * @param[out] nMajor - returns the major version of the extension (if IsSupported) + * @param[out] nMinor - returns the minor version of the extension (if IsSupported) + * @param[out] nMicro - returns the micro version of the extension (if IsSupported) + */ + inline void CWrapper::GetSpecificationVersion(const std::string & sSpecificationURL, bool & bIsSupported, Lib3MF_uint32 & nMajor, Lib3MF_uint32 & nMinor, Lib3MF_uint32 & nMicro) + { + CheckError(nullptr,lib3mf_getspecificationversion(sSpecificationURL.c_str(), &bIsSupported, &nMajor, &nMinor, &nMicro)); + } + + /** + * CWrapper::CreateModel - creates an empty model instance. + * @return returns an empty model instance + */ + inline PModel CWrapper::CreateModel() + { + Lib3MFHandle hModel = nullptr; + CheckError(nullptr,lib3mf_createmodel(&hModel)); + + if (!hModel) { + CheckError(nullptr,LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(this, hModel); + } + + /** + * CWrapper::Release - releases shared ownership of an object instance + * @param[in] pInstance - the object instance to release + */ + inline void CWrapper::Release(CBase * pInstance) + { + Lib3MFHandle hInstance = nullptr; + if (pInstance != nullptr) { + hInstance = pInstance->GetHandle(); + }; + CheckError(nullptr,lib3mf_release(hInstance)); + } + + /** + * CWrapper::Acquire - acquires shared ownership of an object instance + * @param[in] pInstance - the object instance to acquire + */ + inline void CWrapper::Acquire(CBase * pInstance) + { + Lib3MFHandle hInstance = nullptr; + if (pInstance != nullptr) { + hInstance = pInstance->GetHandle(); + }; + CheckError(nullptr,lib3mf_acquire(hInstance)); + } + + /** + * CWrapper::SetJournal - Sets the journal file path + * @param[in] sJournalPath - File name of the journal file + */ + inline void CWrapper::SetJournal(const std::string & sJournalPath) + { + CheckError(nullptr,lib3mf_setjournal(sJournalPath.c_str())); + } + + /** + * CWrapper::GetLastError - Retrieves the last error string of an instance + * @param[in] pInstance - Object where the error occured. + * @param[out] sLastErrorString - Last Error String + * @return Returns if the instance has a last error. + */ + inline bool CWrapper::GetLastError(CBase * pInstance, std::string & sLastErrorString) + { + Lib3MFHandle hInstance = nullptr; + if (pInstance != nullptr) { + hInstance = pInstance->GetHandle(); + }; + Lib3MF_uint32 bytesNeededLastErrorString = 0; + Lib3MF_uint32 bytesWrittenLastErrorString = 0; + bool resultHasLastError = 0; + CheckError(nullptr,lib3mf_getlasterror(hInstance, 0, &bytesNeededLastErrorString, nullptr, &resultHasLastError)); + std::vector bufferLastErrorString(bytesNeededLastErrorString); + CheckError(nullptr,lib3mf_getlasterror(hInstance, bytesNeededLastErrorString, &bytesWrittenLastErrorString, &bufferLastErrorString[0], &resultHasLastError)); + sLastErrorString = std::string(&bufferLastErrorString[0]); + + return resultHasLastError; + } + + /** + * CWrapper::GetSymbolLookupMethod - Returns the address of the SymbolLookupMethod + * @return Address of the SymbolAddressMethod + */ + inline Lib3MF_pvoid CWrapper::GetSymbolLookupMethod() + { + Lib3MF_pvoid resultSymbolLookupMethod = 0; + CheckError(nullptr,lib3mf_getsymbollookupmethod(&resultSymbolLookupMethod)); + + return resultSymbolLookupMethod; + } + + /** + * CWrapper::RetrieveProgressMessage - Return an English text for a progress identifier.|Note: this is the only function you can call from your callback function. + * @param[in] eTheProgressIdentifier - the progress identifier that is passed to the callback function + * @param[out] sProgressMessage - English text for the progress identifier + */ + inline void CWrapper::RetrieveProgressMessage(const eProgressIdentifier eTheProgressIdentifier, std::string & sProgressMessage) + { + Lib3MF_uint32 bytesNeededProgressMessage = 0; + Lib3MF_uint32 bytesWrittenProgressMessage = 0; + CheckError(nullptr,lib3mf_retrieveprogressmessage(eTheProgressIdentifier, 0, &bytesNeededProgressMessage, nullptr)); + std::vector bufferProgressMessage(bytesNeededProgressMessage); + CheckError(nullptr,lib3mf_retrieveprogressmessage(eTheProgressIdentifier, bytesNeededProgressMessage, &bytesWrittenProgressMessage, &bufferProgressMessage[0])); + sProgressMessage = std::string(&bufferProgressMessage[0]); + } + + /** + * CWrapper::RGBAToColor - Creates a Color from uint8 RGBA values + * @param[in] nRed - Red value of color (0-255) + * @param[in] nGreen - Green value of color (0-255) + * @param[in] nBlue - Blue value of color (0-255) + * @param[in] nAlpha - Alpha value of color (0-255) + * @return Assembled color + */ + inline sColor CWrapper::RGBAToColor(const Lib3MF_uint8 nRed, const Lib3MF_uint8 nGreen, const Lib3MF_uint8 nBlue, const Lib3MF_uint8 nAlpha) + { + sColor resultTheColor; + CheckError(nullptr,lib3mf_rgbatocolor(nRed, nGreen, nBlue, nAlpha, &resultTheColor)); + + return resultTheColor; + } + + /** + * CWrapper::FloatRGBAToColor - Creates a Color from uint8 RGBA values + * @param[in] fRed - Red value of color (0-1) + * @param[in] fGreen - Green value of color (0-1) + * @param[in] fBlue - Blue value of color (0-1) + * @param[in] fAlpha - Alpha value of color (0-1) + * @return Assembled color + */ + inline sColor CWrapper::FloatRGBAToColor(const Lib3MF_single fRed, const Lib3MF_single fGreen, const Lib3MF_single fBlue, const Lib3MF_single fAlpha) + { + sColor resultTheColor; + CheckError(nullptr,lib3mf_floatrgbatocolor(fRed, fGreen, fBlue, fAlpha, &resultTheColor)); + + return resultTheColor; + } + + /** + * CWrapper::ColorToRGBA - Calculates uint8-RGBA-values from a Color + * @param[in] TheColor - Color to handle + * @param[out] nRed - Red value of color (0-255) + * @param[out] nGreen - Green value of color (0-255) + * @param[out] nBlue - Blue value of color (0-255) + * @param[out] nAlpha - Alpha value of color (0-255) + */ + inline void CWrapper::ColorToRGBA(const sColor & TheColor, Lib3MF_uint8 & nRed, Lib3MF_uint8 & nGreen, Lib3MF_uint8 & nBlue, Lib3MF_uint8 & nAlpha) + { + CheckError(nullptr,lib3mf_colortorgba(&TheColor, &nRed, &nGreen, &nBlue, &nAlpha)); + } + + /** + * CWrapper::ColorToFloatRGBA - Calculates float-RGBA-values from a Color + * @param[in] TheColor - Color to handle + * @param[out] fRed - Red value of color (0-1) + * @param[out] fGreen - Green value of color (0-1) + * @param[out] fBlue - Blue value of color (0-1) + * @param[out] fAlpha - Alpha value of color (0-1) + */ + inline void CWrapper::ColorToFloatRGBA(const sColor & TheColor, Lib3MF_single & fRed, Lib3MF_single & fGreen, Lib3MF_single & fBlue, Lib3MF_single & fAlpha) + { + CheckError(nullptr,lib3mf_colortofloatrgba(&TheColor, &fRed, &fGreen, &fBlue, &fAlpha)); + } + + /** + * CWrapper::GetIdentityTransform - Creates an identity transform + * @return Transformation matrix. + */ + inline sTransform CWrapper::GetIdentityTransform() + { + sTransform resultTransform; + CheckError(nullptr,lib3mf_getidentitytransform(&resultTransform)); + + return resultTransform; + } + + /** + * CWrapper::GetUniformScaleTransform - Creates a uniform scale transform + * @param[in] fFactor - Factor in X, Y and Z + * @return Transformation matrix. + */ + inline sTransform CWrapper::GetUniformScaleTransform(const Lib3MF_single fFactor) + { + sTransform resultTransform; + CheckError(nullptr,lib3mf_getuniformscaletransform(fFactor, &resultTransform)); + + return resultTransform; + } + + /** + * CWrapper::GetScaleTransform - Creates a scale transform + * @param[in] fFactorX - Factor in X + * @param[in] fFactorY - Factor in Y + * @param[in] fFactorZ - Factor in Z + * @return Transformation matrix. + */ + inline sTransform CWrapper::GetScaleTransform(const Lib3MF_single fFactorX, const Lib3MF_single fFactorY, const Lib3MF_single fFactorZ) + { + sTransform resultTransform; + CheckError(nullptr,lib3mf_getscaletransform(fFactorX, fFactorY, fFactorZ, &resultTransform)); + + return resultTransform; + } + + /** + * CWrapper::GetTranslationTransform - Creates an translation transform + * @param[in] fVectorX - Translation in X + * @param[in] fVectorY - Translation in Y + * @param[in] fVectorZ - Translation in Z + * @return Transformation matrix. + */ + inline sTransform CWrapper::GetTranslationTransform(const Lib3MF_single fVectorX, const Lib3MF_single fVectorY, const Lib3MF_single fVectorZ) + { + sTransform resultTransform; + CheckError(nullptr,lib3mf_gettranslationtransform(fVectorX, fVectorY, fVectorZ, &resultTransform)); + + return resultTransform; + } + + inline void CWrapper::CheckError(CBase * pBaseClass, Lib3MFResult nResult) + { + if (nResult != 0) { + std::string sErrorMessage; + if (pBaseClass != nullptr) { + GetLastError(pBaseClass, sErrorMessage); + } + throw ELib3MFException(nResult, sErrorMessage); + } + } + + + + /** + * Method definitions for class CBase + */ + + /** + * Method definitions for class CWriter + */ + + /** + * CWriter::WriteToFile - Writes out the model as file. The file type is specified by the Model Writer class. + * @param[in] sFilename - Filename to write into + */ + void CWriter::WriteToFile(const std::string & sFilename) + { + CheckError(lib3mf_writer_writetofile(m_pHandle, sFilename.c_str())); + } + + /** + * CWriter::GetStreamSize - Retrieves the size of the full 3MF file stream. + * @return the stream size + */ + Lib3MF_uint64 CWriter::GetStreamSize() + { + Lib3MF_uint64 resultStreamSize = 0; + CheckError(lib3mf_writer_getstreamsize(m_pHandle, &resultStreamSize)); + + return resultStreamSize; + } + + /** + * CWriter::WriteToBuffer - Writes out the 3MF file into a memory buffer + * @param[out] BufferBuffer - buffer to write into + */ + void CWriter::WriteToBuffer(std::vector & BufferBuffer) + { + Lib3MF_uint64 elementsNeededBuffer = 0; + Lib3MF_uint64 elementsWrittenBuffer = 0; + CheckError(lib3mf_writer_writetobuffer(m_pHandle, 0, &elementsNeededBuffer, nullptr)); + BufferBuffer.resize((size_t) elementsNeededBuffer); + CheckError(lib3mf_writer_writetobuffer(m_pHandle, elementsNeededBuffer, &elementsWrittenBuffer, BufferBuffer.data())); + } + + /** + * CWriter::WriteToCallback - Writes out the model and passes the data to a provided callback function. The file type is specified by the Model Writer class. + * @param[in] pTheWriteCallback - Callback to call for writing a data chunk + * @param[in] pTheSeekCallback - Callback to call for seeking in the stream + * @param[in] pUserData - Userdata that is passed to the callback function + */ + void CWriter::WriteToCallback(const WriteCallback pTheWriteCallback, const SeekCallback pTheSeekCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_writer_writetocallback(m_pHandle, pTheWriteCallback, pTheSeekCallback, pUserData)); + } + + /** + * CWriter::SetProgressCallback - Set the progress callback for calls to this writer + * @param[in] pProgressCallback - pointer to the callback function. + * @param[in] pUserData - pointer to arbitrary user data that is passed without modification to the callback. + */ + void CWriter::SetProgressCallback(const ProgressCallback pProgressCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_writer_setprogresscallback(m_pHandle, pProgressCallback, pUserData)); + } + + /** + * CWriter::GetDecimalPrecision - Returns the number of digits after the decimal point to be written in each vertex coordinate-value. + * @return The number of digits to be written in each vertex coordinate-value after the decimal point. + */ + Lib3MF_uint32 CWriter::GetDecimalPrecision() + { + Lib3MF_uint32 resultDecimalPrecision = 0; + CheckError(lib3mf_writer_getdecimalprecision(m_pHandle, &resultDecimalPrecision)); + + return resultDecimalPrecision; + } + + /** + * CWriter::SetDecimalPrecision - Sets the number of digits after the decimal point to be written in each vertex coordinate-value. + * @param[in] nDecimalPrecision - The number of digits to be written in each vertex coordinate-value after the decimal point. + */ + void CWriter::SetDecimalPrecision(const Lib3MF_uint32 nDecimalPrecision) + { + CheckError(lib3mf_writer_setdecimalprecision(m_pHandle, nDecimalPrecision)); + } + + /** + * CWriter::SetStrictModeActive - Activates (deactivates) the strict mode of the reader. + * @param[in] bStrictModeActive - flag whether strict mode is active or not. + */ + void CWriter::SetStrictModeActive(const bool bStrictModeActive) + { + CheckError(lib3mf_writer_setstrictmodeactive(m_pHandle, bStrictModeActive)); + } + + /** + * CWriter::GetStrictModeActive - Queries whether the strict mode of the reader is active or not + * @return returns flag whether strict mode is active or not. + */ + bool CWriter::GetStrictModeActive() + { + bool resultStrictModeActive = 0; + CheckError(lib3mf_writer_getstrictmodeactive(m_pHandle, &resultStrictModeActive)); + + return resultStrictModeActive; + } + + /** + * CWriter::GetWarning - Returns Warning and Error Information of the read process + * @param[in] nIndex - Index of the Warning. Valid values are 0 to WarningCount - 1 + * @param[out] nErrorCode - filled with the error code of the warning + * @return the message of the warning + */ + std::string CWriter::GetWarning(const Lib3MF_uint32 nIndex, Lib3MF_uint32 & nErrorCode) + { + Lib3MF_uint32 bytesNeededWarning = 0; + Lib3MF_uint32 bytesWrittenWarning = 0; + CheckError(lib3mf_writer_getwarning(m_pHandle, nIndex, &nErrorCode, 0, &bytesNeededWarning, nullptr)); + std::vector bufferWarning(bytesNeededWarning); + CheckError(lib3mf_writer_getwarning(m_pHandle, nIndex, &nErrorCode, bytesNeededWarning, &bytesWrittenWarning, &bufferWarning[0])); + + return std::string(&bufferWarning[0]); + } + + /** + * CWriter::GetWarningCount - Returns Warning and Error Count of the read process + * @return filled with the count of the occurred warnings. + */ + Lib3MF_uint32 CWriter::GetWarningCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_writer_getwarningcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CWriter::AddKeyWrappingCallback - Registers a callback to deal with data key encryption/decryption from keystore + * @param[in] sConsumerID - The ConsumerID to register for + * @param[in] pTheCallback - The callback to be callede for wrapping and encryption key + * @param[in] pUserData - Userdata that is passed to the callback function + */ + void CWriter::AddKeyWrappingCallback(const std::string & sConsumerID, const KeyWrappingCallback pTheCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_writer_addkeywrappingcallback(m_pHandle, sConsumerID.c_str(), pTheCallback, pUserData)); + } + + /** + * CWriter::SetContentEncryptionCallback - Registers a callback to deal with encryption of content + * @param[in] pTheCallback - The callback used to encrypt content + * @param[in] pUserData - Userdata that is passed to the callback function + */ + void CWriter::SetContentEncryptionCallback(const ContentEncryptionCallback pTheCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_writer_setcontentencryptioncallback(m_pHandle, pTheCallback, pUserData)); + } + + /** + * Method definitions for class CReader + */ + + /** + * CReader::ReadFromFile - Reads a model from a file. The file type is specified by the Model Reader class + * @param[in] sFilename - Filename to read from + */ + void CReader::ReadFromFile(const std::string & sFilename) + { + CheckError(lib3mf_reader_readfromfile(m_pHandle, sFilename.c_str())); + } + + /** + * CReader::ReadFromBuffer - Reads a model from a memory buffer. + * @param[in] BufferBuffer - Buffer to read from + */ + void CReader::ReadFromBuffer(const CInputVector & BufferBuffer) + { + CheckError(lib3mf_reader_readfrombuffer(m_pHandle, (Lib3MF_uint64)BufferBuffer.size(), BufferBuffer.data())); + } + + /** + * CReader::ReadFromCallback - Reads a model and from the data provided by a callback function + * @param[in] pTheReadCallback - Callback to call for reading a data chunk + * @param[in] nStreamSize - number of bytes the callback returns + * @param[in] pTheSeekCallback - Callback to call for seeking in the stream. + * @param[in] pUserData - Userdata that is passed to the callback function + */ + void CReader::ReadFromCallback(const ReadCallback pTheReadCallback, const Lib3MF_uint64 nStreamSize, const SeekCallback pTheSeekCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_reader_readfromcallback(m_pHandle, pTheReadCallback, nStreamSize, pTheSeekCallback, pUserData)); + } + + /** + * CReader::SetProgressCallback - Set the progress callback for calls to this writer + * @param[in] pProgressCallback - pointer to the callback function. + * @param[in] pUserData - pointer to arbitrary user data that is passed without modification to the callback. + */ + void CReader::SetProgressCallback(const ProgressCallback pProgressCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_reader_setprogresscallback(m_pHandle, pProgressCallback, pUserData)); + } + + /** + * CReader::AddRelationToRead - Adds a relationship type which shall be read as attachment in memory while loading + * @param[in] sRelationShipType - String of the relationship type + */ + void CReader::AddRelationToRead(const std::string & sRelationShipType) + { + CheckError(lib3mf_reader_addrelationtoread(m_pHandle, sRelationShipType.c_str())); + } + + /** + * CReader::RemoveRelationToRead - Removes a relationship type which shall be read as attachment in memory while loading + * @param[in] sRelationShipType - String of the relationship type + */ + void CReader::RemoveRelationToRead(const std::string & sRelationShipType) + { + CheckError(lib3mf_reader_removerelationtoread(m_pHandle, sRelationShipType.c_str())); + } + + /** + * CReader::SetStrictModeActive - Activates (deactivates) the strict mode of the reader. + * @param[in] bStrictModeActive - flag whether strict mode is active or not. + */ + void CReader::SetStrictModeActive(const bool bStrictModeActive) + { + CheckError(lib3mf_reader_setstrictmodeactive(m_pHandle, bStrictModeActive)); + } + + /** + * CReader::GetStrictModeActive - Queries whether the strict mode of the reader is active or not + * @return returns flag whether strict mode is active or not. + */ + bool CReader::GetStrictModeActive() + { + bool resultStrictModeActive = 0; + CheckError(lib3mf_reader_getstrictmodeactive(m_pHandle, &resultStrictModeActive)); + + return resultStrictModeActive; + } + + /** + * CReader::GetWarning - Returns Warning and Error Information of the read process + * @param[in] nIndex - Index of the Warning. Valid values are 0 to WarningCount - 1 + * @param[out] nErrorCode - filled with the error code of the warning + * @return the message of the warning + */ + std::string CReader::GetWarning(const Lib3MF_uint32 nIndex, Lib3MF_uint32 & nErrorCode) + { + Lib3MF_uint32 bytesNeededWarning = 0; + Lib3MF_uint32 bytesWrittenWarning = 0; + CheckError(lib3mf_reader_getwarning(m_pHandle, nIndex, &nErrorCode, 0, &bytesNeededWarning, nullptr)); + std::vector bufferWarning(bytesNeededWarning); + CheckError(lib3mf_reader_getwarning(m_pHandle, nIndex, &nErrorCode, bytesNeededWarning, &bytesWrittenWarning, &bufferWarning[0])); + + return std::string(&bufferWarning[0]); + } + + /** + * CReader::GetWarningCount - Returns Warning and Error Count of the read process + * @return filled with the count of the occurred warnings. + */ + Lib3MF_uint32 CReader::GetWarningCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_reader_getwarningcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CReader::AddKeyWrappingCallback - Registers a callback to deal with key wrapping mechanism from keystore + * @param[in] sConsumerID - The ConsumerID to register for + * @param[in] pTheCallback - The callback used to decrypt data key + * @param[in] pUserData - Userdata that is passed to the callback function + */ + void CReader::AddKeyWrappingCallback(const std::string & sConsumerID, const KeyWrappingCallback pTheCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_reader_addkeywrappingcallback(m_pHandle, sConsumerID.c_str(), pTheCallback, pUserData)); + } + + /** + * CReader::SetContentEncryptionCallback - Registers a callback to deal with encryption of content + * @param[in] pTheCallback - The callback used to encrypt content + * @param[in] pUserData - Userdata that is passed to the callback function + */ + void CReader::SetContentEncryptionCallback(const ContentEncryptionCallback pTheCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_reader_setcontentencryptioncallback(m_pHandle, pTheCallback, pUserData)); + } + + /** + * Method definitions for class CPackagePart + */ + + /** + * CPackagePart::GetPath - Returns the absolute path of this PackagePart. + * @return Returns the absolute path of this PackagePart + */ + std::string CPackagePart::GetPath() + { + Lib3MF_uint32 bytesNeededPath = 0; + Lib3MF_uint32 bytesWrittenPath = 0; + CheckError(lib3mf_packagepart_getpath(m_pHandle, 0, &bytesNeededPath, nullptr)); + std::vector bufferPath(bytesNeededPath); + CheckError(lib3mf_packagepart_getpath(m_pHandle, bytesNeededPath, &bytesWrittenPath, &bufferPath[0])); + + return std::string(&bufferPath[0]); + } + + /** + * CPackagePart::SetPath - Sets the absolute path of this PackagePart. + * @param[in] sPath - Sets the absolute path of this PackagePart. + */ + void CPackagePart::SetPath(const std::string & sPath) + { + CheckError(lib3mf_packagepart_setpath(m_pHandle, sPath.c_str())); + } + + /** + * Method definitions for class CResource + */ + + /** + * CResource::GetResourceID - Retrieves the unique id of this resource within a package. This function will be removed in a later release in favor of GetUniqueResourceID + * @return Retrieves the unique id of this resource within a package. + */ + Lib3MF_uint32 CResource::GetResourceID() + { + Lib3MF_uint32 resultUniqueResourceID = 0; + CheckError(lib3mf_resource_getresourceid(m_pHandle, &resultUniqueResourceID)); + + return resultUniqueResourceID; + } + + /** + * CResource::GetUniqueResourceID - Retrieves the unique id of this resource within a package. + * @return Retrieves the unique id of this resource within a package. + */ + Lib3MF_uint32 CResource::GetUniqueResourceID() + { + Lib3MF_uint32 resultUniqueResourceID = 0; + CheckError(lib3mf_resource_getuniqueresourceid(m_pHandle, &resultUniqueResourceID)); + + return resultUniqueResourceID; + } + + /** + * CResource::PackagePart - Returns the PackagePart within which this resource resides + * @return the PackagePart within which this resource resides. + */ + PPackagePart CResource::PackagePart() + { + Lib3MFHandle hPackagePart = nullptr; + CheckError(lib3mf_resource_packagepart(m_pHandle, &hPackagePart)); + + if (!hPackagePart) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hPackagePart); + } + + /** + * CResource::SetPackagePart - Sets the new PackagePart within which this resource resides + * @param[in] pPackagePart - the new PackagePart within which this resource resides. + */ + void CResource::SetPackagePart(CPackagePart * pPackagePart) + { + Lib3MFHandle hPackagePart = nullptr; + if (pPackagePart != nullptr) { + hPackagePart = pPackagePart->GetHandle(); + }; + CheckError(lib3mf_resource_setpackagepart(m_pHandle, hPackagePart)); + } + + /** + * CResource::GetModelResourceID - Retrieves the id of this resource within a model. + * @return Retrieves the id of this resource within a model. + */ + Lib3MF_uint32 CResource::GetModelResourceID() + { + Lib3MF_uint32 resultModelResourceId = 0; + CheckError(lib3mf_resource_getmodelresourceid(m_pHandle, &resultModelResourceId)); + + return resultModelResourceId; + } + + /** + * Method definitions for class CResourceIterator + */ + + /** + * CResourceIterator::MoveNext - Iterates to the next resource in the list. + * @return Iterates to the next resource in the list. + */ + bool CResourceIterator::MoveNext() + { + bool resultHasNext = 0; + CheckError(lib3mf_resourceiterator_movenext(m_pHandle, &resultHasNext)); + + return resultHasNext; + } + + /** + * CResourceIterator::MovePrevious - Iterates to the previous resource in the list. + * @return Iterates to the previous resource in the list. + */ + bool CResourceIterator::MovePrevious() + { + bool resultHasPrevious = 0; + CheckError(lib3mf_resourceiterator_moveprevious(m_pHandle, &resultHasPrevious)); + + return resultHasPrevious; + } + + /** + * CResourceIterator::GetCurrent - Returns the resource the iterator points at. + * @return returns the resource instance. + */ + PResource CResourceIterator::GetCurrent() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_resourceiterator_getcurrent(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * CResourceIterator::Clone - Creates a new resource iterator with the same resource list. + * @return returns the cloned Iterator instance + */ + PResourceIterator CResourceIterator::Clone() + { + Lib3MFHandle hOutResourceIterator = nullptr; + CheckError(lib3mf_resourceiterator_clone(m_pHandle, &hOutResourceIterator)); + + if (!hOutResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hOutResourceIterator); + } + + /** + * CResourceIterator::Count - Returns the number of resoucres the iterator captures. + * @return returns the number of resoucres the iterator captures. + */ + Lib3MF_uint64 CResourceIterator::Count() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_resourceiterator_count(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * Method definitions for class CSliceStackIterator + */ + + /** + * CSliceStackIterator::GetCurrentSliceStack - Returns the SliceStack the iterator points at. + * @return returns the SliceStack instance. + */ + PSliceStack CSliceStackIterator::GetCurrentSliceStack() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_slicestackiterator_getcurrentslicestack(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CObjectIterator + */ + + /** + * CObjectIterator::GetCurrentObject - Returns the Object the iterator points at. + * @return returns the Object instance. + */ + PObject CObjectIterator::GetCurrentObject() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_objectiterator_getcurrentobject(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CMeshObjectIterator + */ + + /** + * CMeshObjectIterator::GetCurrentMeshObject - Returns the MeshObject the iterator points at. + * @return returns the MeshObject instance. + */ + PMeshObject CMeshObjectIterator::GetCurrentMeshObject() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_meshobjectiterator_getcurrentmeshobject(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CComponentsObjectIterator + */ + + /** + * CComponentsObjectIterator::GetCurrentComponentsObject - Returns the ComponentsObject the iterator points at. + * @return returns the ComponentsObject instance. + */ + PComponentsObject CComponentsObjectIterator::GetCurrentComponentsObject() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_componentsobjectiterator_getcurrentcomponentsobject(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CTexture2DIterator + */ + + /** + * CTexture2DIterator::GetCurrentTexture2D - Returns the Texture2D the iterator points at. + * @return returns the Texture2D instance. + */ + PTexture2D CTexture2DIterator::GetCurrentTexture2D() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_texture2diterator_getcurrenttexture2d(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CBaseMaterialGroupIterator + */ + + /** + * CBaseMaterialGroupIterator::GetCurrentBaseMaterialGroup - Returns the MaterialGroup the iterator points at. + * @return returns the BaseMaterialGroup instance. + */ + PBaseMaterialGroup CBaseMaterialGroupIterator::GetCurrentBaseMaterialGroup() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_basematerialgroupiterator_getcurrentbasematerialgroup(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CColorGroupIterator + */ + + /** + * CColorGroupIterator::GetCurrentColorGroup - Returns the ColorGroup the iterator points at. + * @return returns the ColorGroup instance. + */ + PColorGroup CColorGroupIterator::GetCurrentColorGroup() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_colorgroupiterator_getcurrentcolorgroup(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CTexture2DGroupIterator + */ + + /** + * CTexture2DGroupIterator::GetCurrentTexture2DGroup - Returns the Texture2DGroup the iterator points at. + * @return returns the Texture2DGroup instance. + */ + PTexture2DGroup CTexture2DGroupIterator::GetCurrentTexture2DGroup() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_texture2dgroupiterator_getcurrenttexture2dgroup(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CCompositeMaterialsIterator + */ + + /** + * CCompositeMaterialsIterator::GetCurrentCompositeMaterials - Returns the CompositeMaterials the iterator points at. + * @return returns the CompositeMaterials instance. + */ + PCompositeMaterials CCompositeMaterialsIterator::GetCurrentCompositeMaterials() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_compositematerialsiterator_getcurrentcompositematerials(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CMultiPropertyGroupIterator + */ + + /** + * CMultiPropertyGroupIterator::GetCurrentMultiPropertyGroup - Returns the MultiPropertyGroup the iterator points at. + * @return returns the MultiPropertyGroup instance. + */ + PMultiPropertyGroup CMultiPropertyGroupIterator::GetCurrentMultiPropertyGroup() + { + Lib3MFHandle hResource = nullptr; + CheckError(lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup(m_pHandle, &hResource)); + + if (!hResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResource); + } + + /** + * Method definitions for class CMetaData + */ + + /** + * CMetaData::GetNameSpace - returns the namespace URL of the metadata + * @return the namespace URL of the metadata + */ + std::string CMetaData::GetNameSpace() + { + Lib3MF_uint32 bytesNeededNameSpace = 0; + Lib3MF_uint32 bytesWrittenNameSpace = 0; + CheckError(lib3mf_metadata_getnamespace(m_pHandle, 0, &bytesNeededNameSpace, nullptr)); + std::vector bufferNameSpace(bytesNeededNameSpace); + CheckError(lib3mf_metadata_getnamespace(m_pHandle, bytesNeededNameSpace, &bytesWrittenNameSpace, &bufferNameSpace[0])); + + return std::string(&bufferNameSpace[0]); + } + + /** + * CMetaData::SetNameSpace - sets a new namespace URL of the metadata + * @param[in] sNameSpace - the new namespace URL of the metadata + */ + void CMetaData::SetNameSpace(const std::string & sNameSpace) + { + CheckError(lib3mf_metadata_setnamespace(m_pHandle, sNameSpace.c_str())); + } + + /** + * CMetaData::GetName - returns the name of a metadata + * @return the name of the metadata + */ + std::string CMetaData::GetName() + { + Lib3MF_uint32 bytesNeededName = 0; + Lib3MF_uint32 bytesWrittenName = 0; + CheckError(lib3mf_metadata_getname(m_pHandle, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(lib3mf_metadata_getname(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CMetaData::SetName - sets a new name of a metadata + * @param[in] sName - the new name of the metadata + */ + void CMetaData::SetName(const std::string & sName) + { + CheckError(lib3mf_metadata_setname(m_pHandle, sName.c_str())); + } + + /** + * CMetaData::GetKey - returns the (namespace+name) of a metadata + * @return the key (namespace+name) of the metadata + */ + std::string CMetaData::GetKey() + { + Lib3MF_uint32 bytesNeededKey = 0; + Lib3MF_uint32 bytesWrittenKey = 0; + CheckError(lib3mf_metadata_getkey(m_pHandle, 0, &bytesNeededKey, nullptr)); + std::vector bufferKey(bytesNeededKey); + CheckError(lib3mf_metadata_getkey(m_pHandle, bytesNeededKey, &bytesWrittenKey, &bufferKey[0])); + + return std::string(&bufferKey[0]); + } + + /** + * CMetaData::GetMustPreserve - returns, whether a metadata must be preserved + * @return returns, whether a metadata must be preserved + */ + bool CMetaData::GetMustPreserve() + { + bool resultMustPreserve = 0; + CheckError(lib3mf_metadata_getmustpreserve(m_pHandle, &resultMustPreserve)); + + return resultMustPreserve; + } + + /** + * CMetaData::SetMustPreserve - sets whether a metadata must be preserved + * @param[in] bMustPreserve - a new value whether a metadata must be preserved + */ + void CMetaData::SetMustPreserve(const bool bMustPreserve) + { + CheckError(lib3mf_metadata_setmustpreserve(m_pHandle, bMustPreserve)); + } + + /** + * CMetaData::GetType - returns the type of a metadata + * @return the type of the metadata + */ + std::string CMetaData::GetType() + { + Lib3MF_uint32 bytesNeededType = 0; + Lib3MF_uint32 bytesWrittenType = 0; + CheckError(lib3mf_metadata_gettype(m_pHandle, 0, &bytesNeededType, nullptr)); + std::vector bufferType(bytesNeededType); + CheckError(lib3mf_metadata_gettype(m_pHandle, bytesNeededType, &bytesWrittenType, &bufferType[0])); + + return std::string(&bufferType[0]); + } + + /** + * CMetaData::SetType - sets a new type of a metadata. This must be a simple XML type + * @param[in] sType - a new type of the metadata + */ + void CMetaData::SetType(const std::string & sType) + { + CheckError(lib3mf_metadata_settype(m_pHandle, sType.c_str())); + } + + /** + * CMetaData::GetValue - returns the value of the metadata + * @return the value of the metadata + */ + std::string CMetaData::GetValue() + { + Lib3MF_uint32 bytesNeededValue = 0; + Lib3MF_uint32 bytesWrittenValue = 0; + CheckError(lib3mf_metadata_getvalue(m_pHandle, 0, &bytesNeededValue, nullptr)); + std::vector bufferValue(bytesNeededValue); + CheckError(lib3mf_metadata_getvalue(m_pHandle, bytesNeededValue, &bytesWrittenValue, &bufferValue[0])); + + return std::string(&bufferValue[0]); + } + + /** + * CMetaData::SetValue - sets a new value of the metadata + * @param[in] sValue - a new value of the metadata + */ + void CMetaData::SetValue(const std::string & sValue) + { + CheckError(lib3mf_metadata_setvalue(m_pHandle, sValue.c_str())); + } + + /** + * Method definitions for class CMetaDataGroup + */ + + /** + * CMetaDataGroup::GetMetaDataCount - returns the number of metadata in this metadatagroup + * @return returns the number metadata + */ + Lib3MF_uint32 CMetaDataGroup::GetMetaDataCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_metadatagroup_getmetadatacount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CMetaDataGroup::GetMetaData - returns a metadata value within this metadatagroup + * @param[in] nIndex - Index of the Metadata. + * @return an instance of the metadata + */ + PMetaData CMetaDataGroup::GetMetaData(const Lib3MF_uint32 nIndex) + { + Lib3MFHandle hMetaData = nullptr; + CheckError(lib3mf_metadatagroup_getmetadata(m_pHandle, nIndex, &hMetaData)); + + if (!hMetaData) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMetaData); + } + + /** + * CMetaDataGroup::GetMetaDataByKey - returns a metadata value within this metadatagroup + * @param[in] sNameSpace - the namespace of the metadata + * @param[in] sName - the name of the Metadata + * @return an instance of the metadata + */ + PMetaData CMetaDataGroup::GetMetaDataByKey(const std::string & sNameSpace, const std::string & sName) + { + Lib3MFHandle hMetaData = nullptr; + CheckError(lib3mf_metadatagroup_getmetadatabykey(m_pHandle, sNameSpace.c_str(), sName.c_str(), &hMetaData)); + + if (!hMetaData) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMetaData); + } + + /** + * CMetaDataGroup::RemoveMetaDataByIndex - removes metadata by index from the model. + * @param[in] nIndex - Index of the metadata to remove + */ + void CMetaDataGroup::RemoveMetaDataByIndex(const Lib3MF_uint32 nIndex) + { + CheckError(lib3mf_metadatagroup_removemetadatabyindex(m_pHandle, nIndex)); + } + + /** + * CMetaDataGroup::RemoveMetaData - removes metadata from the model. + * @param[in] pTheMetaData - The metadata to remove + */ + void CMetaDataGroup::RemoveMetaData(CMetaData * pTheMetaData) + { + Lib3MFHandle hTheMetaData = nullptr; + if (pTheMetaData != nullptr) { + hTheMetaData = pTheMetaData->GetHandle(); + }; + CheckError(lib3mf_metadatagroup_removemetadata(m_pHandle, hTheMetaData)); + } + + /** + * CMetaDataGroup::AddMetaData - adds a new metadata to this metadatagroup + * @param[in] sNameSpace - the namespace of the metadata + * @param[in] sName - the name of the metadata + * @param[in] sValue - the value of the metadata + * @param[in] sType - the type of the metadata + * @param[in] bMustPreserve - shuold the metadata be preserved + * @return a new instance of the metadata + */ + PMetaData CMetaDataGroup::AddMetaData(const std::string & sNameSpace, const std::string & sName, const std::string & sValue, const std::string & sType, const bool bMustPreserve) + { + Lib3MFHandle hMetaData = nullptr; + CheckError(lib3mf_metadatagroup_addmetadata(m_pHandle, sNameSpace.c_str(), sName.c_str(), sValue.c_str(), sType.c_str(), bMustPreserve, &hMetaData)); + + if (!hMetaData) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMetaData); + } + + /** + * Method definitions for class CObject + */ + + /** + * CObject::GetType - Retrieves an object's type + * @return returns object type enum. + */ + eObjectType CObject::GetType() + { + eObjectType resultObjectType = (eObjectType) 0; + CheckError(lib3mf_object_gettype(m_pHandle, &resultObjectType)); + + return resultObjectType; + } + + /** + * CObject::SetType - Sets an object's type + * @param[in] eObjectType - object type enum. + */ + void CObject::SetType(const eObjectType eObjectType) + { + CheckError(lib3mf_object_settype(m_pHandle, eObjectType)); + } + + /** + * CObject::GetName - Retrieves an object's name + * @return returns object name. + */ + std::string CObject::GetName() + { + Lib3MF_uint32 bytesNeededName = 0; + Lib3MF_uint32 bytesWrittenName = 0; + CheckError(lib3mf_object_getname(m_pHandle, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(lib3mf_object_getname(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CObject::SetName - Sets an object's name string + * @param[in] sName - new object name. + */ + void CObject::SetName(const std::string & sName) + { + CheckError(lib3mf_object_setname(m_pHandle, sName.c_str())); + } + + /** + * CObject::GetPartNumber - Retrieves an object's part number + * @return returns object part number. + */ + std::string CObject::GetPartNumber() + { + Lib3MF_uint32 bytesNeededPartNumber = 0; + Lib3MF_uint32 bytesWrittenPartNumber = 0; + CheckError(lib3mf_object_getpartnumber(m_pHandle, 0, &bytesNeededPartNumber, nullptr)); + std::vector bufferPartNumber(bytesNeededPartNumber); + CheckError(lib3mf_object_getpartnumber(m_pHandle, bytesNeededPartNumber, &bytesWrittenPartNumber, &bufferPartNumber[0])); + + return std::string(&bufferPartNumber[0]); + } + + /** + * CObject::SetPartNumber - Sets an objects partnumber string + * @param[in] sPartNumber - new object part number. + */ + void CObject::SetPartNumber(const std::string & sPartNumber) + { + CheckError(lib3mf_object_setpartnumber(m_pHandle, sPartNumber.c_str())); + } + + /** + * CObject::IsMeshObject - Retrieves, if an object is a mesh object + * @return returns, whether the object is a mesh object + */ + bool CObject::IsMeshObject() + { + bool resultIsMeshObject = 0; + CheckError(lib3mf_object_ismeshobject(m_pHandle, &resultIsMeshObject)); + + return resultIsMeshObject; + } + + /** + * CObject::IsComponentsObject - Retrieves, if an object is a components object + * @return returns, whether the object is a components object + */ + bool CObject::IsComponentsObject() + { + bool resultIsComponentsObject = 0; + CheckError(lib3mf_object_iscomponentsobject(m_pHandle, &resultIsComponentsObject)); + + return resultIsComponentsObject; + } + + /** + * CObject::IsValid - Retrieves, if the object is valid according to the core spec. For mesh objects, we distinguish between the type attribute of the object:In case of object type other, this always means false.In case of object type model or solidsupport, this means, if the mesh suffices all requirements of the core spec chapter 4.1.In case of object type support or surface, this always means true.A component objects is valid if and only if it contains at least one component and all child components are valid objects. + * @return returns whether the object is a valid object description + */ + bool CObject::IsValid() + { + bool resultIsValid = 0; + CheckError(lib3mf_object_isvalid(m_pHandle, &resultIsValid)); + + return resultIsValid; + } + + /** + * CObject::SetAttachmentAsThumbnail - Use an existing attachment as thumbnail for this object + * @param[in] pAttachment - Instance of a new or the existing thumbnailattachment object. + */ + void CObject::SetAttachmentAsThumbnail(CAttachment * pAttachment) + { + Lib3MFHandle hAttachment = nullptr; + if (pAttachment != nullptr) { + hAttachment = pAttachment->GetHandle(); + }; + CheckError(lib3mf_object_setattachmentasthumbnail(m_pHandle, hAttachment)); + } + + /** + * CObject::GetThumbnailAttachment - Get the attachment containing the object thumbnail. + * @return Instance of the thumbnailattachment object or NULL. + */ + PAttachment CObject::GetThumbnailAttachment() + { + Lib3MFHandle hAttachment = nullptr; + CheckError(lib3mf_object_getthumbnailattachment(m_pHandle, &hAttachment)); + + if (hAttachment) { + return std::make_shared(m_pWrapper, hAttachment); + } else { + return nullptr; + } + } + + /** + * CObject::ClearThumbnailAttachment - Clears the attachment. The attachment instance is not removed from the package. + */ + void CObject::ClearThumbnailAttachment() + { + CheckError(lib3mf_object_clearthumbnailattachment(m_pHandle)); + } + + /** + * CObject::GetOutbox - Returns the outbox of a build item + * @return Outbox of this build item + */ + sBox CObject::GetOutbox() + { + sBox resultOutbox; + CheckError(lib3mf_object_getoutbox(m_pHandle, &resultOutbox)); + + return resultOutbox; + } + + /** + * CObject::GetUUID - Retrieves an object's uuid string (see production extension specification) + * @param[out] bHasUUID - flag whether the build item has a UUID + * @return returns object uuid. + */ + std::string CObject::GetUUID(bool & bHasUUID) + { + Lib3MF_uint32 bytesNeededUUID = 0; + Lib3MF_uint32 bytesWrittenUUID = 0; + CheckError(lib3mf_object_getuuid(m_pHandle, &bHasUUID, 0, &bytesNeededUUID, nullptr)); + std::vector bufferUUID(bytesNeededUUID); + CheckError(lib3mf_object_getuuid(m_pHandle, &bHasUUID, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); + + return std::string(&bufferUUID[0]); + } + + /** + * CObject::SetUUID - Sets a build object's uuid string (see production extension specification) + * @param[in] sUUID - new object uuid string. + */ + void CObject::SetUUID(const std::string & sUUID) + { + CheckError(lib3mf_object_setuuid(m_pHandle, sUUID.c_str())); + } + + /** + * CObject::GetMetaDataGroup - Returns the metadatagroup of this object + * @return returns an Instance of the metadatagroup of this object + */ + PMetaDataGroup CObject::GetMetaDataGroup() + { + Lib3MFHandle hMetaDataGroup = nullptr; + CheckError(lib3mf_object_getmetadatagroup(m_pHandle, &hMetaDataGroup)); + + if (!hMetaDataGroup) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMetaDataGroup); + } + + /** + * CObject::SetSlicesMeshResolution - set the meshresolution of the mesh object + * @param[in] eMeshResolution - meshresolution of this object + */ + void CObject::SetSlicesMeshResolution(const eSlicesMeshResolution eMeshResolution) + { + CheckError(lib3mf_object_setslicesmeshresolution(m_pHandle, eMeshResolution)); + } + + /** + * CObject::GetSlicesMeshResolution - get the meshresolution of the mesh object + * @return meshresolution of this object + */ + eSlicesMeshResolution CObject::GetSlicesMeshResolution() + { + eSlicesMeshResolution resultMeshResolution = (eSlicesMeshResolution) 0; + CheckError(lib3mf_object_getslicesmeshresolution(m_pHandle, &resultMeshResolution)); + + return resultMeshResolution; + } + + /** + * CObject::HasSlices - returns whether the Object has a slice stack. If Recursive is true, also checks whether any references object has a slice stack + * @param[in] bRecursive - check also all referenced objects? + * @return does the object have a slice stack? + */ + bool CObject::HasSlices(const bool bRecursive) + { + bool resultHasSlices = 0; + CheckError(lib3mf_object_hasslices(m_pHandle, bRecursive, &resultHasSlices)); + + return resultHasSlices; + } + + /** + * CObject::ClearSliceStack - unlinks the attached slicestack from this object. If no slice stack is attached, do noting. + */ + void CObject::ClearSliceStack() + { + CheckError(lib3mf_object_clearslicestack(m_pHandle)); + } + + /** + * CObject::GetSliceStack - get the Slicestack attached to the object + * @return returns the slicestack instance + */ + PSliceStack CObject::GetSliceStack() + { + Lib3MFHandle hSliceStackInstance = nullptr; + CheckError(lib3mf_object_getslicestack(m_pHandle, &hSliceStackInstance)); + + if (!hSliceStackInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hSliceStackInstance); + } + + /** + * CObject::AssignSliceStack - assigns a slicestack to the object + * @param[in] pSliceStackInstance - the new slice stack of this Object + */ + void CObject::AssignSliceStack(CSliceStack * pSliceStackInstance) + { + Lib3MFHandle hSliceStackInstance = nullptr; + if (pSliceStackInstance != nullptr) { + hSliceStackInstance = pSliceStackInstance->GetHandle(); + }; + CheckError(lib3mf_object_assignslicestack(m_pHandle, hSliceStackInstance)); + } + + /** + * Method definitions for class CMeshObject + */ + + /** + * CMeshObject::GetVertexCount - Returns the vertex count of a mesh object. + * @return filled with the vertex count. + */ + Lib3MF_uint32 CMeshObject::GetVertexCount() + { + Lib3MF_uint32 resultVertexCount = 0; + CheckError(lib3mf_meshobject_getvertexcount(m_pHandle, &resultVertexCount)); + + return resultVertexCount; + } + + /** + * CMeshObject::GetTriangleCount - Returns the triangle count of a mesh object. + * @return filled with the triangle count. + */ + Lib3MF_uint32 CMeshObject::GetTriangleCount() + { + Lib3MF_uint32 resultVertexCount = 0; + CheckError(lib3mf_meshobject_gettrianglecount(m_pHandle, &resultVertexCount)); + + return resultVertexCount; + } + + /** + * CMeshObject::GetVertex - Returns the vertex count of a mesh object. + * @param[in] nIndex - Index of the vertex (0 to vertexcount - 1) + * @return filled with the vertex coordinates. + */ + sPosition CMeshObject::GetVertex(const Lib3MF_uint32 nIndex) + { + sPosition resultCoordinates; + CheckError(lib3mf_meshobject_getvertex(m_pHandle, nIndex, &resultCoordinates)); + + return resultCoordinates; + } + + /** + * CMeshObject::SetVertex - Sets the coordinates of a single vertex of a mesh object + * @param[in] nIndex - Index of the vertex (0 to vertexcount - 1) + * @param[in] Coordinates - contains the vertex coordinates. + */ + void CMeshObject::SetVertex(const Lib3MF_uint32 nIndex, const sPosition & Coordinates) + { + CheckError(lib3mf_meshobject_setvertex(m_pHandle, nIndex, &Coordinates)); + } + + /** + * CMeshObject::AddVertex - Adds a single vertex to a mesh object + * @param[in] Coordinates - contains the vertex coordinates. + * @return Index of the new vertex + */ + Lib3MF_uint32 CMeshObject::AddVertex(const sPosition & Coordinates) + { + Lib3MF_uint32 resultNewIndex = 0; + CheckError(lib3mf_meshobject_addvertex(m_pHandle, &Coordinates, &resultNewIndex)); + + return resultNewIndex; + } + + /** + * CMeshObject::GetVertices - Obtains all vertex positions of a mesh object + * @param[out] VerticesBuffer - contains the vertex coordinates. + */ + void CMeshObject::GetVertices(std::vector & VerticesBuffer) + { + Lib3MF_uint64 elementsNeededVertices = 0; + Lib3MF_uint64 elementsWrittenVertices = 0; + CheckError(lib3mf_meshobject_getvertices(m_pHandle, 0, &elementsNeededVertices, nullptr)); + VerticesBuffer.resize((size_t) elementsNeededVertices); + CheckError(lib3mf_meshobject_getvertices(m_pHandle, elementsNeededVertices, &elementsWrittenVertices, VerticesBuffer.data())); + } + + /** + * CMeshObject::GetTriangle - Returns indices of a single triangle of a mesh object. + * @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) + * @return filled with the triangle indices. + */ + sTriangle CMeshObject::GetTriangle(const Lib3MF_uint32 nIndex) + { + sTriangle resultIndices; + CheckError(lib3mf_meshobject_gettriangle(m_pHandle, nIndex, &resultIndices)); + + return resultIndices; + } + + /** + * CMeshObject::SetTriangle - Sets the indices of a single triangle of a mesh object. + * @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) + * @param[in] Indices - contains the triangle indices. + */ + void CMeshObject::SetTriangle(const Lib3MF_uint32 nIndex, const sTriangle & Indices) + { + CheckError(lib3mf_meshobject_settriangle(m_pHandle, nIndex, &Indices)); + } + + /** + * CMeshObject::AddTriangle - Adds a single triangle to a mesh object + * @param[in] Indices - contains the triangle indices. + * @return Index of the new triangle + */ + Lib3MF_uint32 CMeshObject::AddTriangle(const sTriangle & Indices) + { + Lib3MF_uint32 resultNewIndex = 0; + CheckError(lib3mf_meshobject_addtriangle(m_pHandle, &Indices, &resultNewIndex)); + + return resultNewIndex; + } + + /** + * CMeshObject::GetTriangleIndices - Get all triangles of a mesh object + * @param[out] IndicesBuffer - contains the triangle indices. + */ + void CMeshObject::GetTriangleIndices(std::vector & IndicesBuffer) + { + Lib3MF_uint64 elementsNeededIndices = 0; + Lib3MF_uint64 elementsWrittenIndices = 0; + CheckError(lib3mf_meshobject_gettriangleindices(m_pHandle, 0, &elementsNeededIndices, nullptr)); + IndicesBuffer.resize((size_t) elementsNeededIndices); + CheckError(lib3mf_meshobject_gettriangleindices(m_pHandle, elementsNeededIndices, &elementsWrittenIndices, IndicesBuffer.data())); + } + + /** + * CMeshObject::SetObjectLevelProperty - Sets the property at the object-level of the mesh object. + * @param[in] nUniqueResourceID - the object-level Property UniqueResourceID. + * @param[in] nPropertyID - the object-level PropertyID. + */ + void CMeshObject::SetObjectLevelProperty(const Lib3MF_uint32 nUniqueResourceID, const Lib3MF_uint32 nPropertyID) + { + CheckError(lib3mf_meshobject_setobjectlevelproperty(m_pHandle, nUniqueResourceID, nPropertyID)); + } + + /** + * CMeshObject::GetObjectLevelProperty - Gets the property at the object-level of the mesh object. + * @param[out] nUniqueResourceID - the object-level Property UniqueResourceID. + * @param[out] nPropertyID - the object-level PropertyID. + * @return Has an object-level property been specified? + */ + bool CMeshObject::GetObjectLevelProperty(Lib3MF_uint32 & nUniqueResourceID, Lib3MF_uint32 & nPropertyID) + { + bool resultHasObjectLevelProperty = 0; + CheckError(lib3mf_meshobject_getobjectlevelproperty(m_pHandle, &nUniqueResourceID, &nPropertyID, &resultHasObjectLevelProperty)); + + return resultHasObjectLevelProperty; + } + + /** + * CMeshObject::SetTriangleProperties - Sets the properties of a single triangle of a mesh object. + * @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) + * @param[in] Properties - contains the triangle properties. + */ + void CMeshObject::SetTriangleProperties(const Lib3MF_uint32 nIndex, const sTriangleProperties & Properties) + { + CheckError(lib3mf_meshobject_settriangleproperties(m_pHandle, nIndex, &Properties)); + } + + /** + * CMeshObject::GetTriangleProperties - Gets the properties of a single triangle of a mesh object. + * @param[in] nIndex - Index of the triangle (0 to trianglecount - 1) + * @param[out] Property - returns the triangle properties. + */ + void CMeshObject::GetTriangleProperties(const Lib3MF_uint32 nIndex, sTriangleProperties & Property) + { + CheckError(lib3mf_meshobject_gettriangleproperties(m_pHandle, nIndex, &Property)); + } + + /** + * CMeshObject::SetAllTriangleProperties - Sets the properties of all triangles of a mesh object. Sets the object level property to the first entry of the passed triangle properties, if not yet specified. + * @param[in] PropertiesArrayBuffer - contains the triangle properties array. Must have trianglecount elements. + */ + void CMeshObject::SetAllTriangleProperties(const CInputVector & PropertiesArrayBuffer) + { + CheckError(lib3mf_meshobject_setalltriangleproperties(m_pHandle, (Lib3MF_uint64)PropertiesArrayBuffer.size(), PropertiesArrayBuffer.data())); + } + + /** + * CMeshObject::GetAllTriangleProperties - Gets the properties of all triangles of a mesh object. + * @param[out] PropertiesArrayBuffer - returns the triangle properties array. Must have trianglecount elements. + */ + void CMeshObject::GetAllTriangleProperties(std::vector & PropertiesArrayBuffer) + { + Lib3MF_uint64 elementsNeededPropertiesArray = 0; + Lib3MF_uint64 elementsWrittenPropertiesArray = 0; + CheckError(lib3mf_meshobject_getalltriangleproperties(m_pHandle, 0, &elementsNeededPropertiesArray, nullptr)); + PropertiesArrayBuffer.resize((size_t) elementsNeededPropertiesArray); + CheckError(lib3mf_meshobject_getalltriangleproperties(m_pHandle, elementsNeededPropertiesArray, &elementsWrittenPropertiesArray, PropertiesArrayBuffer.data())); + } + + /** + * CMeshObject::ClearAllProperties - Clears all properties of this mesh object (triangle and object-level). + */ + void CMeshObject::ClearAllProperties() + { + CheckError(lib3mf_meshobject_clearallproperties(m_pHandle)); + } + + /** + * CMeshObject::SetGeometry - Set all triangles of a mesh object + * @param[in] VerticesBuffer - contains the positions. + * @param[in] IndicesBuffer - contains the triangle indices. + */ + void CMeshObject::SetGeometry(const CInputVector & VerticesBuffer, const CInputVector & IndicesBuffer) + { + CheckError(lib3mf_meshobject_setgeometry(m_pHandle, (Lib3MF_uint64)VerticesBuffer.size(), VerticesBuffer.data(), (Lib3MF_uint64)IndicesBuffer.size(), IndicesBuffer.data())); + } + + /** + * CMeshObject::IsManifoldAndOriented - Retrieves, if an object describes a topologically oriented and manifold mesh, according to the core spec. + * @return returns, if the object is oriented and manifold. + */ + bool CMeshObject::IsManifoldAndOriented() + { + bool resultIsManifoldAndOriented = 0; + CheckError(lib3mf_meshobject_ismanifoldandoriented(m_pHandle, &resultIsManifoldAndOriented)); + + return resultIsManifoldAndOriented; + } + + /** + * CMeshObject::BeamLattice - Retrieves the BeamLattice within this MeshObject. + * @return the BeamLattice within this MeshObject + */ + PBeamLattice CMeshObject::BeamLattice() + { + Lib3MFHandle hTheBeamLattice = nullptr; + CheckError(lib3mf_meshobject_beamlattice(m_pHandle, &hTheBeamLattice)); + + if (!hTheBeamLattice) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTheBeamLattice); + } + + /** + * Method definitions for class CBeamLattice + */ + + /** + * CBeamLattice::GetMinLength - Returns the minimal length of beams for the beamlattice. + * @return minimal length of beams for the beamlattice + */ + Lib3MF_double CBeamLattice::GetMinLength() + { + Lib3MF_double resultMinLength = 0; + CheckError(lib3mf_beamlattice_getminlength(m_pHandle, &resultMinLength)); + + return resultMinLength; + } + + /** + * CBeamLattice::SetMinLength - Sets the minimal length of beams for the beamlattice. + * @param[in] dMinLength - minimal length of beams for the beamlattice + */ + void CBeamLattice::SetMinLength(const Lib3MF_double dMinLength) + { + CheckError(lib3mf_beamlattice_setminlength(m_pHandle, dMinLength)); + } + + /** + * CBeamLattice::GetClipping - Returns the clipping mode and the clipping-mesh for the beamlattice of this mesh. + * @param[out] eClipMode - contains the clip mode of this mesh + * @param[out] nUniqueResourceID - filled with the UniqueResourceID of the clipping mesh-object or an undefined value if pClipMode is MODELBEAMLATTICECLIPMODE_NONE + */ + void CBeamLattice::GetClipping(eBeamLatticeClipMode & eClipMode, Lib3MF_uint32 & nUniqueResourceID) + { + CheckError(lib3mf_beamlattice_getclipping(m_pHandle, &eClipMode, &nUniqueResourceID)); + } + + /** + * CBeamLattice::SetClipping - Sets the clipping mode and the clipping-mesh for the beamlattice of this mesh. + * @param[in] eClipMode - contains the clip mode of this mesh + * @param[in] nUniqueResourceID - the UniqueResourceID of the clipping mesh-object. This mesh-object has to be defined before setting the Clipping. + */ + void CBeamLattice::SetClipping(const eBeamLatticeClipMode eClipMode, const Lib3MF_uint32 nUniqueResourceID) + { + CheckError(lib3mf_beamlattice_setclipping(m_pHandle, eClipMode, nUniqueResourceID)); + } + + /** + * CBeamLattice::GetRepresentation - Returns the representation-mesh for the beamlattice of this mesh. + * @return flag whether the beamlattice has a representation mesh. + * @param[out] nUniqueResourceID - filled with the UniqueResourceID of the clipping mesh-object. + */ + bool CBeamLattice::GetRepresentation(Lib3MF_uint32 & nUniqueResourceID) + { + bool resultHasRepresentation = 0; + CheckError(lib3mf_beamlattice_getrepresentation(m_pHandle, &resultHasRepresentation, &nUniqueResourceID)); + + return resultHasRepresentation; + } + + /** + * CBeamLattice::SetRepresentation - Sets the representation-mesh for the beamlattice of this mesh. + * @param[in] nUniqueResourceID - the UniqueResourceID of the representation mesh-object. This mesh-object has to be defined before setting the representation. + */ + void CBeamLattice::SetRepresentation(const Lib3MF_uint32 nUniqueResourceID) + { + CheckError(lib3mf_beamlattice_setrepresentation(m_pHandle, nUniqueResourceID)); + } + + /** + * CBeamLattice::GetBallOptions - Returns the ball mode and the default ball radius for the beamlattice of this mesh. + * @param[out] eBallMode - contains the ball mode of this mesh + * @param[out] dBallRadius - default ball radius of balls for the beamlattice + */ + void CBeamLattice::GetBallOptions(eBeamLatticeBallMode & eBallMode, Lib3MF_double & dBallRadius) + { + CheckError(lib3mf_beamlattice_getballoptions(m_pHandle, &eBallMode, &dBallRadius)); + } + + /** + * CBeamLattice::SetBallOptions - Sets the ball mode and thedefault ball radius for the beamlattice. + * @param[in] eBallMode - contains the ball mode of this mesh + * @param[in] dBallRadius - default ball radius of balls for the beamlattice + */ + void CBeamLattice::SetBallOptions(const eBeamLatticeBallMode eBallMode, const Lib3MF_double dBallRadius) + { + CheckError(lib3mf_beamlattice_setballoptions(m_pHandle, eBallMode, dBallRadius)); + } + + /** + * CBeamLattice::GetBeamCount - Returns the beam count of a mesh object. + * @return filled with the beam count. + */ + Lib3MF_uint32 CBeamLattice::GetBeamCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_beamlattice_getbeamcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CBeamLattice::GetBeam - Returns indices, radii and capmodes of a single beam of a mesh object. + * @param[in] nIndex - Index of the beam (0 to beamcount - 1). + * @return filled with the beam indices, radii and capmodes. + */ + sBeam CBeamLattice::GetBeam(const Lib3MF_uint32 nIndex) + { + sBeam resultBeamInfo; + CheckError(lib3mf_beamlattice_getbeam(m_pHandle, nIndex, &resultBeamInfo)); + + return resultBeamInfo; + } + + /** + * CBeamLattice::AddBeam - Adds a single beam to a mesh object. + * @param[in] BeamInfo - contains the node indices, radii and capmodes. + * @return filled with the new Index of the beam. + */ + Lib3MF_uint32 CBeamLattice::AddBeam(const sBeam & BeamInfo) + { + Lib3MF_uint32 resultIndex = 0; + CheckError(lib3mf_beamlattice_addbeam(m_pHandle, &BeamInfo, &resultIndex)); + + return resultIndex; + } + + /** + * CBeamLattice::SetBeam - Sets the indices, radii and capmodes of a single beam of a mesh object. + * @param[in] nIndex - Index of the beam (0 to beamcount - 1). + * @param[in] BeamInfo - filled with the beam indices, radii and capmodes. + */ + void CBeamLattice::SetBeam(const Lib3MF_uint32 nIndex, const sBeam & BeamInfo) + { + CheckError(lib3mf_beamlattice_setbeam(m_pHandle, nIndex, &BeamInfo)); + } + + /** + * CBeamLattice::SetBeams - Sets all beam indices, radii and capmodes of a mesh object. + * @param[in] BeamInfoBuffer - contains information of a number of beams + */ + void CBeamLattice::SetBeams(const CInputVector & BeamInfoBuffer) + { + CheckError(lib3mf_beamlattice_setbeams(m_pHandle, (Lib3MF_uint64)BeamInfoBuffer.size(), BeamInfoBuffer.data())); + } + + /** + * CBeamLattice::GetBeams - obtains all beam indices, radii and capmodes of a mesh object. + * @param[out] BeamInfoBuffer - contains information of all beams + */ + void CBeamLattice::GetBeams(std::vector & BeamInfoBuffer) + { + Lib3MF_uint64 elementsNeededBeamInfo = 0; + Lib3MF_uint64 elementsWrittenBeamInfo = 0; + CheckError(lib3mf_beamlattice_getbeams(m_pHandle, 0, &elementsNeededBeamInfo, nullptr)); + BeamInfoBuffer.resize((size_t) elementsNeededBeamInfo); + CheckError(lib3mf_beamlattice_getbeams(m_pHandle, elementsNeededBeamInfo, &elementsWrittenBeamInfo, BeamInfoBuffer.data())); + } + + /** + * CBeamLattice::GetBallCount - Returns the ball count of a mesh object. + * @return filled with the ball count. + */ + Lib3MF_uint32 CBeamLattice::GetBallCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_beamlattice_getballcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CBeamLattice::GetBall - Returns index and radius of a single ball of a mesh object. + * @param[in] nIndex - Index of the ball (0 to ballcount - 1). + * @return filled with the ball node index and radius. + */ + sBall CBeamLattice::GetBall(const Lib3MF_uint32 nIndex) + { + sBall resultBallInfo; + CheckError(lib3mf_beamlattice_getball(m_pHandle, nIndex, &resultBallInfo)); + + return resultBallInfo; + } + + /** + * CBeamLattice::AddBall - Adds a single ball to a mesh object. + * @param[in] BallInfo - contains the node index and radius. + * @return filled with the new Index of the ball. + */ + Lib3MF_uint32 CBeamLattice::AddBall(const sBall & BallInfo) + { + Lib3MF_uint32 resultIndex = 0; + CheckError(lib3mf_beamlattice_addball(m_pHandle, &BallInfo, &resultIndex)); + + return resultIndex; + } + + /** + * CBeamLattice::SetBall - Sets the index and radius of a single ball of a mesh object. + * @param[in] nIndex - Index of the ball (0 to ballcount - 1). + * @param[in] BallInfo - filled with the ball node index and radius. + */ + void CBeamLattice::SetBall(const Lib3MF_uint32 nIndex, const sBall & BallInfo) + { + CheckError(lib3mf_beamlattice_setball(m_pHandle, nIndex, &BallInfo)); + } + + /** + * CBeamLattice::SetBalls - Sets all ball indices and radii of a mesh object. + * @param[in] BallInfoBuffer - contains information of a number of balls + */ + void CBeamLattice::SetBalls(const CInputVector & BallInfoBuffer) + { + CheckError(lib3mf_beamlattice_setballs(m_pHandle, (Lib3MF_uint64)BallInfoBuffer.size(), BallInfoBuffer.data())); + } + + /** + * CBeamLattice::GetBalls - obtains all ball indices and radii of a mesh object. + * @param[out] BallInfoBuffer - contains information of all balls + */ + void CBeamLattice::GetBalls(std::vector & BallInfoBuffer) + { + Lib3MF_uint64 elementsNeededBallInfo = 0; + Lib3MF_uint64 elementsWrittenBallInfo = 0; + CheckError(lib3mf_beamlattice_getballs(m_pHandle, 0, &elementsNeededBallInfo, nullptr)); + BallInfoBuffer.resize((size_t) elementsNeededBallInfo); + CheckError(lib3mf_beamlattice_getballs(m_pHandle, elementsNeededBallInfo, &elementsWrittenBallInfo, BallInfoBuffer.data())); + } + + /** + * CBeamLattice::GetBeamSetCount - Returns the number of beamsets of a mesh object. + * @return filled with the beamset count. + */ + Lib3MF_uint32 CBeamLattice::GetBeamSetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_beamlattice_getbeamsetcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CBeamLattice::AddBeamSet - Adds an empty beamset to a mesh object + * @return the new beamset + */ + PBeamSet CBeamLattice::AddBeamSet() + { + Lib3MFHandle hBeamSet = nullptr; + CheckError(lib3mf_beamlattice_addbeamset(m_pHandle, &hBeamSet)); + + if (!hBeamSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBeamSet); + } + + /** + * CBeamLattice::GetBeamSet - Returns a beamset of a mesh object + * @param[in] nIndex - index of the requested beamset (0 ... beamsetcount-1). + * @return the requested beamset + */ + PBeamSet CBeamLattice::GetBeamSet(const Lib3MF_uint32 nIndex) + { + Lib3MFHandle hBeamSet = nullptr; + CheckError(lib3mf_beamlattice_getbeamset(m_pHandle, nIndex, &hBeamSet)); + + if (!hBeamSet) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBeamSet); + } + + /** + * Method definitions for class CComponent + */ + + /** + * CComponent::GetObjectResource - Returns the Resource Instance of the component. + * @return filled with the Resource Instance. + */ + PObject CComponent::GetObjectResource() + { + Lib3MFHandle hObjectResource = nullptr; + CheckError(lib3mf_component_getobjectresource(m_pHandle, &hObjectResource)); + + if (!hObjectResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hObjectResource); + } + + /** + * CComponent::GetObjectResourceID - Returns the UniqueResourceID of the component. + * @return returns the UniqueResourceID. + */ + Lib3MF_uint32 CComponent::GetObjectResourceID() + { + Lib3MF_uint32 resultUniqueResourceID = 0; + CheckError(lib3mf_component_getobjectresourceid(m_pHandle, &resultUniqueResourceID)); + + return resultUniqueResourceID; + } + + /** + * CComponent::GetUUID - returns, whether a component has a UUID and, if true, the component's UUID + * @param[out] bHasUUID - flag whether the component has a UUID + * @return the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' + */ + std::string CComponent::GetUUID(bool & bHasUUID) + { + Lib3MF_uint32 bytesNeededUUID = 0; + Lib3MF_uint32 bytesWrittenUUID = 0; + CheckError(lib3mf_component_getuuid(m_pHandle, &bHasUUID, 0, &bytesNeededUUID, nullptr)); + std::vector bufferUUID(bytesNeededUUID); + CheckError(lib3mf_component_getuuid(m_pHandle, &bHasUUID, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); + + return std::string(&bufferUUID[0]); + } + + /** + * CComponent::SetUUID - sets the component's UUID + * @param[in] sUUID - the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' + */ + void CComponent::SetUUID(const std::string & sUUID) + { + CheckError(lib3mf_component_setuuid(m_pHandle, sUUID.c_str())); + } + + /** + * CComponent::HasTransform - Returns, if the component has a different transformation than the identity matrix + * @return if true is returned, the transformation is not equal than the identity + */ + bool CComponent::HasTransform() + { + bool resultHasTransform = 0; + CheckError(lib3mf_component_hastransform(m_pHandle, &resultHasTransform)); + + return resultHasTransform; + } + + /** + * CComponent::GetTransform - Returns the transformation matrix of the component. + * @return filled with the component transformation matrix + */ + sTransform CComponent::GetTransform() + { + sTransform resultTransform; + CheckError(lib3mf_component_gettransform(m_pHandle, &resultTransform)); + + return resultTransform; + } + + /** + * CComponent::SetTransform - Sets the transformation matrix of the component. + * @param[in] Transform - new transformation matrix + */ + void CComponent::SetTransform(const sTransform & Transform) + { + CheckError(lib3mf_component_settransform(m_pHandle, &Transform)); + } + + /** + * Method definitions for class CComponentsObject + */ + + /** + * CComponentsObject::AddComponent - Adds a new component to a components object. + * @param[in] pObjectResource - object to add as component. Must not lead to circular references! + * @param[in] Transform - optional transform matrix for the component. + * @return new component instance + */ + PComponent CComponentsObject::AddComponent(CObject * pObjectResource, const sTransform & Transform) + { + Lib3MFHandle hObjectResource = nullptr; + if (pObjectResource != nullptr) { + hObjectResource = pObjectResource->GetHandle(); + }; + Lib3MFHandle hComponentInstance = nullptr; + CheckError(lib3mf_componentsobject_addcomponent(m_pHandle, hObjectResource, &Transform, &hComponentInstance)); + + if (!hComponentInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hComponentInstance); + } + + /** + * CComponentsObject::GetComponent - Retrieves a component from a component object. + * @param[in] nIndex - index of the component to retrieve (0 to componentcount - 1) + * @return component instance + */ + PComponent CComponentsObject::GetComponent(const Lib3MF_uint32 nIndex) + { + Lib3MFHandle hComponentInstance = nullptr; + CheckError(lib3mf_componentsobject_getcomponent(m_pHandle, nIndex, &hComponentInstance)); + + if (!hComponentInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hComponentInstance); + } + + /** + * CComponentsObject::GetComponentCount - Retrieves a component count of a component object. + * @return returns the component count + */ + Lib3MF_uint32 CComponentsObject::GetComponentCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_componentsobject_getcomponentcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * Method definitions for class CBeamSet + */ + + /** + * CBeamSet::SetName - Sets a beamset's name string + * @param[in] sName - new name of the beamset. + */ + void CBeamSet::SetName(const std::string & sName) + { + CheckError(lib3mf_beamset_setname(m_pHandle, sName.c_str())); + } + + /** + * CBeamSet::GetName - Retrieves a beamset's name string + * @return returns the name of the beamset. + */ + std::string CBeamSet::GetName() + { + Lib3MF_uint32 bytesNeededName = 0; + Lib3MF_uint32 bytesWrittenName = 0; + CheckError(lib3mf_beamset_getname(m_pHandle, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(lib3mf_beamset_getname(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CBeamSet::SetIdentifier - Sets a beamset's identifier string + * @param[in] sIdentifier - new name of the beamset. + */ + void CBeamSet::SetIdentifier(const std::string & sIdentifier) + { + CheckError(lib3mf_beamset_setidentifier(m_pHandle, sIdentifier.c_str())); + } + + /** + * CBeamSet::GetIdentifier - Retrieves a beamset's identifier string + * @return returns the identifier of the beamset. + */ + std::string CBeamSet::GetIdentifier() + { + Lib3MF_uint32 bytesNeededIdentifier = 0; + Lib3MF_uint32 bytesWrittenIdentifier = 0; + CheckError(lib3mf_beamset_getidentifier(m_pHandle, 0, &bytesNeededIdentifier, nullptr)); + std::vector bufferIdentifier(bytesNeededIdentifier); + CheckError(lib3mf_beamset_getidentifier(m_pHandle, bytesNeededIdentifier, &bytesWrittenIdentifier, &bufferIdentifier[0])); + + return std::string(&bufferIdentifier[0]); + } + + /** + * CBeamSet::GetReferenceCount - Retrieves the reference count of a beamset + * @return returns the reference count + */ + Lib3MF_uint32 CBeamSet::GetReferenceCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_beamset_getreferencecount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CBeamSet::SetReferences - Sets the references of a beamset + * @param[in] ReferencesBuffer - the new indices of all beams in this beamset + */ + void CBeamSet::SetReferences(const CInputVector & ReferencesBuffer) + { + CheckError(lib3mf_beamset_setreferences(m_pHandle, (Lib3MF_uint64)ReferencesBuffer.size(), ReferencesBuffer.data())); + } + + /** + * CBeamSet::GetReferences - Retrieves the references of a beamset + * @param[out] ReferencesBuffer - retrieves the indices of all beams in this beamset + */ + void CBeamSet::GetReferences(std::vector & ReferencesBuffer) + { + Lib3MF_uint64 elementsNeededReferences = 0; + Lib3MF_uint64 elementsWrittenReferences = 0; + CheckError(lib3mf_beamset_getreferences(m_pHandle, 0, &elementsNeededReferences, nullptr)); + ReferencesBuffer.resize((size_t) elementsNeededReferences); + CheckError(lib3mf_beamset_getreferences(m_pHandle, elementsNeededReferences, &elementsWrittenReferences, ReferencesBuffer.data())); + } + + /** + * CBeamSet::GetBallReferenceCount - Retrieves the ball reference count of a beamset + * @return returns the ball reference count + */ + Lib3MF_uint32 CBeamSet::GetBallReferenceCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_beamset_getballreferencecount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CBeamSet::SetBallReferences - Sets the ball references of a beamset + * @param[in] BallReferencesBuffer - the new indices of all balls in this beamset + */ + void CBeamSet::SetBallReferences(const CInputVector & BallReferencesBuffer) + { + CheckError(lib3mf_beamset_setballreferences(m_pHandle, (Lib3MF_uint64)BallReferencesBuffer.size(), BallReferencesBuffer.data())); + } + + /** + * CBeamSet::GetBallReferences - Retrieves the ball references of a beamset + * @param[out] BallReferencesBuffer - retrieves the indices of all balls in this beamset + */ + void CBeamSet::GetBallReferences(std::vector & BallReferencesBuffer) + { + Lib3MF_uint64 elementsNeededBallReferences = 0; + Lib3MF_uint64 elementsWrittenBallReferences = 0; + CheckError(lib3mf_beamset_getballreferences(m_pHandle, 0, &elementsNeededBallReferences, nullptr)); + BallReferencesBuffer.resize((size_t) elementsNeededBallReferences); + CheckError(lib3mf_beamset_getballreferences(m_pHandle, elementsNeededBallReferences, &elementsWrittenBallReferences, BallReferencesBuffer.data())); + } + + /** + * Method definitions for class CBaseMaterialGroup + */ + + /** + * CBaseMaterialGroup::GetCount - Retrieves the count of base materials in the material group. + * @return returns the count of base materials. + */ + Lib3MF_uint32 CBaseMaterialGroup::GetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_basematerialgroup_getcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CBaseMaterialGroup::GetAllPropertyIDs - returns all the PropertyIDs of all materials in this group + * @param[out] PropertyIDsBuffer - PropertyID of the material in the material group. + */ + void CBaseMaterialGroup::GetAllPropertyIDs(std::vector & PropertyIDsBuffer) + { + Lib3MF_uint64 elementsNeededPropertyIDs = 0; + Lib3MF_uint64 elementsWrittenPropertyIDs = 0; + CheckError(lib3mf_basematerialgroup_getallpropertyids(m_pHandle, 0, &elementsNeededPropertyIDs, nullptr)); + PropertyIDsBuffer.resize((size_t) elementsNeededPropertyIDs); + CheckError(lib3mf_basematerialgroup_getallpropertyids(m_pHandle, elementsNeededPropertyIDs, &elementsWrittenPropertyIDs, PropertyIDsBuffer.data())); + } + + /** + * CBaseMaterialGroup::AddMaterial - Adds a new material to the material group + * @param[in] sName - new name of the base material. + * @param[in] DisplayColor - Display color of the material + * @return returns new PropertyID of the new material in the material group. + */ + Lib3MF_uint32 CBaseMaterialGroup::AddMaterial(const std::string & sName, const sColor & DisplayColor) + { + Lib3MF_uint32 resultPropertyID = 0; + CheckError(lib3mf_basematerialgroup_addmaterial(m_pHandle, sName.c_str(), &DisplayColor, &resultPropertyID)); + + return resultPropertyID; + } + + /** + * CBaseMaterialGroup::RemoveMaterial - Removes a material from the material group. + * @param[in] nPropertyID - PropertyID of the material in the material group. + */ + void CBaseMaterialGroup::RemoveMaterial(const Lib3MF_uint32 nPropertyID) + { + CheckError(lib3mf_basematerialgroup_removematerial(m_pHandle, nPropertyID)); + } + + /** + * CBaseMaterialGroup::GetName - Returns the base material's name + * @param[in] nPropertyID - PropertyID of the material in the material group. + * @return returns the name of the base material. + */ + std::string CBaseMaterialGroup::GetName(const Lib3MF_uint32 nPropertyID) + { + Lib3MF_uint32 bytesNeededName = 0; + Lib3MF_uint32 bytesWrittenName = 0; + CheckError(lib3mf_basematerialgroup_getname(m_pHandle, nPropertyID, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(lib3mf_basematerialgroup_getname(m_pHandle, nPropertyID, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CBaseMaterialGroup::SetName - Sets a base material's name + * @param[in] nPropertyID - PropertyID of the material in the material group. + * @param[in] sName - new name of the base material. + */ + void CBaseMaterialGroup::SetName(const Lib3MF_uint32 nPropertyID, const std::string & sName) + { + CheckError(lib3mf_basematerialgroup_setname(m_pHandle, nPropertyID, sName.c_str())); + } + + /** + * CBaseMaterialGroup::SetDisplayColor - Sets a base material's display color. + * @param[in] nPropertyID - PropertyID of the material in the material group. + * @param[in] TheColor - The base material's display color + */ + void CBaseMaterialGroup::SetDisplayColor(const Lib3MF_uint32 nPropertyID, const sColor & TheColor) + { + CheckError(lib3mf_basematerialgroup_setdisplaycolor(m_pHandle, nPropertyID, &TheColor)); + } + + /** + * CBaseMaterialGroup::GetDisplayColor - Returns a base material's display color. + * @param[in] nPropertyID - PropertyID of the material in the material group. + * @return The base material's display color + */ + sColor CBaseMaterialGroup::GetDisplayColor(const Lib3MF_uint32 nPropertyID) + { + sColor resultTheColor; + CheckError(lib3mf_basematerialgroup_getdisplaycolor(m_pHandle, nPropertyID, &resultTheColor)); + + return resultTheColor; + } + + /** + * Method definitions for class CColorGroup + */ + + /** + * CColorGroup::GetCount - Retrieves the count of base materials in this Color Group. + * @return returns the count of colors within this color group. + */ + Lib3MF_uint32 CColorGroup::GetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_colorgroup_getcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CColorGroup::GetAllPropertyIDs - returns all the PropertyIDs of all colors within this group + * @param[out] PropertyIDsBuffer - PropertyID of the color in the color group. + */ + void CColorGroup::GetAllPropertyIDs(std::vector & PropertyIDsBuffer) + { + Lib3MF_uint64 elementsNeededPropertyIDs = 0; + Lib3MF_uint64 elementsWrittenPropertyIDs = 0; + CheckError(lib3mf_colorgroup_getallpropertyids(m_pHandle, 0, &elementsNeededPropertyIDs, nullptr)); + PropertyIDsBuffer.resize((size_t) elementsNeededPropertyIDs); + CheckError(lib3mf_colorgroup_getallpropertyids(m_pHandle, elementsNeededPropertyIDs, &elementsWrittenPropertyIDs, PropertyIDsBuffer.data())); + } + + /** + * CColorGroup::AddColor - Adds a new value. + * @param[in] TheColor - The new color + * @return PropertyID of the new color within this color group. + */ + Lib3MF_uint32 CColorGroup::AddColor(const sColor & TheColor) + { + Lib3MF_uint32 resultPropertyID = 0; + CheckError(lib3mf_colorgroup_addcolor(m_pHandle, &TheColor, &resultPropertyID)); + + return resultPropertyID; + } + + /** + * CColorGroup::RemoveColor - Removes a color from the color group. + * @param[in] nPropertyID - PropertyID of the color to be removed from the color group. + */ + void CColorGroup::RemoveColor(const Lib3MF_uint32 nPropertyID) + { + CheckError(lib3mf_colorgroup_removecolor(m_pHandle, nPropertyID)); + } + + /** + * CColorGroup::SetColor - Sets a color value. + * @param[in] nPropertyID - PropertyID of a color within this color group. + * @param[in] TheColor - The color + */ + void CColorGroup::SetColor(const Lib3MF_uint32 nPropertyID, const sColor & TheColor) + { + CheckError(lib3mf_colorgroup_setcolor(m_pHandle, nPropertyID, &TheColor)); + } + + /** + * CColorGroup::GetColor - Sets a color value. + * @param[in] nPropertyID - PropertyID of a color within this color group. + * @return The color + */ + sColor CColorGroup::GetColor(const Lib3MF_uint32 nPropertyID) + { + sColor resultTheColor; + CheckError(lib3mf_colorgroup_getcolor(m_pHandle, nPropertyID, &resultTheColor)); + + return resultTheColor; + } + + /** + * Method definitions for class CTexture2DGroup + */ + + /** + * CTexture2DGroup::GetCount - Retrieves the count of tex2coords in the Texture2DGroup. + * @return returns the count of tex2coords. + */ + Lib3MF_uint32 CTexture2DGroup::GetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_texture2dgroup_getcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CTexture2DGroup::GetAllPropertyIDs - returns all the PropertyIDs of all tex2coords in this Texture2DGroup + * @param[out] PropertyIDsBuffer - PropertyID of the tex2coords in the Texture2DGroup. + */ + void CTexture2DGroup::GetAllPropertyIDs(std::vector & PropertyIDsBuffer) + { + Lib3MF_uint64 elementsNeededPropertyIDs = 0; + Lib3MF_uint64 elementsWrittenPropertyIDs = 0; + CheckError(lib3mf_texture2dgroup_getallpropertyids(m_pHandle, 0, &elementsNeededPropertyIDs, nullptr)); + PropertyIDsBuffer.resize((size_t) elementsNeededPropertyIDs); + CheckError(lib3mf_texture2dgroup_getallpropertyids(m_pHandle, elementsNeededPropertyIDs, &elementsWrittenPropertyIDs, PropertyIDsBuffer.data())); + } + + /** + * CTexture2DGroup::AddTex2Coord - Adds a new tex2coord to the Texture2DGroup + * @param[in] UVCoordinate - The u/v-coordinate within the texture, horizontally right/vertically up from the origin in the lower left of the texture. + * @return returns new PropertyID of the new tex2coord in the Texture2DGroup. + */ + Lib3MF_uint32 CTexture2DGroup::AddTex2Coord(const sTex2Coord & UVCoordinate) + { + Lib3MF_uint32 resultPropertyID = 0; + CheckError(lib3mf_texture2dgroup_addtex2coord(m_pHandle, &UVCoordinate, &resultPropertyID)); + + return resultPropertyID; + } + + /** + * CTexture2DGroup::GetTex2Coord - Obtains a tex2coord to the Texture2DGroup + * @param[in] nPropertyID - the PropertyID of the tex2coord in the Texture2DGroup. + * @return The u/v-coordinate within the texture, horizontally right/vertically up from the origin in the lower left of the texture. + */ + sTex2Coord CTexture2DGroup::GetTex2Coord(const Lib3MF_uint32 nPropertyID) + { + sTex2Coord resultUVCoordinate; + CheckError(lib3mf_texture2dgroup_gettex2coord(m_pHandle, nPropertyID, &resultUVCoordinate)); + + return resultUVCoordinate; + } + + /** + * CTexture2DGroup::RemoveTex2Coord - Removes a tex2coords from the Texture2DGroup. + * @param[in] nPropertyID - PropertyID of the tex2coords in the Texture2DGroup. + */ + void CTexture2DGroup::RemoveTex2Coord(const Lib3MF_uint32 nPropertyID) + { + CheckError(lib3mf_texture2dgroup_removetex2coord(m_pHandle, nPropertyID)); + } + + /** + * CTexture2DGroup::GetTexture2D - Obtains the texture2D instance of this group. + * @return the texture2D instance of this group. + */ + PTexture2D CTexture2DGroup::GetTexture2D() + { + Lib3MFHandle hTexture2DInstance = nullptr; + CheckError(lib3mf_texture2dgroup_gettexture2d(m_pHandle, &hTexture2DInstance)); + + if (!hTexture2DInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTexture2DInstance); + } + + /** + * Method definitions for class CCompositeMaterials + */ + + /** + * CCompositeMaterials::GetCount - Retrieves the count of Composite-s in the CompositeMaterials. + * @return returns the count of Composite-s + */ + Lib3MF_uint32 CCompositeMaterials::GetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_compositematerials_getcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CCompositeMaterials::GetAllPropertyIDs - returns all the PropertyIDs of all Composite-Mixing Values in this CompositeMaterials + * @param[out] PropertyIDsBuffer - PropertyID of the Composite-Mixing Values in the CompositeMaterials. + */ + void CCompositeMaterials::GetAllPropertyIDs(std::vector & PropertyIDsBuffer) + { + Lib3MF_uint64 elementsNeededPropertyIDs = 0; + Lib3MF_uint64 elementsWrittenPropertyIDs = 0; + CheckError(lib3mf_compositematerials_getallpropertyids(m_pHandle, 0, &elementsNeededPropertyIDs, nullptr)); + PropertyIDsBuffer.resize((size_t) elementsNeededPropertyIDs); + CheckError(lib3mf_compositematerials_getallpropertyids(m_pHandle, elementsNeededPropertyIDs, &elementsWrittenPropertyIDs, PropertyIDsBuffer.data())); + } + + /** + * CCompositeMaterials::GetBaseMaterialGroup - Obtains the BaseMaterialGroup instance of this CompositeMaterials. + * @return returns the BaseMaterialGroup instance of this CompositeMaterials + */ + PBaseMaterialGroup CCompositeMaterials::GetBaseMaterialGroup() + { + Lib3MFHandle hBaseMaterialGroupInstance = nullptr; + CheckError(lib3mf_compositematerials_getbasematerialgroup(m_pHandle, &hBaseMaterialGroupInstance)); + + if (!hBaseMaterialGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBaseMaterialGroupInstance); + } + + /** + * CCompositeMaterials::AddComposite - Adds a new Composite-Mixing Values to the CompositeMaterials. + * @param[in] CompositeBuffer - The Composite Constituents to be added as composite + * @return returns new PropertyID of the new Composite in the CompositeMaterials. + */ + Lib3MF_uint32 CCompositeMaterials::AddComposite(const CInputVector & CompositeBuffer) + { + Lib3MF_uint32 resultPropertyID = 0; + CheckError(lib3mf_compositematerials_addcomposite(m_pHandle, (Lib3MF_uint64)CompositeBuffer.size(), CompositeBuffer.data(), &resultPropertyID)); + + return resultPropertyID; + } + + /** + * CCompositeMaterials::RemoveComposite - Removes a Composite-Maxing Ratio from the CompositeMaterials. + * @param[in] nPropertyID - PropertyID of the Composite-Mixing Values in the CompositeMaterials to be removed. + */ + void CCompositeMaterials::RemoveComposite(const Lib3MF_uint32 nPropertyID) + { + CheckError(lib3mf_compositematerials_removecomposite(m_pHandle, nPropertyID)); + } + + /** + * CCompositeMaterials::GetComposite - Obtains a Composite-Maxing Ratio of this CompositeMaterials. + * @param[in] nPropertyID - the PropertyID of the Composite-Maxing Ratio in the CompositeMaterials. + * @param[out] CompositeBuffer - The Composite-Mixing Values with the given PropertyID + */ + void CCompositeMaterials::GetComposite(const Lib3MF_uint32 nPropertyID, std::vector & CompositeBuffer) + { + Lib3MF_uint64 elementsNeededComposite = 0; + Lib3MF_uint64 elementsWrittenComposite = 0; + CheckError(lib3mf_compositematerials_getcomposite(m_pHandle, nPropertyID, 0, &elementsNeededComposite, nullptr)); + CompositeBuffer.resize((size_t) elementsNeededComposite); + CheckError(lib3mf_compositematerials_getcomposite(m_pHandle, nPropertyID, elementsNeededComposite, &elementsWrittenComposite, CompositeBuffer.data())); + } + + /** + * Method definitions for class CMultiPropertyGroup + */ + + /** + * CMultiPropertyGroup::GetCount - Retrieves the count of MultiProperty-s in the MultiPropertyGroup. + * @return returns the count of MultiProperty-s + */ + Lib3MF_uint32 CMultiPropertyGroup::GetCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_multipropertygroup_getcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CMultiPropertyGroup::GetAllPropertyIDs - returns all the PropertyIDs of all MultiProperty-s in this MultiPropertyGroup + * @param[out] PropertyIDsBuffer - PropertyID of the MultiProperty-s in the MultiPropertyGroup. + */ + void CMultiPropertyGroup::GetAllPropertyIDs(std::vector & PropertyIDsBuffer) + { + Lib3MF_uint64 elementsNeededPropertyIDs = 0; + Lib3MF_uint64 elementsWrittenPropertyIDs = 0; + CheckError(lib3mf_multipropertygroup_getallpropertyids(m_pHandle, 0, &elementsNeededPropertyIDs, nullptr)); + PropertyIDsBuffer.resize((size_t) elementsNeededPropertyIDs); + CheckError(lib3mf_multipropertygroup_getallpropertyids(m_pHandle, elementsNeededPropertyIDs, &elementsWrittenPropertyIDs, PropertyIDsBuffer.data())); + } + + /** + * CMultiPropertyGroup::AddMultiProperty - Adds a new MultiProperty to the MultiPropertyGroup. + * @param[in] PropertyIDsBuffer - The PropertyIDs of the new MultiProperty. + * @return returns the PropertyID of the new MultiProperty in the MultiPropertyGroup. + */ + Lib3MF_uint32 CMultiPropertyGroup::AddMultiProperty(const CInputVector & PropertyIDsBuffer) + { + Lib3MF_uint32 resultPropertyID = 0; + CheckError(lib3mf_multipropertygroup_addmultiproperty(m_pHandle, (Lib3MF_uint64)PropertyIDsBuffer.size(), PropertyIDsBuffer.data(), &resultPropertyID)); + + return resultPropertyID; + } + + /** + * CMultiPropertyGroup::SetMultiProperty - Sets the PropertyIDs of a MultiProperty. + * @param[in] nPropertyID - the PropertyID of the MultiProperty to be changed. + * @param[in] PropertyIDsBuffer - The new PropertyIDs of the MultiProperty + */ + void CMultiPropertyGroup::SetMultiProperty(const Lib3MF_uint32 nPropertyID, const CInputVector & PropertyIDsBuffer) + { + CheckError(lib3mf_multipropertygroup_setmultiproperty(m_pHandle, nPropertyID, (Lib3MF_uint64)PropertyIDsBuffer.size(), PropertyIDsBuffer.data())); + } + + /** + * CMultiPropertyGroup::GetMultiProperty - Obtains the PropertyIDs of a MultiProperty. + * @param[in] nPropertyID - the PropertyID of the MultiProperty to be queried. + * @param[out] PropertyIDsBuffer - The PropertyIDs of the MultiProperty + */ + void CMultiPropertyGroup::GetMultiProperty(const Lib3MF_uint32 nPropertyID, std::vector & PropertyIDsBuffer) + { + Lib3MF_uint64 elementsNeededPropertyIDs = 0; + Lib3MF_uint64 elementsWrittenPropertyIDs = 0; + CheckError(lib3mf_multipropertygroup_getmultiproperty(m_pHandle, nPropertyID, 0, &elementsNeededPropertyIDs, nullptr)); + PropertyIDsBuffer.resize((size_t) elementsNeededPropertyIDs); + CheckError(lib3mf_multipropertygroup_getmultiproperty(m_pHandle, nPropertyID, elementsNeededPropertyIDs, &elementsWrittenPropertyIDs, PropertyIDsBuffer.data())); + } + + /** + * CMultiPropertyGroup::RemoveMultiProperty - Removes a MultiProperty from this MultiPropertyGroup. + * @param[in] nPropertyID - the PropertyID of the MultiProperty to be removed. + */ + void CMultiPropertyGroup::RemoveMultiProperty(const Lib3MF_uint32 nPropertyID) + { + CheckError(lib3mf_multipropertygroup_removemultiproperty(m_pHandle, nPropertyID)); + } + + /** + * CMultiPropertyGroup::GetLayerCount - Retrieves the number of layers of this MultiPropertyGroup. + * @return returns the number of layers + */ + Lib3MF_uint32 CMultiPropertyGroup::GetLayerCount() + { + Lib3MF_uint32 resultCount = 0; + CheckError(lib3mf_multipropertygroup_getlayercount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CMultiPropertyGroup::AddLayer - Adds a MultiPropertyLayer to this MultiPropertyGroup. + * @param[in] TheLayer - The MultiPropertyLayer to add to this MultiPropertyGroup + * @return returns the index of this MultiPropertyLayer + */ + Lib3MF_uint32 CMultiPropertyGroup::AddLayer(const sMultiPropertyLayer & TheLayer) + { + Lib3MF_uint32 resultLayerIndex = 0; + CheckError(lib3mf_multipropertygroup_addlayer(m_pHandle, &TheLayer, &resultLayerIndex)); + + return resultLayerIndex; + } + + /** + * CMultiPropertyGroup::GetLayer - Obtains a MultiPropertyLayer of this MultiPropertyGroup. + * @param[in] nLayerIndex - The Index of the MultiPropertyLayer queried + * @return The MultiPropertyLayer with index LayerIndex within MultiPropertyGroup + */ + sMultiPropertyLayer CMultiPropertyGroup::GetLayer(const Lib3MF_uint32 nLayerIndex) + { + sMultiPropertyLayer resultTheLayer; + CheckError(lib3mf_multipropertygroup_getlayer(m_pHandle, nLayerIndex, &resultTheLayer)); + + return resultTheLayer; + } + + /** + * CMultiPropertyGroup::RemoveLayer - Removes a MultiPropertyLayer from this MultiPropertyGroup. + * @param[in] nLayerIndex - The Index of the MultiPropertyLayer to be removed + */ + void CMultiPropertyGroup::RemoveLayer(const Lib3MF_uint32 nLayerIndex) + { + CheckError(lib3mf_multipropertygroup_removelayer(m_pHandle, nLayerIndex)); + } + + /** + * Method definitions for class CAttachment + */ + + /** + * CAttachment::GetPath - Retrieves an attachment's package path. This function will be removed in a later release. + * @return returns the attachment's package path string + */ + std::string CAttachment::GetPath() + { + Lib3MF_uint32 bytesNeededPath = 0; + Lib3MF_uint32 bytesWrittenPath = 0; + CheckError(lib3mf_attachment_getpath(m_pHandle, 0, &bytesNeededPath, nullptr)); + std::vector bufferPath(bytesNeededPath); + CheckError(lib3mf_attachment_getpath(m_pHandle, bytesNeededPath, &bytesWrittenPath, &bufferPath[0])); + + return std::string(&bufferPath[0]); + } + + /** + * CAttachment::SetPath - Sets an attachment's package path. This function will be removed in a later release. + * @param[in] sPath - new path of the attachment. + */ + void CAttachment::SetPath(const std::string & sPath) + { + CheckError(lib3mf_attachment_setpath(m_pHandle, sPath.c_str())); + } + + /** + * CAttachment::PackagePart - Returns the PackagePart that is this attachment. + * @return The PackagePart of this attachment. + */ + PPackagePart CAttachment::PackagePart() + { + Lib3MFHandle hPackagePart = nullptr; + CheckError(lib3mf_attachment_packagepart(m_pHandle, &hPackagePart)); + + if (!hPackagePart) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hPackagePart); + } + + /** + * CAttachment::GetRelationShipType - Retrieves an attachment's relationship type + * @return returns the attachment's package relationship type string + */ + std::string CAttachment::GetRelationShipType() + { + Lib3MF_uint32 bytesNeededPath = 0; + Lib3MF_uint32 bytesWrittenPath = 0; + CheckError(lib3mf_attachment_getrelationshiptype(m_pHandle, 0, &bytesNeededPath, nullptr)); + std::vector bufferPath(bytesNeededPath); + CheckError(lib3mf_attachment_getrelationshiptype(m_pHandle, bytesNeededPath, &bytesWrittenPath, &bufferPath[0])); + + return std::string(&bufferPath[0]); + } + + /** + * CAttachment::SetRelationShipType - Sets an attachment's relationship type. + * @param[in] sPath - new relationship type string. + */ + void CAttachment::SetRelationShipType(const std::string & sPath) + { + CheckError(lib3mf_attachment_setrelationshiptype(m_pHandle, sPath.c_str())); + } + + /** + * CAttachment::WriteToFile - Writes out the attachment as file. + * @param[in] sFileName - file to write into. + */ + void CAttachment::WriteToFile(const std::string & sFileName) + { + CheckError(lib3mf_attachment_writetofile(m_pHandle, sFileName.c_str())); + } + + /** + * CAttachment::ReadFromFile - Reads an attachment from a file. The path of this file is only read when this attachment is being written as part of the 3MF packege, or via the WriteToFile or WriteToBuffer-methods. + * @param[in] sFileName - file to read from. + */ + void CAttachment::ReadFromFile(const std::string & sFileName) + { + CheckError(lib3mf_attachment_readfromfile(m_pHandle, sFileName.c_str())); + } + + /** + * CAttachment::ReadFromCallback - Reads a model and from the data provided by a callback function + * @param[in] pTheReadCallback - Callback to call for reading a data chunk + * @param[in] nStreamSize - number of bytes the callback returns + * @param[in] pTheSeekCallback - Callback to call for seeking in the stream. + * @param[in] pUserData - Userdata that is passed to the callback function + */ + void CAttachment::ReadFromCallback(const ReadCallback pTheReadCallback, const Lib3MF_uint64 nStreamSize, const SeekCallback pTheSeekCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_attachment_readfromcallback(m_pHandle, pTheReadCallback, nStreamSize, pTheSeekCallback, pUserData)); + } + + /** + * CAttachment::GetStreamSize - Retrieves the size of the attachment stream + * @return the stream size + */ + Lib3MF_uint64 CAttachment::GetStreamSize() + { + Lib3MF_uint64 resultStreamSize = 0; + CheckError(lib3mf_attachment_getstreamsize(m_pHandle, &resultStreamSize)); + + return resultStreamSize; + } + + /** + * CAttachment::WriteToBuffer - Writes out the attachment into a buffer + * @param[out] BufferBuffer - Buffer to write into + */ + void CAttachment::WriteToBuffer(std::vector & BufferBuffer) + { + Lib3MF_uint64 elementsNeededBuffer = 0; + Lib3MF_uint64 elementsWrittenBuffer = 0; + CheckError(lib3mf_attachment_writetobuffer(m_pHandle, 0, &elementsNeededBuffer, nullptr)); + BufferBuffer.resize((size_t) elementsNeededBuffer); + CheckError(lib3mf_attachment_writetobuffer(m_pHandle, elementsNeededBuffer, &elementsWrittenBuffer, BufferBuffer.data())); + } + + /** + * CAttachment::ReadFromBuffer - Reads an attachment from a memory buffer + * @param[in] BufferBuffer - Buffer to read from + */ + void CAttachment::ReadFromBuffer(const CInputVector & BufferBuffer) + { + CheckError(lib3mf_attachment_readfrombuffer(m_pHandle, (Lib3MF_uint64)BufferBuffer.size(), BufferBuffer.data())); + } + + /** + * Method definitions for class CTexture2D + */ + + /** + * CTexture2D::GetAttachment - Retrieves the attachment located at the path of the texture. + * @return attachment that holds the texture's image information. + */ + PAttachment CTexture2D::GetAttachment() + { + Lib3MFHandle hAttachment = nullptr; + CheckError(lib3mf_texture2d_getattachment(m_pHandle, &hAttachment)); + + if (!hAttachment) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hAttachment); + } + + /** + * CTexture2D::SetAttachment - Sets the texture's package path to the path of the attachment. + * @param[in] pAttachment - attachment that holds the texture's image information. + */ + void CTexture2D::SetAttachment(CAttachment * pAttachment) + { + Lib3MFHandle hAttachment = nullptr; + if (pAttachment != nullptr) { + hAttachment = pAttachment->GetHandle(); + }; + CheckError(lib3mf_texture2d_setattachment(m_pHandle, hAttachment)); + } + + /** + * CTexture2D::GetContentType - Retrieves a texture's content type. + * @return returns content type enum. + */ + eTextureType CTexture2D::GetContentType() + { + eTextureType resultContentType = (eTextureType) 0; + CheckError(lib3mf_texture2d_getcontenttype(m_pHandle, &resultContentType)); + + return resultContentType; + } + + /** + * CTexture2D::SetContentType - Retrieves a texture's content type. + * @param[in] eContentType - new Content Type + */ + void CTexture2D::SetContentType(const eTextureType eContentType) + { + CheckError(lib3mf_texture2d_setcontenttype(m_pHandle, eContentType)); + } + + /** + * CTexture2D::GetTileStyleUV - Retrieves a texture's tilestyle type. + * @param[out] eTileStyleU - returns tilestyle type enum. + * @param[out] eTileStyleV - returns tilestyle type enum. + */ + void CTexture2D::GetTileStyleUV(eTextureTileStyle & eTileStyleU, eTextureTileStyle & eTileStyleV) + { + CheckError(lib3mf_texture2d_gettilestyleuv(m_pHandle, &eTileStyleU, &eTileStyleV)); + } + + /** + * CTexture2D::SetTileStyleUV - Sets a texture's tilestyle type. + * @param[in] eTileStyleU - new tilestyle type enum. + * @param[in] eTileStyleV - new tilestyle type enum. + */ + void CTexture2D::SetTileStyleUV(const eTextureTileStyle eTileStyleU, const eTextureTileStyle eTileStyleV) + { + CheckError(lib3mf_texture2d_settilestyleuv(m_pHandle, eTileStyleU, eTileStyleV)); + } + + /** + * CTexture2D::GetFilter - Retrieves a texture's filter type. + * @return returns filter type enum. + */ + eTextureFilter CTexture2D::GetFilter() + { + eTextureFilter resultFilter = (eTextureFilter) 0; + CheckError(lib3mf_texture2d_getfilter(m_pHandle, &resultFilter)); + + return resultFilter; + } + + /** + * CTexture2D::SetFilter - Sets a texture's filter type. + * @param[in] eFilter - sets new filter type enum. + */ + void CTexture2D::SetFilter(const eTextureFilter eFilter) + { + CheckError(lib3mf_texture2d_setfilter(m_pHandle, eFilter)); + } + + /** + * Method definitions for class CBuildItem + */ + + /** + * CBuildItem::GetObjectResource - Retrieves the object resource associated to a build item + * @return returns the associated resource instance + */ + PObject CBuildItem::GetObjectResource() + { + Lib3MFHandle hObjectResource = nullptr; + CheckError(lib3mf_builditem_getobjectresource(m_pHandle, &hObjectResource)); + + if (!hObjectResource) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hObjectResource); + } + + /** + * CBuildItem::GetUUID - returns, whether a build item has a UUID and, if true, the build item's UUID + * @param[out] bHasUUID - flag whether the build item has a UUID + * @return the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' + */ + std::string CBuildItem::GetUUID(bool & bHasUUID) + { + Lib3MF_uint32 bytesNeededUUID = 0; + Lib3MF_uint32 bytesWrittenUUID = 0; + CheckError(lib3mf_builditem_getuuid(m_pHandle, &bHasUUID, 0, &bytesNeededUUID, nullptr)); + std::vector bufferUUID(bytesNeededUUID); + CheckError(lib3mf_builditem_getuuid(m_pHandle, &bHasUUID, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); + + return std::string(&bufferUUID[0]); + } + + /** + * CBuildItem::SetUUID - sets the build item's UUID + * @param[in] sUUID - the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' + */ + void CBuildItem::SetUUID(const std::string & sUUID) + { + CheckError(lib3mf_builditem_setuuid(m_pHandle, sUUID.c_str())); + } + + /** + * CBuildItem::GetObjectResourceID - Retrieves the object UniqueResourceID associated to a build item + * @return returns the UniqueResourceID of the object + */ + Lib3MF_uint32 CBuildItem::GetObjectResourceID() + { + Lib3MF_uint32 resultUniqueResourceID = 0; + CheckError(lib3mf_builditem_getobjectresourceid(m_pHandle, &resultUniqueResourceID)); + + return resultUniqueResourceID; + } + + /** + * CBuildItem::HasObjectTransform - Checks, if a build item has a non-identity transformation matrix + * @return returns true, if the transformation matrix is not the identity + */ + bool CBuildItem::HasObjectTransform() + { + bool resultHasTransform = 0; + CheckError(lib3mf_builditem_hasobjecttransform(m_pHandle, &resultHasTransform)); + + return resultHasTransform; + } + + /** + * CBuildItem::GetObjectTransform - Retrieves a build item's transformation matrix. + * @return returns the transformation matrix + */ + sTransform CBuildItem::GetObjectTransform() + { + sTransform resultTransform; + CheckError(lib3mf_builditem_getobjecttransform(m_pHandle, &resultTransform)); + + return resultTransform; + } + + /** + * CBuildItem::SetObjectTransform - Sets a build item's transformation matrix. + * @param[in] Transform - new transformation matrix + */ + void CBuildItem::SetObjectTransform(const sTransform & Transform) + { + CheckError(lib3mf_builditem_setobjecttransform(m_pHandle, &Transform)); + } + + /** + * CBuildItem::GetPartNumber - Retrieves a build item's part number string + * @return Returns a build item's part number string + */ + std::string CBuildItem::GetPartNumber() + { + Lib3MF_uint32 bytesNeededPartNumber = 0; + Lib3MF_uint32 bytesWrittenPartNumber = 0; + CheckError(lib3mf_builditem_getpartnumber(m_pHandle, 0, &bytesNeededPartNumber, nullptr)); + std::vector bufferPartNumber(bytesNeededPartNumber); + CheckError(lib3mf_builditem_getpartnumber(m_pHandle, bytesNeededPartNumber, &bytesWrittenPartNumber, &bufferPartNumber[0])); + + return std::string(&bufferPartNumber[0]); + } + + /** + * CBuildItem::SetPartNumber - Sets a build item's part number string + * @param[in] sSetPartnumber - new part number string for referencing parts from the outside world + */ + void CBuildItem::SetPartNumber(const std::string & sSetPartnumber) + { + CheckError(lib3mf_builditem_setpartnumber(m_pHandle, sSetPartnumber.c_str())); + } + + /** + * CBuildItem::GetMetaDataGroup - Returns the metadatagroup of this build item + * @return returns an Instance of the metadatagroup of this build item + */ + PMetaDataGroup CBuildItem::GetMetaDataGroup() + { + Lib3MFHandle hMetaDataGroup = nullptr; + CheckError(lib3mf_builditem_getmetadatagroup(m_pHandle, &hMetaDataGroup)); + + if (!hMetaDataGroup) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMetaDataGroup); + } + + /** + * CBuildItem::GetOutbox - Returns the outbox of a build item + * @return Outbox of this build item + */ + sBox CBuildItem::GetOutbox() + { + sBox resultOutbox; + CheckError(lib3mf_builditem_getoutbox(m_pHandle, &resultOutbox)); + + return resultOutbox; + } + + /** + * Method definitions for class CBuildItemIterator + */ + + /** + * CBuildItemIterator::MoveNext - Iterates to the next build item in the list. + * @return Iterates to the next build item in the list. + */ + bool CBuildItemIterator::MoveNext() + { + bool resultHasNext = 0; + CheckError(lib3mf_builditemiterator_movenext(m_pHandle, &resultHasNext)); + + return resultHasNext; + } + + /** + * CBuildItemIterator::MovePrevious - Iterates to the previous build item in the list. + * @return Iterates to the previous build item in the list. + */ + bool CBuildItemIterator::MovePrevious() + { + bool resultHasPrevious = 0; + CheckError(lib3mf_builditemiterator_moveprevious(m_pHandle, &resultHasPrevious)); + + return resultHasPrevious; + } + + /** + * CBuildItemIterator::GetCurrent - Returns the build item the iterator points at. + * @return returns the build item instance. + */ + PBuildItem CBuildItemIterator::GetCurrent() + { + Lib3MFHandle hBuildItem = nullptr; + CheckError(lib3mf_builditemiterator_getcurrent(m_pHandle, &hBuildItem)); + + if (!hBuildItem) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBuildItem); + } + + /** + * CBuildItemIterator::Clone - Creates a new build item iterator with the same build item list. + * @return returns the cloned Iterator instance + */ + PBuildItemIterator CBuildItemIterator::Clone() + { + Lib3MFHandle hOutBuildItemIterator = nullptr; + CheckError(lib3mf_builditemiterator_clone(m_pHandle, &hOutBuildItemIterator)); + + if (!hOutBuildItemIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hOutBuildItemIterator); + } + + /** + * CBuildItemIterator::Count - Returns the number of build items the iterator captures. + * @return returns the number of build items the iterator captures. + */ + Lib3MF_uint64 CBuildItemIterator::Count() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_builditemiterator_count(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * Method definitions for class CSlice + */ + + /** + * CSlice::SetVertices - Set all vertices of a slice. All polygons will be cleared. + * @param[in] VerticesBuffer - contains the positions. + */ + void CSlice::SetVertices(const CInputVector & VerticesBuffer) + { + CheckError(lib3mf_slice_setvertices(m_pHandle, (Lib3MF_uint64)VerticesBuffer.size(), VerticesBuffer.data())); + } + + /** + * CSlice::GetVertices - Get all vertices of a slice + * @param[out] VerticesBuffer - contains the positions. + */ + void CSlice::GetVertices(std::vector & VerticesBuffer) + { + Lib3MF_uint64 elementsNeededVertices = 0; + Lib3MF_uint64 elementsWrittenVertices = 0; + CheckError(lib3mf_slice_getvertices(m_pHandle, 0, &elementsNeededVertices, nullptr)); + VerticesBuffer.resize((size_t) elementsNeededVertices); + CheckError(lib3mf_slice_getvertices(m_pHandle, elementsNeededVertices, &elementsWrittenVertices, VerticesBuffer.data())); + } + + /** + * CSlice::GetVertexCount - Get the number of vertices in a slice + * @return the number of vertices in the slice + */ + Lib3MF_uint64 CSlice::GetVertexCount() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_slice_getvertexcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CSlice::AddPolygon - Add a new polygon to this slice + * @param[in] IndicesBuffer - the new indices of the new polygon + * @return the index of the new polygon + */ + Lib3MF_uint64 CSlice::AddPolygon(const CInputVector & IndicesBuffer) + { + Lib3MF_uint64 resultIndex = 0; + CheckError(lib3mf_slice_addpolygon(m_pHandle, (Lib3MF_uint64)IndicesBuffer.size(), IndicesBuffer.data(), &resultIndex)); + + return resultIndex; + } + + /** + * CSlice::GetPolygonCount - Get the number of polygons in the slice + * @return the number of polygons in the slice + */ + Lib3MF_uint64 CSlice::GetPolygonCount() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_slice_getpolygoncount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CSlice::SetPolygonIndices - Set all indices of a polygon + * @param[in] nIndex - the index of the polygon to manipulate + * @param[in] IndicesBuffer - the new indices of the index-th polygon + */ + void CSlice::SetPolygonIndices(const Lib3MF_uint64 nIndex, const CInputVector & IndicesBuffer) + { + CheckError(lib3mf_slice_setpolygonindices(m_pHandle, nIndex, (Lib3MF_uint64)IndicesBuffer.size(), IndicesBuffer.data())); + } + + /** + * CSlice::GetPolygonIndices - Get all vertices of a slice + * @param[in] nIndex - the index of the polygon to manipulate + * @param[out] IndicesBuffer - the indices of the index-th polygon + */ + void CSlice::GetPolygonIndices(const Lib3MF_uint64 nIndex, std::vector & IndicesBuffer) + { + Lib3MF_uint64 elementsNeededIndices = 0; + Lib3MF_uint64 elementsWrittenIndices = 0; + CheckError(lib3mf_slice_getpolygonindices(m_pHandle, nIndex, 0, &elementsNeededIndices, nullptr)); + IndicesBuffer.resize((size_t) elementsNeededIndices); + CheckError(lib3mf_slice_getpolygonindices(m_pHandle, nIndex, elementsNeededIndices, &elementsWrittenIndices, IndicesBuffer.data())); + } + + /** + * CSlice::GetPolygonIndexCount - Get the number of vertices in a slice + * @param[in] nIndex - the index of the polygon to manipulate + * @return the number of indices of the index-th polygon + */ + Lib3MF_uint64 CSlice::GetPolygonIndexCount(const Lib3MF_uint64 nIndex) + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_slice_getpolygonindexcount(m_pHandle, nIndex, &resultCount)); + + return resultCount; + } + + /** + * CSlice::GetZTop - Get the upper Z-Coordinate of this slice. + * @return the upper Z-Coordinate of this slice + */ + Lib3MF_double CSlice::GetZTop() + { + Lib3MF_double resultZTop = 0; + CheckError(lib3mf_slice_getztop(m_pHandle, &resultZTop)); + + return resultZTop; + } + + /** + * Method definitions for class CSliceStack + */ + + /** + * CSliceStack::GetBottomZ - Get the lower Z-Coordinate of the slice stack. + * @return the lower Z-Coordinate the slice stack + */ + Lib3MF_double CSliceStack::GetBottomZ() + { + Lib3MF_double resultZBottom = 0; + CheckError(lib3mf_slicestack_getbottomz(m_pHandle, &resultZBottom)); + + return resultZBottom; + } + + /** + * CSliceStack::GetSliceCount - Returns the number of slices + * @return the number of slices + */ + Lib3MF_uint64 CSliceStack::GetSliceCount() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_slicestack_getslicecount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CSliceStack::GetSlice - Query a slice from the slice stack + * @param[in] nSliceIndex - the index of the slice + * @return the Slice instance + */ + PSlice CSliceStack::GetSlice(const Lib3MF_uint64 nSliceIndex) + { + Lib3MFHandle hTheSlice = nullptr; + CheckError(lib3mf_slicestack_getslice(m_pHandle, nSliceIndex, &hTheSlice)); + + if (!hTheSlice) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTheSlice); + } + + /** + * CSliceStack::AddSlice - Returns the number of slices + * @param[in] dZTop - upper Z coordinate of the slice + * @return a new Slice instance + */ + PSlice CSliceStack::AddSlice(const Lib3MF_double dZTop) + { + Lib3MFHandle hTheSlice = nullptr; + CheckError(lib3mf_slicestack_addslice(m_pHandle, dZTop, &hTheSlice)); + + if (!hTheSlice) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTheSlice); + } + + /** + * CSliceStack::GetSliceRefCount - Returns the number of slice refs + * @return the number of slicereferences + */ + Lib3MF_uint64 CSliceStack::GetSliceRefCount() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_slicestack_getslicerefcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CSliceStack::AddSliceStackReference - Adds another existing slicestack as sliceref in this slicestack + * @param[in] pTheSliceStack - the slicestack to use as sliceref + */ + void CSliceStack::AddSliceStackReference(CSliceStack * pTheSliceStack) + { + Lib3MFHandle hTheSliceStack = nullptr; + if (pTheSliceStack != nullptr) { + hTheSliceStack = pTheSliceStack->GetHandle(); + }; + CheckError(lib3mf_slicestack_addslicestackreference(m_pHandle, hTheSliceStack)); + } + + /** + * CSliceStack::GetSliceStackReference - Adds another existing slicestack as sliceref in this slicestack + * @param[in] nSliceRefIndex - the index of the slice ref + * @return the slicestack that is used as sliceref + */ + PSliceStack CSliceStack::GetSliceStackReference(const Lib3MF_uint64 nSliceRefIndex) + { + Lib3MFHandle hTheSliceStack = nullptr; + CheckError(lib3mf_slicestack_getslicestackreference(m_pHandle, nSliceRefIndex, &hTheSliceStack)); + + if (!hTheSliceStack) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTheSliceStack); + } + + /** + * CSliceStack::CollapseSliceReferences - Removes the indirection of slices via slice-refs, i.e. creates the slices of all slice refs of this SliceStack as actual slices of this SliceStack. All previously existing slices or slicerefs will be removed. + */ + void CSliceStack::CollapseSliceReferences() + { + CheckError(lib3mf_slicestack_collapseslicereferences(m_pHandle)); + } + + /** + * CSliceStack::SetOwnPath - Sets the package path where this Slice should be stored. Input an empty string to reset the path + * @param[in] sPath - the package path where this Slice should be stored + */ + void CSliceStack::SetOwnPath(const std::string & sPath) + { + CheckError(lib3mf_slicestack_setownpath(m_pHandle, sPath.c_str())); + } + + /** + * CSliceStack::GetOwnPath - Obtains the package path where this Slice should be stored. Returns an empty string if the slicestack is stored within the root model. + * @return the package path where this Slice will be stored + */ + std::string CSliceStack::GetOwnPath() + { + Lib3MF_uint32 bytesNeededPath = 0; + Lib3MF_uint32 bytesWrittenPath = 0; + CheckError(lib3mf_slicestack_getownpath(m_pHandle, 0, &bytesNeededPath, nullptr)); + std::vector bufferPath(bytesNeededPath); + CheckError(lib3mf_slicestack_getownpath(m_pHandle, bytesNeededPath, &bytesWrittenPath, &bufferPath[0])); + + return std::string(&bufferPath[0]); + } + + /** + * Method definitions for class CConsumer + */ + + /** + * CConsumer::GetConsumerID - Gets the consumerid + * @return A unique identifier for the consumers + */ + std::string CConsumer::GetConsumerID() + { + Lib3MF_uint32 bytesNeededConsumerID = 0; + Lib3MF_uint32 bytesWrittenConsumerID = 0; + CheckError(lib3mf_consumer_getconsumerid(m_pHandle, 0, &bytesNeededConsumerID, nullptr)); + std::vector bufferConsumerID(bytesNeededConsumerID); + CheckError(lib3mf_consumer_getconsumerid(m_pHandle, bytesNeededConsumerID, &bytesWrittenConsumerID, &bufferConsumerID[0])); + + return std::string(&bufferConsumerID[0]); + } + + /** + * CConsumer::GetKeyID - Getts the keyid + * @return The identifier for the key of this consumer + */ + std::string CConsumer::GetKeyID() + { + Lib3MF_uint32 bytesNeededKeyID = 0; + Lib3MF_uint32 bytesWrittenKeyID = 0; + CheckError(lib3mf_consumer_getkeyid(m_pHandle, 0, &bytesNeededKeyID, nullptr)); + std::vector bufferKeyID(bytesNeededKeyID); + CheckError(lib3mf_consumer_getkeyid(m_pHandle, bytesNeededKeyID, &bytesWrittenKeyID, &bufferKeyID[0])); + + return std::string(&bufferKeyID[0]); + } + + /** + * CConsumer::GetKeyValue - Gets the keyvalue associated with this consumer + * @return The public key, when available, of this consumer + */ + std::string CConsumer::GetKeyValue() + { + Lib3MF_uint32 bytesNeededKeyValue = 0; + Lib3MF_uint32 bytesWrittenKeyValue = 0; + CheckError(lib3mf_consumer_getkeyvalue(m_pHandle, 0, &bytesNeededKeyValue, nullptr)); + std::vector bufferKeyValue(bytesNeededKeyValue); + CheckError(lib3mf_consumer_getkeyvalue(m_pHandle, bytesNeededKeyValue, &bytesWrittenKeyValue, &bufferKeyValue[0])); + + return std::string(&bufferKeyValue[0]); + } + + /** + * Method definitions for class CAccessRight + */ + + /** + * CAccessRight::GetConsumer - Gets the consumer associated with this access right + * @return The consumer instance + */ + PConsumer CAccessRight::GetConsumer() + { + Lib3MFHandle hConsumer = nullptr; + CheckError(lib3mf_accessright_getconsumer(m_pHandle, &hConsumer)); + + if (!hConsumer) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hConsumer); + } + + /** + * CAccessRight::GetWrappingAlgorithm - Gets the associated encryption algorithm + * @return The algorithm used for the key in this accessright + */ + eWrappingAlgorithm CAccessRight::GetWrappingAlgorithm() + { + eWrappingAlgorithm resultAlgorithm = (eWrappingAlgorithm) 0; + CheckError(lib3mf_accessright_getwrappingalgorithm(m_pHandle, &resultAlgorithm)); + + return resultAlgorithm; + } + + /** + * CAccessRight::GetMgfAlgorithm - Gets the associated mask generation function algorithm + * @return The MFG1 algorithm + */ + eMgfAlgorithm CAccessRight::GetMgfAlgorithm() + { + eMgfAlgorithm resultAlgorithm = (eMgfAlgorithm) 0; + CheckError(lib3mf_accessright_getmgfalgorithm(m_pHandle, &resultAlgorithm)); + + return resultAlgorithm; + } + + /** + * CAccessRight::GetDigestMethod - Gets the digest method assoicated + * @return The digest method for this accessright + */ + eDigestMethod CAccessRight::GetDigestMethod() + { + eDigestMethod resultAlgorithm = (eDigestMethod) 0; + CheckError(lib3mf_accessright_getdigestmethod(m_pHandle, &resultAlgorithm)); + + return resultAlgorithm; + } + + /** + * Method definitions for class CContentEncryptionParams + */ + + /** + * CContentEncryptionParams::GetEncryptionAlgorithm - Returns the encryption method to be used in this encryption process + * @return + */ + eEncryptionAlgorithm CContentEncryptionParams::GetEncryptionAlgorithm() + { + eEncryptionAlgorithm resultAlgorithm = (eEncryptionAlgorithm) 0; + CheckError(lib3mf_contentencryptionparams_getencryptionalgorithm(m_pHandle, &resultAlgorithm)); + + return resultAlgorithm; + } + + /** + * CContentEncryptionParams::GetKey - Gets the key for the resource associated + * @param[out] ByteDataBuffer - Pointer to a buffer where to place the key. + */ + void CContentEncryptionParams::GetKey(std::vector & ByteDataBuffer) + { + Lib3MF_uint64 elementsNeededByteData = 0; + Lib3MF_uint64 elementsWrittenByteData = 0; + CheckError(lib3mf_contentencryptionparams_getkey(m_pHandle, 0, &elementsNeededByteData, nullptr)); + ByteDataBuffer.resize((size_t) elementsNeededByteData); + CheckError(lib3mf_contentencryptionparams_getkey(m_pHandle, elementsNeededByteData, &elementsWrittenByteData, ByteDataBuffer.data())); + } + + /** + * CContentEncryptionParams::GetInitializationVector - Gets the IV data + * @param[out] ByteDataBuffer - Pointer to a buffer where to place the data. + */ + void CContentEncryptionParams::GetInitializationVector(std::vector & ByteDataBuffer) + { + Lib3MF_uint64 elementsNeededByteData = 0; + Lib3MF_uint64 elementsWrittenByteData = 0; + CheckError(lib3mf_contentencryptionparams_getinitializationvector(m_pHandle, 0, &elementsNeededByteData, nullptr)); + ByteDataBuffer.resize((size_t) elementsNeededByteData); + CheckError(lib3mf_contentencryptionparams_getinitializationvector(m_pHandle, elementsNeededByteData, &elementsWrittenByteData, ByteDataBuffer.data())); + } + + /** + * CContentEncryptionParams::GetAuthenticationTag - A handler descriptor that uniquely identifies the context of the resource. Each resource will be assigned a different value + * @param[out] ByteDataBuffer - Pointer to a buffer where to place the data. + */ + void CContentEncryptionParams::GetAuthenticationTag(std::vector & ByteDataBuffer) + { + Lib3MF_uint64 elementsNeededByteData = 0; + Lib3MF_uint64 elementsWrittenByteData = 0; + CheckError(lib3mf_contentencryptionparams_getauthenticationtag(m_pHandle, 0, &elementsNeededByteData, nullptr)); + ByteDataBuffer.resize((size_t) elementsNeededByteData); + CheckError(lib3mf_contentencryptionparams_getauthenticationtag(m_pHandle, elementsNeededByteData, &elementsWrittenByteData, ByteDataBuffer.data())); + } + + /** + * CContentEncryptionParams::SetAuthenticationTag - Sets the authentication tag + * @param[in] ByteDataBuffer - The authentication tag size + */ + void CContentEncryptionParams::SetAuthenticationTag(const CInputVector & ByteDataBuffer) + { + CheckError(lib3mf_contentencryptionparams_setauthenticationtag(m_pHandle, (Lib3MF_uint64)ByteDataBuffer.size(), ByteDataBuffer.data())); + } + + /** + * CContentEncryptionParams::GetAdditionalAuthenticationData - A handler descriptor that uniquely identifies the context of the resource. Each resource will be assigned a different value + * @param[out] ByteDataBuffer - Buffer where the data will be placed + */ + void CContentEncryptionParams::GetAdditionalAuthenticationData(std::vector & ByteDataBuffer) + { + Lib3MF_uint64 elementsNeededByteData = 0; + Lib3MF_uint64 elementsWrittenByteData = 0; + CheckError(lib3mf_contentencryptionparams_getadditionalauthenticationdata(m_pHandle, 0, &elementsNeededByteData, nullptr)); + ByteDataBuffer.resize((size_t) elementsNeededByteData); + CheckError(lib3mf_contentencryptionparams_getadditionalauthenticationdata(m_pHandle, elementsNeededByteData, &elementsWrittenByteData, ByteDataBuffer.data())); + } + + /** + * CContentEncryptionParams::GetDescriptor - A handler descriptor that uniquely identifies the context of the resource. Each resource will be assigned a different value + * @return + */ + Lib3MF_uint64 CContentEncryptionParams::GetDescriptor() + { + Lib3MF_uint64 resultDescriptor = 0; + CheckError(lib3mf_contentencryptionparams_getdescriptor(m_pHandle, &resultDescriptor)); + + return resultDescriptor; + } + + /** + * CContentEncryptionParams::GetKeyUUID - Gets the resourcedatagroup keyuuid + * @return The resourcedatagroup keyuuid that may be use to reference an external key + */ + std::string CContentEncryptionParams::GetKeyUUID() + { + Lib3MF_uint32 bytesNeededUUID = 0; + Lib3MF_uint32 bytesWrittenUUID = 0; + CheckError(lib3mf_contentencryptionparams_getkeyuuid(m_pHandle, 0, &bytesNeededUUID, nullptr)); + std::vector bufferUUID(bytesNeededUUID); + CheckError(lib3mf_contentencryptionparams_getkeyuuid(m_pHandle, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); + + return std::string(&bufferUUID[0]); + } + + /** + * Method definitions for class CResourceData + */ + + /** + * CResourceData::GetPath - Gets the encrypted part path + * @return The part path + */ + PPackagePart CResourceData::GetPath() + { + Lib3MFHandle hPath = nullptr; + CheckError(lib3mf_resourcedata_getpath(m_pHandle, &hPath)); + + if (!hPath) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hPath); + } + + /** + * CResourceData::GetEncryptionAlgorithm - Gets the encryption algorithm used to encrypt this ResourceData + * @return The encryption algorithm + */ + eEncryptionAlgorithm CResourceData::GetEncryptionAlgorithm() + { + eEncryptionAlgorithm resultEncryptionAlgorithm = (eEncryptionAlgorithm) 0; + CheckError(lib3mf_resourcedata_getencryptionalgorithm(m_pHandle, &resultEncryptionAlgorithm)); + + return resultEncryptionAlgorithm; + } + + /** + * CResourceData::GetCompression - Tells whether this ResourceData is compressed or not + * @return The compression method + */ + eCompression CResourceData::GetCompression() + { + eCompression resultCompression = (eCompression) 0; + CheckError(lib3mf_resourcedata_getcompression(m_pHandle, &resultCompression)); + + return resultCompression; + } + + /** + * CResourceData::GetAdditionalAuthenticationData - Tells whether this ResourceData is compressed or not + * @param[out] ByteDataBuffer - The compression method + */ + void CResourceData::GetAdditionalAuthenticationData(std::vector & ByteDataBuffer) + { + Lib3MF_uint64 elementsNeededByteData = 0; + Lib3MF_uint64 elementsWrittenByteData = 0; + CheckError(lib3mf_resourcedata_getadditionalauthenticationdata(m_pHandle, 0, &elementsNeededByteData, nullptr)); + ByteDataBuffer.resize((size_t) elementsNeededByteData); + CheckError(lib3mf_resourcedata_getadditionalauthenticationdata(m_pHandle, elementsNeededByteData, &elementsWrittenByteData, ByteDataBuffer.data())); + } + + /** + * Method definitions for class CResourceDataGroup + */ + + /** + * CResourceDataGroup::GetKeyUUID - Sets the resourcedatagroup keyuuid + * @return The new resourcedatagroup keyuuid. + */ + std::string CResourceDataGroup::GetKeyUUID() + { + Lib3MF_uint32 bytesNeededUUID = 0; + Lib3MF_uint32 bytesWrittenUUID = 0; + CheckError(lib3mf_resourcedatagroup_getkeyuuid(m_pHandle, 0, &bytesNeededUUID, nullptr)); + std::vector bufferUUID(bytesNeededUUID); + CheckError(lib3mf_resourcedatagroup_getkeyuuid(m_pHandle, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); + + return std::string(&bufferUUID[0]); + } + + /** + * CResourceDataGroup::AddAccessRight - Add accessright to resourcedatagroup element + * @param[in] pConsumer - The Consumer reference + * @param[in] eWrappingAlgorithm - The key wrapping algorithm to be used + * @param[in] eMgfAlgorithm - The mask generation function to be used + * @param[in] eDigestMethod - The digest mechanism to be used + * @return The acess right instance + */ + PAccessRight CResourceDataGroup::AddAccessRight(CConsumer * pConsumer, const eWrappingAlgorithm eWrappingAlgorithm, const eMgfAlgorithm eMgfAlgorithm, const eDigestMethod eDigestMethod) + { + Lib3MFHandle hConsumer = nullptr; + if (pConsumer != nullptr) { + hConsumer = pConsumer->GetHandle(); + }; + Lib3MFHandle hTheAccessRight = nullptr; + CheckError(lib3mf_resourcedatagroup_addaccessright(m_pHandle, hConsumer, eWrappingAlgorithm, eMgfAlgorithm, eDigestMethod, &hTheAccessRight)); + + if (!hTheAccessRight) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTheAccessRight); + } + + /** + * CResourceDataGroup::FindAccessRightByConsumer - Finds the AccessRight associated with a Consumer + * @param[in] pConsumer - The Consumer instance + * @return The AcessRight instance + */ + PAccessRight CResourceDataGroup::FindAccessRightByConsumer(CConsumer * pConsumer) + { + Lib3MFHandle hConsumer = nullptr; + if (pConsumer != nullptr) { + hConsumer = pConsumer->GetHandle(); + }; + Lib3MFHandle hTheAccessRight = nullptr; + CheckError(lib3mf_resourcedatagroup_findaccessrightbyconsumer(m_pHandle, hConsumer, &hTheAccessRight)); + + if (hTheAccessRight) { + return std::make_shared(m_pWrapper, hTheAccessRight); + } else { + return nullptr; + } + } + + /** + * CResourceDataGroup::RemoveAccessRight - Removes access from a Consumer on this resource data group + * @param[in] pConsumer - The Consumer instance + */ + void CResourceDataGroup::RemoveAccessRight(CConsumer * pConsumer) + { + Lib3MFHandle hConsumer = nullptr; + if (pConsumer != nullptr) { + hConsumer = pConsumer->GetHandle(); + }; + CheckError(lib3mf_resourcedatagroup_removeaccessright(m_pHandle, hConsumer)); + } + + /** + * Method definitions for class CKeyStore + */ + + /** + * CKeyStore::AddConsumer - Adds a consumer to the keystore + * @param[in] sConsumerID - A unique identifier for the consumer + * @param[in] sKeyID - The id of the key of the consumer + * @param[in] sKeyValue - The public key for this consumer in PEM format + * @return The consumer instance + */ + PConsumer CKeyStore::AddConsumer(const std::string & sConsumerID, const std::string & sKeyID, const std::string & sKeyValue) + { + Lib3MFHandle hConsumer = nullptr; + CheckError(lib3mf_keystore_addconsumer(m_pHandle, sConsumerID.c_str(), sKeyID.c_str(), sKeyValue.c_str(), &hConsumer)); + + if (!hConsumer) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hConsumer); + } + + /** + * CKeyStore::GetConsumerCount - Gets the number of consumers in the keystore + * @return The consumer count + */ + Lib3MF_uint64 CKeyStore::GetConsumerCount() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_keystore_getconsumercount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CKeyStore::GetConsumer - Get a consumer from the keystore + * @param[in] nConsumerIndex - The index of the consumer + * @return The consumer instance + */ + PConsumer CKeyStore::GetConsumer(const Lib3MF_uint64 nConsumerIndex) + { + Lib3MFHandle hConsumer = nullptr; + CheckError(lib3mf_keystore_getconsumer(m_pHandle, nConsumerIndex, &hConsumer)); + + if (!hConsumer) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hConsumer); + } + + /** + * CKeyStore::RemoveConsumer - Removes a consumer from the keystore + * @param[in] pConsumer - The consumer instance to remove + */ + void CKeyStore::RemoveConsumer(CConsumer * pConsumer) + { + Lib3MFHandle hConsumer = nullptr; + if (pConsumer != nullptr) { + hConsumer = pConsumer->GetHandle(); + }; + CheckError(lib3mf_keystore_removeconsumer(m_pHandle, hConsumer)); + } + + /** + * CKeyStore::FindConsumer - Finds a consumer by ID + * @param[in] sConsumerID - The ID of the consumer + * @return The consumer instance + */ + PConsumer CKeyStore::FindConsumer(const std::string & sConsumerID) + { + Lib3MFHandle hConsumer = nullptr; + CheckError(lib3mf_keystore_findconsumer(m_pHandle, sConsumerID.c_str(), &hConsumer)); + + if (hConsumer) { + return std::make_shared(m_pWrapper, hConsumer); + } else { + return nullptr; + } + } + + /** + * CKeyStore::GetResourceDataGroupCount - Gets the number of resource data group in the keysore + * @return The number of resource data available + */ + Lib3MF_uint64 CKeyStore::GetResourceDataGroupCount() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_keystore_getresourcedatagroupcount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CKeyStore::AddResourceDataGroup - Adds a resource data group into the keystore. + * @return The resource data group instance + */ + PResourceDataGroup CKeyStore::AddResourceDataGroup() + { + Lib3MFHandle hResourceDataGroup = nullptr; + CheckError(lib3mf_keystore_addresourcedatagroup(m_pHandle, &hResourceDataGroup)); + + if (!hResourceDataGroup) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceDataGroup); + } + + /** + * CKeyStore::GetResourceDataGroup - Gets a resource data group + * @param[in] nResourceDataIndex - The index of the resource data + * @return The resource data group instance + */ + PResourceDataGroup CKeyStore::GetResourceDataGroup(const Lib3MF_uint64 nResourceDataIndex) + { + Lib3MFHandle hResourceDataGroup = nullptr; + CheckError(lib3mf_keystore_getresourcedatagroup(m_pHandle, nResourceDataIndex, &hResourceDataGroup)); + + if (!hResourceDataGroup) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceDataGroup); + } + + /** + * CKeyStore::RemoveResourceDataGroup - Removes a resource data group + * @param[in] pResourceDataGroup - The resource data group instance + */ + void CKeyStore::RemoveResourceDataGroup(CResourceDataGroup * pResourceDataGroup) + { + Lib3MFHandle hResourceDataGroup = nullptr; + if (pResourceDataGroup != nullptr) { + hResourceDataGroup = pResourceDataGroup->GetHandle(); + }; + CheckError(lib3mf_keystore_removeresourcedatagroup(m_pHandle, hResourceDataGroup)); + } + + /** + * CKeyStore::FindResourceDataGroup - Finds a resource data group that contains a particular resourcedata + * @param[in] pPartPath - The target path for the resourcedata hold by the resource data group + * @return The data resource instance + */ + PResourceDataGroup CKeyStore::FindResourceDataGroup(CPackagePart * pPartPath) + { + Lib3MFHandle hPartPath = nullptr; + if (pPartPath != nullptr) { + hPartPath = pPartPath->GetHandle(); + }; + Lib3MFHandle hResourceDataGroup = nullptr; + CheckError(lib3mf_keystore_findresourcedatagroup(m_pHandle, hPartPath, &hResourceDataGroup)); + + if (hResourceDataGroup) { + return std::make_shared(m_pWrapper, hResourceDataGroup); + } else { + return nullptr; + } + } + + /** + * CKeyStore::AddResourceData - Add resourcedata to resourcedatagroup element + * @param[in] pResourceDataGroup - The resource data group where to add this resource data + * @param[in] pPartPath - The path of the part to be encrypted + * @param[in] eAlgorithm - The encryption algorithm to be used to encrypt this resource + * @param[in] eCompression - Whether compression should be used prior to encryption + * @param[in] AdditionalAuthenticationDataBuffer - Additional data to be encrypted along the contents for better security + * @return The data resource instance + */ + PResourceData CKeyStore::AddResourceData(CResourceDataGroup * pResourceDataGroup, CPackagePart * pPartPath, const eEncryptionAlgorithm eAlgorithm, const eCompression eCompression, const CInputVector & AdditionalAuthenticationDataBuffer) + { + Lib3MFHandle hResourceDataGroup = nullptr; + if (pResourceDataGroup != nullptr) { + hResourceDataGroup = pResourceDataGroup->GetHandle(); + }; + Lib3MFHandle hPartPath = nullptr; + if (pPartPath != nullptr) { + hPartPath = pPartPath->GetHandle(); + }; + Lib3MFHandle hResourceData = nullptr; + CheckError(lib3mf_keystore_addresourcedata(m_pHandle, hResourceDataGroup, hPartPath, eAlgorithm, eCompression, (Lib3MF_uint64)AdditionalAuthenticationDataBuffer.size(), AdditionalAuthenticationDataBuffer.data(), &hResourceData)); + + if (!hResourceData) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceData); + } + + /** + * CKeyStore::RemoveResourceData - Removes a resource data + * @param[in] pResourceData - The resource data to be removed + */ + void CKeyStore::RemoveResourceData(CResourceData * pResourceData) + { + Lib3MFHandle hResourceData = nullptr; + if (pResourceData != nullptr) { + hResourceData = pResourceData->GetHandle(); + }; + CheckError(lib3mf_keystore_removeresourcedata(m_pHandle, hResourceData)); + } + + /** + * CKeyStore::FindResourceData - Finds a resource data on this resource group + * @param[in] pResourcePath - The target path for the resourcedata + * @return The resource data instance + */ + PResourceData CKeyStore::FindResourceData(CPackagePart * pResourcePath) + { + Lib3MFHandle hResourcePath = nullptr; + if (pResourcePath != nullptr) { + hResourcePath = pResourcePath->GetHandle(); + }; + Lib3MFHandle hResourceData = nullptr; + CheckError(lib3mf_keystore_findresourcedata(m_pHandle, hResourcePath, &hResourceData)); + + if (hResourceData) { + return std::make_shared(m_pWrapper, hResourceData); + } else { + return nullptr; + } + } + + /** + * CKeyStore::GetResourceDataCount - Gets the number of resource data in the keysore + * @return The number of resource data available + */ + Lib3MF_uint64 CKeyStore::GetResourceDataCount() + { + Lib3MF_uint64 resultCount = 0; + CheckError(lib3mf_keystore_getresourcedatacount(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * CKeyStore::GetResourceData - Gets a resource data + * @param[in] nResourceDataIndex - The index of the resource data + * @return The data resource instance + */ + PResourceData CKeyStore::GetResourceData(const Lib3MF_uint64 nResourceDataIndex) + { + Lib3MFHandle hResourceData = nullptr; + CheckError(lib3mf_keystore_getresourcedata(m_pHandle, nResourceDataIndex, &hResourceData)); + + if (!hResourceData) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceData); + } + + /** + * CKeyStore::GetUUID - Gets the keystore UUID + * @param[out] bHasUUID - flag whether the keystore has a UUID + * @return returns the keystore uuid. + */ + std::string CKeyStore::GetUUID(bool & bHasUUID) + { + Lib3MF_uint32 bytesNeededUUID = 0; + Lib3MF_uint32 bytesWrittenUUID = 0; + CheckError(lib3mf_keystore_getuuid(m_pHandle, &bHasUUID, 0, &bytesNeededUUID, nullptr)); + std::vector bufferUUID(bytesNeededUUID); + CheckError(lib3mf_keystore_getuuid(m_pHandle, &bHasUUID, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); + + return std::string(&bufferUUID[0]); + } + + /** + * CKeyStore::SetUUID - Sets the keystore UUID + * @param[in] sUUID - The new keystore uuid. + */ + void CKeyStore::SetUUID(const std::string & sUUID) + { + CheckError(lib3mf_keystore_setuuid(m_pHandle, sUUID.c_str())); + } + + /** + * Method definitions for class CModel + */ + + /** + * CModel::RootModelPart - Returns the PackagePart within the OPC package that holds the root model. + * @return the PackagePart within the OPC package that holds the model-file + */ + PPackagePart CModel::RootModelPart() + { + Lib3MFHandle hRootModelPart = nullptr; + CheckError(lib3mf_model_rootmodelpart(m_pHandle, &hRootModelPart)); + + if (!hRootModelPart) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hRootModelPart); + } + + /** + * CModel::FindOrCreatePackagePart - Returns a new PackagePart for use within the OPC package. + * @param[in] sAbsolutePath - the absolute Path (physical location) within the OPC package + * @return the new PackagePart within the OPC package + */ + PPackagePart CModel::FindOrCreatePackagePart(const std::string & sAbsolutePath) + { + Lib3MFHandle hModelPart = nullptr; + CheckError(lib3mf_model_findorcreatepackagepart(m_pHandle, sAbsolutePath.c_str(), &hModelPart)); + + if (!hModelPart) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hModelPart); + } + + /** + * CModel::SetUnit - sets the units of a model. + * @param[in] eUnit - Unit enum value for the model unit + */ + void CModel::SetUnit(const eModelUnit eUnit) + { + CheckError(lib3mf_model_setunit(m_pHandle, eUnit)); + } + + /** + * CModel::GetUnit - returns the units of a model. + * @return Unit enum value for the model unit + */ + eModelUnit CModel::GetUnit() + { + eModelUnit resultUnit = (eModelUnit) 0; + CheckError(lib3mf_model_getunit(m_pHandle, &resultUnit)); + + return resultUnit; + } + + /** + * CModel::GetLanguage - retrieves the language of a model + * @return language identifier + */ + std::string CModel::GetLanguage() + { + Lib3MF_uint32 bytesNeededLanguage = 0; + Lib3MF_uint32 bytesWrittenLanguage = 0; + CheckError(lib3mf_model_getlanguage(m_pHandle, 0, &bytesNeededLanguage, nullptr)); + std::vector bufferLanguage(bytesNeededLanguage); + CheckError(lib3mf_model_getlanguage(m_pHandle, bytesNeededLanguage, &bytesWrittenLanguage, &bufferLanguage[0])); + + return std::string(&bufferLanguage[0]); + } + + /** + * CModel::SetLanguage - sets the language of a model + * @param[in] sLanguage - language identifier + */ + void CModel::SetLanguage(const std::string & sLanguage) + { + CheckError(lib3mf_model_setlanguage(m_pHandle, sLanguage.c_str())); + } + + /** + * CModel::QueryWriter - creates a model writer instance for a specific file type + * @param[in] sWriterClass - string identifier for the file type + * @return string identifier for the file type + */ + PWriter CModel::QueryWriter(const std::string & sWriterClass) + { + Lib3MFHandle hWriterInstance = nullptr; + CheckError(lib3mf_model_querywriter(m_pHandle, sWriterClass.c_str(), &hWriterInstance)); + + if (!hWriterInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hWriterInstance); + } + + /** + * CModel::QueryReader - creates a model reader instance for a specific file type + * @param[in] sReaderClass - string identifier for the file type + * @return string identifier for the file type + */ + PReader CModel::QueryReader(const std::string & sReaderClass) + { + Lib3MFHandle hReaderInstance = nullptr; + CheckError(lib3mf_model_queryreader(m_pHandle, sReaderClass.c_str(), &hReaderInstance)); + + if (!hReaderInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hReaderInstance); + } + + /** + * CModel::GetTexture2DByID - finds a model texture by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the texture2d instance + */ + PTexture2D CModel::GetTexture2DByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hTextureInstance = nullptr; + CheckError(lib3mf_model_gettexture2dbyid(m_pHandle, nUniqueResourceID, &hTextureInstance)); + + if (!hTextureInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTextureInstance); + } + + /** + * CModel::GetPropertyTypeByID - returns a Property's type + * @param[in] nUniqueResourceID - Resource ID of the Property to Query + * @return returns a Property's type + */ + ePropertyType CModel::GetPropertyTypeByID(const Lib3MF_uint32 nUniqueResourceID) + { + ePropertyType resultThePropertyType = (ePropertyType) 0; + CheckError(lib3mf_model_getpropertytypebyid(m_pHandle, nUniqueResourceID, &resultThePropertyType)); + + return resultThePropertyType; + } + + /** + * CModel::GetBaseMaterialGroupByID - finds a model base material group by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the BaseMaterialGroup instance + */ + PBaseMaterialGroup CModel::GetBaseMaterialGroupByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hBaseMaterialGroupInstance = nullptr; + CheckError(lib3mf_model_getbasematerialgroupbyid(m_pHandle, nUniqueResourceID, &hBaseMaterialGroupInstance)); + + if (!hBaseMaterialGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBaseMaterialGroupInstance); + } + + /** + * CModel::GetTexture2DGroupByID - finds a model texture2d group by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the Texture2DGroup instance + */ + PTexture2DGroup CModel::GetTexture2DGroupByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hTexture2DGroupInstance = nullptr; + CheckError(lib3mf_model_gettexture2dgroupbyid(m_pHandle, nUniqueResourceID, &hTexture2DGroupInstance)); + + if (!hTexture2DGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTexture2DGroupInstance); + } + + /** + * CModel::GetCompositeMaterialsByID - finds a model CompositeMaterials by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the CompositeMaterials instance + */ + PCompositeMaterials CModel::GetCompositeMaterialsByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hCompositeMaterialsInstance = nullptr; + CheckError(lib3mf_model_getcompositematerialsbyid(m_pHandle, nUniqueResourceID, &hCompositeMaterialsInstance)); + + if (!hCompositeMaterialsInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCompositeMaterialsInstance); + } + + /** + * CModel::GetMultiPropertyGroupByID - finds a model MultiPropertyGroup by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the MultiPropertyGroup instance + */ + PMultiPropertyGroup CModel::GetMultiPropertyGroupByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hMultiPropertyGroupInstance = nullptr; + CheckError(lib3mf_model_getmultipropertygroupbyid(m_pHandle, nUniqueResourceID, &hMultiPropertyGroupInstance)); + + if (!hMultiPropertyGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMultiPropertyGroupInstance); + } + + /** + * CModel::GetMeshObjectByID - finds a mesh object by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the mesh object instance + */ + PMeshObject CModel::GetMeshObjectByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hMeshObjectInstance = nullptr; + CheckError(lib3mf_model_getmeshobjectbyid(m_pHandle, nUniqueResourceID, &hMeshObjectInstance)); + + if (!hMeshObjectInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMeshObjectInstance); + } + + /** + * CModel::GetComponentsObjectByID - finds a components object by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the components object instance + */ + PComponentsObject CModel::GetComponentsObjectByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hComponentsObjectInstance = nullptr; + CheckError(lib3mf_model_getcomponentsobjectbyid(m_pHandle, nUniqueResourceID, &hComponentsObjectInstance)); + + if (!hComponentsObjectInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hComponentsObjectInstance); + } + + /** + * CModel::GetColorGroupByID - finds a model color group by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the ColorGroup instance + */ + PColorGroup CModel::GetColorGroupByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hColorGroupInstance = nullptr; + CheckError(lib3mf_model_getcolorgroupbyid(m_pHandle, nUniqueResourceID, &hColorGroupInstance)); + + if (!hColorGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hColorGroupInstance); + } + + /** + * CModel::GetSliceStackByID - finds a model slicestack by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the slicestack instance + */ + PSliceStack CModel::GetSliceStackByID(const Lib3MF_uint32 nUniqueResourceID) + { + Lib3MFHandle hSliceStacInstance = nullptr; + CheckError(lib3mf_model_getslicestackbyid(m_pHandle, nUniqueResourceID, &hSliceStacInstance)); + + if (!hSliceStacInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hSliceStacInstance); + } + + /** + * CModel::GetBuildUUID - returns, whether a build has a UUID and, if true, the build's UUID + * @param[out] bHasUUID - flag whether the build has a UUID + * @return the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' + */ + std::string CModel::GetBuildUUID(bool & bHasUUID) + { + Lib3MF_uint32 bytesNeededUUID = 0; + Lib3MF_uint32 bytesWrittenUUID = 0; + CheckError(lib3mf_model_getbuilduuid(m_pHandle, &bHasUUID, 0, &bytesNeededUUID, nullptr)); + std::vector bufferUUID(bytesNeededUUID); + CheckError(lib3mf_model_getbuilduuid(m_pHandle, &bHasUUID, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); + + return std::string(&bufferUUID[0]); + } + + /** + * CModel::SetBuildUUID - sets the build's UUID + * @param[in] sUUID - the UUID as string of the form 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx' + */ + void CModel::SetBuildUUID(const std::string & sUUID) + { + CheckError(lib3mf_model_setbuilduuid(m_pHandle, sUUID.c_str())); + } + + /** + * CModel::GetBuildItems - creates a build item iterator instance with all build items. + * @return returns the iterator instance. + */ + PBuildItemIterator CModel::GetBuildItems() + { + Lib3MFHandle hBuildItemIterator = nullptr; + CheckError(lib3mf_model_getbuilditems(m_pHandle, &hBuildItemIterator)); + + if (!hBuildItemIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBuildItemIterator); + } + + /** + * CModel::GetOutbox - Returns the outbox of a Model + * @return Outbox of this Model + */ + sBox CModel::GetOutbox() + { + sBox resultOutbox; + CheckError(lib3mf_model_getoutbox(m_pHandle, &resultOutbox)); + + return resultOutbox; + } + + /** + * CModel::GetResources - creates a resource iterator instance with all resources. + * @return returns the iterator instance. + */ + PResourceIterator CModel::GetResources() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getresources(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetObjects - creates a resource iterator instance with all object resources. + * @return returns the iterator instance. + */ + PObjectIterator CModel::GetObjects() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getobjects(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetMeshObjects - creates a resource iterator instance with all mesh object resources. + * @return returns the iterator instance. + */ + PMeshObjectIterator CModel::GetMeshObjects() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getmeshobjects(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetComponentsObjects - creates a resource iterator instance with all components object resources. + * @return returns the iterator instance. + */ + PComponentsObjectIterator CModel::GetComponentsObjects() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getcomponentsobjects(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetTexture2Ds - creates a Texture2DIterator instance with all texture2d resources. + * @return returns the iterator instance. + */ + PTexture2DIterator CModel::GetTexture2Ds() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_gettexture2ds(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetBaseMaterialGroups - creates a BaseMaterialGroupIterator instance with all base material resources. + * @return returns the iterator instance. + */ + PBaseMaterialGroupIterator CModel::GetBaseMaterialGroups() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getbasematerialgroups(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetColorGroups - creates a ColorGroupIterator instance with all ColorGroup resources. + * @return returns the iterator instance. + */ + PColorGroupIterator CModel::GetColorGroups() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getcolorgroups(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetTexture2DGroups - creates a Texture2DGroupIterator instance with all base material resources. + * @return returns the iterator instance. + */ + PTexture2DGroupIterator CModel::GetTexture2DGroups() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_gettexture2dgroups(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetCompositeMaterials - creates a CompositeMaterialsIterator instance with all CompositeMaterials resources. + * @return returns the iterator instance. + */ + PCompositeMaterialsIterator CModel::GetCompositeMaterials() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getcompositematerials(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetMultiPropertyGroups - creates a MultiPropertyGroupsIterator instance with all MultiPropertyGroup resources. + * @return returns the iterator instance. + */ + PMultiPropertyGroupIterator CModel::GetMultiPropertyGroups() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getmultipropertygroups(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::GetSliceStacks - creates a resource iterator instance with all slice stack resources. + * @return returns the iterator instance. + */ + PSliceStackIterator CModel::GetSliceStacks() + { + Lib3MFHandle hResourceIterator = nullptr; + CheckError(lib3mf_model_getslicestacks(m_pHandle, &hResourceIterator)); + + if (!hResourceIterator) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hResourceIterator); + } + + /** + * CModel::MergeToModel - Merges all components and objects which are referenced by a build item into a mesh. The memory is duplicated and a new model is created. + * @return returns the merged model instance + */ + PModel CModel::MergeToModel() + { + Lib3MFHandle hMergedModelInstance = nullptr; + CheckError(lib3mf_model_mergetomodel(m_pHandle, &hMergedModelInstance)); + + if (!hMergedModelInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMergedModelInstance); + } + + /** + * CModel::AddMeshObject - adds an empty mesh object to the model. + * @return returns the mesh object instance + */ + PMeshObject CModel::AddMeshObject() + { + Lib3MFHandle hMeshObjectInstance = nullptr; + CheckError(lib3mf_model_addmeshobject(m_pHandle, &hMeshObjectInstance)); + + if (!hMeshObjectInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMeshObjectInstance); + } + + /** + * CModel::AddComponentsObject - adds an empty component object to the model. + * @return returns the components object instance + */ + PComponentsObject CModel::AddComponentsObject() + { + Lib3MFHandle hComponentsObjectInstance = nullptr; + CheckError(lib3mf_model_addcomponentsobject(m_pHandle, &hComponentsObjectInstance)); + + if (!hComponentsObjectInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hComponentsObjectInstance); + } + + /** + * CModel::AddSliceStack - creates a new model slicestack by its id + * @param[in] dZBottom - Bottom Z value of the slicestack + * @return returns the new slicestack instance + */ + PSliceStack CModel::AddSliceStack(const Lib3MF_double dZBottom) + { + Lib3MFHandle hSliceStackInstance = nullptr; + CheckError(lib3mf_model_addslicestack(m_pHandle, dZBottom, &hSliceStackInstance)); + + if (!hSliceStackInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hSliceStackInstance); + } + + /** + * CModel::AddTexture2DFromAttachment - adds a texture2d resource to the model. Its path is given by that of an existing attachment. + * @param[in] pTextureAttachment - attachment containing the image data. + * @return returns the new texture instance. + */ + PTexture2D CModel::AddTexture2DFromAttachment(CAttachment * pTextureAttachment) + { + Lib3MFHandle hTextureAttachment = nullptr; + if (pTextureAttachment != nullptr) { + hTextureAttachment = pTextureAttachment->GetHandle(); + }; + Lib3MFHandle hTexture2DInstance = nullptr; + CheckError(lib3mf_model_addtexture2dfromattachment(m_pHandle, hTextureAttachment, &hTexture2DInstance)); + + if (!hTexture2DInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTexture2DInstance); + } + + /** + * CModel::AddBaseMaterialGroup - adds an empty BaseMaterialGroup resource to the model. + * @return returns the new base material instance. + */ + PBaseMaterialGroup CModel::AddBaseMaterialGroup() + { + Lib3MFHandle hBaseMaterialGroupInstance = nullptr; + CheckError(lib3mf_model_addbasematerialgroup(m_pHandle, &hBaseMaterialGroupInstance)); + + if (!hBaseMaterialGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBaseMaterialGroupInstance); + } + + /** + * CModel::AddColorGroup - adds an empty ColorGroup resource to the model. + * @return returns the new ColorGroup instance. + */ + PColorGroup CModel::AddColorGroup() + { + Lib3MFHandle hColorGroupInstance = nullptr; + CheckError(lib3mf_model_addcolorgroup(m_pHandle, &hColorGroupInstance)); + + if (!hColorGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hColorGroupInstance); + } + + /** + * CModel::AddTexture2DGroup - adds an empty Texture2DGroup resource to the model. + * @param[in] pTexture2DInstance - The texture2D instance of the created Texture2DGroup. + * @return returns the new Texture2DGroup instance. + */ + PTexture2DGroup CModel::AddTexture2DGroup(CTexture2D * pTexture2DInstance) + { + Lib3MFHandle hTexture2DInstance = nullptr; + if (pTexture2DInstance != nullptr) { + hTexture2DInstance = pTexture2DInstance->GetHandle(); + }; + Lib3MFHandle hTexture2DGroupInstance = nullptr; + CheckError(lib3mf_model_addtexture2dgroup(m_pHandle, hTexture2DInstance, &hTexture2DGroupInstance)); + + if (!hTexture2DGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTexture2DGroupInstance); + } + + /** + * CModel::AddCompositeMaterials - adds an empty CompositeMaterials resource to the model. + * @param[in] pBaseMaterialGroupInstance - The BaseMaterialGroup instance of the created CompositeMaterials. + * @return returns the new CompositeMaterials instance. + */ + PCompositeMaterials CModel::AddCompositeMaterials(CBaseMaterialGroup * pBaseMaterialGroupInstance) + { + Lib3MFHandle hBaseMaterialGroupInstance = nullptr; + if (pBaseMaterialGroupInstance != nullptr) { + hBaseMaterialGroupInstance = pBaseMaterialGroupInstance->GetHandle(); + }; + Lib3MFHandle hCompositeMaterialsInstance = nullptr; + CheckError(lib3mf_model_addcompositematerials(m_pHandle, hBaseMaterialGroupInstance, &hCompositeMaterialsInstance)); + + if (!hCompositeMaterialsInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCompositeMaterialsInstance); + } + + /** + * CModel::AddMultiPropertyGroup - adds an empty MultiPropertyGroup resource to the model. + * @return returns the new MultiPropertyGroup instance. + */ + PMultiPropertyGroup CModel::AddMultiPropertyGroup() + { + Lib3MFHandle hMultiPropertyGroupInstance = nullptr; + CheckError(lib3mf_model_addmultipropertygroup(m_pHandle, &hMultiPropertyGroupInstance)); + + if (!hMultiPropertyGroupInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hMultiPropertyGroupInstance); + } + + /** + * CModel::AddBuildItem - adds a build item to the model. + * @param[in] pObject - Object instance. + * @param[in] Transform - Transformation matrix. + * @return returns the build item instance. + */ + PBuildItem CModel::AddBuildItem(CObject * pObject, const sTransform & Transform) + { + Lib3MFHandle hObject = nullptr; + if (pObject != nullptr) { + hObject = pObject->GetHandle(); + }; + Lib3MFHandle hBuildItemInstance = nullptr; + CheckError(lib3mf_model_addbuilditem(m_pHandle, hObject, &Transform, &hBuildItemInstance)); + + if (!hBuildItemInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBuildItemInstance); + } + + /** + * CModel::RemoveBuildItem - removes a build item from the model + * @param[in] pBuildItemInstance - Build item to remove. + */ + void CModel::RemoveBuildItem(CBuildItem * pBuildItemInstance) + { + Lib3MFHandle hBuildItemInstance = nullptr; + if (pBuildItemInstance != nullptr) { + hBuildItemInstance = pBuildItemInstance->GetHandle(); + }; + CheckError(lib3mf_model_removebuilditem(m_pHandle, hBuildItemInstance)); + } + + /** + * CModel::GetMetaDataGroup - Returns the metadata of the model as MetaDataGroup + * @return returns an Instance of the metadatagroup of the model + */ + PMetaDataGroup CModel::GetMetaDataGroup() + { + Lib3MFHandle hTheMetaDataGroup = nullptr; + CheckError(lib3mf_model_getmetadatagroup(m_pHandle, &hTheMetaDataGroup)); + + if (!hTheMetaDataGroup) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hTheMetaDataGroup); + } + + /** + * CModel::AddAttachment - adds an attachment stream to the model. The OPC part will be related to the model stream with a certain relationship type. + * @param[in] sURI - Path of the attachment + * @param[in] sRelationShipType - Relationship type of the attachment + * @return Instance of the attachment object + */ + PAttachment CModel::AddAttachment(const std::string & sURI, const std::string & sRelationShipType) + { + Lib3MFHandle hAttachmentInstance = nullptr; + CheckError(lib3mf_model_addattachment(m_pHandle, sURI.c_str(), sRelationShipType.c_str(), &hAttachmentInstance)); + + if (!hAttachmentInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hAttachmentInstance); + } + + /** + * CModel::RemoveAttachment - Removes attachment from the model. + * @param[in] pAttachmentInstance - Attachment instance to remove + */ + void CModel::RemoveAttachment(CAttachment * pAttachmentInstance) + { + Lib3MFHandle hAttachmentInstance = nullptr; + if (pAttachmentInstance != nullptr) { + hAttachmentInstance = pAttachmentInstance->GetHandle(); + }; + CheckError(lib3mf_model_removeattachment(m_pHandle, hAttachmentInstance)); + } + + /** + * CModel::GetAttachment - retrieves an attachment stream object from the model.. + * @param[in] nIndex - Index of the attachment stream + * @return Instance of the attachment object + */ + PAttachment CModel::GetAttachment(const Lib3MF_uint32 nIndex) + { + Lib3MFHandle hAttachmentInstance = nullptr; + CheckError(lib3mf_model_getattachment(m_pHandle, nIndex, &hAttachmentInstance)); + + if (!hAttachmentInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hAttachmentInstance); + } + + /** + * CModel::FindAttachment - retrieves an attachment stream object from the model. + * @param[in] sURI - Path URI in the package + * @return Instance of the attachment object + */ + PAttachment CModel::FindAttachment(const std::string & sURI) + { + Lib3MFHandle hAttachmentInstance = nullptr; + CheckError(lib3mf_model_findattachment(m_pHandle, sURI.c_str(), &hAttachmentInstance)); + + if (!hAttachmentInstance) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hAttachmentInstance); + } + + /** + * CModel::GetAttachmentCount - retrieves the number of attachments of the model. + * @return Returns the number of attachments. + */ + Lib3MF_uint32 CModel::GetAttachmentCount() + { + Lib3MF_uint32 resultAttachmentCount = 0; + CheckError(lib3mf_model_getattachmentcount(m_pHandle, &resultAttachmentCount)); + + return resultAttachmentCount; + } + + /** + * CModel::HasPackageThumbnailAttachment - Retrieve whether the OPC package contains a package thumbnail. + * @return returns whether the OPC package contains a package thumbnail + */ + bool CModel::HasPackageThumbnailAttachment() + { + bool resultHasThumbnail = 0; + CheckError(lib3mf_model_haspackagethumbnailattachment(m_pHandle, &resultHasThumbnail)); + + return resultHasThumbnail; + } + + /** + * CModel::CreatePackageThumbnailAttachment - Create a new or the existing package thumbnail for the OPC package. + * @return Instance of a new or the existing thumbnailattachment object. + */ + PAttachment CModel::CreatePackageThumbnailAttachment() + { + Lib3MFHandle hAttachment = nullptr; + CheckError(lib3mf_model_createpackagethumbnailattachment(m_pHandle, &hAttachment)); + + if (!hAttachment) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hAttachment); + } + + /** + * CModel::GetPackageThumbnailAttachment - Get the attachment to the OPC package containing the package thumbnail. + * @return Instance of the thumbnailattachment object or NULL. + */ + PAttachment CModel::GetPackageThumbnailAttachment() + { + Lib3MFHandle hAttachment = nullptr; + CheckError(lib3mf_model_getpackagethumbnailattachment(m_pHandle, &hAttachment)); + + if (hAttachment) { + return std::make_shared(m_pWrapper, hAttachment); + } else { + return nullptr; + } + } + + /** + * CModel::RemovePackageThumbnailAttachment - Remove the attachment to the OPC package containing the package thumbnail. + */ + void CModel::RemovePackageThumbnailAttachment() + { + CheckError(lib3mf_model_removepackagethumbnailattachment(m_pHandle)); + } + + /** + * CModel::AddCustomContentType - Adds a new Content Type to the model. + * @param[in] sExtension - File Extension + * @param[in] sContentType - Content Type Identifier + */ + void CModel::AddCustomContentType(const std::string & sExtension, const std::string & sContentType) + { + CheckError(lib3mf_model_addcustomcontenttype(m_pHandle, sExtension.c_str(), sContentType.c_str())); + } + + /** + * CModel::RemoveCustomContentType - Removes a custom Content Type from the model (UTF8 version). + * @param[in] sExtension - File Extension + */ + void CModel::RemoveCustomContentType(const std::string & sExtension) + { + CheckError(lib3mf_model_removecustomcontenttype(m_pHandle, sExtension.c_str())); + } + + /** + * CModel::SetRandomNumberCallback - Sets the random number generator callback for use in the library + * @param[in] pTheCallback - The callback used to generate random numbers + * @param[in] pUserData - Userdata to be passed to the callback function + */ + void CModel::SetRandomNumberCallback(const RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData) + { + CheckError(lib3mf_model_setrandomnumbercallback(m_pHandle, pTheCallback, pUserData)); + } + + /** + * CModel::GetKeyStore - Gets the keystore associated with this model + * @return The package keystore + */ + PKeyStore CModel::GetKeyStore() + { + Lib3MFHandle hKeyStore = nullptr; + CheckError(lib3mf_model_getkeystore(m_pHandle, &hKeyStore)); + + if (!hKeyStore) { + CheckError(LIB3MF_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hKeyStore); + } + +} // namespace Lib3MF + +#endif // __LIB3MF_CPPHEADER_IMPLICIT_CPP + diff --git a/lib3mf/Include/lib3mf_types.hpp b/lib3mf/Include/lib3mf_types.hpp new file mode 100644 index 0000000..c13c034 --- /dev/null +++ b/lib3mf/Include/lib3mf_types.hpp @@ -0,0 +1,502 @@ +/*++ + +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. + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. + +Abstract: This is an autogenerated C++-Header file with basic types in +order to allow an easy use of the 3MF Library + +Interface version: 2.2.0 + +*/ + +#ifndef __LIB3MF_TYPES_HEADER_CPP +#define __LIB3MF_TYPES_HEADER_CPP + + +/************************************************************************************************************************* + Scalar types definition +**************************************************************************************************************************/ + +#ifdef LIB3MF_USELEGACYINTEGERTYPES + +typedef unsigned char Lib3MF_uint8; +typedef unsigned short Lib3MF_uint16 ; +typedef unsigned int Lib3MF_uint32; +typedef unsigned long long Lib3MF_uint64; +typedef char Lib3MF_int8; +typedef short Lib3MF_int16; +typedef int Lib3MF_int32; +typedef long long Lib3MF_int64; + +#else // LIB3MF_USELEGACYINTEGERTYPES + +#include + +typedef uint8_t Lib3MF_uint8; +typedef uint16_t Lib3MF_uint16; +typedef uint32_t Lib3MF_uint32; +typedef uint64_t Lib3MF_uint64; +typedef int8_t Lib3MF_int8; +typedef int16_t Lib3MF_int16; +typedef int32_t Lib3MF_int32; +typedef int64_t Lib3MF_int64 ; + +#endif // LIB3MF_USELEGACYINTEGERTYPES + +typedef float Lib3MF_single; +typedef double Lib3MF_double; + +/************************************************************************************************************************* + General type definitions +**************************************************************************************************************************/ + +typedef Lib3MF_int32 Lib3MFResult; +typedef void * Lib3MFHandle; +typedef void * Lib3MF_pvoid; + +/************************************************************************************************************************* + Version for Lib3MF +**************************************************************************************************************************/ + +#define LIB3MF_VERSION_MAJOR 2 +#define LIB3MF_VERSION_MINOR 2 +#define LIB3MF_VERSION_MICRO 0 +#define LIB3MF_VERSION_PRERELEASEINFO "" +#define LIB3MF_VERSION_BUILDINFO "" + +/************************************************************************************************************************* + Error constants for Lib3MF +**************************************************************************************************************************/ + +#define LIB3MF_SUCCESS 0 +#define LIB3MF_ERROR_NOTIMPLEMENTED 1 +#define LIB3MF_ERROR_INVALIDPARAM 2 +#define LIB3MF_ERROR_INVALIDCAST 3 +#define LIB3MF_ERROR_BUFFERTOOSMALL 4 +#define LIB3MF_ERROR_GENERICEXCEPTION 5 +#define LIB3MF_ERROR_COULDNOTLOADLIBRARY 6 +#define LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT 7 +#define LIB3MF_ERROR_INCOMPATIBLEBINARYVERSION 8 +#define LIB3MF_ERROR_CALCULATIONABORTED 10 +#define LIB3MF_ERROR_SHOULDNOTBECALLED 11 +#define LIB3MF_ERROR_READERCLASSUNKNOWN 100 +#define LIB3MF_ERROR_WRITERCLASSUNKNOWN 101 +#define LIB3MF_ERROR_ITERATORINVALIDINDEX 102 +#define LIB3MF_ERROR_INVALIDMODELRESOURCE 103 +#define LIB3MF_ERROR_RESOURCENOTFOUND 104 +#define LIB3MF_ERROR_INVALIDMODEL 105 +#define LIB3MF_ERROR_INVALIDOBJECT 106 +#define LIB3MF_ERROR_INVALIDMESHOBJECT 107 +#define LIB3MF_ERROR_INVALIDCOMPONENTSOBJECT 108 +#define LIB3MF_ERROR_INVALIDCOMPONENT 109 +#define LIB3MF_ERROR_INVALIDBUILDITEM 110 +#define LIB3MF_ERROR_INVALIDBASEMATERIALGROUP 111 +#define LIB3MF_ERROR_INVALIDSLICESTACKRESOURCE 112 +#define LIB3MF_ERROR_INVALIDTEXTURERESOURCE 113 +#define LIB3MF_ERROR_INVALIDCOLORGROUP 114 +#define LIB3MF_ERROR_INVALIDTEXTURE2DGROUP 115 +#define LIB3MF_ERROR_INVALIDCOMPOSITEMATERIALS 116 +#define LIB3MF_ERROR_INVALIDMULTIPROPERTYGROUP 117 +#define LIB3MF_ERROR_INVALIDRESOURCEINDEX 120 +#define LIB3MF_ERROR_ATTACHMENTNOTFOUND 121 +#define LIB3MF_ERROR_FORBIDDENCYCLICREFERENCE 130 +#define LIB3MF_ERROR_INVALIDATTACHMENTSTREAM 131 +#define LIB3MF_ERROR_INVALIDPROPERTYCOUNT 132 +#define LIB3MF_ERROR_UNKOWNPROGRESSIDENTIFIER 140 +#define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 +#define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 +#define LIB3MF_ERROR_INVALIDKEYSTORE 3000 +#define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 +#define LIB3MF_ERROR_KEYSTORECONSUMERNOTFOUND 3002 +#define LIB3MF_ERROR_KEYSTORERESOURCEDATANOTFOUND 3003 +#define LIB3MF_ERROR_SECURECONTEXTNOTREGISTERED 3004 + +/************************************************************************************************************************* + Declaration of handle classes +**************************************************************************************************************************/ + +typedef Lib3MFHandle Lib3MF_Base; +typedef Lib3MFHandle Lib3MF_Writer; +typedef Lib3MFHandle Lib3MF_Reader; +typedef Lib3MFHandle Lib3MF_PackagePart; +typedef Lib3MFHandle Lib3MF_Resource; +typedef Lib3MFHandle Lib3MF_ResourceIterator; +typedef Lib3MFHandle Lib3MF_SliceStackIterator; +typedef Lib3MFHandle Lib3MF_ObjectIterator; +typedef Lib3MFHandle Lib3MF_MeshObjectIterator; +typedef Lib3MFHandle Lib3MF_ComponentsObjectIterator; +typedef Lib3MFHandle Lib3MF_Texture2DIterator; +typedef Lib3MFHandle Lib3MF_BaseMaterialGroupIterator; +typedef Lib3MFHandle Lib3MF_ColorGroupIterator; +typedef Lib3MFHandle Lib3MF_Texture2DGroupIterator; +typedef Lib3MFHandle Lib3MF_CompositeMaterialsIterator; +typedef Lib3MFHandle Lib3MF_MultiPropertyGroupIterator; +typedef Lib3MFHandle Lib3MF_MetaData; +typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_Object; +typedef Lib3MFHandle Lib3MF_MeshObject; +typedef Lib3MFHandle Lib3MF_BeamLattice; +typedef Lib3MFHandle Lib3MF_Component; +typedef Lib3MFHandle Lib3MF_ComponentsObject; +typedef Lib3MFHandle Lib3MF_BeamSet; +typedef Lib3MFHandle Lib3MF_BaseMaterialGroup; +typedef Lib3MFHandle Lib3MF_ColorGroup; +typedef Lib3MFHandle Lib3MF_Texture2DGroup; +typedef Lib3MFHandle Lib3MF_CompositeMaterials; +typedef Lib3MFHandle Lib3MF_MultiPropertyGroup; +typedef Lib3MFHandle Lib3MF_Attachment; +typedef Lib3MFHandle Lib3MF_Texture2D; +typedef Lib3MFHandle Lib3MF_BuildItem; +typedef Lib3MFHandle Lib3MF_BuildItemIterator; +typedef Lib3MFHandle Lib3MF_Slice; +typedef Lib3MFHandle Lib3MF_SliceStack; +typedef Lib3MFHandle Lib3MF_Consumer; +typedef Lib3MFHandle Lib3MF_AccessRight; +typedef Lib3MFHandle Lib3MF_ContentEncryptionParams; +typedef Lib3MFHandle Lib3MF_ResourceData; +typedef Lib3MFHandle Lib3MF_ResourceDataGroup; +typedef Lib3MFHandle Lib3MF_KeyStore; +typedef Lib3MFHandle Lib3MF_Model; + +namespace Lib3MF { + + /************************************************************************************************************************* + Declaration of enums + **************************************************************************************************************************/ + + enum class ePropertyType : Lib3MF_int32 { + NoPropertyType = 0, + BaseMaterial = 1, + TexCoord = 2, + Colors = 3, + Composite = 4, + Multi = 5 + }; + + enum class eSlicesMeshResolution : Lib3MF_int32 { + Fullres = 0, + Lowres = 1 + }; + + enum class eModelUnit : Lib3MF_int32 { + MicroMeter = 0, + MilliMeter = 1, + CentiMeter = 2, + Inch = 3, + Foot = 4, + Meter = 5 + }; + + enum class eObjectType : Lib3MF_int32 { + Other = 0, + Model = 1, + Support = 2, + SolidSupport = 3 + }; + + enum class eTextureType : Lib3MF_int32 { + Unknown = 0, + PNG = 1, + JPEG = 2 + }; + + enum class eTextureTileStyle : Lib3MF_int32 { + Wrap = 0, + Mirror = 1, + Clamp = 2, + NoTileStyle = 3 + }; + + enum class eTextureFilter : Lib3MF_int32 { + Auto = 0, + Linear = 1, + Nearest = 2 + }; + + enum class eBeamLatticeCapMode : Lib3MF_int32 { + Sphere = 0, + HemiSphere = 1, + Butt = 2 + }; + + enum class eBeamLatticeClipMode : Lib3MF_int32 { + NoClipMode = 0, + Inside = 1, + Outside = 2 + }; + + enum class eBeamLatticeBallMode : Lib3MF_int32 { + None = 0, + Mixed = 1, + All = 2 + }; + + enum class eProgressIdentifier : Lib3MF_int32 { + QUERYCANCELED = 0, + DONE = 1, + CLEANUP = 2, + READSTREAM = 3, + EXTRACTOPCPACKAGE = 4, + READNONROOTMODELS = 5, + READROOTMODEL = 6, + READRESOURCES = 7, + READMESH = 8, + READSLICES = 9, + READBUILD = 10, + READCUSTOMATTACHMENT = 11, + READTEXTURETACHMENTS = 12, + CREATEOPCPACKAGE = 13, + WRITEMODELSTOSTREAM = 14, + WRITEROOTMODEL = 15, + WRITENONROOTMODELS = 16, + WRITEATTACHMENTS = 17, + WRITECONTENTTYPES = 18, + WRITENOBJECTS = 19, + WRITENODES = 20, + WRITETRIANGLES = 21, + WRITESLICES = 22, + WRITEKEYSTORE = 23 + }; + + enum class eBlendMethod : Lib3MF_int32 { + NoBlendMethod = 0, + Mix = 1, + Multiply = 2 + }; + + enum class eEncryptionAlgorithm : Lib3MF_int32 { + AES256_GCM = 1 + }; + + enum class eWrappingAlgorithm : Lib3MF_int32 { + RSA_OAEP = 0 + }; + + enum class eMgfAlgorithm : Lib3MF_int32 { + MGF1_SHA1 = 160, + MGF1_SHA224 = 224, + MGF1_SHA256 = 256, + MGF1_SHA384 = 384, + MGF1_SHA512 = 512 + }; + + enum class eDigestMethod : Lib3MF_int32 { + SHA1 = 160, + SHA256 = 256 + }; + + enum class eCompression : Lib3MF_int32 { + NoCompression = 0, + Deflate = 1 + }; + + /************************************************************************************************************************* + Declaration of structs + **************************************************************************************************************************/ + + #pragma pack (1) + + typedef struct { + Lib3MF_uint32 m_Indices[3]; + } sTriangle; + + typedef struct { + Lib3MF_uint32 m_ResourceID; + Lib3MF_uint32 m_PropertyIDs[3]; + } sTriangleProperties; + + typedef struct { + Lib3MF_single m_Coordinates[3]; + } sPosition; + + typedef struct { + Lib3MF_single m_Coordinates[2]; + } sPosition2D; + + typedef struct { + Lib3MF_uint32 m_PropertyID; + Lib3MF_double m_MixingRatio; + } sCompositeConstituent; + + typedef struct { + Lib3MF_uint32 m_ResourceID; + eBlendMethod m_TheBlendMethod; + } sMultiPropertyLayer; + + typedef struct { + Lib3MF_double m_U; + Lib3MF_double m_V; + } sTex2Coord; + + typedef struct { + Lib3MF_single m_Fields[4][3]; + } sTransform; + + typedef struct { + Lib3MF_single m_MinCoordinate[3]; + Lib3MF_single m_MaxCoordinate[3]; + } sBox; + + typedef struct { + Lib3MF_uint8 m_Red; + Lib3MF_uint8 m_Green; + Lib3MF_uint8 m_Blue; + Lib3MF_uint8 m_Alpha; + } sColor; + + typedef struct { + Lib3MF_uint32 m_Indices[2]; + Lib3MF_double m_Radii[2]; + eBeamLatticeCapMode m_CapModes[2]; + } sBeam; + + typedef struct { + Lib3MF_uint32 m_Index; + Lib3MF_double m_Radius; + } sBall; + + #pragma pack () + + /************************************************************************************************************************* + Declaration of function pointers + **************************************************************************************************************************/ + + /** + * ProgressCallback - A callback function + * + * @param[out] pAbort - Returns whether the calculation should be aborted + * @param[in] dProgressValue - The value of the progress function: values in the interval [0,1] are progress; < mean no progress update + * @param[in] eProgressIdentifier - An identifier of progress + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*ProgressCallback)(bool *, Lib3MF_double, Lib3MF::eProgressIdentifier, Lib3MF_pvoid); + + /** + * WriteCallback - Callback to call for writing a data chunk + * + * @param[in] nByteData - Pointer to the data to be written + * @param[in] nNumBytes - Number of bytes to write + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*WriteCallback)(Lib3MF_uint64, Lib3MF_uint64, Lib3MF_pvoid); + + /** + * ReadCallback - Callback to call for reading a data chunk + * + * @param[in] nByteData - Pointer to a buffer to read data into + * @param[in] nNumBytes - Number of bytes to read + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*ReadCallback)(Lib3MF_uint64, Lib3MF_uint64, Lib3MF_pvoid); + + /** + * SeekCallback - Callback to call for seeking in the stream + * + * @param[in] nPosition - Position in the stream to move to + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*SeekCallback)(Lib3MF_uint64, Lib3MF_pvoid); + + /** + * RandomNumberCallback - Callback to generate random numbers + * + * @param[in] nByteData - Pointer to a buffer to read data into + * @param[in] nNumBytes - Size of available bytes in the buffer + * @param[in] pUserData - Userdata that is passed to the callback function + * @param[out] pBytesWritten - Number of bytes generated when succeed. 0 or less if failed. + */ + typedef void(*RandomNumberCallback)(Lib3MF_uint64, Lib3MF_uint64, Lib3MF_pvoid, Lib3MF_uint64 *); + + /** + * KeyWrappingCallback - A callback used to wrap (encrypt) the content key available in keystore resource group + * + * @param[in] pKEKParams - The information about the parameters used used to wrap the key to the contents + * @param[in] nInBufferBufferSize - Number of elements in buffer + * @param[in] pInBufferBuffer - uint8 buffer of Buffer to the input value. When encrypting, this should be the plain key. When decrypting, this should be the key cipher. + * @param[in] nOutBufferBufferSize - Number of elements in buffer + * @param[out] pOutBufferNeededCount - will be filled with the count of the written elements, or needed buffer size. + * @param[out] pOutBufferBuffer - uint8 buffer of Buffer where the data will be placed. When encrypting, this will be the key cipher. When decrypting, this will be the plain key. When buffer is null, neededBytes contains the required bytes to run. + * @param[in] pUserData - Userdata that is passed to the callback function + * @param[out] pStatus - The needed/encrypted/decrypted bytes when succeed or zero when error. + */ + typedef void(*KeyWrappingCallback)(Lib3MF_AccessRight, Lib3MF_uint64, const Lib3MF_uint8 *, const Lib3MF_uint64, Lib3MF_uint64*, Lib3MF_uint8 *, Lib3MF_pvoid, Lib3MF_uint64 *); + + /** + * ContentEncryptionCallback - A callback to encrypt/decrypt content called on each resource encrypted. This might be called several times depending on content size. If Input is not available(either null or size is 0), clients must return the result of authenticated tag generation/validation. + * + * @param[in] pCEKParams - The params of the encryption process. Client must set/check AuthenticationTag when closing the encryption/decryption process. + * @param[in] nInputBufferSize - Number of elements in buffer + * @param[in] pInputBuffer - uint8 buffer of Buffer to the original data. In encrypting, this will be the plain data. If decrypting, this will be the cipher data + * @param[in] nOutputBufferSize - Number of elements in buffer + * @param[out] pOutputNeededCount - will be filled with the count of the written elements, or needed buffer size. + * @param[out] pOutputBuffer - uint8 buffer of Buffer to hold the transformed data. When encrypting, this will be the cipher data. When decrypting, this shall be the plain data. If buffer is null, neededBytes return the necessary amount of bytes. + * @param[in] pUserData - Userdata that is passed to the callback function + * @param[out] pStatus - The needed/encrypted/decrypted/verified bytes when succeed or zero when error. + */ + typedef void(*ContentEncryptionCallback)(Lib3MF_ContentEncryptionParams, Lib3MF_uint64, const Lib3MF_uint8 *, const Lib3MF_uint64, Lib3MF_uint64*, Lib3MF_uint8 *, Lib3MF_pvoid, Lib3MF_uint64 *); + +} // namespace Lib3MF; + +// define legacy C-names for enums, structs and function types +typedef Lib3MF::ePropertyType eLib3MFPropertyType; +typedef Lib3MF::eSlicesMeshResolution eLib3MFSlicesMeshResolution; +typedef Lib3MF::eModelUnit eLib3MFModelUnit; +typedef Lib3MF::eObjectType eLib3MFObjectType; +typedef Lib3MF::eTextureType eLib3MFTextureType; +typedef Lib3MF::eTextureTileStyle eLib3MFTextureTileStyle; +typedef Lib3MF::eTextureFilter eLib3MFTextureFilter; +typedef Lib3MF::eBeamLatticeCapMode eLib3MFBeamLatticeCapMode; +typedef Lib3MF::eBeamLatticeClipMode eLib3MFBeamLatticeClipMode; +typedef Lib3MF::eBeamLatticeBallMode eLib3MFBeamLatticeBallMode; +typedef Lib3MF::eProgressIdentifier eLib3MFProgressIdentifier; +typedef Lib3MF::eBlendMethod eLib3MFBlendMethod; +typedef Lib3MF::eEncryptionAlgorithm eLib3MFEncryptionAlgorithm; +typedef Lib3MF::eWrappingAlgorithm eLib3MFWrappingAlgorithm; +typedef Lib3MF::eMgfAlgorithm eLib3MFMgfAlgorithm; +typedef Lib3MF::eDigestMethod eLib3MFDigestMethod; +typedef Lib3MF::eCompression eLib3MFCompression; +typedef Lib3MF::sTriangle sLib3MFTriangle; +typedef Lib3MF::sTriangleProperties sLib3MFTriangleProperties; +typedef Lib3MF::sPosition sLib3MFPosition; +typedef Lib3MF::sPosition2D sLib3MFPosition2D; +typedef Lib3MF::sCompositeConstituent sLib3MFCompositeConstituent; +typedef Lib3MF::sMultiPropertyLayer sLib3MFMultiPropertyLayer; +typedef Lib3MF::sTex2Coord sLib3MFTex2Coord; +typedef Lib3MF::sTransform sLib3MFTransform; +typedef Lib3MF::sBox sLib3MFBox; +typedef Lib3MF::sColor sLib3MFColor; +typedef Lib3MF::sBeam sLib3MFBeam; +typedef Lib3MF::sBall sLib3MFBall; +typedef Lib3MF::ProgressCallback Lib3MFProgressCallback; +typedef Lib3MF::WriteCallback Lib3MFWriteCallback; +typedef Lib3MF::ReadCallback Lib3MFReadCallback; +typedef Lib3MF::SeekCallback Lib3MFSeekCallback; +typedef Lib3MF::RandomNumberCallback Lib3MFRandomNumberCallback; +typedef Lib3MF::KeyWrappingCallback Lib3MFKeyWrappingCallback; +typedef Lib3MF::ContentEncryptionCallback Lib3MFContentEncryptionCallback; + +#endif // __LIB3MF_TYPES_HEADER_CPP diff --git a/lib3mf/Lib/lib3mfD32.lib b/lib3mf/Lib/lib3mfD32.lib new file mode 100644 index 0000000..a8d5464 Binary files /dev/null and b/lib3mf/Lib/lib3mfD32.lib differ diff --git a/lib3mf/Lib/lib3mfD32.pdb b/lib3mf/Lib/lib3mfD32.pdb new file mode 100644 index 0000000..6f61afd Binary files /dev/null and b/lib3mf/Lib/lib3mfD32.pdb differ diff --git a/lib3mf/Lib/lib3mfD64.lib b/lib3mf/Lib/lib3mfD64.lib new file mode 100644 index 0000000..2f553b8 Binary files /dev/null and b/lib3mf/Lib/lib3mfD64.lib differ diff --git a/lib3mf/Lib/lib3mfD64.pdb b/lib3mf/Lib/lib3mfD64.pdb new file mode 100644 index 0000000..1367005 Binary files /dev/null and b/lib3mf/Lib/lib3mfD64.pdb differ diff --git a/lib3mf/Lib/lib3mfR32.lib b/lib3mf/Lib/lib3mfR32.lib new file mode 100644 index 0000000..a454401 Binary files /dev/null and b/lib3mf/Lib/lib3mfR32.lib differ diff --git a/lib3mf/Lib/lib3mfR64.lib b/lib3mf/Lib/lib3mfR64.lib new file mode 100644 index 0000000..1c931d1 Binary files /dev/null and b/lib3mf/Lib/lib3mfR64.lib differ