diff --git a/Include/API/lib3mf_absnode.hpp b/Include/API/lib3mf_absnode.hpp new file mode 100644 index 0000000..e2fddf1 --- /dev/null +++ b/Include/API/lib3mf_absnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CAbsNode + +*/ + + +#ifndef __LIB3MF_ABSNODE +#define __LIB3MF_ABSNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CAbsNode +**************************************************************************************************************************/ + +class CAbsNode : public virtual IAbsNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CAbsNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ABSNODE diff --git a/Include/API/lib3mf_accessright.hpp b/Include/API/lib3mf_accessright.hpp index a1e8fe6..1c655ee 100644 --- a/Include/API/lib3mf_accessright.hpp +++ b/Include/API/lib3mf_accessright.hpp @@ -56,13 +56,13 @@ namespace Lib3MF { CAccessRight(NMR::PKeyStoreAccessRight ar); // Inherited via IAccessRight - virtual IConsumer * GetConsumer() override; + IConsumer * GetConsumer() override; - virtual Lib3MF::eWrappingAlgorithm GetWrappingAlgorithm(); + Lib3MF::eWrappingAlgorithm GetWrappingAlgorithm() override; - virtual Lib3MF::eMgfAlgorithm GetMgfAlgorithm(); + Lib3MF::eMgfAlgorithm GetMgfAlgorithm() override; - virtual Lib3MF::eDigestMethod GetDigestMethod(); + Lib3MF::eDigestMethod GetDigestMethod() override; // Other access methods NMR::PKeyStoreAccessRight accessRight() const; diff --git a/Include/API/lib3mf_additionnode.hpp b/Include/API/lib3mf_additionnode.hpp new file mode 100644 index 0000000..e1f1038 --- /dev/null +++ b/Include/API/lib3mf_additionnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CAdditionNode + +*/ + + +#ifndef __LIB3MF_ADDITIONNODE +#define __LIB3MF_ADDITIONNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CAdditionNode +**************************************************************************************************************************/ + +class CAdditionNode : public virtual IAdditionNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CAdditionNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ADDITIONNODE diff --git a/Include/API/lib3mf_arccosnode.hpp b/Include/API/lib3mf_arccosnode.hpp new file mode 100644 index 0000000..2619ddf --- /dev/null +++ b/Include/API/lib3mf_arccosnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CArcCosNode + +*/ + + +#ifndef __LIB3MF_ARCCOSNODE +#define __LIB3MF_ARCCOSNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CArcCosNode +**************************************************************************************************************************/ + +class CArcCosNode : public virtual IArcCosNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + /** + * Put protected members here. + */ + +public: + CArcCosNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ARCCOSNODE diff --git a/Include/API/lib3mf_arcsinnode.hpp b/Include/API/lib3mf_arcsinnode.hpp new file mode 100644 index 0000000..b80b7f8 --- /dev/null +++ b/Include/API/lib3mf_arcsinnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CArcSinNode + +*/ + + +#ifndef __LIB3MF_ARCSINNODE +#define __LIB3MF_ARCSINNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CArcSinNode +**************************************************************************************************************************/ + +class CArcSinNode : public virtual IArcSinNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + /** + * Put protected members here. + */ + +public: + CArcSinNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ARCSINNODE diff --git a/Include/API/lib3mf_arctan2node.hpp b/Include/API/lib3mf_arctan2node.hpp new file mode 100644 index 0000000..a808736 --- /dev/null +++ b/Include/API/lib3mf_arctan2node.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CArcTan2Node + +*/ + + +#ifndef __LIB3MF_ARCTAN2NODE +#define __LIB3MF_ARCTAN2NODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CArcTan2Node +**************************************************************************************************************************/ + +class CArcTan2Node : public virtual IArcTan2Node, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CArcTan2Node(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ARCTAN2NODE diff --git a/Include/API/lib3mf_arctannode.hpp b/Include/API/lib3mf_arctannode.hpp new file mode 100644 index 0000000..469f660 --- /dev/null +++ b/Include/API/lib3mf_arctannode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CArcTanNode + +*/ + + +#ifndef __LIB3MF_ARCTANNODE +#define __LIB3MF_ARCTANNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CArcTanNode +**************************************************************************************************************************/ + +class CArcTanNode : public virtual IArcTanNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CArcTanNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ARCTANNODE diff --git a/Include/API/lib3mf_attachment.hpp b/Include/API/lib3mf_attachment.hpp index 1c3bfa7..b2f69a3 100644 --- a/Include/API/lib3mf_attachment.hpp +++ b/Include/API/lib3mf_attachment.hpp @@ -97,6 +97,8 @@ public: void ReadFromBuffer(const Lib3MF_uint64 nBufferBufferSize, const Lib3MF_uint8 * pBufferBuffer); + NMR::PModelAttachment getModelAttachment (); + }; } diff --git a/Include/API/lib3mf_base.hpp b/Include/API/lib3mf_base.hpp index a22a641..069e23a 100644 --- a/Include/API/lib3mf_base.hpp +++ b/Include/API/lib3mf_base.hpp @@ -71,20 +71,19 @@ public: * Put additional public members here. They will not be visible in the external API. */ - bool GetLastErrorMessage(std::string & sErrorMessage); + bool GetLastErrorMessage(std::string & sErrorMessage) override; - void ClearErrorMessages(); + void ClearErrorMessages() override; - void RegisterErrorMessage(const std::string & sErrorMessage); + void RegisterErrorMessage(const std::string & sErrorMessage) override; - void IncRefCount(); + void IncRefCount() override; - bool DecRefCount(); + bool DecRefCount() override; /** * Public member functions to implement. */ - }; } // namespace Impl diff --git a/Include/API/lib3mf_basematerialgroupiterator.hpp b/Include/API/lib3mf_basematerialgroupiterator.hpp index 25a0aee..30ecc42 100644 --- a/Include/API/lib3mf_basematerialgroupiterator.hpp +++ b/Include/API/lib3mf_basematerialgroupiterator.hpp @@ -76,7 +76,9 @@ public: * Public member functions to implement. */ - IBaseMaterialGroup * GetCurrentBaseMaterialGroup (); + IBaseMaterialGroup * GetCurrentBaseMaterialGroup() override; + + IResource * GetCurrent() override; }; diff --git a/Include/API/lib3mf_beamlatticenode.hpp b/Include/API/lib3mf_beamlatticenode.hpp new file mode 100644 index 0000000..fcaf4ac --- /dev/null +++ b/Include/API/lib3mf_beamlatticenode.hpp @@ -0,0 +1,98 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CBeamLatticeNode + +*/ + + +#ifndef __LIB3MF_BEAMLATTICENODE +#define __LIB3MF_BEAMLATTICENODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CBeamLatticeNode +**************************************************************************************************************************/ + +class CBeamLatticeNode : public virtual IBeamLatticeNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + CBeamLatticeNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Public member functions to implement. + */ + + IImplicitPort * GetInputBeamLattice() override; + + IImplicitPort * GetInputPos() override; + + IImplicitPort * GetOutputDistance() override; + + void SetAccurateRange(const Lib3MF_double dAccurateRange) override; + + Lib3MF_double GetAccurateRange() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_BEAMLATTICENODE diff --git a/Include/API/lib3mf_ceilnode.hpp b/Include/API/lib3mf_ceilnode.hpp new file mode 100644 index 0000000..3cf09ae --- /dev/null +++ b/Include/API/lib3mf_ceilnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CCeilNode + +*/ + + +#ifndef __LIB3MF_CEILNODE +#define __LIB3MF_CEILNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CCeilNode +**************************************************************************************************************************/ + +class CCeilNode : public virtual ICeilNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CCeilNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_CEILNODE diff --git a/Include/API/lib3mf_clampnode.hpp b/Include/API/lib3mf_clampnode.hpp new file mode 100644 index 0000000..23f2361 --- /dev/null +++ b/Include/API/lib3mf_clampnode.hpp @@ -0,0 +1,99 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CClampNode + +*/ + + +#ifndef __LIB3MF_CLAMPNODE +#define __LIB3MF_CLAMPNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CClampNode +**************************************************************************************************************************/ + +class CClampNode : public virtual IClampNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CClampNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IClampNode::GetInputMin - Retrieves the input for the lower limit + * @return the input for the lower limit + */ + IImplicitPort * GetInputMin() override; + + /** + * IClampNode::GetInputMax - Retrieves the input for the upper limit + * @return the input for the upper limit + */ + IImplicitPort * GetInputMax() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_CLAMPNODE diff --git a/Include/API/lib3mf_colorgroupiterator.hpp b/Include/API/lib3mf_colorgroupiterator.hpp index 0187a9a..223ff8f 100644 --- a/Include/API/lib3mf_colorgroupiterator.hpp +++ b/Include/API/lib3mf_colorgroupiterator.hpp @@ -76,7 +76,9 @@ public: * Public member functions to implement. */ - IColorGroup * GetCurrentColorGroup (); + IColorGroup * GetCurrentColorGroup() override; + + IResource * GetCurrent() override; }; diff --git a/Include/API/lib3mf_componentsobject.hpp b/Include/API/lib3mf_componentsobject.hpp index 83f2cff..2206a25 100644 --- a/Include/API/lib3mf_componentsobject.hpp +++ b/Include/API/lib3mf_componentsobject.hpp @@ -86,6 +86,7 @@ public: bool IsComponentsObject(); + bool IsLevelSetObject() override; }; } diff --git a/Include/API/lib3mf_componentsobjectiterator.hpp b/Include/API/lib3mf_componentsobjectiterator.hpp index 5229c2c..7444c65 100644 --- a/Include/API/lib3mf_componentsobjectiterator.hpp +++ b/Include/API/lib3mf_componentsobjectiterator.hpp @@ -76,7 +76,7 @@ public: * Public member functions to implement. */ - IComponentsObject * GetCurrentComponentsObject (); + IComponentsObject * GetCurrentComponentsObject() override; }; diff --git a/Include/API/lib3mf_composematrixnode.hpp b/Include/API/lib3mf_composematrixnode.hpp new file mode 100644 index 0000000..24d9c2b --- /dev/null +++ b/Include/API/lib3mf_composematrixnode.hpp @@ -0,0 +1,190 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CComposeMatrixNode + +*/ + + +#ifndef __LIB3MF_COMPOSEMATRIXNODE +#define __LIB3MF_COMPOSEMATRIXNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CComposeMatrixNode +**************************************************************************************************************************/ + +class CComposeMatrixNode : public virtual IComposeMatrixNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CComposeMatrixNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IComposeMatrixNode::GetInputM00 - Retrieves the input for the element 0 0 + * @return the input for the m00 element + */ + IImplicitPort * GetInputM00() override; + + /** + * IComposeMatrixNode::GetInputM01 - Retrieves the input for the element 0 1 + * @return the input for the m01 element + */ + IImplicitPort * GetInputM01() override; + + /** + * IComposeMatrixNode::GetInputM02 - Retrieves the input for the element 0 2 + * @return the input for the m02 element + */ + IImplicitPort * GetInputM02() override; + + /** + * IComposeMatrixNode::GetInputM03 - Retrieves the input for the element 0 3 + * @return the input for the m03 element + */ + IImplicitPort * GetInputM03() override; + + /** + * IComposeMatrixNode::GetInputM10 - Retrieves the input for the element 1 0 + * @return the input for the m10 element + */ + IImplicitPort * GetInputM10() override; + + /** + * IComposeMatrixNode::GetInputM11 - Retrieves the input for the element 1 1 + * @return the input for the m11 element + */ + IImplicitPort * GetInputM11() override; + + /** + * IComposeMatrixNode::GetInputM12 - Retrieves the input for the element 1 2 + * @return the input for the m12 element + */ + IImplicitPort * GetInputM12() override; + + /** + * IComposeMatrixNode::GetInputM13 - Retrieves the input for the element 1 3 + * @return the input for the m3 element + */ + IImplicitPort * GetInputM13() override; + + /** + * IComposeMatrixNode::GetInputM20 - Retrieves the input for the element 2 0 + * @return the input for the m2 element + */ + IImplicitPort * GetInputM20() override; + + /** + * IComposeMatrixNode::GetInputM21 - Retrieves the input for the element 2 1 + * @return + */ + IImplicitPort * GetInputM21() override; + + /** + * IComposeMatrixNode::GetInputM22 - Retrieves the input for the element 2 2 + * @return the input for the m22 element + */ + IImplicitPort * GetInputM22() override; + + /** + * IComposeMatrixNode::GetInputM23 - Retrieves the input for the element 2 3 + * @return the input for the m23 element + */ + IImplicitPort * GetInputM23() override; + + /** + * IComposeMatrixNode::GetInputM30 - Retrieves the input for the element 3 0 + * @return the input for the m30 element + */ + IImplicitPort * GetInputM30() override; + + /** + * IComposeMatrixNode::GetInputM31 - Retrieves the input for the element 3 1 + * @return the input for the m31 element + */ + IImplicitPort * GetInputM31() override; + + /** + * IComposeMatrixNode::GetInputM32 - Retrieves the input for the element 3 2 + * @return the input for the m32 element + */ + IImplicitPort * GetInputM32() override; + + /** + * IComposeMatrixNode::GetInputM33 - Retrieves the input for the element 3 3 + * @return the input for the m33 element + */ + IImplicitPort * GetInputM33() override; + + /** + * IComposeMatrixNode::GetOutputMatrix - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputResult() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_COMPOSEMATRIXNODE diff --git a/Include/API/lib3mf_composevectornode.hpp b/Include/API/lib3mf_composevectornode.hpp new file mode 100644 index 0000000..b8496bb --- /dev/null +++ b/Include/API/lib3mf_composevectornode.hpp @@ -0,0 +1,111 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CComposeVectorNode + +*/ + + +#ifndef __LIB3MF_COMPOSEVECTORNODE +#define __LIB3MF_COMPOSEVECTORNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CComposeVectorNode +**************************************************************************************************************************/ + +class CComposeVectorNode : public virtual IComposeVectorNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CComposeVectorNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IComposeVectorNode::GetInputX - Retrieves the input for the x component + * @return the input for the x component + */ + IImplicitPort * GetInputX() override; + + /** + * IComposeVectorNode::GetInputY - Retrieves the input for the y component + * @return the input for the y component + */ + IImplicitPort * GetInputY() override; + + /** + * IComposeVectorNode::GetInputZ - Retrieves the input for the z component + * @return the input for the z component + */ + IImplicitPort * GetInputZ() override; + + /** + * IComposeVectorNode::GetOutputVector - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputResult() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_COMPOSEVECTORNODE diff --git a/Include/API/lib3mf_compositematerialsiterator.hpp b/Include/API/lib3mf_compositematerialsiterator.hpp index 6f12527..0448a34 100644 --- a/Include/API/lib3mf_compositematerialsiterator.hpp +++ b/Include/API/lib3mf_compositematerialsiterator.hpp @@ -76,7 +76,9 @@ public: * Public member functions to implement. */ - ICompositeMaterials * GetCurrentCompositeMaterials (); + ICompositeMaterials * GetCurrentCompositeMaterials() override; + + IResource * GetCurrent() override; }; diff --git a/Include/API/lib3mf_constantnode.hpp b/Include/API/lib3mf_constantnode.hpp new file mode 100644 index 0000000..b0aa332 --- /dev/null +++ b/Include/API/lib3mf_constantnode.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CConstantNode + +*/ + + +#ifndef __LIB3MF_CONSTANTNODE +#define __LIB3MF_CONSTANTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CConstantNode +**************************************************************************************************************************/ + +class CConstantNode : public virtual IConstantNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CConstantNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IConstantNode::SetConstant - Sets the constant value of the node + * @param[in] dValue - the value + */ + void SetConstant(const Lib3MF_double dValue) override; + + /** + * IConstantNode::GetConstant - Retrieves the constant value of the node + * @return the value + */ + Lib3MF_double GetConstant() override; + + /** + * IConstantNode::GetOutputValue - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputValue() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_CONSTANTNODE diff --git a/Include/API/lib3mf_constmatnode.hpp b/Include/API/lib3mf_constmatnode.hpp new file mode 100644 index 0000000..95cb78d --- /dev/null +++ b/Include/API/lib3mf_constmatnode.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CConstMatNode + +*/ + + +#ifndef __LIB3MF_CONSTMATNODE +#define __LIB3MF_CONSTMATNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CConstMatNode +**************************************************************************************************************************/ + +class CConstMatNode : public virtual IConstMatNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CConstMatNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IConstMatNode::SetMatrix - Sets the matrix value of the node + * @param[in] Value - the value + */ + void SetMatrix(const Lib3MF::sMatrix4x4 Value) override; + + /** + * IConstMatNode::GetMatrix - Retrieves the matrix value of the node + * @return the matrix + */ + Lib3MF::sMatrix4x4 GetMatrix() override; + + /** + * IConstMatNode::GetOutputMatrix - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputMatrix() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_CONSTMATNODE diff --git a/Include/API/lib3mf_constvecnode.hpp b/Include/API/lib3mf_constvecnode.hpp new file mode 100644 index 0000000..5f6c493 --- /dev/null +++ b/Include/API/lib3mf_constvecnode.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CConstVecNode + +*/ + + +#ifndef __LIB3MF_CONSTVECNODE +#define __LIB3MF_CONSTVECNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CConstVecNode +**************************************************************************************************************************/ + +class CConstVecNode : public virtual IConstVecNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CConstVecNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IConstVecNode::SetVector - Sets the vector value of the node + * @param[in] Value - the value + */ + void SetVector(const Lib3MF::sVector Value) override; + + /** + * IConstVecNode::GetVector - Retrieves the vector value of the node + * @return the value + */ + Lib3MF::sVector GetVector() override; + + /** + * IConstVecNode::GetOutputVector - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputVector() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_CONSTVECNODE diff --git a/Include/API/lib3mf_coshnode.hpp b/Include/API/lib3mf_coshnode.hpp new file mode 100644 index 0000000..b0de53b --- /dev/null +++ b/Include/API/lib3mf_coshnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CCoshNode + +*/ + + +#ifndef __LIB3MF_COSHNODE +#define __LIB3MF_COSHNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CCoshNode +**************************************************************************************************************************/ + +class CCoshNode : public virtual ICoshNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CCoshNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_COSHNODE diff --git a/Include/API/lib3mf_cosnode.hpp b/Include/API/lib3mf_cosnode.hpp new file mode 100644 index 0000000..1128cf7 --- /dev/null +++ b/Include/API/lib3mf_cosnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CCosNode + +*/ + + +#ifndef __LIB3MF_COSNODE +#define __LIB3MF_COSNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CCosNode +**************************************************************************************************************************/ + +class CCosNode : public virtual ICosNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CCosNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_COSNODE diff --git a/Include/API/lib3mf_crossnode.hpp b/Include/API/lib3mf_crossnode.hpp new file mode 100644 index 0000000..13d5a70 --- /dev/null +++ b/Include/API/lib3mf_crossnode.hpp @@ -0,0 +1,88 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CCrossNode + +*/ + + +#ifndef __LIB3MF_CROSSNODE +#define __LIB3MF_CROSSNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CCrossNode +**************************************************************************************************************************/ + +class CCrossNode : public virtual ICrossNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CCrossNode() = delete; + CCrossNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_CROSSNODE diff --git a/Include/API/lib3mf_decomposevectornode.hpp b/Include/API/lib3mf_decomposevectornode.hpp new file mode 100644 index 0000000..070ca9d --- /dev/null +++ b/Include/API/lib3mf_decomposevectornode.hpp @@ -0,0 +1,111 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CDecomposeVectorNode + +*/ + + +#ifndef __LIB3MF_DECOMPOSEVECTORNODE +#define __LIB3MF_DECOMPOSEVECTORNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CDecomposeVectorNode +**************************************************************************************************************************/ + +class CDecomposeVectorNode : public virtual IDecomposeVectorNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CDecomposeVectorNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IDecomposeVectorNode::GetInputVector - Retrieves the input + * @return the input + */ + IImplicitPort * GetInputA() override; + + /** + * IDecomposeVectorNode::GetOutputX - Retrieves the output for the x component + * @return the output for the x component + */ + IImplicitPort * GetOutputX() override; + + /** + * IDecomposeVectorNode::GetOutputY - Retrieves the output for the y component + * @return the output for the y component + */ + IImplicitPort * GetOutputY() override; + + /** + * IDecomposeVectorNode::GetOutputZ - Retrieves the output for the z component + * @return the output for the z component + */ + IImplicitPort * GetOutputZ() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_DECOMPOSEVECTORNODE diff --git a/Include/API/lib3mf_divisionnode.hpp b/Include/API/lib3mf_divisionnode.hpp new file mode 100644 index 0000000..0e23bf4 --- /dev/null +++ b/Include/API/lib3mf_divisionnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CDivisionNode + +*/ + + +#ifndef __LIB3MF_DIVISIONNODE +#define __LIB3MF_DIVISIONNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CDivisionNode +**************************************************************************************************************************/ + +class CDivisionNode : public virtual IDivisionNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CDivisionNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_DIVISIONNODE diff --git a/Include/API/lib3mf_dotnode.hpp b/Include/API/lib3mf_dotnode.hpp new file mode 100644 index 0000000..32951f0 --- /dev/null +++ b/Include/API/lib3mf_dotnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CDotNode + +*/ + + +#ifndef __LIB3MF_DOTNODE +#define __LIB3MF_DOTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CDotNode +**************************************************************************************************************************/ + +class CDotNode : public virtual IDotNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CDotNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_DOTNODE diff --git a/Include/API/lib3mf_expnode.hpp b/Include/API/lib3mf_expnode.hpp new file mode 100644 index 0000000..3b9dae9 --- /dev/null +++ b/Include/API/lib3mf_expnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CExpNode + +*/ + + +#ifndef __LIB3MF_EXPNODE +#define __LIB3MF_EXPNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CExpNode +**************************************************************************************************************************/ + +class CExpNode : public virtual IExpNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CExpNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_EXPNODE diff --git a/Include/API/lib3mf_floornode.hpp b/Include/API/lib3mf_floornode.hpp new file mode 100644 index 0000000..2131506 --- /dev/null +++ b/Include/API/lib3mf_floornode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFloorNode + +*/ + + +#ifndef __LIB3MF_FLOORNODE +#define __LIB3MF_FLOORNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFloorNode +**************************************************************************************************************************/ + +class CFloorNode : public virtual IFloorNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CFloorNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FLOORNODE diff --git a/Include/API/lib3mf_fmodnode.hpp b/Include/API/lib3mf_fmodnode.hpp new file mode 100644 index 0000000..ec99eb5 --- /dev/null +++ b/Include/API/lib3mf_fmodnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFmodNode + +*/ + + +#ifndef __LIB3MF_FMODNODE +#define __LIB3MF_FMODNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFmodNode +**************************************************************************************************************************/ + +class CFmodNode : public virtual IFmodNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CFmodNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FMODNODE diff --git a/Include/API/lib3mf_fractnode.hpp b/Include/API/lib3mf_fractnode.hpp new file mode 100644 index 0000000..d50eb5c --- /dev/null +++ b/Include/API/lib3mf_fractnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFractNode + +*/ + + +#ifndef __LIB3MF_FRACTNODE +#define __LIB3MF_FRACTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFractNode +**************************************************************************************************************************/ + +class CFractNode : public virtual IFractNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CFractNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FRACTNODE diff --git a/Include/API/lib3mf_function.hpp b/Include/API/lib3mf_function.hpp new file mode 100644 index 0000000..3b8f2d7 --- /dev/null +++ b/Include/API/lib3mf_function.hpp @@ -0,0 +1,156 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFunction + +*/ + + +#ifndef __LIB3MF_FUNCTION +#define __LIB3MF_FUNCTION + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_resource.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelFunction.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFunction +**************************************************************************************************************************/ + +class CFunction : public virtual IFunction, public virtual CResource { +private: + /** + * Put private members here. + */ + NMR::CModelFunction* function(); + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CFunction() = delete; + CFunction(NMR::PModelResource pResource); + + /** + * Public member functions to implement. + */ + + /** + * IFunction::GetDisplayName - Retrieves the display name of the function + * @return the display name + */ + std::string GetDisplayName() override; + + /** + * IFunction::SetDisplayName - Sets the display name of the function + * @param[in] sDisplayName - the display name + */ + void SetDisplayName(const std::string & sDisplayName) override; + + /** + * IFunction::AddInput - Add an input + * @param[in] sIdentifier - the identifier of the input + * @param[in] sDisplayName - the display name of the input + * @param[in] eType - the type of the input + * @return The added input port + */ + IImplicitPort * AddInput(const std::string & sIdentifier, const std::string & sDisplayName, const Lib3MF::eImplicitPortType eType) override; + + /** + * IFunction::GetInputs - Retrieves the inputs + * @return iterator for the list of inputs + */ + IImplicitPortIterator * GetInputs() override; + + /** + * IFunction::RemoveInput - Removes an input + * @param[in] pInput - The input to be removed + */ + void RemoveInput(IImplicitPort* pInput) override; + + /** + * IFunction::AddOutput - Add an output + * @param[in] sIdentifier - the identifier of the output + * @param[in] sDisplayName - the display name of the output + * @param[in] eType - the type of the input + * @return The added input port + */ + IImplicitPort * AddOutput(const std::string & sIdentifier, const std::string & sDisplayName, const Lib3MF::eImplicitPortType eType) override; + + /** + * IFunction::GetOutputs - Retrieves the outputs + * @return iterator for the outputs + */ + IImplicitPortIterator * GetOutputs() override; + + /** + * IFunction::RemoveOutput - Removes an output + * @param[in] pOutput - The output to be removed + */ + void RemoveOutput(IImplicitPort* pOutput) override; + + /** + * IFunction::FindInput - Retrieves an input + * @param[in] sIdentifier - the identifier of the input + * @return the input port + */ + IImplicitPort * FindInput(const std::string & sIdentifier) override; + + /** + * IFunction::FindOutput - Retrieves an output + * @param[in] sIdentifier - the identifier of the output + * @return the output port + */ + IImplicitPort * FindOutput(const std::string & sIdentifier) override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FUNCTION diff --git a/Include/API/lib3mf_functioncallnode.hpp b/Include/API/lib3mf_functioncallnode.hpp new file mode 100644 index 0000000..bdad495 --- /dev/null +++ b/Include/API/lib3mf_functioncallnode.hpp @@ -0,0 +1,92 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFunctionCallNode + +*/ + + +#ifndef __LIB3MF_FUNCTIONCALLNODE +#define __LIB3MF_FUNCTIONCALLNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFunctionCallNode +**************************************************************************************************************************/ + +class CFunctionCallNode : public virtual IFunctionCallNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CFunctionCallNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IFunctionCallNode::GetInputFunctionId - Retrieves the input for the function id + * @return the input port for the function + */ + IImplicitPort * GetInputFunctionID() override; +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FUNCTIONCALLNODE diff --git a/Include/API/lib3mf_functionfromimage3d.hpp b/Include/API/lib3mf_functionfromimage3d.hpp new file mode 100644 index 0000000..ef781c4 --- /dev/null +++ b/Include/API/lib3mf_functionfromimage3d.hpp @@ -0,0 +1,156 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFunctionFromImage3D + +*/ + + +#ifndef __LIB3MF_FUNCTIONFROMIMAGE3D +#define __LIB3MF_FUNCTIONFROMIMAGE3D + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_function.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelFunctionFromImage3D.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFunctionFromImage3D +**************************************************************************************************************************/ + +class CFunctionFromImage3D : public virtual IFunctionFromImage3D, public virtual CFunction { +private: + + /** + * Put private members here. + */ + NMR::CModelFunctionFromImage3D* functionfromimage3d(); + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + /** + * Put additional public members here. They will not be visible in the external API. + */ + CFunctionFromImage3D() = delete; + CFunctionFromImage3D(NMR::PModelResource pResource); + + /** + * Public member functions to implement. + */ + + /** + * IFunctionFromImage3D::GetImage3D - Returns the selected 3D image. + * @return image instance + */ + IImage3D * GetImage3D() override; + + /** + * IFunctionFromImage3D::SetImage3D - Sets the 3D image of the selector. + * @param[in] pImage3D - image instance + */ + void SetImage3D(IImage3D* pImage3D) override; + + /** + * IFunctionFromImage3D::SetFilter - Sets the texture filter of the selector. + * @param[in] eFilter - texture filter + */ + void SetFilter(const Lib3MF::eTextureFilter eFilter) override; + + /** + * IFunctionFromImage3D::GetFilter - Returns the texture filter of the selector. + * @return texture filter + */ + Lib3MF::eTextureFilter GetFilter() override; + + /** + * IFunctionFromImage3D::SetTileStyles - Sets the tile styles of the selector. + * @param[in] eTileStyleU - tile style in U + * @param[in] eTileStyleV - tile style in V + * @param[in] eTileStyleW - tile style in W + */ + void SetTileStyles(const Lib3MF::eTextureTileStyle eTileStyleU, const Lib3MF::eTextureTileStyle eTileStyleV, const Lib3MF::eTextureTileStyle eTileStyleW) override; + + /** + * IFunctionFromImage3D::GetTileStyles - Retrieves the tile styles of the selector. + * @param[out] eTileStyleU - tile style in U + * @param[out] eTileStyleV - tile style in V + * @param[out] eTileStyleW - tile style in W + */ + void GetTileStyles(Lib3MF::eTextureTileStyle & eTileStyleU, Lib3MF::eTextureTileStyle & eTileStyleV, Lib3MF::eTextureTileStyle & eTileStyleW) override; + + /** + * IFunctionFromImage3D::GetOffset - returns the offset value for the pixel values in the Image3D + * @return the offset value for the pixel values in the Image3D + */ + Lib3MF_double GetOffset() override; + + /** + * IFunctionFromImage3D::SetOffset - Sets the offset value for the pixel values in the Image3D + * @param[in] dOffset - the offset value for the pixel values in the Image3D + */ + void SetOffset(const Lib3MF_double dOffset) override; + + /** + * IFunctionFromImage3D::GetScale - returns the scale value for the pixel values in the Image3D + * @return the scale value for the pixel values in the Image3D + */ + Lib3MF_double GetScale() override; + + /** + * IFunctionFromImage3D::SetScale - Sets the scale value for the pixel values in the Image3D + * @param[in] dScale - the scale value for the pixel values in the Image3D + */ + void SetScale(const Lib3MF_double dScale) override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FUNCTIONFROMIMAGE3D diff --git a/Include/API/lib3mf_functiongradientnode.hpp b/Include/API/lib3mf_functiongradientnode.hpp new file mode 100644 index 0000000..7ee920c --- /dev/null +++ b/Include/API/lib3mf_functiongradientnode.hpp @@ -0,0 +1,108 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFunctionGradientNode + +*/ + + +#ifndef __LIB3MF_FUNCTIONGRADIENTNODE +#define __LIB3MF_FUNCTIONGRADIENTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFunctionGradientNode +**************************************************************************************************************************/ + +class CFunctionGradientNode : public virtual IFunctionGradientNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + CFunctionGradientNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Public member functions to implement. + */ + + IImplicitPort * GetInputFunctionID() override; + + IImplicitPort * GetInputPos() override; + + IImplicitPort * GetInputStep() override; + + void SetScalarOutputName(const std::string & sScalarOutputName) override; + + std::string GetScalarOutputName() override; + + void SetVectorInputName(const std::string & sVectorInputName) override; + + std::string GetVectorInputName() override; + + IImplicitPort * GetOutputNormalizedGradient() override; + + IImplicitPort * GetOutputGradient() override; + + IImplicitPort * GetOutputMagnitude() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FUNCTIONGRADIENTNODE diff --git a/Include/API/lib3mf_functioniterator.hpp b/Include/API/lib3mf_functioniterator.hpp new file mode 100644 index 0000000..95d6948 --- /dev/null +++ b/Include/API/lib3mf_functioniterator.hpp @@ -0,0 +1,93 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFunctionIterator + +*/ + + +#ifndef __LIB3MF_FUNCTIONITERATOR +#define __LIB3MF_FUNCTIONITERATOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_resourceiterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFunctionIterator +**************************************************************************************************************************/ + +class CFunctionIterator : public virtual IFunctionIterator, public virtual CResourceIterator { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IFunctionIterator::GetCurrentFunction - Returns the Function the iterator points at. + * @return returns the Function instance. + */ + IFunction * GetCurrentFunction() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FUNCTIONITERATOR diff --git a/Include/API/lib3mf_functionreference.hpp b/Include/API/lib3mf_functionreference.hpp new file mode 100644 index 0000000..b2c7b82 --- /dev/null +++ b/Include/API/lib3mf_functionreference.hpp @@ -0,0 +1,149 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CFunctionReference + +*/ + + +#ifndef __LIB3MF_FUNCTIONREFERENCE +#define __LIB3MF_FUNCTIONREFERENCE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Common/NMR_FunctionReference.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CFunctionReference +**************************************************************************************************************************/ + +class CFunctionReference : public virtual IFunctionReference, public virtual CBase { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + NMR::PFunctionReference m_pFunctionReference; +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CFunctionReference(NMR::PFunctionReference pFunctionReference); + + /** + * Public member functions to implement. + */ + + /** + * IFunctionReference::GetFunctionResourceID - Returns the UniqueResourceID of the Function. + * @return returns the UniqueResourceID. + */ + Lib3MF_uint32 GetFunctionResourceID() override; + + /** + * IFunctionReference::SetFunctionResourceID - Sets the UniqueResourceID to refer to. + * @param[in] nUniqueResourceID - UniqueResourceID of the function + */ + void SetFunctionResourceID(const Lib3MF_uint32 nUniqueResourceID) override; + + + /** + * IFunctionReference::GetTransform - Returns the transformation matrix into the coordinate system of the referenced Function. + * @return the transformation matrix + */ + Lib3MF::sTransform GetTransform() override; + + /** + * IFunctionReference::SetTransform - Sets the transformation matrix into the coordinate system of the referenced Function. + * @param[in] Transform - new transformation matrix + */ + void SetTransform(const Lib3MF::sTransform Transform) override; + + /** + * IFunctionReference::GetChannelName - Returns the name of the function output to use. + * @return the name of the function output + */ + std::string GetChannelName() override; + + /** + * IFunctionReference::SetChannelName - Sets the name of the function output to use. + * @param[in] sChannelName - new name of the function output + */ + void SetChannelName(const std::string & sChannelName) override; + + /** + * IFunctionReference::SetMinFeatureSize - Sets the minimal feature size as a hint for the function evaluator + * @param[in] dMinFeatureSize - minimal feature size + */ + void SetMinFeatureSize(const Lib3MF_double dMinFeatureSize) override; + + /** + * IFunctionReference::GetMinFeatureSize - Returns the minimal feature size as a hint for the function evaluator + * @return minimal feature size + */ + Lib3MF_double GetMinFeatureSize() override; + + /** + * IFunctionReference::SetFallBackValue - Sets the fallback value to use + * if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + void SetFallBackValue(const Lib3MF_double dFallBackValue) override; + + /** + * IFunctionReference::GetFallBackValue - Returns the fallback value to + * use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + Lib3MF_double GetFallBackValue(); +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_FUNCTIONREFERENCE diff --git a/Include/API/lib3mf_image3d.hpp b/Include/API/lib3mf_image3d.hpp new file mode 100644 index 0000000..8de4524 --- /dev/null +++ b/Include/API/lib3mf_image3d.hpp @@ -0,0 +1,94 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CImage3D + +*/ + + +#ifndef __LIB3MF_IMAGE3D +#define __LIB3MF_IMAGE3D + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_resource.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelImage3D.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CImage3D +**************************************************************************************************************************/ + +class CImage3D : public virtual IImage3D, public virtual CResource { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + NMR::CModelImage3D* image3D(); +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CImage3D() = delete; + CImage3D(NMR::PModelResource pResource); + + /** + * Public member functions to implement. + */ + + std::string GetName() override; + + void SetName(const std::string & sName) override; + + bool IsImageStack() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_IMAGE3D diff --git a/Include/API/lib3mf_image3diterator.hpp b/Include/API/lib3mf_image3diterator.hpp new file mode 100644 index 0000000..4752d35 --- /dev/null +++ b/Include/API/lib3mf_image3diterator.hpp @@ -0,0 +1,88 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CImage3DIterator + +*/ + + +#ifndef __LIB3MF_IMAGE3DITERATOR +#define __LIB3MF_IMAGE3DITERATOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_resourceiterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CImage3DIterator +**************************************************************************************************************************/ + +class CImage3DIterator : public virtual IImage3DIterator, public virtual CResourceIterator { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + IImage3D * GetCurrentImage3D() override; +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_IMAGE3DITERATOR diff --git a/Include/API/lib3mf_imagestack.hpp b/Include/API/lib3mf_imagestack.hpp new file mode 100644 index 0000000..b0d6da4 --- /dev/null +++ b/Include/API/lib3mf_imagestack.hpp @@ -0,0 +1,109 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CImageStack + +*/ + + +#ifndef __LIB3MF_IMAGESTACK +#define __LIB3MF_IMAGESTACK + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_image3d.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelImageStack.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CImageStack +**************************************************************************************************************************/ + +class CImageStack : public virtual IImageStack, public virtual CImage3D { +private: + + /** + * Put private members here. + */ + NMR::PModelImageStack m_pModelImageStack; + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CImageStack() = delete; + CImageStack(NMR::PModelImageStack pModelImageStack); + + /** + * Public member functions to implement. + */ + + Lib3MF_uint32 GetRowCount() override; + + void SetRowCount(const Lib3MF_uint32 nRowCount) override; + + Lib3MF_uint32 GetColumnCount() override; + + void SetColumnCount(const Lib3MF_uint32 nColumnCount) override; + + Lib3MF_uint32 GetSheetCount() override; + + IAttachment * GetSheet(const Lib3MF_uint32 nIndex) override; + + void SetSheet(const Lib3MF_uint32 nIndex, IAttachment* pSheet) override; + + IAttachment * CreateEmptySheet(const Lib3MF_uint32 nIndex, const std::string & sPath) override; + + IAttachment * CreateSheetFromBuffer(const Lib3MF_uint32 nIndex, const std::string & sPath, const Lib3MF_uint64 nDataBufferSize, const Lib3MF_uint8 * pDataBuffer) override; + + IAttachment * CreateSheetFromFile(const Lib3MF_uint32 nIndex, const std::string & sPath, const std::string & sFileName) override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_IMAGESTACK diff --git a/Include/API/lib3mf_implicitfunction.hpp b/Include/API/lib3mf_implicitfunction.hpp new file mode 100644 index 0000000..e569a63 --- /dev/null +++ b/Include/API/lib3mf_implicitfunction.hpp @@ -0,0 +1,828 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CImplicitFunction + +*/ + +#ifndef __LIB3MF_IMPLICITFUNCTION +#define __LIB3MF_IMPLICITFUNCTION + +#include "lib3mf_function.hpp" +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelImplicitFunction.h" + +namespace Lib3MF +{ + namespace Impl + { + + /************************************************************************************************************************* + Class declaration of CImplicitFunction + **************************************************************************************************************************/ + + class CImplicitFunction : public IImplicitFunction, public CFunction + { + private: + /** + * Put private members here. + */ + NMR::CModelImplicitFunction* function(); + + protected: + /** + * Put protected members here. + */ + + public: + /** + * Put additional public members here. They will not be visible in + * the external API. + */ + + CImplicitFunction() = delete; + CImplicitFunction(NMR::PModelResource pResource); + /** + * Public member functions to implement. + */ + + /** + * IImplicitFunction::GetIdentifier - Retrieves the identifier of + * the function + * @return the identifier + */ + std::string GetIdentifier() override; + + /** + * IImplicitFunction::SetIdentifier - Sets the identifier of the + * function + * @param[in] sIdentifier - the identifier + */ + void SetIdentifier(const std::string& sIdentifier) override; + + /** + * IImplicitFunction::AddNode - Add a node + * @param[in] eNodeType - the type of the node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IImplicitNode* AddNode( + const Lib3MF::eImplicitNodeType eNodeType, + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddSinNode - Add a SinNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ISinNode* AddSinNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddCosNode - Add a CosNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ICosNode* AddCosNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddTanNode - Add a TanNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ITanNode* AddTanNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddArcSinNode - Add a ArcSinNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IArcSinNode* AddArcSinNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddArcCosNode - Add a ArcCosNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IArcCosNode* AddArcCosNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddArcTan2Node - Add a ArcTan2Node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IArcTan2Node* AddArcTan2Node( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddSinhNode - Add a SinhNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ISinhNode* AddSinhNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddCoshNode - Add a CoshNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ICoshNode* AddCoshNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddTanhNode - Add a TanhNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ITanhNode* AddTanhNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddRoundNode - Add a RoundNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IRoundNode* AddRoundNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddCeilNode - Add a CeilNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ICeilNode* AddCeilNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddFloorNode - Add a FloorNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IFloorNode* AddFloorNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddSignNode - Add a SignNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ISignNode* AddSignNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddFractNode - Add a FractNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IFractNode* AddFractNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddAbsNode - Add a AbsNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IAbsNode* AddAbsNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddExpNode - Add a ExpNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IExpNode* AddExpNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddLogNode - Add a LogNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ILogNode* AddLogNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddLog2Node - Add a Log2Node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ILog2Node* AddLog2Node( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddLog10Node - Add a Log10Node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ILog10Node* AddLog10Node( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddLengthNode - Add a LengthNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ILengthNode* AddLengthNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddTransposeNode - Add a TransposeNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ITransposeNode* AddTransposeNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::InverseNode - Add a InverseNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IInverseNode* AddInverseNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddSqrtNode - Add a SqrtNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ISqrtNode* AddSqrtNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddResourceIdNode - Add a ResourceIdNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IResourceIdNode* AddResourceIdNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddAdditionNode - Add an AdditionNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IAdditionNode* AddAdditionNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddSubtractionNode - Add a SubtractionNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ISubtractionNode* AddSubtractionNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddMultiplicationNode - Add a + * MultiplicationNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IMultiplicationNode* AddMultiplicationNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddDivisionNode - Add a DivisionNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IDivisionNode* AddDivisionNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddDotNode - Add a DotNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IDotNode* AddDotNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddCrossNode - Add a CrossNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ICrossNode* AddCrossNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddMatVecMultiplicationNode - Add a + * MatVecMultiplicationNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IMatVecMultiplicationNode* AddMatVecMultiplicationNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddMinNode - Add a MinNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IMinNode* AddMinNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddMaxNode - Add a MaxNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IMaxNode* AddMaxNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddFmodNode - Add a FmodNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IFmodNode* AddFmodNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddPowNode - Add a PowNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IPowNode* AddPowNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddSelectNode - Add a SelectNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + ISelectNode* AddSelectNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddClampNode - Add a ClampNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IClampNode* AddClampNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddComposeVectorNode - Add a ComposeVectorNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IComposeVectorNode* AddComposeVectorNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddVectorFromScalarNode - Add a VectorFromScalar + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IVectorFromScalarNode * AddVectorFromScalarNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) override; + + /** + * IImplicitFunction::AddDecomposeVectorNode - Add a + * DecomposeVectorNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IDecomposeVectorNode* AddDecomposeVectorNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddComposeMatrixNode - Add a ComposeMatrixNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IComposeMatrixNode* AddComposeMatrixNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddMatrixFromRowsNode - Add a MatrixFromRowsNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IMatrixFromRowsNode * AddMatrixFromRowsNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) override; + + /** + * IImplicitFunction::AddMatrixFromColumnsNode - Add a MatrixFromColumnsNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IMatrixFromColumnsNode * AddMatrixFromColumnsNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) override; + + /** + * IImplicitFunction::AddConstantNode - Add a ConstantNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IConstantNode* AddConstantNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddConstVecNode - Add a ConstVecNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IConstVecNode* AddConstVecNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddConstMatNode - Add a ConstMatNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IConstMatNode* AddConstMatNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddMeshNode - Add a MeshNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IMeshNode* AddMeshNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddUnsignedMeshNode - Add a UnsignedMeshNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IUnsignedMeshNode * AddUnsignedMeshNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) override; + + /** + * IImplicitFunction::AddFunctionCallNode - Add a FunctionCallNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IFunctionCallNode* AddFunctionCallNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddBeamLatticeNode - Add a BeamLatticeNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IBeamLatticeNode* AddBeamLatticeNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddFunctionGradientNode - Add a FunctionGradientNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + IFunctionGradientNode* AddFunctionGradientNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::AddNormalizeDistanceNode - Add a NormalizeDistanceNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + INormalizeDistanceNode* AddNormalizeDistanceNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) override; + + /** + * IImplicitFunction::GetNodes - Retrieves the nodes + * @return the accessor to the nodes + */ + INodeIterator* GetNodes() override; + + /** + * IImplicitFunction::RemoveNode - Removes a node + * @param[in] pNode - The node to be removed + */ + void RemoveNode(IImplicitNode* pNode) override; + + /** + * IImplicitFunction::AddLink - Add a link + * @param[in] pSource - the source port + * @param[in] pTarget - the target port + */ + void AddLink(IImplicitPort* pSource, + IImplicitPort* pTarget) override; + + /** + * IImplicitFunction::AddLinkByNames - Add a link + * @param[in] sSource - name of the source port in the format + * nodename.portname + * @param[in] sTarget - name of the target port in the format + * nodename.portname + */ + void AddLinkByNames(const std::string& sSource, + const std::string& sTarget) override; + + /** + * IImplicitFunction::Clear - Clears the function + */ + void Clear() override; + + /** + * IImplicitFunction::SortNodesTopologically - Sorts the nodes + * topologically + */ + void SortNodesTopologically() override; + }; + + } // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_IMPLICITFUNCTION diff --git a/Include/API/lib3mf_implicitnode.hpp b/Include/API/lib3mf_implicitnode.hpp new file mode 100644 index 0000000..10b733b --- /dev/null +++ b/Include/API/lib3mf_implicitnode.hpp @@ -0,0 +1,173 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CImplicitNode + +*/ + +#ifndef __LIB3MF_IMPLICITNODE +#define __LIB3MF_IMPLICITNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelImplicitNode.h" + +namespace Lib3MF +{ + namespace Impl + { + + /************************************************************************************************************************* + Class declaration of CImplicitNode + **************************************************************************************************************************/ + + class CImplicitNode : public virtual IImplicitNode, public virtual CBase + { + private: + + + protected: + /** + * Put protected members here. + */ + NMR::PModelImplicitNode m_pImplicitNode; + + IImplicitPort * FindInputOrThrow(const std::string & sIdentifier); + IImplicitPort * FindOutputOrThrow(const std::string & sIdentifier); + public: + + CImplicitNode() = default; + explicit CImplicitNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Public member functions to implement. + */ + + /** + * IImplicitNode::GetIdentifier - Retrieves the identifier of the node + * @return the identifier + */ + std::string GetIdentifier() override; + + /** + * IImplicitNode::SetIdentifier - Sets the identifier of the node + * @param[in] sIdentifier - the identifier + */ + void SetIdentifier(const std::string & sIdentifier) override; + + /** + * IImplicitNode::GetDisplayName - Retrieves the display name of the node + * @return the display name + */ + std::string GetDisplayName() override; + + /** + * IImplicitNode::SetDisplayName - Sets the display name of the node + * @param[in] sDisplayName - the display name + */ + void SetDisplayName(const std::string & sDisplayName) override; + + /** + * IImplicitNode::GetTag - Retrieves the tag of the node + * @return the tag + */ + std::string GetTag() override; + + /** + * IImplicitNode::SetTag - Sets the tag of the node + * @param[in] sTag - the tag + */ + void SetTag(const std::string& sTag) override; + + Lib3MF::eImplicitNodeType GetNodeType() override; + + /** + * IImplicitNode::AddInput - Add an input + * @param[in] sIdentifier - the identifier of the input + * @param[in] sDisplayName - the display name of the input + * @return + */ + IImplicitPort * AddInput(const std::string & sIdentifier, + const std::string & sDisplayName) override; + + /** + * IImplicitNode::GetInputs - Retrieves the inputs + * @return the accessor to the inputs + */ + IImplicitPortIterator * GetInputs() override; + + /** + * IImplicitNode::AddOutput - Add an output + * @param[in] sIdentifier - the identifier of the output + * @param[in] sDisplayName - the display name of the output + * @return + */ + IImplicitPort * AddOutput(const std::string & sIdentifier, + const std::string & sDisplayName) override; + + /** + * IImplicitNode::GetOutputs - Retrieves the outputs + * @return the accessor to the outputs + */ + IImplicitPortIterator * GetOutputs() override; + + /** + * IImplicitNode::FindInput - Retrieves an input + * @param[in] sIdentifier - the identifier of the input + * @return the input port + */ + IImplicitPort * FindInput(const std::string & sIdentifier) override; + + /** + * IImplicitNode::FindOutput - Retrieves an output + * @param[in] sIdentifier - the identifier of the output + * @return the output port + */ + IImplicitPort * FindOutput(const std::string & sIdentifier) override; + + /** + * IImplicitNode::AreTypesValid - Checks if the types of the input + * and output ports are valid for the node type + * @return true, if the types are valid + */ + bool AreTypesValid() override; + }; + + } // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_IMPLICITNODE diff --git a/Include/API/lib3mf_implicitport.hpp b/Include/API/lib3mf_implicitport.hpp new file mode 100644 index 0000000..28a1aae --- /dev/null +++ b/Include/API/lib3mf_implicitport.hpp @@ -0,0 +1,137 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CImplicitPort + +*/ + +#ifndef __LIB3MF_IMPLICITPORT +#define __LIB3MF_IMPLICITPORT + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelImplicitPort.h" + +namespace Lib3MF +{ + namespace Impl + { + + /************************************************************************************************************************* + Class declaration of CImplicitPort + **************************************************************************************************************************/ + + class CImplicitPort : public virtual IImplicitPort, public virtual CBase + { + private: + /** + * Put private members here. + */ + NMR::PModelImplicitPort m_pImplicitPort; + + protected: + /** + * Put protected members here. + */ + + public: + CImplicitPort(NMR::PModelImplicitPort pImplicitPort); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + /** + * Public member functions to implement. + */ + + /** + * IImplicitPort::GetIdentifier - Retrieves the identifier of the port + * @return the identifier + */ + std::string GetIdentifier() override; + + /** + * IImplicitPort::SetIdentifier - Sets the identifier of the port + * @param[in] sIdentifier - the identifier + */ + void SetIdentifier(const std::string & sIdentifier) override; + + /** + * IImplicitPort::GetDisplayName - Retrieves the display name of the port + * @return the display name + */ + std::string GetDisplayName() override; + + /** + * IImplicitPort::SetDisplayName - Sets the display name of the port + * @param[in] sDisplayName - the display name + */ + void SetDisplayName(const std::string & sDisplayName) override; + + /** + * IImplicitPort::SetType - Sets the type of the port + * @param[in] eImplicitPortType - the type + */ + void SetType(const Lib3MF::eImplicitPortType eImplicitPortType) override; + + /** + * IImplicitPort::GetType - Retrieves the type of the port + * @return the type + */ + Lib3MF::eImplicitPortType GetType() override; + + /** + * IImplicitPort::GetReference - Retrieves the reference of the port, only used for + * input ports + * @return the reference + */ + std::string GetReference() override; + + /** + * IImplicitPort::SetReference - Sets the reference of the port, only used for input + * ports + * @param[in] sReference - the reference + */ + void SetReference(const std::string & sReference) override; + + NMR::PModelImplicitPort getPort(); + }; + + } // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_IMPLICITPORT diff --git a/Include/API/lib3mf_implicitportiterator.hpp b/Include/API/lib3mf_implicitportiterator.hpp new file mode 100644 index 0000000..b0e6d16 --- /dev/null +++ b/Include/API/lib3mf_implicitportiterator.hpp @@ -0,0 +1,95 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CImplicitPortIterator + +*/ + + +#ifndef __LIB3MF_IMPLICITPORTITERATOR +#define __LIB3MF_IMPLICITPORTITERATOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_iterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelImplicitNode.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CImplicitPortIterator +**************************************************************************************************************************/ + +class CImplicitPortIterator : public virtual IImplicitPortIterator, public virtual CIterator { +private: + + /** + * Put private members here. + */ + NMR::PPorts m_pPorts; +protected: + + /** + * Put protected members here. + */ + +public: + CImplicitPortIterator(NMR::PPorts pPorts); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IImplicitPortIterator::GetCurrent - Returns the current element + * @return The current element + */ + IImplicitPort * GetCurrent() override; + + Lib3MF_uint64 Count() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_IMPLICITPORTITERATOR diff --git a/Include/API/lib3mf_inversenode.hpp b/Include/API/lib3mf_inversenode.hpp new file mode 100644 index 0000000..a013fd1 --- /dev/null +++ b/Include/API/lib3mf_inversenode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CInverseNode + +*/ + + +#ifndef __LIB3MF_INVERSENODE +#define __LIB3MF_INVERSENODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CInverseNode +**************************************************************************************************************************/ + +class CInverseNode : public virtual IInverseNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CInverseNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_INVERSENODE diff --git a/Include/API/lib3mf_iterator.hpp b/Include/API/lib3mf_iterator.hpp new file mode 100644 index 0000000..fb72702 --- /dev/null +++ b/Include/API/lib3mf_iterator.hpp @@ -0,0 +1,106 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CIterator + +*/ + + +#ifndef __LIB3MF_ITERATOR +#define __LIB3MF_ITERATOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CIterator +**************************************************************************************************************************/ + +class CIterator : public virtual IIterator, public virtual CBase { +private: + + /** + * Put private members here. + */ + Lib3MF_int64 m_nCurrentIndex = -1; +protected: + + /** + * Put protected members here. + */ + Lib3MF_int64 getCurrentIndex(); + void throwIfInvalidIndex(); +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IIterator::MoveNext - Iterates to the next item in the list. + * @return Iterates to the next item in the list. + */ + bool MoveNext() override; + + /** + * IIterator::MovePrevious - Iterates to the previous item in the list. + * @return Iterates to the previous item in the list. + */ + bool MovePrevious() override; + + /** + * IIterator::Count - Returns the number of items the iterator captures. + * @return returns the number of items the iterator captures. + */ + Lib3MF_uint64 Count() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ITERATOR diff --git a/Include/API/lib3mf_keystore.hpp b/Include/API/lib3mf_keystore.hpp index cfc4bb2..78e48df 100644 --- a/Include/API/lib3mf_keystore.hpp +++ b/Include/API/lib3mf_keystore.hpp @@ -93,23 +93,29 @@ namespace Lib3MF { virtual Lib3MF_uint64 GetResourceDataGroupCount() override; - virtual IResourceDataGroup * GetResourceDataGroup(const Lib3MF_uint64 nResourceDataIndex) override; + IResourceDataGroup * GetResourceDataGroup(const Lib3MF_uint64 nResourceDataIndex) override; - virtual IResourceDataGroup * AddResourceDataGroup() override; + IResourceDataGroup * AddResourceDataGroup() override; - virtual void RemoveResourceDataGroup(IResourceDataGroup * pTheResourceDataGroup) override; + void RemoveResourceDataGroup(IResourceDataGroup * pTheResourceDataGroup) override; - virtual Lib3MF::Impl::IResourceDataGroup * FindResourceDataGroup(Lib3MF::Impl::IPackagePart *pPartPath); + Lib3MF::Impl::IResourceDataGroup * FindResourceDataGroup(Lib3MF::Impl::IPackagePart *pPartPath) override; - virtual IResourceData * AddResourceData(IResourceDataGroup* pResourceDataGroup, IPackagePart* pPartPath, const Lib3MF::eEncryptionAlgorithm eAlgorithm, const Lib3MF::eCompression eCompression, const Lib3MF_uint64 nAdditionalAuthenticationDataBufferSize, const Lib3MF_uint8 * pAdditionalAuthenticationDataBuffer); + IResourceData * AddResourceData( + IResourceDataGroup * pResourceDataGroup, + IPackagePart * pPartPath, + const Lib3MF::eEncryptionAlgorithm eAlgorithm, + const Lib3MF::eCompression eCompression, + const Lib3MF_uint64 nAdditionalAuthenticationDataBufferSize, + const Lib3MF_uint8 * pAdditionalAuthenticationDataBuffer) override; - virtual void RemoveResourceData(Lib3MF::Impl::IResourceData *pResourceData); + void RemoveResourceData(Lib3MF::Impl::IResourceData *pResourceData) override; - virtual Lib3MF_uint64 GetResourceDataCount(); + Lib3MF_uint64 GetResourceDataCount() override; - virtual Lib3MF::Impl::IResourceData * GetResourceData(const Lib3MF_uint64 nResourceDataIndex); + Lib3MF::Impl::IResourceData * GetResourceData(const Lib3MF_uint64 nResourceDataIndex) override; - virtual IResourceData * FindResourceData(IPackagePart * pResourcePath) override; + IResourceData * FindResourceData(IPackagePart * pResourcePath) override; }; diff --git a/Include/API/lib3mf_lengthnode.hpp b/Include/API/lib3mf_lengthnode.hpp new file mode 100644 index 0000000..912c6f2 --- /dev/null +++ b/Include/API/lib3mf_lengthnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CLengthNode + +*/ + + +#ifndef __LIB3MF_LENGTHNODE +#define __LIB3MF_LENGTHNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CLengthNode +**************************************************************************************************************************/ + +class CLengthNode : public virtual ILengthNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CLengthNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_LENGTHNODE diff --git a/Include/API/lib3mf_levelset.hpp b/Include/API/lib3mf_levelset.hpp new file mode 100644 index 0000000..be1c11e --- /dev/null +++ b/Include/API/lib3mf_levelset.hpp @@ -0,0 +1,194 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CLevelSet + +*/ + + +#ifndef __LIB3MF_BOUNDARYSHAPE +#define __LIB3MF_BOUNDARYSHAPE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_object.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_ModelLevelSetObject.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CLevelSet +**************************************************************************************************************************/ + +class CLevelSet : public virtual ILevelSet, public virtual CObject { +private: + + /** + * Put private members here. + */ + NMR::PModelLevelSetObject levelSetObject(); +protected: + + /** + * Put protected members here. + */ + +public: + /** + * Put additional public members here. They will not be visible in the external API. + */ + + CLevelSet() = delete; + + CLevelSet(NMR::PModelResource pResource); + + + /** + * Public member functions to implement. + */ + static ILevelSet* fnCreateLevelSetFromModelResource( + NMR::PModelResource pResource, bool bFailIfUnkownClass); + + /** + * ILevelSet::GetFunction - Returns the function that is used as boundary shape. + * @return the function to use as boundary shape + */ + IFunction * GetFunction() override; + + /** + * ILevelSet::SetFunction - Sets the function to use as boundary shape. + * @param[in] pTheFunction - the function to use as boundary shape + */ + void SetFunction(IFunction* pTheFunction) override; + + /** + * ILevelSet::GetTransform - Returns the transformation matrix into the coordinate system of the referenced Function. + * @return the transformation matrix + */ + Lib3MF::sTransform GetTransform() override; + + /** + * ILevelSet::SetTransform - Sets the transformation matrix into the coordinate system of the referenced Function. + * @param[in] Transform - new transformation matrix + */ + void SetTransform(const Lib3MF::sTransform Transform) override; + + /** + * ILevelSet::GetChannelName - Returns the name of the function output channel to use. + * @return the name of the function output channel + */ + std::string GetChannelName() override; + + /** + * ILevelSet::SetChannelName - Sets the name of the function output channel to use. + * @param[in] sChannelName - new name of the function output channel + */ + void SetChannelName(const std::string & sChannelName) override; + + /** + * ILevelSet::SetMinFeatureSize - Sets the minimal feature size as a hint for the function evaluator + * @param[in] dMinFeatureSize - minimal feature size + */ + void SetMinFeatureSize(const Lib3MF_double dMinFeatureSize) override; + + /** + * ILevelSet::GetMinFeatureSize - Returns the minimal feature size as a hint for the function evaluator + * @return minimal feature size + */ + Lib3MF_double GetMinFeatureSize() override; + + /** + * ILevelSet::SetFallBackValue - Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + void SetFallBackValue(const Lib3MF_double dFallBackValue) override; + + /** + * ILevelSet::GetFallBackValue - Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + Lib3MF_double GetFallBackValue() override; + + /** + * ILevelSet::SetMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary + * @param[in] bMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary + */ + void SetMeshBBoxOnly(const bool bMeshBBoxOnly) override; + + /** + * ILevelSet::GetMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary + * @return If set only the bounding box of the mesh is intersected with the boundary + */ + bool GetMeshBBoxOnly() override; + + /** + * ILevelSet::SetMesh - Sets the mesh to use as evaluation domain + * @param[in] pTheMesh - The mesh + */ + void SetMesh(IMeshObject* pTheMesh) override; + + /** + * ILevelSet::GetMesh - Returns the mesh that is used as evaluation domain + * @return The mesh + */ + IMeshObject * GetMesh() override; + + + /** + * ILevelSet::GetVolumeData - Retrieves the VolumeData this MeshObject. + * @return the VolumeData of this MeshObject + */ + IVolumeData * GetVolumeData() override; + + /** + * ILevelSet::SetVolumeData - Sets the VolumeData of this LevelSet. + * @param[in] pTheVolumeData - the VolumeData of this MeshObject + */ + void SetVolumeData(IVolumeData* pTheVolumeData) override; + + bool IsMeshObject() override; + + bool IsComponentsObject() override; + + bool IsLevelSetObject() override; +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_BOUNDARYSHAPE diff --git a/Include/API/lib3mf_levelsetiterator.hpp b/Include/API/lib3mf_levelsetiterator.hpp new file mode 100644 index 0000000..1684a13 --- /dev/null +++ b/Include/API/lib3mf_levelsetiterator.hpp @@ -0,0 +1,93 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CLevelSetIterator + +*/ + + +#ifndef __LIB3MF_BOUNDARYSHAPEITERATOR +#define __LIB3MF_BOUNDARYSHAPEITERATOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_resourceiterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CLevelSetIterator +**************************************************************************************************************************/ + +class CLevelSetIterator : public virtual ILevelSetIterator, public virtual CResourceIterator { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * ILevelSetIterator::GetCurrentLevelSet - Returns the LevelSet the iterator points at. + * @return returns the MeshObject instance. + */ + ILevelSet * GetCurrentLevelSet() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_BOUNDARYSHAPEITERATOR diff --git a/Include/API/lib3mf_log10node.hpp b/Include/API/lib3mf_log10node.hpp new file mode 100644 index 0000000..d8429ea --- /dev/null +++ b/Include/API/lib3mf_log10node.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CLog10Node + +*/ + + +#ifndef __LIB3MF_LOG10NODE +#define __LIB3MF_LOG10NODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CLog10Node +**************************************************************************************************************************/ + +class CLog10Node : public virtual ILog10Node, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CLog10Node(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_LOG10NODE diff --git a/Include/API/lib3mf_log2node.hpp b/Include/API/lib3mf_log2node.hpp new file mode 100644 index 0000000..7120285 --- /dev/null +++ b/Include/API/lib3mf_log2node.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CLog2Node + +*/ + + +#ifndef __LIB3MF_LOG2NODE +#define __LIB3MF_LOG2NODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CLog2Node +**************************************************************************************************************************/ + +class CLog2Node : public virtual ILog2Node, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CLog2Node(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_LOG2NODE diff --git a/Include/API/lib3mf_lognode.hpp b/Include/API/lib3mf_lognode.hpp new file mode 100644 index 0000000..c14eab2 --- /dev/null +++ b/Include/API/lib3mf_lognode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CLogNode + +*/ + + +#ifndef __LIB3MF_LOGNODE +#define __LIB3MF_LOGNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CLogNode +**************************************************************************************************************************/ + +class CLogNode : public virtual ILogNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CLogNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_LOGNODE diff --git a/Include/API/lib3mf_materialmapping.hpp b/Include/API/lib3mf_materialmapping.hpp new file mode 100644 index 0000000..0bfd6d6 --- /dev/null +++ b/Include/API/lib3mf_materialmapping.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMaterialMapping + +*/ + + +#ifndef __LIB3MF_MATERIALMAPPING +#define __LIB3MF_MATERIALMAPPING + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_functionreference.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CMaterialMapping +**************************************************************************************************************************/ + +class CMaterialMapping : public virtual IMaterialMapping, public virtual CFunctionReference { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MATERIALMAPPING diff --git a/Include/API/lib3mf_matrixfromcolumnsnode.hpp b/Include/API/lib3mf_matrixfromcolumnsnode.hpp new file mode 100644 index 0000000..0fe9700 --- /dev/null +++ b/Include/API/lib3mf_matrixfromcolumnsnode.hpp @@ -0,0 +1,117 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMatrixFromColumnsNode + +*/ + + +#ifndef __LIB3MF_MATRIXFROMCOLUMNSNODE +#define __LIB3MF_MATRIXFROMCOLUMNSNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CMatrixFromColumnsNode +**************************************************************************************************************************/ + +class CMatrixFromColumnsNode : public virtual IMatrixFromColumnsNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CMatrixFromColumnsNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IMatrixFromColumnsNode::GetInputA - Retrieves the input for the first column + * @return the input for the first column + */ + IImplicitPort * GetInputA() override; + + /** + * IMatrixFromColumnsNode::GetInputB - Retrieves the input for the second column + * @return the input for the second column + */ + IImplicitPort * GetInputB() override; + + /** + * IMatrixFromColumnsNode::GetInputC - Retrieves the input for the third column + * @return the input for the third column + */ + IImplicitPort * GetInputC() override; + + /** + * IMatrixFromColumnsNode::GetInputD - Retrieves the input for the fourth column + * @return the input for the fourth column + */ + IImplicitPort * GetInputD() override; + + /** + * IMatrixFromColumnsNode::GetOutputResult - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputResult() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MATRIXFROMCOLUMNSNODE diff --git a/Include/API/lib3mf_matrixfromrowsnode.hpp b/Include/API/lib3mf_matrixfromrowsnode.hpp new file mode 100644 index 0000000..b02703d --- /dev/null +++ b/Include/API/lib3mf_matrixfromrowsnode.hpp @@ -0,0 +1,117 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMatrixFromRowsNode + +*/ + + +#ifndef __LIB3MF_MATRIXFROMROWSNODE +#define __LIB3MF_MATRIXFROMROWSNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CMatrixFromRowsNode +**************************************************************************************************************************/ + +class CMatrixFromRowsNode : public virtual IMatrixFromRowsNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CMatrixFromRowsNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IMatrixFromRowsNode::GetInputA - Retrieves the input for the first row + * @return the input for the first row + */ + IImplicitPort * GetInputA() override; + + /** + * IMatrixFromRowsNode::GetInputB - Retrieves the input for the second row + * @return the input for the second row + */ + IImplicitPort * GetInputB() override; + + /** + * IMatrixFromRowsNode::GetInputC - Retrieves the input for the third row + * @return the input for the third row + */ + IImplicitPort * GetInputC() override; + + /** + * IMatrixFromRowsNode::GetInputD - Retrieves the input for the fourth row + * @return the input for the fourth row + */ + IImplicitPort * GetInputD() override; + + /** + * IMatrixFromRowsNode::GetOutputResult - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputResult() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MATRIXFROMROWSNODE diff --git a/Include/API/lib3mf_matvecmultiplicationnode.hpp b/Include/API/lib3mf_matvecmultiplicationnode.hpp new file mode 100644 index 0000000..c534ce4 --- /dev/null +++ b/Include/API/lib3mf_matvecmultiplicationnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMatVecMultiplicationNode + +*/ + + +#ifndef __LIB3MF_MATVECMULTIPLICATIONNODE +#define __LIB3MF_MATVECMULTIPLICATIONNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CMatVecMultiplicationNode +**************************************************************************************************************************/ + +class CMatVecMultiplicationNode : public virtual IMatVecMultiplicationNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CMatVecMultiplicationNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MATVECMULTIPLICATIONNODE diff --git a/Include/API/lib3mf_maxnode.hpp b/Include/API/lib3mf_maxnode.hpp new file mode 100644 index 0000000..06969d7 --- /dev/null +++ b/Include/API/lib3mf_maxnode.hpp @@ -0,0 +1,84 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMaxNode + +*/ + +#ifndef __LIB3MF_MAXNODE +#define __LIB3MF_MAXNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + +namespace Lib3MF +{ + namespace Impl + { + + /************************************************************************************************************************* + Class declaration of CMaxNode + **************************************************************************************************************************/ + + class CMaxNode : public virtual IMaxNode, public virtual CTwoInputNode + { + private: + /** + * Put private members here. + */ + + protected: + /** + * Put protected members here. + */ + + public: + CMaxNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in + * the external API. + */ + + /** + * Public member functions to implement. + */ + }; + + } // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MAXNODE diff --git a/Include/API/lib3mf_meshnode.hpp b/Include/API/lib3mf_meshnode.hpp new file mode 100644 index 0000000..6094a14 --- /dev/null +++ b/Include/API/lib3mf_meshnode.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMeshNode + +*/ + + +#ifndef __LIB3MF_MESHNODE +#define __LIB3MF_MESHNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CMeshNode +**************************************************************************************************************************/ + +class CMeshNode : public virtual IMeshNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CMeshNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IMeshNode::GetInputMesh - Retrieves the input for the model resource id of the mesh + * @return the input port for the model resource id of the mesh + */ + IImplicitPort * GetInputMesh() override; + + /** + * IMeshNode::GetInputPos - Retrieves the input for the position + * @return the input port for the position + */ + IImplicitPort * GetInputPos() override; + + /** + * IMeshNode::GetOutputDistance - Retrieves the output + * @return the output port for the signed distance to the mesh + */ + IImplicitPort * GetOutputDistance() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MESHNODE diff --git a/Include/API/lib3mf_meshobject.hpp b/Include/API/lib3mf_meshobject.hpp index edc714c..c2d4c4b 100644 --- a/Include/API/lib3mf_meshobject.hpp +++ b/Include/API/lib3mf_meshobject.hpp @@ -63,6 +63,7 @@ private: NMR::CMeshInformation_Properties* getMeshInformationProperties(); + protected: /** @@ -81,51 +82,67 @@ public: * Public member functions to implement. */ - Lib3MF_uint32 GetVertexCount (); + Lib3MF_uint32 GetVertexCount () override; - Lib3MF_uint32 GetTriangleCount (); + Lib3MF_uint32 GetTriangleCount () override; - void SetVertex (const Lib3MF_uint32 nIndex, const sLib3MFPosition Coordinates); + void SetVertex (const Lib3MF_uint32 nIndex, const sLib3MFPosition Coordinates) override; - sLib3MFPosition GetVertex(const Lib3MF_uint32 nIndex); + sLib3MFPosition GetVertex(const Lib3MF_uint32 nIndex) override; - Lib3MF_uint32 AddVertex (const sLib3MFPosition Coordinates); + Lib3MF_uint32 AddVertex (const sLib3MFPosition Coordinates) override; - virtual void GetVertices(Lib3MF_uint64 nVerticesBufferSize, Lib3MF_uint64* pVerticesNeededCount, sLib3MFPosition * pVerticesBuffer); + virtual void GetVertices(Lib3MF_uint64 nVerticesBufferSize, Lib3MF_uint64* pVerticesNeededCount, sLib3MFPosition * pVerticesBuffer) override; - sLib3MFTriangle GetTriangle (const Lib3MF_uint32 nIndex); + sLib3MFTriangle GetTriangle (const Lib3MF_uint32 nIndex) override; - void SetTriangle (const Lib3MF_uint32 nIndex, const sLib3MFTriangle Indices); + void SetTriangle (const Lib3MF_uint32 nIndex, const sLib3MFTriangle Indices) override; - Lib3MF_uint32 AddTriangle (const sLib3MFTriangle Indices); + Lib3MF_uint32 AddTriangle (const sLib3MFTriangle Indices) override; - void GetTriangleIndices (Lib3MF_uint64 nIndicesBufferSize, Lib3MF_uint64* pIndicesNeededCount, sLib3MFTriangle * pIndicesBuffer); + void GetTriangleIndices (Lib3MF_uint64 nIndicesBufferSize, Lib3MF_uint64* pIndicesNeededCount, sLib3MFTriangle * pIndicesBuffer) override; - void SetGeometry(const Lib3MF_uint64 nVerticesBufferSize, const sLib3MFPosition * pVerticesBuffer, const Lib3MF_uint64 nIndicesBufferSize, const sLib3MFTriangle * pIndicesBuffer); + void SetGeometry(const Lib3MF_uint64 nVerticesBufferSize, const sLib3MFPosition * pVerticesBuffer, const Lib3MF_uint64 nIndicesBufferSize, const sLib3MFTriangle * pIndicesBuffer) override; - bool IsManifoldAndOriented(); + bool IsManifoldAndOriented() override; - bool IsMeshObject(); + bool IsMeshObject() override; - bool IsComponentsObject(); + bool IsComponentsObject() override; - bool IsValid(); + bool IsLevelSetObject() override; - virtual IBeamLattice * BeamLattice(); + bool IsValid(); - void SetObjectLevelProperty(const Lib3MF_uint32 nUniqueResourceID, const Lib3MF_uint32 nPropertyID); + virtual IBeamLattice * BeamLattice() override; - bool GetObjectLevelProperty(Lib3MF_uint32 & nUniqueResourceID, Lib3MF_uint32 & nPropertyID); + void SetObjectLevelProperty(const Lib3MF_uint32 nUniqueResourceID, const Lib3MF_uint32 nPropertyID) override; - void SetTriangleProperties(const Lib3MF_uint32 nIndex, const sLib3MFTriangleProperties Properties); + bool GetObjectLevelProperty(Lib3MF_uint32 & nUniqueResourceID, Lib3MF_uint32 & nPropertyID) override; - void GetTriangleProperties(const Lib3MF_uint32 nIndex, sLib3MFTriangleProperties & sProperty); + void SetTriangleProperties(const Lib3MF_uint32 nIndex, const sLib3MFTriangleProperties Properties) override; - void SetAllTriangleProperties(const Lib3MF_uint64 nPropertiesArrayBufferSize, const sLib3MFTriangleProperties * pPropertiesArrayBuffer); + void GetTriangleProperties(const Lib3MF_uint32 nIndex, sLib3MFTriangleProperties & sProperty) override; - void GetAllTriangleProperties(Lib3MF_uint64 nPropertiesArrayBufferSize, Lib3MF_uint64* pPropertiesArrayNeededCount, sLib3MFTriangleProperties * pPropertiesArrayBuffer); + void SetAllTriangleProperties(const Lib3MF_uint64 nPropertiesArrayBufferSize, const sLib3MFTriangleProperties * pPropertiesArrayBuffer) override; - void ClearAllProperties(); + void GetAllTriangleProperties(Lib3MF_uint64 nPropertiesArrayBufferSize, Lib3MF_uint64* pPropertiesArrayNeededCount, sLib3MFTriangleProperties * pPropertiesArrayBuffer) override; + + void ClearAllProperties() override; + + IVolumeData * GetVolumeData() override; + + void SetVolumeData(IVolumeData* pTheVolumeData) override; + + ITriangleSet* AddTriangleSet(const std::string& sIdentifier, const std::string& sName) override; + + bool HasTriangleSet(const std::string& sIdentifier) override; + + ITriangleSet* FindTriangleSet(const std::string& sIdentifier) override; + + Lib3MF_uint32 GetTriangleSetCount() override; + + ITriangleSet* GetTriangleSet(const Lib3MF_uint32 nIndex) override; }; } diff --git a/Include/API/lib3mf_meshobjectiterator.hpp b/Include/API/lib3mf_meshobjectiterator.hpp index c8a35a1..766f33a 100644 --- a/Include/API/lib3mf_meshobjectiterator.hpp +++ b/Include/API/lib3mf_meshobjectiterator.hpp @@ -76,7 +76,7 @@ public: * Public member functions to implement. */ - IMeshObject * GetCurrentMeshObject (); + IMeshObject * GetCurrentMeshObject() override; }; diff --git a/Include/API/lib3mf_minnode.hpp b/Include/API/lib3mf_minnode.hpp new file mode 100644 index 0000000..47cdb5e --- /dev/null +++ b/Include/API/lib3mf_minnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMinNode + +*/ + + +#ifndef __LIB3MF_MINNODE +#define __LIB3MF_MINNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CMinNode +**************************************************************************************************************************/ + +class CMinNode : public virtual IMinNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CMinNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MINNODE diff --git a/Include/API/lib3mf_model.hpp b/Include/API/lib3mf_model.hpp index 5e63c74..6326c12 100644 --- a/Include/API/lib3mf_model.hpp +++ b/Include/API/lib3mf_model.hpp @@ -58,6 +58,8 @@ private: NMR::PModel m_model; + void mergeModel(NMR::CModel & sourceModel, NMR::CModel & targetModel); + protected: /** @@ -73,6 +75,8 @@ public: NMR::CModel& model(); + static IResource* createIResourceFromModelResource(NMR::PModelResource pResource, bool bFailIfUnkownClass); + /** * Public member functions to implement. */ @@ -93,6 +97,8 @@ public: IReader * QueryReader(const std::string & sReaderClass) override; + IResource* GetResourceByID(const Lib3MF_uint32 nUniqueResourceID) override; + ITexture2D * GetTexture2DByID(const Lib3MF_uint32 nUniqueResourceID) override; eLib3MFPropertyType GetPropertyTypeByID(const Lib3MF_uint32 nUniqueResourceID) override; @@ -113,7 +119,9 @@ public: ISliceStack * GetSliceStackByID(const Lib3MF_uint32 nUniqueResourceID) override; - std::string GetBuildUUID (bool & bHasUUID) override; + ILevelSet* GetLevelSetByID(const Lib3MF_uint32 nUniqueResourceID) override; + + std::string GetBuildUUID (bool & bHasUUID) override; void SetBuildUUID (const std::string & sUUID) override; @@ -143,6 +151,8 @@ public: IModel * MergeToModel() override; + void MergeFromModel(IModel* pModelInstance) override; + IMeshObject * AddMeshObject() override; IComponentsObject * AddComponentsObject() override; @@ -191,9 +201,29 @@ public: Lib3MF::sBox GetOutbox() override; - IKeyStore * GetKeyStore(); + IKeyStore * GetKeyStore() override; - void SetRandomNumberCallback(const Lib3MF::RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData); + void SetRandomNumberCallback(const Lib3MF::RandomNumberCallback pTheCallback, const Lib3MF_pvoid pUserData) override; + + IImageStack * AddImageStack(const Lib3MF_uint32 nSizeX, const Lib3MF_uint32 nSizeY, const Lib3MF_uint32 nSheetCount) override; + + IImageStack* GetImageStackByID(const Lib3MF_uint32 nUniqueResourceID) override; + + IImage3DIterator * GetImage3Ds() override; + + IFunctionIterator * GetFunctions() override; + + IImplicitFunction * AddImplicitFunction() override; + + IFunctionFromImage3D* AddFunctionFromImage3D(IImage3D* pImage3DInstance) override; + + IVolumeData * AddVolumeData() override; + + ILevelSet* AddLevelSet() override; + + ILevelSetIterator * GetLevelSets() override; + + void RemoveResource(IResource* pResource) override; }; } diff --git a/Include/API/lib3mf_modnode.hpp b/Include/API/lib3mf_modnode.hpp new file mode 100644 index 0000000..8ea0e79 --- /dev/null +++ b/Include/API/lib3mf_modnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CModNode + +*/ + + +#ifndef __LIB3MF_MODNODE +#define __LIB3MF_MODNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CModNode +**************************************************************************************************************************/ + +class CModNode : public virtual IModNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CModNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MODNODE diff --git a/Include/API/lib3mf_multiplicationnode.hpp b/Include/API/lib3mf_multiplicationnode.hpp new file mode 100644 index 0000000..032fa1b --- /dev/null +++ b/Include/API/lib3mf_multiplicationnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMultiplicationNode + +*/ + + +#ifndef __LIB3MF_MULTIPLICATIONNODE +#define __LIB3MF_MULTIPLICATIONNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CMultiplicationNode +**************************************************************************************************************************/ + +class CMultiplicationNode : public virtual IMultiplicationNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CMultiplicationNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_MULTIPLICATIONNODE diff --git a/Include/API/lib3mf_multipropertygroupiterator.hpp b/Include/API/lib3mf_multipropertygroupiterator.hpp index 2150650..4181e88 100644 --- a/Include/API/lib3mf_multipropertygroupiterator.hpp +++ b/Include/API/lib3mf_multipropertygroupiterator.hpp @@ -76,8 +76,9 @@ public: * Public member functions to implement. */ - IMultiPropertyGroup * GetCurrentMultiPropertyGroup (); + IMultiPropertyGroup * GetCurrentMultiPropertyGroup() override; + IResource * GetCurrent() override; }; } // namespace Impl diff --git a/Include/API/lib3mf_nodeiterator.hpp b/Include/API/lib3mf_nodeiterator.hpp new file mode 100644 index 0000000..4839fa5 --- /dev/null +++ b/Include/API/lib3mf_nodeiterator.hpp @@ -0,0 +1,96 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CNodeIterator + +*/ + +#ifndef __LIB3MF_NODEITERATOR +#define __LIB3MF_NODEITERATOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_iterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "lib3mf_implicitfunction.hpp" +#include "lib3mf_implicitnode.hpp" + +namespace Lib3MF +{ + namespace Impl + { + + /************************************************************************************************************************* + Class declaration of CNodeIterator + **************************************************************************************************************************/ + + class CNodeIterator : public virtual INodeIterator, public virtual CIterator + { + private: + /** + * Put private members here. + */ + NMR::PImplicitNodes m_pNodes; + + IImplicitNode * implicitNodeFromModelImplicitNode(NMR::PModelImplicitNode pNode); + protected: + /** + * Put protected members here. + */ + + public: + CNodeIterator(NMR::PImplicitNodes pNodes); + CNodeIterator() = delete; + /** + * Put additional public members here. They will not be visible in the external API. + */ + + /** + * Public member functions to implement. + */ + + /** + * INodeIterator::GetCurrent - Returns the current element + * @return The current element + */ + IImplicitNode * GetCurrent() override; + + Lib3MF_uint64 Count() override; + }; + + } // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_NODEITERATOR diff --git a/Include/API/lib3mf_normalizedistancenode.hpp b/Include/API/lib3mf_normalizedistancenode.hpp new file mode 100644 index 0000000..8bb5335 --- /dev/null +++ b/Include/API/lib3mf_normalizedistancenode.hpp @@ -0,0 +1,104 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CNormalizeDistanceNode + +*/ + + +#ifndef __LIB3MF_NORMALIZEDISTANCENODE +#define __LIB3MF_NORMALIZEDISTANCENODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CNormalizeDistanceNode +**************************************************************************************************************************/ + +class CNormalizeDistanceNode : public virtual INormalizeDistanceNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + CNormalizeDistanceNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Public member functions to implement. + */ + + IImplicitPort * GetInputFunctionID() override; + + IImplicitPort * GetInputPos() override; + + IImplicitPort * GetInputStep() override; + + void SetScalarOutputName(const std::string & sScalarOutputName) override; + + std::string GetScalarOutputName() override; + + void SetVectorInputName(const std::string & sVectorInputName) override; + + std::string GetVectorInputName() override; + + IImplicitPort * GetOutputResult() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_NORMALIZEDISTANCENODE diff --git a/Include/API/lib3mf_object.hpp b/Include/API/lib3mf_object.hpp index 24bee6c..1b92133 100644 --- a/Include/API/lib3mf_object.hpp +++ b/Include/API/lib3mf_object.hpp @@ -92,6 +92,8 @@ public: virtual bool IsComponentsObject (); + virtual bool IsLevelSetObject (); + virtual IMeshObject * AsMeshObject(); virtual IComponentsObject * AsComponentsObject(); diff --git a/Include/API/lib3mf_objectiterator.hpp b/Include/API/lib3mf_objectiterator.hpp index e3b23f1..e1e1947 100644 --- a/Include/API/lib3mf_objectiterator.hpp +++ b/Include/API/lib3mf_objectiterator.hpp @@ -76,7 +76,10 @@ public: * Public member functions to implement. */ - IObject * GetCurrentObject (); + IObject * GetCurrentObject() override; + + + IResource * GetCurrent() override; }; diff --git a/Include/API/lib3mf_oneinputnode.hpp b/Include/API/lib3mf_oneinputnode.hpp new file mode 100644 index 0000000..823e7d4 --- /dev/null +++ b/Include/API/lib3mf_oneinputnode.hpp @@ -0,0 +1,101 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of COneInputNode + +*/ + + +#ifndef __LIB3MF_ONEINPUTNODE +#define __LIB3MF_ONEINPUTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of COneInputNode +**************************************************************************************************************************/ + +class COneInputNode : public virtual IOneInputNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + COneInputNode() = default; + COneInputNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IOneInputNode::GetInputA - Retrieves the input + * @return the input + */ + IImplicitPort * GetInputA() override; + + /** + * IOneInputNode::GetOutputResult - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputResult() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ONEINPUTNODE diff --git a/Include/API/lib3mf_pownode.hpp b/Include/API/lib3mf_pownode.hpp new file mode 100644 index 0000000..991e53b --- /dev/null +++ b/Include/API/lib3mf_pownode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CPowNode + +*/ + + +#ifndef __LIB3MF_POWNODE +#define __LIB3MF_POWNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CPowNode +**************************************************************************************************************************/ + +class CPowNode : public virtual IPowNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CPowNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_POWNODE diff --git a/Include/API/lib3mf_reader.hpp b/Include/API/lib3mf_reader.hpp index 50a4c78..1e0f76e 100644 --- a/Include/API/lib3mf_reader.hpp +++ b/Include/API/lib3mf_reader.hpp @@ -48,6 +48,7 @@ Abstract: This is the class declaration of CReader namespace Lib3MF { namespace Impl { +#define LIB3MF_READER_MAXKEYSIZE (1UL << 31) /************************************************************************************************************************* Class declaration of CReader diff --git a/Include/API/lib3mf_resource.hpp b/Include/API/lib3mf_resource.hpp index a24bf7f..846a27f 100644 --- a/Include/API/lib3mf_resource.hpp +++ b/Include/API/lib3mf_resource.hpp @@ -61,9 +61,9 @@ private: protected: - NMR::PModelResource resource(); - public: + NMR::CModel* model(); + NMR::PModelResource resource(); /** * Put additional public members here. They will not be visible in the external API. diff --git a/Include/API/lib3mf_resourceidnode.hpp b/Include/API/lib3mf_resourceidnode.hpp new file mode 100644 index 0000000..2e620b4 --- /dev/null +++ b/Include/API/lib3mf_resourceidnode.hpp @@ -0,0 +1,106 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CResourceIdNode + +*/ + + +#ifndef __LIB3MF_RESOURCEIDNODE +#define __LIB3MF_RESOURCEIDNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CResourceIdNode +**************************************************************************************************************************/ + +class CResourceIdNode : public virtual IResourceIdNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + CResourceIdNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IResourceIdNode::SetResource - Sets the Resource that the resourceid attribute of the node will point to + * @param[in] pResource - the resource + */ + void SetResource(IResource* pResource) override; + + /** + * IResourceIdNode::GetResource - Retrieves the resource of the node + * @return the resource + */ + IResource * GetResource() override; + + /** + * IResourceIdNode::GetOutputValue - Retrieves the output + * @return the output + */ + IImplicitPort * GetOutputValue() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_RESOURCEIDNODE diff --git a/Include/API/lib3mf_resourceiterator.hpp b/Include/API/lib3mf_resourceiterator.hpp index 0641172..42e76a9 100644 --- a/Include/API/lib3mf_resourceiterator.hpp +++ b/Include/API/lib3mf_resourceiterator.hpp @@ -54,6 +54,8 @@ namespace Impl { class CResourceIterator : public virtual IResourceIterator, public virtual CBase { private: + NMR::PModel m_pModel; + std::vector m_pResources; Lib3MF_int32 m_nCurrentIndex; diff --git a/Include/API/lib3mf_roundnode.hpp b/Include/API/lib3mf_roundnode.hpp new file mode 100644 index 0000000..7266211 --- /dev/null +++ b/Include/API/lib3mf_roundnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CRoundNode + +*/ + + +#ifndef __LIB3MF_ROUNDNODE +#define __LIB3MF_ROUNDNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CRoundNode +**************************************************************************************************************************/ + +class CRoundNode : public virtual IRoundNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CRoundNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_ROUNDNODE diff --git a/Include/API/lib3mf_selectnode.hpp b/Include/API/lib3mf_selectnode.hpp new file mode 100644 index 0000000..7b0cf39 --- /dev/null +++ b/Include/API/lib3mf_selectnode.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CSelectNode + +*/ + + +#ifndef __LIB3MF_SELECTNODE +#define __LIB3MF_SELECTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CSelectNode +**************************************************************************************************************************/ + +class CSelectNode : public virtual ISelectNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CSelectNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * ISelectNode::GetInputB - Retrieves the second input + * @return the second input + */ + IImplicitPort * GetInputB() override; + + /** + * ISelectNode::GetInputC - Retrieves the third input + * @return the third input + */ + IImplicitPort * GetInputC() override; + + /** + * ISelectNode::GetInputD - Retrieves the fourth input + * @return the fourth input + */ + IImplicitPort * GetInputD() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_SELECTNODE diff --git a/Include/API/lib3mf_signnode.hpp b/Include/API/lib3mf_signnode.hpp new file mode 100644 index 0000000..1451891 --- /dev/null +++ b/Include/API/lib3mf_signnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CSignNode + +*/ + + +#ifndef __LIB3MF_SIGNNODE +#define __LIB3MF_SIGNNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CSignNode +**************************************************************************************************************************/ + +class CSignNode : public virtual ISignNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CSignNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_SIGNNODE diff --git a/Include/API/lib3mf_sinhnode.hpp b/Include/API/lib3mf_sinhnode.hpp new file mode 100644 index 0000000..397b75e --- /dev/null +++ b/Include/API/lib3mf_sinhnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CSinhNode + +*/ + + +#ifndef __LIB3MF_SINHNODE +#define __LIB3MF_SINHNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CSinhNode +**************************************************************************************************************************/ + +class CSinhNode : public virtual ISinhNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CSinhNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_SINHNODE diff --git a/Include/API/lib3mf_sinnode.hpp b/Include/API/lib3mf_sinnode.hpp new file mode 100644 index 0000000..2b19cb2 --- /dev/null +++ b/Include/API/lib3mf_sinnode.hpp @@ -0,0 +1,88 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CSinNode + +*/ + + +#ifndef __LIB3MF_SINNODE +#define __LIB3MF_SINNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CSinNode +**************************************************************************************************************************/ + +class CSinNode : public virtual ISinNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CSinNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_SINNODE diff --git a/Include/API/lib3mf_slicestackiterator.hpp b/Include/API/lib3mf_slicestackiterator.hpp index ab1c589..fac9a6f 100644 --- a/Include/API/lib3mf_slicestackiterator.hpp +++ b/Include/API/lib3mf_slicestackiterator.hpp @@ -76,7 +76,9 @@ public: * Public member functions to implement. */ - ISliceStack * GetCurrentSliceStack (); + ISliceStack * GetCurrentSliceStack() override; + + IResource * GetCurrent() override; }; diff --git a/Include/API/lib3mf_sqrtnode.hpp b/Include/API/lib3mf_sqrtnode.hpp new file mode 100644 index 0000000..bb8124f --- /dev/null +++ b/Include/API/lib3mf_sqrtnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CSqrtNode + +*/ + + +#ifndef __LIB3MF_SQRTNODE +#define __LIB3MF_SQRTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CSqrtNode +**************************************************************************************************************************/ + +class CSqrtNode : public virtual ISqrtNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CSqrtNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_SQRTNODE diff --git a/Include/API/lib3mf_subtractionnode.hpp b/Include/API/lib3mf_subtractionnode.hpp new file mode 100644 index 0000000..4e6eb35 --- /dev/null +++ b/Include/API/lib3mf_subtractionnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CSubtractionNode + +*/ + + +#ifndef __LIB3MF_SUBTRACTIONNODE +#define __LIB3MF_SUBTRACTIONNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_twoinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CSubtractionNode +**************************************************************************************************************************/ + +class CSubtractionNode : public virtual ISubtractionNode, public virtual CTwoInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CSubtractionNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_SUBTRACTIONNODE diff --git a/Include/API/lib3mf_tanhnode.hpp b/Include/API/lib3mf_tanhnode.hpp new file mode 100644 index 0000000..a6ff9ad --- /dev/null +++ b/Include/API/lib3mf_tanhnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CTanhNode + +*/ + + +#ifndef __LIB3MF_TANHNODE +#define __LIB3MF_TANHNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CTanhNode +**************************************************************************************************************************/ + +class CTanhNode : public virtual ITanhNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CTanhNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_TANHNODE diff --git a/Include/API/lib3mf_tannode.hpp b/Include/API/lib3mf_tannode.hpp new file mode 100644 index 0000000..53c0c86 --- /dev/null +++ b/Include/API/lib3mf_tannode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CTanNode + +*/ + + +#ifndef __LIB3MF_TANNODE +#define __LIB3MF_TANNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CTanNode +**************************************************************************************************************************/ + +class CTanNode : public virtual ITanNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CTanNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_TANNODE diff --git a/Include/API/lib3mf_texture2dgroupiterator.hpp b/Include/API/lib3mf_texture2dgroupiterator.hpp index 140ce6a..5b1fd3b 100644 --- a/Include/API/lib3mf_texture2dgroupiterator.hpp +++ b/Include/API/lib3mf_texture2dgroupiterator.hpp @@ -76,7 +76,9 @@ public: * Public member functions to implement. */ - ITexture2DGroup * GetCurrentTexture2DGroup (); + ITexture2DGroup * GetCurrentTexture2DGroup() override; + + IResource * GetCurrent() override; }; diff --git a/Include/API/lib3mf_texture2diterator.hpp b/Include/API/lib3mf_texture2diterator.hpp index 74a8f28..9096c59 100644 --- a/Include/API/lib3mf_texture2diterator.hpp +++ b/Include/API/lib3mf_texture2diterator.hpp @@ -76,8 +76,9 @@ public: * Public member functions to implement. */ - ITexture2D * GetCurrentTexture2D (); + ITexture2D * GetCurrentTexture2D() override; + IResource * GetCurrent() override; }; } // namespace Impl diff --git a/Include/API/lib3mf_transposenode.hpp b/Include/API/lib3mf_transposenode.hpp new file mode 100644 index 0000000..a1c30ca --- /dev/null +++ b/Include/API/lib3mf_transposenode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CTransposeNode + +*/ + + +#ifndef __LIB3MF_TRANSPOSENODE +#define __LIB3MF_TRANSPOSENODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CTransposeNode +**************************************************************************************************************************/ + +class CTransposeNode : public virtual ITransposeNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CTransposeNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_TRANSPOSENODE diff --git a/Include/API/lib3mf_triangleset.hpp b/Include/API/lib3mf_triangleset.hpp new file mode 100644 index 0000000..c15833a --- /dev/null +++ b/Include/API/lib3mf_triangleset.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CMeshObject + +*/ + + +#ifndef __LIB3MF_TRIANGLESET +#define __LIB3MF_TRIANGLESET + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_object.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" + +namespace Lib3MF { +namespace Impl { + +/************************************************************************************************************************* + Class declaration of CMeshObject +**************************************************************************************************************************/ + +class CTriangleSet : public virtual ITriangleSet, public virtual CBase { +protected: + NMR::PModelTriangleSet m_pTriangleSet; + NMR::PModelMeshObject m_pMeshObject; + +public: + /** + * Put additional public members here. They will not be visible in the external API. + */ + CTriangleSet(NMR::PModelTriangleSet pTriangleSet, NMR::PModelMeshObject pMeshObject); + + virtual ~CTriangleSet(); + + void SetName(const std::string& sName) override; + + std::string GetName() override; + + void SetIdentifier(const std::string& sIdentifier) override; + + std::string GetIdentifier() override; + + void AddTriangle(const Lib3MF_uint32 nTriangleIndex) override; + + void RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) override; + + void Clear() override; + + void SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) override; + + void GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64 * pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) override; + + void AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) override; + + void Merge(ITriangleSet* pOtherTriangleSet, const bool bDeleteOther) override; + + void DeleteSet() override; + + ITriangleSet* Duplicate(const std::string& sIdentifier) override; + + NMR::PModelTriangleSet triangleSet(); + +}; + +} +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_TRIANGLESET diff --git a/Include/API/lib3mf_twoinputnode.hpp b/Include/API/lib3mf_twoinputnode.hpp new file mode 100644 index 0000000..a532259 --- /dev/null +++ b/Include/API/lib3mf_twoinputnode.hpp @@ -0,0 +1,94 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CTwoInputNode + +*/ + + +#ifndef __LIB3MF_TWOINPUTNODE +#define __LIB3MF_TWOINPUTNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CTwoInputNode +**************************************************************************************************************************/ + +class CTwoInputNode : public virtual ITwoInputNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CTwoInputNode() = default; + CTwoInputNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * ITwoInputNode::GetInputB - Retrieves the second input + * @return the second input + */ + IImplicitPort * GetInputB() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_TWOINPUTNODE diff --git a/Include/API/lib3mf_unsignedmeshnode.hpp b/Include/API/lib3mf_unsignedmeshnode.hpp new file mode 100644 index 0000000..29dbe1f --- /dev/null +++ b/Include/API/lib3mf_unsignedmeshnode.hpp @@ -0,0 +1,105 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CUnsignedMeshNode + +*/ + + +#ifndef __LIB3MF_UNSIGNEDMESHNODE +#define __LIB3MF_UNSIGNEDMESHNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_implicitnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CUnsignedMeshNode +**************************************************************************************************************************/ + +class CUnsignedMeshNode : public virtual IUnsignedMeshNode, public virtual CImplicitNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CUnsignedMeshNode(NMR::PModelImplicitNode pImplicitNode); + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + /** + * IUnsignedMeshNode::GetInputMesh - Retrieves the input for the model resource id of the mesh + * @return the input port for the model resource id of the mesh + */ + IImplicitPort * GetInputMesh() override; + + /** + * IUnsignedMeshNode::GetInputPos - Retrieves the input for the position + * @return the input port for the position + */ + IImplicitPort * GetInputPos() override; + + /** + * IUnsignedMeshNode::GetOutputDistance - Retrieves the output + * @return the output port for the unsigned distance to the mesh + */ + IImplicitPort * GetOutputDistance() override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_UNSIGNEDMESHNODE diff --git a/Include/API/lib3mf_utils.hpp b/Include/API/lib3mf_utils.hpp index 235df5d..66883f3 100644 --- a/Include/API/lib3mf_utils.hpp +++ b/Include/API/lib3mf_utils.hpp @@ -36,6 +36,7 @@ Abstract: This file contains utilties used in the API of lib3mf // Include custom headers here. #include "Common/Math/NMR_Matrix.h" +#include "Model/Classes/NMR_ModelTypes.h" #include "Common/NMR_SecureContentTypes.h" namespace Lib3MF { diff --git a/Include/API/lib3mf_vectorfromscalarnode.hpp b/Include/API/lib3mf_vectorfromscalarnode.hpp new file mode 100644 index 0000000..aa9d787 --- /dev/null +++ b/Include/API/lib3mf_vectorfromscalarnode.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CVectorFromScalarNode + +*/ + + +#ifndef __LIB3MF_VECTORFROMSCALARNODE +#define __LIB3MF_VECTORFROMSCALARNODE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_oneinputnode.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CVectorFromScalarNode +**************************************************************************************************************************/ + +class CVectorFromScalarNode : public virtual IVectorFromScalarNode, public virtual COneInputNode { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + CVectorFromScalarNode(NMR::PModelImplicitNode pImplicitNode); + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_VECTORFROMSCALARNODE diff --git a/Include/API/lib3mf_volumedata.hpp b/Include/API/lib3mf_volumedata.hpp new file mode 100644 index 0000000..d90bee8 --- /dev/null +++ b/Include/API/lib3mf_volumedata.hpp @@ -0,0 +1,116 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CVolumeData + +*/ + + +#ifndef __LIB3MF_VOLUMEDATA +#define __LIB3MF_VOLUMEDATA + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" +#include "lib3mf_resource.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Common/Mesh/NMR_Mesh.h" +#include "Model/Classes/NMR_ModelVolumeData.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelResource.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CVolumeData +**************************************************************************************************************************/ + +class CVolumeData : public virtual IVolumeData, public virtual CResource { +private: + + /** + * Put private members here. + */ + NMR::PModelVolumeData m_pVolumeData; + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CVolumeData() = delete; + CVolumeData(NMR::PModelResource pResource); + + // CVolumeData(NMR::PModelMeshObject pMeshObject, NMR::PModelVolumeData pVolumeData); + + /** + * Public member functions to implement. + */ + IVolumeDataComposite * GetComposite() override; + + IVolumeDataComposite * CreateNewComposite() override; + + void RemoveComposite() override; + + IVolumeDataColor * GetColor() override; + + IVolumeDataColor* CreateNewColor(IFunction* pTheFunction) override; + + void RemoveColor() override; + + Lib3MF_uint32 GetPropertyCount() override; + + IVolumeDataProperty * GetProperty(const Lib3MF_uint32 nIndex) override; + + IVolumeDataProperty* AddPropertyFromFunction( + const std::string& sName, IFunction* pTheFunction) override; + + + void RemoveProperty(const Lib3MF_uint32 nIndex) override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_VOLUMEDATA diff --git a/Include/API/lib3mf_volumedatacolor.hpp b/Include/API/lib3mf_volumedatacolor.hpp new file mode 100644 index 0000000..524ce88 --- /dev/null +++ b/Include/API/lib3mf_volumedatacolor.hpp @@ -0,0 +1,89 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CVolumeDataColor + +*/ + + +#ifndef __LIB3MF_VOLUMEDATACOLOR +#define __LIB3MF_VOLUMEDATACOLOR + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_functionreference.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Common/Mesh/NMR_VolumeDataColor.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CVolumeDataColor +**************************************************************************************************************************/ + +class CVolumeDataColor : public virtual IVolumeDataColor, public virtual CFunctionReference { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + NMR::PVolumeDataColor asVolumeDataColor(); + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CVolumeDataColor() = delete; + CVolumeDataColor(NMR::PVolumeDataColor pColor); + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_VOLUMEDATACOLOR diff --git a/Include/API/lib3mf_volumedatacomposite.hpp b/Include/API/lib3mf_volumedatacomposite.hpp new file mode 100644 index 0000000..b2f9ebf --- /dev/null +++ b/Include/API/lib3mf_volumedatacomposite.hpp @@ -0,0 +1,102 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CVolumeDataComposite + +*/ + + +#ifndef __LIB3MF_VOLUMEDATACOMPOSITE +#define __LIB3MF_VOLUMEDATACOMPOSITE + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Common/Mesh/NMR_VolumeDataComposite.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CVolumeDataComposite +**************************************************************************************************************************/ + +class CVolumeDataComposite : public virtual IVolumeDataComposite, public virtual CBase { +private: + + /** + * Put private members here. + */ + NMR::PVolumeDataComposite m_pVolumeDataComposite; + +protected: + + /** + * Put protected members here. + */ + NMR::PVolumeDataComposite volumeDataComposite(); + + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CVolumeDataComposite() = delete; + CVolumeDataComposite(NMR::PVolumeDataComposite pComposite); + + /** + * Public member functions to implement. + */ + IBaseMaterialGroup * GetBaseMaterialGroup() override; + + void SetBaseMaterialGroup(IBaseMaterialGroup* pBaseMaterialGroupInstance) override; + + Lib3MF_uint32 GetMaterialMappingCount() override; + + IMaterialMapping * GetMaterialMapping(const Lib3MF_uint32 nIndex) override; + + IMaterialMapping * AddMaterialMapping(const Lib3MF::sTransform Transform) override; + + void RemoveMaterialMapping(const Lib3MF_uint32 nIndex) override; + +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_VOLUMEDATACOMPOSITE diff --git a/Include/API/lib3mf_volumedataproperty.hpp b/Include/API/lib3mf_volumedataproperty.hpp new file mode 100644 index 0000000..696ae53 --- /dev/null +++ b/Include/API/lib3mf_volumedataproperty.hpp @@ -0,0 +1,94 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is the class declaration of CVolumeDataProperty + +*/ + + +#ifndef __LIB3MF_VOLUMEDATAPROPERTY +#define __LIB3MF_VOLUMEDATAPROPERTY + +#include "lib3mf_interfaces.hpp" + +// Parent classes +#include "lib3mf_functionreference.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "Common/Mesh/NMR_VolumeDataProperty.h" + +namespace Lib3MF { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CVolumeDataProperty +**************************************************************************************************************************/ + +class CVolumeDataProperty : public virtual IVolumeDataProperty, public virtual CFunctionReference { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + NMR::PVolumeDataProperty asVolumeDataProperty(); + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + CVolumeDataProperty() = delete; + CVolumeDataProperty(NMR::PVolumeDataProperty pProperty); + + /** + * Public member functions to implement. + */ + + std::string GetName() override; + + void SetIsRequired(const bool bIsRequired) override; + + bool IsRequired() override; +}; + +} // namespace Impl +} // namespace Lib3MF + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIB3MF_VOLUMEDATAPROPERTY diff --git a/Include/API/lib3mf_writer.hpp b/Include/API/lib3mf_writer.hpp index 6cf997f..9aebe50 100644 --- a/Include/API/lib3mf_writer.hpp +++ b/Include/API/lib3mf_writer.hpp @@ -57,6 +57,8 @@ namespace Impl { Class declaration of CWriter **************************************************************************************************************************/ +#define LIB3MF_WRITER_MAXKEYSIZE (1UL << 31) + class CWriter : public virtual IWriter, public virtual CBase { private: @@ -98,17 +100,17 @@ public: void SetDecimalPrecision(const Lib3MF_uint32 nDecimalPrecision) override; - void AddKeyWrappingCallback(const std::string & sConsumerID, const Lib3MF::KeyWrappingCallback pTheCallback, const Lib3MF_pvoid pUserData); + void AddKeyWrappingCallback(const std::string & sConsumerID, const Lib3MF::KeyWrappingCallback pTheCallback, const Lib3MF_pvoid pUserData) override; - void SetContentEncryptionCallback(const Lib3MF::ContentEncryptionCallback pTheCallback, const Lib3MF_pvoid pUserData); + void SetContentEncryptionCallback(const Lib3MF::ContentEncryptionCallback pTheCallback, const Lib3MF_pvoid pUserData) override; - void SetStrictModeActive(const bool bStrictModeActive); + void SetStrictModeActive(const bool bStrictModeActive) override; - bool GetStrictModeActive(); + bool GetStrictModeActive() override; - std::string GetWarning(const Lib3MF_uint32 nIndex, Lib3MF_uint32 & nErrorCode); + std::string GetWarning(const Lib3MF_uint32 nIndex, Lib3MF_uint32 & nErrorCode) override; - Lib3MF_uint32 GetWarningCount(); + Lib3MF_uint32 GetWarningCount() override; }; diff --git a/Include/Common/Graph/DirectedGraph.h b/Include/Common/Graph/DirectedGraph.h new file mode 100644 index 0000000..a6a6c0e --- /dev/null +++ b/Include/Common/Graph/DirectedGraph.h @@ -0,0 +1,67 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification,276529 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. + +--*/ + +#pragma once +#include "IDirectedGraph.h" + +namespace NMR::common::graph +{ + class DirectedGraph : public IDirectedGraph + { + public: + explicit DirectedGraph(std::size_t size); + void addDependency(Identifier id, Identifier idOfDependency) override; + void removeDependency(Identifier id, + Identifier idOfDependency) override; + [[nodiscard]] auto isDirectlyDependingOn( + Identifier id, + Identifier dependencyInQuestion) const -> bool override; + + [[nodiscard]] auto getSize() const -> std::size_t override; + + void removeVertex(Identifier id) override; + + [[nodiscard]] auto getVertices() const -> const DependencySet& override; + void addVertex(Identifier id) override; + + private: + std::size_t m_size; + std::vector m_graphData; + + DependencySet m_vertices; // Possible performance improvement: We could + // try out a std::set + + using PredecessorList = std::vector; + std::vector m_predecessors; + + // Inherited via IDirectedGraph + [[nodiscard]] auto hasPredecessors(Identifier id) const + -> bool override; + }; +} // namespace NMR::common::graph diff --git a/Include/Common/Graph/GraphAlgorithms.h b/Include/Common/Graph/GraphAlgorithms.h new file mode 100644 index 0000000..2ffc4b1 --- /dev/null +++ b/Include/Common/Graph/GraphAlgorithms.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification,276529 +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. + +--*/ + +#pragma once + +#include "IDirectedGraph.h" +#include +#include +#include +#include + +namespace NMR::common::graph +{ + VertexList topologicalSort(const IDirectedGraph & graph); + bool isCyclic(const IDirectedGraph & graph); +} diff --git a/Include/Common/Graph/IDirectedGraph.h b/Include/Common/Graph/IDirectedGraph.h new file mode 100644 index 0000000..aa109ff --- /dev/null +++ b/Include/Common/Graph/IDirectedGraph.h @@ -0,0 +1,62 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification,276529 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. + +--*/ + +#pragma once + +#include +#include + +namespace NMR::common::graph +{ + using Identifier = std::size_t; + using DependencySet = std::set; + using VertexList = std::vector; + + class IDirectedGraph + { + public: + explicit IDirectedGraph(std::size_t const /*unused*/) {}; + virtual ~IDirectedGraph() = default; + virtual void addDependency(Identifier id, + Identifier idOfDependency) = 0; + virtual void removeDependency(Identifier id, + Identifier idOfDependency) = 0; + [[nodiscard]] virtual auto isDirectlyDependingOn( + Identifier id, Identifier dependencyInQuestion) const -> bool = 0; + + [[nodiscard]] virtual auto getSize() const -> std::size_t = 0; + virtual void removeVertex(Identifier id) = 0; + virtual void addVertex(Identifier id) = 0; + [[nodiscard]] virtual auto hasPredecessors(Identifier id) const + -> bool = 0; + + [[nodiscard]] virtual auto getVertices() const + -> const DependencySet& = 0; + }; +} // namespace NMR::common::graph diff --git a/Include/Common/Mesh/NMR_Mesh.h b/Include/Common/Mesh/NMR_Mesh.h index 628f43d..1297bff 100644 --- a/Include/Common/Mesh/NMR_Mesh.h +++ b/Include/Common/Mesh/NMR_Mesh.h @@ -57,8 +57,9 @@ namespace NMR { MESHFACES m_Faces; CBeamLattice m_BeamLattice; - PMeshInformationHandler m_pMeshInformationHandler; + + PMeshInformationHandler m_pMeshInformationHandler; public: CMesh(); CMesh(_In_opt_ CMesh * pMesh); diff --git a/Include/Common/Mesh/NMR_MeshTypes.h b/Include/Common/Mesh/NMR_MeshTypes.h index 5dbe043..b931694 100644 --- a/Include/Common/Mesh/NMR_MeshTypes.h +++ b/Include/Common/Mesh/NMR_MeshTypes.h @@ -81,16 +81,13 @@ namespace NMR { m_sIdentifier = ""; } } BEAMSET; - typedef std::shared_ptr PBEAMSET; + typedef std::shared_ptr PBEAMSET; typedef struct MESHBEAM { - nfInt32 m_index; - nfInt32 m_nodeindices[2]; - nfDouble m_radius[2]; - nfInt32 m_capMode[2]; - // eModelBeamLatticeCapMode m_capMode[2]; - MESHBEAM() { - }; + nfInt32 m_index = 1; + nfInt32 m_nodeindices[2] = { 0, 0 }; + nfDouble m_radius[2] = { 1., 1. }; + nfInt32 m_capMode[2] = { 0,0 }; } MESHBEAM; typedef CPagedVector MESHBEAMS; @@ -98,8 +95,6 @@ namespace NMR { nfInt32 m_index; nfInt32 m_nodeindex; nfDouble m_radius; - MESHBALL() { - }; } MESHBALL; typedef CPagedVector MESHBALLS; diff --git a/Include/Common/Mesh/NMR_VolumeDataBoundary.h b/Include/Common/Mesh/NMR_VolumeDataBoundary.h new file mode 100644 index 0000000..f05cee9 --- /dev/null +++ b/Include/Common/Mesh/NMR_VolumeDataBoundary.h @@ -0,0 +1,61 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeDataBoundary.h defines the class CVolumeDataBoundary. + +--*/ + +#ifndef __NMR_VOLUMEDATABOUNDARY +#define __NMR_VOLUMEDATABOUNDARY + +#include "Common/NMR_Types.h" +#include "Model/Classes/NMR_ModelTypes.h" +#include "Common/NMR_FunctionReference.h" +#include + +namespace NMR { + class CModelFunction; + typedef std::shared_ptr PModelFunction; + + class CVolumeDataBoundary : public CFunctionReference { + private: + + bool m_meshBBoxOnly = false; + public: + CVolumeDataBoundary() = delete; + CVolumeDataBoundary(PModelFunction pFunction); + + bool getMeshBBoxOnly(); + void setMeshBBoxOnly(bool bMeshBBoxOnly); + }; + + typedef std::shared_ptr PVolumeDataBoundary; + +} + +#endif // __NMR_VOLUMEDATABOUNDARY diff --git a/Include/Common/Mesh/NMR_VolumeDataColor.h b/Include/Common/Mesh/NMR_VolumeDataColor.h new file mode 100644 index 0000000..a88db4f --- /dev/null +++ b/Include/Common/Mesh/NMR_VolumeDataColor.h @@ -0,0 +1,54 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeDataColor.h defines the class CVolumeDataColor. + +--*/ + +#ifndef __NMR_VOLUMECOLOR +#define __NMR_VOLUMECOLOR + +#include "Common/NMR_Types.h" +#include "Model/Classes/NMR_ModelTypes.h" +#include "Common/NMR_FunctionReference.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_ModelFunction.h" + +namespace NMR { + + class CVolumeDataColor : public CFunctionReference { + private: + + public: + CVolumeDataColor(PModelFunction pFunction); + }; + + typedef std::shared_ptr PVolumeDataColor; +} + +#endif // __NMR_VOLUMECOLOR diff --git a/Include/Common/Mesh/NMR_VolumeDataComposite.h b/Include/Common/Mesh/NMR_VolumeDataComposite.h new file mode 100644 index 0000000..60b5d39 --- /dev/null +++ b/Include/Common/Mesh/NMR_VolumeDataComposite.h @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeComposite.h defines the class CVolumeDataComposite. + +--*/ + +#ifndef __NMR_VOLUMEDATACOMPOSITE +#define __NMR_VOLUMEDATACOMPOSITE + +#include +#include "Common/NMR_Types.h" +#include "Common/NMR_FunctionReference.h" +#include "Model/Classes/NMR_ModelTypes.h" +#include "Model/Classes/NMR_ModelBaseMaterials.h" + +namespace NMR { + + class CModelFunction; + typedef std::shared_ptr PModelFunction; + // does not derive from the CVolumeBase, as CVolumeDataComposite contains + // multiple ScalarFieldReferences, but is not a ScalarFieldReference itself. + class CVolumeDataComposite { + private: + std::vector m_vctFunctionReferences; + NMR::PModelBaseMaterialResource m_pBaseMaterialGroup; + public: + CVolumeDataComposite(); + + NMR::PModelBaseMaterialResource getBaseMaterialGroup(); + void setBaseMaterialGroup(PModelBaseMaterialResource ); + + nfUint32 materialMappingCount() const; + PFunctionReference getMaterialMapping(nfUint32); + PFunctionReference addMaterialMapping(PModelFunction pFunction); + void removeMaterialMapping(nfUint32); + }; + + typedef std::shared_ptr PVolumeDataComposite; + +} + +#endif // __NMR_VOLUMEDATACOMPOSITE diff --git a/Include/Common/Mesh/NMR_VolumeDataProperty.h b/Include/Common/Mesh/NMR_VolumeDataProperty.h new file mode 100644 index 0000000..410c704 --- /dev/null +++ b/Include/Common/Mesh/NMR_VolumeDataProperty.h @@ -0,0 +1,64 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeDataProperty.h defines the class CVolumeDataProperty. + +--*/ + +#ifndef __NMR_VOLUMEDATAPROPERTY +#define __NMR_VOLUMEDATAPROPERTY + +#include "Common/NMR_Types.h" +#include "Model/Classes/NMR_ModelTypes.h" +#include "Common/NMR_FunctionReference.h" + +namespace NMR { + class CModelFunction; + typedef std::shared_ptr PModelFunction; + + class CVolumeDataProperty : public CFunctionReference { + private: + std::string m_sName; + bool m_bIsRequired; + public: + CVolumeDataProperty() = delete; + explicit CVolumeDataProperty(PModelFunction pFunction); + CVolumeDataProperty(PModelFunction pFunction, std::string sName); + + std::string getName(); + void setName(std::string sPropertyName); + + bool isRequired(); + void setIsRequired(bool bIsRequired); + }; + + typedef std::shared_ptr PVolumeDataProperty; + +} + +#endif // __NMR_VOLUMEDATAPROPERTY diff --git a/Include/Common/MeshInformation/NMR_MeshInformationTypes.h b/Include/Common/MeshInformation/NMR_MeshInformationTypes.h index c61513a..dc9ae88 100644 --- a/Include/Common/MeshInformation/NMR_MeshInformationTypes.h +++ b/Include/Common/MeshInformation/NMR_MeshInformationTypes.h @@ -50,9 +50,9 @@ namespace NMR { typedef nfByte MESHINFORMATIONFACEDATA; #pragma pack (1) - typedef struct { - nfUint32 m_nUniqueResourceID; - nfUint32 m_nPropertyIDs[3]; + typedef struct sMESHINFORMATION_PROPERTIES { + nfUint32 m_nUniqueResourceID = 0; + nfUint32 m_nPropertyIDs[3] = { 0,0,0 }; } MESHINFORMATION_PROPERTIES; diff --git a/Include/Common/NMR_ErrorConst.h b/Include/Common/NMR_ErrorConst.h index 598880d..007b4f7 100644 --- a/Include/Common/NMR_ErrorConst.h +++ b/Include/Common/NMR_ErrorConst.h @@ -299,6 +299,9 @@ NMR_ErrorConst.h defines all error code constants. // Failed to initialize a zlib buffer #define NMR_ERROR_COULDNOTINITDEFLATE 0x1052 +// Too many slices +#define NMR_ERROR_TOOMANYSLICES 0x1053 + /*------------------------------------------------------------------- Core framework error codes (0x2XXX) -------------------------------------------------------------------*/ @@ -495,6 +498,25 @@ Core framework error codes (0x2XXX) // Invalid slice vertex index #define NMR_ERROR_INVALIDSLICEVERTEX 0x2041 +// Duplicate triangle set +#define NMR_ERROR_DUPLICATETRIANGLESET 0x2042 + +// Too many triangle sets +#define NMR_ERROR_TOOMANYTRIANGLESETS 0x2043 + +// Invalid triangle set attribute +#define NMR_ERROR_TRIANGLESETINVALIDATTRIBUTE 0x2044 + +// Missing triangle set reference index +#define NMR_ERROR_TRIANGLESETMISSINGREFERENCEINDEX 0x2045 + +// Triangle set name missing +#define NMR_ERROR_TRIANGLESETNAMEMISSING 0x2046 + +// Triangle set identifier missing +#define NMR_ERROR_TRIANGLESETIDENTIFIERMISSING 0x2047 + + /*------------------------------------------------------------------- Model error codes (0x8XXX) -------------------------------------------------------------------*/ @@ -1219,8 +1241,241 @@ Model error codes (0x8XXX) // A beamset identifier is not unique #define NMR_ERROR_BEAMSET_IDENTIFIER_NOT_UNIQUE 0x810B +// A transform attribute is duplicated +#define NMR_ERROR_DUPLICATETRANSFORM 0x810C +// A component resource is invalid +#define NMR_ERROR_INVALIDCOMPONENTRESOURCE 0x810D +// A keystore element is not base64 encoded +#define NMR_ERROR_KEYSTOREINVALIDENCODING 0x810E + +// errors for the volumetric extension 0x88xx + +// Invalid Image3D Size +#define NMR_ERROR_INVALIDIMAGE3DSIZE 0x8800 + +// Too many channel selectors +#define NMR_ERROR_TOOMANYCHANNELSELECTORS 0x8801 + +// Too many volumetric channels +#define NMR_ERROR_TOOMANYVOLUMETRICCHANNELS 0x8802 + +// Could not map package ID +#define NMR_ERROR_COULDNOTMAPPACKAGEID 0x8803 + +// Duplicate volumetric channel +#define NMR_ERROR_DUPLICATEVOLUMETRICCHANNEL 0x8804 + +// Could not remove volumetric layer +#define NMR_ERROR_COULDNOTREMOVEVOLUMETRICLAYER 0x8805 + +// Could not reindex volumetric layer +#define NMR_ERROR_COULDNOTREINDEXVOLUMETRICLAYER 0x8806 + +// Could not reindex channel selector +#define NMR_ERROR_COULDNOTREINDEXCHANNELSELECTOR 0x8807 + +// Duplicate Image3D Name +#define NMR_ERROR_DUPLICATEIMAGE3DNAME 0x8808 + +// Duplicate Image3D Size +#define NMR_ERROR_DUPLICATEIMAGESTACKSIZE 0x8809 + +// Duplicate Image3D Sheet count +#define NMR_ERROR_DUPLICATEIMAGESTACKSHEETCOUNT 0x880A + +// Missing Image Stack Size +#define NMR_ERROR_MISSINGIMAGESTACKSIZE 0x880B + +// Missing Image Stack Sheetcount +#define NMR_ERROR_MISSINGIMAGESTACKSHEETCOUNT 0x880C + +// Missing 3D Image Name +#define NMR_ERROR_MISSINGIMAGE3DNAME 0x880D + +// Invalid Image3D Sheet Count +#define NMR_ERROR_INVALIDIMAGSHEETCOUNT 0x880E + +// Image Sheet not found +#define NMR_ERROR_IMAGESHEETNOTFOUND 0x880F + +// Too many Image Stack sheets +#define NMR_ERROR_TOOMANYIMAGESHEETS 0x8810 + +// Missing Image3D sheet path +#define NMR_ERROR_MISSINGIMAGE3DSHEETPATH 0x8811 + +// Duplicate Volumetric Background +#define NMR_ERROR_DUPLICATEVOLUMETRICBACKGROUND 0x8812 + +// Invalid Volumetric Background +#define NMR_ERROR_INVALIDVOLUMETRICBACKGROUND 0x8813 + +// Missing Volumetric DstChannel Name +#define NMR_ERROR_MISSINGVOLUMETRICDSTCHANNELNAME 0x8814 + +// Missing Volumetric Layer Blend Method +#define NMR_ERROR_MISSINGVOLUMETRICLAYERBLENDMETHOD 0x8815 + +// Duplicate Volumetric Blend Method +#define NMR_ERROR_DUPLICATEVOLUMETRICBLENDMETHOD 0x8816 + +// Missing Volumetric Layer Transform +#define NMR_ERROR_MISSINGVOLUMETRICLAYERTRANSFORM 0x8817 + +// Duplicate Volumetric Transform +#define NMR_ERROR_DUPLICATEVOLUMETRICTRANSFORM 0x8818 + +// Duplicate Volumetric Src Alpha +#define NMR_ERROR_DUPLICATEVOLUMETRICSRCALPHA 0x8819 + +// Invalid Volumetric Src Alpha +#define NMR_ERROR_INVALIDVOLUMETRICSRCALPHA 0x881A + +// Duplicate Volumetric Dst Alpha +#define NMR_ERROR_DUPLICATEVOLUMETRICDSTALPHA 0x881B + +// Invalid Volumetric Dst Alpha +#define NMR_ERROR_INVALIDVOLUMETRICDSTALPHA 0x881C + +// Duplicate Mask Channel Selector +#define NMR_ERROR_DUPLICATEMASKCHANNELSELECTOR 0x881D + +// Duplicate Volumetric Min Value +#define NMR_ERROR_DUPLICATEVOLUMETRICMINVALUE 0x881E + +// Invalid Volumetric Min Value +#define NMR_ERROR_INVALIDVOLUMETRICMINVALUE 0x881F + +// Duplicate Volumetric Max Value +#define NMR_ERROR_DUPLICATEVOLUMETRICMAXVALUE 0x8820 + +// Invalid Volumetric Max Value +#define NMR_ERROR_INVALIDVOLUMETRICMAXVALUE 0x8821 + +// Missing Channel Selector ID +#define NMR_ERROR_MISSINGCHANNELSELECTORID 0x8822 + +// Missing Channel Selector TileStyle +#define NMR_ERROR_MISSINGCHANNELSELECTORTILESTYLE 0x8823 + +// Duplicate Volumetric TileStyle +#define NMR_ERROR_DUPLICATEVOLUMETRICTILESTYLE 0x8824 + +// Duplicate Volumetric Filter +#define NMR_ERROR_DUPLICATEVOLUMETRICFILTER 0x8825 + +// Duplicate Volumetric Source Channel +#define NMR_ERROR_DUPLICATEVOLUMETRICSOURCECHANNEL 0x8826 + +// Duplicate Volumetric Destination Channel +#define NMR_ERROR_DUPLICATEVOLUMETRICDESTINATIONCHANNEL 0x8827 + +// Duplicate VolumeData Levelset +#define NMR_ERROR_DUPLICATEVOLUMEDATABOUNDARY 0x8828 + +// Duplicate VolumeData Transform +#define NMR_ERROR_DUPLICATEVOLUMEDATATRANSFORM 0x8829 + +// Duplicate VolumeData Channel +#define NMR_ERROR_DUPLICATEVOLUMEDATACHANNEL 0x882A + +// Duplicate VolumeData VolumetricStackID +#define NMR_ERROR_DUPLICATEVOLUMEDATAFIELDID 0x882B + +// Duplicate VolumeData Solid Threshold +#define NMR_ERROR_DUPLICATEVOLUMEDATASOLIDTHRESHOLD 0x882C + +// Missing VolumeData Channel +#define NMR_ERROR_MISSINGVOLUMEDATACHANNEL 0x882D + +// Missing VolumeData VolumetricStackID +#define NMR_ERROR_MISSINGVOLUMEDATAFIELDID 0x882E + +// Invalid VolumeData Solid Threshold +#define NMR_ERROR_INVALIDVOLUMEDATASOLIDTHRESHOLD 0x882F + +// Duplicate VolumeData Property +#define NMR_ERROR_DUPLICATEVOLUMEDATAPROPERTY 0x8830 + +// Missing VolumeData Property +#define NMR_ERROR_MISSINGVOLUMEDATAPROPERTYNAME 0x8831 + +// Missing Volumetric Source Alpha +#define NMR_ERROR_MISSINGVOLUMETRICSRCALPHA 0x882 + +// Missing Volumetric Destination Alpha +#define NMR_ERROR_MISSINGVOLUMETRICDSTALPHA 0x8833 + +// Missing attribute in scalar field composed +#define NMR_ERROR_MISSING_ATTRIBUTE_SCALARFIELDCOMPOSED 0x8834 + +// Duplicate attribute in scalar field composed +#define NMR_ERROR_DUPLICATE_ATTRIBUTE_SCALARFIELDCOMPOSED 0x8835 + +// Missing attribute in vector3d field composed +#define NMR_ERROR_MISSING_ATTRIBUTE_VECTOR3DFIELDCOMPOSED 0x8836 + +// Duplicate attribute in vector3d field composed +#define NMR_ERROR_DUPLICATE_ATTRIBUTE_VECTOR3DFIELDCOMPOSED 0x8837 + +// Unknown node type in implict model +#define NMR_ERROR_UNKNOWN_NODETYPE_IMPLICITMODEL 0x8838 + +// Invalid source node in implicit function +#define NMR_ERROR_IMPLICIT_FUNCTION_INVALID_SOURCE_NODE 0x8839 + +// Invalid target node in implicit function +#define NMR_ERROR_IMPLICIT_FUNCTION_INVALID_TARGET_NODE 0x883A + +// Invalid source port in implicit function +#define NMR_ERROR_IMPLICIT_FUNCTION_INVALID_SOURCE_PORT 0x883B + +// Invalid target port in implicit function +#define NMR_ERROR_IMPLICIT_FUNCTION_INVALID_TARGET_PORT 0x883C + +// Invalid port type in implicit function +#define NMR_ERROR_IMPLICIT_FUNCTION_INVALID_PORT_TYPE 0x883D + +// Port does not exist in node +#define NMR_ERROR_IMPLICIT_PORT_DOES_NOT_EXIST 0x883E + +// Duplicate attribute meshbboxonly in volumedata boundary +#define NMR_ERROR_DUPLICATE_VOLUMEDATA_MESHBBOXONLY 0x883F + +// Duplicate attribute minfeature size in volumedata element +#define NMR_ERROR_DUPLICATE_VOLUMEDATA_MINFEATURESIZE 0x8840 + +// Function graph is not a directed acyclic graph +#define NMR_ERROR_IMPLICIT_FUNCTION_CYCLIC_GRAPH 0x8841 + +// Duplicate attribute fallbackvalue in volumedata element +#define NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE 0x8842 + +// Duplicate attribute functionid in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_FUNCTION_ID 0x8843 + +// Duplicate attribute channel in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_CHANNEL 0x8844 + +// Duplicate attribute fallbackvalue in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAOE_FALLBACKVALUE 0x8845 + +// Duplicate attribute transform in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_TRANSFORM 0x8846 + +// Duplicate attribute minfeaturesize in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_MIN_FEATURE_SIZE 0x8847 + +// Duplicate attribute fallbackvalue in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_FALLBACK_VALUE 0x8848 + +// Duplicate attribute volumeid in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_VOLUME_ID 0x8849 + +// Duplicate attribute mesh id in levelset element +#define NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_MESH_ID 0x884A /*------------------------------------------------------------------- diff --git a/Include/Common/NMR_Exception.h b/Include/Common/NMR_Exception.h index 00271b1..0f31090 100644 --- a/Include/Common/NMR_Exception.h +++ b/Include/Common/NMR_Exception.h @@ -39,14 +39,19 @@ Each exception is identified via a global ErrorCode #include "Common/NMR_Types.h" #include "Common/NMR_Local.h" #include +#include namespace NMR { class CNMRException : public std::exception { private: nfError m_errorcode; - public: + std::string m_message; + + public: CNMRException(_In_ nfError errorcode); + CNMRException(_In_ nfError errorcode, _In_ const std::string & message); + virtual const char * what() const throw (); nfError getErrorCode() const; }; diff --git a/Include/Common/NMR_FunctionReference.h b/Include/Common/NMR_FunctionReference.h new file mode 100644 index 0000000..a5cb244 --- /dev/null +++ b/Include/Common/NMR_FunctionReference.h @@ -0,0 +1,80 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_FunctionReference.h defines the class CFunctionReference. + +--*/ + +#pragma once + +#include "Common/NMR_Types.h" +#include "Common/Math/NMR_Geometry.h" +#include "Common/Math/NMR_Matrix.h" +#include "Model/Classes/NMR_ModelTypes.h" +#include "Model/Classes/NMR_PackageResourceID.h" + +namespace NMR { + class CModelFunction; + typedef std::shared_ptr PModelFunction; + + class CFunctionReference { + private: + UniqueResourceID m_pFunctionResourceID; + std::string m_outputPortName; + + NMR::NMATRIX3 m_transform = NMR::fnMATRIX3_identity(); + bool m_bHasTransform = false; + + double m_minFeatureSize = 0.0; + + double m_fallBackValue = 0.0; + public: + CFunctionReference() = delete; + explicit CFunctionReference(UniqueResourceID functionResourceId); + explicit CFunctionReference(PModelFunction pFunction); + + virtual void setFunctionResourceID(UniqueResourceID functionID); + virtual UniqueResourceID getFunctionResourceID() const; + + void setChannelName(std::string outputPortName); + std::string const& getChannelName() const; + + void setTransform(NMR::NMATRIX3 transform); + NMR::NMATRIX3 getTransform() const; + + bool hasTransform() const; + + void setMinFeatureSize(double minFeatureSize); + double getMinFeatureSize() const; + + void setFallBackValue(double fallBackValue); + double getFallBackValue() const; + }; + + typedef std::shared_ptr PFunctionReference; +} diff --git a/Include/Common/NMR_SecureContentTypes.h b/Include/Common/NMR_SecureContentTypes.h index 2e19f2c..8fe9852 100644 --- a/Include/Common/NMR_SecureContentTypes.h +++ b/Include/Common/NMR_SecureContentTypes.h @@ -102,15 +102,15 @@ namespace NMR { void * m_pUserData; }; - constexpr nfUint64 fnGetAlgorithmInitVectorSize(eKeyStoreEncryptAlgorithm ea) { + constexpr nfUint32 fnGetAlgorithmInitVectorSize(eKeyStoreEncryptAlgorithm ea) { return 12; } - constexpr nfUint64 fnGetAlgorithmKeySize(eKeyStoreEncryptAlgorithm ea) { + constexpr nfUint32 fnGetAlgorithmKeySize(eKeyStoreEncryptAlgorithm ea) { return 32; } - constexpr nfUint64 fnGetAlgorithmAuthTagSize(eKeyStoreEncryptAlgorithm ea) { + constexpr nfUint32 fnGetAlgorithmAuthTagSize(eKeyStoreEncryptAlgorithm ea) { return 16; } } diff --git a/Include/Common/NMR_StringUtils.h b/Include/Common/NMR_StringUtils.h index 99eb316..b32bc76 100644 --- a/Include/Common/NMR_StringUtils.h +++ b/Include/Common/NMR_StringUtils.h @@ -36,6 +36,9 @@ and Exception-safe #include "Common/NMR_Types.h" #include "Common/NMR_Local.h" + +#include + #include #include #include diff --git a/Include/Common/NMR_UUID.h b/Include/Common/NMR_UUID.h index a02ad2c..5476865 100644 --- a/Include/Common/NMR_UUID.h +++ b/Include/Common/NMR_UUID.h @@ -37,23 +37,21 @@ NMR_UUID.h defines a datatype and functions to handle UUIDs #include "Common/NMR_Local.h" #include -#ifndef _WIN32 -#include +#ifdef GUID_CUSTOM #include +#include +#include #endif - namespace NMR { class CUUID { private: -#ifndef _WIN32 - static bool S_mtwister_initialised; - static std::mutex S_uuid_gen_mutex; - static std::random_device S_rand_dev; - static std::mt19937 S_mtwister; -#endif std::string m_sUUID; +#ifdef GUID_CUSTOM + static std::mutex S_uuid_gen_mutex; + static std::unique_ptr S_mtwister; +#endif public: CUUID(); CUUID(const nfChar* pString); diff --git a/Include/Common/OPC/NMR_OpcPackageReader.h b/Include/Common/OPC/NMR_OpcPackageReader.h index 81f0a0e..3e19876 100644 --- a/Include/Common/OPC/NMR_OpcPackageReader.h +++ b/Include/Common/OPC/NMR_OpcPackageReader.h @@ -40,7 +40,7 @@ NMR_OpcPackageReader.h defines an OPC Package reader in a portable way. #include "Common/OPC/NMR_OpcPackageRelationship.h" #include "Common/3MF_ProgressMonitor.h" #include "Common/NMR_ModelWarnings.h" -#include "Libraries/libzip/zip.h" +#include "zip.h" #include #include #include diff --git a/Include/Common/Platform/NMR_ExportStream_Compressed.h b/Include/Common/Platform/NMR_ExportStream_Compressed.h index 453bfcd..827efe3 100644 --- a/Include/Common/Platform/NMR_ExportStream_Compressed.h +++ b/Include/Common/Platform/NMR_ExportStream_Compressed.h @@ -36,7 +36,7 @@ NMR_ExportStream_Compressed.h defines a stream to write compressed files #include "Common/NMR_Types.h" #include "Common/Platform/NMR_ExportStream.h" #include "Common/Platform/NMR_PortableZIPWriter.h" -#include "Libraries/zlib/zlib.h" +#include "zlib.h" #define EXPORTSTREAM_WRITE_BUFFER_CHUNKSIZE 1024 diff --git a/Include/Common/Platform/NMR_ExportStream_ZIP.h b/Include/Common/Platform/NMR_ExportStream_ZIP.h index cba4fed..c693686 100644 --- a/Include/Common/Platform/NMR_ExportStream_ZIP.h +++ b/Include/Common/Platform/NMR_ExportStream_ZIP.h @@ -36,7 +36,7 @@ NMR_PortableZIPWriter.h defines a portable stream to write into ZIP files #include "Common/NMR_Types.h" #include "Common/Platform/NMR_ExportStream.h" #include "Common/Platform/NMR_PortableZIPWriter.h" -#include "Libraries/zlib/zlib.h" +#include "zlib.h" #include diff --git a/Include/Common/Platform/NMR_ImportStream_Compressed.h b/Include/Common/Platform/NMR_ImportStream_Compressed.h index 166aa01..e9c0084 100644 --- a/Include/Common/Platform/NMR_ImportStream_Compressed.h +++ b/Include/Common/Platform/NMR_ImportStream_Compressed.h @@ -35,7 +35,7 @@ This is a stream class for importing from a compressed object. #define __NMR_IMPORTSTREAM_COMPRESSED #include "Common/Platform/NMR_ImportStream.h" -#include "Libraries/zlib/zlib.h" +#include "zlib.h" #define IMPORTSTREAM_READ_BUFFER_CHUNKSIZE 1024 #define IMPORTSTREAM_COMPRESSED_CHUNKSIZE 1024 diff --git a/Include/Common/Platform/NMR_ImportStream_ZIP.h b/Include/Common/Platform/NMR_ImportStream_ZIP.h index e834e24..a7509e5 100644 --- a/Include/Common/Platform/NMR_ImportStream_ZIP.h +++ b/Include/Common/Platform/NMR_ImportStream_ZIP.h @@ -35,7 +35,7 @@ This is a stream class for importing from a libZIP object. #define __NMR_IMPORTSTREAM_ZIP #include "Common/Platform/NMR_ImportStream.h" -#include "Libraries/libzip/zip.h" +#include "zip.h" #define IMPORTSTREAM_ZIP_CHUNKSIZE (1024 * 1024) diff --git a/Include/Libraries/cpp-base64/base64.h b/Include/Libraries/cpp-base64/base64.h index e8442ea..866505e 100644 --- a/Include/Libraries/cpp-base64/base64.h +++ b/Include/Libraries/cpp-base64/base64.h @@ -1,15 +1,35 @@ // // base64 encoding and decoding with C++. -// Version: 1.01.00 +// Version: 2.rc.08 (release candidate) // #ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A #define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A #include -#include -std::string base64_encode(std::vector const & buffer); -std::vector base64_decode(std::string const& s); +#if __cplusplus >= 201703L +#include +#endif // __cplusplus >= 201703L + +std::string base64_encode (std::string const& s, bool url = false); +std::string base64_encode_pem (std::string const& s); +std::string base64_encode_mime(std::string const& s); + +std::string base64_decode(std::string const& s, bool remove_linebreaks = false); +std::string base64_encode(unsigned char const*, size_t len, bool url = false); + +#if __cplusplus >= 201703L +// +// Interface with std::string_view rather than const std::string& +// Requires C++17 +// Provided by Yannic Bonenberger (https://github.com/Yannic) +// +std::string base64_encode (std::string_view s, bool url = false); +std::string base64_encode_pem (std::string_view s); +std::string base64_encode_mime(std::string_view s); + +std::string base64_decode(std::string_view s, bool remove_linebreaks = false); +#endif // __cplusplus >= 201703L #endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */ diff --git a/Include/Libraries/fast_float/ascii_number.h b/Include/Libraries/fast_float/ascii_number.h new file mode 100644 index 0000000..5d3eac9 --- /dev/null +++ b/Include/Libraries/fast_float/ascii_number.h @@ -0,0 +1,545 @@ +#ifndef FASTFLOAT_ASCII_NUMBER_H +#define FASTFLOAT_ASCII_NUMBER_H + +#include +#include +#include +#include +#include +#include + +#include "float_common.h" + +#ifdef FASTFLOAT_SSE2 +#include +#endif + +#ifdef FASTFLOAT_NEON +#include +#endif + +namespace fast_float { + +template +fastfloat_really_inline constexpr bool has_simd_opt() { +#ifdef FASTFLOAT_HAS_SIMD + return std::is_same::value; +#else + return false; +#endif +} + +// Next function can be micro-optimized, but compilers are entirely +// able to optimize it well. +template +fastfloat_really_inline constexpr bool is_integer(UC c) noexcept { + return !(c > UC('9') || c < UC('0')); +} + +fastfloat_really_inline constexpr uint64_t byteswap(uint64_t val) { + return (val & 0xFF00000000000000) >> 56 + | (val & 0x00FF000000000000) >> 40 + | (val & 0x0000FF0000000000) >> 24 + | (val & 0x000000FF00000000) >> 8 + | (val & 0x00000000FF000000) << 8 + | (val & 0x0000000000FF0000) << 24 + | (val & 0x000000000000FF00) << 40 + | (val & 0x00000000000000FF) << 56; +} + +// Read 8 UC into a u64. Truncates UC if not char. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +uint64_t read8_to_u64(const UC *chars) { + if (cpp20_and_in_constexpr() || !std::is_same::value) { + uint64_t val = 0; + for(int i = 0; i < 8; ++i) { + val |= uint64_t(uint8_t(*chars)) << (i*8); + ++chars; + } + return val; + } + uint64_t val; + ::memcpy(&val, chars, sizeof(uint64_t)); +#if FASTFLOAT_IS_BIG_ENDIAN == 1 + // Need to read as-if the number was in little-endian order. + val = byteswap(val); +#endif + return val; +} + +#ifdef FASTFLOAT_SSE2 + +fastfloat_really_inline +uint64_t simd_read8_to_u64(const __m128i data) { +FASTFLOAT_SIMD_DISABLE_WARNINGS + const __m128i packed = _mm_packus_epi16(data, data); +#ifdef FASTFLOAT_64BIT + return uint64_t(_mm_cvtsi128_si64(packed)); +#else + uint64_t value; + // Visual Studio + older versions of GCC don't support _mm_storeu_si64 + _mm_storel_epi64(reinterpret_cast<__m128i*>(&value), packed); + return value; +#endif +FASTFLOAT_SIMD_RESTORE_WARNINGS +} + +fastfloat_really_inline +uint64_t simd_read8_to_u64(const char16_t* chars) { +FASTFLOAT_SIMD_DISABLE_WARNINGS + return simd_read8_to_u64(_mm_loadu_si128(reinterpret_cast(chars))); +FASTFLOAT_SIMD_RESTORE_WARNINGS +} + +#elif defined(FASTFLOAT_NEON) + + +fastfloat_really_inline +uint64_t simd_read8_to_u64(const uint16x8_t data) { +FASTFLOAT_SIMD_DISABLE_WARNINGS + uint8x8_t utf8_packed = vmovn_u16(data); + return vget_lane_u64(vreinterpret_u64_u8(utf8_packed), 0); +FASTFLOAT_SIMD_RESTORE_WARNINGS +} + +fastfloat_really_inline +uint64_t simd_read8_to_u64(const char16_t* chars) { +FASTFLOAT_SIMD_DISABLE_WARNINGS + return simd_read8_to_u64(vld1q_u16(reinterpret_cast(chars))); +FASTFLOAT_SIMD_RESTORE_WARNINGS +} + +#endif // FASTFLOAT_SSE2 + +// MSVC SFINAE is broken pre-VS2017 +#if defined(_MSC_VER) && _MSC_VER <= 1900 +template +#else +template ()) = 0> +#endif +// dummy for compile +uint64_t simd_read8_to_u64(UC const*) { + return 0; +} + + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void write_u64(uint8_t *chars, uint64_t val) { + if (cpp20_and_in_constexpr()) { + for(int i = 0; i < 8; ++i) { + *chars = uint8_t(val); + val >>= 8; + ++chars; + } + return; + } +#if FASTFLOAT_IS_BIG_ENDIAN == 1 + // Need to read as-if the number was in little-endian order. + val = byteswap(val); +#endif + ::memcpy(chars, &val, sizeof(uint64_t)); +} + +// credit @aqrit +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +uint32_t parse_eight_digits_unrolled(uint64_t val) { + const uint64_t mask = 0x000000FF000000FF; + const uint64_t mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32) + const uint64_t mul2 = 0x0000271000000001; // 1 + (10000ULL << 32) + val -= 0x3030303030303030; + val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8; + val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32; + return uint32_t(val); +} + + +// Call this if chars are definitely 8 digits. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +uint32_t parse_eight_digits_unrolled(UC const * chars) noexcept { + if (cpp20_and_in_constexpr() || !has_simd_opt()) { + return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay + } + return parse_eight_digits_unrolled(simd_read8_to_u64(chars)); +} + + +// credit @aqrit +fastfloat_really_inline constexpr bool is_made_of_eight_digits_fast(uint64_t val) noexcept { + return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) & + 0x8080808080808080)); +} + + +#ifdef FASTFLOAT_HAS_SIMD + +// Call this if chars might not be 8 digits. +// Using this style (instead of is_made_of_eight_digits_fast() then parse_eight_digits_unrolled()) +// ensures we don't load SIMD registers twice. +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +bool simd_parse_if_eight_digits_unrolled(const char16_t* chars, uint64_t& i) noexcept { + if (cpp20_and_in_constexpr()) { + return false; + } +#ifdef FASTFLOAT_SSE2 +FASTFLOAT_SIMD_DISABLE_WARNINGS + const __m128i data = _mm_loadu_si128(reinterpret_cast(chars)); + + // (x - '0') <= 9 + // http://0x80.pl/articles/simd-parsing-int-sequences.html + const __m128i t0 = _mm_add_epi16(data, _mm_set1_epi16(32720)); + const __m128i t1 = _mm_cmpgt_epi16(t0, _mm_set1_epi16(-32759)); + + if (_mm_movemask_epi8(t1) == 0) { + i = i * 100000000 + parse_eight_digits_unrolled(simd_read8_to_u64(data)); + return true; + } + else return false; +FASTFLOAT_SIMD_RESTORE_WARNINGS +#elif defined(FASTFLOAT_NEON) +FASTFLOAT_SIMD_DISABLE_WARNINGS + const uint16x8_t data = vld1q_u16(reinterpret_cast(chars)); + + // (x - '0') <= 9 + // http://0x80.pl/articles/simd-parsing-int-sequences.html + const uint16x8_t t0 = vsubq_u16(data, vmovq_n_u16('0')); + const uint16x8_t mask = vcltq_u16(t0, vmovq_n_u16('9' - '0' + 1)); + + if (vminvq_u16(mask) == 0xFFFF) { + i = i * 100000000 + parse_eight_digits_unrolled(simd_read8_to_u64(data)); + return true; + } + else return false; +FASTFLOAT_SIMD_RESTORE_WARNINGS +#else + (void)chars; (void)i; + return false; +#endif // FASTFLOAT_SSE2 +} + +#endif // FASTFLOAT_HAS_SIMD + +// MSVC SFINAE is broken pre-VS2017 +#if defined(_MSC_VER) && _MSC_VER <= 1900 +template +#else +template ()) = 0> +#endif +// dummy for compile +bool simd_parse_if_eight_digits_unrolled(UC const*, uint64_t&) { + return 0; +} + + +template ::value) = 0> +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void loop_parse_if_eight_digits(const UC*& p, const UC* const pend, uint64_t& i) { + if (!has_simd_opt()) { + return; + } + while ((std::distance(p, pend) >= 8) && simd_parse_if_eight_digits_unrolled(p, i)) { // in rare cases, this will overflow, but that's ok + p += 8; + } +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void loop_parse_if_eight_digits(const char*& p, const char* const pend, uint64_t& i) { + // optimizes better than parse_if_eight_digits_unrolled() for UC = char. + while ((std::distance(p, pend) >= 8) && is_made_of_eight_digits_fast(read8_to_u64(p))) { + i = i * 100000000 + parse_eight_digits_unrolled(read8_to_u64(p)); // in rare cases, this will overflow, but that's ok + p += 8; + } +} + +template +struct parsed_number_string_t { + int64_t exponent{0}; + uint64_t mantissa{0}; + UC const * lastmatch{nullptr}; + bool negative{false}; + bool valid{false}; + bool too_many_digits{false}; + // contains the range of the significant digits + span integer{}; // non-nullable + span fraction{}; // nullable +}; + +using byte_span = span; +using parsed_number_string = parsed_number_string_t; + +// Assuming that you use no more than 19 digits, this will +// parse an ASCII string. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +parsed_number_string_t parse_number_string(UC const *p, UC const * pend, parse_options_t options) noexcept { + chars_format const fmt = options.format; + UC const decimal_point = options.decimal_point; + + parsed_number_string_t answer; + answer.valid = false; + answer.too_many_digits = false; + answer.negative = (*p == UC('-')); +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default + if ((*p == UC('-')) || (!(fmt & FASTFLOAT_JSONFMT) && *p == UC('+'))) { +#else + if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here +#endif + ++p; + if (p == pend) { + return answer; + } + if (fmt & FASTFLOAT_JSONFMT) { + if (!is_integer(*p)) { // a sign must be followed by an integer + return answer; + } + } else { + if (!is_integer(*p) && (*p != decimal_point)) { // a sign must be followed by an integer or the dot + return answer; + } + } + } + UC const * const start_digits = p; + + uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad) + + while ((p != pend) && is_integer(*p)) { + // a multiplication by 10 is cheaper than an arbitrary integer + // multiplication + i = 10 * i + + uint64_t(*p - UC('0')); // might overflow, we will handle the overflow later + ++p; + } + UC const * const end_of_integer_part = p; + int64_t digit_count = int64_t(end_of_integer_part - start_digits); + answer.integer = span(start_digits, size_t(digit_count)); + if (fmt & FASTFLOAT_JSONFMT) { + // at least 1 digit in integer part, without leading zeros + if (digit_count == 0 || (start_digits[0] == UC('0') && digit_count > 1)) { + return answer; + } + } + + int64_t exponent = 0; + const bool has_decimal_point = (p != pend) && (*p == decimal_point); + if (has_decimal_point) { + ++p; + UC const * before = p; + // can occur at most twice without overflowing, but let it occur more, since + // for integers with many digits, digit parsing is the primary bottleneck. + loop_parse_if_eight_digits(p, pend, i); + + while ((p != pend) && is_integer(*p)) { + uint8_t digit = uint8_t(*p - UC('0')); + ++p; + i = i * 10 + digit; // in rare cases, this will overflow, but that's ok + } + exponent = before - p; + answer.fraction = span(before, size_t(p - before)); + digit_count -= exponent; + } + if (fmt & FASTFLOAT_JSONFMT) { + // at least 1 digit in fractional part + if (has_decimal_point && exponent == 0) { + return answer; + } + } + else if (digit_count == 0) { // we must have encountered at least one integer! + return answer; + } + int64_t exp_number = 0; // explicit exponential part + if ( ((fmt & chars_format::scientific) && + (p != pend) && + ((UC('e') == *p) || (UC('E') == *p))) + || + ((fmt & FASTFLOAT_FORTRANFMT) && + (p != pend) && + ((UC('+') == *p) || (UC('-') == *p) || (UC('d') == *p) || (UC('D') == *p)))) { + UC const * location_of_e = p; + if ((UC('e') == *p) || (UC('E') == *p) || (UC('d') == *p) || (UC('D') == *p)) { + ++p; + } + bool neg_exp = false; + if ((p != pend) && (UC('-') == *p)) { + neg_exp = true; + ++p; + } else if ((p != pend) && (UC('+') == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1) + ++p; + } + if ((p == pend) || !is_integer(*p)) { + if(!(fmt & chars_format::fixed)) { + // We are in error. + return answer; + } + // Otherwise, we will be ignoring the 'e'. + p = location_of_e; + } else { + while ((p != pend) && is_integer(*p)) { + uint8_t digit = uint8_t(*p - UC('0')); + if (exp_number < 0x10000000) { + exp_number = 10 * exp_number + digit; + } + ++p; + } + if(neg_exp) { exp_number = - exp_number; } + exponent += exp_number; + } + } else { + // If it scientific and not fixed, we have to bail out. + if((fmt & chars_format::scientific) && !(fmt & chars_format::fixed)) { return answer; } + } + answer.lastmatch = p; + answer.valid = true; + + // If we frequently had to deal with long strings of digits, + // we could extend our code by using a 128-bit integer instead + // of a 64-bit integer. However, this is uncommon. + // + // We can deal with up to 19 digits. + if (digit_count > 19) { // this is uncommon + // It is possible that the integer had an overflow. + // We have to handle the case where we have 0.0000somenumber. + // We need to be mindful of the case where we only have zeroes... + // E.g., 0.000000000...000. + UC const * start = start_digits; + while ((start != pend) && (*start == UC('0') || *start == decimal_point)) { + if(*start == UC('0')) { digit_count --; } + start++; + } + + if (digit_count > 19) { + answer.too_many_digits = true; + // Let us start again, this time, avoiding overflows. + // We don't need to check if is_integer, since we use the + // pre-tokenized spans from above. + i = 0; + p = answer.integer.ptr; + UC const* int_end = p + answer.integer.len(); + const uint64_t minimal_nineteen_digit_integer{ 1000000000000000000 }; + while ((i < minimal_nineteen_digit_integer) && (p != int_end)) { + i = i * 10 + uint64_t(*p - UC('0')); + ++p; + } + if (i >= minimal_nineteen_digit_integer) { // We have a big integers + exponent = end_of_integer_part - p + exp_number; + } + else { // We have a value with a fractional component. + p = answer.fraction.ptr; + UC const* frac_end = p + answer.fraction.len(); + while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) { + i = i * 10 + uint64_t(*p - UC('0')); + ++p; + } + exponent = answer.fraction.ptr - p + exp_number; + } + // We have now corrected both exponent and i, to a truncated value + } + } + answer.exponent = exponent; + answer.mantissa = i; + return answer; +} + +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +from_chars_result_t parse_int_string(UC const* p, UC const* pend, T& value, int base) +{ + from_chars_result_t answer; + + UC const* const first = p; + + bool negative = (*p == UC('-')); + if (!std::is_signed::value && negative) { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; + } +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default + if ((*p == UC('-')) || (*p == UC('+'))) { +#else + if (*p == UC('-')) { +#endif + ++p; + } + + UC const* const start_num = p; + while (*p == UC('0')) { + ++p; + } + const bool has_leading_zeros = p > start_num; + + UC const* const start_digits = p; + + uint64_t i = 0; + if (base == 10) { + loop_parse_if_eight_digits(p, pend, i); // use SIMD if possible + } + while (p != pend) { + uint8_t digit = ch_to_digit(*p); + if (digit >= base) { + break; + } + i = uint64_t(base) * i + digit; // might overflow, check this later + p++; + } + + size_t digit_count = size_t(p - start_digits); + + if (digit_count == 0) { + if (has_leading_zeros) { + value = 0; + answer.ec = std::errc(); + answer.ptr = p; + } + else { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + } + return answer; + } + + answer.ptr = p; + + // check u64 overflow + size_t max_digits = max_digits_u64(base); + if (digit_count > max_digits) { + answer.ec = std::errc::result_out_of_range; + return answer; + } + // this check can be eliminated for all other types, but they will all require a max_digits(base) equivalent + if (digit_count == max_digits && i < min_safe_u64(base)) { + answer.ec = std::errc::result_out_of_range; + return answer; + } + + // check other types overflow + if (!std::is_same::value) { + if (i > uint64_t(std::numeric_limits::max()) + uint64_t(negative)) { + answer.ec = std::errc::result_out_of_range; + return answer; + } + } + + if (negative) { +#ifdef FASTFLOAT_VISUAL_STUDIO +#pragma warning(push) +#pragma warning(disable: 4146) +#endif + // this weird workaround is required because: + // - converting unsigned to signed when its value is greater than signed max is UB pre-C++23. + // - reinterpret_casting (~i + 1) would work, but it is not constexpr + // this is always optimized into a neg instruction. + value = T(-std::numeric_limits::max() - T(i - std::numeric_limits::max())); +#ifdef FASTFLOAT_VISUAL_STUDIO +#pragma warning(pop) +#endif + } + else { value = T(i); } + + answer.ec = std::errc(); + return answer; +} + +} // namespace fast_float + +#endif diff --git a/Include/Libraries/fast_float/bigint.h b/Include/Libraries/fast_float/bigint.h new file mode 100644 index 0000000..5076b47 --- /dev/null +++ b/Include/Libraries/fast_float/bigint.h @@ -0,0 +1,617 @@ +#ifndef FASTFLOAT_BIGINT_H +#define FASTFLOAT_BIGINT_H + +#include +#include +#include +#include + +#include "float_common.h" + +namespace fast_float { + +// the limb width: we want efficient multiplication of double the bits in +// limb, or for 64-bit limbs, at least 64-bit multiplication where we can +// extract the high and low parts efficiently. this is every 64-bit +// architecture except for sparc, which emulates 128-bit multiplication. +// we might have platforms where `CHAR_BIT` is not 8, so let's avoid +// doing `8 * sizeof(limb)`. +#if defined(FASTFLOAT_64BIT) && !defined(__sparc) +#define FASTFLOAT_64BIT_LIMB 1 +typedef uint64_t limb; +constexpr size_t limb_bits = 64; +#else +#define FASTFLOAT_32BIT_LIMB +typedef uint32_t limb; +constexpr size_t limb_bits = 32; +#endif + +typedef span limb_span; + +// number of bits in a bigint. this needs to be at least the number +// of bits required to store the largest bigint, which is +// `log2(10**(digits + max_exp))`, or `log2(10**(767 + 342))`, or +// ~3600 bits, so we round to 4000. +constexpr size_t bigint_bits = 4000; +constexpr size_t bigint_limbs = bigint_bits / limb_bits; + +// vector-like type that is allocated on the stack. the entire +// buffer is pre-allocated, and only the length changes. +template +struct stackvec { + limb data[size]; + // we never need more than 150 limbs + uint16_t length{0}; + + stackvec() = default; + stackvec(const stackvec &) = delete; + stackvec &operator=(const stackvec &) = delete; + stackvec(stackvec &&) = delete; + stackvec &operator=(stackvec &&other) = delete; + + // create stack vector from existing limb span. + FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) { + FASTFLOAT_ASSERT(try_extend(s)); + } + + FASTFLOAT_CONSTEXPR14 limb& operator[](size_t index) noexcept { + FASTFLOAT_DEBUG_ASSERT(index < length); + return data[index]; + } + FASTFLOAT_CONSTEXPR14 const limb& operator[](size_t index) const noexcept { + FASTFLOAT_DEBUG_ASSERT(index < length); + return data[index]; + } + // index from the end of the container + FASTFLOAT_CONSTEXPR14 const limb& rindex(size_t index) const noexcept { + FASTFLOAT_DEBUG_ASSERT(index < length); + size_t rindex = length - index - 1; + return data[rindex]; + } + + // set the length, without bounds checking. + FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept { + length = uint16_t(len); + } + constexpr size_t len() const noexcept { + return length; + } + constexpr bool is_empty() const noexcept { + return length == 0; + } + constexpr size_t capacity() const noexcept { + return size; + } + // append item to vector, without bounds checking + FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept { + data[length] = value; + length++; + } + // append item to vector, returning if item was added + FASTFLOAT_CONSTEXPR14 bool try_push(limb value) noexcept { + if (len() < capacity()) { + push_unchecked(value); + return true; + } else { + return false; + } + } + // add items to the vector, from a span, without bounds checking + FASTFLOAT_CONSTEXPR20 void extend_unchecked(limb_span s) noexcept { + limb* ptr = data + length; + std::copy_n(s.ptr, s.len(), ptr); + set_len(len() + s.len()); + } + // try to add items to the vector, returning if items were added + FASTFLOAT_CONSTEXPR20 bool try_extend(limb_span s) noexcept { + if (len() + s.len() <= capacity()) { + extend_unchecked(s); + return true; + } else { + return false; + } + } + // resize the vector, without bounds checking + // if the new size is longer than the vector, assign value to each + // appended item. + FASTFLOAT_CONSTEXPR20 + void resize_unchecked(size_t new_len, limb value) noexcept { + if (new_len > len()) { + size_t count = new_len - len(); + limb* first = data + len(); + limb* last = first + count; + ::std::fill(first, last, value); + set_len(new_len); + } else { + set_len(new_len); + } + } + // try to resize the vector, returning if the vector was resized. + FASTFLOAT_CONSTEXPR20 bool try_resize(size_t new_len, limb value) noexcept { + if (new_len > capacity()) { + return false; + } else { + resize_unchecked(new_len, value); + return true; + } + } + // check if any limbs are non-zero after the given index. + // this needs to be done in reverse order, since the index + // is relative to the most significant limbs. + FASTFLOAT_CONSTEXPR14 bool nonzero(size_t index) const noexcept { + while (index < len()) { + if (rindex(index) != 0) { + return true; + } + index++; + } + return false; + } + // normalize the big integer, so most-significant zero limbs are removed. + FASTFLOAT_CONSTEXPR14 void normalize() noexcept { + while (len() > 0 && rindex(0) == 0) { + length--; + } + } +}; + +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +uint64_t empty_hi64(bool& truncated) noexcept { + truncated = false; + return 0; +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +uint64_t uint64_hi64(uint64_t r0, bool& truncated) noexcept { + truncated = false; + int shl = leading_zeroes(r0); + return r0 << shl; +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +uint64_t uint64_hi64(uint64_t r0, uint64_t r1, bool& truncated) noexcept { + int shl = leading_zeroes(r0); + if (shl == 0) { + truncated = r1 != 0; + return r0; + } else { + int shr = 64 - shl; + truncated = (r1 << shl) != 0; + return (r0 << shl) | (r1 >> shr); + } +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +uint64_t uint32_hi64(uint32_t r0, bool& truncated) noexcept { + return uint64_hi64(r0, truncated); +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +uint64_t uint32_hi64(uint32_t r0, uint32_t r1, bool& truncated) noexcept { + uint64_t x0 = r0; + uint64_t x1 = r1; + return uint64_hi64((x0 << 32) | x1, truncated); +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +uint64_t uint32_hi64(uint32_t r0, uint32_t r1, uint32_t r2, bool& truncated) noexcept { + uint64_t x0 = r0; + uint64_t x1 = r1; + uint64_t x2 = r2; + return uint64_hi64(x0, (x1 << 32) | x2, truncated); +} + +// add two small integers, checking for overflow. +// we want an efficient operation. for msvc, where +// we don't have built-in intrinsics, this is still +// pretty fast. +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +limb scalar_add(limb x, limb y, bool& overflow) noexcept { + limb z; +// gcc and clang +#if defined(__has_builtin) + #if __has_builtin(__builtin_add_overflow) + if (!cpp20_and_in_constexpr()) { + overflow = __builtin_add_overflow(x, y, &z); + return z; + } + #endif +#endif + + // generic, this still optimizes correctly on MSVC. + z = x + y; + overflow = z < x; + return z; +} + +// multiply two small integers, getting both the high and low bits. +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +limb scalar_mul(limb x, limb y, limb& carry) noexcept { +#ifdef FASTFLOAT_64BIT_LIMB + #if defined(__SIZEOF_INT128__) + // GCC and clang both define it as an extension. + __uint128_t z = __uint128_t(x) * __uint128_t(y) + __uint128_t(carry); + carry = limb(z >> limb_bits); + return limb(z); + #else + // fallback, no native 128-bit integer multiplication with carry. + // on msvc, this optimizes identically, somehow. + value128 z = full_multiplication(x, y); + bool overflow; + z.low = scalar_add(z.low, carry, overflow); + z.high += uint64_t(overflow); // cannot overflow + carry = z.high; + return z.low; + #endif +#else + uint64_t z = uint64_t(x) * uint64_t(y) + uint64_t(carry); + carry = limb(z >> limb_bits); + return limb(z); +#endif +} + +// add scalar value to bigint starting from offset. +// used in grade school multiplication +template +inline FASTFLOAT_CONSTEXPR20 +bool small_add_from(stackvec& vec, limb y, size_t start) noexcept { + size_t index = start; + limb carry = y; + bool overflow; + while (carry != 0 && index < vec.len()) { + vec[index] = scalar_add(vec[index], carry, overflow); + carry = limb(overflow); + index += 1; + } + if (carry != 0) { + FASTFLOAT_TRY(vec.try_push(carry)); + } + return true; +} + +// add scalar value to bigint. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +bool small_add(stackvec& vec, limb y) noexcept { + return small_add_from(vec, y, 0); +} + +// multiply bigint by scalar value. +template +inline FASTFLOAT_CONSTEXPR20 +bool small_mul(stackvec& vec, limb y) noexcept { + limb carry = 0; + for (size_t index = 0; index < vec.len(); index++) { + vec[index] = scalar_mul(vec[index], y, carry); + } + if (carry != 0) { + FASTFLOAT_TRY(vec.try_push(carry)); + } + return true; +} + +// add bigint to bigint starting from index. +// used in grade school multiplication +template +FASTFLOAT_CONSTEXPR20 +bool large_add_from(stackvec& x, limb_span y, size_t start) noexcept { + // the effective x buffer is from `xstart..x.len()`, so exit early + // if we can't get that current range. + if (x.len() < start || y.len() > x.len() - start) { + FASTFLOAT_TRY(x.try_resize(y.len() + start, 0)); + } + + bool carry = false; + for (size_t index = 0; index < y.len(); index++) { + limb xi = x[index + start]; + limb yi = y[index]; + bool c1 = false; + bool c2 = false; + xi = scalar_add(xi, yi, c1); + if (carry) { + xi = scalar_add(xi, 1, c2); + } + x[index + start] = xi; + carry = c1 | c2; + } + + // handle overflow + if (carry) { + FASTFLOAT_TRY(small_add_from(x, 1, y.len() + start)); + } + return true; +} + +// add bigint to bigint. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +bool large_add_from(stackvec& x, limb_span y) noexcept { + return large_add_from(x, y, 0); +} + +// grade-school multiplication algorithm +template +FASTFLOAT_CONSTEXPR20 +bool long_mul(stackvec& x, limb_span y) noexcept { + limb_span xs = limb_span(x.data, x.len()); + stackvec z(xs); + limb_span zs = limb_span(z.data, z.len()); + + if (y.len() != 0) { + limb y0 = y[0]; + FASTFLOAT_TRY(small_mul(x, y0)); + for (size_t index = 1; index < y.len(); index++) { + limb yi = y[index]; + stackvec zi; + if (yi != 0) { + // re-use the same buffer throughout + zi.set_len(0); + FASTFLOAT_TRY(zi.try_extend(zs)); + FASTFLOAT_TRY(small_mul(zi, yi)); + limb_span zis = limb_span(zi.data, zi.len()); + FASTFLOAT_TRY(large_add_from(x, zis, index)); + } + } + } + + x.normalize(); + return true; +} + +// grade-school multiplication algorithm +template +FASTFLOAT_CONSTEXPR20 +bool large_mul(stackvec& x, limb_span y) noexcept { + if (y.len() == 1) { + FASTFLOAT_TRY(small_mul(x, y[0])); + } else { + FASTFLOAT_TRY(long_mul(x, y)); + } + return true; +} + +template +struct pow5_tables { + static constexpr uint32_t large_step = 135; + static constexpr uint64_t small_power_of_5[] = { + 1UL, 5UL, 25UL, 125UL, 625UL, 3125UL, 15625UL, 78125UL, 390625UL, + 1953125UL, 9765625UL, 48828125UL, 244140625UL, 1220703125UL, + 6103515625UL, 30517578125UL, 152587890625UL, 762939453125UL, + 3814697265625UL, 19073486328125UL, 95367431640625UL, 476837158203125UL, + 2384185791015625UL, 11920928955078125UL, 59604644775390625UL, + 298023223876953125UL, 1490116119384765625UL, 7450580596923828125UL, + }; +#ifdef FASTFLOAT_64BIT_LIMB + constexpr static limb large_power_of_5[] = { + 1414648277510068013UL, 9180637584431281687UL, 4539964771860779200UL, + 10482974169319127550UL, 198276706040285095UL}; +#else + constexpr static limb large_power_of_5[] = { + 4279965485U, 329373468U, 4020270615U, 2137533757U, 4287402176U, + 1057042919U, 1071430142U, 2440757623U, 381945767U, 46164893U}; +#endif +}; + +template +constexpr uint32_t pow5_tables::large_step; + +template +constexpr uint64_t pow5_tables::small_power_of_5[]; + +template +constexpr limb pow5_tables::large_power_of_5[]; + +// big integer type. implements a small subset of big integer +// arithmetic, using simple algorithms since asymptotically +// faster algorithms are slower for a small number of limbs. +// all operations assume the big-integer is normalized. +struct bigint : pow5_tables<> { + // storage of the limbs, in little-endian order. + stackvec vec; + + FASTFLOAT_CONSTEXPR20 bigint(): vec() {} + bigint(const bigint &) = delete; + bigint &operator=(const bigint &) = delete; + bigint(bigint &&) = delete; + bigint &operator=(bigint &&other) = delete; + + FASTFLOAT_CONSTEXPR20 bigint(uint64_t value): vec() { +#ifdef FASTFLOAT_64BIT_LIMB + vec.push_unchecked(value); +#else + vec.push_unchecked(uint32_t(value)); + vec.push_unchecked(uint32_t(value >> 32)); +#endif + vec.normalize(); + } + + // get the high 64 bits from the vector, and if bits were truncated. + // this is to get the significant digits for the float. + FASTFLOAT_CONSTEXPR20 uint64_t hi64(bool& truncated) const noexcept { +#ifdef FASTFLOAT_64BIT_LIMB + if (vec.len() == 0) { + return empty_hi64(truncated); + } else if (vec.len() == 1) { + return uint64_hi64(vec.rindex(0), truncated); + } else { + uint64_t result = uint64_hi64(vec.rindex(0), vec.rindex(1), truncated); + truncated |= vec.nonzero(2); + return result; + } +#else + if (vec.len() == 0) { + return empty_hi64(truncated); + } else if (vec.len() == 1) { + return uint32_hi64(vec.rindex(0), truncated); + } else if (vec.len() == 2) { + return uint32_hi64(vec.rindex(0), vec.rindex(1), truncated); + } else { + uint64_t result = uint32_hi64(vec.rindex(0), vec.rindex(1), vec.rindex(2), truncated); + truncated |= vec.nonzero(3); + return result; + } +#endif + } + + // compare two big integers, returning the large value. + // assumes both are normalized. if the return value is + // negative, other is larger, if the return value is + // positive, this is larger, otherwise they are equal. + // the limbs are stored in little-endian order, so we + // must compare the limbs in ever order. + FASTFLOAT_CONSTEXPR20 int compare(const bigint& other) const noexcept { + if (vec.len() > other.vec.len()) { + return 1; + } else if (vec.len() < other.vec.len()) { + return -1; + } else { + for (size_t index = vec.len(); index > 0; index--) { + limb xi = vec[index - 1]; + limb yi = other.vec[index - 1]; + if (xi > yi) { + return 1; + } else if (xi < yi) { + return -1; + } + } + return 0; + } + } + + // shift left each limb n bits, carrying over to the new limb + // returns true if we were able to shift all the digits. + FASTFLOAT_CONSTEXPR20 bool shl_bits(size_t n) noexcept { + // Internally, for each item, we shift left by n, and add the previous + // right shifted limb-bits. + // For example, we transform (for u8) shifted left 2, to: + // b10100100 b01000010 + // b10 b10010001 b00001000 + FASTFLOAT_DEBUG_ASSERT(n != 0); + FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8); + + size_t shl = n; + size_t shr = limb_bits - shl; + limb prev = 0; + for (size_t index = 0; index < vec.len(); index++) { + limb xi = vec[index]; + vec[index] = (xi << shl) | (prev >> shr); + prev = xi; + } + + limb carry = prev >> shr; + if (carry != 0) { + return vec.try_push(carry); + } + return true; + } + + // move the limbs left by `n` limbs. + FASTFLOAT_CONSTEXPR20 bool shl_limbs(size_t n) noexcept { + FASTFLOAT_DEBUG_ASSERT(n != 0); + if (n + vec.len() > vec.capacity()) { + return false; + } else if (!vec.is_empty()) { + // move limbs + limb* dst = vec.data + n; + const limb* src = vec.data; + std::copy_backward(src, src + vec.len(), dst + vec.len()); + // fill in empty limbs + limb* first = vec.data; + limb* last = first + n; + ::std::fill(first, last, 0); + vec.set_len(n + vec.len()); + return true; + } else { + return true; + } + } + + // move the limbs left by `n` bits. + FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept { + size_t rem = n % limb_bits; + size_t div = n / limb_bits; + if (rem != 0) { + FASTFLOAT_TRY(shl_bits(rem)); + } + if (div != 0) { + FASTFLOAT_TRY(shl_limbs(div)); + } + return true; + } + + // get the number of leading zeros in the bigint. + FASTFLOAT_CONSTEXPR20 int ctlz() const noexcept { + if (vec.is_empty()) { + return 0; + } else { +#ifdef FASTFLOAT_64BIT_LIMB + return leading_zeroes(vec.rindex(0)); +#else + // no use defining a specialized leading_zeroes for a 32-bit type. + uint64_t r0 = vec.rindex(0); + return leading_zeroes(r0 << 32); +#endif + } + } + + // get the number of bits in the bigint. + FASTFLOAT_CONSTEXPR20 int bit_length() const noexcept { + int lz = ctlz(); + return int(limb_bits * vec.len()) - lz; + } + + FASTFLOAT_CONSTEXPR20 bool mul(limb y) noexcept { + return small_mul(vec, y); + } + + FASTFLOAT_CONSTEXPR20 bool add(limb y) noexcept { + return small_add(vec, y); + } + + // multiply as if by 2 raised to a power. + FASTFLOAT_CONSTEXPR20 bool pow2(uint32_t exp) noexcept { + return shl(exp); + } + + // multiply as if by 5 raised to a power. + FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept { + // multiply by a power of 5 + size_t large_length = sizeof(large_power_of_5) / sizeof(limb); + limb_span large = limb_span(large_power_of_5, large_length); + while (exp >= large_step) { + FASTFLOAT_TRY(large_mul(vec, large)); + exp -= large_step; + } +#ifdef FASTFLOAT_64BIT_LIMB + uint32_t small_step = 27; + limb max_native = 7450580596923828125UL; +#else + uint32_t small_step = 13; + limb max_native = 1220703125U; +#endif + while (exp >= small_step) { + FASTFLOAT_TRY(small_mul(vec, max_native)); + exp -= small_step; + } + if (exp != 0) { + // Work around clang bug https://godbolt.org/z/zedh7rrhc + // This is similar to https://github.com/llvm/llvm-project/issues/47746, + // except the workaround described there don't work here + FASTFLOAT_TRY( + small_mul(vec, limb(((void)small_power_of_5[0], small_power_of_5[exp]))) + ); + } + + return true; + } + + // multiply as if by 10 raised to a power. + FASTFLOAT_CONSTEXPR20 bool pow10(uint32_t exp) noexcept { + FASTFLOAT_TRY(pow5(exp)); + return pow2(exp); + } +}; + +} // namespace fast_float + +#endif diff --git a/Include/Libraries/fast_float/constexpr_feature_detect.h b/Include/Libraries/fast_float/constexpr_feature_detect.h new file mode 100644 index 0000000..ba8b65c --- /dev/null +++ b/Include/Libraries/fast_float/constexpr_feature_detect.h @@ -0,0 +1,40 @@ +#ifndef FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H +#define FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H + +#ifdef __has_include +#if __has_include() +#include +#endif +#endif + +// Testing for https://wg21.link/N3652, adopted in C++14 +#if __cpp_constexpr >= 201304 +#define FASTFLOAT_CONSTEXPR14 constexpr +#else +#define FASTFLOAT_CONSTEXPR14 +#endif + +#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L +#define FASTFLOAT_HAS_BIT_CAST 1 +#else +#define FASTFLOAT_HAS_BIT_CAST 0 +#endif + +#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L +#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 1 +#else +#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 0 +#endif + +// Testing for relevant C++20 constexpr library features +#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED \ + && FASTFLOAT_HAS_BIT_CAST \ + && __cpp_lib_constexpr_algorithms >= 201806L /*For std::copy and std::fill*/ +#define FASTFLOAT_CONSTEXPR20 constexpr +#define FASTFLOAT_IS_CONSTEXPR 1 +#else +#define FASTFLOAT_CONSTEXPR20 +#define FASTFLOAT_IS_CONSTEXPR 0 +#endif + +#endif // FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H diff --git a/Include/Libraries/fast_float/decimal_to_binary.h b/Include/Libraries/fast_float/decimal_to_binary.h new file mode 100644 index 0000000..fec916f --- /dev/null +++ b/Include/Libraries/fast_float/decimal_to_binary.h @@ -0,0 +1,189 @@ +#ifndef FASTFLOAT_DECIMAL_TO_BINARY_H +#define FASTFLOAT_DECIMAL_TO_BINARY_H + +#include "float_common.h" +#include "fast_table.h" +#include +#include +#include +#include +#include +#include + +namespace fast_float { + +// This will compute or rather approximate w * 5**q and return a pair of 64-bit words approximating +// the result, with the "high" part corresponding to the most significant bits and the +// low part corresponding to the least significant bits. +// +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +value128 compute_product_approximation(int64_t q, uint64_t w) { + const int index = 2 * int(q - powers::smallest_power_of_five); + // For small values of q, e.g., q in [0,27], the answer is always exact because + // The line value128 firstproduct = full_multiplication(w, power_of_five_128[index]); + // gives the exact answer. + value128 firstproduct = full_multiplication(w, powers::power_of_five_128[index]); + static_assert((bit_precision >= 0) && (bit_precision <= 64), " precision should be in (0,64]"); + constexpr uint64_t precision_mask = (bit_precision < 64) ? + (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision) + : uint64_t(0xFFFFFFFFFFFFFFFF); + if((firstproduct.high & precision_mask) == precision_mask) { // could further guard with (lower + w < lower) + // regarding the second product, we only need secondproduct.high, but our expectation is that the compiler will optimize this extra work away if needed. + value128 secondproduct = full_multiplication(w, powers::power_of_five_128[index + 1]); + firstproduct.low += secondproduct.high; + if(secondproduct.high > firstproduct.low) { + firstproduct.high++; + } + } + return firstproduct; +} + +namespace detail { +/** + * For q in (0,350), we have that + * f = (((152170 + 65536) * q ) >> 16); + * is equal to + * floor(p) + q + * where + * p = log(5**q)/log(2) = q * log(5)/log(2) + * + * For negative values of q in (-400,0), we have that + * f = (((152170 + 65536) * q ) >> 16); + * is equal to + * -ceil(p) + q + * where + * p = log(5**-q)/log(2) = -q * log(5)/log(2) + */ + constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept { + return (((152170 + 65536) * q) >> 16) + 63; + } +} // namespace detail + +// create an adjusted mantissa, biased by the invalid power2 +// for significant digits already multiplied by 10 ** q. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +adjusted_mantissa compute_error_scaled(int64_t q, uint64_t w, int lz) noexcept { + int hilz = int(w >> 63) ^ 1; + adjusted_mantissa answer; + answer.mantissa = w << hilz; + int bias = binary::mantissa_explicit_bits() - binary::minimum_exponent(); + answer.power2 = int32_t(detail::power(int32_t(q)) + bias - hilz - lz - 62 + invalid_am_bias); + return answer; +} + +// w * 10 ** q, without rounding the representation up. +// the power2 in the exponent will be adjusted by invalid_am_bias. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +adjusted_mantissa compute_error(int64_t q, uint64_t w) noexcept { + int lz = leading_zeroes(w); + w <<= lz; + value128 product = compute_product_approximation(q, w); + return compute_error_scaled(q, product.high, lz); +} + +// w * 10 ** q +// The returned value should be a valid ieee64 number that simply need to be packed. +// However, in some very rare cases, the computation will fail. In such cases, we +// return an adjusted_mantissa with a negative power of 2: the caller should recompute +// in such cases. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept { + adjusted_mantissa answer; + if ((w == 0) || (q < binary::smallest_power_of_ten())) { + answer.power2 = 0; + answer.mantissa = 0; + // result should be zero + return answer; + } + if (q > binary::largest_power_of_ten()) { + // we want to get infinity: + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + return answer; + } + // At this point in time q is in [powers::smallest_power_of_five, powers::largest_power_of_five]. + + // We want the most significant bit of i to be 1. Shift if needed. + int lz = leading_zeroes(w); + w <<= lz; + + // The required precision is binary::mantissa_explicit_bits() + 3 because + // 1. We need the implicit bit + // 2. We need an extra bit for rounding purposes + // 3. We might lose a bit due to the "upperbit" routine (result too small, requiring a shift) + + value128 product = compute_product_approximation(q, w); + // The computed 'product' is always sufficient. + // Mathematical proof: + // Noble Mushtak and Daniel Lemire, Fast Number Parsing Without Fallback (to appear) + // See script/mushtak_lemire.py + + // The "compute_product_approximation" function can be slightly slower than a branchless approach: + // value128 product = compute_product(q, w); + // but in practice, we can win big with the compute_product_approximation if its additional branch + // is easily predicted. Which is best is data specific. + int upperbit = int(product.high >> 63); + + answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); + + answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz - binary::minimum_exponent()); + if (answer.power2 <= 0) { // we have a subnormal? + // Here have that answer.power2 <= 0 so -answer.power2 >= 0 + if(-answer.power2 + 1 >= 64) { // if we have more than 64 bits below the minimum exponent, you have a zero for sure. + answer.power2 = 0; + answer.mantissa = 0; + // result should be zero + return answer; + } + // next line is safe because -answer.power2 + 1 < 64 + answer.mantissa >>= -answer.power2 + 1; + // Thankfully, we can't have both "round-to-even" and subnormals because + // "round-to-even" only occurs for powers close to 0. + answer.mantissa += (answer.mantissa & 1); // round up + answer.mantissa >>= 1; + // There is a weird scenario where we don't have a subnormal but just. + // Suppose we start with 2.2250738585072013e-308, we end up + // with 0x3fffffffffffff x 2^-1023-53 which is technically subnormal + // whereas 0x40000000000000 x 2^-1023-53 is normal. Now, we need to round + // up 0x3fffffffffffff x 2^-1023-53 and once we do, we are no longer + // subnormal, but we can only know this after rounding. + // So we only declare a subnormal if we are smaller than the threshold. + answer.power2 = (answer.mantissa < (uint64_t(1) << binary::mantissa_explicit_bits())) ? 0 : 1; + return answer; + } + + // usually, we round *up*, but if we fall right in between and and we have an + // even basis, we need to round down + // We are only concerned with the cases where 5**q fits in single 64-bit word. + if ((product.low <= 1) && (q >= binary::min_exponent_round_to_even()) && (q <= binary::max_exponent_round_to_even()) && + ((answer.mantissa & 3) == 1) ) { // we may fall between two floats! + // To be in-between two floats we need that in doing + // answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); + // ... we dropped out only zeroes. But if this happened, then we can go back!!! + if((answer.mantissa << (upperbit + 64 - binary::mantissa_explicit_bits() - 3)) == product.high) { + answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up + } + } + + answer.mantissa += (answer.mantissa & 1); // round up + answer.mantissa >>= 1; + if (answer.mantissa >= (uint64_t(2) << binary::mantissa_explicit_bits())) { + answer.mantissa = (uint64_t(1) << binary::mantissa_explicit_bits()); + answer.power2++; // undo previous addition + } + + answer.mantissa &= ~(uint64_t(1) << binary::mantissa_explicit_bits()); + if (answer.power2 >= binary::infinite_power()) { // infinity + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + } + return answer; +} + +} // namespace fast_float + +#endif diff --git a/Include/Libraries/fast_float/digit_comparison.h b/Include/Libraries/fast_float/digit_comparison.h new file mode 100644 index 0000000..512a27f --- /dev/null +++ b/Include/Libraries/fast_float/digit_comparison.h @@ -0,0 +1,426 @@ +#ifndef FASTFLOAT_DIGIT_COMPARISON_H +#define FASTFLOAT_DIGIT_COMPARISON_H + +#include +#include +#include +#include + +#include "float_common.h" +#include "bigint.h" +#include "ascii_number.h" + +namespace fast_float { + +// 1e0 to 1e19 +constexpr static uint64_t powers_of_ten_uint64[] = { + 1UL, 10UL, 100UL, 1000UL, 10000UL, 100000UL, 1000000UL, 10000000UL, 100000000UL, + 1000000000UL, 10000000000UL, 100000000000UL, 1000000000000UL, 10000000000000UL, + 100000000000000UL, 1000000000000000UL, 10000000000000000UL, 100000000000000000UL, + 1000000000000000000UL, 10000000000000000000UL}; + +// calculate the exponent, in scientific notation, of the number. +// this algorithm is not even close to optimized, but it has no practical +// effect on performance: in order to have a faster algorithm, we'd need +// to slow down performance for faster algorithms, and this is still fast. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +int32_t scientific_exponent(parsed_number_string_t & num) noexcept { + uint64_t mantissa = num.mantissa; + int32_t exponent = int32_t(num.exponent); + while (mantissa >= 10000) { + mantissa /= 10000; + exponent += 4; + } + while (mantissa >= 100) { + mantissa /= 100; + exponent += 2; + } + while (mantissa >= 10) { + mantissa /= 10; + exponent += 1; + } + return exponent; +} + +// this converts a native floating-point number to an extended-precision float. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +adjusted_mantissa to_extended(T value) noexcept { + using equiv_uint = typename binary_format::equiv_uint; + constexpr equiv_uint exponent_mask = binary_format::exponent_mask(); + constexpr equiv_uint mantissa_mask = binary_format::mantissa_mask(); + constexpr equiv_uint hidden_bit_mask = binary_format::hidden_bit_mask(); + + adjusted_mantissa am; + int32_t bias = binary_format::mantissa_explicit_bits() - binary_format::minimum_exponent(); + equiv_uint bits; +#if FASTFLOAT_HAS_BIT_CAST + bits = std::bit_cast(value); +#else + ::memcpy(&bits, &value, sizeof(T)); +#endif + if ((bits & exponent_mask) == 0) { + // denormal + am.power2 = 1 - bias; + am.mantissa = bits & mantissa_mask; + } else { + // normal + am.power2 = int32_t((bits & exponent_mask) >> binary_format::mantissa_explicit_bits()); + am.power2 -= bias; + am.mantissa = (bits & mantissa_mask) | hidden_bit_mask; + } + + return am; +} + +// get the extended precision value of the halfway point between b and b+u. +// we are given a native float that represents b, so we need to adjust it +// halfway between b and b+u. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +adjusted_mantissa to_extended_halfway(T value) noexcept { + adjusted_mantissa am = to_extended(value); + am.mantissa <<= 1; + am.mantissa += 1; + am.power2 -= 1; + return am; +} + +// round an extended-precision float to the nearest machine float. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +void round(adjusted_mantissa& am, callback cb) noexcept { + int32_t mantissa_shift = 64 - binary_format::mantissa_explicit_bits() - 1; + if (-am.power2 >= mantissa_shift) { + // have a denormal float + int32_t shift = -am.power2 + 1; + cb(am, std::min(shift, 64)); + // check for round-up: if rounding-nearest carried us to the hidden bit. + am.power2 = (am.mantissa < (uint64_t(1) << binary_format::mantissa_explicit_bits())) ? 0 : 1; + return; + } + + // have a normal float, use the default shift. + cb(am, mantissa_shift); + + // check for carry + if (am.mantissa >= (uint64_t(2) << binary_format::mantissa_explicit_bits())) { + am.mantissa = (uint64_t(1) << binary_format::mantissa_explicit_bits()); + am.power2++; + } + + // check for infinite: we could have carried to an infinite power + am.mantissa &= ~(uint64_t(1) << binary_format::mantissa_explicit_bits()); + if (am.power2 >= binary_format::infinite_power()) { + am.power2 = binary_format::infinite_power(); + am.mantissa = 0; + } +} + +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +void round_nearest_tie_even(adjusted_mantissa& am, int32_t shift, callback cb) noexcept { + const uint64_t mask + = (shift == 64) + ? UINT64_MAX + : (uint64_t(1) << shift) - 1; + const uint64_t halfway + = (shift == 0) + ? 0 + : uint64_t(1) << (shift - 1); + uint64_t truncated_bits = am.mantissa & mask; + bool is_above = truncated_bits > halfway; + bool is_halfway = truncated_bits == halfway; + + // shift digits into position + if (shift == 64) { + am.mantissa = 0; + } else { + am.mantissa >>= shift; + } + am.power2 += shift; + + bool is_odd = (am.mantissa & 1) == 1; + am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above)); +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +void round_down(adjusted_mantissa& am, int32_t shift) noexcept { + if (shift == 64) { + am.mantissa = 0; + } else { + am.mantissa >>= shift; + } + am.power2 += shift; +} +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void skip_zeros(UC const * & first, UC const * last) noexcept { + uint64_t val; + while (!cpp20_and_in_constexpr() && std::distance(first, last) >= int_cmp_len()) { + ::memcpy(&val, first, sizeof(uint64_t)); + if (val != int_cmp_zeros()) { + break; + } + first += int_cmp_len(); + } + while (first != last) { + if (*first != UC('0')) { + break; + } + first++; + } +} + +// determine if any non-zero digits were truncated. +// all characters must be valid digits. +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +bool is_truncated(UC const * first, UC const * last) noexcept { + // do 8-bit optimizations, can just compare to 8 literal 0s. + uint64_t val; + while (!cpp20_and_in_constexpr() && std::distance(first, last) >= int_cmp_len()) { + ::memcpy(&val, first, sizeof(uint64_t)); + if (val != int_cmp_zeros()) { + return true; + } + first += int_cmp_len(); + } + while (first != last) { + if (*first != UC('0')) { + return true; + } + ++first; + } + return false; +} +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +bool is_truncated(span s) noexcept { + return is_truncated(s.ptr, s.ptr + s.len()); +} + + +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void parse_eight_digits(const UC*& p, limb& value, size_t& counter, size_t& count) noexcept { + value = value * 100000000 + parse_eight_digits_unrolled(p); + p += 8; + counter += 8; + count += 8; +} + +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +void parse_one_digit(UC const *& p, limb& value, size_t& counter, size_t& count) noexcept { + value = value * 10 + limb(*p - UC('0')); + p++; + counter++; + count++; +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void add_native(bigint& big, limb power, limb value) noexcept { + big.mul(power); + big.add(value); +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void round_up_bigint(bigint& big, size_t& count) noexcept { + // need to round-up the digits, but need to avoid rounding + // ....9999 to ...10000, which could cause a false halfway point. + add_native(big, 10, 1); + count++; +} + +// parse the significant digits into a big integer +template +inline FASTFLOAT_CONSTEXPR20 +void parse_mantissa(bigint& result, parsed_number_string_t& num, size_t max_digits, size_t& digits) noexcept { + // try to minimize the number of big integer and scalar multiplication. + // therefore, try to parse 8 digits at a time, and multiply by the largest + // scalar value (9 or 19 digits) for each step. + size_t counter = 0; + digits = 0; + limb value = 0; +#ifdef FASTFLOAT_64BIT_LIMB + size_t step = 19; +#else + size_t step = 9; +#endif + + // process all integer digits. + UC const * p = num.integer.ptr; + UC const * pend = p + num.integer.len(); + skip_zeros(p, pend); + // process all digits, in increments of step per loop + while (p != pend) { + while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && (max_digits - digits >= 8)) { + parse_eight_digits(p, value, counter, digits); + } + while (counter < step && p != pend && digits < max_digits) { + parse_one_digit(p, value, counter, digits); + } + if (digits == max_digits) { + // add the temporary value, then check if we've truncated any digits + add_native(result, limb(powers_of_ten_uint64[counter]), value); + bool truncated = is_truncated(p, pend); + if (num.fraction.ptr != nullptr) { + truncated |= is_truncated(num.fraction); + } + if (truncated) { + round_up_bigint(result, digits); + } + return; + } else { + add_native(result, limb(powers_of_ten_uint64[counter]), value); + counter = 0; + value = 0; + } + } + + // add our fraction digits, if they're available. + if (num.fraction.ptr != nullptr) { + p = num.fraction.ptr; + pend = p + num.fraction.len(); + if (digits == 0) { + skip_zeros(p, pend); + } + // process all digits, in increments of step per loop + while (p != pend) { + while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && (max_digits - digits >= 8)) { + parse_eight_digits(p, value, counter, digits); + } + while (counter < step && p != pend && digits < max_digits) { + parse_one_digit(p, value, counter, digits); + } + if (digits == max_digits) { + // add the temporary value, then check if we've truncated any digits + add_native(result, limb(powers_of_ten_uint64[counter]), value); + bool truncated = is_truncated(p, pend); + if (truncated) { + round_up_bigint(result, digits); + } + return; + } else { + add_native(result, limb(powers_of_ten_uint64[counter]), value); + counter = 0; + value = 0; + } + } + } + + if (counter != 0) { + add_native(result, limb(powers_of_ten_uint64[counter]), value); + } +} + +template +inline FASTFLOAT_CONSTEXPR20 +adjusted_mantissa positive_digit_comp(bigint& bigmant, int32_t exponent) noexcept { + FASTFLOAT_ASSERT(bigmant.pow10(uint32_t(exponent))); + adjusted_mantissa answer; + bool truncated; + answer.mantissa = bigmant.hi64(truncated); + int bias = binary_format::mantissa_explicit_bits() - binary_format::minimum_exponent(); + answer.power2 = bigmant.bit_length() - 64 + bias; + + round(answer, [truncated](adjusted_mantissa& a, int32_t shift) { + round_nearest_tie_even(a, shift, [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool { + return is_above || (is_halfway && truncated) || (is_odd && is_halfway); + }); + }); + + return answer; +} + +// the scaling here is quite simple: we have, for the real digits `m * 10^e`, +// and for the theoretical digits `n * 2^f`. Since `e` is always negative, +// to scale them identically, we do `n * 2^f * 5^-f`, so we now have `m * 2^e`. +// we then need to scale by `2^(f- e)`, and then the two significant digits +// are of the same magnitude. +template +inline FASTFLOAT_CONSTEXPR20 +adjusted_mantissa negative_digit_comp(bigint& bigmant, adjusted_mantissa am, int32_t exponent) noexcept { + bigint& real_digits = bigmant; + int32_t real_exp = exponent; + + // get the value of `b`, rounded down, and get a bigint representation of b+h + adjusted_mantissa am_b = am; + // gcc7 buf: use a lambda to remove the noexcept qualifier bug with -Wnoexcept-type. + round(am_b, [](adjusted_mantissa&a, int32_t shift) { round_down(a, shift); }); + T b; + to_float(false, am_b, b); + adjusted_mantissa theor = to_extended_halfway(b); + bigint theor_digits(theor.mantissa); + int32_t theor_exp = theor.power2; + + // scale real digits and theor digits to be same power. + int32_t pow2_exp = theor_exp - real_exp; + uint32_t pow5_exp = uint32_t(-real_exp); + if (pow5_exp != 0) { + FASTFLOAT_ASSERT(theor_digits.pow5(pow5_exp)); + } + if (pow2_exp > 0) { + FASTFLOAT_ASSERT(theor_digits.pow2(uint32_t(pow2_exp))); + } else if (pow2_exp < 0) { + FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp))); + } + + // compare digits, and use it to director rounding + int ord = real_digits.compare(theor_digits); + adjusted_mantissa answer = am; + round(answer, [ord](adjusted_mantissa& a, int32_t shift) { + round_nearest_tie_even(a, shift, [ord](bool is_odd, bool _, bool __) -> bool { + (void)_; // not needed, since we've done our comparison + (void)__; // not needed, since we've done our comparison + if (ord > 0) { + return true; + } else if (ord < 0) { + return false; + } else { + return is_odd; + } + }); + }); + + return answer; +} + +// parse the significant digits as a big integer to unambiguously round the +// the significant digits. here, we are trying to determine how to round +// an extended float representation close to `b+h`, halfway between `b` +// (the float rounded-down) and `b+u`, the next positive float. this +// algorithm is always correct, and uses one of two approaches. when +// the exponent is positive relative to the significant digits (such as +// 1234), we create a big-integer representation, get the high 64-bits, +// determine if any lower bits are truncated, and use that to direct +// rounding. in case of a negative exponent relative to the significant +// digits (such as 1.2345), we create a theoretical representation of +// `b` as a big-integer type, scaled to the same binary exponent as +// the actual digits. we then compare the big integer representations +// of both, and use that to direct rounding. +template +inline FASTFLOAT_CONSTEXPR20 +adjusted_mantissa digit_comp(parsed_number_string_t& num, adjusted_mantissa am) noexcept { + // remove the invalid exponent bias + am.power2 -= invalid_am_bias; + + int32_t sci_exp = scientific_exponent(num); + size_t max_digits = binary_format::max_digits(); + size_t digits = 0; + bigint bigmant; + parse_mantissa(bigmant, num, max_digits, digits); + // can't underflow, since digits is at most max_digits. + int32_t exponent = sci_exp + 1 - int32_t(digits); + if (exponent >= 0) { + return positive_digit_comp(bigmant, exponent); + } else { + return negative_digit_comp(bigmant, am, exponent); + } +} + +} // namespace fast_float + +#endif diff --git a/Include/Libraries/fast_float/fast_float.h b/Include/Libraries/fast_float/fast_float.h new file mode 100644 index 0000000..9b1b9b4 --- /dev/null +++ b/Include/Libraries/fast_float/fast_float.h @@ -0,0 +1,48 @@ + +#ifndef FASTFLOAT_FAST_FLOAT_H +#define FASTFLOAT_FAST_FLOAT_H + +#include "float_common.h" + +namespace fast_float { +/** + * This function parses the character sequence [first,last) for a number. It parses floating-point numbers expecting + * a locale-indepent format equivalent to what is used by std::strtod in the default ("C") locale. + * The resulting floating-point value is the closest floating-point values (using either float or double), + * using the "round to even" convention for values that would otherwise fall right in-between two values. + * That is, we provide exact parsing according to the IEEE standard. + * + * Given a successful parse, the pointer (`ptr`) in the returned value is set to point right after the + * parsed number, and the `value` referenced is set to the parsed value. In case of error, the returned + * `ec` contains a representative error, otherwise the default (`std::errc()`) value is stored. + * + * The implementation does not throw and does not allocate memory (e.g., with `new` or `malloc`). + * + * Like the C++17 standard, the `fast_float::from_chars` functions take an optional last argument of + * the type `fast_float::chars_format`. It is a bitset value: we check whether + * `fmt & fast_float::chars_format::fixed` and `fmt & fast_float::chars_format::scientific` are set + * to determine whether we allow the fixed point and scientific notation respectively. + * The default is `fast_float::chars_format::general` which allows both `fixed` and `scientific`. + */ +template())> +FASTFLOAT_CONSTEXPR20 +from_chars_result_t from_chars(UC const * first, UC const * last, + T &value, chars_format fmt = chars_format::general) noexcept; + +/** + * Like from_chars, but accepts an `options` argument to govern number parsing. + */ +template +FASTFLOAT_CONSTEXPR20 +from_chars_result_t from_chars_advanced(UC const * first, UC const * last, + T &value, parse_options_t options) noexcept; +/** +* from_chars for integer types. +*/ +template ())> +FASTFLOAT_CONSTEXPR20 +from_chars_result_t from_chars(UC const * first, UC const * last, T& value, int base = 10) noexcept; + +} // namespace fast_float +#include "parse_number.h" +#endif // FASTFLOAT_FAST_FLOAT_H diff --git a/Include/Libraries/fast_float/fast_table.h b/Include/Libraries/fast_float/fast_table.h new file mode 100644 index 0000000..d8dc569 --- /dev/null +++ b/Include/Libraries/fast_float/fast_table.h @@ -0,0 +1,700 @@ +#ifndef FASTFLOAT_FAST_TABLE_H +#define FASTFLOAT_FAST_TABLE_H + +#include + +namespace fast_float { + +/** + * When mapping numbers from decimal to binary, + * we go from w * 10^q to m * 2^p but we have + * 10^q = 5^q * 2^q, so effectively + * we are trying to match + * w * 2^q * 5^q to m * 2^p. Thus the powers of two + * are not a concern since they can be represented + * exactly using the binary notation, only the powers of five + * affect the binary significand. + */ + +/** + * The smallest non-zero float (binary64) is 2^-1074. + * We take as input numbers of the form w x 10^q where w < 2^64. + * We have that w * 10^-343 < 2^(64-344) 5^-343 < 2^-1076. + * However, we have that + * (2^64-1) * 10^-342 = (2^64-1) * 2^-342 * 5^-342 > 2^-1074. + * Thus it is possible for a number of the form w * 10^-342 where + * w is a 64-bit value to be a non-zero floating-point number. + ********* + * Any number of form w * 10^309 where w>= 1 is going to be + * infinite in binary64 so we never need to worry about powers + * of 5 greater than 308. + */ +template +struct powers_template { + +constexpr static int smallest_power_of_five = binary_format::smallest_power_of_ten(); +constexpr static int largest_power_of_five = binary_format::largest_power_of_ten(); +constexpr static int number_of_entries = 2 * (largest_power_of_five - smallest_power_of_five + 1); +// Powers of five from 5^-342 all the way to 5^308 rounded toward one. +constexpr static uint64_t power_of_five_128[number_of_entries] = { + 0xeef453d6923bd65a,0x113faa2906a13b3f, + 0x9558b4661b6565f8,0x4ac7ca59a424c507, + 0xbaaee17fa23ebf76,0x5d79bcf00d2df649, + 0xe95a99df8ace6f53,0xf4d82c2c107973dc, + 0x91d8a02bb6c10594,0x79071b9b8a4be869, + 0xb64ec836a47146f9,0x9748e2826cdee284, + 0xe3e27a444d8d98b7,0xfd1b1b2308169b25, + 0x8e6d8c6ab0787f72,0xfe30f0f5e50e20f7, + 0xb208ef855c969f4f,0xbdbd2d335e51a935, + 0xde8b2b66b3bc4723,0xad2c788035e61382, + 0x8b16fb203055ac76,0x4c3bcb5021afcc31, + 0xaddcb9e83c6b1793,0xdf4abe242a1bbf3d, + 0xd953e8624b85dd78,0xd71d6dad34a2af0d, + 0x87d4713d6f33aa6b,0x8672648c40e5ad68, + 0xa9c98d8ccb009506,0x680efdaf511f18c2, + 0xd43bf0effdc0ba48,0x212bd1b2566def2, + 0x84a57695fe98746d,0x14bb630f7604b57, + 0xa5ced43b7e3e9188,0x419ea3bd35385e2d, + 0xcf42894a5dce35ea,0x52064cac828675b9, + 0x818995ce7aa0e1b2,0x7343efebd1940993, + 0xa1ebfb4219491a1f,0x1014ebe6c5f90bf8, + 0xca66fa129f9b60a6,0xd41a26e077774ef6, + 0xfd00b897478238d0,0x8920b098955522b4, + 0x9e20735e8cb16382,0x55b46e5f5d5535b0, + 0xc5a890362fddbc62,0xeb2189f734aa831d, + 0xf712b443bbd52b7b,0xa5e9ec7501d523e4, + 0x9a6bb0aa55653b2d,0x47b233c92125366e, + 0xc1069cd4eabe89f8,0x999ec0bb696e840a, + 0xf148440a256e2c76,0xc00670ea43ca250d, + 0x96cd2a865764dbca,0x380406926a5e5728, + 0xbc807527ed3e12bc,0xc605083704f5ecf2, + 0xeba09271e88d976b,0xf7864a44c633682e, + 0x93445b8731587ea3,0x7ab3ee6afbe0211d, + 0xb8157268fdae9e4c,0x5960ea05bad82964, + 0xe61acf033d1a45df,0x6fb92487298e33bd, + 0x8fd0c16206306bab,0xa5d3b6d479f8e056, + 0xb3c4f1ba87bc8696,0x8f48a4899877186c, + 0xe0b62e2929aba83c,0x331acdabfe94de87, + 0x8c71dcd9ba0b4925,0x9ff0c08b7f1d0b14, + 0xaf8e5410288e1b6f,0x7ecf0ae5ee44dd9, + 0xdb71e91432b1a24a,0xc9e82cd9f69d6150, + 0x892731ac9faf056e,0xbe311c083a225cd2, + 0xab70fe17c79ac6ca,0x6dbd630a48aaf406, + 0xd64d3d9db981787d,0x92cbbccdad5b108, + 0x85f0468293f0eb4e,0x25bbf56008c58ea5, + 0xa76c582338ed2621,0xaf2af2b80af6f24e, + 0xd1476e2c07286faa,0x1af5af660db4aee1, + 0x82cca4db847945ca,0x50d98d9fc890ed4d, + 0xa37fce126597973c,0xe50ff107bab528a0, + 0xcc5fc196fefd7d0c,0x1e53ed49a96272c8, + 0xff77b1fcbebcdc4f,0x25e8e89c13bb0f7a, + 0x9faacf3df73609b1,0x77b191618c54e9ac, + 0xc795830d75038c1d,0xd59df5b9ef6a2417, + 0xf97ae3d0d2446f25,0x4b0573286b44ad1d, + 0x9becce62836ac577,0x4ee367f9430aec32, + 0xc2e801fb244576d5,0x229c41f793cda73f, + 0xf3a20279ed56d48a,0x6b43527578c1110f, + 0x9845418c345644d6,0x830a13896b78aaa9, + 0xbe5691ef416bd60c,0x23cc986bc656d553, + 0xedec366b11c6cb8f,0x2cbfbe86b7ec8aa8, + 0x94b3a202eb1c3f39,0x7bf7d71432f3d6a9, + 0xb9e08a83a5e34f07,0xdaf5ccd93fb0cc53, + 0xe858ad248f5c22c9,0xd1b3400f8f9cff68, + 0x91376c36d99995be,0x23100809b9c21fa1, + 0xb58547448ffffb2d,0xabd40a0c2832a78a, + 0xe2e69915b3fff9f9,0x16c90c8f323f516c, + 0x8dd01fad907ffc3b,0xae3da7d97f6792e3, + 0xb1442798f49ffb4a,0x99cd11cfdf41779c, + 0xdd95317f31c7fa1d,0x40405643d711d583, + 0x8a7d3eef7f1cfc52,0x482835ea666b2572, + 0xad1c8eab5ee43b66,0xda3243650005eecf, + 0xd863b256369d4a40,0x90bed43e40076a82, + 0x873e4f75e2224e68,0x5a7744a6e804a291, + 0xa90de3535aaae202,0x711515d0a205cb36, + 0xd3515c2831559a83,0xd5a5b44ca873e03, + 0x8412d9991ed58091,0xe858790afe9486c2, + 0xa5178fff668ae0b6,0x626e974dbe39a872, + 0xce5d73ff402d98e3,0xfb0a3d212dc8128f, + 0x80fa687f881c7f8e,0x7ce66634bc9d0b99, + 0xa139029f6a239f72,0x1c1fffc1ebc44e80, + 0xc987434744ac874e,0xa327ffb266b56220, + 0xfbe9141915d7a922,0x4bf1ff9f0062baa8, + 0x9d71ac8fada6c9b5,0x6f773fc3603db4a9, + 0xc4ce17b399107c22,0xcb550fb4384d21d3, + 0xf6019da07f549b2b,0x7e2a53a146606a48, + 0x99c102844f94e0fb,0x2eda7444cbfc426d, + 0xc0314325637a1939,0xfa911155fefb5308, + 0xf03d93eebc589f88,0x793555ab7eba27ca, + 0x96267c7535b763b5,0x4bc1558b2f3458de, + 0xbbb01b9283253ca2,0x9eb1aaedfb016f16, + 0xea9c227723ee8bcb,0x465e15a979c1cadc, + 0x92a1958a7675175f,0xbfacd89ec191ec9, + 0xb749faed14125d36,0xcef980ec671f667b, + 0xe51c79a85916f484,0x82b7e12780e7401a, + 0x8f31cc0937ae58d2,0xd1b2ecb8b0908810, + 0xb2fe3f0b8599ef07,0x861fa7e6dcb4aa15, + 0xdfbdcece67006ac9,0x67a791e093e1d49a, + 0x8bd6a141006042bd,0xe0c8bb2c5c6d24e0, + 0xaecc49914078536d,0x58fae9f773886e18, + 0xda7f5bf590966848,0xaf39a475506a899e, + 0x888f99797a5e012d,0x6d8406c952429603, + 0xaab37fd7d8f58178,0xc8e5087ba6d33b83, + 0xd5605fcdcf32e1d6,0xfb1e4a9a90880a64, + 0x855c3be0a17fcd26,0x5cf2eea09a55067f, + 0xa6b34ad8c9dfc06f,0xf42faa48c0ea481e, + 0xd0601d8efc57b08b,0xf13b94daf124da26, + 0x823c12795db6ce57,0x76c53d08d6b70858, + 0xa2cb1717b52481ed,0x54768c4b0c64ca6e, + 0xcb7ddcdda26da268,0xa9942f5dcf7dfd09, + 0xfe5d54150b090b02,0xd3f93b35435d7c4c, + 0x9efa548d26e5a6e1,0xc47bc5014a1a6daf, + 0xc6b8e9b0709f109a,0x359ab6419ca1091b, + 0xf867241c8cc6d4c0,0xc30163d203c94b62, + 0x9b407691d7fc44f8,0x79e0de63425dcf1d, + 0xc21094364dfb5636,0x985915fc12f542e4, + 0xf294b943e17a2bc4,0x3e6f5b7b17b2939d, + 0x979cf3ca6cec5b5a,0xa705992ceecf9c42, + 0xbd8430bd08277231,0x50c6ff782a838353, + 0xece53cec4a314ebd,0xa4f8bf5635246428, + 0x940f4613ae5ed136,0x871b7795e136be99, + 0xb913179899f68584,0x28e2557b59846e3f, + 0xe757dd7ec07426e5,0x331aeada2fe589cf, + 0x9096ea6f3848984f,0x3ff0d2c85def7621, + 0xb4bca50b065abe63,0xfed077a756b53a9, + 0xe1ebce4dc7f16dfb,0xd3e8495912c62894, + 0x8d3360f09cf6e4bd,0x64712dd7abbbd95c, + 0xb080392cc4349dec,0xbd8d794d96aacfb3, + 0xdca04777f541c567,0xecf0d7a0fc5583a0, + 0x89e42caaf9491b60,0xf41686c49db57244, + 0xac5d37d5b79b6239,0x311c2875c522ced5, + 0xd77485cb25823ac7,0x7d633293366b828b, + 0x86a8d39ef77164bc,0xae5dff9c02033197, + 0xa8530886b54dbdeb,0xd9f57f830283fdfc, + 0xd267caa862a12d66,0xd072df63c324fd7b, + 0x8380dea93da4bc60,0x4247cb9e59f71e6d, + 0xa46116538d0deb78,0x52d9be85f074e608, + 0xcd795be870516656,0x67902e276c921f8b, + 0x806bd9714632dff6,0xba1cd8a3db53b6, + 0xa086cfcd97bf97f3,0x80e8a40eccd228a4, + 0xc8a883c0fdaf7df0,0x6122cd128006b2cd, + 0xfad2a4b13d1b5d6c,0x796b805720085f81, + 0x9cc3a6eec6311a63,0xcbe3303674053bb0, + 0xc3f490aa77bd60fc,0xbedbfc4411068a9c, + 0xf4f1b4d515acb93b,0xee92fb5515482d44, + 0x991711052d8bf3c5,0x751bdd152d4d1c4a, + 0xbf5cd54678eef0b6,0xd262d45a78a0635d, + 0xef340a98172aace4,0x86fb897116c87c34, + 0x9580869f0e7aac0e,0xd45d35e6ae3d4da0, + 0xbae0a846d2195712,0x8974836059cca109, + 0xe998d258869facd7,0x2bd1a438703fc94b, + 0x91ff83775423cc06,0x7b6306a34627ddcf, + 0xb67f6455292cbf08,0x1a3bc84c17b1d542, + 0xe41f3d6a7377eeca,0x20caba5f1d9e4a93, + 0x8e938662882af53e,0x547eb47b7282ee9c, + 0xb23867fb2a35b28d,0xe99e619a4f23aa43, + 0xdec681f9f4c31f31,0x6405fa00e2ec94d4, + 0x8b3c113c38f9f37e,0xde83bc408dd3dd04, + 0xae0b158b4738705e,0x9624ab50b148d445, + 0xd98ddaee19068c76,0x3badd624dd9b0957, + 0x87f8a8d4cfa417c9,0xe54ca5d70a80e5d6, + 0xa9f6d30a038d1dbc,0x5e9fcf4ccd211f4c, + 0xd47487cc8470652b,0x7647c3200069671f, + 0x84c8d4dfd2c63f3b,0x29ecd9f40041e073, + 0xa5fb0a17c777cf09,0xf468107100525890, + 0xcf79cc9db955c2cc,0x7182148d4066eeb4, + 0x81ac1fe293d599bf,0xc6f14cd848405530, + 0xa21727db38cb002f,0xb8ada00e5a506a7c, + 0xca9cf1d206fdc03b,0xa6d90811f0e4851c, + 0xfd442e4688bd304a,0x908f4a166d1da663, + 0x9e4a9cec15763e2e,0x9a598e4e043287fe, + 0xc5dd44271ad3cdba,0x40eff1e1853f29fd, + 0xf7549530e188c128,0xd12bee59e68ef47c, + 0x9a94dd3e8cf578b9,0x82bb74f8301958ce, + 0xc13a148e3032d6e7,0xe36a52363c1faf01, + 0xf18899b1bc3f8ca1,0xdc44e6c3cb279ac1, + 0x96f5600f15a7b7e5,0x29ab103a5ef8c0b9, + 0xbcb2b812db11a5de,0x7415d448f6b6f0e7, + 0xebdf661791d60f56,0x111b495b3464ad21, + 0x936b9fcebb25c995,0xcab10dd900beec34, + 0xb84687c269ef3bfb,0x3d5d514f40eea742, + 0xe65829b3046b0afa,0xcb4a5a3112a5112, + 0x8ff71a0fe2c2e6dc,0x47f0e785eaba72ab, + 0xb3f4e093db73a093,0x59ed216765690f56, + 0xe0f218b8d25088b8,0x306869c13ec3532c, + 0x8c974f7383725573,0x1e414218c73a13fb, + 0xafbd2350644eeacf,0xe5d1929ef90898fa, + 0xdbac6c247d62a583,0xdf45f746b74abf39, + 0x894bc396ce5da772,0x6b8bba8c328eb783, + 0xab9eb47c81f5114f,0x66ea92f3f326564, + 0xd686619ba27255a2,0xc80a537b0efefebd, + 0x8613fd0145877585,0xbd06742ce95f5f36, + 0xa798fc4196e952e7,0x2c48113823b73704, + 0xd17f3b51fca3a7a0,0xf75a15862ca504c5, + 0x82ef85133de648c4,0x9a984d73dbe722fb, + 0xa3ab66580d5fdaf5,0xc13e60d0d2e0ebba, + 0xcc963fee10b7d1b3,0x318df905079926a8, + 0xffbbcfe994e5c61f,0xfdf17746497f7052, + 0x9fd561f1fd0f9bd3,0xfeb6ea8bedefa633, + 0xc7caba6e7c5382c8,0xfe64a52ee96b8fc0, + 0xf9bd690a1b68637b,0x3dfdce7aa3c673b0, + 0x9c1661a651213e2d,0x6bea10ca65c084e, + 0xc31bfa0fe5698db8,0x486e494fcff30a62, + 0xf3e2f893dec3f126,0x5a89dba3c3efccfa, + 0x986ddb5c6b3a76b7,0xf89629465a75e01c, + 0xbe89523386091465,0xf6bbb397f1135823, + 0xee2ba6c0678b597f,0x746aa07ded582e2c, + 0x94db483840b717ef,0xa8c2a44eb4571cdc, + 0xba121a4650e4ddeb,0x92f34d62616ce413, + 0xe896a0d7e51e1566,0x77b020baf9c81d17, + 0x915e2486ef32cd60,0xace1474dc1d122e, + 0xb5b5ada8aaff80b8,0xd819992132456ba, + 0xe3231912d5bf60e6,0x10e1fff697ed6c69, + 0x8df5efabc5979c8f,0xca8d3ffa1ef463c1, + 0xb1736b96b6fd83b3,0xbd308ff8a6b17cb2, + 0xddd0467c64bce4a0,0xac7cb3f6d05ddbde, + 0x8aa22c0dbef60ee4,0x6bcdf07a423aa96b, + 0xad4ab7112eb3929d,0x86c16c98d2c953c6, + 0xd89d64d57a607744,0xe871c7bf077ba8b7, + 0x87625f056c7c4a8b,0x11471cd764ad4972, + 0xa93af6c6c79b5d2d,0xd598e40d3dd89bcf, + 0xd389b47879823479,0x4aff1d108d4ec2c3, + 0x843610cb4bf160cb,0xcedf722a585139ba, + 0xa54394fe1eedb8fe,0xc2974eb4ee658828, + 0xce947a3da6a9273e,0x733d226229feea32, + 0x811ccc668829b887,0x806357d5a3f525f, + 0xa163ff802a3426a8,0xca07c2dcb0cf26f7, + 0xc9bcff6034c13052,0xfc89b393dd02f0b5, + 0xfc2c3f3841f17c67,0xbbac2078d443ace2, + 0x9d9ba7832936edc0,0xd54b944b84aa4c0d, + 0xc5029163f384a931,0xa9e795e65d4df11, + 0xf64335bcf065d37d,0x4d4617b5ff4a16d5, + 0x99ea0196163fa42e,0x504bced1bf8e4e45, + 0xc06481fb9bcf8d39,0xe45ec2862f71e1d6, + 0xf07da27a82c37088,0x5d767327bb4e5a4c, + 0x964e858c91ba2655,0x3a6a07f8d510f86f, + 0xbbe226efb628afea,0x890489f70a55368b, + 0xeadab0aba3b2dbe5,0x2b45ac74ccea842e, + 0x92c8ae6b464fc96f,0x3b0b8bc90012929d, + 0xb77ada0617e3bbcb,0x9ce6ebb40173744, + 0xe55990879ddcaabd,0xcc420a6a101d0515, + 0x8f57fa54c2a9eab6,0x9fa946824a12232d, + 0xb32df8e9f3546564,0x47939822dc96abf9, + 0xdff9772470297ebd,0x59787e2b93bc56f7, + 0x8bfbea76c619ef36,0x57eb4edb3c55b65a, + 0xaefae51477a06b03,0xede622920b6b23f1, + 0xdab99e59958885c4,0xe95fab368e45eced, + 0x88b402f7fd75539b,0x11dbcb0218ebb414, + 0xaae103b5fcd2a881,0xd652bdc29f26a119, + 0xd59944a37c0752a2,0x4be76d3346f0495f, + 0x857fcae62d8493a5,0x6f70a4400c562ddb, + 0xa6dfbd9fb8e5b88e,0xcb4ccd500f6bb952, + 0xd097ad07a71f26b2,0x7e2000a41346a7a7, + 0x825ecc24c873782f,0x8ed400668c0c28c8, + 0xa2f67f2dfa90563b,0x728900802f0f32fa, + 0xcbb41ef979346bca,0x4f2b40a03ad2ffb9, + 0xfea126b7d78186bc,0xe2f610c84987bfa8, + 0x9f24b832e6b0f436,0xdd9ca7d2df4d7c9, + 0xc6ede63fa05d3143,0x91503d1c79720dbb, + 0xf8a95fcf88747d94,0x75a44c6397ce912a, + 0x9b69dbe1b548ce7c,0xc986afbe3ee11aba, + 0xc24452da229b021b,0xfbe85badce996168, + 0xf2d56790ab41c2a2,0xfae27299423fb9c3, + 0x97c560ba6b0919a5,0xdccd879fc967d41a, + 0xbdb6b8e905cb600f,0x5400e987bbc1c920, + 0xed246723473e3813,0x290123e9aab23b68, + 0x9436c0760c86e30b,0xf9a0b6720aaf6521, + 0xb94470938fa89bce,0xf808e40e8d5b3e69, + 0xe7958cb87392c2c2,0xb60b1d1230b20e04, + 0x90bd77f3483bb9b9,0xb1c6f22b5e6f48c2, + 0xb4ecd5f01a4aa828,0x1e38aeb6360b1af3, + 0xe2280b6c20dd5232,0x25c6da63c38de1b0, + 0x8d590723948a535f,0x579c487e5a38ad0e, + 0xb0af48ec79ace837,0x2d835a9df0c6d851, + 0xdcdb1b2798182244,0xf8e431456cf88e65, + 0x8a08f0f8bf0f156b,0x1b8e9ecb641b58ff, + 0xac8b2d36eed2dac5,0xe272467e3d222f3f, + 0xd7adf884aa879177,0x5b0ed81dcc6abb0f, + 0x86ccbb52ea94baea,0x98e947129fc2b4e9, + 0xa87fea27a539e9a5,0x3f2398d747b36224, + 0xd29fe4b18e88640e,0x8eec7f0d19a03aad, + 0x83a3eeeef9153e89,0x1953cf68300424ac, + 0xa48ceaaab75a8e2b,0x5fa8c3423c052dd7, + 0xcdb02555653131b6,0x3792f412cb06794d, + 0x808e17555f3ebf11,0xe2bbd88bbee40bd0, + 0xa0b19d2ab70e6ed6,0x5b6aceaeae9d0ec4, + 0xc8de047564d20a8b,0xf245825a5a445275, + 0xfb158592be068d2e,0xeed6e2f0f0d56712, + 0x9ced737bb6c4183d,0x55464dd69685606b, + 0xc428d05aa4751e4c,0xaa97e14c3c26b886, + 0xf53304714d9265df,0xd53dd99f4b3066a8, + 0x993fe2c6d07b7fab,0xe546a8038efe4029, + 0xbf8fdb78849a5f96,0xde98520472bdd033, + 0xef73d256a5c0f77c,0x963e66858f6d4440, + 0x95a8637627989aad,0xdde7001379a44aa8, + 0xbb127c53b17ec159,0x5560c018580d5d52, + 0xe9d71b689dde71af,0xaab8f01e6e10b4a6, + 0x9226712162ab070d,0xcab3961304ca70e8, + 0xb6b00d69bb55c8d1,0x3d607b97c5fd0d22, + 0xe45c10c42a2b3b05,0x8cb89a7db77c506a, + 0x8eb98a7a9a5b04e3,0x77f3608e92adb242, + 0xb267ed1940f1c61c,0x55f038b237591ed3, + 0xdf01e85f912e37a3,0x6b6c46dec52f6688, + 0x8b61313bbabce2c6,0x2323ac4b3b3da015, + 0xae397d8aa96c1b77,0xabec975e0a0d081a, + 0xd9c7dced53c72255,0x96e7bd358c904a21, + 0x881cea14545c7575,0x7e50d64177da2e54, + 0xaa242499697392d2,0xdde50bd1d5d0b9e9, + 0xd4ad2dbfc3d07787,0x955e4ec64b44e864, + 0x84ec3c97da624ab4,0xbd5af13bef0b113e, + 0xa6274bbdd0fadd61,0xecb1ad8aeacdd58e, + 0xcfb11ead453994ba,0x67de18eda5814af2, + 0x81ceb32c4b43fcf4,0x80eacf948770ced7, + 0xa2425ff75e14fc31,0xa1258379a94d028d, + 0xcad2f7f5359a3b3e,0x96ee45813a04330, + 0xfd87b5f28300ca0d,0x8bca9d6e188853fc, + 0x9e74d1b791e07e48,0x775ea264cf55347e, + 0xc612062576589dda,0x95364afe032a819e, + 0xf79687aed3eec551,0x3a83ddbd83f52205, + 0x9abe14cd44753b52,0xc4926a9672793543, + 0xc16d9a0095928a27,0x75b7053c0f178294, + 0xf1c90080baf72cb1,0x5324c68b12dd6339, + 0x971da05074da7bee,0xd3f6fc16ebca5e04, + 0xbce5086492111aea,0x88f4bb1ca6bcf585, + 0xec1e4a7db69561a5,0x2b31e9e3d06c32e6, + 0x9392ee8e921d5d07,0x3aff322e62439fd0, + 0xb877aa3236a4b449,0x9befeb9fad487c3, + 0xe69594bec44de15b,0x4c2ebe687989a9b4, + 0x901d7cf73ab0acd9,0xf9d37014bf60a11, + 0xb424dc35095cd80f,0x538484c19ef38c95, + 0xe12e13424bb40e13,0x2865a5f206b06fba, + 0x8cbccc096f5088cb,0xf93f87b7442e45d4, + 0xafebff0bcb24aafe,0xf78f69a51539d749, + 0xdbe6fecebdedd5be,0xb573440e5a884d1c, + 0x89705f4136b4a597,0x31680a88f8953031, + 0xabcc77118461cefc,0xfdc20d2b36ba7c3e, + 0xd6bf94d5e57a42bc,0x3d32907604691b4d, + 0x8637bd05af6c69b5,0xa63f9a49c2c1b110, + 0xa7c5ac471b478423,0xfcf80dc33721d54, + 0xd1b71758e219652b,0xd3c36113404ea4a9, + 0x83126e978d4fdf3b,0x645a1cac083126ea, + 0xa3d70a3d70a3d70a,0x3d70a3d70a3d70a4, + 0xcccccccccccccccc,0xcccccccccccccccd, + 0x8000000000000000,0x0, + 0xa000000000000000,0x0, + 0xc800000000000000,0x0, + 0xfa00000000000000,0x0, + 0x9c40000000000000,0x0, + 0xc350000000000000,0x0, + 0xf424000000000000,0x0, + 0x9896800000000000,0x0, + 0xbebc200000000000,0x0, + 0xee6b280000000000,0x0, + 0x9502f90000000000,0x0, + 0xba43b74000000000,0x0, + 0xe8d4a51000000000,0x0, + 0x9184e72a00000000,0x0, + 0xb5e620f480000000,0x0, + 0xe35fa931a0000000,0x0, + 0x8e1bc9bf04000000,0x0, + 0xb1a2bc2ec5000000,0x0, + 0xde0b6b3a76400000,0x0, + 0x8ac7230489e80000,0x0, + 0xad78ebc5ac620000,0x0, + 0xd8d726b7177a8000,0x0, + 0x878678326eac9000,0x0, + 0xa968163f0a57b400,0x0, + 0xd3c21bcecceda100,0x0, + 0x84595161401484a0,0x0, + 0xa56fa5b99019a5c8,0x0, + 0xcecb8f27f4200f3a,0x0, + 0x813f3978f8940984,0x4000000000000000, + 0xa18f07d736b90be5,0x5000000000000000, + 0xc9f2c9cd04674ede,0xa400000000000000, + 0xfc6f7c4045812296,0x4d00000000000000, + 0x9dc5ada82b70b59d,0xf020000000000000, + 0xc5371912364ce305,0x6c28000000000000, + 0xf684df56c3e01bc6,0xc732000000000000, + 0x9a130b963a6c115c,0x3c7f400000000000, + 0xc097ce7bc90715b3,0x4b9f100000000000, + 0xf0bdc21abb48db20,0x1e86d40000000000, + 0x96769950b50d88f4,0x1314448000000000, + 0xbc143fa4e250eb31,0x17d955a000000000, + 0xeb194f8e1ae525fd,0x5dcfab0800000000, + 0x92efd1b8d0cf37be,0x5aa1cae500000000, + 0xb7abc627050305ad,0xf14a3d9e40000000, + 0xe596b7b0c643c719,0x6d9ccd05d0000000, + 0x8f7e32ce7bea5c6f,0xe4820023a2000000, + 0xb35dbf821ae4f38b,0xdda2802c8a800000, + 0xe0352f62a19e306e,0xd50b2037ad200000, + 0x8c213d9da502de45,0x4526f422cc340000, + 0xaf298d050e4395d6,0x9670b12b7f410000, + 0xdaf3f04651d47b4c,0x3c0cdd765f114000, + 0x88d8762bf324cd0f,0xa5880a69fb6ac800, + 0xab0e93b6efee0053,0x8eea0d047a457a00, + 0xd5d238a4abe98068,0x72a4904598d6d880, + 0x85a36366eb71f041,0x47a6da2b7f864750, + 0xa70c3c40a64e6c51,0x999090b65f67d924, + 0xd0cf4b50cfe20765,0xfff4b4e3f741cf6d, + 0x82818f1281ed449f,0xbff8f10e7a8921a4, + 0xa321f2d7226895c7,0xaff72d52192b6a0d, + 0xcbea6f8ceb02bb39,0x9bf4f8a69f764490, + 0xfee50b7025c36a08,0x2f236d04753d5b4, + 0x9f4f2726179a2245,0x1d762422c946590, + 0xc722f0ef9d80aad6,0x424d3ad2b7b97ef5, + 0xf8ebad2b84e0d58b,0xd2e0898765a7deb2, + 0x9b934c3b330c8577,0x63cc55f49f88eb2f, + 0xc2781f49ffcfa6d5,0x3cbf6b71c76b25fb, + 0xf316271c7fc3908a,0x8bef464e3945ef7a, + 0x97edd871cfda3a56,0x97758bf0e3cbb5ac, + 0xbde94e8e43d0c8ec,0x3d52eeed1cbea317, + 0xed63a231d4c4fb27,0x4ca7aaa863ee4bdd, + 0x945e455f24fb1cf8,0x8fe8caa93e74ef6a, + 0xb975d6b6ee39e436,0xb3e2fd538e122b44, + 0xe7d34c64a9c85d44,0x60dbbca87196b616, + 0x90e40fbeea1d3a4a,0xbc8955e946fe31cd, + 0xb51d13aea4a488dd,0x6babab6398bdbe41, + 0xe264589a4dcdab14,0xc696963c7eed2dd1, + 0x8d7eb76070a08aec,0xfc1e1de5cf543ca2, + 0xb0de65388cc8ada8,0x3b25a55f43294bcb, + 0xdd15fe86affad912,0x49ef0eb713f39ebe, + 0x8a2dbf142dfcc7ab,0x6e3569326c784337, + 0xacb92ed9397bf996,0x49c2c37f07965404, + 0xd7e77a8f87daf7fb,0xdc33745ec97be906, + 0x86f0ac99b4e8dafd,0x69a028bb3ded71a3, + 0xa8acd7c0222311bc,0xc40832ea0d68ce0c, + 0xd2d80db02aabd62b,0xf50a3fa490c30190, + 0x83c7088e1aab65db,0x792667c6da79e0fa, + 0xa4b8cab1a1563f52,0x577001b891185938, + 0xcde6fd5e09abcf26,0xed4c0226b55e6f86, + 0x80b05e5ac60b6178,0x544f8158315b05b4, + 0xa0dc75f1778e39d6,0x696361ae3db1c721, + 0xc913936dd571c84c,0x3bc3a19cd1e38e9, + 0xfb5878494ace3a5f,0x4ab48a04065c723, + 0x9d174b2dcec0e47b,0x62eb0d64283f9c76, + 0xc45d1df942711d9a,0x3ba5d0bd324f8394, + 0xf5746577930d6500,0xca8f44ec7ee36479, + 0x9968bf6abbe85f20,0x7e998b13cf4e1ecb, + 0xbfc2ef456ae276e8,0x9e3fedd8c321a67e, + 0xefb3ab16c59b14a2,0xc5cfe94ef3ea101e, + 0x95d04aee3b80ece5,0xbba1f1d158724a12, + 0xbb445da9ca61281f,0x2a8a6e45ae8edc97, + 0xea1575143cf97226,0xf52d09d71a3293bd, + 0x924d692ca61be758,0x593c2626705f9c56, + 0xb6e0c377cfa2e12e,0x6f8b2fb00c77836c, + 0xe498f455c38b997a,0xb6dfb9c0f956447, + 0x8edf98b59a373fec,0x4724bd4189bd5eac, + 0xb2977ee300c50fe7,0x58edec91ec2cb657, + 0xdf3d5e9bc0f653e1,0x2f2967b66737e3ed, + 0x8b865b215899f46c,0xbd79e0d20082ee74, + 0xae67f1e9aec07187,0xecd8590680a3aa11, + 0xda01ee641a708de9,0xe80e6f4820cc9495, + 0x884134fe908658b2,0x3109058d147fdcdd, + 0xaa51823e34a7eede,0xbd4b46f0599fd415, + 0xd4e5e2cdc1d1ea96,0x6c9e18ac7007c91a, + 0x850fadc09923329e,0x3e2cf6bc604ddb0, + 0xa6539930bf6bff45,0x84db8346b786151c, + 0xcfe87f7cef46ff16,0xe612641865679a63, + 0x81f14fae158c5f6e,0x4fcb7e8f3f60c07e, + 0xa26da3999aef7749,0xe3be5e330f38f09d, + 0xcb090c8001ab551c,0x5cadf5bfd3072cc5, + 0xfdcb4fa002162a63,0x73d9732fc7c8f7f6, + 0x9e9f11c4014dda7e,0x2867e7fddcdd9afa, + 0xc646d63501a1511d,0xb281e1fd541501b8, + 0xf7d88bc24209a565,0x1f225a7ca91a4226, + 0x9ae757596946075f,0x3375788de9b06958, + 0xc1a12d2fc3978937,0x52d6b1641c83ae, + 0xf209787bb47d6b84,0xc0678c5dbd23a49a, + 0x9745eb4d50ce6332,0xf840b7ba963646e0, + 0xbd176620a501fbff,0xb650e5a93bc3d898, + 0xec5d3fa8ce427aff,0xa3e51f138ab4cebe, + 0x93ba47c980e98cdf,0xc66f336c36b10137, + 0xb8a8d9bbe123f017,0xb80b0047445d4184, + 0xe6d3102ad96cec1d,0xa60dc059157491e5, + 0x9043ea1ac7e41392,0x87c89837ad68db2f, + 0xb454e4a179dd1877,0x29babe4598c311fb, + 0xe16a1dc9d8545e94,0xf4296dd6fef3d67a, + 0x8ce2529e2734bb1d,0x1899e4a65f58660c, + 0xb01ae745b101e9e4,0x5ec05dcff72e7f8f, + 0xdc21a1171d42645d,0x76707543f4fa1f73, + 0x899504ae72497eba,0x6a06494a791c53a8, + 0xabfa45da0edbde69,0x487db9d17636892, + 0xd6f8d7509292d603,0x45a9d2845d3c42b6, + 0x865b86925b9bc5c2,0xb8a2392ba45a9b2, + 0xa7f26836f282b732,0x8e6cac7768d7141e, + 0xd1ef0244af2364ff,0x3207d795430cd926, + 0x8335616aed761f1f,0x7f44e6bd49e807b8, + 0xa402b9c5a8d3a6e7,0x5f16206c9c6209a6, + 0xcd036837130890a1,0x36dba887c37a8c0f, + 0x802221226be55a64,0xc2494954da2c9789, + 0xa02aa96b06deb0fd,0xf2db9baa10b7bd6c, + 0xc83553c5c8965d3d,0x6f92829494e5acc7, + 0xfa42a8b73abbf48c,0xcb772339ba1f17f9, + 0x9c69a97284b578d7,0xff2a760414536efb, + 0xc38413cf25e2d70d,0xfef5138519684aba, + 0xf46518c2ef5b8cd1,0x7eb258665fc25d69, + 0x98bf2f79d5993802,0xef2f773ffbd97a61, + 0xbeeefb584aff8603,0xaafb550ffacfd8fa, + 0xeeaaba2e5dbf6784,0x95ba2a53f983cf38, + 0x952ab45cfa97a0b2,0xdd945a747bf26183, + 0xba756174393d88df,0x94f971119aeef9e4, + 0xe912b9d1478ceb17,0x7a37cd5601aab85d, + 0x91abb422ccb812ee,0xac62e055c10ab33a, + 0xb616a12b7fe617aa,0x577b986b314d6009, + 0xe39c49765fdf9d94,0xed5a7e85fda0b80b, + 0x8e41ade9fbebc27d,0x14588f13be847307, + 0xb1d219647ae6b31c,0x596eb2d8ae258fc8, + 0xde469fbd99a05fe3,0x6fca5f8ed9aef3bb, + 0x8aec23d680043bee,0x25de7bb9480d5854, + 0xada72ccc20054ae9,0xaf561aa79a10ae6a, + 0xd910f7ff28069da4,0x1b2ba1518094da04, + 0x87aa9aff79042286,0x90fb44d2f05d0842, + 0xa99541bf57452b28,0x353a1607ac744a53, + 0xd3fa922f2d1675f2,0x42889b8997915ce8, + 0x847c9b5d7c2e09b7,0x69956135febada11, + 0xa59bc234db398c25,0x43fab9837e699095, + 0xcf02b2c21207ef2e,0x94f967e45e03f4bb, + 0x8161afb94b44f57d,0x1d1be0eebac278f5, + 0xa1ba1ba79e1632dc,0x6462d92a69731732, + 0xca28a291859bbf93,0x7d7b8f7503cfdcfe, + 0xfcb2cb35e702af78,0x5cda735244c3d43e, + 0x9defbf01b061adab,0x3a0888136afa64a7, + 0xc56baec21c7a1916,0x88aaa1845b8fdd0, + 0xf6c69a72a3989f5b,0x8aad549e57273d45, + 0x9a3c2087a63f6399,0x36ac54e2f678864b, + 0xc0cb28a98fcf3c7f,0x84576a1bb416a7dd, + 0xf0fdf2d3f3c30b9f,0x656d44a2a11c51d5, + 0x969eb7c47859e743,0x9f644ae5a4b1b325, + 0xbc4665b596706114,0x873d5d9f0dde1fee, + 0xeb57ff22fc0c7959,0xa90cb506d155a7ea, + 0x9316ff75dd87cbd8,0x9a7f12442d588f2, + 0xb7dcbf5354e9bece,0xc11ed6d538aeb2f, + 0xe5d3ef282a242e81,0x8f1668c8a86da5fa, + 0x8fa475791a569d10,0xf96e017d694487bc, + 0xb38d92d760ec4455,0x37c981dcc395a9ac, + 0xe070f78d3927556a,0x85bbe253f47b1417, + 0x8c469ab843b89562,0x93956d7478ccec8e, + 0xaf58416654a6babb,0x387ac8d1970027b2, + 0xdb2e51bfe9d0696a,0x6997b05fcc0319e, + 0x88fcf317f22241e2,0x441fece3bdf81f03, + 0xab3c2fddeeaad25a,0xd527e81cad7626c3, + 0xd60b3bd56a5586f1,0x8a71e223d8d3b074, + 0x85c7056562757456,0xf6872d5667844e49, + 0xa738c6bebb12d16c,0xb428f8ac016561db, + 0xd106f86e69d785c7,0xe13336d701beba52, + 0x82a45b450226b39c,0xecc0024661173473, + 0xa34d721642b06084,0x27f002d7f95d0190, + 0xcc20ce9bd35c78a5,0x31ec038df7b441f4, + 0xff290242c83396ce,0x7e67047175a15271, + 0x9f79a169bd203e41,0xf0062c6e984d386, + 0xc75809c42c684dd1,0x52c07b78a3e60868, + 0xf92e0c3537826145,0xa7709a56ccdf8a82, + 0x9bbcc7a142b17ccb,0x88a66076400bb691, + 0xc2abf989935ddbfe,0x6acff893d00ea435, + 0xf356f7ebf83552fe,0x583f6b8c4124d43, + 0x98165af37b2153de,0xc3727a337a8b704a, + 0xbe1bf1b059e9a8d6,0x744f18c0592e4c5c, + 0xeda2ee1c7064130c,0x1162def06f79df73, + 0x9485d4d1c63e8be7,0x8addcb5645ac2ba8, + 0xb9a74a0637ce2ee1,0x6d953e2bd7173692, + 0xe8111c87c5c1ba99,0xc8fa8db6ccdd0437, + 0x910ab1d4db9914a0,0x1d9c9892400a22a2, + 0xb54d5e4a127f59c8,0x2503beb6d00cab4b, + 0xe2a0b5dc971f303a,0x2e44ae64840fd61d, + 0x8da471a9de737e24,0x5ceaecfed289e5d2, + 0xb10d8e1456105dad,0x7425a83e872c5f47, + 0xdd50f1996b947518,0xd12f124e28f77719, + 0x8a5296ffe33cc92f,0x82bd6b70d99aaa6f, + 0xace73cbfdc0bfb7b,0x636cc64d1001550b, + 0xd8210befd30efa5a,0x3c47f7e05401aa4e, + 0x8714a775e3e95c78,0x65acfaec34810a71, + 0xa8d9d1535ce3b396,0x7f1839a741a14d0d, + 0xd31045a8341ca07c,0x1ede48111209a050, + 0x83ea2b892091e44d,0x934aed0aab460432, + 0xa4e4b66b68b65d60,0xf81da84d5617853f, + 0xce1de40642e3f4b9,0x36251260ab9d668e, + 0x80d2ae83e9ce78f3,0xc1d72b7c6b426019, + 0xa1075a24e4421730,0xb24cf65b8612f81f, + 0xc94930ae1d529cfc,0xdee033f26797b627, + 0xfb9b7cd9a4a7443c,0x169840ef017da3b1, + 0x9d412e0806e88aa5,0x8e1f289560ee864e, + 0xc491798a08a2ad4e,0xf1a6f2bab92a27e2, + 0xf5b5d7ec8acb58a2,0xae10af696774b1db, + 0x9991a6f3d6bf1765,0xacca6da1e0a8ef29, + 0xbff610b0cc6edd3f,0x17fd090a58d32af3, + 0xeff394dcff8a948e,0xddfc4b4cef07f5b0, + 0x95f83d0a1fb69cd9,0x4abdaf101564f98e, + 0xbb764c4ca7a4440f,0x9d6d1ad41abe37f1, + 0xea53df5fd18d5513,0x84c86189216dc5ed, + 0x92746b9be2f8552c,0x32fd3cf5b4e49bb4, + 0xb7118682dbb66a77,0x3fbc8c33221dc2a1, + 0xe4d5e82392a40515,0xfabaf3feaa5334a, + 0x8f05b1163ba6832d,0x29cb4d87f2a7400e, + 0xb2c71d5bca9023f8,0x743e20e9ef511012, + 0xdf78e4b2bd342cf6,0x914da9246b255416, + 0x8bab8eefb6409c1a,0x1ad089b6c2f7548e, + 0xae9672aba3d0c320,0xa184ac2473b529b1, + 0xda3c0f568cc4f3e8,0xc9e5d72d90a2741e, + 0x8865899617fb1871,0x7e2fa67c7a658892, + 0xaa7eebfb9df9de8d,0xddbb901b98feeab7, + 0xd51ea6fa85785631,0x552a74227f3ea565, + 0x8533285c936b35de,0xd53a88958f87275f, + 0xa67ff273b8460356,0x8a892abaf368f137, + 0xd01fef10a657842c,0x2d2b7569b0432d85, + 0x8213f56a67f6b29b,0x9c3b29620e29fc73, + 0xa298f2c501f45f42,0x8349f3ba91b47b8f, + 0xcb3f2f7642717713,0x241c70a936219a73, + 0xfe0efb53d30dd4d7,0xed238cd383aa0110, + 0x9ec95d1463e8a506,0xf4363804324a40aa, + 0xc67bb4597ce2ce48,0xb143c6053edcd0d5, + 0xf81aa16fdc1b81da,0xdd94b7868e94050a, + 0x9b10a4e5e9913128,0xca7cf2b4191c8326, + 0xc1d4ce1f63f57d72,0xfd1c2f611f63a3f0, + 0xf24a01a73cf2dccf,0xbc633b39673c8cec, + 0x976e41088617ca01,0xd5be0503e085d813, + 0xbd49d14aa79dbc82,0x4b2d8644d8a74e18, + 0xec9c459d51852ba2,0xddf8e7d60ed1219e, + 0x93e1ab8252f33b45,0xcabb90e5c942b503, + 0xb8da1662e7b00a17,0x3d6a751f3b936243, + 0xe7109bfba19c0c9d,0xcc512670a783ad4, + 0x906a617d450187e2,0x27fb2b80668b24c5, + 0xb484f9dc9641e9da,0xb1f9f660802dedf6, + 0xe1a63853bbd26451,0x5e7873f8a0396973, + 0x8d07e33455637eb2,0xdb0b487b6423e1e8, + 0xb049dc016abc5e5f,0x91ce1a9a3d2cda62, + 0xdc5c5301c56b75f7,0x7641a140cc7810fb, + 0x89b9b3e11b6329ba,0xa9e904c87fcb0a9d, + 0xac2820d9623bf429,0x546345fa9fbdcd44, + 0xd732290fbacaf133,0xa97c177947ad4095, + 0x867f59a9d4bed6c0,0x49ed8eabcccc485d, + 0xa81f301449ee8c70,0x5c68f256bfff5a74, + 0xd226fc195c6a2f8c,0x73832eec6fff3111, + 0x83585d8fd9c25db7,0xc831fd53c5ff7eab, + 0xa42e74f3d032f525,0xba3e7ca8b77f5e55, + 0xcd3a1230c43fb26f,0x28ce1bd2e55f35eb, + 0x80444b5e7aa7cf85,0x7980d163cf5b81b3, + 0xa0555e361951c366,0xd7e105bcc332621f, + 0xc86ab5c39fa63440,0x8dd9472bf3fefaa7, + 0xfa856334878fc150,0xb14f98f6f0feb951, + 0x9c935e00d4b9d8d2,0x6ed1bf9a569f33d3, + 0xc3b8358109e84f07,0xa862f80ec4700c8, + 0xf4a642e14c6262c8,0xcd27bb612758c0fa, + 0x98e7e9cccfbd7dbd,0x8038d51cb897789c, + 0xbf21e44003acdd2c,0xe0470a63e6bd56c3, + 0xeeea5d5004981478,0x1858ccfce06cac74, + 0x95527a5202df0ccb,0xf37801e0c43ebc8, + 0xbaa718e68396cffd,0xd30560258f54e6ba, + 0xe950df20247c83fd,0x47c6b82ef32a2069, + 0x91d28b7416cdd27e,0x4cdc331d57fa5441, + 0xb6472e511c81471d,0xe0133fe4adf8e952, + 0xe3d8f9e563a198e5,0x58180fddd97723a6, + 0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,}; +}; + +template +constexpr uint64_t powers_template::power_of_five_128[number_of_entries]; + +using powers = powers_template<>; + +} // namespace fast_float + +#endif diff --git a/Include/Libraries/fast_float/float_common.h b/Include/Libraries/fast_float/float_common.h new file mode 100644 index 0000000..b5a357b --- /dev/null +++ b/Include/Libraries/fast_float/float_common.h @@ -0,0 +1,756 @@ +#ifndef FASTFLOAT_FLOAT_COMMON_H +#define FASTFLOAT_FLOAT_COMMON_H + +#include +#include +#include +#include +#include +#include + +#include "constexpr_feature_detect.h" + +namespace fast_float { + +#define FASTFLOAT_JSONFMT (1 << 5) +#define FASTFLOAT_FORTRANFMT (1 << 6) + +enum chars_format { + scientific = 1 << 0, + fixed = 1 << 2, + hex = 1 << 3, + no_infnan = 1 << 4, + // RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259#section-6 + json = FASTFLOAT_JSONFMT | fixed | scientific | no_infnan, + // Extension of RFC 8259 where, e.g., "inf" and "nan" are allowed. + json_or_infnan = FASTFLOAT_JSONFMT | fixed | scientific, + fortran = FASTFLOAT_FORTRANFMT | fixed | scientific, + general = fixed | scientific +}; + +template +struct from_chars_result_t { + UC const* ptr; + std::errc ec; +}; +using from_chars_result = from_chars_result_t; + +template +struct parse_options_t { + constexpr explicit parse_options_t(chars_format fmt = chars_format::general, + UC dot = UC('.')) + : format(fmt), decimal_point(dot) {} + + /** Which number formats are accepted */ + chars_format format; + /** The character used as decimal point */ + UC decimal_point; +}; +using parse_options = parse_options_t; + +} + +#if FASTFLOAT_HAS_BIT_CAST +#include +#endif + +#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \ + || defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \ + || defined(__MINGW64__) \ + || defined(__s390x__) \ + || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) \ + || defined(__loongarch64) ) +#define FASTFLOAT_64BIT 1 +#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) \ + || defined(__arm__) || defined(_M_ARM) || defined(__ppc__) \ + || defined(__MINGW32__) || defined(__EMSCRIPTEN__)) +#define FASTFLOAT_32BIT 1 +#else + // Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow. + // We can never tell the register width, but the SIZE_MAX is a good approximation. + // UINTPTR_MAX and INTPTR_MAX are optional, so avoid them for max portability. + #if SIZE_MAX == 0xffff + #error Unknown platform (16-bit, unsupported) + #elif SIZE_MAX == 0xffffffff + #define FASTFLOAT_32BIT 1 + #elif SIZE_MAX == 0xffffffffffffffff + #define FASTFLOAT_64BIT 1 + #else + #error Unknown platform (not 32-bit, not 64-bit?) + #endif +#endif + +#if ((defined(_WIN32) || defined(_WIN64)) && !defined(__clang__)) +#include +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +#define FASTFLOAT_VISUAL_STUDIO 1 +#endif + +#if defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__ +#define FASTFLOAT_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#elif defined _WIN32 +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#else +#if defined(__APPLE__) || defined(__FreeBSD__) +#include +#elif defined(sun) || defined(__sun) +#include +#elif defined(__MVS__) +#include +#else +#ifdef __has_include +#if __has_include() +#include +#endif //__has_include() +#endif //__has_include +#endif +# +#ifndef __BYTE_ORDER__ +// safe choice +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#endif +# +#ifndef __ORDER_LITTLE_ENDIAN__ +// safe choice +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#endif +# +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#else +#define FASTFLOAT_IS_BIG_ENDIAN 1 +#endif +#endif + +#if defined(__SSE2__) || \ + (defined(FASTFLOAT_VISUAL_STUDIO) && \ + (defined(_M_AMD64) || defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP == 2))) +#define FASTFLOAT_SSE2 1 +#endif + +#if defined(__aarch64__) || defined(_M_ARM64) +#define FASTFLOAT_NEON 1 +#endif + +#if defined(FASTFLOAT_SSE2) || defined(FASTFLOAT_NEON) +#define FASTFLOAT_HAS_SIMD 1 +#endif + +#if defined(__GNUC__) +// disable -Wcast-align=strict (GCC only) +#define FASTFLOAT_SIMD_DISABLE_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wcast-align\"") +#else +#define FASTFLOAT_SIMD_DISABLE_WARNINGS +#endif + +#if defined(__GNUC__) +#define FASTFLOAT_SIMD_RESTORE_WARNINGS \ + _Pragma("GCC diagnostic pop") +#else +#define FASTFLOAT_SIMD_RESTORE_WARNINGS +#endif + + + +#ifdef FASTFLOAT_VISUAL_STUDIO +#define fastfloat_really_inline __forceinline +#else +#define fastfloat_really_inline inline __attribute__((always_inline)) +#endif + +#ifndef FASTFLOAT_ASSERT +#define FASTFLOAT_ASSERT(x) { ((void)(x)); } +#endif + +#ifndef FASTFLOAT_DEBUG_ASSERT +#define FASTFLOAT_DEBUG_ASSERT(x) { ((void)(x)); } +#endif + +// rust style `try!()` macro, or `?` operator +#define FASTFLOAT_TRY(x) { if (!(x)) return false; } + +#define FASTFLOAT_ENABLE_IF(...) typename std::enable_if<(__VA_ARGS__), int>::type + + +namespace fast_float { + +fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() { +#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED + return std::is_constant_evaluated(); +#else + return false; +#endif +} + +template +fastfloat_really_inline constexpr bool is_supported_float_type() { + return std::is_same::value || std::is_same::value; +} + +template +fastfloat_really_inline constexpr bool is_supported_char_type() { + return + std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value; +} + +// Compares two ASCII strings in a case insensitive manner. +template +inline FASTFLOAT_CONSTEXPR14 bool +fastfloat_strncasecmp(UC const * input1, UC const * input2, size_t length) { + char running_diff{0}; + for (size_t i = 0; i < length; ++i) { + running_diff |= (char(input1[i]) ^ char(input2[i])); + } + return (running_diff == 0) || (running_diff == 32); +} + +#ifndef FLT_EVAL_METHOD +#error "FLT_EVAL_METHOD should be defined, please include cfloat." +#endif + +// a pointer and a length to a contiguous block of memory +template +struct span { + const T* ptr; + size_t length; + constexpr span(const T* _ptr, size_t _length) : ptr(_ptr), length(_length) {} + constexpr span() : ptr(nullptr), length(0) {} + + constexpr size_t len() const noexcept { + return length; + } + + FASTFLOAT_CONSTEXPR14 const T& operator[](size_t index) const noexcept { + FASTFLOAT_DEBUG_ASSERT(index < length); + return ptr[index]; + } +}; + +struct value128 { + uint64_t low; + uint64_t high; + constexpr value128(uint64_t _low, uint64_t _high) : low(_low), high(_high) {} + constexpr value128() : low(0), high(0) {} +}; + +/* Helper C++14 constexpr generic implementation of leading_zeroes */ +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +int leading_zeroes_generic(uint64_t input_num, int last_bit = 0) { + if(input_num & uint64_t(0xffffffff00000000)) { input_num >>= 32; last_bit |= 32; } + if(input_num & uint64_t( 0xffff0000)) { input_num >>= 16; last_bit |= 16; } + if(input_num & uint64_t( 0xff00)) { input_num >>= 8; last_bit |= 8; } + if(input_num & uint64_t( 0xf0)) { input_num >>= 4; last_bit |= 4; } + if(input_num & uint64_t( 0xc)) { input_num >>= 2; last_bit |= 2; } + if(input_num & uint64_t( 0x2)) { /* input_num >>= 1; */ last_bit |= 1; } + return 63 - last_bit; +} + +/* result might be undefined when input_num is zero */ +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +int leading_zeroes(uint64_t input_num) { + assert(input_num > 0); + if (cpp20_and_in_constexpr()) { + return leading_zeroes_generic(input_num); + } +#ifdef FASTFLOAT_VISUAL_STUDIO + #if defined(_M_X64) || defined(_M_ARM64) + unsigned long leading_zero = 0; + // Search the mask data from most significant bit (MSB) + // to least significant bit (LSB) for a set bit (1). + _BitScanReverse64(&leading_zero, input_num); + return (int)(63 - leading_zero); + #else + return leading_zeroes_generic(input_num); + #endif +#else + return __builtin_clzll(input_num); +#endif +} + +// slow emulation routine for 32-bit +fastfloat_really_inline constexpr uint64_t emulu(uint32_t x, uint32_t y) { + return x * (uint64_t)y; +} + +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +uint64_t umul128_generic(uint64_t ab, uint64_t cd, uint64_t *hi) { + uint64_t ad = emulu((uint32_t)(ab >> 32), (uint32_t)cd); + uint64_t bd = emulu((uint32_t)ab, (uint32_t)cd); + uint64_t adbc = ad + emulu((uint32_t)ab, (uint32_t)(cd >> 32)); + uint64_t adbc_carry = !!(adbc < ad); + uint64_t lo = bd + (adbc << 32); + *hi = emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) + + (adbc_carry << 32) + !!(lo < bd); + return lo; +} + +#ifdef FASTFLOAT_32BIT + +// slow emulation routine for 32-bit +#if !defined(__MINGW64__) +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 +uint64_t _umul128(uint64_t ab, uint64_t cd, uint64_t *hi) { + return umul128_generic(ab, cd, hi); +} +#endif // !__MINGW64__ + +#endif // FASTFLOAT_32BIT + + +// compute 64-bit a*b +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +value128 full_multiplication(uint64_t a, uint64_t b) { + if (cpp20_and_in_constexpr()) { + value128 answer; + answer.low = umul128_generic(a, b, &answer.high); + return answer; + } + value128 answer; +#if defined(_M_ARM64) && !defined(__MINGW32__) + // ARM64 has native support for 64-bit multiplications, no need to emulate + // But MinGW on ARM64 doesn't have native support for 64-bit multiplications + answer.high = __umulh(a, b); + answer.low = a * b; +#elif defined(FASTFLOAT_32BIT) || (defined(_WIN64) && !defined(__clang__)) + answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64 +#elif defined(FASTFLOAT_64BIT) + __uint128_t r = ((__uint128_t)a) * b; + answer.low = uint64_t(r); + answer.high = uint64_t(r >> 64); +#else + answer.low = umul128_generic(a, b, &answer.high); +#endif + return answer; +} + +struct adjusted_mantissa { + uint64_t mantissa{0}; + int32_t power2{0}; // a negative value indicates an invalid result + adjusted_mantissa() = default; + constexpr bool operator==(const adjusted_mantissa &o) const { + return mantissa == o.mantissa && power2 == o.power2; + } + constexpr bool operator!=(const adjusted_mantissa &o) const { + return mantissa != o.mantissa || power2 != o.power2; + } +}; + +// Bias so we can get the real exponent with an invalid adjusted_mantissa. +constexpr static int32_t invalid_am_bias = -0x8000; + +// used for binary_format_lookup_tables::max_mantissa +constexpr uint64_t constant_55555 = 5 * 5 * 5 * 5 * 5; + +template +struct binary_format_lookup_tables; + +template struct binary_format : binary_format_lookup_tables { + using equiv_uint = typename std::conditional::type; + + static inline constexpr int mantissa_explicit_bits(); + static inline constexpr int minimum_exponent(); + static inline constexpr int infinite_power(); + static inline constexpr int sign_index(); + static inline constexpr int min_exponent_fast_path(); // used when fegetround() == FE_TONEAREST + static inline constexpr int max_exponent_fast_path(); + static inline constexpr int max_exponent_round_to_even(); + static inline constexpr int min_exponent_round_to_even(); + static inline constexpr uint64_t max_mantissa_fast_path(int64_t power); + static inline constexpr uint64_t max_mantissa_fast_path(); // used when fegetround() == FE_TONEAREST + static inline constexpr int largest_power_of_ten(); + static inline constexpr int smallest_power_of_ten(); + static inline constexpr T exact_power_of_ten(int64_t power); + static inline constexpr size_t max_digits(); + static inline constexpr equiv_uint exponent_mask(); + static inline constexpr equiv_uint mantissa_mask(); + static inline constexpr equiv_uint hidden_bit_mask(); +}; + +template +struct binary_format_lookup_tables { + static constexpr double powers_of_ten[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, + 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; + + // Largest integer value v so that (5**index * v) <= 1<<53. + // 0x10000000000000 == 1 << 53 + static constexpr uint64_t max_mantissa[] = { + 0x10000000000000, + 0x10000000000000 / 5, + 0x10000000000000 / (5 * 5), + 0x10000000000000 / (5 * 5 * 5), + 0x10000000000000 / (5 * 5 * 5 * 5), + 0x10000000000000 / (constant_55555), + 0x10000000000000 / (constant_55555 * 5), + 0x10000000000000 / (constant_55555 * 5 * 5), + 0x10000000000000 / (constant_55555 * 5 * 5 * 5), + 0x10000000000000 / (constant_55555 * 5 * 5 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555), + 0x10000000000000 / (constant_55555 * constant_55555 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * 5 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * constant_55555), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * constant_55555 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * constant_55555 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5), + 0x10000000000000 / (constant_55555 * constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5 * 5)}; +}; + +template +constexpr double binary_format_lookup_tables::powers_of_ten[]; + +template +constexpr uint64_t binary_format_lookup_tables::max_mantissa[]; + +template +struct binary_format_lookup_tables { + static constexpr float powers_of_ten[] = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f, + 1e6f, 1e7f, 1e8f, 1e9f, 1e10f}; + + // Largest integer value v so that (5**index * v) <= 1<<24. + // 0x1000000 == 1<<24 + static constexpr uint64_t max_mantissa[] = { + 0x1000000, + 0x1000000 / 5, + 0x1000000 / (5 * 5), + 0x1000000 / (5 * 5 * 5), + 0x1000000 / (5 * 5 * 5 * 5), + 0x1000000 / (constant_55555), + 0x1000000 / (constant_55555 * 5), + 0x1000000 / (constant_55555 * 5 * 5), + 0x1000000 / (constant_55555 * 5 * 5 * 5), + 0x1000000 / (constant_55555 * 5 * 5 * 5 * 5), + 0x1000000 / (constant_55555 * constant_55555), + 0x1000000 / (constant_55555 * constant_55555 * 5)}; +}; + +template +constexpr float binary_format_lookup_tables::powers_of_ten[]; + +template +constexpr uint64_t binary_format_lookup_tables::max_mantissa[]; + +template <> inline constexpr int binary_format::min_exponent_fast_path() { +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) + return 0; +#else + return -22; +#endif +} + +template <> inline constexpr int binary_format::min_exponent_fast_path() { +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) + return 0; +#else + return -10; +#endif +} + +template <> inline constexpr int binary_format::mantissa_explicit_bits() { + return 52; +} +template <> inline constexpr int binary_format::mantissa_explicit_bits() { + return 23; +} + +template <> inline constexpr int binary_format::max_exponent_round_to_even() { + return 23; +} + +template <> inline constexpr int binary_format::max_exponent_round_to_even() { + return 10; +} + +template <> inline constexpr int binary_format::min_exponent_round_to_even() { + return -4; +} + +template <> inline constexpr int binary_format::min_exponent_round_to_even() { + return -17; +} + +template <> inline constexpr int binary_format::minimum_exponent() { + return -1023; +} +template <> inline constexpr int binary_format::minimum_exponent() { + return -127; +} + +template <> inline constexpr int binary_format::infinite_power() { + return 0x7FF; +} +template <> inline constexpr int binary_format::infinite_power() { + return 0xFF; +} + +template <> inline constexpr int binary_format::sign_index() { return 63; } +template <> inline constexpr int binary_format::sign_index() { return 31; } + +template <> inline constexpr int binary_format::max_exponent_fast_path() { + return 22; +} +template <> inline constexpr int binary_format::max_exponent_fast_path() { + return 10; +} + +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path() { + return uint64_t(2) << mantissa_explicit_bits(); +} +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path(int64_t power) { + // caller is responsible to ensure that + // power >= 0 && power <= 22 + // + // Work around clang bug https://godbolt.org/z/zedh7rrhc + return (void)max_mantissa[0], max_mantissa[power]; +} +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path() { + return uint64_t(2) << mantissa_explicit_bits(); +} +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path(int64_t power) { + // caller is responsible to ensure that + // power >= 0 && power <= 10 + // + // Work around clang bug https://godbolt.org/z/zedh7rrhc + return (void)max_mantissa[0], max_mantissa[power]; +} + +template <> +inline constexpr double binary_format::exact_power_of_ten(int64_t power) { + // Work around clang bug https://godbolt.org/z/zedh7rrhc + return (void)powers_of_ten[0], powers_of_ten[power]; +} +template <> +inline constexpr float binary_format::exact_power_of_ten(int64_t power) { + // Work around clang bug https://godbolt.org/z/zedh7rrhc + return (void)powers_of_ten[0], powers_of_ten[power]; +} + + +template <> +inline constexpr int binary_format::largest_power_of_ten() { + return 308; +} +template <> +inline constexpr int binary_format::largest_power_of_ten() { + return 38; +} + +template <> +inline constexpr int binary_format::smallest_power_of_ten() { + return -342; +} +template <> +inline constexpr int binary_format::smallest_power_of_ten() { + return -65; +} + +template <> inline constexpr size_t binary_format::max_digits() { + return 769; +} +template <> inline constexpr size_t binary_format::max_digits() { + return 114; +} + +template <> inline constexpr binary_format::equiv_uint + binary_format::exponent_mask() { + return 0x7F800000; +} +template <> inline constexpr binary_format::equiv_uint + binary_format::exponent_mask() { + return 0x7FF0000000000000; +} + +template <> inline constexpr binary_format::equiv_uint + binary_format::mantissa_mask() { + return 0x007FFFFF; +} +template <> inline constexpr binary_format::equiv_uint + binary_format::mantissa_mask() { + return 0x000FFFFFFFFFFFFF; +} + +template <> inline constexpr binary_format::equiv_uint + binary_format::hidden_bit_mask() { + return 0x00800000; +} +template <> inline constexpr binary_format::equiv_uint + binary_format::hidden_bit_mask() { + return 0x0010000000000000; +} + +template +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 +void to_float(bool negative, adjusted_mantissa am, T &value) { + using fastfloat_uint = typename binary_format::equiv_uint; + fastfloat_uint word = (fastfloat_uint)am.mantissa; + word |= fastfloat_uint(am.power2) << binary_format::mantissa_explicit_bits(); + word |= fastfloat_uint(negative) << binary_format::sign_index(); +#if FASTFLOAT_HAS_BIT_CAST + value = std::bit_cast(word); +#else + ::memcpy(&value, &word, sizeof(T)); +#endif +} + +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default +template +struct space_lut { + static constexpr bool value[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +}; + +template +constexpr bool space_lut::value[]; + +inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; } +#endif + +template +static constexpr uint64_t int_cmp_zeros() +{ + static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4), "Unsupported character size"); + return (sizeof(UC) == 1) ? 0x3030303030303030 : (sizeof(UC) == 2) ? (uint64_t(UC('0')) << 48 | uint64_t(UC('0')) << 32 | uint64_t(UC('0')) << 16 | UC('0')) : (uint64_t(UC('0')) << 32 | UC('0')); +} +template +static constexpr int int_cmp_len() +{ + return sizeof(uint64_t) / sizeof(UC); +} +template +static constexpr UC const * str_const_nan() +{ + return nullptr; +} +template<> +constexpr char const * str_const_nan() +{ + return "nan"; +} +template<> +constexpr wchar_t const * str_const_nan() +{ + return L"nan"; +} +template<> +constexpr char16_t const * str_const_nan() +{ + return u"nan"; +} +template<> +constexpr char32_t const * str_const_nan() +{ + return U"nan"; +} +template +static constexpr UC const * str_const_inf() +{ + return nullptr; +} +template<> +constexpr char const * str_const_inf() +{ + return "infinity"; +} +template<> +constexpr wchar_t const * str_const_inf() +{ + return L"infinity"; +} +template<> +constexpr char16_t const * str_const_inf() +{ + return u"infinity"; +} +template<> +constexpr char32_t const * str_const_inf() +{ + return U"infinity"; +} + + +template +struct int_luts { + static constexpr uint8_t chdigit[] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 + }; + + static constexpr size_t maxdigits_u64[] = { + 64, 41, 32, 28, 25, 23, 22, 21, + 20, 19, 18, 18, 17, 17, 16, 16, + 16, 16, 15, 15, 15, 15, 14, 14, + 14, 14, 14, 14, 14, 13, 13, 13, + 13, 13, 13 + }; + + static constexpr uint64_t min_safe_u64[] = { + 9223372036854775808ull, 12157665459056928801ull, 4611686018427387904, 7450580596923828125, 4738381338321616896, + 3909821048582988049, 9223372036854775808ull, 12157665459056928801ull, 10000000000000000000ull, 5559917313492231481, + 2218611106740436992, 8650415919381337933, 2177953337809371136, 6568408355712890625, 1152921504606846976, + 2862423051509815793, 6746640616477458432, 15181127029874798299ull, 1638400000000000000, 3243919932521508681, + 6221821273427820544, 11592836324538749809ull, 876488338465357824, 1490116119384765625, 2481152873203736576, + 4052555153018976267, 6502111422497947648, 10260628712958602189ull, 15943230000000000000ull, 787662783788549761, + 1152921504606846976, 1667889514952984961, 2386420683693101056, 3379220508056640625, 4738381338321616896 + }; +}; + +template +constexpr uint8_t int_luts::chdigit[]; + +template +constexpr size_t int_luts::maxdigits_u64[]; + +template +constexpr uint64_t int_luts::min_safe_u64[]; + +template +fastfloat_really_inline +constexpr uint8_t ch_to_digit(UC c) { return int_luts<>::chdigit[static_cast(c)]; } + +fastfloat_really_inline +constexpr size_t max_digits_u64(int base) { return int_luts<>::maxdigits_u64[base - 2]; } + +// If a u64 is exactly max_digits_u64() in length, this is +// the value below which it has definitely overflowed. +fastfloat_really_inline +constexpr uint64_t min_safe_u64(int base) { return int_luts<>::min_safe_u64[base - 2]; } + +} // namespace fast_float + +#endif diff --git a/Include/Libraries/fast_float/parse_number.h b/Include/Libraries/fast_float/parse_number.h new file mode 100644 index 0000000..1fd587b --- /dev/null +++ b/Include/Libraries/fast_float/parse_number.h @@ -0,0 +1,255 @@ +#ifndef FASTFLOAT_PARSE_NUMBER_H +#define FASTFLOAT_PARSE_NUMBER_H + +#include "ascii_number.h" +#include "decimal_to_binary.h" +#include "digit_comparison.h" +#include "float_common.h" + +#include +#include +#include +#include + +namespace fast_float { + + +namespace detail { +/** + * Special case +inf, -inf, nan, infinity, -infinity. + * The case comparisons could be made much faster given that we know that the + * strings a null-free and fixed. + **/ +template +from_chars_result_t FASTFLOAT_CONSTEXPR14 +parse_infnan(UC const * first, UC const * last, T &value) noexcept { + from_chars_result_t answer{}; + answer.ptr = first; + answer.ec = std::errc(); // be optimistic + bool minusSign = false; + if (*first == UC('-')) { // assume first < last, so dereference without checks; C++17 20.19.3.(7.1) explicitly forbids '+' here + minusSign = true; + ++first; + } +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default + if (*first == UC('+')) { + ++first; + } +#endif + if (last - first >= 3) { + if (fastfloat_strncasecmp(first, str_const_nan(), 3)) { + answer.ptr = (first += 3); + value = minusSign ? -std::numeric_limits::quiet_NaN() : std::numeric_limits::quiet_NaN(); + // Check for possible nan(n-char-seq-opt), C++17 20.19.3.7, C11 7.20.1.3.3. At least MSVC produces nan(ind) and nan(snan). + if(first != last && *first == UC('(')) { + for(UC const * ptr = first + 1; ptr != last; ++ptr) { + if (*ptr == UC(')')) { + answer.ptr = ptr + 1; // valid nan(n-char-seq-opt) + break; + } + else if(!((UC('a') <= *ptr && *ptr <= UC('z')) || (UC('A') <= *ptr && *ptr <= UC('Z')) || (UC('0') <= *ptr && *ptr <= UC('9')) || *ptr == UC('_'))) + break; // forbidden char, not nan(n-char-seq-opt) + } + } + return answer; + } + if (fastfloat_strncasecmp(first, str_const_inf(), 3)) { + if ((last - first >= 8) && fastfloat_strncasecmp(first + 3, str_const_inf() + 3, 5)) { + answer.ptr = first + 8; + } else { + answer.ptr = first + 3; + } + value = minusSign ? -std::numeric_limits::infinity() : std::numeric_limits::infinity(); + return answer; + } + } + answer.ec = std::errc::invalid_argument; + return answer; +} + +/** + * Returns true if the floating-pointing rounding mode is to 'nearest'. + * It is the default on most system. This function is meant to be inexpensive. + * Credit : @mwalcott3 + */ +fastfloat_really_inline bool rounds_to_nearest() noexcept { + // https://lemire.me/blog/2020/06/26/gcc-not-nearest/ +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) + return false; +#endif + // See + // A fast function to check your floating-point rounding mode + // https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/ + // + // This function is meant to be equivalent to : + // prior: #include + // return fegetround() == FE_TONEAREST; + // However, it is expected to be much faster than the fegetround() + // function call. + // + // The volatile keywoard prevents the compiler from computing the function + // at compile-time. + // There might be other ways to prevent compile-time optimizations (e.g., asm). + // The value does not need to be std::numeric_limits::min(), any small + // value so that 1 + x should round to 1 would do (after accounting for excess + // precision, as in 387 instructions). + static volatile float fmin = std::numeric_limits::min(); + float fmini = fmin; // we copy it so that it gets loaded at most once. + // + // Explanation: + // Only when fegetround() == FE_TONEAREST do we have that + // fmin + 1.0f == 1.0f - fmin. + // + // FE_UPWARD: + // fmin + 1.0f > 1 + // 1.0f - fmin == 1 + // + // FE_DOWNWARD or FE_TOWARDZERO: + // fmin + 1.0f == 1 + // 1.0f - fmin < 1 + // + // Note: This may fail to be accurate if fast-math has been + // enabled, as rounding conventions may not apply. + #ifdef FASTFLOAT_VISUAL_STUDIO + # pragma warning(push) + // todo: is there a VS warning? + // see https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013 + #elif defined(__clang__) + # pragma clang diagnostic push + # pragma clang diagnostic ignored "-Wfloat-equal" + #elif defined(__GNUC__) + # pragma GCC diagnostic push + # pragma GCC diagnostic ignored "-Wfloat-equal" + #endif + return (fmini + 1.0f == 1.0f - fmini); + #ifdef FASTFLOAT_VISUAL_STUDIO + # pragma warning(pop) + #elif defined(__clang__) + # pragma clang diagnostic pop + #elif defined(__GNUC__) + # pragma GCC diagnostic pop + #endif +} + +} // namespace detail + +template +FASTFLOAT_CONSTEXPR20 +from_chars_result_t from_chars(UC const * first, UC const * last, + T &value, chars_format fmt /*= chars_format::general*/) noexcept { + return from_chars_advanced(first, last, value, parse_options_t{fmt}); +} + +template +FASTFLOAT_CONSTEXPR20 +from_chars_result_t from_chars_advanced(UC const * first, UC const * last, + T &value, parse_options_t options) noexcept { + + static_assert (is_supported_float_type(), "only float and double are supported"); + static_assert (is_supported_char_type(), "only char, wchar_t, char16_t and char32_t are supported"); + + from_chars_result_t answer; +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default + while ((first != last) && fast_float::is_space(uint8_t(*first))) { + first++; + } +#endif + if (first == last) { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; + } + parsed_number_string_t pns = parse_number_string(first, last, options); + if (!pns.valid) { + if (options.format & chars_format::no_infnan) { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; + } else { + return detail::parse_infnan(first, last, value); + } + } + + answer.ec = std::errc(); // be optimistic + answer.ptr = pns.lastmatch; + // The implementation of the Clinger's fast path is convoluted because + // we want round-to-nearest in all cases, irrespective of the rounding mode + // selected on the thread. + // We proceed optimistically, assuming that detail::rounds_to_nearest() returns + // true. + if (binary_format::min_exponent_fast_path() <= pns.exponent && pns.exponent <= binary_format::max_exponent_fast_path() && !pns.too_many_digits) { + // Unfortunately, the conventional Clinger's fast path is only possible + // when the system rounds to the nearest float. + // + // We expect the next branch to almost always be selected. + // We could check it first (before the previous branch), but + // there might be performance advantages at having the check + // be last. + if(!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) { + // We have that fegetround() == FE_TONEAREST. + // Next is Clinger's fast path. + if (pns.mantissa <=binary_format::max_mantissa_fast_path()) { + value = T(pns.mantissa); + if (pns.exponent < 0) { value = value / binary_format::exact_power_of_ten(-pns.exponent); } + else { value = value * binary_format::exact_power_of_ten(pns.exponent); } + if (pns.negative) { value = -value; } + return answer; + } + } else { + // We do not have that fegetround() == FE_TONEAREST. + // Next is a modified Clinger's fast path, inspired by Jakub Jelínek's proposal + if (pns.exponent >= 0 && pns.mantissa <=binary_format::max_mantissa_fast_path(pns.exponent)) { +#if defined(__clang__) || defined(FASTFLOAT_32BIT) + // Clang may map 0 to -0.0 when fegetround() == FE_DOWNWARD + if(pns.mantissa == 0) { + value = pns.negative ? T(-0.) : T(0.); + return answer; + } +#endif + value = T(pns.mantissa) * binary_format::exact_power_of_ten(pns.exponent); + if (pns.negative) { value = -value; } + return answer; + } + } + } + adjusted_mantissa am = compute_float>(pns.exponent, pns.mantissa); + if(pns.too_many_digits && am.power2 >= 0) { + if(am != compute_float>(pns.exponent, pns.mantissa + 1)) { + am = compute_error>(pns.exponent, pns.mantissa); + } + } + // If we called compute_float>(pns.exponent, pns.mantissa) and we have an invalid power (am.power2 < 0), + // then we need to go the long way around again. This is very uncommon. + if(am.power2 < 0) { am = digit_comp(pns, am); } + to_float(pns.negative, am, value); + // Test for over/underflow. + if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) || am.power2 == binary_format::infinite_power()) { + answer.ec = std::errc::result_out_of_range; + } + return answer; +} + + +template +FASTFLOAT_CONSTEXPR20 +from_chars_result_t from_chars(UC const* first, UC const* last, T& value, int base) noexcept +{ + static_assert (is_supported_char_type(), "only char, wchar_t, char16_t and char32_t are supported"); + + from_chars_result_t answer; +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default + while ((first != last) && fast_float::is_space(uint8_t(*first))) { + first++; + } +#endif + if (first == last || base < 2 || base > 36) { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; + } + return parse_int_string(first, last, value, base); +} + +} // namespace fast_float + +#endif diff --git a/Include/Libraries/libzip/compat.h b/Include/Libraries/libzip/compat.h deleted file mode 100644 index 257e0ab..0000000 --- a/Include/Libraries/libzip/compat.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef _HAD_LIBZIP_COMPAT_H -#define _HAD_LIBZIP_COMPAT_H - -/* - compat.h -- compatibility defines. - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipconf.h" - -#include "config.h" - -/* to have *_MAX definitions for all types when compiling with g++ */ -#define __STDC_LIMIT_MACROS - -#ifdef _WIN32 -#ifndef ZIP_EXTERN -#ifndef ZIP_STATIC -#define ZIP_EXTERN __declspec(dllexport) -#endif -#endif -/* for dup(), close(), etc. */ -#include -#endif - -#ifdef HAVE_STDBOOL_H -#include -#else -typedef char bool; -#define true 1 -#define false 0 -#endif - -#include - -/* at least MinGW does not provide EOPNOTSUPP, see - * http://sourceforge.net/p/mingw/bugs/263/ - */ -#ifndef EOPNOTSUPP -#define EOPNOTSUPP EINVAL -#endif - -/* at least MinGW does not provide EOVERFLOW, see - * http://sourceforge.net/p/mingw/bugs/242/ - */ -#ifndef EOVERFLOW -#define EOVERFLOW EFBIG -#endif - -/* not supported on at least Windows */ -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - -#ifdef _WIN32 -#if defined(HAVE__CLOSE) -#define close _close -#endif -#if defined(HAVE__DUP) -#define dup _dup -#endif -/* crashes reported when using fdopen instead of _fdopen on Windows/Visual Studio 10/Win64 */ -#if defined(HAVE__FDOPEN) -#define fdopen _fdopen -#endif -#if !defined(HAVE_FILENO) && defined(HAVE__FILENO) -#define fileno _fileno -#endif -#if defined(HAVE__SNPRINTF) -#define snprintf _snprintf -#endif -#if defined(HAVE__STRDUP) -#if !defined(HAVE_STRDUP) || defined(_WIN32) -#undef strdup -#define strdup _strdup -#endif -#endif -#if !defined(HAVE__SETMODE) && defined(HAVE_SETMODE) -#define _setmode setmode -#endif -#if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64) -#define strtoll _strtoi64 -#endif -#if !defined(HAVE_STRTOULL) && defined(HAVE__STRTOUI64) -#define strtoull _strtoui64 -#endif -#if defined(HAVE__UNLINK) -#define unlink _unlink -#endif -#endif - -#ifndef HAVE_FSEEKO -#define fseeko(s, o, w) (fseek((s), (long int)(o), (w))) -#endif - -#ifndef HAVE_FTELLO -#define ftello(s) ((long)ftell((s))) -#endif - -#if !defined(HAVE_STRCASECMP) -#if defined(HAVE__STRICMP) -#define strcasecmp _stricmp -#elif defined(HAVE_STRICMP) -#define strcasecmp stricmp -#endif -#endif - -#if SIZEOF_OFF_T == 8 -#define ZIP_OFF_MAX ZIP_INT64_MAX -#define ZIP_OFF_MIN ZIP_INT64_MIN -#elif SIZEOF_OFF_T == 4 -#define ZIP_OFF_MAX ZIP_INT32_MAX -#define ZIP_OFF_MIN ZIP_INT32_MIN -#elif SIZEOF_OFF_T == 2 -#define ZIP_OFF_MAX ZIP_INT16_MAX -#define ZIP_OFF_MIN ZIP_INT16_MIN -#else -#error unsupported size of off_t -#endif - -#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO) -#define ZIP_FSEEK_MAX ZIP_OFF_MAX -#define ZIP_FSEEK_MIN ZIP_OFF_MIN -#else -#include -#define ZIP_FSEEK_MAX LONG_MAX -#define ZIP_FSEEK_MIN LONG_MIN -#endif - -#ifndef SIZE_MAX -#if SIZEOF_SIZE_T == 8 -#define SIZE_MAX ZIP_INT64_MAX -#elif SIZEOF_SIZE_T == 4 -#define SIZE_MAX ZIP_INT32_MAX -#elif SIZEOF_SIZE_T == 2 -#define SIZE_MAX ZIP_INT16_MAX -#else -#error unsupported size of size_t -#endif -#endif - -#ifndef PRId64 -#ifdef _MSC_VER -#define PRId64 "I64d" -#else -#define PRId64 "lld" -#endif -#endif - -#ifndef PRIu64 -#ifdef _MSC_VER -#define PRIu64 "I64u" -#else -#define PRIu64 "llu" -#endif -#endif - -#ifndef S_ISDIR -#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) -#endif - -#ifndef S_ISREG -#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG) -#endif - -#endif /* compat.h */ diff --git a/Include/Libraries/libzip/config.h b/Include/Libraries/libzip/config.h deleted file mode 100644 index 5112dd9..0000000 --- a/Include/Libraries/libzip/config.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef HAD_CONFIG_H -#define HAD_CONFIG_H -#ifndef _HAD_ZIPCONF_H -#include "zipconf.h" -#endif -/* BEGIN DEFINES */ -/* #undef HAVE___PROGNAME */ -#define HAVE__CLOSE -#define HAVE__DUP -#define HAVE__FDOPEN -#define HAVE__FILENO -#define HAVE__SETMODE -/* #undef HAVE__SNPRINTF */ -#define HAVE__STRDUP -#define HAVE__STRICMP -#define HAVE__STRTOI64 -#define HAVE__STRTOUI64 -/* #undef HAVE__UMASK */ -#define HAVE__UNLINK -/* #undef HAVE_ARC4RANDOM */ -/* #undef HAVE_CLONEFILE */ -/* #undef HAVE_COMMONCRYPTO */ -/* #define HAVE_CRYPTO */ -/* #undef HAVE_FICLONERANGE */ -#define HAVE_FILENO -/* #undef HAVE_FSEEKO */ -/* #undef HAVE_FTELLO */ -/* #undef HAVE_GETPROGNAME */ -/* #undef HAVE_GNUTLS */ -/* #undef HAVE_LIBBZ2 */ -/* #undef HAVE_LIBLZMA */ -/* #undef HAVE_LIBZSTD */ -/* #undef HAVE_LOCALTIME_R */ -/* #undef HAVE_MBEDTLS */ -/* #undef HAVE_MKSTEMP */ -/* #undef HAVE_NULLABLE */ -/* #undef HAVE_OPENSSL */ -#define HAVE_SETMODE -/* #undef HAVE_STRCASECMP */ -#define HAVE_STRDUP -#define HAVE_STRICMP -#define HAVE_STRTOLL -#define HAVE_STRTOULL -/* #undef HAVE_STRUCT_TM_TM_ZONE */ -#define HAVE_STDBOOL_H -/* #undef HAVE_STRINGS_H */ -/* #undef HAVE_UNISTD_H */ -/* #define HAVE_WINDOWS_CRYPTO */ -#define SIZEOF_OFF_T 4 -#define SIZEOF_SIZE_T 8 -/* #undef HAVE_DIRENT_H */ -/* #undef HAVE_FTS_H */ -/* #undef HAVE_NDIR_H */ -/* #undef HAVE_SYS_DIR_H */ -/* #undef HAVE_SYS_NDIR_H */ -/* #undef WORDS_BIGENDIAN */ -#define HAVE_SHARED -/* END DEFINES */ -#define PACKAGE "libzip" -#define VERSION "1.7.3.1" - -#endif /* HAD_CONFIG_H */ diff --git a/Include/Libraries/libzip/zip.h b/Include/Libraries/libzip/zip.h deleted file mode 100644 index 4a1bf89..0000000 --- a/Include/Libraries/libzip/zip.h +++ /dev/null @@ -1,481 +0,0 @@ -#ifndef _HAD_ZIP_H -#define _HAD_ZIP_H - -/* - zip.h -- exported declarations. - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* fix autoindent */ -#endif -#endif - -#include - -#ifndef ZIP_EXTERN -#ifndef ZIP_STATIC -#ifdef _WIN32 -#define ZIP_EXTERN __declspec(dllimport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -#define ZIP_EXTERN __attribute__((visibility("default"))) -#else -#define ZIP_EXTERN -#endif -#else -#define ZIP_EXTERN -#endif -#endif - -#include -#include -#include - -/* flags for zip_open */ - -#define ZIP_CREATE 1 -#define ZIP_EXCL 2 -#define ZIP_CHECKCONS 4 -#define ZIP_TRUNCATE 8 -#define ZIP_RDONLY 16 - - -/* flags for zip_name_locate, zip_fopen, zip_stat, ... */ - -#define ZIP_FL_NOCASE 1u /* ignore case on name lookup */ -#define ZIP_FL_NODIR 2u /* ignore directory component */ -#define ZIP_FL_COMPRESSED 4u /* read compressed data */ -#define ZIP_FL_UNCHANGED 8u /* use original data, ignoring changes */ -#define ZIP_FL_RECOMPRESS 16u /* force recompression of data */ -#define ZIP_FL_ENCRYPTED 32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */ -#define ZIP_FL_ENC_GUESS 0u /* guess string encoding (is default) */ -#define ZIP_FL_ENC_RAW 64u /* get unmodified string */ -#define ZIP_FL_ENC_STRICT 128u /* follow specification strictly */ -#define ZIP_FL_LOCAL 256u /* in local header */ -#define ZIP_FL_CENTRAL 512u /* in central directory */ -/* 1024u reserved for internal use */ -#define ZIP_FL_ENC_UTF_8 2048u /* string is UTF-8 encoded */ -#define ZIP_FL_ENC_CP437 4096u /* string is CP437 encoded */ -#define ZIP_FL_OVERWRITE 8192u /* zip_file_add: if file with name exists, overwrite (replace) it */ - -/* archive global flags flags */ - -#define ZIP_AFL_RDONLY 2u /* read only -- cannot be cleared */ - - -/* create a new extra field */ - -#define ZIP_EXTRA_FIELD_ALL ZIP_UINT16_MAX -#define ZIP_EXTRA_FIELD_NEW ZIP_UINT16_MAX - - -/* libzip error codes */ - -#define ZIP_ER_OK 0 /* N No error */ -#define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */ -#define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */ -#define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */ -#define ZIP_ER_SEEK 4 /* S Seek error */ -#define ZIP_ER_READ 5 /* S Read error */ -#define ZIP_ER_WRITE 6 /* S Write error */ -#define ZIP_ER_CRC 7 /* N CRC error */ -#define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */ -#define ZIP_ER_NOENT 9 /* N No such file */ -#define ZIP_ER_EXISTS 10 /* N File already exists */ -#define ZIP_ER_OPEN 11 /* S Can't open file */ -#define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */ -#define ZIP_ER_ZLIB 13 /* Z Zlib error */ -#define ZIP_ER_MEMORY 14 /* N Malloc failure */ -#define ZIP_ER_CHANGED 15 /* N Entry has been changed */ -#define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */ -#define ZIP_ER_EOF 17 /* N Premature end of file */ -#define ZIP_ER_INVAL 18 /* N Invalid argument */ -#define ZIP_ER_NOZIP 19 /* N Not a zip archive */ -#define ZIP_ER_INTERNAL 20 /* N Internal error */ -#define ZIP_ER_INCONS 21 /* N Zip archive inconsistent */ -#define ZIP_ER_REMOVE 22 /* S Can't remove file */ -#define ZIP_ER_DELETED 23 /* N Entry has been deleted */ -#define ZIP_ER_ENCRNOTSUPP 24 /* N Encryption method not supported */ -#define ZIP_ER_RDONLY 25 /* N Read-only archive */ -#define ZIP_ER_NOPASSWD 26 /* N No password provided */ -#define ZIP_ER_WRONGPASSWD 27 /* N Wrong password provided */ -#define ZIP_ER_OPNOTSUPP 28 /* N Operation not supported */ -#define ZIP_ER_INUSE 29 /* N Resource still in use */ -#define ZIP_ER_TELL 30 /* S Tell error */ -#define ZIP_ER_COMPRESSED_DATA 31 /* N Compressed data invalid */ -#define ZIP_ER_CANCELLED 32 /* N Operation cancelled */ - -/* type of system error value */ - -#define ZIP_ET_NONE 0 /* sys_err unused */ -#define ZIP_ET_SYS 1 /* sys_err is errno */ -#define ZIP_ET_ZLIB 2 /* sys_err is zlib error code */ - -/* compression methods */ - -#define ZIP_CM_DEFAULT -1 /* better of deflate or store */ -#define ZIP_CM_STORE 0 /* stored (uncompressed) */ -#define ZIP_CM_SHRINK 1 /* shrunk */ -#define ZIP_CM_REDUCE_1 2 /* reduced with factor 1 */ -#define ZIP_CM_REDUCE_2 3 /* reduced with factor 2 */ -#define ZIP_CM_REDUCE_3 4 /* reduced with factor 3 */ -#define ZIP_CM_REDUCE_4 5 /* reduced with factor 4 */ -#define ZIP_CM_IMPLODE 6 /* imploded */ -/* 7 - Reserved for Tokenizing compression algorithm */ -#define ZIP_CM_DEFLATE 8 /* deflated */ -#define ZIP_CM_DEFLATE64 9 /* deflate64 */ -#define ZIP_CM_PKWARE_IMPLODE 10 /* PKWARE imploding */ -/* 11 - Reserved by PKWARE */ -#define ZIP_CM_BZIP2 12 /* compressed using BZIP2 algorithm */ -/* 13 - Reserved by PKWARE */ -#define ZIP_CM_LZMA 14 /* LZMA (EFS) */ -/* 15-17 - Reserved by PKWARE */ -#define ZIP_CM_TERSE 18 /* compressed using IBM TERSE (new) */ -#define ZIP_CM_LZ77 19 /* IBM LZ77 z Architecture (PFS) */ -/* 20 - old value for Zstandard */ -#define ZIP_CM_LZMA2 33 -#define ZIP_CM_ZSTD 93 /* Zstandard compressed data */ -#define ZIP_CM_XZ 95 /* XZ compressed data */ -#define ZIP_CM_JPEG 96 /* Compressed Jpeg data */ -#define ZIP_CM_WAVPACK 97 /* WavPack compressed data */ -#define ZIP_CM_PPMD 98 /* PPMd version I, Rev 1 */ - -/* encryption methods */ - -#define ZIP_EM_NONE 0 /* not encrypted */ -#define ZIP_EM_TRAD_PKWARE 1 /* traditional PKWARE encryption */ -#if 0 /* Strong Encryption Header not parsed yet */ -#define ZIP_EM_DES 0x6601 /* strong encryption: DES */ -#define ZIP_EM_RC2_OLD 0x6602 /* strong encryption: RC2, version < 5.2 */ -#define ZIP_EM_3DES_168 0x6603 -#define ZIP_EM_3DES_112 0x6609 -#define ZIP_EM_PKZIP_AES_128 0x660e -#define ZIP_EM_PKZIP_AES_192 0x660f -#define ZIP_EM_PKZIP_AES_256 0x6610 -#define ZIP_EM_RC2 0x6702 /* strong encryption: RC2, version >= 5.2 */ -#define ZIP_EM_RC4 0x6801 -#endif -#define ZIP_EM_AES_128 0x0101 /* Winzip AES encryption */ -#define ZIP_EM_AES_192 0x0102 -#define ZIP_EM_AES_256 0x0103 -#define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */ - -#define ZIP_OPSYS_DOS 0x00u -#define ZIP_OPSYS_AMIGA 0x01u -#define ZIP_OPSYS_OPENVMS 0x02u -#define ZIP_OPSYS_UNIX 0x03u -#define ZIP_OPSYS_VM_CMS 0x04u -#define ZIP_OPSYS_ATARI_ST 0x05u -#define ZIP_OPSYS_OS_2 0x06u -#define ZIP_OPSYS_MACINTOSH 0x07u -#define ZIP_OPSYS_Z_SYSTEM 0x08u -#define ZIP_OPSYS_CPM 0x09u -#define ZIP_OPSYS_WINDOWS_NTFS 0x0au -#define ZIP_OPSYS_MVS 0x0bu -#define ZIP_OPSYS_VSE 0x0cu -#define ZIP_OPSYS_ACORN_RISC 0x0du -#define ZIP_OPSYS_VFAT 0x0eu -#define ZIP_OPSYS_ALTERNATE_MVS 0x0fu -#define ZIP_OPSYS_BEOS 0x10u -#define ZIP_OPSYS_TANDEM 0x11u -#define ZIP_OPSYS_OS_400 0x12u -#define ZIP_OPSYS_OS_X 0x13u - -#define ZIP_OPSYS_DEFAULT ZIP_OPSYS_UNIX - - -enum zip_source_cmd { - ZIP_SOURCE_OPEN, /* prepare for reading */ - ZIP_SOURCE_READ, /* read data */ - ZIP_SOURCE_CLOSE, /* reading is done */ - ZIP_SOURCE_STAT, /* get meta information */ - ZIP_SOURCE_ERROR, /* get error information */ - ZIP_SOURCE_FREE, /* cleanup and free resources */ - ZIP_SOURCE_SEEK, /* set position for reading */ - ZIP_SOURCE_TELL, /* get read position */ - ZIP_SOURCE_BEGIN_WRITE, /* prepare for writing */ - ZIP_SOURCE_COMMIT_WRITE, /* writing is done */ - ZIP_SOURCE_ROLLBACK_WRITE, /* discard written changes */ - ZIP_SOURCE_WRITE, /* write data */ - ZIP_SOURCE_SEEK_WRITE, /* set position for writing */ - ZIP_SOURCE_TELL_WRITE, /* get write position */ - ZIP_SOURCE_SUPPORTS, /* check whether source supports command */ - ZIP_SOURCE_REMOVE, /* remove file */ - ZIP_SOURCE_RESERVED_1, /* previously used internally */ - ZIP_SOURCE_BEGIN_WRITE_CLONING, /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */ - ZIP_SOURCE_ACCEPT_EMPTY, /* whether empty files are valid archives */ - ZIP_SOURCE_GET_FILE_ATTRIBUTES /* get additional file attributes */ -}; -typedef enum zip_source_cmd zip_source_cmd_t; - -#define ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd) (((zip_int64_t)1) << (cmd)) - -/* clang-format off */ - -#define ZIP_SOURCE_SUPPORTS_READABLE (ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_OPEN) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_READ) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_CLOSE) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_STAT) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ERROR) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_FREE)) - -#define ZIP_SOURCE_SUPPORTS_SEEKABLE (ZIP_SOURCE_SUPPORTS_READABLE \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SUPPORTS)) - -#define ZIP_SOURCE_SUPPORTS_WRITABLE (ZIP_SOURCE_SUPPORTS_SEEKABLE \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_COMMIT_WRITE) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ROLLBACK_WRITE) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_WRITE) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK_WRITE) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL_WRITE) \ - | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_REMOVE)) - -/* clang-format on */ - -/* for use by sources */ -struct zip_source_args_seek { - zip_int64_t offset; - int whence; -}; - -typedef struct zip_source_args_seek zip_source_args_seek_t; -#define ZIP_SOURCE_GET_ARGS(type, data, len, error) ((len) < sizeof(type) ? zip_error_set((error), ZIP_ER_INVAL, 0), (type *)NULL : (type *)(data)) - - -/* error information */ -/* use zip_error_*() to access */ -struct zip_error { - int zip_err; /* libzip error code (ZIP_ER_*) */ - int sys_err; /* copy of errno (E*) or zlib error code */ - char *_Nullable str; /* string representation or NULL */ -}; - -#define ZIP_STAT_NAME 0x0001u -#define ZIP_STAT_INDEX 0x0002u -#define ZIP_STAT_SIZE 0x0004u -#define ZIP_STAT_COMP_SIZE 0x0008u -#define ZIP_STAT_MTIME 0x0010u -#define ZIP_STAT_CRC 0x0020u -#define ZIP_STAT_COMP_METHOD 0x0040u -#define ZIP_STAT_ENCRYPTION_METHOD 0x0080u -#define ZIP_STAT_FLAGS 0x0100u - -struct zip_stat { - zip_uint64_t valid; /* which fields have valid values */ - const char *_Nullable name; /* name of the file */ - zip_uint64_t index; /* index within archive */ - zip_uint64_t size; /* size of file (uncompressed) */ - zip_uint64_t comp_size; /* size of file (compressed) */ - time_t mtime; /* modification time */ - zip_uint32_t crc; /* crc of file data */ - zip_uint16_t comp_method; /* compression method used */ - zip_uint16_t encryption_method; /* encryption method used */ - zip_uint32_t flags; /* reserved for future use */ -}; - -struct zip_buffer_fragment { - zip_uint8_t *_Nonnull data; - zip_uint64_t length; -}; - -struct zip_file_attributes { - zip_uint64_t valid; /* which fields have valid values */ - zip_uint8_t version; /* version of this struct, currently 1 */ - zip_uint8_t host_system; /* host system on which file was created */ - zip_uint8_t ascii; /* flag whether file is ASCII text */ - zip_uint8_t version_needed; /* minimum version needed to extract file */ - zip_uint32_t external_file_attributes; /* external file attributes (host-system specific) */ - zip_uint16_t general_purpose_bit_flags; /* general purpose big flags, only some bits are honored */ - zip_uint16_t general_purpose_bit_mask; /* which bits in general_purpose_bit_flags are valid */ -}; - -#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM 0x0001u -#define ZIP_FILE_ATTRIBUTES_ASCII 0x0002u -#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED 0x0004u -#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES 0x0008u -#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS 0x0010u - -struct zip; -struct zip_file; -struct zip_source; - -typedef struct zip zip_t; -typedef struct zip_error zip_error_t; -typedef struct zip_file zip_file_t; -typedef struct zip_file_attributes zip_file_attributes_t; -typedef struct zip_source zip_source_t; -typedef struct zip_stat zip_stat_t; -typedef struct zip_buffer_fragment zip_buffer_fragment_t; - -typedef zip_uint32_t zip_flags_t; - -typedef zip_int64_t (*zip_source_callback)(void *_Nullable, void *_Nullable, zip_uint64_t, zip_source_cmd_t); -typedef void (*zip_progress_callback)(zip_t *_Nonnull, double, void *_Nullable); -typedef int (*zip_cancel_callback)(zip_t *_Nonnull, void *_Nullable); - -#ifndef ZIP_DISABLE_DEPRECATED -typedef void (*zip_progress_callback_t)(double); -ZIP_EXTERN void zip_register_progress_callback(zip_t *_Nonnull, zip_progress_callback_t _Nullable); /* use zip_register_progress_callback_with_state */ - -ZIP_EXTERN zip_int64_t zip_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull); /* use zip_file_add */ -ZIP_EXTERN zip_int64_t zip_add_dir(zip_t *_Nonnull, const char *_Nonnull); /* use zip_dir_add */ -ZIP_EXTERN const char *_Nullable zip_get_file_comment(zip_t *_Nonnull, zip_uint64_t, int *_Nullable, int); /* use zip_file_get_comment */ -ZIP_EXTERN int zip_get_num_files(zip_t *_Nonnull); /* use zip_get_num_entries instead */ -ZIP_EXTERN int zip_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull); /* use zip_file_rename */ -ZIP_EXTERN int zip_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull); /* use zip_file_replace */ -ZIP_EXTERN int zip_set_file_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, int); /* use zip_file_set_comment */ -ZIP_EXTERN int zip_error_get_sys_type(int); /* use zip_error_system_type */ -ZIP_EXTERN void zip_error_get(zip_t *_Nonnull, int *_Nullable, int *_Nullable); /* use zip_get_error, zip_error_code_zip / zip_error_code_system */ -ZIP_EXTERN int zip_error_to_str(char *_Nonnull, zip_uint64_t, int, int); /* use zip_error_init_with_code / zip_error_strerror */ -ZIP_EXTERN void zip_file_error_get(zip_file_t *_Nonnull, int *_Nullable, int *_Nullable); /* use zip_file_get_error, zip_error_code_zip / zip_error_code_system */ -#endif - -ZIP_EXTERN int zip_close(zip_t *_Nonnull); -ZIP_EXTERN int zip_delete(zip_t *_Nonnull, zip_uint64_t); -ZIP_EXTERN zip_int64_t zip_dir_add(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); -ZIP_EXTERN void zip_discard(zip_t *_Nonnull); - -ZIP_EXTERN zip_error_t *_Nonnull zip_get_error(zip_t *_Nonnull); -ZIP_EXTERN void zip_error_clear(zip_t *_Nonnull); -ZIP_EXTERN int zip_error_code_zip(const zip_error_t *_Nonnull); -ZIP_EXTERN int zip_error_code_system(const zip_error_t *_Nonnull); -ZIP_EXTERN void zip_error_fini(zip_error_t *_Nonnull); -ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull); -ZIP_EXTERN void zip_error_init_with_code(zip_error_t *_Nonnull, int); -ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int); -ZIP_EXTERN const char *_Nonnull zip_error_strerror(zip_error_t *_Nonnull); -ZIP_EXTERN int zip_error_system_type(const zip_error_t *_Nonnull); -ZIP_EXTERN zip_int64_t zip_error_to_data(const zip_error_t *_Nonnull, void *_Nonnull, zip_uint64_t); - -ZIP_EXTERN int zip_fclose(zip_file_t *_Nonnull); -ZIP_EXTERN zip_t *_Nullable zip_fdopen(int, int, int *_Nullable); -ZIP_EXTERN zip_int64_t zip_file_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull, zip_flags_t); -ZIP_EXTERN void zip_file_attributes_init(zip_file_attributes_t *_Nonnull); -ZIP_EXTERN void zip_file_error_clear(zip_file_t *_Nonnull); -ZIP_EXTERN int zip_file_extra_field_delete(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t); -ZIP_EXTERN int zip_file_extra_field_delete_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t); -ZIP_EXTERN int zip_file_extra_field_set(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *_Nullable, zip_uint16_t, zip_flags_t); -ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); -ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t); -ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_uint16_t *_Nullable, zip_flags_t); -ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_flags_t); -ZIP_EXTERN const char *_Nullable zip_file_get_comment(zip_t *_Nonnull, zip_uint64_t, zip_uint32_t *_Nullable, zip_flags_t); -ZIP_EXTERN zip_error_t *_Nonnull zip_file_get_error(zip_file_t *_Nonnull); -ZIP_EXTERN int zip_file_get_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t *_Nullable, zip_uint32_t *_Nullable); -ZIP_EXTERN int zip_file_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull, zip_flags_t); -ZIP_EXTERN int zip_file_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull, zip_flags_t); -ZIP_EXTERN int zip_file_set_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, zip_uint16_t, zip_flags_t); -ZIP_EXTERN int zip_file_set_dostime(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t); -ZIP_EXTERN int zip_file_set_encryption(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, const char *_Nullable); -ZIP_EXTERN int zip_file_set_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t); -ZIP_EXTERN int zip_file_set_mtime(zip_t *_Nonnull, zip_uint64_t, time_t, zip_flags_t); -ZIP_EXTERN const char *_Nonnull zip_file_strerror(zip_file_t *_Nonnull); -ZIP_EXTERN zip_file_t *_Nullable zip_fopen(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); -ZIP_EXTERN zip_file_t *_Nullable zip_fopen_encrypted(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, const char *_Nullable); -ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); -ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index_encrypted(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, const char *_Nullable); -ZIP_EXTERN zip_int64_t zip_fread(zip_file_t *_Nonnull, void *_Nonnull, zip_uint64_t); -ZIP_EXTERN zip_int8_t zip_fseek(zip_file_t *_Nonnull, zip_int64_t, int); -ZIP_EXTERN zip_int64_t zip_ftell(zip_file_t *_Nonnull); -ZIP_EXTERN const char *_Nullable zip_get_archive_comment(zip_t *_Nonnull, int *_Nullable, zip_flags_t); -ZIP_EXTERN int zip_get_archive_flag(zip_t *_Nonnull, zip_flags_t, zip_flags_t); -ZIP_EXTERN const char *_Nullable zip_get_name(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); -ZIP_EXTERN zip_int64_t zip_get_num_entries(zip_t *_Nonnull, zip_flags_t); -ZIP_EXTERN const char *_Nonnull zip_libzip_version(void); -ZIP_EXTERN zip_int64_t zip_name_locate(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); -ZIP_EXTERN zip_t *_Nullable zip_open(const char *_Nonnull, int, int *_Nullable); -ZIP_EXTERN zip_t *_Nullable zip_open_from_source(zip_source_t *_Nonnull, int, zip_error_t *_Nullable); -ZIP_EXTERN int zip_register_progress_callback_with_state(zip_t *_Nonnull, double, zip_progress_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable); -ZIP_EXTERN int zip_register_cancel_callback_with_state(zip_t *_Nonnull, zip_cancel_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable); -ZIP_EXTERN int zip_set_archive_comment(zip_t *_Nonnull, const char *_Nullable, zip_uint16_t); -ZIP_EXTERN int zip_set_archive_flag(zip_t *_Nonnull, zip_flags_t, int); -ZIP_EXTERN int zip_set_default_password(zip_t *_Nonnull, const char *_Nullable); -ZIP_EXTERN int zip_set_file_compression(zip_t *_Nonnull, zip_uint64_t, zip_int32_t, zip_uint32_t); -ZIP_EXTERN int zip_source_begin_write(zip_source_t *_Nonnull); -ZIP_EXTERN int zip_source_begin_write_cloning(zip_source_t *_Nonnull, zip_uint64_t); -ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer(zip_t *_Nonnull, const void *_Nullable, zip_uint64_t, int); -ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_create(const void *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable); -ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment(zip_t *_Nonnull, const zip_buffer_fragment_t *_Nonnull, zip_uint64_t, int); -ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment_create(const zip_buffer_fragment_t *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable); -ZIP_EXTERN int zip_source_close(zip_source_t *_Nonnull); -ZIP_EXTERN int zip_source_commit_write(zip_source_t *_Nonnull); -ZIP_EXTERN zip_error_t *_Nonnull zip_source_error(zip_source_t *_Nonnull); -ZIP_EXTERN zip_source_t *_Nullable zip_source_file(zip_t *_Nonnull, const char *_Nonnull, zip_uint64_t, zip_int64_t); -ZIP_EXTERN zip_source_t *_Nullable zip_source_file_create(const char *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); -ZIP_EXTERN zip_source_t *_Nullable zip_source_filep(zip_t *_Nonnull, FILE *_Nonnull, zip_uint64_t, zip_int64_t); -ZIP_EXTERN zip_source_t *_Nullable zip_source_filep_create(FILE *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); -ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable); -ZIP_EXTERN zip_source_t *_Nullable zip_source_function(zip_t *_Nonnull, zip_source_callback _Nonnull, void *_Nullable); -ZIP_EXTERN zip_source_t *_Nullable zip_source_function_create(zip_source_callback _Nonnull, void *_Nullable, zip_error_t *_Nullable); -ZIP_EXTERN int zip_source_get_file_attributes(zip_source_t *_Nonnull, zip_file_attributes_t *_Nonnull); -ZIP_EXTERN int zip_source_is_deleted(zip_source_t *_Nonnull); -ZIP_EXTERN void zip_source_keep(zip_source_t *_Nonnull); -ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t, ...); -ZIP_EXTERN int zip_source_open(zip_source_t *_Nonnull); -ZIP_EXTERN zip_int64_t zip_source_read(zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t); -ZIP_EXTERN void zip_source_rollback_write(zip_source_t *_Nonnull); -ZIP_EXTERN int zip_source_seek(zip_source_t *_Nonnull, zip_int64_t, int); -ZIP_EXTERN zip_int64_t zip_source_seek_compute_offset(zip_uint64_t, zip_uint64_t, void *_Nonnull, zip_uint64_t, zip_error_t *_Nullable); -ZIP_EXTERN int zip_source_seek_write(zip_source_t *_Nonnull, zip_int64_t, int); -ZIP_EXTERN int zip_source_stat(zip_source_t *_Nonnull, zip_stat_t *_Nonnull); -ZIP_EXTERN zip_int64_t zip_source_tell(zip_source_t *_Nonnull); -ZIP_EXTERN zip_int64_t zip_source_tell_write(zip_source_t *_Nonnull); -#ifdef _WIN32 -ZIP_EXTERN zip_source_t *zip_source_win32a(zip_t *, const char *, zip_uint64_t, zip_int64_t); -ZIP_EXTERN zip_source_t *zip_source_win32a_create(const char *, zip_uint64_t, zip_int64_t, zip_error_t *); -ZIP_EXTERN zip_source_t *zip_source_win32handle(zip_t *, void *, zip_uint64_t, zip_int64_t); -ZIP_EXTERN zip_source_t *zip_source_win32handle_create(void *, zip_uint64_t, zip_int64_t, zip_error_t *); -ZIP_EXTERN zip_source_t *zip_source_win32w(zip_t *, const wchar_t *, zip_uint64_t, zip_int64_t); -ZIP_EXTERN zip_source_t *zip_source_win32w_create(const wchar_t *, zip_uint64_t, zip_int64_t, zip_error_t *); -#endif -ZIP_EXTERN zip_int64_t zip_source_write(zip_source_t *_Nonnull, const void *_Nullable, zip_uint64_t); -ZIP_EXTERN zip_source_t *_Nullable zip_source_zip(zip_t *_Nonnull, zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t); -ZIP_EXTERN int zip_stat(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, zip_stat_t *_Nonnull); -ZIP_EXTERN int zip_stat_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull); -ZIP_EXTERN void zip_stat_init(zip_stat_t *_Nonnull); -ZIP_EXTERN const char *_Nonnull zip_strerror(zip_t *_Nonnull); -ZIP_EXTERN int zip_unchange(zip_t *_Nonnull, zip_uint64_t); -ZIP_EXTERN int zip_unchange_all(zip_t *_Nonnull); -ZIP_EXTERN int zip_unchange_archive(zip_t *_Nonnull); -ZIP_EXTERN int zip_compression_method_supported(zip_int32_t method, int compress); -ZIP_EXTERN int zip_encryption_method_supported(zip_uint16_t method, int encode); - -#ifdef __cplusplus -} -#endif - -#endif /* _HAD_ZIP_H */ diff --git a/Include/Libraries/libzip/zip_source_file.h b/Include/Libraries/libzip/zip_source_file.h deleted file mode 100644 index 43a4645..0000000 --- a/Include/Libraries/libzip/zip_source_file.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - zip_source_file.h -- header for common file operations - Copyright (C) 2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - -struct zip_source_file_stat { - zip_uint64_t size; /* must be valid for regular files */ - time_t mtime; /* must always be valid, is initialized to current time */ - bool exists; /* must always be vaild */ - bool regular_file; /* must always be valid */ -}; - -typedef struct zip_source_file_context zip_source_file_context_t; -typedef struct zip_source_file_operations zip_source_file_operations_t; -typedef struct zip_source_file_stat zip_source_file_stat_t; - -struct zip_source_file_context { - zip_error_t error; /* last error information */ - zip_int64_t supports; - - /* reading */ - char *fname; /* name of file to read from */ - void *f; /* file to read from */ - zip_stat_t st; /* stat information passed in */ - zip_file_attributes_t attributes; /* additional file attributes */ - zip_error_t stat_error; /* error returned for stat */ - zip_uint64_t start; /* start offset of data to read */ - zip_uint64_t len; /* length of the file, 0 for up to EOF */ - zip_uint64_t offset; /* current offset relative to start (0 is beginning of part we read) */ - - /* writing */ - char *tmpname; - void *fout; - - zip_source_file_operations_t *ops; - void *ops_userdata; -}; - - -/* The following methods must be implemented to support each feature: - - close, read, seek, and stat must always be implemented. - - To support specifying the file by name, open, and strdup must be implemented. - - For write support, the file must be specified by name and close, commit_write, create_temp_output, remove, rollback_write, and tell must be implemented. - - create_temp_output_cloning is always optional. */ - -struct zip_source_file_operations { - void (*close)(zip_source_file_context_t *ctx); - zip_int64_t (*commit_write)(zip_source_file_context_t *ctx); - zip_int64_t (*create_temp_output)(zip_source_file_context_t *ctx); - zip_int64_t (*create_temp_output_cloning)(zip_source_file_context_t *ctx, zip_uint64_t len); - bool (*open)(zip_source_file_context_t *ctx); - zip_int64_t (*read)(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len); - zip_int64_t (*remove)(zip_source_file_context_t *ctx); - void (*rollback_write)(zip_source_file_context_t *ctx); - bool (*seek)(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence); - bool (*stat)(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); - char *(*string_duplicate)(zip_source_file_context_t *ctx, const char *); - zip_int64_t (*tell)(zip_source_file_context_t *ctx, void *f); - zip_int64_t (*write)(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len); -}; - -zip_source_t *zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error); diff --git a/Include/Libraries/libzip/zip_source_file_stdio.h b/Include/Libraries/libzip/zip_source_file_stdio.h deleted file mode 100644 index 1bf698c..0000000 --- a/Include/Libraries/libzip/zip_source_file_stdio.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _HAD_ZIP_SOURCE_FILE_STDIO_H -#define _HAD_ZIP_SOURCE_FILE_STDIO_H - -/* - zip_source_file_stdio.h -- common header for stdio file implementation - Copyright (C) 2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -void _zip_stdio_op_close(zip_source_file_context_t *ctx); -zip_int64_t _zip_stdio_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len); -bool _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence); -bool _zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); -zip_int64_t _zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f); - -FILE *_zip_fopen_close_on_exec(const char *name, bool writeable); - -#endif /* _HAD_ZIP_SOURCE_FILE_STDIO_H */ diff --git a/Include/Libraries/libzip/zip_source_file_win32.h b/Include/Libraries/libzip/zip_source_file_win32.h deleted file mode 100644 index 88e45b1..0000000 --- a/Include/Libraries/libzip/zip_source_file_win32.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef _HAD_ZIP_SOURCE_FILE_WIN32_H -#define _HAD_ZIP_SOURCE_FILE_WIN32_H - -/* - zip_source_file_win32.h -- common header for Windows file implementation - Copyright (C) 2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - -/* 0x0501 => Windows XP; needs to be at least this value because of GetFileSizeEx */ -#if !defined(MS_UWP) && !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x0501 -#endif - -#include - -#include - -#include - -#include "zipint.h" - -#include "zip_source_file.h" - -struct zip_win32_file_operations { - char *(*allocate_tempname)(const char *name, size_t extra_chars, size_t *lengthp); - HANDLE(__stdcall *create_file)(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file); - BOOL(__stdcall *delete_file)(const void *name); - DWORD(__stdcall *get_file_attributes)(const void *name); - BOOL(__stdcall *get_file_attributes_ex)(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information); - void (*make_tempname)(char *buf, size_t len, const char *name, zip_uint32_t i); - BOOL(__stdcall *move_file)(const void *from, const void *to, DWORD flags); - BOOL(__stdcall *set_file_attributes)(const void *name, DWORD attributes); - char *(*string_duplicate)(const char *string); -}; - -typedef struct zip_win32_file_operations zip_win32_file_operations_t; - -extern zip_source_file_operations_t _zip_source_file_win32_named_ops; - -void _zip_win32_op_close(zip_source_file_context_t *ctx); -zip_int64_t _zip_win32_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len); -bool _zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence); -zip_int64_t _zip_win32_op_tell(zip_source_file_context_t *ctx, void *f); - -bool _zip_filetime_to_time_t(FILETIME ft, time_t *t); -int _zip_win32_error_to_errno(DWORD win32err); - -#endif /* _HAD_ZIP_SOURCE_FILE_WIN32_H */ diff --git a/Include/Libraries/libzip/zipconf.h b/Include/Libraries/libzip/zipconf.h deleted file mode 100644 index f6e9ed0..0000000 --- a/Include/Libraries/libzip/zipconf.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _HAD_ZIPCONF_H -#define _HAD_ZIPCONF_H - -/* - zipconf.h -- platform specific include file - - This file was generated automatically by CMake - based on ../cmake-zipconf.h.in. - */ - -#define LIBZIP_VERSION "1.7.3.1" -#define LIBZIP_VERSION_MAJOR 1 -#define LIBZIP_VERSION_MINOR 7 -#define LIBZIP_VERSION_MICRO 3 - -/* #undef ZIP_STATIC */ - -#define _Nullable -#define _Nonnull - -#if !defined(__STDC_FORMAT_MACROS) -#define __STDC_FORMAT_MACROS 1 -#endif -#include - -typedef int8_t zip_int8_t; -typedef uint8_t zip_uint8_t; -typedef int16_t zip_int16_t; -typedef uint16_t zip_uint16_t; -typedef int32_t zip_int32_t; -typedef uint32_t zip_uint32_t; -typedef int64_t zip_int64_t; -typedef uint64_t zip_uint64_t; - -#define ZIP_INT8_MIN (-ZIP_INT8_MAX-1) -#define ZIP_INT8_MAX 0x7f -#define ZIP_UINT8_MAX 0xff - -#define ZIP_INT16_MIN (-ZIP_INT16_MAX-1) -#define ZIP_INT16_MAX 0x7fff -#define ZIP_UINT16_MAX 0xffff - -#define ZIP_INT32_MIN (-ZIP_INT32_MAX-1L) -#define ZIP_INT32_MAX 0x7fffffffL -#define ZIP_UINT32_MAX 0xffffffffLU - -#define ZIP_INT64_MIN (-ZIP_INT64_MAX-1LL) -#define ZIP_INT64_MAX 0x7fffffffffffffffLL -#define ZIP_UINT64_MAX 0xffffffffffffffffULL - -#endif /* zipconf.h */ diff --git a/Include/Libraries/libzip/zipint.h b/Include/Libraries/libzip/zipint.h deleted file mode 100644 index 65e602c..0000000 --- a/Include/Libraries/libzip/zipint.h +++ /dev/null @@ -1,609 +0,0 @@ -#ifndef _HAD_ZIPINT_H -#define _HAD_ZIPINT_H - -/* - zipint.h -- internal declarations. - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include "compat.h" - -#ifdef ZIP_ALLOCATE_BUFFER -#include -#endif - -#ifndef _ZIP_COMPILING_DEPRECATED -#define ZIP_DISABLE_DEPRECATED -#endif - -#include "zip.h" - -#define CENTRAL_MAGIC "PK\1\2" -#define LOCAL_MAGIC "PK\3\4" -#define EOCD_MAGIC "PK\5\6" -#define DATADES_MAGIC "PK\7\10" -#define EOCD64LOC_MAGIC "PK\6\7" -#define EOCD64_MAGIC "PK\6\6" -#define CDENTRYSIZE 46u -#define LENTRYSIZE 30 -#define MAXCOMLEN 65536 -#define MAXEXTLEN 65536 -#define EOCDLEN 22 -#define EOCD64LOCLEN 20 -#define EOCD64LEN 56 -#define CDBUFSIZE (MAXCOMLEN + EOCDLEN + EOCD64LOCLEN) -#define BUFSIZE 8192 -#define EFZIP64SIZE 28 -#define EF_WINZIP_AES_SIZE 7 -#define MAX_DATA_DESCRIPTOR_LENGTH 24 - -#define ZIP_CRYPTO_PKWARE_HEADERLEN 12 - -#define ZIP_CM_REPLACED_DEFAULT (-2) -#define ZIP_CM_WINZIP_AES 99 /* Winzip AES encrypted */ - -#define WINZIP_AES_PASSWORD_VERIFY_LENGTH 2 -#define WINZIP_AES_MAX_HEADER_LENGTH (16 + WINZIP_AES_PASSWORD_VERIFY_LENGTH) -#define AES_BLOCK_SIZE 16 -#define HMAC_LENGTH 10 -#define SHA1_LENGTH 20 -#define SALT_LENGTH(method) ((method) == ZIP_EM_AES_128 ? 8 : ((method) == ZIP_EM_AES_192 ? 12 : 16)) - -#define ZIP_CM_IS_DEFAULT(x) ((x) == ZIP_CM_DEFAULT || (x) == ZIP_CM_REPLACED_DEFAULT) -#define ZIP_CM_ACTUAL(x) ((zip_uint16_t)(ZIP_CM_IS_DEFAULT(x) ? ZIP_CM_DEFLATE : (x))) - -#define ZIP_EF_UTF_8_COMMENT 0x6375 -#define ZIP_EF_UTF_8_NAME 0x7075 -#define ZIP_EF_WINZIP_AES 0x9901 -#define ZIP_EF_ZIP64 0x0001 - -#define ZIP_EF_IS_INTERNAL(id) ((id) == ZIP_EF_UTF_8_COMMENT || (id) == ZIP_EF_UTF_8_NAME || (id) == ZIP_EF_WINZIP_AES || (id) == ZIP_EF_ZIP64) - -/* according to unzip-6.0's zipinfo.c, this corresponds to a regular file with rw permissions for everyone */ -#define ZIP_EXT_ATTRIB_DEFAULT (0100666u << 16) -/* according to unzip-6.0's zipinfo.c, this corresponds to a directory with rwx permissions for everyone */ -#define ZIP_EXT_ATTRIB_DEFAULT_DIR (0040777u << 16) - -#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK 0x0836 - -#define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b)) - -/* This section contains API that won't materialize like this. It's - placed in the internal section, pending cleanup. */ - -/* flags for compression and encryption sources */ - -#define ZIP_CODEC_DECODE 0 /* decompress/decrypt (encode flag not set) */ -#define ZIP_CODEC_ENCODE 1 /* compress/encrypt */ - -typedef zip_source_t *(*zip_encryption_implementation)(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); - -zip_encryption_implementation _zip_get_encryption_implementation(zip_uint16_t method, int operation); - -/* clang-format off */ -enum zip_compression_status { - ZIP_COMPRESSION_OK, - ZIP_COMPRESSION_END, - ZIP_COMPRESSION_ERROR, - ZIP_COMPRESSION_NEED_DATA -}; -/* clang-format on */ -typedef enum zip_compression_status zip_compression_status_t; - -struct zip_compression_algorithm { - /* Return maxiumum compressed size for uncompressed data of given size. */ - zip_uint64_t (*maximum_compressed_size)(zip_uint64_t uncompressed_size); - - /* called once to create new context */ - void *(*allocate)(zip_uint16_t method, int compression_flags, zip_error_t *error); - /* called once to free context */ - void (*deallocate)(void *ctx); - - /* get compression specific general purpose bitflags */ - zip_uint16_t (*general_purpose_bit_flags)(void *ctx); - /* minimum version needed when using this algorithm */ - zip_uint8_t version_needed; - - /* start processing */ - bool (*start)(void *ctx, zip_stat_t *st, zip_file_attributes_t *attributes); - /* stop processing */ - bool (*end)(void *ctx); - - /* provide new input data, remains valid until next call to input or end */ - bool (*input)(void *ctx, zip_uint8_t *data, zip_uint64_t length); - - /* all input data has been provided */ - void (*end_of_input)(void *ctx); - - /* process input data, writing to data, which has room for length bytes, update length to number of bytes written */ - zip_compression_status_t (*process)(void *ctx, zip_uint8_t *data, zip_uint64_t *length); -}; -typedef struct zip_compression_algorithm zip_compression_algorithm_t; - -extern zip_compression_algorithm_t zip_algorithm_bzip2_compress; -extern zip_compression_algorithm_t zip_algorithm_bzip2_decompress; -extern zip_compression_algorithm_t zip_algorithm_deflate_compress; -extern zip_compression_algorithm_t zip_algorithm_deflate_decompress; -extern zip_compression_algorithm_t zip_algorithm_xz_compress; -extern zip_compression_algorithm_t zip_algorithm_xz_decompress; -extern zip_compression_algorithm_t zip_algorithm_zstd_compress; -extern zip_compression_algorithm_t zip_algorithm_zstd_decompress; - -zip_compression_algorithm_t *_zip_get_compression_algorithm(zip_int32_t method, bool compress); - -/* This API is not final yet, but we need it internally, so it's private for now. */ - -const zip_uint8_t *zip_get_extra_field_by_id(zip_t *, int, int, zip_uint16_t, int, zip_uint16_t *); - -/* This section contains API that is of limited use until support for - user-supplied compression/encryption implementation is finished. - Thus we will keep it private for now. */ - -typedef zip_int64_t (*zip_source_layered_callback)(zip_source_t *, void *, void *, zip_uint64_t, enum zip_source_cmd); -zip_source_t *zip_source_compress(zip_t *za, zip_source_t *src, zip_int32_t cm, int compression_flags); -zip_source_t *zip_source_crc(zip_t *, zip_source_t *, int); -zip_source_t *zip_source_decompress(zip_t *za, zip_source_t *src, zip_int32_t cm); -zip_source_t *zip_source_layered(zip_t *, zip_source_t *, zip_source_layered_callback, void *); -zip_source_t *zip_source_layered_create(zip_source_t *src, zip_source_layered_callback cb, void *ud, zip_error_t *error); -zip_source_t *zip_source_pkware_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); -zip_source_t *zip_source_pkware_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); -int zip_source_remove(zip_source_t *); -zip_int64_t zip_source_supports(zip_source_t *src); -zip_source_t *zip_source_window(zip_t *, zip_source_t *, zip_uint64_t, zip_uint64_t); -// zip_source_t *zip_source_winzip_aes_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); -// zip_source_t *zip_source_winzip_aes_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); -zip_source_t *zip_source_buffer_with_attributes(zip_t *za, const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes); - -/* error source for layered sources */ - -enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL }; - -/* directory entry: general purpose bit flags */ - -#define ZIP_GPBF_ENCRYPTED 0x0001u /* is encrypted */ -#define ZIP_GPBF_DATA_DESCRIPTOR 0x0008u /* crc/size after file data */ -#define ZIP_GPBF_STRONG_ENCRYPTION 0x0040u /* uses strong encryption */ -#define ZIP_GPBF_ENCODING_UTF_8 0x0800u /* file name encoding is UTF-8 */ - - -/* extra fields */ -#define ZIP_EF_LOCAL ZIP_FL_LOCAL /* include in local header */ -#define ZIP_EF_CENTRAL ZIP_FL_CENTRAL /* include in central directory */ -#define ZIP_EF_BOTH (ZIP_EF_LOCAL | ZIP_EF_CENTRAL) /* include in both */ - -#define ZIP_FL_FORCE_ZIP64 1024 /* force zip64 extra field (_zip_dirent_write) */ - -#define ZIP_FL_ENCODING_ALL (ZIP_FL_ENC_GUESS | ZIP_FL_ENC_CP437 | ZIP_FL_ENC_UTF_8) - - -/* encoding type */ -enum zip_encoding_type { - ZIP_ENCODING_UNKNOWN, /* not yet analyzed */ - ZIP_ENCODING_ASCII, /* plain ASCII */ - ZIP_ENCODING_UTF8_KNOWN, /* is UTF-8 */ - ZIP_ENCODING_UTF8_GUESSED, /* possibly UTF-8 */ - ZIP_ENCODING_CP437, /* Code Page 437 */ - ZIP_ENCODING_ERROR /* should be UTF-8 but isn't */ -}; - -typedef enum zip_encoding_type zip_encoding_type_t; - -struct zip_hash; -struct zip_progress; - -typedef struct zip_cdir zip_cdir_t; -typedef struct zip_dirent zip_dirent_t; -typedef struct zip_entry zip_entry_t; -typedef struct zip_extra_field zip_extra_field_t; -typedef struct zip_string zip_string_t; -typedef struct zip_buffer zip_buffer_t; -typedef struct zip_hash zip_hash_t; -typedef struct zip_progress zip_progress_t; - -/* zip archive, part of API */ - -struct zip { - zip_source_t *src; /* data source for archive */ - unsigned int open_flags; /* flags passed to zip_open */ - zip_error_t error; /* error information */ - - unsigned int flags; /* archive global flags */ - unsigned int ch_flags; /* changed archive global flags */ - - char *default_password; /* password used when no other supplied */ - - zip_string_t *comment_orig; /* archive comment */ - zip_string_t *comment_changes; /* changed archive comment */ - bool comment_changed; /* whether archive comment was changed */ - - zip_uint64_t nentry; /* number of entries */ - zip_uint64_t nentry_alloc; /* number of entries allocated */ - zip_entry_t *entry; /* entries */ - - unsigned int nopen_source; /* number of open sources using archive */ - unsigned int nopen_source_alloc; /* number of sources allocated */ - zip_source_t **open_source; /* open sources using archive */ - - zip_hash_t *names; /* hash table for name lookup */ - - zip_progress_t *progress; /* progress callback for zip_close() */ -}; - -/* file in zip archive, part of API */ - -struct zip_file { - zip_t *za; /* zip archive containing this file */ - zip_error_t error; /* error information */ - bool eof; - zip_source_t *src; /* data source */ -}; - -/* zip archive directory entry (central or local) */ - -#define ZIP_DIRENT_COMP_METHOD 0x0001u -#define ZIP_DIRENT_FILENAME 0x0002u -#define ZIP_DIRENT_COMMENT 0x0004u -#define ZIP_DIRENT_EXTRA_FIELD 0x0008u -#define ZIP_DIRENT_ATTRIBUTES 0x0010u -#define ZIP_DIRENT_LAST_MOD 0x0020u -#define ZIP_DIRENT_ENCRYPTION_METHOD 0x0040u -#define ZIP_DIRENT_PASSWORD 0x0080u -#define ZIP_DIRENT_ALL ZIP_UINT32_MAX - -struct zip_dirent { - zip_uint32_t changed; - bool local_extra_fields_read; /* whether we already read in local header extra fields */ - bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */ - - bool crc_valid; /* if CRC is valid (sometimes not for encrypted archives) */ - - zip_uint16_t version_madeby; /* (c) version of creator */ - zip_uint16_t version_needed; /* (cl) version needed to extract */ - zip_uint16_t bitflags; /* (cl) general purpose bit flag */ - zip_int32_t comp_method; /* (cl) compression method used (uint16 and ZIP_CM_DEFAULT (-1)) */ - time_t last_mod; /* (cl) time of last modification */ - zip_uint32_t crc; /* (cl) CRC-32 of uncompressed data */ - zip_uint64_t comp_size; /* (cl) size of compressed data */ - zip_uint64_t uncomp_size; /* (cl) size of uncompressed data */ - zip_string_t *filename; /* (cl) file name (NUL-terminated) */ - zip_extra_field_t *extra_fields; /* (cl) extra fields, parsed */ - zip_string_t *comment; /* (c) file comment */ - zip_uint32_t disk_number; /* (c) disk number start */ - zip_uint16_t int_attrib; /* (c) internal file attributes */ - zip_uint32_t ext_attrib; /* (c) external file attributes */ - zip_uint64_t offset; /* (c) offset of local header */ - - zip_uint16_t compression_level; /* level of compression to use (never valid in orig) */ - zip_uint16_t encryption_method; /* encryption method, computed from other fields */ - char *password; /* file specific encryption password */ -}; - -/* zip archive central directory */ - -struct zip_cdir { - zip_entry_t *entry; /* directory entries */ - zip_uint64_t nentry; /* number of entries */ - zip_uint64_t nentry_alloc; /* number of entries allocated */ - - zip_uint64_t size; /* size of central directory */ - zip_uint64_t offset; /* offset of central directory in file */ - zip_string_t *comment; /* zip archive comment */ - bool is_zip64; /* central directory in zip64 format */ -}; - -struct zip_extra_field { - zip_extra_field_t *next; - zip_flags_t flags; /* in local/central header */ - zip_uint16_t id; /* header id */ - zip_uint16_t size; /* data size */ - zip_uint8_t *data; -}; - -enum zip_source_write_state { - ZIP_SOURCE_WRITE_CLOSED, /* write is not in progress */ - ZIP_SOURCE_WRITE_OPEN, /* write is in progress */ - ZIP_SOURCE_WRITE_FAILED, /* commit failed, only rollback allowed */ - ZIP_SOURCE_WRITE_REMOVED /* file was removed */ -}; -typedef enum zip_source_write_state zip_source_write_state_t; - -struct zip_source { - zip_source_t *src; - union { - zip_source_callback f; - zip_source_layered_callback l; - } cb; - void *ud; - zip_error_t error; - zip_int64_t supports; /* supported commands */ - unsigned int open_count; /* number of times source was opened (directly or as lower layer) */ - zip_source_write_state_t write_state; /* whether source is open for writing */ - bool source_closed; /* set if source archive is closed */ - zip_t *source_archive; /* zip archive we're reading from, NULL if not from archive */ - unsigned int refcount; - bool eof; /* EOF reached */ - bool had_read_error; /* a previous ZIP_SOURCE_READ reported an error */ - zip_uint64_t bytes_read; /* for sources that don't support ZIP_SOURCE_TELL. */ -}; - -#define ZIP_SOURCE_IS_OPEN_READING(src) ((src)->open_count > 0) -#define ZIP_SOURCE_IS_OPEN_WRITING(src) ((src)->write_state == ZIP_SOURCE_WRITE_OPEN) -#define ZIP_SOURCE_IS_LAYERED(src) ((src)->src != NULL) - -/* entry in zip archive directory */ - -struct zip_entry { - zip_dirent_t *orig; - zip_dirent_t *changes; - zip_source_t *source; - bool deleted; -}; - - -/* file or archive comment, or filename */ - -struct zip_string { - zip_uint8_t *raw; /* raw string */ - zip_uint16_t length; /* length of raw string */ - enum zip_encoding_type encoding; /* autorecognized encoding */ - zip_uint8_t *converted; /* autoconverted string */ - zip_uint32_t converted_length; /* length of converted */ -}; - - -/* byte array */ - -/* For performance, we usually keep 8k byte arrays on the stack. - However, there are (embedded) systems with a stack size of 12k; - for those, use malloc()/free() */ - -#ifdef ZIP_ALLOCATE_BUFFER -#define DEFINE_BYTE_ARRAY(buf, size) zip_uint8_t *buf -#define byte_array_init(buf, size) (((buf) = (zip_uint8_t *)malloc(size)) != NULL) -#define byte_array_fini(buf) (free(buf)) -#else -#define DEFINE_BYTE_ARRAY(buf, size) zip_uint8_t buf[size] -#define byte_array_init(buf, size) (1) -#define byte_array_fini(buf) ((void)0) -#endif - - -/* bounds checked access to memory buffer */ - -struct zip_buffer { - bool ok; - bool free_data; - - zip_uint8_t *data; - zip_uint64_t size; - zip_uint64_t offset; -}; - -/* which files to write in which order */ - -struct zip_filelist { - zip_uint64_t idx; - /* TODO const char *name; */ -}; - -typedef struct zip_filelist zip_filelist_t; - -struct _zip_winzip_aes; -typedef struct _zip_winzip_aes zip_winzip_aes_t; - -struct _zip_pkware_keys { - zip_uint32_t key[3]; -}; -typedef struct _zip_pkware_keys zip_pkware_keys_t; - -extern const char *const _zip_err_str[]; -extern const int _zip_nerr_str; -extern const int _zip_err_type[]; - -#define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b)) - -#define ZIP_ENTRY_CHANGED(e, f) ((e)->changes && ((e)->changes->changed & (f))) -#define ZIP_ENTRY_DATA_CHANGED(x) ((x)->source != NULL) -#define ZIP_ENTRY_HAS_CHANGES(e) (ZIP_ENTRY_DATA_CHANGED(e) || (e)->deleted || ZIP_ENTRY_CHANGED((e), ZIP_DIRENT_ALL)) - -#define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY) - - -#ifdef HAVE_EXPLICIT_MEMSET -#define _zip_crypto_clear(b, l) explicit_memset((b), 0, (l)) -#else -#ifdef HAVE_EXPLICIT_BZERO -#define _zip_crypto_clear(b, l) explicit_bzero((b), (l)) -#else -#include -#define _zip_crypto_clear(b, l) memset((b), 0, (l)) -#endif -#endif - - -zip_int64_t _zip_add_entry(zip_t *); - -zip_uint8_t *_zip_buffer_data(zip_buffer_t *buffer); -bool _zip_buffer_eof(zip_buffer_t *buffer); -void _zip_buffer_free(zip_buffer_t *buffer); -zip_uint8_t *_zip_buffer_get(zip_buffer_t *buffer, zip_uint64_t length); -zip_uint16_t _zip_buffer_get_16(zip_buffer_t *buffer); -zip_uint32_t _zip_buffer_get_32(zip_buffer_t *buffer); -zip_uint64_t _zip_buffer_get_64(zip_buffer_t *buffer); -zip_uint8_t _zip_buffer_get_8(zip_buffer_t *buffer); -zip_uint64_t _zip_buffer_left(zip_buffer_t *buffer); -zip_buffer_t *_zip_buffer_new(zip_uint8_t *data, zip_uint64_t size); -zip_buffer_t *_zip_buffer_new_from_source(zip_source_t *src, zip_uint64_t size, zip_uint8_t *buf, zip_error_t *error); -zip_uint64_t _zip_buffer_offset(zip_buffer_t *buffer); -bool _zip_buffer_ok(zip_buffer_t *buffer); -zip_uint8_t *_zip_buffer_peek(zip_buffer_t *buffer, zip_uint64_t length); -int _zip_buffer_put(zip_buffer_t *buffer, const void *src, size_t length); -int _zip_buffer_put_16(zip_buffer_t *buffer, zip_uint16_t i); -int _zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i); -int _zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i); -int _zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i); -zip_uint64_t _zip_buffer_read(zip_buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length); -int _zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length); -int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset); -zip_uint64_t _zip_buffer_size(zip_buffer_t *buffer); - -void _zip_cdir_free(zip_cdir_t *); -bool _zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error); -zip_cdir_t *_zip_cdir_new(zip_uint64_t, zip_error_t *); -zip_int64_t _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors); -time_t _zip_d2u_time(zip_uint16_t, zip_uint16_t); -void _zip_deregister_source(zip_t *za, zip_source_t *src); - -void _zip_dirent_apply_attributes(zip_dirent_t *, zip_file_attributes_t *, bool, zip_uint32_t); -zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *); -void _zip_dirent_free(zip_dirent_t *); -void _zip_dirent_finalize(zip_dirent_t *); -void _zip_dirent_init(zip_dirent_t *); -bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t); -zip_dirent_t *_zip_dirent_new(void); -zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error); -void _zip_dirent_set_version_needed(zip_dirent_t *de, bool force_zip64); -zip_int32_t _zip_dirent_size(zip_source_t *src, zip_uint16_t, zip_error_t *); -int _zip_dirent_write(zip_t *za, zip_dirent_t *dirent, zip_flags_t flags); - -zip_extra_field_t *_zip_ef_clone(const zip_extra_field_t *, zip_error_t *); -zip_extra_field_t *_zip_ef_delete_by_id(zip_extra_field_t *, zip_uint16_t, zip_uint16_t, zip_flags_t); -void _zip_ef_free(zip_extra_field_t *); -const zip_uint8_t *_zip_ef_get_by_id(const zip_extra_field_t *, zip_uint16_t *, zip_uint16_t, zip_uint16_t, zip_flags_t, zip_error_t *); -zip_extra_field_t *_zip_ef_merge(zip_extra_field_t *, zip_extra_field_t *); -zip_extra_field_t *_zip_ef_new(zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_flags_t); -bool _zip_ef_parse(const zip_uint8_t *, zip_uint16_t, zip_flags_t, zip_extra_field_t **, zip_error_t *); -zip_extra_field_t *_zip_ef_remove_internal(zip_extra_field_t *); -zip_uint16_t _zip_ef_size(const zip_extra_field_t *, zip_flags_t); -int _zip_ef_write(zip_t *za, const zip_extra_field_t *ef, zip_flags_t flags); - -void _zip_entry_finalize(zip_entry_t *); -void _zip_entry_init(zip_entry_t *); - -void _zip_error_clear(zip_error_t *); -void _zip_error_get(const zip_error_t *, int *, int *); - -void _zip_error_copy(zip_error_t *dst, const zip_error_t *src); -void _zip_error_set_from_source(zip_error_t *, zip_source_t *); - -const zip_uint8_t *_zip_extract_extra_field_by_id(zip_error_t *, zip_uint16_t, int, const zip_uint8_t *, zip_uint16_t, zip_uint16_t *); - -int _zip_file_extra_field_prepare_for_change(zip_t *, zip_uint64_t); -int _zip_file_fillbuf(void *, size_t, zip_file_t *); -zip_uint64_t _zip_file_get_end(const zip_t *za, zip_uint64_t index, zip_error_t *error); -zip_uint64_t _zip_file_get_offset(const zip_t *, zip_uint64_t, zip_error_t *); - -zip_dirent_t *_zip_get_dirent(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *); - -enum zip_encoding_type _zip_guess_encoding(zip_string_t *, enum zip_encoding_type); -zip_uint8_t *_zip_cp437_to_utf8(const zip_uint8_t *const, zip_uint32_t, zip_uint32_t *, zip_error_t *); - -bool _zip_hash_add(zip_hash_t *hash, const zip_uint8_t *name, zip_uint64_t index, zip_flags_t flags, zip_error_t *error); -bool _zip_hash_delete(zip_hash_t *hash, const zip_uint8_t *key, zip_error_t *error); -void _zip_hash_free(zip_hash_t *hash); -zip_int64_t _zip_hash_lookup(zip_hash_t *hash, const zip_uint8_t *name, zip_flags_t flags, zip_error_t *error); -zip_hash_t *_zip_hash_new(zip_error_t *error); -bool _zip_hash_reserve_capacity(zip_hash_t *hash, zip_uint64_t capacity, zip_error_t *error); -bool _zip_hash_revert(zip_hash_t *hash, zip_error_t *error); - -int _zip_mkstempm(char *path, int mode); - -zip_t *_zip_open(zip_source_t *, unsigned int, zip_error_t *); - -void _zip_progress_end(zip_progress_t *progress); -void _zip_progress_free(zip_progress_t *progress); -int _zip_progress_start(zip_progress_t *progress); -int _zip_progress_subrange(zip_progress_t *progress, double start, double end); -int _zip_progress_update(zip_progress_t *progress, double value); - -/* this symbol is extern so it can be overridden for regression testing */ -//ZIP_EXTERN bool zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length); -zip_uint32_t zip_random_uint32(void); - -int _zip_read(zip_source_t *src, zip_uint8_t *data, zip_uint64_t length, zip_error_t *error); -int _zip_read_at_offset(zip_source_t *src, zip_uint64_t offset, unsigned char *b, size_t length, zip_error_t *error); -zip_uint8_t *_zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp, zip_error_t *error); -int _zip_read_local_ef(zip_t *, zip_uint64_t); -zip_string_t *_zip_read_string(zip_buffer_t *buffer, zip_source_t *src, zip_uint16_t length, bool nulp, zip_error_t *error); -int _zip_register_source(zip_t *za, zip_source_t *src); - -void _zip_set_open_error(int *zep, const zip_error_t *err, int ze); - -bool zip_source_accept_empty(zip_source_t *src); -zip_int64_t _zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command); -bool _zip_source_eof(zip_source_t *); -zip_source_t *_zip_source_file_or_p(const char *, FILE *, zip_uint64_t, zip_int64_t, const zip_stat_t *, zip_error_t *error); -bool _zip_source_had_error(zip_source_t *); -void _zip_source_invalidate(zip_source_t *src); -zip_source_t *_zip_source_new(zip_error_t *error); -int _zip_source_set_source_archive(zip_source_t *, zip_t *); -zip_source_t *_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_uint64_t length, zip_stat_t *st, zip_file_attributes_t *attributes, zip_t *source_archive, zip_uint64_t source_index, zip_error_t *error); -zip_source_t *_zip_source_zip_new(zip_t *, zip_t *, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_uint64_t, const char *); - -int _zip_stat_merge(zip_stat_t *dst, const zip_stat_t *src, zip_error_t *error); -int _zip_string_equal(const zip_string_t *, const zip_string_t *); -void _zip_string_free(zip_string_t *); -zip_uint32_t _zip_string_crc32(const zip_string_t *); -const zip_uint8_t *_zip_string_get(zip_string_t *, zip_uint32_t *, zip_flags_t, zip_error_t *); -zip_uint16_t _zip_string_length(const zip_string_t *); -zip_string_t *_zip_string_new(const zip_uint8_t *, zip_uint16_t, zip_flags_t, zip_error_t *); -int _zip_string_write(zip_t *za, const zip_string_t *string); -bool _zip_winzip_aes_decrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length); -bool _zip_winzip_aes_encrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length); -bool _zip_winzip_aes_finish(zip_winzip_aes_t *ctx, zip_uint8_t *hmac); -void _zip_winzip_aes_free(zip_winzip_aes_t *ctx); -zip_winzip_aes_t *_zip_winzip_aes_new(const zip_uint8_t *password, zip_uint64_t password_length, const zip_uint8_t *salt, zip_uint16_t key_size, zip_uint8_t *password_verify, zip_error_t *error); - -void _zip_pkware_encrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len); -void _zip_pkware_decrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len); -zip_pkware_keys_t *_zip_pkware_keys_new(zip_error_t *error); -void _zip_pkware_keys_free(zip_pkware_keys_t *keys); -void _zip_pkware_keys_reset(zip_pkware_keys_t *keys); - -int _zip_changed(const zip_t *, zip_uint64_t *); -const char *_zip_get_name(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *); -int _zip_local_header_read(zip_t *, int); -void *_zip_memdup(const void *, size_t, zip_error_t *); -zip_int64_t _zip_name_locate(zip_t *, const char *, zip_flags_t, zip_error_t *); -zip_t *_zip_new(zip_error_t *); - -zip_int64_t _zip_file_replace(zip_t *, zip_uint64_t, const char *, zip_source_t *, zip_flags_t); -int _zip_set_name(zip_t *, zip_uint64_t, const char *, zip_flags_t); -void _zip_u2d_time(time_t, zip_uint16_t *, zip_uint16_t *); -int _zip_unchange(zip_t *, zip_uint64_t, int); -void _zip_unchange_data(zip_entry_t *); -int _zip_write(zip_t *za, const void *data, zip_uint64_t length); - -#endif /* zipint.h */ diff --git a/Include/Libraries/zlib/FAQ b/Include/Libraries/zlib/FAQ deleted file mode 100644 index 99b7cf9..0000000 --- a/Include/Libraries/zlib/FAQ +++ /dev/null @@ -1,368 +0,0 @@ - - Frequently Asked Questions about zlib - - -If your question is not there, please check the zlib home page -http://zlib.net/ which may have more recent information. -The lastest zlib FAQ is at http://zlib.net/zlib_faq.html - - - 1. Is zlib Y2K-compliant? - - Yes. zlib doesn't handle dates. - - 2. Where can I get a Windows DLL version? - - The zlib sources can be compiled without change to produce a DLL. See the - file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the - precompiled DLL are found in the zlib web site at http://zlib.net/ . - - 3. Where can I get a Visual Basic interface to zlib? - - See - * http://marknelson.us/1997/01/01/zlib-engine/ - * win32/DLL_FAQ.txt in the zlib distribution - - 4. compress() returns Z_BUF_ERROR. - - Make sure that before the call of compress(), the length of the compressed - buffer is equal to the available size of the compressed buffer and not - zero. For Visual Basic, check that this parameter is passed by reference - ("as any"), not by value ("as long"). - - 5. deflate() or inflate() returns Z_BUF_ERROR. - - Before making the call, make sure that avail_in and avail_out are not zero. - When setting the parameter flush equal to Z_FINISH, also make sure that - avail_out is big enough to allow processing all pending input. Note that a - Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be - made with more input or output space. A Z_BUF_ERROR may in fact be - unavoidable depending on how the functions are used, since it is not - possible to tell whether or not there is more output pending when - strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a - heavily annotated example. - - 6. Where's the zlib documentation (man pages, etc.)? - - It's in zlib.h . Examples of zlib usage are in the files test/example.c - and test/minigzip.c, with more in examples/ . - - 7. Why don't you use GNU autoconf or libtool or ...? - - Because we would like to keep zlib as a very small and simple package. - zlib is rather portable and doesn't need much configuration. - - 8. I found a bug in zlib. - - Most of the time, such problems are due to an incorrect usage of zlib. - Please try to reproduce the problem with a small program and send the - corresponding source to us at zlib@gzip.org . Do not send multi-megabyte - data files without prior agreement. - - 9. Why do I get "undefined reference to gzputc"? - - If "make test" produces something like - - example.o(.text+0x154): undefined reference to `gzputc' - - check that you don't have old files libz.* in /usr/lib, /usr/local/lib or - /usr/X11R6/lib. Remove any old versions, then do "make install". - -10. I need a Delphi interface to zlib. - - See the contrib/delphi directory in the zlib distribution. - -11. Can zlib handle .zip archives? - - Not by itself, no. See the directory contrib/minizip in the zlib - distribution. - -12. Can zlib handle .Z files? - - No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt - the code of uncompress on your own. - -13. How can I make a Unix shared library? - - By default a shared (and a static) library is built for Unix. So: - - make distclean - ./configure - make - -14. How do I install a shared zlib library on Unix? - - After the above, then: - - make install - - However, many flavors of Unix come with a shared zlib already installed. - Before going to the trouble of compiling a shared version of zlib and - trying to install it, you may want to check if it's already there! If you - can #include , it's there. The -lz option will probably link to - it. You can check the version at the top of zlib.h or with the - ZLIB_VERSION symbol defined in zlib.h . - -15. I have a question about OttoPDF. - - We are not the authors of OttoPDF. The real author is on the OttoPDF web - site: Joel Hainley, jhainley@myndkryme.com. - -16. Can zlib decode Flate data in an Adobe PDF file? - - Yes. See http://www.pdflib.com/ . To modify PDF forms, see - http://sourceforge.net/projects/acroformtool/ . - -17. Why am I getting this "register_frame_info not found" error on Solaris? - - After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib - generates an error such as: - - ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: - symbol __register_frame_info: referenced symbol not found - - The symbol __register_frame_info is not part of zlib, it is generated by - the C compiler (cc or gcc). You must recompile applications using zlib - which have this problem. This problem is specific to Solaris. See - http://www.sunfreeware.com for Solaris versions of zlib and applications - using zlib. - -18. Why does gzip give an error on a file I make with compress/deflate? - - The compress and deflate functions produce data in the zlib format, which - is different and incompatible with the gzip format. The gz* functions in - zlib on the other hand use the gzip format. Both the zlib and gzip formats - use the same compressed data format internally, but have different headers - and trailers around the compressed data. - -19. Ok, so why are there two different formats? - - The gzip format was designed to retain the directory information about a - single file, such as the name and last modification date. The zlib format - on the other hand was designed for in-memory and communication channel - applications, and has a much more compact header and trailer and uses a - faster integrity check than gzip. - -20. Well that's nice, but how do I make a gzip file in memory? - - You can request that deflate write the gzip format instead of the zlib - format using deflateInit2(). You can also request that inflate decode the - gzip format using inflateInit2(). Read zlib.h for more details. - -21. Is zlib thread-safe? - - Yes. However any library routines that zlib uses and any application- - provided memory allocation routines must also be thread-safe. zlib's gz* - functions use stdio library routines, and most of zlib's functions use the - library memory allocation routines by default. zlib's *Init* functions - allow for the application to provide custom memory allocation routines. - - Of course, you should only operate on any given zlib or gzip stream from a - single thread at a time. - -22. Can I use zlib in my commercial application? - - Yes. Please read the license in zlib.h. - -23. Is zlib under the GNU license? - - No. Please read the license in zlib.h. - -24. The license says that altered source versions must be "plainly marked". So - what exactly do I need to do to meet that requirement? - - You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In - particular, the final version number needs to be changed to "f", and an - identification string should be appended to ZLIB_VERSION. Version numbers - x.x.x.f are reserved for modifications to zlib by others than the zlib - maintainers. For example, if the version of the base zlib you are altering - is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and - ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also - update the version strings in deflate.c and inftrees.c. - - For altered source distributions, you should also note the origin and - nature of the changes in zlib.h, as well as in ChangeLog and README, along - with the dates of the alterations. The origin should include at least your - name (or your company's name), and an email address to contact for help or - issues with the library. - - Note that distributing a compiled zlib library along with zlib.h and - zconf.h is also a source distribution, and so you should change - ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes - in zlib.h as you would for a full source distribution. - -25. Will zlib work on a big-endian or little-endian architecture, and can I - exchange compressed data between them? - - Yes and yes. - -26. Will zlib work on a 64-bit machine? - - Yes. It has been tested on 64-bit machines, and has no dependence on any - data types being limited to 32-bits in length. If you have any - difficulties, please provide a complete problem report to zlib@gzip.org - -27. Will zlib decompress data from the PKWare Data Compression Library? - - No. The PKWare DCL uses a completely different compressed data format than - does PKZIP and zlib. However, you can look in zlib's contrib/blast - directory for a possible solution to your problem. - -28. Can I access data randomly in a compressed stream? - - No, not without some preparation. If when compressing you periodically use - Z_FULL_FLUSH, carefully write all the pending data at those points, and - keep an index of those locations, then you can start decompression at those - points. You have to be careful to not use Z_FULL_FLUSH too often, since it - can significantly degrade compression. Alternatively, you can scan a - deflate stream once to generate an index, and then use that index for - random access. See examples/zran.c . - -29. Does zlib work on MVS, OS/390, CICS, etc.? - - It has in the past, but we have not heard of any recent evidence. There - were working ports of zlib 1.1.4 to MVS, but those links no longer work. - If you know of recent, successful applications of zlib on these operating - systems, please let us know. Thanks. - -30. Is there some simpler, easier to read version of inflate I can look at to - understand the deflate format? - - First off, you should read RFC 1951. Second, yes. Look in zlib's - contrib/puff directory. - -31. Does zlib infringe on any patents? - - As far as we know, no. In fact, that was originally the whole point behind - zlib. Look here for some more information: - - http://www.gzip.org/#faq11 - -32. Can zlib work with greater than 4 GB of data? - - Yes. inflate() and deflate() will process any amount of data correctly. - Each call of inflate() or deflate() is limited to input and output chunks - of the maximum value that can be stored in the compiler's "unsigned int" - type, but there is no limit to the number of chunks. Note however that the - strm.total_in and strm_total_out counters may be limited to 4 GB. These - counters are provided as a convenience and are not used internally by - inflate() or deflate(). The application can easily set up its own counters - updated after each call of inflate() or deflate() to count beyond 4 GB. - compress() and uncompress() may be limited to 4 GB, since they operate in a - single call. gzseek() and gztell() may be limited to 4 GB depending on how - zlib is compiled. See the zlibCompileFlags() function in zlib.h. - - The word "may" appears several times above since there is a 4 GB limit only - if the compiler's "long" type is 32 bits. If the compiler's "long" type is - 64 bits, then the limit is 16 exabytes. - -33. Does zlib have any security vulnerabilities? - - The only one that we are aware of is potentially in gzprintf(). If zlib is - compiled to use sprintf() or vsprintf(), then there is no protection - against a buffer overflow of an 8K string space (or other value as set by - gzbuffer()), other than the caller of gzprintf() assuring that the output - will not exceed 8K. On the other hand, if zlib is compiled to use - snprintf() or vsnprintf(), which should normally be the case, then there is - no vulnerability. The ./configure script will display warnings if an - insecure variation of sprintf() will be used by gzprintf(). Also the - zlibCompileFlags() function will return information on what variant of - sprintf() is used by gzprintf(). - - If you don't have snprintf() or vsnprintf() and would like one, you can - find a portable implementation here: - - http://www.ijs.si/software/snprintf/ - - Note that you should be using the most recent version of zlib. Versions - 1.1.3 and before were subject to a double-free vulnerability, and versions - 1.2.1 and 1.2.2 were subject to an access exception when decompressing - invalid compressed data. - -34. Is there a Java version of zlib? - - Probably what you want is to use zlib in Java. zlib is already included - as part of the Java SDK in the java.util.zip package. If you really want - a version of zlib written in the Java language, look on the zlib home - page for links: http://zlib.net/ . - -35. I get this or that compiler or source-code scanner warning when I crank it - up to maximally-pedantic. Can't you guys write proper code? - - Many years ago, we gave up attempting to avoid warnings on every compiler - in the universe. It just got to be a waste of time, and some compilers - were downright silly as well as contradicted each other. So now, we simply - make sure that the code always works. - -36. Valgrind (or some similar memory access checker) says that deflate is - performing a conditional jump that depends on an uninitialized value. - Isn't that a bug? - - No. That is intentional for performance reasons, and the output of deflate - is not affected. This only started showing up recently since zlib 1.2.x - uses malloc() by default for allocations, whereas earlier versions used - calloc(), which zeros out the allocated memory. Even though the code was - correct, versions 1.2.4 and later was changed to not stimulate these - checkers. - -37. Will zlib read the (insert any ancient or arcane format here) compressed - data format? - - Probably not. Look in the comp.compression FAQ for pointers to various - formats and associated software. - -38. How can I encrypt/decrypt zip files with zlib? - - zlib doesn't support encryption. The original PKZIP encryption is very - weak and can be broken with freely available programs. To get strong - encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib - compression. For PKZIP compatible "encryption", look at - http://www.info-zip.org/ - -39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? - - "gzip" is the gzip format, and "deflate" is the zlib format. They should - probably have called the second one "zlib" instead to avoid confusion with - the raw deflate compressed data format. While the HTTP 1.1 RFC 2616 - correctly points to the zlib specification in RFC 1950 for the "deflate" - transfer encoding, there have been reports of servers and browsers that - incorrectly produce or expect raw deflate data per the deflate - specification in RFC 1951, most notably Microsoft. So even though the - "deflate" transfer encoding using the zlib format would be the more - efficient approach (and in fact exactly what the zlib format was designed - for), using the "gzip" transfer encoding is probably more reliable due to - an unfortunate choice of name on the part of the HTTP 1.1 authors. - - Bottom line: use the gzip format for HTTP 1.1 encoding. - -40. Does zlib support the new "Deflate64" format introduced by PKWare? - - No. PKWare has apparently decided to keep that format proprietary, since - they have not documented it as they have previous compression formats. In - any case, the compression improvements are so modest compared to other more - modern approaches, that it's not worth the effort to implement. - -41. I'm having a problem with the zip functions in zlib, can you help? - - There are no zip functions in zlib. You are probably using minizip by - Giles Vollant, which is found in the contrib directory of zlib. It is not - part of zlib. In fact none of the stuff in contrib is part of zlib. The - files in there are not supported by the zlib authors. You need to contact - the authors of the respective contribution for help. - -42. The match.asm code in contrib is under the GNU General Public License. - Since it's part of zlib, doesn't that mean that all of zlib falls under the - GNU GPL? - - No. The files in contrib are not part of zlib. They were contributed by - other authors and are provided as a convenience to the user within the zlib - distribution. Each item in contrib has its own license. - -43. Is zlib subject to export controls? What is its ECCN? - - zlib is not subject to export controls, and so is classified as EAR99. - -44. Can you please sign these lengthy legal documents and fax them back to us - so that we can use your software in our product? - - No. Go away. Shoo. diff --git a/Include/Libraries/zlib/README b/Include/Libraries/zlib/README deleted file mode 100644 index 51106de..0000000 --- a/Include/Libraries/zlib/README +++ /dev/null @@ -1,115 +0,0 @@ -ZLIB DATA COMPRESSION LIBRARY - -zlib 1.2.11 is a general purpose data compression library. All the code is -thread safe. The data format used by the zlib library is described by RFCs -(Request for Comments) 1950 to 1952 in the files -http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and -rfc1952 (gzip format). - -All functions of the compression library are documented in the file zlib.h -(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example -of the library is given in the file test/example.c which also tests that -the library is working correctly. Another example is given in the file -test/minigzip.c. The compression library itself is composed of all source -files in the root directory. - -To compile all files and run the test program, follow the instructions given at -the top of Makefile.in. In short "./configure; make test", and if that goes -well, "make install" should work for most flavors of Unix. For Windows, use -one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use -make_vms.com. - -Questions about zlib should be sent to , or to Gilles Vollant - for the Windows DLL version. The zlib home page is -http://zlib.net/ . Before reporting a problem, please check this site to -verify that you have the latest version of zlib; otherwise get the latest -version and check whether the problem still exists or not. - -PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. - -Mark Nelson wrote an article about zlib for the Jan. 1997 -issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . - -The changes made in version 1.2.11 are documented in the file ChangeLog. - -Unsupported third party contributions are provided in directory contrib/ . - -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . - -A Perl interface to zlib written by Paul Marquess is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . - -A Python interface to zlib written by A.M. Kuchling is -available in Python 1.5 and later versions, see -http://docs.python.org/library/zlib.html . - -zlib is built into tcl: http://wiki.tcl.tk/4610 . - -An experimental package to read and write files in .zip format, written on top -of zlib by Gilles Vollant , is available in the -contrib/minizip directory of zlib. - - -Notes for some targets: - -- For Windows DLL versions, please see win32/DLL_FAQ.txt - -- For 64-bit Irix, deflate.c must be compiled without any optimization. With - -O, one libpng test fails. The test works in 32 bit mode (with the -n32 - compiler flag). The compiler bug has been reported to SGI. - -- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works - when compiled with cc. - -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is - necessary to get gzprintf working correctly. This is done by configure. - -- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with - other compilers. Use "make test" to check your compiler. - -- gzdopen is not supported on RISCOS or BEOS. - -- For PalmOs, see http://palmzlib.sourceforge.net/ - - -Acknowledgments: - - The deflate format used by zlib was defined by Phil Katz. The deflate and - zlib specifications were written by L. Peter Deutsch. Thanks to all the - people who reported problems and suggested various improvements in zlib; they - are too numerous to cite here. - -Copyright notice: - - (C) 1995-2017 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - -If you use the zlib library in a product, we would appreciate *not* receiving -lengthy legal documents to sign. The sources are provided for free but without -warranty of any kind. The library has been entirely written by Jean-loup -Gailly and Mark Adler; it does not include third-party code. - -If you redistribute modified sources, we would appreciate that you include in -the file ChangeLog history information documenting your changes. Please read -the FAQ for more information on the distribution of modified source versions. diff --git a/Include/Libraries/zlib/crc32.h b/Include/Libraries/zlib/crc32.h deleted file mode 100644 index 9e0c778..0000000 --- a/Include/Libraries/zlib/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const z_crc_t FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL -#endif - } -}; diff --git a/Include/Libraries/zlib/deflate.h b/Include/Libraries/zlib/deflate.h deleted file mode 100644 index 23ecdd3..0000000 --- a/Include/Libraries/zlib/deflate.h +++ /dev/null @@ -1,349 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2016 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define Buf_size 16 -/* size of bit buffer in bi_buf */ - -#define INIT_STATE 42 /* zlib header -> BUSY_STATE */ -#ifdef GZIP -# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */ -#endif -#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */ -#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */ -#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */ -#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */ -#define BUSY_STATE 113 /* deflate -> FINISH_STATE */ -#define FINISH_STATE 666 /* stream complete */ -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - const static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - ulg pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - ulg gzindex; /* where in extra, name, or comment */ - Byte method; /* can only be DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to suppress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - uInt insert; /* bytes at end of window left to insert */ - -#ifdef ZLIB_DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - - ulg high_water; - /* High water mark offset in window for initialized bytes -- bytes above - * this are set to zero in order to avoid memory check warnings when - * longest match routines access bytes past the input. This is then - * updated to the new high water mark. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - -#define WIN_INIT MAX_MATCH -/* Number of bytes after end of data in window to initialize in order to avoid - memory checker errors from longest match routines */ - - /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef ZLIB_DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch ZLIB_INTERNAL _length_code[]; - extern uch ZLIB_INTERNAL _dist_code[]; -#else - extern const uch ZLIB_INTERNAL _length_code[]; - extern const uch ZLIB_INTERNAL _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (uch)(length); \ - ush dist = (ush)(distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ diff --git a/Include/Libraries/zlib/gzguts.h b/Include/Libraries/zlib/gzguts.h deleted file mode 100644 index 990a4d2..0000000 --- a/Include/Libraries/zlib/gzguts.h +++ /dev/null @@ -1,218 +0,0 @@ -/* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#ifdef _LARGEFILE64_SOURCE -# ifndef _LARGEFILE_SOURCE -# define _LARGEFILE_SOURCE 1 -# endif -# ifdef _FILE_OFFSET_BITS -# undef _FILE_OFFSET_BITS -# endif -#endif - -#ifdef HAVE_HIDDEN -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include -#include "zlib.h" -#ifdef STDC -# include -# include -# include -#endif - -#ifndef _POSIX_SOURCE -# define _POSIX_SOURCE -#endif -#include - -#ifdef _WIN32 -# include -#endif - -#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) -# include -#endif - -#if defined(_WIN32) || defined(__CYGWIN__) -# define WIDECHAR -#endif - -#ifdef WINAPI_FAMILY -# define open _open -# define read _read -# define write _write -# define close _close -#endif - -#ifdef NO_DEFLATE /* for compatibility with old definition */ -# define NO_GZCOMPRESS -#endif - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS -/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 -/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf -# endif -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -# ifdef VMS -# define NO_vsnprintf -# endif -# ifdef __OS400__ -# define NO_vsnprintf -# endif -# ifdef __MVS__ -# define NO_vsnprintf -# endif -#endif - -/* unlike snprintf (which is required in C99), _snprintf does not guarantee - null termination of the result -- however this is only used in gzlib.c where - the result is assured to fit in the space provided */ -#if defined(_MSC_VER) && _MSC_VER < 1900 -# define snprintf _snprintf -#endif - -#ifndef local -# define local static -#endif -/* since "static" is used to mean two completely different things in C, we - define "local" for the non-static meaning of "static", for readability - (compile with -Dlocal if your debugger can't find static symbols) */ - -/* gz* functions always use library allocation functions */ -#ifndef STDC - extern voidp malloc OF((uInt size)); - extern void free OF((voidpf ptr)); -#endif - -/* get errno and strerror definition */ -#if defined UNDER_CE -# include -# define zstrerror() gz_strwinerror((DWORD)GetLastError()) -#else -# ifndef NO_STRERROR -# include -# define zstrerror() strerror(errno) -# else -# define zstrerror() "stdio error (consult errno)" -# endif -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); -#endif - -/* default memLevel */ -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif - -/* default i/o buffer size -- double this for output when reading (this and - twice this must be able to fit in an unsigned type) */ -#define GZBUFSIZE 8192 - -/* gzip modes, also provide a little integrity check on the passed structure */ -#define GZ_NONE 0 -#define GZ_READ 7247 -#define GZ_WRITE 31153 -#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ - -/* values for gz_state how */ -#define LOOK 0 /* look for a gzip header */ -#define COPY 1 /* copy input directly */ -#define GZIP 2 /* decompress a gzip stream */ - -/* internal gzip file state data structure */ -typedef struct { - /* exposed contents for gzgetc() macro */ - struct gzFile_s x; /* "x" for exposed */ - /* x.have: number of bytes available at x.next */ - /* x.next: next output data to deliver or write */ - /* x.pos: current position in uncompressed data */ - /* used for both reading and writing */ - int mode; /* see gzip modes above */ - int fd; /* file descriptor */ - char *path; /* path or fd for error messages */ - unsigned size; /* buffer size, zero if not allocated yet */ - unsigned want; /* requested buffer size, default is GZBUFSIZE */ - unsigned char *in; /* input buffer (double-sized when writing) */ - unsigned char *out; /* output buffer (double-sized when reading) */ - int direct; /* 0 if processing gzip, 1 if transparent */ - /* just for reading */ - int how; /* 0: get header, 1: copy, 2: decompress */ - z_off64_t start; /* where the gzip data started, for rewinding */ - int eof; /* true if end of input file reached */ - int past; /* true if read requested past end */ - /* just for writing */ - int level; /* compression level */ - int strategy; /* compression strategy */ - /* seek request */ - z_off64_t skip; /* amount to skip (already rewound if backwards) */ - int seek; /* true if seek request pending */ - /* error information */ - int err; /* error code */ - char *msg; /* error message */ - /* zlib inflate or deflate stream */ - z_stream strm; /* stream structure in-place (not a pointer) */ -} gz_state; -typedef gz_state FAR *gz_statep; - -/* shared functions */ -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); -#if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); -#endif - -/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t - value -- needed when comparing unsigned to z_off64_t, which is signed - (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else -unsigned ZLIB_INTERNAL gz_intmax OF((void)); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif diff --git a/Include/Libraries/zlib/inffast.h b/Include/Libraries/zlib/inffast.h deleted file mode 100644 index e5c1aa4..0000000 --- a/Include/Libraries/zlib/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/Include/Libraries/zlib/inffixed.h b/Include/Libraries/zlib/inffixed.h deleted file mode 100644 index d628327..0000000 --- a/Include/Libraries/zlib/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. - It is part of the implementation of this library and is - subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/Include/Libraries/zlib/inflate.h b/Include/Libraries/zlib/inflate.h deleted file mode 100644 index a46cce6..0000000 --- a/Include/Libraries/zlib/inflate.h +++ /dev/null @@ -1,125 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD = 16180, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY_, /* i/o: same as COPY below, but only first time in */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN_, /* i: same as LEN below, but only first time in */ - LEN, /* i: waiting for length/lit/eob code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to BAD or MEM on error -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) or (raw) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> - HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - (raw) -> TYPEDO - Read deflate blocks: - TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK - STORED -> COPY_ -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN_ - LEN_ -> LEN - Read deflate codes in fixed or dynamic block: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* State maintained between inflate() calls -- approximately 7K bytes, not - including the allocated sliding window, which is up to 32K bytes. */ -struct inflate_state { - z_streamp strm; /* pointer back to this zlib stream */ - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip, - bit 2 true to validate check value */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ - int sane; /* if false, allow invalid distance too far */ - int back; /* bits back of last unprocessed length/lit */ - unsigned was; /* initial length of match */ -}; diff --git a/Include/Libraries/zlib/inftrees.h b/Include/Libraries/zlib/inftrees.h deleted file mode 100644 index baa53a0..0000000 --- a/Include/Libraries/zlib/inftrees.h +++ /dev/null @@ -1,62 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of the dynamic table. The maximum number of code structures is - 1444, which is the sum of 852 for literal/length codes and 592 for distance - codes. These values were found by exhaustive searches using the program - examples/enough.c found in the zlib distribtution. The arguments to that - program are the number of symbols, the initial root table size, and the - maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the - inflate_table() calls in inflate.c and infback.c. If the root table size is - changed, then these maximum sizes would be need to be recalculated and - updated. */ -#define ENOUGH_LENS 852 -#define ENOUGH_DISTS 592 -#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) - -/* Type of code to build for inflate_table() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/Include/Libraries/zlib/trees.h b/Include/Libraries/zlib/trees.h deleted file mode 100644 index d35639d..0000000 --- a/Include/Libraries/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/Include/Libraries/zlib/zconf.h b/Include/Libraries/zlib/zconf.h deleted file mode 100644 index 352f552..0000000 --- a/Include/Libraries/zlib/zconf.h +++ /dev/null @@ -1,536 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H -/* #undef Z_PREFIX */ -/* #undef Z_HAVE_UNISTD_H */ - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -#ifdef Z_SOLO - typedef unsigned long z_size_t; -#else -# define z_longlong long long -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef unsigned long z_size_t; -# endif -# undef z_longlong -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus about 7 kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/Include/Libraries/zlib/zlib.h b/Include/Libraries/zlib/zlib.h deleted file mode 100644 index f09cdaf..0000000 --- a/Include/Libraries/zlib/zlib.h +++ /dev/null @@ -1,1912 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.11, January 15th, 2017 - - Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.11" -#define ZLIB_VERNUM 0x12b0 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 11 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip and raw deflate streams in - memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in the case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - z_const Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total number of input bytes read so far */ - - Bytef *next_out; /* next output byte will go here */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total number of bytes output so far */ - - z_const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text - for deflate, or the decoding state for inflate */ - uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. In that case, zlib is thread-safe. When zalloc and zfree are - Z_NULL on entry to the initialization function, they are set to internal - routines that use the standard library functions malloc() and free(). - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use by the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field for deflate() */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary. Some output may be provided even if - flush is zero. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. See deflatePending(), - which can be used if desired to determine whether or not there is more ouput - in that case. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed - codes block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this - function must be called again with Z_FINISH and more output space (updated - avail_out) but no more input data, until it returns with Z_STREAM_END or an - error. After deflate has returned Z_STREAM_END, the only possible operations - on the stream are deflateReset or deflateEnd. - - Z_FINISH can be used in the first deflate call after deflateInit if all the - compression is to be done in a single step. In order to complete in one - call, avail_out must be at least the value returned by deflateBound (see - below). Then deflate is guaranteed to return Z_STREAM_END. If not enough - output space is provided, deflate will not return Z_STREAM_END, and it must - be called again as described above. - - deflate() sets strm->adler to the Adler-32 checksum of all input read - so far (that is, total_in bytes). If a gzip stream is being generated, then - strm->adler will be the CRC-32 checksum of the input read so far. (See - deflateInit2 below.) - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is - considered binary. This field is only for information purposes and does not - affect the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL or the state was inadvertently written over - by the application), or Z_BUF_ERROR if no progress is possible (for example - avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and - deflate() can be called again with more input and more output space to - continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. In the current version of inflate, the provided input is not - read or consumed. The allocation of a sliding window will be deferred to - the first call of inflate (if the decompression does not complete on the - first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression. - Actual decompression will be done by inflate(). So next_in, and avail_in, - next_out, and avail_out are unused and unchanged. The current - implementation of inflateInit() does not process any header information -- - that is deferred until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), then next_in and avail_in are updated - accordingly, and processing will resume at this point for the next call of - inflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. If the - caller of inflate() does not provide both available input and available - output space, it is possible that there will be no progress made. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - To assist in this, on return inflate() always sets strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all of the uncompressed data for the - operation to complete. (The size of the uncompressed data may have been - saved by the compressor for this purpose.) The use of Z_FINISH is not - required to perform an inflation in one step. However it may be used to - inform inflate that a faster approach can be used for the single inflate() - call. Z_FINISH also informs inflate to not maintain a sliding window if the - stream completes, which reduces inflate's memory footprint. If the stream - does not complete, either because not all of the stream is provided or not - enough output space is provided, then a sliding window will be allocated and - inflate() can be called again to continue the operation as if Z_NO_FLUSH had - been used. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the effects of the flush parameter in this implementation are - on the return value of inflate() as noted below, when inflate() returns early - when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of - memory for a sliding window when Z_FINISH is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the Adler-32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the Adler-32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed Adler-32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained unless inflateGetHeader() is used. When processing - gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - produced so far. The CRC-32 is checked against the gzip trailer, as is the - uncompressed length, modulo 2^32. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value, in which case strm->msg points to a string with a more specific - error), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL, or the state was inadvertently written over - by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR - if no progress was possible or if there was not enough room in the output - buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is to be attempted. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state - was inconsistent. -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - For the current implementation of deflate(), a windowBits value of 8 (a - window size of 256 bytes) is not supported. As a result, a request for 8 - will result in 9 (a 512-byte window). In that case, providing 8 to - inflateInit2() will result in an error when the zlib header with 9 is - checked against the initialization of inflate(). The remedy is to not use 8 - with deflateInit2() with this initialization, or at least in that case use 9 - with inflateInit2(). - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute a check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to the appropriate value, - if the operating system was determined at compile time. If a gzip stream is - being written, strm->adler is a CRC-32 instead of an Adler-32. - - For raw deflate or gzip encoding, a request for a 256-byte window is - rejected as invalid, since only the zlib header provides a means of - transmitting the window size to the decompressor. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. When using the zlib format, this - function must be called immediately after deflateInit, deflateInit2 or - deflateReset, and before any call of deflate. When doing raw deflate, this - function must be called either before any call of deflate, or immediately - after the completion of a deflate block, i.e. after all input has been - consumed and all output has been delivered when using any of the flush - options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The - compressor and decompressor must use exactly the same dictionary (see - inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the Adler-32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The Adler-32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - Adler-32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if not at a block boundary for raw deflate). deflateSetDictionary does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by deflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If deflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - deflateGetDictionary() may return a length less than the window size, even - when more than the window size in input has been provided. It may return up - to 258 bytes less in that case, due to how zlib's implementation of deflate - manages the sliding window and lookahead for matches, where matches can be - up to 258 bytes long. If the application needs the last window-size bytes of - input, then that would need to be saved by the application outside of zlib. - - deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, but - does not free and reallocate the internal compression state. The stream - will leave the compression level and any other attributes that may have been - set unchanged. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2(). This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression approach (which is a function of the level) or the - strategy is changed, and if any input has been consumed in a previous - deflate() call, then the input available so far is compressed with the old - level and strategy using deflate(strm, Z_BLOCK). There are three approaches - for the compression levels 0, 1..3, and 4..9 respectively. The new level - and strategy will take effect at the next call of deflate(). - - If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does - not have enough output space to complete, then the parameter change will not - take effect. In this case, deflateParams() can be called again with the - same parameters and more output space to try again. - - In order to assure a change in the parameters on the first try, the - deflate stream should be flushed using deflate() with Z_BLOCK or other flush - request until strm.avail_out is not zero, before calling deflateParams(). - Then no more input data should be provided before the deflateParams() call. - If this is done, the old level and strategy will be applied to the data - compressed before deflateParams(), and the new level and strategy will be - applied to the the data compressed after deflateParams(). - - deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream - state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if - there was not enough output space to complete the compression of the - available input data before a change in the strategy or approach. Note that - in the case of a Z_BUF_ERROR, the parameters are not changed. A return - value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be - retried with more output space. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). If that first deflate() call is provided the - sourceLen input bytes, an output buffer allocated to the size returned by - deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed - to return Z_STREAM_END. Note that it is possible for the compressed size to - be larger than the value returned by deflateBound() if flush options other - than Z_FINISH or Z_NO_FLUSH are used. -*/ - -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); -/* - deflatePending() returns the number of bytes and bits of output that have - been generated, but not yet provided in the available output. The bytes not - provided would be due to the available output space having being consumed. - The number of bits of output not provided are between 0 and 7, where they - await more bits to join them in order to fill out a full byte. If pending - or bits are Z_NULL, then those values are not set. - - deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. - */ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough - room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an Adler-32 or a CRC-32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see - below), inflate() will not automatically decode concatenated gzip streams. - inflate() will return Z_STREAM_END at the end of the gzip stream. The state - would need to be reset to continue decoding a subsequent gzip stream. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler-32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called at any - time to set the dictionary. If the provided dictionary is smaller than the - window and there is already data in the window, then the provided dictionary - will amend what's there. The application must insure that the dictionary - that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect Adler-32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by inflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If inflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a possible full flush point (see above - for the description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurrences of this - pattern are full flush points. - - inflateSync returns Z_OK if a possible full flush point has been found, - Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point - has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. If the window size is changed, then the - memory allocated for the window is freed, and the window will be reallocated - by inflate() if needed. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above, or -65536 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the parameters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is potentially more efficient than - inflate() for file i/o applications, in that it avoids copying between the - output and the sliding window by simply making the window itself the output - buffer. inflate() can be faster on modern CPUs when used with large - buffers. inflateBack() trusts the application to not change the output - buffer passed by the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the default - behavior of inflate(), which expects a zlib header and trailer around the - deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero -- buf is ignored in that - case -- and inflateBack() will return a buffer error. inflateBack() will - call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. - out() should return zero on success, or non-zero on failure. If out() - returns non-zero, inflateBack() will return with an error. Neither in() nor - out() are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: ZLIB_DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - -#ifndef Z_SOLO - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. compress() is equivalent to compress2() with a level - parameter of Z_DEFAULT_COMPRESSION. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed data. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In - the case where there is not enough room, uncompress() will fill the output - buffer with the uncompressed data up to that point. -*/ - -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen)); -/* - Same as uncompress, except that sourceLen is a pointer, where the - length of the source is *sourceLen. On return, *sourceLen is the number of - source bytes consumed. -*/ - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) 'T' will - request transparent writing or appending with no compression and not using - the gzip format. - - "a" can be used instead of "w" to request that the gzip stream that will - be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. The addition of - "x" when writing will create the file exclusively, which fails if the file - already exists. On systems that support it, the addition of "e" when - reading or writing will set the flag to close the file on an execve() call. - - These functions, as well as gzip, will read and decode a sequence of gzip - streams in a file. The append function of gzopen() can be used to create - such a file. (Also see gzflush() for another way to do this.) When - appending, gzopen does not test whether the file begins with a gzip stream, - nor does it look for the end of the gzip streams to begin appending. gzopen - will simply append a gzip stream to the existing file. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. When - reading, this will be detected automatically by looking for the magic two- - byte gzip header. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. If you are using fileno() to get the - file descriptor from a FILE *, then you will have to use dup() to avoid - double-close()ing the file descriptor. Both gzclose() and fclose() will - close the associated file descriptor, so they need to have different file - descriptors. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Three times that size in buffer space is allocated. A larger buffer - size of, for example, 64K or 128K bytes will noticeably increase the speed - of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. Previously provided - data is flushed before the parameter change. - - gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not - opened for writing, Z_ERRNO if there is an error writing the flushed data, - or Z_MEM_ERROR if there is a memory allocation error. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. If - the input file is not in gzip format, gzread copies the given number of - bytes into the buffer directly from the file. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream. Any number of gzip streams may be - concatenated in the input file, and will all be decompressed by gzread(). - If something other than a gzip stream is encountered after a gzip stream, - that remaining trailing garbage is ignored (and no error is returned). - - gzread can be used to read a gzip file that is being concurrently written. - Upon reaching the end of the input, gzread will return with the available - data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then - gzclearerr can be used to clear the end of file indicator in order to permit - gzread to be tried again. Z_OK indicates that a gzip stream was completed - on the last gzread. Z_BUF_ERROR indicates that the input file ended in the - middle of a gzip stream. Note that gzread does not return -1 in the event - of an incomplete gzip stream. This error is deferred until gzclose(), which - will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip - stream. Alternatively, gzerror can be used before gzclose to detect this - case. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. If len is too large to fit in an int, - then nothing is read, -1 is returned, and the error state is set to - Z_STREAM_ERROR. -*/ - -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, - gzFile file)); -/* - Read up to nitems items of size size from file to buf, otherwise operating - as gzread() does. This duplicates the interface of stdio's fread(), with - size_t request and return types. If the library defines size_t, then - z_size_t is identical to size_t. If not, then z_size_t is an unsigned - integer type that can contain a pointer. - - gzfread() returns the number of full items read of size size, or zero if - the end of the file was reached and a full item could not be read, or if - there was an error. gzerror() must be consulted if zero is returned in - order to determine if there was an error. If the multiplication of size and - nitems overflows, i.e. the product does not fit in a z_size_t, then nothing - is read, zero is returned, and the error state is set to Z_STREAM_ERROR. - - In the event that the end of file is reached and only a partial item is - available at the end, i.e. the remaining uncompressed data length is not a - multiple of size, then the final partial item is nevetheless read into buf - and the end-of-file flag is set. The length of the partial item read is not - provided, but could be inferred from the result of gztell(). This behavior - is the same as the behavior of fread() implementations in common libraries, - but it prevents the direct use of gzfread() to read a concurrently written - file, reseting and retrying on end-of-file, when size is not 1. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. -*/ - -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, - z_size_t nitems, gzFile file)); -/* - gzfwrite() writes nitems items of size size from buf to file, duplicating - the interface of stdio's fwrite(), with size_t request and return types. If - the library defines size_t, then z_size_t is identical to size_t. If not, - then z_size_t is an unsigned integer type that can contain a pointer. - - gzfwrite() returns the number of full items written of size size, or zero - if there was an error. If the multiplication of size and nitems overflows, - i.e. the product does not fit in a z_size_t, then nothing is written, zero - is returned, and the error state is set to Z_STREAM_ERROR. -*/ - -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or a negative zlib error code in case - of error. The number of uncompressed bytes written is limited to 8191, or - one less than the buffer size given to gzbuffer(). The caller should assure - that this limit is not exceeded. If it is exceeded, then gzprintf() will - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. - This can be determined using zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. This is implemented as a macro for speed. - As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file - points to has been clobbered or not. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatenated gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). - - When writing, gzdirect() returns true (1) if transparent writing was - requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: - gzdirect() is not needed when writing. Transparent writing must be - explicitly requested, so the application already knows the answer. When - linking statically, using gzdirect() will include all of the zlib code for - gzip file reading and decompression, which may not be desired.) -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the - last read ended in the middle of a gzip stream, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - -#endif /* !Z_SOLO */ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); -/* - Same as adler32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note - that the z_off_t type (like off_t) is a signed integer. If len2 is - negative, the result has no meaning or utility. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); -/* - Same as crc32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#ifdef Z_PREFIX_SET -# define z_deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define z_inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#else -# define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#endif - -#ifndef Z_SOLO - -/* gzgetc() macro and its supporting function and exposed data structure. Note - * that the real internal state is much larger than the exposed structure. - * This abbreviated structure exposes just enough for the gzgetc() macro. The - * user should not mess with these exposed elements, since their names or - * behavior could change in the future, perhaps even capriciously. They can - * only be used by the gzgetc() macro. You have been warned. - */ -struct gzFile_s { - unsigned have; - unsigned char *next; - z_off64_t pos; -}; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -# define z_gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#else -# define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#endif - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# ifdef Z_PREFIX_SET -# define z_gzopen z_gzopen64 -# define z_gzseek z_gzseek64 -# define z_gztell z_gztell64 -# define z_gzoffset z_gzoffset64 -# define z_adler32_combine z_adler32_combine64 -# define z_crc32_combine z_crc32_combine64 -# else -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# endif -# ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); -#endif - -#else /* Z_SOLO */ - - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - -#endif /* !Z_SOLO */ - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); -# endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/Include/Libraries/zlib/zutil.h b/Include/Libraries/zlib/zutil.h deleted file mode 100644 index b079ea6..0000000 --- a/Include/Libraries/zlib/zutil.h +++ /dev/null @@ -1,271 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#ifdef HAVE_HIDDEN -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include "zlib.h" - -#if defined(STDC) && !defined(Z_SOLO) -# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) -# include -# endif -# include -# include -#endif - -#ifdef Z_SOLO - typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ -#endif - -#ifndef local -# define local static -#endif -/* since "static" is used to mean two completely different things in C, we - define "local" for the non-static meaning of "static", for readability - (compile with -Dlocal if your debugger can't find static symbols) */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# ifndef Z_SOLO -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 1 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 2 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#ifdef __370__ -# if __TARGET_LIB__ < 0x20000000 -# define OS_CODE 4 -# elif __TARGET_LIB__ < 0x40000000 -# define OS_CODE 11 -# else -# define OS_CODE 8 -# endif -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 5 -#endif - -#ifdef OS2 -# define OS_CODE 6 -# if defined(M_I86) && !defined(Z_SOLO) -# include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 7 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif -#endif - -#ifdef __acorn -# define OS_CODE 13 -#endif - -#if defined(WIN32) && !defined(__CYGWIN__) -# define OS_CODE 10 -#endif - -#ifdef _BEOS_ -# define OS_CODE 16 -#endif - -#ifdef __TOS_OS400__ -# define OS_CODE 18 -#endif - -#ifdef __APPLE__ -# define OS_CODE 19 -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - -#if defined(__BORLANDC__) && !defined(MSDOS) - #pragma warn -8004 - #pragma warn -8008 - #pragma warn -8066 -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_WIN32) && \ - (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 3 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(pyr) || defined(Z_SOLO) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef ZLIB_DEBUG -# include - extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - -#ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); -#endif - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -/* Reverse the bytes in a 32-bit value */ -#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -#endif /* ZUTIL_H */ diff --git a/Include/Model/Classes/NMR_ImplicitNodeTypes.h b/Include/Model/Classes/NMR_ImplicitNodeTypes.h new file mode 100644 index 0000000..5fa0ad0 --- /dev/null +++ b/Include/Model/Classes/NMR_ImplicitNodeTypes.h @@ -0,0 +1,116 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#pragma once + +#include +#include +#include +#include +#include + +namespace NMR +{ + class CModelImplicitNode; + namespace implicit + { + using PortIdentifier = std::string; + + using PortMap = + std::unordered_map; + using In = PortMap; + using Out = PortMap; + + struct InputOutputRule + { + InputOutputRule(Lib3MF::eImplicitNodeConfiguration const& configuration, + In const& inputs, + Out const& outputs) + : configuration(configuration), inputs(inputs), outputs(outputs) + { + } + + Lib3MF::eImplicitNodeConfiguration configuration = Lib3MF::eImplicitNodeConfiguration::Default; + In inputs; + Out outputs; + }; + + using AllowedInputOutputs = std::vector; + + class NodeType + { + public: + NodeType(std::string const& name, + AllowedInputOutputs const& allowedInputOutputs); + + NodeType() = delete; + + std::string const& getName() const; + + AllowedInputOutputs const& getAllowedInputOutputs() const; + + Lib3MF::eImplicitNodeType getType() const; + + private: + std::string m_name; + AllowedInputOutputs m_allowedInputOutputs; + }; + + using NodeTypesMap = std::map; + + class NodeTypes + { + public: + NodeTypes(); + NodeTypes(NodeTypes const& other) = delete; + NodeTypes(NodeTypes&& other) = delete; + NodeTypes& operator=(NodeTypes const& other) = delete; + NodeTypes& operator=(NodeTypes&& other) = delete; + + NodeType const& getNodeType(Lib3MF::eImplicitNodeType type) const; + + NodeTypesMap const& getTypes() const; + + void addExpectedPortsToNode(NMR::CModelImplicitNode& node) const; + void addExpectedPortsToNode(NMR::CModelImplicitNode& node, Lib3MF::eImplicitNodeConfiguration const configuration) const; + + void applyInputOutputRuleToNode(NMR::CModelImplicitNode& node, + InputOutputRule const& rule) const; + + bool arePortsValidForNode(NMR::CModelImplicitNode const& node) const; + + private: + NodeTypesMap m_nodeTypes; + + bool arePortsValidForRule(NMR::CModelImplicitNode const& node, + InputOutputRule const& rule) const; + }; + + NodeTypes const& getNodeTypes(); + } // namespace implicit +} // namespace NMR \ No newline at end of file diff --git a/Include/Model/Classes/NMR_KeyStoreCEKParams.h b/Include/Model/Classes/NMR_KeyStoreCEKParams.h index becdeb0..1d605ef 100644 --- a/Include/Model/Classes/NMR_KeyStoreCEKParams.h +++ b/Include/Model/Classes/NMR_KeyStoreCEKParams.h @@ -42,8 +42,8 @@ namespace NMR { class CKeyStoreCEKParams { protected: - eKeyStoreEncryptAlgorithm m_eAlgorithm; nfBool m_bCompression; + eKeyStoreEncryptAlgorithm m_eAlgorithm; std::vector m_rgIv, m_rgTag, m_rgAad; nfUint64 m_nDescriptor; public: diff --git a/Include/Model/Classes/NMR_Model.h b/Include/Model/Classes/NMR_Model.h index ebb1146..21581aa 100644 --- a/Include/Model/Classes/NMR_Model.h +++ b/Include/Model/Classes/NMR_Model.h @@ -96,6 +96,27 @@ namespace NMR { typedef std::map UniqueResourceIDMapping; + class CModelImage3D; + typedef std::shared_ptr PModelImage3D; + + class CModelImageStack; + typedef std::shared_ptr PModelImageStack; + + class CModelFunction; + typedef std::shared_ptr PModelFunction; + + class CModelImplicitFunction; + typedef std::shared_ptr PModelImplicitFunction; + + class CModelFunctionFromImage3D; + typedef std::shared_ptr PModelFunctionFromImage3D; + + class CModelVolumeData; + typedef std::shared_ptr PModelVolumeData; + + class LevelSetObject; + typedef std::shared_ptr PLevelSetObject; + // The Model class implements the unification of all model-file in a 3MF package // It should be understood as a "MultiModel" class CModel { @@ -110,6 +131,7 @@ namespace NMR { CResourceHandler m_resourceHandler; private: std::vector m_Resources; + ModelResourceID m_MaxResourceId = 0; // Model Build Items std::vector m_BuildItems; @@ -147,6 +169,10 @@ namespace NMR { std::vector m_Texture2DGroupLookup; std::vector m_CompositeMaterialsLookup; std::vector m_MultiPropertyGroupLookup; + std::vector m_Image3DLookup; + std::vector m_FunctionLookup; // for implicit models + std::vector m_VolumeDataLookup; + std::vector m_levelSetObjectLookup; // The KeyStore reference PKeyStore m_pKeyStore; @@ -279,6 +305,29 @@ namespace NMR { CModelTexture2DResource * getTexture2D(_In_ nfUint32 nIndex); void mergeTextures2D(_In_ CModel * pSourceModel, _In_ UniqueResourceIDMapping &oldToNewMapping); + // Convenience functions for 3D Images + _Ret_maybenull_ PModelImage3D findImage3D(_In_ UniqueResourceID nResourceID); + _Ret_maybenull_ PModelImageStack findImageStack(_In_ UniqueResourceID nResourceID); + nfUint32 getImage3DCount(); + PModelResource getImage3DResource(_In_ nfUint32 nIndex); + CModelImage3D* getImage3D(_In_ nfUint32 nIndex); + void mergeImage3Ds(_In_ CModel* pSourceModel, _In_ UniqueResourceIDMapping& oldToNewMapping); + + // Convenience functions for Functions + PModelFunction findFunction(UniqueResourceID nResourceID); + nfUint32 getFunctionCount(); + PModelResource getFunctionResource(_In_ nfUint32 nIndex); + CModelImplicitFunction* getImplicitFunction(_In_ nfUint32 nIndex); + CModelFunctionFromImage3D* getFunctionFromImage3D(_In_ nfUint32 nIndex); + void mergeFunctions(_In_ CModel* pSourceModel, _In_ UniqueResourceIDMapping& oldToNewMapping); + + // Convenience functions for volume data + PModelVolumeData findVolumeData(UniqueResourceID nResourceID); + nfUint32 getVolumeDataCount(); + PModelResource getVolumeDataResource(_In_ nfUint32 nIndex); + CModelVolumeData* getVolumeData(_In_ nfUint32 nIndex); + + // Clear all build items and Resources void clearAll (); @@ -327,6 +376,10 @@ namespace NMR { nfBool hasCryptoRandCallbak() const; nfUint64 generateRandomBytes(nfByte *, nfUint64); + [[nodiscard]] ModelResourceID getMaxModelResourceID(); + + void removeResource(PModelResource pResource); + }; typedef std::shared_ptr PModel; diff --git a/Include/Model/Classes/NMR_ModelAttachment.h b/Include/Model/Classes/NMR_ModelAttachment.h index 758793d..2610e04 100644 --- a/Include/Model/Classes/NMR_ModelAttachment.h +++ b/Include/Model/Classes/NMR_ModelAttachment.h @@ -42,6 +42,8 @@ NMR_ModelAttachment.h defines the Model Attachment Class. namespace NMR { + typedef std::shared_ptr PModelAttachment; + class CModelAttachment { private: CModel * m_pModel; @@ -61,9 +63,10 @@ namespace NMR { void setStream(_In_ PImportStream pStream); void setRelationShipType(_In_ const std::string sRelationShipType); + + PModelAttachment cloneIntoNewModel (_In_ CModel * pModel, _In_ nfBool bCloneMemory); }; - typedef std::shared_ptr PModelAttachment; } diff --git a/Include/Model/Classes/NMR_ModelComponentsObject.h b/Include/Model/Classes/NMR_ModelComponentsObject.h index 8b4d1f0..86a2882 100644 --- a/Include/Model/Classes/NMR_ModelComponentsObject.h +++ b/Include/Model/Classes/NMR_ModelComponentsObject.h @@ -70,6 +70,8 @@ namespace NMR { void calculateComponentDepthLevel(nfUint32 nLevel) override; void extendOutbox(_Out_ NOUTBOX3& vOutBox, _In_ const NMATRIX3 mAccumulatedMatrix) override; + + ResourceDependencies getDependencies() override; }; typedef std::shared_ptr PModelComponentsObject; diff --git a/Include/Model/Classes/NMR_ModelConstants.h b/Include/Model/Classes/NMR_ModelConstants.h index 2119189..7403f0e 100644 --- a/Include/Model/Classes/NMR_ModelConstants.h +++ b/Include/Model/Classes/NMR_ModelConstants.h @@ -80,16 +80,24 @@ These are given by the 3MF Standard #define XML_3MF_NAMESPACE_MATERIALSPEC "http://schemas.microsoft.com/3dmanufacturing/material/2015/02" #define XML_3MF_NAMESPACE_PRODUCTIONSPEC "http://schemas.microsoft.com/3dmanufacturing/production/2015/06" #define XML_3MF_NAMESPACE_BEAMLATTICESPEC "http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02" +#define XML_3MF_NAMESPACE_BEAMLATTICEBALLSSPEC "http://schemas.microsoft.com/3dmanufacturing/beamlattice/balls/2020/07" +#define XML_3MF_NAMESPACE_TRIANGLESETS "http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07" #define XML_3MF_NAMESPACE_SLICESPEC "http://schemas.microsoft.com/3dmanufacturing/slice/2015/07" #define XML_3MF_NAMESPACE_SECURECONTENTSPEC "http://schemas.microsoft.com/3dmanufacturing/securecontent/2019/04" #define XML_3MF_NAMESPACE_DIGITALSIGNATURESPEC "http://www.w3.org/2000/09/xmldsig#" #define XML_3MF_NAMESPACE_CIPHERVALUESPEC "http://www.w3.org/2001/04/xmlenc#" +#define XML_3MF_NAMESPACE_VOLUMETRICSPEC "http://schemas.3mf.io/3dmanufacturing/volumetric/2022/01" +#define XML_3MF_NAMESPACE_IMPLICITSPEC "http://schemas.3mf.io/3dmanufacturing/implicit/2023/12" #define XML_3MF_NAMESPACEPREFIX_MATERIAL "m" #define XML_3MF_NAMESPACEPREFIX_PRODUCTION "p" #define XML_3MF_NAMESPACEPREFIX_BEAMLATTICE "b" +#define XML_3MF_NAMESPACEPREFIX_BEAMLATTICEBALLS "b2" #define XML_3MF_NAMESPACEPREFIX_SLICE "s" #define XML_3MF_NAMESPACEPREFIX_SECURECONTENT "sc" +#define XML_3MF_NAMESPACEPREFIX_VOLUMETRIC "v" +#define XML_3MF_NAMESPACEPREFIX_IMPLICIT "i" +#define XML_3MF_NAMESPACEPREFIX_TRIANGLESETS "t" #define XML_3MF_ATTRIBUTE_XMLNS "xmlns" #define XML_3MF_ATTRIBUTE_PREFIX_XML "xml" @@ -117,6 +125,7 @@ These are given by the 3MF Standard // Mesh element. #define XML_3MF_ELEMENT_MESH "mesh" +#define XML_3MF_ATTRIBUTE_MESH_VOLUMEDATA "volumeid" // Slices element. #define XML_3MF_ELEMENT_SLICES "slices" @@ -144,6 +153,8 @@ These are given by the 3MF Standard #define XML_3MF_ELEMENT_BEAMSET "beamset" #define XML_3MF_ELEMENT_REF "ref" #define XML_3MF_ELEMENT_BALLREF "ballref" +#define XML_3MF_ELEMENT_TRIANGLESETS "trianglesets" +#define XML_3MF_ELEMENT_TRIANGLESET "triangleset" // Triangle element. #define XML_3MF_ELEMENT_TRIANGLE "triangle" @@ -183,6 +194,9 @@ These are given by the 3MF Standard // deprecated (has been used in draft version of the specification): #define XML_3MF_ATTRIBUTE_BEAMLATTICE_ACCURACY "accuracy" #define XML_3MF_ATTRIBUTE_BEAMLATTICE_PRECISION "precision" +#define XML_3MF_ATTRIBUTE_TRIANGLESET_IDENTIFIER "identifier" +#define XML_3MF_ATTRIBUTE_TRIANGLESET_NAME "name" +#define XML_3MF_ATTRIBUTE_TRIANGLESETREF_INDEX "index" // Vertex element. #define XML_3MF_ELEMENT_VERTEX "vertex" @@ -221,6 +235,97 @@ These are given by the 3MF Standard #define XML_3MF_ELEMENT_COMPOSITE "composite" #define XML_3MF_ATTRIBUTE_COMPOSITE_VALUES "values" + +// Volumetric Extension +#define XML_3MF_ELEMENT_IMAGE3D "image3d" +#define XML_3MF_ATTRIBUTE_IMAGE3D_ID "id" +#define XML_3MF_ATTRIBUTE_IMAGE3D_NAME "name" + +#define XML_3MF_ELEMENT_IMAGESTACK "imagestack" +#define XML_3MF_ATTRIBUTE_IMAGESTACK_ROWCOUNT "rowcount" +#define XML_3MF_ATTRIBUTE_IMAGESTACK_COLUMNCOUNT "columncount" +#define XML_3MF_ATTRIBUTE_IMAGESTACK_SHEETCOUNT "sheetcount" + +#define XML_3MF_ELEMENT_IMAGESHEET "imagesheet" +#define XML_3MF_ATTRIBUTE_IMAGESHEET_PATH "path" + +#define XML_3MF_ELEMENT_VOLUMEDATA "volumedata" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_ID "id" +#define XML_3MF_ELEMENT_VOLUMETRIC_COMPOSITE "composite" +#define XML_3MF_ELEMENT_VOLUMETRIC_COLOR "color" +#define XML_3MF_ELEMENT_VOLUMETRIC_PROPERTY "property" + +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID "functionid" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_TRANSFORM "transform" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_CHANNEL "channel" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_SOLIDTHRESHOLD "solidthreshold" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE "minfeaturesize" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE "fallbackvalue" + +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY "name" +#define XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY_REQUIRED "required" + + +// Voumeteric/Implicit +#define XML_3MF_ELEMENT_IMPLICIT_FUNCTION_DEPRECATED "function" +#define XML_3MF_ELEMENT_IMPLICIT_FUNCTION "implicitfunction" + +#define XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_ID "id" +#define XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_DISPLAY_NAME "displayname" +#define XML_3MF_ELEMENT_IMPLICIT_FUNCTION_INPUT "in" +#define XML_3MF_ELEMENT_IMPLICIT_FUNCTION_OUTPUT "out" +#define XML_3MF_ELEMENT_IMPLICIT_NODE_INPUT "in" +#define XML_3MF_ELEMENT_IMPLICIT_NODE_OUTPUT "out" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VALUE "value" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_MATRIX "matrix" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_X "x" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_Y "y" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_Z "z" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_ID "identifier" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_DISPLAY_NAME "displayname" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_TAG "tag" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_RESOURCE_ID "resourceid" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_RESOURCE_ID_VALUE_DEPRECATED "resourceid" +#define XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID "identifier" +#define XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME "displayname" +#define XML_3MF_ATTRIBUTE_IMPLICIT_PORT_REFERENCE "ref" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_ACCURATERANGE "accuraterange" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_SCALAROUTPUT "scalaroutput" +#define XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VECTORINPUT "vectorinput" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR "scalar" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR "vector" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX "matrix" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_ID "resourceid" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR_REF "scalarref" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR_REF "vectorref" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX_REF "matrixref" +#define XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_REF "resourceref" + +#define XML_3MF_ELEMENT_FUNCTION_FROM_IMAGE3D "functionfromimage3d" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_IMAGE3DID "image3did" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_OFFSET "valueoffset" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_SCALE "valuescale" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_IMAGE3DID_DEPRECATED "image3dID" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_OFFSET_DEPRECATED "offset" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_SCALE_DEPRECATED "scale" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEU "tilestyleu" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEV "tilestylev" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEW "tilestylew" +#define XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_FILTER "filter" + + +#define XML_3MF_ELEMENT_BOUNDARY_SHAPE "levelset" +#define XML_3MF_ATTRIBUTE_LEVELSET_VOLUMEDATA "volumeid" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_ID "id" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_FUNCTION_ID "functionid" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_CHANNEL "channel" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_CHANNEL_DEFAULT "shape" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_TRANSFORM "transform" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MIN_FEATURE_SIZE "minfeaturesize" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MESH_BBOX_ONLY "meshbboxonly" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_FALLBACK_VALUE "fallbackvalue" +#define XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MESH_ID "meshid" + // Multiproperties #define XML_3MF_ELEMENT_MULTIPROPERTIES "multiproperties" #define XML_3MF_ATTRIBUTE_MULTIPROPERTIES_ID "id" @@ -228,6 +333,7 @@ These are given by the 3MF Standard #define XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHODS "blendmethods" #define XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MIX "mix" #define XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MULTIPLY "multiply" +#define XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MASK "mask" #define XML_3MF_ELEMENT_MULTI "multi" #define XML_3MF_ATTRIBUTE_MULTI_PINDICES "pindices" @@ -424,4 +530,8 @@ These are given by the 3MF Standard #define XML_3MF_MAXBEAMCOUNT 2147483647 #define XML_3MF_MAXBALLCOUNT 2147483647 +#ifdef __MINGW32__ +#define isNotANumber(x) ((x)!=(x)) +#endif + #endif // __NMR_MODELCONSTANTS diff --git a/Include/Model/Classes/NMR_ModelFunction.h b/Include/Model/Classes/NMR_ModelFunction.h new file mode 100644 index 0000000..ace840f --- /dev/null +++ b/Include/Model/Classes/NMR_ModelFunction.h @@ -0,0 +1,73 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelResource.h" +#include +#include + +#include +#include +#include + +namespace NMR +{ + class CModelFunction : public CModelResource + { + private: + std::string m_displayname; + + PPorts m_inputs; + PPorts m_outputs; + + public: + CModelFunction(_In_ const ModelResourceID sID, _In_ CModel* pModel); + + std::string const& getDisplayName() const; + void setDisplayName(std::string const& displayname); + + PModelImplicitPort addInput(const std::string& sPortIdentifier, + const std::string& sDisplayName, + const Lib3MF::eImplicitPortType ePortType); + + PModelImplicitPort addOutput(const std::string& sPortIdentifier, + const std::string& sDisplayName, + const Lib3MF::eImplicitPortType ePortType); + + PPorts const& getInputs() const; + PPorts const& getOutputs() const; + + PModelImplicitPort findInput(const std::string& sIdentifier) const; + PModelImplicitPort findOutput(const std::string& sIdentifier) const; + + virtual void clear(); + }; + + using PModelFunction = std::shared_ptr; +} diff --git a/Include/Model/Classes/NMR_ModelFunctionFromImage3D.h b/Include/Model/Classes/NMR_ModelFunctionFromImage3D.h new file mode 100644 index 0000000..fbd0980 --- /dev/null +++ b/Include/Model/Classes/NMR_ModelFunctionFromImage3D.h @@ -0,0 +1,91 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +CModelFunctionFromImage3D.h defines a function that can be used inside of an implicit model to access a 3D image. +--*/ +#pragma once + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Common/NMR_Types.h" + + +#include + +namespace NMR { + + class CModel; + typedef std::shared_ptr PModel; + + class CModelFunctionFromImage3D : public CModelFunction{ + + UniqueResourceID m_image3DUniqueResourceID{}; + + eModelTextureTileStyle m_tileStyleU = {}; + eModelTextureTileStyle m_tileStyleV = {}; + eModelTextureTileStyle m_tileStyleW = {}; + + eModelTextureFilter m_filter = {eModelTextureFilter::MODELTEXTUREFILTER_LINEAR}; + + double m_offset = {}; + double m_scale = {1.}; + public: + CModelFunctionFromImage3D() = delete; + CModelFunctionFromImage3D(const ModelResourceID sID, CModel * pModel); + + CModelFunctionFromImage3D(const CModelFunctionFromImage3D& other) = default; + CModelFunctionFromImage3D& operator=(const CModelFunctionFromImage3D& other) = default; + + void setImage3DUniqueResourceID(const UniqueResourceID sID); + UniqueResourceID getImage3DUniqueResourceID(); + + void setImage3DModelResourceID(const ModelResourceID sID); + ModelResourceID getImage3DModelResourceID(); + + void setTileStyleU(const eModelTextureTileStyle tileStyleU); + eModelTextureTileStyle getTileStyleU(); + + void setTileStyleV(const eModelTextureTileStyle tileStyleV); + eModelTextureTileStyle getTileStyleV(); + + void setTileStyleW(const eModelTextureTileStyle tileStyleW); + eModelTextureTileStyle getTileStyleW(); + + void setFilter(const eModelTextureFilter filter); + eModelTextureFilter getFilter(); + + void setOffset(double offset); + double getOffset(); + + void setScale(double scale); + double getScale(); + }; + + typedef std::shared_ptr PModelFunctionFromImage3D; +} + diff --git a/Include/Model/Classes/NMR_ModelImage3D.h b/Include/Model/Classes/NMR_ModelImage3D.h new file mode 100644 index 0000000..6a36090 --- /dev/null +++ b/Include/Model/Classes/NMR_ModelImage3D.h @@ -0,0 +1,69 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelImage3D.h defines a 3D image for the volumetric extension + +--*/ + +#ifndef __NMR_MODELIMAGE3D +#define __NMR_MODELIMAGE3D + +#include "Common/NMR_Types.h" + + +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_Model.h" +#include +#include "Common/Platform/NMR_ImportStream.h" +#include +#include +#include + +namespace NMR { + + class CModel; + typedef std::shared_ptr PModel; + + class CModelImage3D : public CModelResource { + private: + std::string m_sName; + + protected: + CModelImage3D(_In_ const ModelResourceID sID, _In_ CModel* pModel); + public: + CModelImage3D() = delete; + + void setName(std::string); + std::string getName() const; + }; + + typedef std::shared_ptr PModelImage3D; +} + +#endif // __NMR_MODELIMAGE3D + diff --git a/Include/Model/Classes/NMR_ModelImageStack.h b/Include/Model/Classes/NMR_ModelImageStack.h new file mode 100644 index 0000000..557892a --- /dev/null +++ b/Include/Model/Classes/NMR_ModelImageStack.h @@ -0,0 +1,80 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelImageStack.h defines an image stack for the volumetric extension + +--*/ + +#ifndef __NMR_MODELIMAGESTACK +#define __NMR_MODELIMAGESTACK + +#include +#include +#include +#include +#include "Common/NMR_Types.h" +#include "Model/Classes/NMR_ModelImage3D.h" +#include "Common/Platform/NMR_ImportStream.h" + +constexpr auto MAX_IMAGESTACK_SIZE = (1024 * 1024 * 1024); + +namespace NMR { + + class CModelImageStack : public CModelImage3D { + private: + nfUint32 m_nRowCount; + nfUint32 m_nColumnCount; + nfUint32 m_nSheetCount; + + std::vector m_Sheets; + protected: + CModelImageStack(_In_ const ModelResourceID sID, _In_ CModel* pModel, _In_ nfUint32 nRowCount, _In_ nfUint32 nColumCount, nfUint32 nSheetCount); + + public: + CModelImageStack() = delete; + + static std::shared_ptr make(_In_ const ModelResourceID sID, _In_ CModel* pModel, _In_ nfUint32 nRowCount, _In_ nfUint32 nColumCount, nfUint32 nSheetCount); + + nfUint32 getRowCount() const; + nfUint32 getColumnCount() const; + nfUint32 getSheetCount() const; + void setRowCount(nfUint32 nRowCount); + void setColumnCount(nfUint32 nColumnCount); + void setSheetCount(nfUint32 nSheetCount); + + void setSheet(nfUint32 nSheetIndex, PModelAttachment pAttachment); + PModelAttachment getSheet(nfUint32 nSheetIndex); + PModelAttachment createSheet(nfUint32 nSheetIndex, const std::string & sPath, PImportStream pCopiedStream); + }; + + typedef std::shared_ptr PModelImageStack; + +} + +#endif // __NMR_MODELIMAGESTACK + diff --git a/Include/Model/Classes/NMR_ModelImplicitFunction.h b/Include/Model/Classes/NMR_ModelImplicitFunction.h new file mode 100644 index 0000000..e3600e9 --- /dev/null +++ b/Include/Model/Classes/NMR_ModelImplicitFunction.h @@ -0,0 +1,134 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#pragma once + +#include +#include + +#include +#include +#include + +#include "Model/Classes/NMR_ModelFunction.h" + +namespace NMR +{ + using ImplicitNodes = std::vector; + using PImplicitNodes = std::shared_ptr; + + namespace implicit + { + class NodeTypes; + } + + // Extract node name (before the first dot) from a node identifier + std::string extractNodeName(const ImplicitIdentifier& sIdentifier); + + // Extract port name (after the first dot) from a node identifier + std::string extractPortName(const ImplicitIdentifier& sIdentifier); + + // Concatenate node name and port name to a reference identifier + ImplicitIdentifier makeReferenceIdentifier( + const ImplicitIdentifier& sNodeIdentifier, + const ImplicitIdentifier& sPortIdentifier); + + class CModelImplicitFunction : public CModelFunction + { + private: + ImplicitIdentifier m_identifier; + PImplicitNodes m_nodes; + static const implicit::NodeTypes m_nodeTypes; + + CModelImplicitNode* findNode( + const ImplicitIdentifier& sIdentifier) const; + + public: + CModelImplicitFunction(_In_ const ModelResourceID sID, + _In_ CModel* pModel); + + // Copy constructor + CModelImplicitFunction(const CModelImplicitFunction& other) = default; + + // Copy assignment operator + CModelImplicitFunction& operator=(const CModelImplicitFunction& other) = + default; + + ImplicitIdentifier const& getIdentifier() const; + void setIdentifier(ImplicitIdentifier const& identifier); + + PModelImplicitNode addNode(const Lib3MF::eImplicitNodeType eNodeType, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag); + + PModelImplicitNode addNode(const Lib3MF::eImplicitNodeType eNodeType, const Lib3MF::eImplicitNodeConfiguration eConfiguration); + + PImplicitNodes getNodes() const; + + void addLink(const ImplicitIdentifier& sSourceNodeIdentifier, + const ImplicitIdentifier& sTargetNodeIdentifier); + + void addLink(PModelImplicitPort pSourcePort, PModelImplicitPort pTargetPort); + + implicit::NodeTypes const& getNodeTypes() const; + + void removeNode(const ImplicitIdentifier& sIdentifier); + + void clear() override; + + /** + * @brief Replaces a resource ID with a new one. + * + * This function replaces all occurrences of the old resource ID with + * the new one. + * + * @param sOldID The old resource ID to replace. + * @param sNewID The new resource ID to use. + */ + void replaceResourceID(const ModelResourceID sOldID, + const ModelResourceID sNewID); + + /** + * @brief Topologically sorts the implicit function tree. + * + * This function performs a topological sort on the implicit function + * tree, ensuring that parent nodes are always evaluated before their + * children. + * + */ + void sortNodesTopologically(); + + PModelImplicitPort findPort(const ImplicitIdentifier& sIdentifier) const; + + ResourceDependencies getDependencies() override; + }; + + using PModelImplicitFunction = std::shared_ptr; +} // namespace NMR diff --git a/Include/Model/Classes/NMR_ModelImplicitNode.h b/Include/Model/Classes/NMR_ModelImplicitNode.h new file mode 100644 index 0000000..acaca85 --- /dev/null +++ b/Include/Model/Classes/NMR_ModelImplicitNode.h @@ -0,0 +1,141 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace NMR +{ + class CModelImplicitFunction; + + using GraphID = unsigned int; + using TopologicalOrderIndex = unsigned int; + class CModelImplicitNode + { + private: + Lib3MF::eImplicitNodeType m_type; + ImplicitIdentifier m_identifier; + std::string m_displayname; + std::string m_tag; + + PPorts m_inputs; + PPorts m_outputs; + + // Optional values for constants + double m_constant = 0.; + std::unique_ptr m_vector; + std::unique_ptr m_matrix; + + // resource ID that is unique in the scope of a model to reference mesh objects, functions etc. + ModelResourceID m_modelResourceID; + + // Attributes specific to new nodes + double m_accurateRange = 0.0; // For BeamLatticeNode + std::string m_scalarOutputName; // For FunctionGradient and NormalizeDistance + std::string m_vectorInputName; // For FunctionGradient and NormalizeDistance + + CModelImplicitFunction * m_parent = nullptr; + + // ID of the node in the graph, used for the topological sort + GraphID m_graphId = 0; + TopologicalOrderIndex m_topologicalOrderIndex = 0; + + public: + CModelImplicitNode(Lib3MF::eImplicitNodeType type, + ImplicitIdentifier const & identifier, + std::string const & displayname, + std::string const & tag, + CModelImplicitFunction * parent); + CModelImplicitNode(Lib3MF::eImplicitNodeType type, CModelImplicitFunction * parent); + + ImplicitIdentifier const & getIdentifier() const; + std::string const & getDisplayName() const; + std::string const& getTag() const; + void setIdentifier(ImplicitIdentifier const & identifier); + void setDisplayName(std::string const & displayname); + void setTag(std::string const& tag); + + void setType(Lib3MF::eImplicitNodeType type); + Lib3MF::eImplicitNodeType getNodeType() const; + + PModelImplicitPort addInput(const std::string & sIdentifier, + const std::string & sDisplayName); + + PModelImplicitPort addOutput(const std::string & sIdentifier, + const std::string & sDisplayName); + + PPorts getInputs() const; + PPorts getOutputs() const; + + PModelImplicitPort findInput(const std::string & sIdentifier) const; + PModelImplicitPort findOutput(const std::string & sIdentifier) const; + + void setConstant(double value); + double getConstant() const; + + void setVector(const Lib3MF::sVector & value); + Lib3MF::sVector getVector() const; + + + void setMatrix(const Lib3MF::sMatrix4x4 & value); + Lib3MF::sMatrix4x4 getMatrix() const; + + void setModelResourceID(ModelResourceID resourceID); + ModelResourceID getModelResourceID() const; + PModelResource getResource() const; + + // BeamLatticeNode attribute + void setAccurateRange(double accurateRange); + double getAccurateRange() const; + + // FunctionGradient and NormalizeDistance attributes + void setScalarOutputName(const std::string& name); + std::string getScalarOutputName() const; + void setVectorInputName(const std::string& name); + std::string getVectorInputName() const; + + bool arePortsValid() const; + + void setGraphID(GraphID id); + GraphID getGraphID() const; + CModelImplicitFunction * getParent() const; + void setParent(CModelImplicitFunction * parent); + }; + + using PModelImplicitNode = std::shared_ptr; +} diff --git a/Include/Model/Classes/NMR_ModelImplicitPort.h b/Include/Model/Classes/NMR_ModelImplicitPort.h new file mode 100644 index 0000000..f6a1505 --- /dev/null +++ b/Include/Model/Classes/NMR_ModelImplicitPort.h @@ -0,0 +1,90 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#pragma once + +#include +#include +#include +#include + +#include "Model/Classes/NMR_ModelImplicitPortNames.h" + + +namespace NMR +{ + + using ImplicitIdentifier = std::string; + class CModelImplicitNode; + class CModelImplicitPort; + class CModelImplicitFunction; + + class CModelImplicitPort + { + private: + CModelImplicitNode * m_parent = nullptr; + ImplicitIdentifier m_identifier; + std::string m_displayname; + Lib3MF::eImplicitPortType m_type = Lib3MF::eImplicitPortType::Scalar; + + mutable std::shared_ptr m_referencedPort; + ImplicitIdentifier m_reference; // m_reference might seem redundant, but it can be set if the dependency does not exist yet + + void updateReference() const; + + public: + CModelImplicitPort(CModelImplicitNode * parent, + ImplicitIdentifier const & identifier, + std::string const & displayname); + + CModelImplicitPort(ImplicitIdentifier const & identifier, + std::string const & displayname, + Lib3MF::eImplicitPortType type); + + ImplicitIdentifier const & getIdentifier() const; + std::string const & getDisplayName() const; + void setIdentifier(ImplicitIdentifier const & identifier); + void setDisplayName(std::string const & displayname); + + Lib3MF::eImplicitPortType getType() const; + void setType(Lib3MF::eImplicitPortType type); + + ImplicitIdentifier getReference() const; + void setReference(ImplicitIdentifier const & reference); + + CModelImplicitNode * getParent() const; + + std::shared_ptr getReferencedPort() const; + void setReferencedPort(std::shared_ptr const & referencedPort); + }; + + using PModelImplicitPort = std::shared_ptr; + + using Ports = std::vector; + using PPorts = std::shared_ptr; +} diff --git a/Include/Model/Classes/NMR_ModelImplicitPortNames.h b/Include/Model/Classes/NMR_ModelImplicitPortNames.h new file mode 100644 index 0000000..1b3fa20 --- /dev/null +++ b/Include/Model/Classes/NMR_ModelImplicitPortNames.h @@ -0,0 +1,79 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#pragma once + + +#include +#include + +namespace NMR +{ + struct InputNames + { + static auto constexpr A = "A"; + static auto constexpr B = "B"; + static auto constexpr C = "C"; + static auto constexpr D = "D"; + static auto constexpr m00 = "m00"; + static auto constexpr m01 = "m01"; + static auto constexpr m02 = "m02"; + static auto constexpr m03 = "m03"; + static auto constexpr m10 = "m10"; + static auto constexpr m11 = "m11"; + static auto constexpr m12 = "m12"; + static auto constexpr m13 = "m13"; + static auto constexpr m20 = "m20"; + static auto constexpr m21 = "m21"; + static auto constexpr m22 = "m22"; + static auto constexpr m23 = "m23"; + static auto constexpr m30 = "m30"; + static auto constexpr m31 = "m31"; + static auto constexpr m32 = "m32"; + static auto constexpr m33 = "m33"; + static auto constexpr x = "x"; + static auto constexpr y = "y"; + static auto constexpr z = "z"; + static auto constexpr pos = "pos"; + static auto constexpr mesh = "mesh"; + static auto constexpr color = "color"; + static auto constexpr min = "min"; + static auto constexpr max = "max"; + static auto constexpr functionID = "functionID"; + }; + + struct OutputNames + { + static auto constexpr result = "result"; + static auto constexpr value = "value"; + static auto constexpr vector = "vector"; + static auto constexpr matrix = "matrix"; + static auto constexpr color = "color"; + static auto constexpr distance = "distance"; + }; +} diff --git a/Include/Model/Classes/NMR_ModelLevelSetObject.h b/Include/Model/Classes/NMR_ModelLevelSetObject.h new file mode 100644 index 0000000..6a8832b --- /dev/null +++ b/Include/Model/Classes/NMR_ModelLevelSetObject.h @@ -0,0 +1,116 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelLevelSetObject.cpp implements the Model LevelSet Object Class. +A model levelset object is an in memory representation of the 3MF +levelset object. + +--*/ + +#ifndef __NMR_ModelLevelSetObject +#define __NMR_ModelLevelSetObject + +#include "Model/Classes/NMR_ModelObject.h" + +#include + +namespace NMR { + + class CModel; + typedef std::shared_ptr PModel; + + class CModelVolumeData; + typedef std::shared_ptr PModelVolumeData; + + class CModelMeshObject; + typedef std::shared_ptr PModelMeshObject; + + class CModelFunction; + typedef std::shared_ptr PModelFunction; + + class CModelLevelSetObject : public CModelObject { + private: + PModelMeshObject m_pMesh; + PModelFunction m_pFunction; + PModelVolumeData m_pVolumeData; + + std::string m_outputPortName; + NMR::NMATRIX3 m_transform = NMR::fnMATRIX3_identity(); + bool m_bHasTransform = false; + double m_minFeatureSize = 0.0; + double m_fallBackValue = 0.0; + bool m_meshBBoxOnly = false; + public: + CModelLevelSetObject() = delete; + CModelLevelSetObject(const ModelResourceID sID, CModel * pModel); + ~CModelLevelSetObject(); + + void mergeToMesh(_In_ CMesh* pMesh, + _In_ const NMATRIX3 mMatrix) override; + + nfBool isValid() override; + nfBool hasSlices(nfBool bRecursive) override; + nfBool isValidForSlices( + const NMATRIX3& totalParentMatrix) override; + void extendOutbox(_Out_ NOUTBOX3& vOutBox, + _In_ const NMATRIX3 + mAccumulatedMatrix) override; + + PModelMeshObject getMesh(); + void setMesh(PModelMeshObject pMesh); + + PModelFunction getFunction(); + void setFunction(PModelFunction pFunction); + + PModelVolumeData getVolumeData(); + void setVolumeData(_In_ PModelVolumeData pVolumeData); + + void setChannelName(std::string outputPortName); + std::string const& getChannelName() const; + + void setTransform(NMR::NMATRIX3 transform); + NMR::NMATRIX3 getTransform() const; + bool hasTransform() const; + + void setMinFeatureSize(double minFeatureSize); + double getMinFeatureSize() const; + + void setFallBackValue(double fallBackValue); + double getFallBackValue() const; + + void setMeshBBoxOnly(bool bMeshBBoxOnly); + bool getMeshBBoxOnly() const; + + ResourceDependencies getDependencies() override; + }; + + typedef std::shared_ptr PModelLevelSetObject; + +} + +#endif // __NMR_ModelLevelSetObject diff --git a/Include/Model/Classes/NMR_ModelMeshObject.h b/Include/Model/Classes/NMR_ModelMeshObject.h index b040a46..cc0ce6b 100644 --- a/Include/Model/Classes/NMR_ModelMeshObject.h +++ b/Include/Model/Classes/NMR_ModelMeshObject.h @@ -35,8 +35,10 @@ mesh object. #ifndef __NMR_MODELMESHOBJECT #define __NMR_MODELMESHOBJECT -#include "Common/Mesh/NMR_Mesh.h" +#include "Common/Mesh/NMR_Mesh.h" +#include "Model/Classes/NMR_ModelVolumeData.h" #include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" #include "Model/Classes/NMR_ModelMeshBeamLatticeAttributes.h" namespace NMR { @@ -50,7 +52,13 @@ namespace NMR { class CModelMeshObject : public CModelObject { private: PMesh m_pMesh; + + PModelVolumeData m_pVolumeData; PModelMeshBeamLatticeAttributes m_pBeamLatticeAttributes; + + std::map m_TriangleSetMap; + std::vector m_TriangleSets; + public: CModelMeshObject() = delete; CModelMeshObject(_In_ const ModelResourceID sID, _In_ CModel * pModel); @@ -80,6 +88,18 @@ namespace NMR { void extendOutbox(_Out_ NOUTBOX3& vOutBox, _In_ const NMATRIX3 mAccumulatedMatrix) override; + _Ret_notnull_ PModelVolumeData getVolumeData(); + void setVolumeData(_In_ PModelVolumeData pVolumeData); + + ResourceDependencies getDependencies() override; + void deleteTriangleSet (_In_ CModelTriangleSet * pTriangleSet); + PModelTriangleSet addTriangleSet(const std::string& sIdentifier, const std::string& sName); + PModelTriangleSet addTriangleSet(PModelTriangleSet pModelTriangleSet); + PModelTriangleSet findTriangleSet (const std::string & sIdentifier); + uint32_t getTriangleSetCount(); + PModelTriangleSet getTriangleSet(const uint32_t nIndex); + + }; typedef std::shared_ptr PModelMeshObject; diff --git a/Include/Model/Classes/NMR_ModelObject.h b/Include/Model/Classes/NMR_ModelObject.h index 8195083..7d64f75 100644 --- a/Include/Model/Classes/NMR_ModelObject.h +++ b/Include/Model/Classes/NMR_ModelObject.h @@ -118,7 +118,6 @@ namespace NMR { virtual void calculateComponentDepthLevel (nfUint32 nLevel); virtual void extendOutbox(_Out_ NOUTBOX3& vOutBox, _In_ const NMATRIX3 mAccumulatedMatrix) = 0; - }; typedef std::shared_ptr PModelObject; diff --git a/Include/Model/Classes/NMR_ModelResource.h b/Include/Model/Classes/NMR_ModelResource.h index 95eef8e..54b96e9 100644 --- a/Include/Model/Classes/NMR_ModelResource.h +++ b/Include/Model/Classes/NMR_ModelResource.h @@ -41,9 +41,12 @@ resource object. #include "Model/Classes/NMR_Model.h" #include +#include namespace NMR { + using ResourceDependencies = std::vector; + class CModelResource { private: CModel * m_pModel; @@ -52,15 +55,14 @@ namespace NMR { protected: std::vector m_ResourceIndexMap; nfBool m_bHasResourceIndexMap; - CModel * Model(); - + CModel * Model(); public: CModelResource() = delete; // CModelResource(_In_ const PPackageResourceID sResourceID, _In_ CModel * pModel); CModelResource(_In_ const ModelResourceID sResourceID, _In_ CModel * pModel); virtual ~CModelResource(); - virtual PPackageResourceID getPackageResourceID(); + PPackageResourceID getPackageResourceID(); void setPackageResourceID(PPackageResourceID pID); bool mapResourceIndexToPropertyID (_In_ ModelResourceIndex nPropertyIndex, _Out_ ModelPropertyID & nPropertyID); @@ -69,6 +71,11 @@ namespace NMR { nfBool hasResourceIndexMap(); _Ret_notnull_ CModel * getModel(); + void setModel(CModel * pModel); + + /// Returns all dependencies of this resource, usd for topological sorting during writing + virtual ResourceDependencies getDependencies(); + }; typedef std::shared_ptr PModelResource; diff --git a/Include/Model/Classes/NMR_ModelSliceStack.h b/Include/Model/Classes/NMR_ModelSliceStack.h index 2c64a44..fb3a9f4 100644 --- a/Include/Model/Classes/NMR_ModelSliceStack.h +++ b/Include/Model/Classes/NMR_ModelSliceStack.h @@ -41,6 +41,8 @@ A Model Slice Stack represents a ordered list of slices. #include +#define LIB3MF_MAXSLICEREFERENCES (1UL << 31) + namespace NMR { diff --git a/Include/Model/Classes/NMR_ModelTriangleSet.h b/Include/Model/Classes/NMR_ModelTriangleSet.h new file mode 100644 index 0000000..111a56a --- /dev/null +++ b/Include/Model/Classes/NMR_ModelTriangleSet.h @@ -0,0 +1,84 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELTRIANGLESET +#define __NMR_MODELTRIANGLESET + +#include "Common/NMR_Types.h" + +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_Model.h" +#include "Common/Platform/NMR_ImportStream.h" +#include + + +namespace NMR { + + class CModelTriangleSet; + typedef std::shared_ptr PModelTriangleSet; + + class CModelTriangleSet { + private: + + std::string m_sName; + std::string m_sIdentifier; + + std::set m_sTriangles; + + protected: + + + public: + CModelTriangleSet(_In_ const std::string& sName, _In_ const std::string& sIdentifier); + + CModelTriangleSet() = delete; + + static PModelTriangleSet make(_In_ const std::string & sName, _In_ const std::string & sIdentifier); + + std::string getName (); + std::string getIdentifier (); + + void setName (_In_ const std::string & sName); + void setIdentifier (_In_ const std::string & sIdentifier); + + void clear(); + void addTriangle(const uint32_t nTriangleIndex); + void removeTriangle(const uint32_t nTriangleIndex); + + PModelTriangleSet duplicate(const std::string & sIdentifier); + void merge (PModelTriangleSet pTriangleSet); + + std::set & getTriangles (); + + }; + +} + +#endif // __NMR_MODELTRIANGLESET + + diff --git a/Include/Model/Classes/NMR_ModelTypes.h b/Include/Model/Classes/NMR_ModelTypes.h index a63ea06..6c1fec4 100644 --- a/Include/Model/Classes/NMR_ModelTypes.h +++ b/Include/Model/Classes/NMR_ModelTypes.h @@ -79,8 +79,8 @@ namespace NMR { }; typedef struct MODELMESHBEAM { - DWORD m_nIndices[2]; - DOUBLE m_dRadius[2]; // the radius of end 0 or 1 of this beam + DWORD m_nIndices[2] = {0,0}; + DOUBLE m_dRadius[2] = { 1.,1. }; // the radius of end 0 or 1 of this beam eModelBeamLatticeCapMode m_eCapMode[2]; MODELMESHBEAM() { m_eCapMode[0] = MODELBEAMLATTICECAPMODE_SPHERE; @@ -89,16 +89,12 @@ namespace NMR { } MODELMESHBEAM; typedef struct MODELMESHBALL { - DWORD m_nIndex; - DOUBLE m_dRadius; // the radius of this ball + DWORD m_nIndex = 0; + DOUBLE m_dRadius = 1.; // the radius of this ball MODELMESHBALL() { } } MODELMESHBALL; - typedef struct { - FLOAT m_fFields[3][4]; - } MODELTRANSFORM; - typedef struct { BYTE m_Red; BYTE m_Green; @@ -124,9 +120,9 @@ namespace NMR { #pragma pack() typedef DWORD ModelPropertyID; - typedef DWORD ModelResourceID; - typedef DWORD UniqueResourceID; - typedef DWORD ModelResourceIndex; + typedef DWORD ModelResourceID; // Resource ID unique within a model, the id that you actually see as id in the xml + typedef DWORD UniqueResourceID; // Resource ID unique within a package, handled internally to allow access to resources across models + typedef DWORD ModelResourceIndex; //TODO: Add explanation enum eModelUnit { MODELUNIT_MICROMETER = 0, @@ -173,9 +169,29 @@ namespace NMR { }; enum eModelBlendMethod { - MODELBLENDMETHOD_NONE = 0, - MODELBLENDMETHOD_MIX = 1, - MODELBLENDMETHOD_MULTIPLY = 2 + MODELBLENDMETHOD_MIX = 0, + MODELBLENDMETHOD_MULTIPLY = 1, + MODELBLENDMETHOD_MASK = 2 + }; + + enum eModelColorChannel { + MODELCOLORCHANNEL_RED = 0, + MODELCOLORCHANNEL_GREEN = 1, + MODELCOLORCHANNEL_BLUE = 2, + MODELCOLORCHANNEL_ALPHA = 3 + }; + + enum class eModelCompositionMethod { + MODELCOMPOSITIONMETHOD_WEIGHTEDSUM = 0, + MODELCOMPOSITIONMETHOD_MULTIPLY= 1, + MODELCOMPOSITIONMETHOD_MIN = 2, + MODELCOMPOSITIONMETHOD_MAX = 3, + MODELCOMPOSITIONMETHOD_MASK = 4 + }; + + enum class eModelCompositionSpace { + MODELCOMPOSITIONSPACE_RAW = 0, + MODELCOMPOSITIONSPACE_LINEARCOLOR = 1 }; typedef struct { @@ -191,7 +207,6 @@ namespace NMR { UniqueResourceID m_nUniqueResourceID; eModelBlendMethod m_nMethod; } MODELMULTIPROPERTYLAYER; - } #endif // __NMR_MODELTYPES diff --git a/Include/Model/Classes/NMR_ModelVolumeData.h b/Include/Model/Classes/NMR_ModelVolumeData.h new file mode 100644 index 0000000..e7065bf --- /dev/null +++ b/Include/Model/Classes/NMR_ModelVolumeData.h @@ -0,0 +1,92 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeData.h defines the class CVolumeData. + +--*/ + +#ifndef __NMR_VOLUMEDATA +#define __NMR_VOLUMEDATA + +#include "Common/NMR_Types.h" +#include "Common/Math/NMR_Geometry.h" +#include "Common/Mesh/NMR_MeshTypes.h" + +#include "Common/Mesh/NMR_VolumeDataColor.h" +#include "Common/Mesh/NMR_VolumeDataProperty.h" +#include "Common/Mesh/NMR_VolumeDataComposite.h" +#include "Model/Classes/NMR_ModelResource.h" + +namespace NMR { + class CModelFunction; + typedef std::shared_ptr PModelFunction; + + class CModelVolumeData : public CModelResource { + private: + PVolumeDataComposite m_pComposite; + PVolumeDataColor m_pColor; + std::map m_mapProperties; + public: + CModelVolumeData() = delete; + CModelVolumeData(ModelResourceID sResourceID, + CModel* pModel); + + void clear(); + + nfBool hasProperty(std::string sName); + nfUint32 getPropertyCount() const; + PVolumeDataProperty getProperty(nfUint32 nIndex); + PVolumeDataProperty findProperty(std::string sName); + void addProperty(PVolumeDataProperty pProperty); + PVolumeDataProperty addProperty(std::string sName, + PModelFunction pfunction); + void removeProperty(std::string sName); + + bool hasColor() const; + PVolumeDataColor getColor(); + PVolumeDataColor createColor(PModelFunction pfunction); + void setColor(PVolumeDataColor pColor); + void removeColor(); + + bool hasComposite() const; + PVolumeDataComposite getComposite(); + PVolumeDataComposite createComposite(/* basematerialgroupd*/); + void setComposite(PVolumeDataComposite pComposite); + void removeComposite(); + + ResourceDependencies getDependencies() override; + + PPackageResourceID packageResourceIDFromResourceID( + UniqueResourceID uniqueResourceID); + }; + + typedef std::shared_ptr PModelVolumeData; + +} + +#endif // __NMR_BEAMLATTICE diff --git a/Include/Model/Reader/NMR_ModelReaderNode_KeyStoreBase.h b/Include/Model/Reader/NMR_ModelReaderNode_KeyStoreBase.h index 6b076bd..bbff6d9 100644 --- a/Include/Model/Reader/NMR_ModelReaderNode_KeyStoreBase.h +++ b/Include/Model/Reader/NMR_ModelReaderNode_KeyStoreBase.h @@ -42,8 +42,8 @@ namespace NMR { class CModelReaderNode_KeyStoreBase : public CModelReaderNode { protected: - CKeyStore * const m_pKeyStore; CModel * const m_pModel; + CKeyStore * const m_pKeyStore; public: CModelReaderNode_KeyStoreBase() = delete; diff --git a/Include/Model/Reader/NMR_ModelReaderNode_StringValue.h b/Include/Model/Reader/NMR_ModelReaderNode_StringValue.h index 2fc74e2..2a2e515 100644 --- a/Include/Model/Reader/NMR_ModelReaderNode_StringValue.h +++ b/Include/Model/Reader/NMR_ModelReaderNode_StringValue.h @@ -57,4 +57,3 @@ namespace NMR { } #endif // __NMR_MODELREADERNODE_KEYSTOREKEYVALUE - diff --git a/Include/Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h b/Include/Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h new file mode 100644 index 0000000..42fff50 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h @@ -0,0 +1,55 @@ + + +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Coverter for PortType + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelConstants.h" +#include "lib3mf_types.hpp" + +#include + +namespace NMR +{ + + namespace implicit + { + const char * portTypeToRefName(Lib3MF::eImplicitPortType type); + + const char * portTypeToName(Lib3MF::eImplicitPortType type); + + bool portTypeFromRefName(std::string const & name, Lib3MF::eImplicitPortType & resultType); + + bool portTypeFromName(std::string const & name, Lib3MF::eImplicitPortType & resultType); + + } +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.h new file mode 100644 index 0000000..e50cf8d --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.h @@ -0,0 +1,74 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for FunctionFromImage3D + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "Model/Classes/NMR_ModelFunctionFromImage3D.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR +{ + class CModelReaderNode_FunctionFromImage3D : public CModelReaderNode + { + private: + PModelFunctionFromImage3D m_pFunctionFromImage3D; + CModel * m_pModel = nullptr; + + ModelResourceID m_nID = 0; + ModelResourceID m_imageModelResourceID = 0; + + std::string m_displayName; + + eModelTextureTileStyle m_tileStyleU = {}; + eModelTextureTileStyle m_tileStyleV = {}; + eModelTextureTileStyle m_tileStyleW = {}; + + eModelTextureFilter m_filter = {eModelTextureFilter::MODELTEXTUREFILTER_LINEAR}; + + double m_offset = {}; + double m_scale = {1.}; + + public: + CModelReaderNode_FunctionFromImage3D() = delete; + CModelReaderNode_FunctionFromImage3D(_In_ CModel * pModel, _In_ PModelWarnings pWarnings); + + void parseXML(_In_ CXmlReader * pXMLReader) override; + + void OnAttribute(_In_z_ const nfChar * pAttributeName, + _In_z_ const nfChar * pAttributeValue) override; + + }; + + typedef std::shared_ptr + PModelReaderNode_FunctionFromImage3D; + +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.h new file mode 100644 index 0000000..0d2853f --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.h @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for implicit function ressources + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ImplicitNodeTypes.h" + +namespace NMR +{ + class CModelReaderNode_ImplicitFunction : public CModelReaderNode + { + private: + PModelImplicitFunction m_pImplicitFunction; + CModel * m_pModel = nullptr; + + ModelResourceID m_nID = 0; + + std::string m_displayName; + const static implicit::NodeTypes m_nodeTypes; + + public: + CModelReaderNode_ImplicitFunction() = delete; + CModelReaderNode_ImplicitFunction(_In_ CModel * pModel, _In_ PModelWarnings pWarnings); + + void parseXML(_In_ CXmlReader * pXMLReader) override; + + void OnAttribute(_In_z_ const nfChar * pAttributeName, + _In_z_ const nfChar * pAttributeValue) override; + + void OnNSChildElement(_In_z_ const nfChar * pChildName, + _In_z_ const nfChar * pNameSpace, + _In_ CXmlReader * pXMLReader) override; + + + }; + + typedef std::shared_ptr PModelReaderNode_ImplicitFunction; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.h new file mode 100644 index 0000000..8e7f3e0 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.h @@ -0,0 +1,63 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for a single input of a function for implicit modelling + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR +{ + class CModelReaderNode_Implicit_Function_Input : public CModelReaderNode + { + private: + CModelImplicitFunction * m_pParentFunction; + + std::string m_identifier; + std::string m_displayName; + std::string m_reference; + Lib3MF::eImplicitPortType m_portType; + void createInput(); + + public: + CModelReaderNode_Implicit_Function_Input() = delete; + CModelReaderNode_Implicit_Function_Input(CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings, + Lib3MF::eImplicitPortType portType); + + void parseXML(CXmlReader * pXMLReader) override; + + void OnAttribute(const nfChar * pAttributeName, const nfChar * pAttributeValue) override; + }; + + typedef std::shared_ptr + PModelReaderNode_Implicit_Function_Input; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.h new file mode 100644 index 0000000..ddb843d --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.h @@ -0,0 +1,60 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for ports of a function for implicit modelling + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + + +namespace NMR +{ + + class CModelReaderNode_Implicit_Function_Inputs : public CModelReaderNode + { + private: + CModelImplicitFunction * m_pImplicitFunction; + + public: + CModelReaderNode_Implicit_Function_Inputs() = delete; + CModelReaderNode_Implicit_Function_Inputs(CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings); + + void parseXML(CXmlReader * pXMLReader) override; + + void OnNSChildElement(const nfChar * pChildName, + const nfChar * pNameSpace, + CXmlReader * pXMLReader) override; + }; + + typedef std::shared_ptr + PModelReaderNode_Implicit_Function_Inputs; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.h new file mode 100644 index 0000000..8a891e6 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.h @@ -0,0 +1,64 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for an output element + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR +{ + class CModelReaderNode_Implicit_Function_Output : public CModelReaderNode + { + private: + CModelImplicitFunction * m_pParentFunction; + + std::string m_identifier; + std::string m_displayName; + std::string m_reference; + Lib3MF::eImplicitPortType m_portType; + void createOutput(); + public: + CModelReaderNode_Implicit_Function_Output() = delete; + CModelReaderNode_Implicit_Function_Output(CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings, + Lib3MF::eImplicitPortType portType + ); + + void parseXML(CXmlReader * pXMLReader) override; + + void OnAttribute(const nfChar * pAttributeName, const nfChar * pAttributeValue) override; + + + }; + + typedef std::shared_ptr PModelReaderNode_Implicit_Function_Output; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.h new file mode 100644 index 0000000..356be17 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.h @@ -0,0 +1,60 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for inputs (arguments) of a function for implicit modelling + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + + +namespace NMR +{ + + class CModelReaderNode_Implicit_Function_Outputs : public CModelReaderNode + { + private: + CModelImplicitFunction * m_pImplicitFunction; + + public: + CModelReaderNode_Implicit_Function_Outputs() = delete; + CModelReaderNode_Implicit_Function_Outputs(CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings); + + void parseXML(CXmlReader * pXMLReader) override; + + void OnNSChildElement(const nfChar * pChildName, + const nfChar * pNameSpace, + CXmlReader * pXMLReader) override; + }; + + typedef std::shared_ptr + PModelReaderNode_Implicit_Function_Outputs; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.h new file mode 100644 index 0000000..af82ab5 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.h @@ -0,0 +1,65 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for nodes of graph representing a function for implicit modelling + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitNode.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR +{ + class CModelReaderNode_Implicit_Node : public CModelReaderNode + { + private: + CModelImplicitNode * m_pImplicitNode; + CModel * m_pModel; + + double m_value; + Lib3MF::sVector m_vector; + public: + CModelReaderNode_Implicit_Node() = delete; + CModelReaderNode_Implicit_Node(_In_ CModel * pModel, + _In_ CModelImplicitNode * pImplicitNode, + _In_ PModelWarnings pWarnings); + + void parseXML(_In_ CXmlReader * pXMLReader) override; + + void OnAttribute(_In_z_ const nfChar * pAttributeName, + _In_z_ const nfChar * pAttributeValue) override; + + void OnNSChildElement(_In_z_ const nfChar * pChildName, + _In_z_ const nfChar * pNameSpace, + _In_ CXmlReader * pXMLReader) override; + }; + + typedef std::shared_ptr + PModelReaderNode_Implicit_Node; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.h new file mode 100644 index 0000000..a7ca933 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.h @@ -0,0 +1,59 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for ports of a node of a graph representing a function for implicit modelling + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitNode.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR +{ + + class CModelReaderNode_Implicit_Node_Inputs : public CModelReaderNode + { + private: + CModelImplicitNode * m_pImplicitNode; + + public: + CModelReaderNode_Implicit_Node_Inputs() = delete; + CModelReaderNode_Implicit_Node_Inputs(_In_ CModelImplicitNode * pParentNode, + _In_ PModelWarnings pWarnings + ); + + void parseXML(_In_ CXmlReader * pXMLReader) override; + + void OnNSChildElement(_In_z_ const nfChar * pChildName, + _In_z_ const nfChar * pNameSpace, + _In_ CXmlReader * pXMLReader) override; + }; + + typedef std::shared_ptr PModelReaderNode_Implicit_Node_Inputs; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.h new file mode 100644 index 0000000..a343a1b --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.h @@ -0,0 +1,59 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for output ports of a node + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitNode.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR +{ + + class CModelReaderNode_Implicit_Node_Outputs : public CModelReaderNode + { + private: + CModelImplicitNode * m_pImplicitNode; + + public: + CModelReaderNode_Implicit_Node_Outputs() = delete; + CModelReaderNode_Implicit_Node_Outputs(_In_ CModelImplicitNode * pParentNode, + _In_ PModelWarnings pWarnings + ); + + void parseXML(_In_ CXmlReader * pXMLReader) override; + + void OnNSChildElement(_In_z_ const nfChar * pChildName, + _In_z_ const nfChar * pNameSpace, + _In_ CXmlReader * pXMLReader) override; + }; + + typedef std::shared_ptr PModelReaderNode_Implicit_Node_Outputs; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.h new file mode 100644 index 0000000..5a71b7b --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for a single port of a node of a graph representing a function for implicit modelling + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ModelImplicitNode.h" +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR +{ + + enum class ImplicitPortInOut + { + Input, + Output + }; + + + class CModelReaderNode_Implicit_Port : public CModelReaderNode + { + private: + CModelImplicitNode * m_pParentNode; + + std::string m_identifier; + std::string m_displayName; + std::string m_reference; + Lib3MF::eImplicitPortType m_portType; + ImplicitPortInOut m_inOut; + + + public: + CModelReaderNode_Implicit_Port() = delete; + CModelReaderNode_Implicit_Port(CModelImplicitNode * pParentNode, + PModelWarnings pWarnings, + Lib3MF::eImplicitPortType portType, + ImplicitPortInOut inOut); + + void parseXML(CXmlReader * pXMLReader) override; + + void OnAttribute(const nfChar * pAttributeName, const nfChar * pAttributeValue) override; + + void createInput(); + void createOutput(); + }; + + typedef std::shared_ptr PModelReaderNode_Implicit_Port; +} \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.h new file mode 100644 index 0000000..102c0cc --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for boundary shape objects + +--*/ + +#pragma once + +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "Model/Classes/NMR_ModelLevelSetObject.h" +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Reader/v100/NMR_ModelReaderNode100_Object.h" + +namespace NMR +{ + class CModelReaderNode_LevelSet : public CModelReaderNode + { + private: + PModelLevelSetObject m_pLevelSet; + CModel* m_parentModel = nullptr; + + ModelResourceID m_resID = 0; + + nfBool m_bHasFunctionID = false; + nfBool m_bHasTransform = false; + nfBool m_bHasChannel = false; + nfBool m_bHasMeshBBoxOnly = false; + nfBool m_meshBBoxOnly = false; + nfBool m_bHasMeshID = false; + + double m_dMinFeatureSize = 0.0; + nfBool m_bHasMinFeatureSize = false; + + double m_dFallBackValue = 0.0; + nfBool m_bHasFallBackValue = false; + + ModelResourceID m_nFunctionID; + NMATRIX3 m_Transform; + + std::string m_sChannel; + + ModelResourceID m_nVolumeDataID = 0; + ModelResourceID m_nMeshID = 0; + nfBool m_bHasVolumeDataID = false; + + public: + CModelReaderNode_LevelSet() = delete; + CModelReaderNode_LevelSet(CModel* pModel, PModelLevelSetObject levelSet, PModelWarnings pWarnings, + PProgressMonitor pProgressMonitor); + + void parseXML(_In_ CXmlReader* pXMLReader) override; + + void OnAttribute(_In_z_ const nfChar* pAttributeName, + _In_z_ const nfChar* pAttributeValue) override; + + void OnNSChildElement(_In_z_ const nfChar* pChildName, + _In_z_ const nfChar* pNameSpace, + _In_ CXmlReader* pXMLReader) override; + }; + + typedef std::shared_ptr + PModelReaderNode_LevelSet; +} // namespace NMR \ No newline at end of file diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h new file mode 100644 index 0000000..13edd1a --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h @@ -0,0 +1,76 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_Color.h covers the official 3MF volumetric extension. + +--*/ + +#ifndef __NMR_MODELREADERNODE_Volumetric2201_COLOR +#define __NMR_MODELREADERNODE_Volumetric2201_COLOR + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelComponent.h" +#include "Model/Classes/NMR_ModelVolumeData.h" +#include "Common/Math/NMR_Matrix.h" + +namespace NMR { + + class CModelReaderNode_Volumetric2201_Color : public CModelReaderNode { + private: + nfBool m_bHasFieldID = false; + nfBool m_bHasTransform = false; + nfBool m_bHasChannel = false; + + ModelResourceID m_nFieldID; + NMATRIX3 m_Transform = fnMATRIX3_identity(); + std::string m_sChannel; + + double m_dMinFeatureSize = 0.0; + nfBool m_bHasMinFeatureSize = false; + + double m_dFallBackValue = 0.0; + nfBool m_bHasFallBackValue = false; + + protected: + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + public: + CModelReaderNode_Volumetric2201_Color() = delete; + CModelReaderNode_Volumetric2201_Color(_In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader); + + PVolumeDataColor MakeColor(_In_ CModel* pModel); + }; + + typedef std::shared_ptr PModelReaderNode_Volumetric2201_Color; + +} + +#endif // __NMR_MODELREADERNODE_Volumetric2201_COLOR + diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.h new file mode 100644 index 0000000..4e784e1 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.h @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_Image3D.h covers the official 3MF volumetric extension. + +--*/ + +#ifndef __NMR_MODELREADERNODE_Volumetric2201_IMAGE3D +#define __NMR_MODELREADERNODE_Volumetric2201_IMAGE3D + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelImage3D.h" + +namespace NMR { + + class CModelReaderNode_Volumetric2201_Image3D : public CModelReaderNode { + private: + protected: + + CModel * m_pModel; + + ModelResourceID m_modelResourceId; + + nfBool m_bHasName; + std::string m_sName; + + PModelImage3D m_pImage3D; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader); + + public: + CModelReaderNode_Volumetric2201_Image3D() = delete; + CModelReaderNode_Volumetric2201_Image3D(_In_ CModel * pModel, _In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + }; + + typedef std::shared_ptr PModelReaderNode_Volumetric2201_Image3D; + +} + +#endif // __NMR_MODELREADERNODE_Volumetric2201_IMAGE3D diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.h new file mode 100644 index 0000000..218ab8d --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.h @@ -0,0 +1,61 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_ImageSheet.h covers the official 3MF volumetric extension. + +--*/ + +#ifndef __NMR_MODELREADERNODE_VOLUMETRIC2201_IMAGESHEET +#define __NMR_MODELREADERNODE_VOLUMETRIC2201_IMAGESHEET + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelComponent.h" +#include "Model/Classes/NMR_ModelComponentsObject.h" +#include "Model/Classes/NMR_ModelObject.h" + +namespace NMR { + + class CModelReaderNode_Volumetric2201_ImageSheet : public CModelReaderNode { + private: + std::string m_sPath; + + protected: + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + public: + CModelReaderNode_Volumetric2201_ImageSheet() = delete; + CModelReaderNode_Volumetric2201_ImageSheet(_In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + std::string getPath(); + }; + + typedef std::shared_ptr PModelReaderNode_Volumetric2201_ImageSheet; + +} + +#endif // __NMR_MODELREADERNODE_VOLUMETRIC2201_IMAGESHEET diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.h new file mode 100644 index 0000000..8ccee51 --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.h @@ -0,0 +1,67 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_Image3D.h covers the official 3MF volumetric extension. + +--*/ + +#ifndef __NMR_MODELREADERNODE_VOLUMETRIC2201_IMAGESTACK +#define __NMR_MODELREADERNODE_VOLUMETRIC2201_IMAGESTACK + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelImageStack.h" + +namespace NMR { + + class CModelReaderNode_Volumetric2201_ImageStack : public CModelReaderNode { + private: + protected: + + CModel* m_pModel = nullptr; + CModelImageStack* m_pImageStack = nullptr; + + nfUint32 m_nRowCount; + nfUint32 m_nColumnCount; + nfUint32 m_nSheetCount; + nfUint32 m_nSheetIndex; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader); + + public: + CModelReaderNode_Volumetric2201_ImageStack() = delete; + CModelReaderNode_Volumetric2201_ImageStack(_In_ CModel* pModel, _In_ CModelImageStack* pImageStack, _In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + }; + + typedef std::shared_ptr PModelReaderNode_Volumetric2201_ImageStack; + +} + +#endif // __NMR_MODELREADERNODE_VOLUMETRIC2201_IMAGESTACK diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h new file mode 100644 index 0000000..c118b0e --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h @@ -0,0 +1,78 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_Property.h covers the official 3MF volumetric extension. + +--*/ + +#ifndef __NMR_MODELREADERNODE_VOLUMETRIC2201_PROPERTY +#define __NMR_MODELREADERNODE_VOLUMETRIC2201_PROPERTY + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelVolumeData.h" +#include "Common/Math/NMR_Matrix.h" + +namespace NMR { + + class CModelReaderNode_Volumetric2201_Property : public CModelReaderNode { + private: + nfBool m_bHasFieldID = false; + nfBool m_bHasName = false; + nfBool m_bHasTransform = false; + nfBool m_bHasRequired = false; + nfBool m_bHasChannel = false; + + ModelResourceID m_nFieldID; + std::string m_sName; + NMATRIX3 m_Transform; + nfBool m_bRequired = true; + std::string m_sChannel; + + double m_dMinFeatureSize = 0.0; + nfBool m_bHasMinFeatureSize = false; + + double m_dFallBackValue = 0.0; + nfBool m_bHasFallBackValue = false; + protected: + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + public: + CModelReaderNode_Volumetric2201_Property() = delete; + CModelReaderNode_Volumetric2201_Property(_In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader); + + PVolumeDataProperty MakeProperty(_In_ CModel* pModel); + }; + + typedef std::shared_ptr PModelReaderNode_Volumetric2201_Property; + +} + +#endif // __NMR_MODELREADERNODE_VOLUMETRIC2201_PROPERTY + diff --git a/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.h b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.h new file mode 100644 index 0000000..8a03f8b --- /dev/null +++ b/Include/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.h @@ -0,0 +1,63 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_VolumeData.h covers the official 3MF volumetric extension. + +--*/ + +#ifndef __NMR_MODELREADERNODE_VOLUMETRIC2201_VOLUMEDATA +#define __NMR_MODELREADERNODE_VOLUMETRIC2201_VOLUMEDATA + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelComponent.h" +#include "Model/Classes/NMR_ModelVolumeData.h" + +namespace NMR { + + class CModelReaderNode_Volumetric2201_VolumeData : public CModelReaderNode { + private: + CModel* m_pModel; + ModelResourceID m_nID = 0; + PModelVolumeData m_pVolumeData; + + protected: + virtual void OnAttribute(const nfChar * pAttributeName, const nfChar * pAttributeValue); + public: + CModelReaderNode_Volumetric2201_VolumeData() = delete; + CModelReaderNode_Volumetric2201_VolumeData(CModel* pModel, PModelWarnings pWarnings); + + virtual void parseXML(CXmlReader * pXMLReader); + + virtual void OnNSChildElement(const nfChar * pChildName, const nfChar * pNameSpace, CXmlReader * pXMLReader); + }; + + typedef std::shared_ptr PModelReaderNode_Volumetric2201_VolumeData; + +} + +#endif // __NMR_MODELREADERNODE_VOLUMETRIC2201_VOLUMEDATA + diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.h index f2af2c4..f358ee2 100644 --- a/Include/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.h +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.h @@ -45,6 +45,7 @@ namespace NMR { nfInt32 m_ObjectID; nfBool m_bHasID; std::string m_sPartNumber; + bool m_bHasTransform; NMATRIX3 m_mTransform; // Production Extension diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_Component.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_Component.h index bb981b2..7ef0e8d 100644 --- a/Include/Model/Reader/v100/NMR_ModelReaderNode100_Component.h +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_Component.h @@ -42,6 +42,7 @@ namespace NMR { CModel * m_pModel; ModelResourceID m_ObjectID; nfBool m_bHasID; + nfBool m_bHasTransform; NMATRIX3 m_mTransform; nfBool m_bHasPath; diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h index 573f7f8..51b50ac 100644 --- a/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h @@ -38,14 +38,19 @@ A mesh reader model node is a parser for the mesh node of an XML Model Stream. #include "Model/Reader/NMR_ModelReader_TexCoordMapping.h" #include "Model/Classes/NMR_ModelComponent.h" #include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelVolumeData.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" namespace NMR { class CModelReaderNode100_Mesh : public CModelReaderNode { private: - CMesh * m_pMesh; + PModelMeshObject m_pMesh; CModel * m_pModel; + std::vector m_pTriangleSets; + ModelResourceID m_nObjectLevelPropertyID; PPackageResourceID m_pObjectLevelPropertyID; ModelResourceIndex m_nObjectLevelPropertyIndex; @@ -54,16 +59,23 @@ namespace NMR { ModelResourceID m_nClippingMeshID; nfBool m_bHasRepresentationMeshID; ModelResourceID m_nRepresentationMeshID; + + nfBool m_bHasVolumeDataID = false; + ModelResourceID m_nVolumeDataID = 0; protected: - virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); - virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader); + void OnNSAttribute(_In_z_ const nfChar *pAttributeName, + _In_z_ const nfChar *pAttributeValue, + _In_z_ const nfChar *pNameSpace) override; + void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) override; public: CModelReaderNode100_Mesh() = delete; - CModelReaderNode100_Mesh(_In_ CModel * pModel, _In_ CMesh * pMesh, _In_ PModelWarnings pWarnings, _In_ PProgressMonitor pProgressMonitor, _In_ PPackageResourceID m_pObjectLevelPropertyID, _In_ ModelResourceIndex nDefaultPropertyIndex); + CModelReaderNode100_Mesh(_In_ CModel * pModel, PModelMeshObject pMesh, _In_ PModelWarnings pWarnings, _In_ PProgressMonitor pProgressMonitor, _In_ PPackageResourceID m_pObjectLevelPropertyID, _In_ ModelResourceIndex nDefaultPropertyIndex); virtual void parseXML(_In_ CXmlReader * pXMLReader); void retrieveClippingInfo(_Out_ eModelBeamLatticeClipMode &eClipMode, _Out_ nfBool & bHasClippingMode, _Out_ ModelResourceID & nClippingMeshID); void retrieveRepresentationInfo(_Out_ nfBool & bHasRepresentation, _Out_ ModelResourceID & nRepresentationMeshID); + + std::vector getTriangleSets (); }; typedef std::shared_ptr PModelReaderNode100_Mesh; } diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h new file mode 100644 index 0000000..86a8c64 --- /dev/null +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h @@ -0,0 +1,63 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELREADERNODE100_TRIANGLESET +#define __NMR_MODELREADERNODE100_TRIANGLESET + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelComponent.h" +#include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" + +namespace NMR { + + class CModelReaderNode100_TriangleSet : public CModelReaderNode { + protected: + + std::string m_sName; + std::string m_sIdentifier; + + PModelTriangleSet m_pTriangleSet; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + virtual void OnNSChildElement(_In_z_ const nfChar* pChildName, _In_z_ const nfChar* pNameSpace, _In_ CXmlReader* pXMLReader); + + public: + CModelReaderNode100_TriangleSet() = delete; + CModelReaderNode100_TriangleSet(_In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + PModelTriangleSet createTriangleSet(); + }; + + typedef std::shared_ptr PModelReaderNode100_TriangleSet; + +} + +#endif // __NMR_MODELREADERNODE100_TRIANGLESET diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h new file mode 100644 index 0000000..2be0cc3 --- /dev/null +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h @@ -0,0 +1,55 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELREADERNODE100_TRIANGLESETREF +#define __NMR_MODELREADERNODE100_TRIANGLESETREF + +#include "Model/Reader/NMR_ModelReaderNode.h" + +namespace NMR { + + class CModelReaderNode100_TriangleSetRef : public CModelReaderNode { + protected: + + uint32_t m_nIndex; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + public: + CModelReaderNode100_TriangleSetRef() = delete; + CModelReaderNode100_TriangleSetRef(_In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + uint32_t getIndex(); + }; + + typedef std::shared_ptr PModelReaderNode100_TriangleSetRef; + +} + +#endif // __NMR_MODELREADERNODE100_TRIANGLESETREF diff --git a/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h new file mode 100644 index 0000000..d357c8e --- /dev/null +++ b/Include/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h @@ -0,0 +1,62 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#ifndef __NMR_MODELREADERNODE100_TRIANGLESETS +#define __NMR_MODELREADERNODE100_TRIANGLESETS + +#include "Model/Reader/NMR_ModelReaderNode.h" +#include "Model/Classes/NMR_ModelComponent.h" +#include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" + +namespace NMR { + + class CModelReaderNode100_TriangleSets : public CModelReaderNode { + protected: + CMesh * m_pMesh; + CModel * m_pModel; + + std::vector m_TriangleSets; + + virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); + virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader); + + public: + CModelReaderNode100_TriangleSets() = delete; + CModelReaderNode100_TriangleSets(_In_ CModel * pModel, _In_ CMesh * pMesh, _In_ PModelWarnings pWarnings); + + virtual void parseXML(_In_ CXmlReader * pXMLReader); + + std::vector getTriangleSets (); + }; + + typedef std::shared_ptr PModelReaderNode100_TriangleSets; + +} + +#endif // __NMR_MODELREADERNODE100_TRIANGLESETS diff --git a/Include/Model/Writer/NMR_ModelWriterNode.h b/Include/Model/Writer/NMR_ModelWriterNode.h index 0a3caee..12f25ac 100644 --- a/Include/Model/Writer/NMR_ModelWriterNode.h +++ b/Include/Model/Writer/NMR_ModelWriterNode.h @@ -51,8 +51,10 @@ namespace NMR { void writeConstPrefixedStringAttribute(_In_z_ const nfChar * pPrefix, _In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue); void writeIntAttribute(_In_z_ const nfChar * pAttributeName, _In_ nfInt32 nAttributeValue); + void writePrefixedIntAttribute(_In_z_ const nfChar * pPrefix, _In_z_ const nfChar * pAttributeName, _In_ nfInt32 nAttributeValue); void writeUintAttribute(_In_z_ const nfChar * pAttributeName, _In_ nfUint32 nAttributeValue); void writeFloatAttribute(_In_z_ const nfChar * pAttributeName, _In_ nfFloat fAttributeValue); + void writeDoubleAttribute(_In_z_ const nfChar* pAttributeName, _In_ nfDouble dAttributeValue); void writeStartElement(_In_z_ const nfChar * pElementName); void writeStartElementWithNamespace(_In_z_ const nfChar * pElementName, _In_z_ const nfChar * pNameSpace); diff --git a/Include/Model/Writer/NMR_ModelWriterNode_Implicit.h b/Include/Model/Writer/NMR_ModelWriterNode_Implicit.h new file mode 100644 index 0000000..7edc1ee --- /dev/null +++ b/Include/Model/Writer/NMR_ModelWriterNode_Implicit.h @@ -0,0 +1,74 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + + +--*/ + +#pragma once + +#include "Common/3MF_ProgressMonitor.h" +#include "Common/Platform/NMR_XmlWriter.h" +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Classes/NMR_ModelImplicitNode.h" +#include "Model/Writer/NMR_ModelWriterNode_ModelBase.h" + +namespace NMR +{ + namespace implicit + { + class NodeTypes; + } + + class CModelWriterNode_Implicit : public CModelWriterNode_ModelBase + { + + public: + CModelWriterNode_Implicit() = delete; + CModelWriterNode_Implicit(CModel * pModel, + CXmlWriter * pXMLWriter, + PProgressMonitor pProgressMonitor); + + void writeImplicitFunctions(); + void writeImplicitFunction(CModelImplicitFunction & function); + + void writeToXML() override; + + private: + static const implicit::NodeTypes m_nodeTypes; + + void writeImplicitFunctionElements(CModelImplicitFunction & function); + void writeImplicitNode(CModelImplicitNode & node); + void writeImplicitOutputs(NMR::Ports & ports); + void writeImplicitInputs(NMR::Ports & ports); + + void writeImplicitFunctionInputs(NMR::Ports & ports); + void writeImplicitFunctionOutputs(NMR::Ports & ports); + }; + +} diff --git a/Include/Model/Writer/NMR_ModelWriterNode_LevelSet.h b/Include/Model/Writer/NMR_ModelWriterNode_LevelSet.h new file mode 100644 index 0000000..ed52bcb --- /dev/null +++ b/Include/Model/Writer/NMR_ModelWriterNode_LevelSet.h @@ -0,0 +1,70 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Writer node for LevelSet resources + +--*/ + +#pragma once + +#include "Common/3MF_ProgressMonitor.h" +#include "Common/Platform/NMR_XmlWriter.h" +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_ModelVolumeData.h" + +#include "Model/Writer/NMR_ModelWriterNode_ModelBase.h" + +namespace NMR +{ + namespace implicit + { + class NodeTypes; + } + + class CModelLevelSetObject; + + class CModelWriterNode_LevelSet : public CModelWriterNode_ModelBase + { + + public: + CModelWriterNode_LevelSet() = delete; + CModelWriterNode_LevelSet(CModel * pModel, + CModelLevelSetObject * pLevelSet, + CXmlWriter * pXMLWriter, + PProgressMonitor pProgressMonitor); + + void writeToXML() override; + + private: + void writeLevelSetResources(); + void writeLevelSetResource(CModelLevelSetObject& levelSet); + + CModelLevelSetObject * m_pLevelSet = nullptr; + }; + +} diff --git a/Include/Model/Writer/NMR_ModelWriterNode_VolumeData.h b/Include/Model/Writer/NMR_ModelWriterNode_VolumeData.h new file mode 100644 index 0000000..9e20e0b --- /dev/null +++ b/Include/Model/Writer/NMR_ModelWriterNode_VolumeData.h @@ -0,0 +1,69 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Writer node for VolumeData resources + +--*/ + +#pragma once + +#include "Common/3MF_ProgressMonitor.h" +#include "Common/Platform/NMR_XmlWriter.h" +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_ModelVolumeData.h" + +#include "Model/Writer/NMR_ModelWriterNode_ModelBase.h" + +namespace NMR +{ + namespace implicit + { + class NodeTypes; + } + + class CModelWriterNode_VolumeData : public CModelWriterNode_ModelBase + { + + public: + CModelWriterNode_VolumeData() = delete; + CModelWriterNode_VolumeData(CModel * pModel, + CXmlWriter * pXMLWriter, + PProgressMonitor pProgressMonitor); + + + void writeToXML() override; + + void writeVolumeDataResource(CModelVolumeData & volumeData); + private: + void writeVolumeDataResources(); + void writeProperty(CVolumeDataProperty & property); + void writeColor(CVolumeDataColor & color); + + }; + +} diff --git a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h index 6a6954b..6b7c517 100644 --- a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h +++ b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h @@ -50,12 +50,14 @@ This is the class for exporting the 3mf mesh node. #define MODELWRITERMESH100_TRIANGLELINESTARTLENGTH 14 #define MODELWRITERMESH100_BEAMLATTICE_BEAMLINESTART " m_VertexLine; @@ -76,15 +81,17 @@ namespace NMR { std::array m_BallLine; std::array m_BeamRefLine; std::array m_BallRefLine; + std::array m_TriangleSetRefLine; nfUint32 m_nVertexBufferPos; nfUint32 m_nTriangleBufferPos; nfUint32 m_nBeamBufferPos; nfUint32 m_nBallBufferPos; nfUint32 m_nBeamRefBufferPos; nfUint32 m_nBallRefBufferPos; + nfUint32 m_nTriangleSetRefBufferPos; private: const int m_nPosAfterDecPoint; - const int m_nPutDoubleFactor; + const nfInt64 m_nPutDoubleFactor; __NMR_INLINE void putFloat(_In_ const nfFloat fValue, _In_ std::array & line, _In_ nfUint32 & nBufferPos); __NMR_INLINE void putDouble(_In_ const nfDouble dValue, _In_ std::array & line, _In_ nfUint32 & nBufferPos); @@ -109,6 +116,9 @@ namespace NMR { __NMR_INLINE void putBallRefString(_In_ const nfChar * pszString); __NMR_INLINE void putBallRefUInt32(_In_ const nfUint32 nValue); + __NMR_INLINE void putTriangleSetRefString(_In_ const nfChar* pszString); + __NMR_INLINE void putTriangleSetRefUInt32(_In_ const nfUint32 nValue); + __NMR_INLINE void writeVertexData(_In_ MESHNODE * pNode); __NMR_INLINE void writeFaceData_Plain(_In_ MESHFACE * pFace, _In_opt_ const nfChar * pszAdditionalString); __NMR_INLINE void writeFaceData_OneProperty(_In_ MESHFACE * pFace, _In_ const ModelResourceID nPropertyID, _In_ const ModelResourceIndex nPropertyIndex, _In_opt_ const nfChar * pszAdditionalString); @@ -117,10 +127,12 @@ namespace NMR { __NMR_INLINE void writeBallData(_In_ MESHBALL * pBall, _In_ eModelBeamLatticeBallMode eBallMode, _In_ nfDouble dRadius); __NMR_INLINE void writeRefData(_In_ INT nRefID); __NMR_INLINE void writeBallRefData(_In_ INT nRefID); + __NMR_INLINE void writeTriangleSetRefData(_In_ INT nRefID); public: CModelWriterNode100_Mesh() = delete; CModelWriterNode100_Mesh(_In_ CModelMeshObject * pModelMeshObject, _In_ CXmlWriter * pXMLWriter, _In_ PProgressMonitor pProgressMonitor, - _In_ PMeshInformation_PropertyIndexMapping pPropertyIndexMapping, _In_ int nPosAfterDecPoint, _In_ nfBool bWriteMaterialExtension, _In_ nfBool m_bWriteBeamLatticeExtension); + _In_ PMeshInformation_PropertyIndexMapping pPropertyIndexMapping, _In_ int nPosAfterDecPoint, _In_ nfBool bWriteMaterialExtension, _In_ nfBool bWriteBeamLatticeExtension, + _In_ nfBool bWriteBeamLatticeBallsExtension, _In_ nfBool bWriteVolumetricExtension, _In_ nfBool bWriteTriangleSetExtension); virtual void writeToXML(); }; diff --git a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h index 6ed375b..5c716c2 100644 --- a/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h +++ b/Include/Model/Writer/v100/NMR_ModelWriterNode100_Model.h @@ -54,6 +54,8 @@ namespace NMR { nfBool m_bWriteMaterialExtension; nfBool m_bWriteProductionExtension; nfBool m_bWriteBeamLatticeExtension; + nfBool m_bWriteBeamLatticeBallsExtension; + nfBool m_bWriteTriangleSetExtension; nfBool m_bWriteNurbsExtension; nfBool m_bWriteSliceExtension; nfBool m_bWriteSecureContentExtension; @@ -61,22 +63,46 @@ namespace NMR { nfBool m_bWriteObjects; nfBool m_bIsRootModel; nfBool m_bWriteCustomNamespaces; + nfBool m_bWriteVolumetricExtension; + nfBool m_bWriteImplicitExtension; - void writeModelMetaData(); + void writeModelMetaData(); void writeMetaData(_In_ PModelMetaData pMetaData); void writeMetaDataGroup(_In_ PModelMetaDataGroup pMetaDataGroup); void writeResources(); + void writeResource(CModelResource * pResource); + void writeBaseMaterials(); + void writeBaseMaterial( + CModelBaseMaterialResource* pBaseMaterial); void writeTextures2D(); + void writeTexture2D( + CModelTexture2DResource* pTexture2D); void writeColors(); + void writeColor( + CModelColorGroupResource* pColorGroup); void writeTex2Coords(); void writeCompositeMaterials(); void writeMultiProperties(); void writeMultiPropertyAttributes(_In_ CModelMultiPropertyGroupResource* pMultiPropertyGroup); void writeMultiPropertyMultiElements(_In_ CModelMultiPropertyGroupResource* pMultiPropertyGroup); + + void writeImage3Ds(); + void writeImage3D(CModelImage3D & pImage3D); + + void writeFunctionsFromImage3D(); + void writeFunctionFromImage3D(CModelFunctionFromImage3D & functionFromImage3D); + + void writeImplicitFunctions(); + void writeVolumeData(); + + void detectRequiredExtensions(); + + void writeObjects(); + void writeObject(CModelObject & pObject); void writeBuild(); void writeSliceStacks(); diff --git a/Include/Model/Writer/v100/NMR_ResourceDependencySorter.h b/Include/Model/Writer/v100/NMR_ResourceDependencySorter.h new file mode 100644 index 0000000..2f83d54 --- /dev/null +++ b/Include/Model/Writer/v100/NMR_ResourceDependencySorter.h @@ -0,0 +1,65 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ResourcDependencySorter resolves the dependencies between resources by +sorting them topologically. +--*/ + +#pragma once + +#include + +#include "Common/Graph/DirectedGraph.h" +#include "Common/Graph/GraphAlgorithms.h" +#include "Model/Classes/NMR_Model.h" + +namespace NMR +{ + using TopologicalSortResult = std::vector; + + class CResourceDependencySorter + { + private: + common::graph::DirectedGraph buildGraph(); + void buildIndexMaps(); + + [[nodiscard]] PPackageResourceID indexToModelResourceID(size_t index) const; + [[nodiscard]] size_t modelResourceIDToIndex(PPackageResourceID resourceID) const; + + CModel * m_pModel; + + std::unordered_map m_indexToResourceID; + std::unordered_map m_resourceIDToIndex; + + public: + explicit CResourceDependencySorter(CModel * pModel); + TopologicalSortResult sort(); + + }; + +} // namespace NMR \ No newline at end of file diff --git a/Include/NMR_Spec_Version.h b/Include/NMR_Spec_Version.h index 7d3f75a..87caaa2 100644 --- a/Include/NMR_Spec_Version.h +++ b/Include/NMR_Spec_Version.h @@ -59,4 +59,16 @@ NMR_Spec_Version.h defines the current implementation version. #define NMR_SPECVERSION_SECURECONTENT_MINOR 0 #define NMR_SPECVERSION_SECURECONTENT_MICRO 2 +#define NMR_SPECVERSION_TRIANGLESETS_MAJOR 1 +#define NMR_SPECVERSION_TRIANGLESETS_MINOR 3 +#define NMR_SPECVERSION_TRIANGLESETS_MICRO 0 + +#define NMR_SPECVERSION_VOLUMETRIC_MAJOR 0 +#define NMR_SPECVERSION_VOLUMETRIC_MINOR 8 +#define NMR_SPECVERSION_VOLUMETRIC_MICRO 0 + +#define NMR_SPECVERSION_IMPLICIT_MAJOR 0 +#define NMR_SPECVERSION_IMPLICIT_MINOR 8 +#define NMR_SPECVERSION_IMPLICIT_MICRO 0 + #endif // __NMR_SPECVERSION diff --git a/Include/lib3mf_abi.hpp b/Include/lib3mf_abi.hpp index 16fece3..0c55803 100644 --- a/Include/lib3mf_abi.hpp +++ b/Include/lib3mf_abi.hpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,12 +24,12 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. Abstract: This is an autogenerated C++-Header file in order to allow an easy use of the 3MF Library -Interface version: 2.2.0 +Interface version: 2.5.0 */ @@ -49,12 +49,23 @@ Interface version: 2.2.0 #include "lib3mf_types.hpp" +#ifdef __cplusplus extern "C" { +#endif /************************************************************************************************************************* Class definition for Base **************************************************************************************************************************/ +/** +* Get Class Type Id +* +* @param[in] pBase - Base instance. +* @param[out] pClassTypeId - Class type as a 64 bits integer +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_base_classtypeid(Lib3MF_Base pBase, Lib3MF_uint64 * pClassTypeId); + /************************************************************************************************************************* Class definition for Writer **************************************************************************************************************************/ @@ -564,6 +575,45 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_compositematerialsiterator_getcurrentcomposi */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup(Lib3MF_MultiPropertyGroupIterator pMultiPropertyGroupIterator, Lib3MF_MultiPropertyGroup * pResource); +/************************************************************************************************************************* + Class definition for Image3DIterator +**************************************************************************************************************************/ + +/** +* Returns the Image3D the iterator points at. +* +* @param[in] pImage3DIterator - Image3DIterator instance. +* @param[out] pResource - returns the Image3D instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_image3diterator_getcurrentimage3d(Lib3MF_Image3DIterator pImage3DIterator, Lib3MF_Image3D * pResource); + +/************************************************************************************************************************* + Class definition for FunctionIterator +**************************************************************************************************************************/ + +/** +* Returns the Function the iterator points at. +* +* @param[in] pFunctionIterator - FunctionIterator instance. +* @param[out] pResource - returns the Function instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functioniterator_getcurrentfunction(Lib3MF_FunctionIterator pFunctionIterator, Lib3MF_Function * pResource); + +/************************************************************************************************************************* + Class definition for LevelSetIterator +**************************************************************************************************************************/ + +/** +* Returns the LevelSet the iterator points at. +* +* @param[in] pLevelSetIterator - LevelSetIterator instance. +* @param[out] pResource - returns the MeshObject instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelsetiterator_getcurrentlevelset(Lib3MF_LevelSetIterator pLevelSetIterator, Lib3MF_LevelSet * pResource); + /************************************************************************************************************************* Class definition for MetaData **************************************************************************************************************************/ @@ -737,12 +787,141 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_metadatagroup_removemetadata(Lib3MF_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[in] bMustPreserve - should 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 TriangleSet +**************************************************************************************************************************/ + +/** +* sets the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pName - the new name +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setname(Lib3MF_TriangleSet pTriangleSet, const char * pName); + +/** +* returns the name of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of returns the name, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getname(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets the identifier of the triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_setidentifier(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier); + +/** +* returns the identifier of the triangle set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nIdentifierBufferSize - size of the buffer (including trailing 0) +* @param[out] pIdentifierNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pIdentifierBuffer - buffer of returns the identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_getidentifier(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* adds a triangle to the set. Does nothing if triangle is already in the set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* removes a triangle from the set +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_removetriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex); + +/** +* clears all triangles from the list +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_clear(Lib3MF_TriangleSet pTriangleSet); + +/** +* Sets all triangles in the list, while clearing old values. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_settrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Retrieves all the triangles in the TriangleSet +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_gettrianglelist(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Adds multiple triangles in the list. Duplicates will be merged. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] nTriangleIndicesBufferSize - Number of elements in buffer +* @param[in] pTriangleIndicesBuffer - uint32 buffer of Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_addtrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer); + +/** +* Merges another Triangle set. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pOtherTriangleSet - Other triangle set to merge. +* @param[in] bDeleteOther - Flag if other triangle set is getting removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_merge(Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther); + +/** +* Deletes the whole set from the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_deleteset(Lib3MF_TriangleSet pTriangleSet); + +/** +* Duplicates the set in the mesh. +* +* @param[in] pTriangleSet - TriangleSet instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[out] pNewSet - Copy of the triangle set. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_triangleset_duplicate(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet); + /************************************************************************************************************************* Class definition for Object **************************************************************************************************************************/ @@ -823,6 +1002,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_ismeshobject(Lib3MF_Object pObject, b */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_iscomponentsobject(Lib3MF_Object pObject, bool * pIsComponentsObject); +/** +* Retrieves, if an object is a level set object +* +* @param[in] pObject - Object instance. +* @param[out] pIsLevelSetObject - returns, whether the object is a level set object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_object_islevelsetobject(Lib3MF_Object pObject, bool * pIsLevelSetObject); + /** * 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. * @@ -1155,6 +1343,224 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_ismanifoldandoriented(Lib3MF_Mesh */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMeshObject, Lib3MF_BeamLattice * pTheBeamLattice); +/** +* Retrieves the VolumeData of this MeshObject. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pTheVolumeData - the VolumeData of this MeshObject +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData); + +/** +* Sets the VolumeData of this MeshObject. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pTheVolumeData - the VolumeData of this MeshObject +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_setvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData); + +/** +* Adds a new triangle set. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string +* @param[in] pName - the human readable name. MUST NOT be an empty string +* @param[out] pTheTriangleSet - the new Triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_addtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Checks if a triangle set exists. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTriangleSetExists - flag if the triangles set exists. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_hastriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists); + +/** +* Finds a new triangle set by identifier. Fails if not existing. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] pIdentifier - the identifier to be found. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_findtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet); + +/** +* Returns number of triangle sets. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[out] pCount - the number of triangle sets of this mesh. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettrianglesetcount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount); + +/** +* Returns a specific triangle set by index. +* +* @param[in] pMeshObject - MeshObject instance. +* @param[in] nIndex - the index of the triangle set. +* @param[out] pTheTriangleSet - the triangle Set Instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshobject_gettriangleset(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet); + +/************************************************************************************************************************* + Class definition for LevelSet +**************************************************************************************************************************/ + +/** +* Returns the function that is used as boundary shape. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[out] pTheFunction - the function to use as boundary shape +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_getfunction(Lib3MF_LevelSet pLevelSet, Lib3MF_Function * pTheFunction); + +/** +* Sets the function to use as boundary shape. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] pTheFunction - the function to use as boundary shape +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_setfunction(Lib3MF_LevelSet pLevelSet, Lib3MF_Function pTheFunction); + +/** +* Returns the transformation matrix into the coordinate system of the referenced Function. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[out] pTransform - the transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_gettransform(Lib3MF_LevelSet pLevelSet, Lib3MF::sTransform * pTransform); + +/** +* Sets the transformation matrix into the coordinate system of the referenced Function. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] pTransform - new transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_settransform(Lib3MF_LevelSet pLevelSet, const Lib3MF::sTransform * pTransform); + +/** +* Returns the name of the function output channel to use. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] nChannelNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pChannelNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pChannelNameBuffer - buffer of the name of the function output channel, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_getchannelname(Lib3MF_LevelSet pLevelSet, const Lib3MF_uint32 nChannelNameBufferSize, Lib3MF_uint32* pChannelNameNeededChars, char * pChannelNameBuffer); + +/** +* Sets the name of the function output channel to use. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] pChannelName - new name of the function output channel +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_setchannelname(Lib3MF_LevelSet pLevelSet, const char * pChannelName); + +/** +* Sets the minimal feature size as a hint for the function evaluator +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] dMinFeatureSize - minimal feature size +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_setminfeaturesize(Lib3MF_LevelSet pLevelSet, Lib3MF_double dMinFeatureSize); + +/** +* Returns the minimal feature size as a hint for the function evaluator +* +* @param[in] pLevelSet - LevelSet instance. +* @param[out] pMinFeatureSize - minimal feature size +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_getminfeaturesize(Lib3MF_LevelSet pLevelSet, Lib3MF_double * pMinFeatureSize); + +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_setfallbackvalue(Lib3MF_LevelSet pLevelSet, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pLevelSet - LevelSet instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_getfallbackvalue(Lib3MF_LevelSet pLevelSet, Lib3MF_double * pFallBackValue); + +/** +* If set only the bounding box of the mesh is intersected with the boundary +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] bMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_setmeshbboxonly(Lib3MF_LevelSet pLevelSet, bool bMeshBBoxOnly); + +/** +* If set only the bounding box of the mesh is intersected with the boundary +* +* @param[in] pLevelSet - LevelSet instance. +* @param[out] pMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_getmeshbboxonly(Lib3MF_LevelSet pLevelSet, bool * pMeshBBoxOnly); + +/** +* Sets the mesh to use as evaluation domain +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] pTheMesh - The mesh +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_setmesh(Lib3MF_LevelSet pLevelSet, Lib3MF_MeshObject pTheMesh); + +/** +* Returns the mesh that is used as evaluation domain +* +* @param[in] pLevelSet - LevelSet instance. +* @param[out] pTheMesh - The mesh +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_getmesh(Lib3MF_LevelSet pLevelSet, Lib3MF_MeshObject * pTheMesh); + +/** +* Retrieves the VolumeData this Object. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[out] pTheVolumeData - the VolumeData of this Object +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_getvolumedata(Lib3MF_LevelSet pLevelSet, Lib3MF_VolumeData * pTheVolumeData); + +/** +* Sets the VolumeData of this LevelSet. +* +* @param[in] pLevelSet - LevelSet instance. +* @param[in] pTheVolumeData - the VolumeData of this MeshObject +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_levelset_setvolumedata(Lib3MF_LevelSet pLevelSet, Lib3MF_VolumeData pTheVolumeData); + /************************************************************************************************************************* Class definition for BeamLattice **************************************************************************************************************************/ @@ -1384,6 +1790,299 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_addbeamset(Lib3MF_BeamLattice pB */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlattice_getbeamset(Lib3MF_BeamLattice pBeamLattice, Lib3MF_uint32 nIndex, Lib3MF_BeamSet * pBeamSet); +/************************************************************************************************************************* + Class definition for FunctionReference +**************************************************************************************************************************/ + +/** +* Returns the UniqueResourceID of the Function. Only functions with a 'pos'-input are allowed. +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pUniqueResourceID - returns the UniqueResourceID. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getfunctionresourceid(Lib3MF_FunctionReference pFunctionReference, Lib3MF_uint32 * pUniqueResourceID); + +/** +* Sets the UniqueResourceID to refer to. +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] nUniqueResourceID - UniqueResourceID of the function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setfunctionresourceid(Lib3MF_FunctionReference pFunctionReference, Lib3MF_uint32 nUniqueResourceID); + +/** +* Returns the transformation matrix into the coordinate system of the referenced Function. +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pTransform - the transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_gettransform(Lib3MF_FunctionReference pFunctionReference, Lib3MF::sTransform * pTransform); + +/** +* Sets the transformation matrix into the coordinate system of the referenced Function. +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] pTransform - new transformation matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_settransform(Lib3MF_FunctionReference pFunctionReference, const Lib3MF::sTransform * pTransform); + +/** +* Returns the name of the function output channel to use. +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] nChannelNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pChannelNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pChannelNameBuffer - buffer of the name of the function output channel, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getchannelname(Lib3MF_FunctionReference pFunctionReference, const Lib3MF_uint32 nChannelNameBufferSize, Lib3MF_uint32* pChannelNameNeededChars, char * pChannelNameBuffer); + +/** +* Sets the name of the function output channel to use. +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] pChannelName - new name of the function output channel +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setchannelname(Lib3MF_FunctionReference pFunctionReference, const char * pChannelName); + +/** +* Sets the minimal feature size as a hint for the function evaluator +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dMinFeatureSize - minimal feature size +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setminfeaturesize(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dMinFeatureSize); + +/** +* Returns the minimal feature size as a hint for the function evaluator +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pMinFeatureSize - minimal feature size +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getminfeaturesize(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize); + +/** +* Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[in] dFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_setfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue); + +/** +* Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). +* +* @param[in] pFunctionReference - FunctionReference instance. +* @param[out] pFallBackValue - fallback value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionreference_getfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue); + +/************************************************************************************************************************* + Class definition for VolumeDataColor +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for MaterialMapping +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for VolumeDataComposite +**************************************************************************************************************************/ + +/** +* Returns the BaseMaterialGroup used within this volume data item +* +* @param[in] pVolumeDataComposite - VolumeDataComposite instance. +* @param[out] pBaseMaterialGroupInstance - The BaseMaterialGroup instance of this VolumeDataComposite element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedatacomposite_getbasematerialgroup(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_BaseMaterialGroup * pBaseMaterialGroupInstance); + +/** +* Sets the BaseMaterialGroup to use within this volume data item. +* +* @param[in] pVolumeDataComposite - VolumeDataComposite instance. +* @param[in] pBaseMaterialGroupInstance - The new BaseMaterialGroup instance of this VolumeDataComposite element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedatacomposite_setbasematerialgroup(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_BaseMaterialGroup pBaseMaterialGroupInstance); + +/** +* Returns the number of material mappings of this VolumeDataComposite element +* +* @param[in] pVolumeDataComposite - VolumeDataComposite instance. +* @param[out] pCount - the number of material mappings. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedatacomposite_getmaterialmappingcount(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_uint32 * pCount); + +/** +* Returns MaterialMapping with given index +* +* @param[in] pVolumeDataComposite - VolumeDataComposite instance. +* @param[in] nIndex - Index of the MaterialMapping in question. +* @param[out] pTheMaterialMapping - MaterialMapping used in this element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedatacomposite_getmaterialmapping(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_uint32 nIndex, Lib3MF_MaterialMapping * pTheMaterialMapping); + +/** +* Adds a MaterialMapping +* +* @param[in] pVolumeDataComposite - VolumeDataComposite instance. +* @param[in] pTransform - new transformation matrix +* @param[out] pTheMaterialMapping - The new MaterialMapping +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedatacomposite_addmaterialmapping(Lib3MF_VolumeDataComposite pVolumeDataComposite, const Lib3MF::sTransform * pTransform, Lib3MF_MaterialMapping * pTheMaterialMapping); + +/** +* Removes the MaterialMapping with given index +* +* @param[in] pVolumeDataComposite - VolumeDataComposite instance. +* @param[in] nIndex - The index of the MaterialMapping to be removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedatacomposite_removematerialmapping(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_uint32 nIndex); + +/************************************************************************************************************************* + Class definition for VolumeDataProperty +**************************************************************************************************************************/ + +/** +* Gets the qualified name of this property. +* +* @param[in] pVolumeDataProperty - VolumeDataProperty instance. +* @param[in] nPropertyNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pPropertyNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pPropertyNameBuffer - buffer of The qualified name of this property., may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedataproperty_getname(Lib3MF_VolumeDataProperty pVolumeDataProperty, const Lib3MF_uint32 nPropertyNameBufferSize, Lib3MF_uint32* pPropertyNameNeededChars, char * pPropertyNameBuffer); + +/** +* Sets whether this property is required to process this 3MF document instance. +* +* @param[in] pVolumeDataProperty - VolumeDataProperty instance. +* @param[in] bIsRequired - New value for whether this property is required to process this 3MF document instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedataproperty_setisrequired(Lib3MF_VolumeDataProperty pVolumeDataProperty, bool bIsRequired); + +/** +* Returns whether this property is required to process this 3MF document instance. +* +* @param[in] pVolumeDataProperty - VolumeDataProperty instance. +* @param[out] pIsRequired - Is this property required to process this 3MF document instance? +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedataproperty_isrequired(Lib3MF_VolumeDataProperty pVolumeDataProperty, bool * pIsRequired); + +/************************************************************************************************************************* + Class definition for VolumeData +**************************************************************************************************************************/ + +/** +* Returns the VolumeDataComposite of this VolumeData instance +* +* @param[in] pVolumeData - VolumeData instance. +* @param[out] pTheCompositeData - filled with the VolumeDataComposite of this VolumeData instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_getcomposite(Lib3MF_VolumeData pVolumeData, Lib3MF_VolumeDataComposite * pTheCompositeData); + +/** +* Creates a new VolumeDataComposite for this VolumeData instance +* +* @param[in] pVolumeData - VolumeData instance. +* @param[out] pTheCompositeData - The new VolumeDataComposite of this VolumeData instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_createnewcomposite(Lib3MF_VolumeData pVolumeData, Lib3MF_VolumeDataComposite * pTheCompositeData); + +/** +* Removes the VolumeDataComposite of this VolumeData instance +* +* @param[in] pVolumeData - VolumeData instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_removecomposite(Lib3MF_VolumeData pVolumeData); + +/** +* Returns the VolumeDataColor of this VolumeData instance +* +* @param[in] pVolumeData - VolumeData instance. +* @param[out] pTheColorData - filled with the VolumeDataColor of this VolumeData instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_getcolor(Lib3MF_VolumeData pVolumeData, Lib3MF_VolumeDataColor * pTheColorData); + +/** +* Creates a new VolumeDataColor for this VolumeData instance +* +* @param[in] pVolumeData - VolumeData instance. +* @param[in] pTheFunction - Function used in this element +* @param[out] pTheColorData - The new VolumeDataColor of this VolumeData instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_createnewcolor(Lib3MF_VolumeData pVolumeData, Lib3MF_Function pTheFunction, Lib3MF_VolumeDataColor * pTheColorData); + +/** +* Removes the VolumeDataColor of this VolumeData instance +* +* @param[in] pVolumeData - VolumeData instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_removecolor(Lib3MF_VolumeData pVolumeData); + +/** +* Returns the number of VolumeDataProperty +* +* @param[in] pVolumeData - VolumeData instance. +* @param[out] pCount - the number of VolumeDataProperty-elements within this VolumeData +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_getpropertycount(Lib3MF_VolumeData pVolumeData, Lib3MF_uint32 * pCount); + +/** +* Returns the VolumeDataProperty at a given Index +* +* @param[in] pVolumeData - VolumeData instance. +* @param[in] nIndex - the index of the VolumeDataProperty to be returned. +* @param[out] pTheVolumeDataProperty - the VolumeDataProperty at the given index. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_getproperty(Lib3MF_VolumeData pVolumeData, Lib3MF_uint32 nIndex, Lib3MF_VolumeDataProperty * pTheVolumeDataProperty); + +/** +* Adds a new VolumeDataProperty from a Function +* +* @param[in] pVolumeData - VolumeData instance. +* @param[in] pName - the qualified name (namespace+name) of the Property +* @param[in] pTheFunction - Function used in this element +* @param[out] pTheVolumeDataProperty - the newly created VolumeDataProperty. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_addpropertyfromfunction(Lib3MF_VolumeData pVolumeData, const char * pName, Lib3MF_Function pTheFunction, Lib3MF_VolumeDataProperty * pTheVolumeDataProperty); + +/** +* Removes the VolumeDataProperty with a given index +* +* @param[in] pVolumeData - VolumeData instance. +* @param[in] nIndex - the index of the VolumeDataProperty to be removed. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_volumedata_removeproperty(Lib3MF_VolumeData pVolumeData, Lib3MF_uint32 nIndex); + /************************************************************************************************************************* Class definition for Component **************************************************************************************************************************/ @@ -1973,6 +2672,144 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_getlayer(Lib3MF_MultiProp */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_multipropertygroup_removelayer(Lib3MF_MultiPropertyGroup pMultiPropertyGroup, Lib3MF_uint32 nLayerIndex); +/************************************************************************************************************************* + Class definition for Image3D +**************************************************************************************************************************/ + +/** +* returns the name of this Image3D +* +* @param[in] pImage3D - Image3D 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 this Image3D, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_image3d_getname(Lib3MF_Image3D pImage3D, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* sets a new name of this Image3D +* +* @param[in] pImage3D - Image3D instance. +* @param[in] pName - the new name of this Image3D +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_image3d_setname(Lib3MF_Image3D pImage3D, const char * pName); + +/** +* Retrieves, if this Image3D is a ImageStack +* +* @param[in] pImage3D - Image3D instance. +* @param[out] pIsImageStack - returns, whether the Image3D is an ImageStack +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_image3d_isimagestack(Lib3MF_Image3D pImage3D, bool * pIsImageStack); + +/************************************************************************************************************************* + Class definition for ImageStack +**************************************************************************************************************************/ + +/** +* Retrieves the number of rows in each image of this image3d +* +* @param[in] pImageStack - ImageStack instance. +* @param[out] pRowCount - number of rows +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_getrowcount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 * pRowCount); + +/** +* Sets the number of rows in each image of this image3d +* +* @param[in] pImageStack - ImageStack instance. +* @param[in] nRowCount - number of rows +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_setrowcount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nRowCount); + +/** +* Retrieves the number of columns in each image of this image3d +* +* @param[in] pImageStack - ImageStack instance. +* @param[out] pColumnCount - number of columns +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_getcolumncount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 * pColumnCount); + +/** +* Sets the number of columns in each image of this image3d +* +* @param[in] pImageStack - ImageStack instance. +* @param[in] nColumnCount - number of columns +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_setcolumncount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nColumnCount); + +/** +* Retrieves the number of images in the stack. +* +* @param[in] pImageStack - ImageStack instance. +* @param[out] pSheetCount - number of images +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_getsheetcount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 * pSheetCount); + +/** +* Retrieves a sheet of the stack. Raises an error if sheet is not set. +* +* @param[in] pImageStack - ImageStack instance. +* @param[in] nIndex - index of the image (0-based) +* @param[out] pSheet - attachment containing the image +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_getsheet(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, Lib3MF_Attachment * pSheet); + +/** +* Sets a sheet to an existing attachment. +* +* @param[in] pImageStack - ImageStack instance. +* @param[in] nIndex - index of the image (0-based) +* @param[in] pSheet - attachment containing the image +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_setsheet(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, Lib3MF_Attachment pSheet); + +/** +* Creates a new sheet attachment with empty data. +* +* @param[in] pImageStack - ImageStack instance. +* @param[in] nIndex - index of the image (0-based) +* @param[in] pPath - path of part in the package +* @param[out] pSheet - attachment containing the image +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_createemptysheet(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, const char * pPath, Lib3MF_Attachment * pSheet); + +/** +* Creates a new sheet attachment from a memory buffer. +* +* @param[in] pImageStack - ImageStack instance. +* @param[in] nIndex - index of the image (0-based) +* @param[in] pPath - path of part in the package +* @param[in] nDataBufferSize - Number of elements in buffer +* @param[in] pDataBuffer - uint8 buffer of binary image data +* @param[out] pSheet - attachment containing the image +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_createsheetfrombuffer(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, const char * pPath, Lib3MF_uint64 nDataBufferSize, const Lib3MF_uint8 * pDataBuffer, Lib3MF_Attachment * pSheet); + +/** +* Creates a new sheet attachment from a file on disk. +* +* @param[in] pImageStack - ImageStack instance. +* @param[in] nIndex - index of the image (0-based) +* @param[in] pPath - path of part in the package +* @param[in] pFileName - file name to read from +* @param[out] pSheet - attachment containing the image +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_imagestack_createsheetfromfile(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, const char * pPath, const char * pFileName, Lib3MF_Attachment * pSheet); + /************************************************************************************************************************* Class definition for Attachment **************************************************************************************************************************/ @@ -2036,7 +2873,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_setrelationshiptype(Lib3MF_Attach 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. +* 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 package, or via the WriteToFile or WriteToBuffer methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pFileName - file to read from. @@ -2045,7 +2882,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_writetofile(Lib3MF_Attachment pAt LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_readfromfile(Lib3MF_Attachment pAttachment, const char * pFileName); /** -* Reads a model and from the data provided by a callback function +* Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer methods. * * @param[in] pAttachment - Attachment instance. * @param[in] pTheReadCallback - Callback to call for reading a data chunk @@ -2077,7 +2914,7 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_attachment_getstreamsize(Lib3MF_Attachment p 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 +* Reads an attachment from a memory buffer. This buffer is immediately read (in contrast to the ReadFromCallback and ReadFromFile-methods). * * @param[in] pAttachment - Attachment instance. * @param[in] nBufferBufferSize - Number of elements in buffer @@ -2164,6 +3001,2233 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_getfilter(Lib3MF_Texture2D pTextur */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_texture2d_setfilter(Lib3MF_Texture2D pTexture2D, Lib3MF::eTextureFilter eFilter); +/************************************************************************************************************************* + Class definition for ImplicitPort +**************************************************************************************************************************/ + +/** +* Retrieves the identifier of the port +* +* @param[in] pImplicitPort - ImplicitPort 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 the identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_getidentifier(Lib3MF_ImplicitPort pImplicitPort, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* Sets the identifier of the port +* +* @param[in] pImplicitPort - ImplicitPort instance. +* @param[in] pIdentifier - the identifier +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_setidentifier(Lib3MF_ImplicitPort pImplicitPort, const char * pIdentifier); + +/** +* Retrieves the display name of the port +* +* @param[in] pImplicitPort - ImplicitPort instance. +* @param[in] nDisplayNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pDisplayNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pDisplayNameBuffer - buffer of the display name, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_getdisplayname(Lib3MF_ImplicitPort pImplicitPort, const Lib3MF_uint32 nDisplayNameBufferSize, Lib3MF_uint32* pDisplayNameNeededChars, char * pDisplayNameBuffer); + +/** +* Sets the display name of the port +* +* @param[in] pImplicitPort - ImplicitPort instance. +* @param[in] pDisplayName - the display name +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_setdisplayname(Lib3MF_ImplicitPort pImplicitPort, const char * pDisplayName); + +/** +* Sets the type of the port +* +* @param[in] pImplicitPort - ImplicitPort instance. +* @param[in] eImplicitPortType - the type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_settype(Lib3MF_ImplicitPort pImplicitPort, Lib3MF::eImplicitPortType eImplicitPortType); + +/** +* Retrieves the type of the port +* +* @param[in] pImplicitPort - ImplicitPort instance. +* @param[out] pImplicitPortType - the type +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_gettype(Lib3MF_ImplicitPort pImplicitPort, Lib3MF::eImplicitPortType * pImplicitPortType); + +/** +* Retrieves the reference of the port, only used for input ports +* +* @param[in] pImplicitPort - ImplicitPort instance. +* @param[in] nReferenceBufferSize - size of the buffer (including trailing 0) +* @param[out] pReferenceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pReferenceBuffer - buffer of the reference, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_getreference(Lib3MF_ImplicitPort pImplicitPort, const Lib3MF_uint32 nReferenceBufferSize, Lib3MF_uint32* pReferenceNeededChars, char * pReferenceBuffer); + +/** +* Sets the reference of the port, only used for input ports +* +* @param[in] pImplicitPort - ImplicitPort instance. +* @param[in] pReference - the reference +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitport_setreference(Lib3MF_ImplicitPort pImplicitPort, const char * pReference); + +/************************************************************************************************************************* + Class definition for Iterator +**************************************************************************************************************************/ + +/** +* Iterates to the next item in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasNext - Iterates to the next item in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_iterator_movenext(Lib3MF_Iterator pIterator, bool * pHasNext); + +/** +* Iterates to the previous item in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasPrevious - Iterates to the previous item in the list. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_iterator_moveprevious(Lib3MF_Iterator pIterator, bool * pHasPrevious); + +/** +* Returns the number of items the iterator captures. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCount - returns the number of items the iterator captures. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_iterator_count(Lib3MF_Iterator pIterator, Lib3MF_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for ImplicitPortIterator +**************************************************************************************************************************/ + +/** +* Returns the current element +* +* @param[in] pImplicitPortIterator - ImplicitPortIterator instance. +* @param[out] pPort - The current element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitportiterator_getcurrent(Lib3MF_ImplicitPortIterator pImplicitPortIterator, Lib3MF_ImplicitPort * pPort); + +/************************************************************************************************************************* + Class definition for ImplicitNode +**************************************************************************************************************************/ + +/** +* Retrieves the identifier of the node +* +* @param[in] pImplicitNode - ImplicitNode 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 the identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_getidentifier(Lib3MF_ImplicitNode pImplicitNode, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* Sets the identifier of the node +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] pIdentifier - the identifier +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_setidentifier(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier); + +/** +* Retrieves the display name of the node +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] nDisplayNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pDisplayNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pDisplayNameBuffer - buffer of the display name, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_getdisplayname(Lib3MF_ImplicitNode pImplicitNode, const Lib3MF_uint32 nDisplayNameBufferSize, Lib3MF_uint32* pDisplayNameNeededChars, char * pDisplayNameBuffer); + +/** +* Sets the display name of the node +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] pDisplayName - the display name +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_setdisplayname(Lib3MF_ImplicitNode pImplicitNode, const char * pDisplayName); + +/** +* Retrieves the tag of the node +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] nTagBufferSize - size of the buffer (including trailing 0) +* @param[out] pTagNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTagBuffer - buffer of the tag, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_gettag(Lib3MF_ImplicitNode pImplicitNode, const Lib3MF_uint32 nTagBufferSize, Lib3MF_uint32* pTagNeededChars, char * pTagBuffer); + +/** +* Sets the tag of the node +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] pTag - the tag +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_settag(Lib3MF_ImplicitNode pImplicitNode, const char * pTag); + +/** +* Retrieves the type of the node +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[out] pType - the type of the node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_getnodetype(Lib3MF_ImplicitNode pImplicitNode, Lib3MF::eImplicitNodeType * pType); + +/** +* Add an input +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] pIdentifier - the identifier of the input +* @param[in] pDisplayName - the display name of the input +* @param[out] pPort - +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_addinput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, const char * pDisplayName, Lib3MF_ImplicitPort * pPort); + +/** +* Retrieves the inputs +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[out] pIterator - the iterator for the inputs +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_getinputs(Lib3MF_ImplicitNode pImplicitNode, Lib3MF_ImplicitPortIterator * pIterator); + +/** +* Add an output +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] pIdentifier - the identifier of the output +* @param[in] pDisplayName - the display name of the output +* @param[out] pPort - +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_addoutput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, const char * pDisplayName, Lib3MF_ImplicitPort * pPort); + +/** +* Retrieves the outputs +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[out] pIterator - the iterator the outputs +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_getoutputs(Lib3MF_ImplicitNode pImplicitNode, Lib3MF_ImplicitPortIterator * pIterator); + +/** +* Retrieves an input +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] pIdentifier - the identifier of the input +* @param[out] pInput - the input port +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_findinput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, Lib3MF_ImplicitPort * pInput); + +/** +* Retrieves an output +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[in] pIdentifier - the identifier of the output +* @param[out] pOutput - the output port +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_findoutput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, Lib3MF_ImplicitPort * pOutput); + +/** +* Checks if the types of the input and output ports are valid for the node type +* +* @param[in] pImplicitNode - ImplicitNode instance. +* @param[out] pValid - true, if the types are valid +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitnode_aretypesvalid(Lib3MF_ImplicitNode pImplicitNode, bool * pValid); + +/************************************************************************************************************************* + Class definition for OneInputNode +**************************************************************************************************************************/ + +/** +* Retrieves the input +* +* @param[in] pOneInputNode - OneInputNode instance. +* @param[out] pInput - the input +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_oneinputnode_getinputa(Lib3MF_OneInputNode pOneInputNode, Lib3MF_ImplicitPort * pInput); + +/** +* Retrieves the output +* +* @param[in] pOneInputNode - OneInputNode instance. +* @param[out] pResult - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_oneinputnode_getoutputresult(Lib3MF_OneInputNode pOneInputNode, Lib3MF_ImplicitPort * pResult); + +/************************************************************************************************************************* + Class definition for SinNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for CosNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for TanNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for ArcSinNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for ArcCosNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for ArcTanNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for SinhNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for CoshNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for TanhNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for RoundNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for CeilNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for FloorNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for SignNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for FractNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for AbsNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for ExpNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for LogNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Log2Node +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Log10Node +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for LengthNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for TransposeNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for InverseNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for SqrtNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for ResourceIdNode +**************************************************************************************************************************/ + +/** +* Sets the Resource that the resourceid attribute of the node will point to +* +* @param[in] pResourceIdNode - ResourceIdNode instance. +* @param[in] pResource - the resource +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceidnode_setresource(Lib3MF_ResourceIdNode pResourceIdNode, Lib3MF_Resource pResource); + +/** +* Retrieves the resource of the node +* +* @param[in] pResourceIdNode - ResourceIdNode instance. +* @param[out] pResource - the resource +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceidnode_getresource(Lib3MF_ResourceIdNode pResourceIdNode, Lib3MF_Resource * pResource); + +/** +* Retrieves the output +* +* @param[in] pResourceIdNode - ResourceIdNode instance. +* @param[out] pValue - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_resourceidnode_getoutputvalue(Lib3MF_ResourceIdNode pResourceIdNode, Lib3MF_ImplicitPort * pValue); + +/************************************************************************************************************************* + Class definition for TwoInputNode +**************************************************************************************************************************/ + +/** +* Retrieves the second input +* +* @param[in] pTwoInputNode - TwoInputNode instance. +* @param[out] pB - the second input +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_twoinputnode_getinputb(Lib3MF_TwoInputNode pTwoInputNode, Lib3MF_ImplicitPort * pB); + +/************************************************************************************************************************* + Class definition for AdditionNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for SubtractionNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for MultiplicationNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for DivisionNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for DotNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for CrossNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for ArcTan2Node +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for MatVecMultiplicationNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for MinNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for MaxNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for FmodNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for ModNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for PowNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for SelectNode +**************************************************************************************************************************/ + +/** +* Retrieves the second input +* +* @param[in] pSelectNode - SelectNode instance. +* @param[out] pB - the second input +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_selectnode_getinputb(Lib3MF_SelectNode pSelectNode, Lib3MF_ImplicitPort * pB); + +/** +* Retrieves the third input +* +* @param[in] pSelectNode - SelectNode instance. +* @param[out] pC - the third input +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_selectnode_getinputc(Lib3MF_SelectNode pSelectNode, Lib3MF_ImplicitPort * pC); + +/** +* Retrieves the fourth input +* +* @param[in] pSelectNode - SelectNode instance. +* @param[out] pD - the fourth input +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_selectnode_getinputd(Lib3MF_SelectNode pSelectNode, Lib3MF_ImplicitPort * pD); + +/************************************************************************************************************************* + Class definition for ClampNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the lower limit +* +* @param[in] pClampNode - ClampNode instance. +* @param[out] pMin - the input for the lower limit +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_clampnode_getinputmin(Lib3MF_ClampNode pClampNode, Lib3MF_ImplicitPort * pMin); + +/** +* Retrieves the input for the upper limit +* +* @param[in] pClampNode - ClampNode instance. +* @param[out] pMax - the input for the upper limit +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_clampnode_getinputmax(Lib3MF_ClampNode pClampNode, Lib3MF_ImplicitPort * pMax); + +/************************************************************************************************************************* + Class definition for ComposeVectorNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the x component +* +* @param[in] pComposeVectorNode - ComposeVectorNode instance. +* @param[out] pX - the input for the x component +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composevectornode_getinputx(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pX); + +/** +* Retrieves the input for the y component +* +* @param[in] pComposeVectorNode - ComposeVectorNode instance. +* @param[out] pY - the input for the y component +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composevectornode_getinputy(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pY); + +/** +* Retrieves the input for the z component +* +* @param[in] pComposeVectorNode - ComposeVectorNode instance. +* @param[out] pZ - the input for the z component +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composevectornode_getinputz(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pZ); + +/** +* Retrieves the output +* +* @param[in] pComposeVectorNode - ComposeVectorNode instance. +* @param[out] pResult - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composevectornode_getoutputresult(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pResult); + +/************************************************************************************************************************* + Class definition for VectorFromScalarNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for DecomposeVectorNode +**************************************************************************************************************************/ + +/** +* Retrieves the input +* +* @param[in] pDecomposeVectorNode - DecomposeVectorNode instance. +* @param[out] pA - the input port for the vector to decompose +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_decomposevectornode_getinputa(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pA); + +/** +* Retrieves the output for the x component +* +* @param[in] pDecomposeVectorNode - DecomposeVectorNode instance. +* @param[out] pX - the output for the x component +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_decomposevectornode_getoutputx(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pX); + +/** +* Retrieves the output for the y component +* +* @param[in] pDecomposeVectorNode - DecomposeVectorNode instance. +* @param[out] pY - the output for the y component +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_decomposevectornode_getoutputy(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pY); + +/** +* Retrieves the output for the z component +* +* @param[in] pDecomposeVectorNode - DecomposeVectorNode instance. +* @param[out] pZ - the output for the z component +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_decomposevectornode_getoutputz(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pZ); + +/************************************************************************************************************************* + Class definition for ComposeMatrixNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the element 0 0 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM00 - the input for the m00 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm00(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM00); + +/** +* Retrieves the input for the element 0 1 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM01 - the input for the m01 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm01(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM01); + +/** +* Retrieves the input for the element 0 2 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM02 - the input for the m02 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm02(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM02); + +/** +* Retrieves the input for the element 0 3 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM03 - the input for the m03 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm03(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM03); + +/** +* Retrieves the input for the element 1 0 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM10 - the input for the m10 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm10(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM10); + +/** +* Retrieves the input for the element 1 1 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM11 - the input for the m11 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm11(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM11); + +/** +* Retrieves the input for the element 1 2 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM12 - the input for the m12 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm12(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM12); + +/** +* Retrieves the input for the element 1 3 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM13 - the input for the m13 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm13(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM13); + +/** +* Retrieves the input for the element 2 0 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM20 - the input for the m20 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm20(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM20); + +/** +* Retrieves the input for the element 2 1 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM21 - +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm21(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM21); + +/** +* Retrieves the input for the element 2 2 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM22 - the input for the m22 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm22(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM22); + +/** +* Retrieves the input for the element 2 3 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM23 - the input for the m23 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm23(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM23); + +/** +* Retrieves the input for the element 3 0 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM30 - the input for the m30 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm30(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM30); + +/** +* Retrieves the input for the element 3 1 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM31 - the input for the m31 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm31(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM31); + +/** +* Retrieves the input for the element 3 2 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM32 - the input for the m32 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm32(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM32); + +/** +* Retrieves the input for the element 3 3 +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pM33 - the input for the m33 element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getinputm33(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM33); + +/** +* Retrieves the output +* +* @param[in] pComposeMatrixNode - ComposeMatrixNode instance. +* @param[out] pResult - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_composematrixnode_getoutputresult(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pResult); + +/************************************************************************************************************************* + Class definition for MatrixFromRowsNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the first row +* +* @param[in] pMatrixFromRowsNode - MatrixFromRowsNode instance. +* @param[out] pRow0 - the input for the first row +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromrowsnode_getinputa(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow0); + +/** +* Retrieves the input for the second row +* +* @param[in] pMatrixFromRowsNode - MatrixFromRowsNode instance. +* @param[out] pRow1 - the input for the second row +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromrowsnode_getinputb(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow1); + +/** +* Retrieves the input for the third row +* +* @param[in] pMatrixFromRowsNode - MatrixFromRowsNode instance. +* @param[out] pRow2 - the input for the third row +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromrowsnode_getinputc(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow2); + +/** +* Retrieves the input for the fourth row +* +* @param[in] pMatrixFromRowsNode - MatrixFromRowsNode instance. +* @param[out] pRow3 - the input for the fourth row +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromrowsnode_getinputd(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow3); + +/** +* Retrieves the output +* +* @param[in] pMatrixFromRowsNode - MatrixFromRowsNode instance. +* @param[out] pResult - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromrowsnode_getoutputresult(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pResult); + +/************************************************************************************************************************* + Class definition for MatrixFromColumnsNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the first column +* +* @param[in] pMatrixFromColumnsNode - MatrixFromColumnsNode instance. +* @param[out] pColumn0 - the input for the first column +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputa(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn0); + +/** +* Retrieves the input for the second column +* +* @param[in] pMatrixFromColumnsNode - MatrixFromColumnsNode instance. +* @param[out] pColumn1 - the input for the second column +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputb(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn1); + +/** +* Retrieves the input for the third column +* +* @param[in] pMatrixFromColumnsNode - MatrixFromColumnsNode instance. +* @param[out] pColumn2 - the input for the third column +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputc(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn2); + +/** +* Retrieves the input for the fourth column +* +* @param[in] pMatrixFromColumnsNode - MatrixFromColumnsNode instance. +* @param[out] pColumn3 - the input for the fourth column +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputd(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn3); + +/** +* Retrieves the output +* +* @param[in] pMatrixFromColumnsNode - MatrixFromColumnsNode instance. +* @param[out] pResult - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_matrixfromcolumnsnode_getoutputresult(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pResult); + +/************************************************************************************************************************* + Class definition for ConstantNode +**************************************************************************************************************************/ + +/** +* Sets the constant value of the node +* +* @param[in] pConstantNode - ConstantNode instance. +* @param[in] dValue - the value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constantnode_setconstant(Lib3MF_ConstantNode pConstantNode, Lib3MF_double dValue); + +/** +* Retrieves the constant value of the node +* +* @param[in] pConstantNode - ConstantNode instance. +* @param[out] pValue - the value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constantnode_getconstant(Lib3MF_ConstantNode pConstantNode, Lib3MF_double * pValue); + +/** +* Retrieves the output +* +* @param[in] pConstantNode - ConstantNode instance. +* @param[out] pValue - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constantnode_getoutputvalue(Lib3MF_ConstantNode pConstantNode, Lib3MF_ImplicitPort * pValue); + +/************************************************************************************************************************* + Class definition for ConstVecNode +**************************************************************************************************************************/ + +/** +* Sets the vector value of the node +* +* @param[in] pConstVecNode - ConstVecNode instance. +* @param[in] pValue - the value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constvecnode_setvector(Lib3MF_ConstVecNode pConstVecNode, const Lib3MF::sVector * pValue); + +/** +* Retrieves the vector value of the node +* +* @param[in] pConstVecNode - ConstVecNode instance. +* @param[out] pValue - the value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constvecnode_getvector(Lib3MF_ConstVecNode pConstVecNode, Lib3MF::sVector * pValue); + +/** +* Retrieves the output +* +* @param[in] pConstVecNode - ConstVecNode instance. +* @param[out] pVector - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constvecnode_getoutputvector(Lib3MF_ConstVecNode pConstVecNode, Lib3MF_ImplicitPort * pVector); + +/************************************************************************************************************************* + Class definition for ConstMatNode +**************************************************************************************************************************/ + +/** +* Sets the matrix value of the node +* +* @param[in] pConstMatNode - ConstMatNode instance. +* @param[in] pValue - the value +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constmatnode_setmatrix(Lib3MF_ConstMatNode pConstMatNode, const Lib3MF::sMatrix4x4 * pValue); + +/** +* Retrieves the matrix value of the node +* +* @param[in] pConstMatNode - ConstMatNode instance. +* @param[out] pValue - the matrix +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constmatnode_getmatrix(Lib3MF_ConstMatNode pConstMatNode, Lib3MF::sMatrix4x4 * pValue); + +/** +* Retrieves the output +* +* @param[in] pConstMatNode - ConstMatNode instance. +* @param[out] pMatrix - the output +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_constmatnode_getoutputmatrix(Lib3MF_ConstMatNode pConstMatNode, Lib3MF_ImplicitPort * pMatrix); + +/************************************************************************************************************************* + Class definition for MeshNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the model resource id of the mesh +* +* @param[in] pMeshNode - MeshNode instance. +* @param[out] pMesh - the input port for the model resource id of the mesh +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshnode_getinputmesh(Lib3MF_MeshNode pMeshNode, Lib3MF_ImplicitPort * pMesh); + +/** +* Retrieves the input for the position +* +* @param[in] pMeshNode - MeshNode instance. +* @param[out] pPos - the input port for the position +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshnode_getinputpos(Lib3MF_MeshNode pMeshNode, Lib3MF_ImplicitPort * pPos); + +/** +* Retrieves the output +* +* @param[in] pMeshNode - MeshNode instance. +* @param[out] pDistance - the output port for the signed distance to the mesh +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_meshnode_getoutputdistance(Lib3MF_MeshNode pMeshNode, Lib3MF_ImplicitPort * pDistance); + +/************************************************************************************************************************* + Class definition for UnsignedMeshNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the model resource id of the mesh +* +* @param[in] pUnsignedMeshNode - UnsignedMeshNode instance. +* @param[out] pMesh - the input port for the model resource id of the mesh +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_unsignedmeshnode_getinputmesh(Lib3MF_UnsignedMeshNode pUnsignedMeshNode, Lib3MF_ImplicitPort * pMesh); + +/** +* Retrieves the input for the position +* +* @param[in] pUnsignedMeshNode - UnsignedMeshNode instance. +* @param[out] pPos - the input port for the position +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_unsignedmeshnode_getinputpos(Lib3MF_UnsignedMeshNode pUnsignedMeshNode, Lib3MF_ImplicitPort * pPos); + +/** +* Retrieves the output +* +* @param[in] pUnsignedMeshNode - UnsignedMeshNode instance. +* @param[out] pDistance - the output port for the unsigned distance to the mesh +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_unsignedmeshnode_getoutputdistance(Lib3MF_UnsignedMeshNode pUnsignedMeshNode, Lib3MF_ImplicitPort * pDistance); + +/************************************************************************************************************************* + Class definition for BeamLatticeNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the model resource id of the beam lattice +* +* @param[in] pBeamLatticeNode - BeamLatticeNode instance. +* @param[out] pBeamLattice - the input port for the model resource id of the beam lattice (mesh with beamlattice extension) +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlatticenode_getinputbeamlattice(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_ImplicitPort * pBeamLattice); + +/** +* Retrieves the input for the position +* +* @param[in] pBeamLatticeNode - BeamLatticeNode instance. +* @param[out] pPos - the input port for the position +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlatticenode_getinputpos(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_ImplicitPort * pPos); + +/** +* Retrieves the output +* +* @param[in] pBeamLatticeNode - BeamLatticeNode instance. +* @param[out] pDistance - the output port for the signed distance to the beam lattice +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlatticenode_getoutputdistance(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_ImplicitPort * pDistance); + +/** +* Sets the accurate range for distance computation +* +* @param[in] pBeamLatticeNode - BeamLatticeNode instance. +* @param[in] dAccurateRange - the accurate range in model units +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlatticenode_setaccuraterange(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_double dAccurateRange); + +/** +* Retrieves the accurate range for distance computation +* +* @param[in] pBeamLatticeNode - BeamLatticeNode instance. +* @param[out] pAccurateRange - the accurate range in model units +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_beamlatticenode_getaccuraterange(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_double * pAccurateRange); + +/************************************************************************************************************************* + Class definition for FunctionGradientNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the function id +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[out] pFunction - the input port for the function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getinputfunctionid(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pFunction); + +/** +* Retrieves the input for the position +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[out] pPos - the input port for the position +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getinputpos(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pPos); + +/** +* Retrieves the input for the finite difference step +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[out] pStep - the input port for the finite difference step +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getinputstep(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pStep); + +/** +* Sets the name of the referenced scalar output +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[in] pScalarOutputName - the name of the scalar output of the referenced function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_setscalaroutputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const char * pScalarOutputName); + +/** +* Retrieves the name of the referenced scalar output +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[in] nScalarOutputNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pScalarOutputNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pScalarOutputNameBuffer - buffer of the name of the scalar output of the referenced function, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getscalaroutputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const Lib3MF_uint32 nScalarOutputNameBufferSize, Lib3MF_uint32* pScalarOutputNameNeededChars, char * pScalarOutputNameBuffer); + +/** +* Sets the name of the referenced vector input +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[in] pVectorInputName - the name of the vector input (float3) of the referenced function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_setvectorinputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const char * pVectorInputName); + +/** +* Retrieves the name of the referenced vector input +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[in] nVectorInputNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pVectorInputNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pVectorInputNameBuffer - buffer of the name of the vector input (float3) of the referenced function, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getvectorinputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const Lib3MF_uint32 nVectorInputNameBufferSize, Lib3MF_uint32* pVectorInputNameNeededChars, char * pVectorInputNameBuffer); + +/** +* Retrieves the normalized gradient output +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[out] pNormalizedGradient - the output port for the normalized gradient +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getoutputnormalizedgradient(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pNormalizedGradient); + +/** +* Retrieves the raw gradient output +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[out] pGradient - the output port for the raw gradient +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getoutputgradient(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pGradient); + +/** +* Retrieves the gradient magnitude output +* +* @param[in] pFunctionGradientNode - FunctionGradientNode instance. +* @param[out] pMagnitude - the output port for the gradient magnitude +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functiongradientnode_getoutputmagnitude(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pMagnitude); + +/************************************************************************************************************************* + Class definition for NormalizeDistanceNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the function id +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[out] pFunction - the input port for the function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_getinputfunctionid(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pFunction); + +/** +* Retrieves the input for the position +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[out] pPos - the input port for the position (vector) +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_getinputpos(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pPos); + +/** +* Retrieves the input for the finite difference step +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[out] pStep - the input port for the finite difference step +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_getinputstep(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pStep); + +/** +* Sets the name of the referenced scalar output +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[in] pScalarOutputName - the name of the scalar output of the referenced function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_setscalaroutputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const char * pScalarOutputName); + +/** +* Retrieves the name of the referenced scalar output +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[in] nScalarOutputNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pScalarOutputNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pScalarOutputNameBuffer - buffer of the name of the scalar output of the referenced function, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_getscalaroutputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const Lib3MF_uint32 nScalarOutputNameBufferSize, Lib3MF_uint32* pScalarOutputNameNeededChars, char * pScalarOutputNameBuffer); + +/** +* Sets the name of the referenced vector input +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[in] pVectorInputName - the name of the vector input (float3) of the referenced function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_setvectorinputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const char * pVectorInputName); + +/** +* Retrieves the name of the referenced vector input +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[in] nVectorInputNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pVectorInputNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pVectorInputNameBuffer - buffer of the name of the vector input (float3) of the referenced function, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_getvectorinputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const Lib3MF_uint32 nVectorInputNameBufferSize, Lib3MF_uint32* pVectorInputNameNeededChars, char * pVectorInputNameBuffer); + +/** +* Retrieves the normalized result output +* +* @param[in] pNormalizeDistanceNode - NormalizeDistanceNode instance. +* @param[out] pResult - the output port for the normalized distance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_normalizedistancenode_getoutputresult(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pResult); + +/************************************************************************************************************************* + Class definition for FunctionCallNode +**************************************************************************************************************************/ + +/** +* Retrieves the input for the function id +* +* @param[in] pFunctionCallNode - FunctionCallNode instance. +* @param[out] pFunction - the input port for the function +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functioncallnode_getinputfunctionid(Lib3MF_FunctionCallNode pFunctionCallNode, Lib3MF_ImplicitPort * pFunction); + +/************************************************************************************************************************* + Class definition for NodeIterator +**************************************************************************************************************************/ + +/** +* Returns the current element +* +* @param[in] pNodeIterator - NodeIterator instance. +* @param[out] pNode - The current element +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_nodeiterator_getcurrent(Lib3MF_NodeIterator pNodeIterator, Lib3MF_ImplicitNode * pNode); + +/************************************************************************************************************************* + Class definition for Function +**************************************************************************************************************************/ + +/** +* Retrieves the display name of the function +* +* @param[in] pFunction - Function instance. +* @param[in] nDisplayNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pDisplayNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pDisplayNameBuffer - buffer of the display name, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_getdisplayname(Lib3MF_Function pFunction, const Lib3MF_uint32 nDisplayNameBufferSize, Lib3MF_uint32* pDisplayNameNeededChars, char * pDisplayNameBuffer); + +/** +* Sets the display name of the function +* +* @param[in] pFunction - Function instance. +* @param[in] pDisplayName - the display name +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_setdisplayname(Lib3MF_Function pFunction, const char * pDisplayName); + +/** +* Add an input +* +* @param[in] pFunction - Function instance. +* @param[in] pIdentifier - the identifier of the input +* @param[in] pDisplayName - the display name of the input +* @param[in] eType - the type of the input +* @param[out] pPort - The added input port +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_addinput(Lib3MF_Function pFunction, const char * pIdentifier, const char * pDisplayName, Lib3MF::eImplicitPortType eType, Lib3MF_ImplicitPort * pPort); + +/** +* Retrieves the inputs +* +* @param[in] pFunction - Function instance. +* @param[out] pIterator - iterator for the list of inputs +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_getinputs(Lib3MF_Function pFunction, Lib3MF_ImplicitPortIterator * pIterator); + +/** +* Removes an input +* +* @param[in] pFunction - Function instance. +* @param[in] pInput - The input to be removed +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_removeinput(Lib3MF_Function pFunction, Lib3MF_ImplicitPort pInput); + +/** +* Add an output +* +* @param[in] pFunction - Function instance. +* @param[in] pIdentifier - the identifier of the output +* @param[in] pDisplayName - the display name of the output +* @param[in] eType - the type of the input +* @param[out] pPort - The added input port +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_addoutput(Lib3MF_Function pFunction, const char * pIdentifier, const char * pDisplayName, Lib3MF::eImplicitPortType eType, Lib3MF_ImplicitPort * pPort); + +/** +* Retrieves the outputs +* +* @param[in] pFunction - Function instance. +* @param[out] pIterator - iterator for the outputs +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_getoutputs(Lib3MF_Function pFunction, Lib3MF_ImplicitPortIterator * pIterator); + +/** +* Removes an output +* +* @param[in] pFunction - Function instance. +* @param[in] pOutput - The output to be removed +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_removeoutput(Lib3MF_Function pFunction, Lib3MF_ImplicitPort pOutput); + +/** +* Retrieves an input +* +* @param[in] pFunction - Function instance. +* @param[in] pIdentifier - the identifier of the input +* @param[out] pInput - the input port +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_findinput(Lib3MF_Function pFunction, const char * pIdentifier, Lib3MF_ImplicitPort * pInput); + +/** +* Retrieves an output +* +* @param[in] pFunction - Function instance. +* @param[in] pIdentifier - the identifier of the output +* @param[out] pOutput - the output port +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_function_findoutput(Lib3MF_Function pFunction, const char * pIdentifier, Lib3MF_ImplicitPort * pOutput); + +/************************************************************************************************************************* + Class definition for ImplicitFunction +**************************************************************************************************************************/ + +/** +* Retrieves the identifier of the function +* +* @param[in] pImplicitFunction - ImplicitFunction 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 the identifier, may be NULL +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_getidentifier(Lib3MF_ImplicitFunction pImplicitFunction, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer); + +/** +* Sets the identifier of the function +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_setidentifier(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier); + +/** +* Add a node +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] eNodeType - the type of the node +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addnode(Lib3MF_ImplicitFunction pImplicitFunction, Lib3MF::eImplicitNodeType eNodeType, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ImplicitNode * pNode); + +/** +* Add a SinNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addsinnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SinNode * pNode); + +/** +* Add a CosNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addcosnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_CosNode * pNode); + +/** +* Add a TanNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addtannode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_TanNode * pNode); + +/** +* Add a ArcSinNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addarcsinnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ArcSinNode * pNode); + +/** +* Add a ArcCosNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addarccosnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ArcCosNode * pNode); + +/** +* Add a ArcTan2Node +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addarctan2node(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ArcTan2Node * pNode); + +/** +* Add a SinhNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addsinhnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SinhNode * pNode); + +/** +* Add a CoshNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addcoshnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_CoshNode * pNode); + +/** +* Add a TanhNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addtanhnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_TanhNode * pNode); + +/** +* Add a RoundNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addroundnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_RoundNode * pNode); + +/** +* Add a CeilNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addceilnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_CeilNode * pNode); + +/** +* Add a FloorNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addfloornode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_FloorNode * pNode); + +/** +* Add a SignNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addsignnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SignNode * pNode); + +/** +* Add a FractNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addfractnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_FractNode * pNode); + +/** +* Add a AbsNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addabsnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_AbsNode * pNode); + +/** +* Add a ExpNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addexpnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ExpNode * pNode); + +/** +* Add a LogNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addlognode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_LogNode * pNode); + +/** +* Add a Log2Node +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addlog2node(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_Log2Node * pNode); + +/** +* Add a Log10Node +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addlog10node(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_Log10Node * pNode); + +/** +* Add a LengthNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addlengthnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_LengthNode * pNode); + +/** +* Add a TransposeNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addtransposenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_TransposeNode * pNode); + +/** +* Add a InverseNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addinversenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_InverseNode * pNode); + +/** +* Add a SqrtNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addsqrtnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SqrtNode * pNode); + +/** +* Add a ResourceIdNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addresourceidnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ResourceIdNode * pNode); + +/** +* Add an AdditionNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addadditionnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_AdditionNode * pNode); + +/** +* Add a SubtractionNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addsubtractionnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SubtractionNode * pNode); + +/** +* Add a MultiplicationNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addmultiplicationnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_MultiplicationNode * pNode); + +/** +* Add a DivisionNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_adddivisionnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_DivisionNode * pNode); + +/** +* Add a DotNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_adddotnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_DotNode * pNode); + +/** +* Add a CrossNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addcrossnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_CrossNode * pNode); + +/** +* Add a MatVecMultiplicationNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addmatvecmultiplicationnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MatVecMultiplicationNode * pNode); + +/** +* Add a MinNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addminnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_MinNode * pNode); + +/** +* Add a MaxNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addmaxnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_MaxNode * pNode); + +/** +* Add a FmodNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addfmodnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_FmodNode * pNode); + +/** +* Add a PowNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addpownode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_PowNode * pNode); + +/** +* Add a SelectNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addselectnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SelectNode * pNode); + +/** +* Add a ClampNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] eConfiguration - the configuration of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addclampnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, Lib3MF::eImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ClampNode * pNode); + +/** +* Add a ComposeVectorNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addcomposevectornode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ComposeVectorNode * pNode); + +/** +* Add a VectorFromScalar +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addvectorfromscalarnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_VectorFromScalarNode * pNode); + +/** +* Add a DecomposeVectorNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_adddecomposevectornode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_DecomposeVectorNode * pNode); + +/** +* Add a ComposeMatrixNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addcomposematrixnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ComposeMatrixNode * pNode); + +/** +* Add a MatrixFromRowsNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addmatrixfromrowsnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MatrixFromRowsNode * pNode); + +/** +* Add a MatrixFromColumnsNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addmatrixfromcolumnsnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MatrixFromColumnsNode * pNode); + +/** +* Add a ConstantNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addconstantnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ConstantNode * pNode); + +/** +* Add a ConstVecNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addconstvecnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ConstVecNode * pNode); + +/** +* Add a ConstMatNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addconstmatnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ConstMatNode * pNode); + +/** +* Add a MeshNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addmeshnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MeshNode * pNode); + +/** +* Add a UnsignedMeshNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addunsignedmeshnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_UnsignedMeshNode * pNode); + +/** +* Add a BeamLatticeNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addbeamlatticenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_BeamLatticeNode * pNode); + +/** +* Add a FunctionGradientNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addfunctiongradientnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_FunctionGradientNode * pNode); + +/** +* Add a NormalizeDistanceNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addnormalizedistancenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_NormalizeDistanceNode * pNode); + +/** +* Add a FunctionCallNode +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pIdentifier - the identifier of the node +* @param[in] pDisplayName - the display name of the node +* @param[in] pTag - the tag of the node +* @param[out] pNode - the added node +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addfunctioncallnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_FunctionCallNode * pNode); + +/** +* Retrieves the nodes +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[out] pIterator - iterator for the list of nodes +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_getnodes(Lib3MF_ImplicitFunction pImplicitFunction, Lib3MF_NodeIterator * pIterator); + +/** +* Removes a node +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pNode - The node to be removed +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_removenode(Lib3MF_ImplicitFunction pImplicitFunction, Lib3MF_ImplicitNode pNode); + +/** +* Add a link +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pSource - the source port +* @param[in] pTarget - the target port +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addlink(Lib3MF_ImplicitFunction pImplicitFunction, Lib3MF_ImplicitPort pSource, Lib3MF_ImplicitPort pTarget); + +/** +* Add a link +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @param[in] pSource - name of the source port in the format nodename.portname +* @param[in] pTarget - name of the target port in the format nodename.portname +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_addlinkbynames(Lib3MF_ImplicitFunction pImplicitFunction, const char * pSource, const char * pTarget); + +/** +* Clears the function +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_clear(Lib3MF_ImplicitFunction pImplicitFunction); + +/** +* Sorts the nodes topologically +* +* @param[in] pImplicitFunction - ImplicitFunction instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_implicitfunction_sortnodestopologically(Lib3MF_ImplicitFunction pImplicitFunction); + +/************************************************************************************************************************* + Class definition for FunctionFromImage3D +**************************************************************************************************************************/ + +/** +* Returns the selected 3D image. +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[out] pImage3D - image instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_getimage3d(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_Image3D * pImage3D); + +/** +* Sets the 3D image of the selector. +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[in] pImage3D - image instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_setimage3d(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_Image3D pImage3D); + +/** +* Sets the texture filter of the selector. +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[in] eFilter - texture filter +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_setfilter(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF::eTextureFilter eFilter); + +/** +* Returns the texture filter of the selector. +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[out] pFilter - texture filter +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_getfilter(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF::eTextureFilter * pFilter); + +/** +* Sets the tile styles of the selector. +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[in] eTileStyleU - tile style in U +* @param[in] eTileStyleV - tile style in V +* @param[in] eTileStyleW - tile style in W +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_settilestyles(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF::eTextureTileStyle eTileStyleU, Lib3MF::eTextureTileStyle eTileStyleV, Lib3MF::eTextureTileStyle eTileStyleW); + +/** +* Retrieves the tile styles of the selector. +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[out] pTileStyleU - tile style in U +* @param[out] pTileStyleV - tile style in V +* @param[out] pTileStyleW - tile style in W +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_gettilestyles(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF::eTextureTileStyle * pTileStyleU, Lib3MF::eTextureTileStyle * pTileStyleV, Lib3MF::eTextureTileStyle * pTileStyleW); + +/** +* returns the offset value for the pixel values in the Image3D +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[out] pOffset - the offset value for the pixel values in the Image3D +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_getoffset(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double * pOffset); + +/** +* Sets the offset value for the pixel values in the Image3D +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[in] dOffset - the offset value for the pixel values in the Image3D +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_setoffset(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double dOffset); + +/** +* returns the scale value for the pixel values in the Image3D +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[out] pScale - the scale value for the pixel values in the Image3D +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_getscale(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double * pScale); + +/** +* Sets the scale value for the pixel values in the Image3D +* +* @param[in] pFunctionFromImage3D - FunctionFromImage3D instance. +* @param[in] dScale - the scale value for the pixel values in the Image3D +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_functionfromimage3d_setscale(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double dScale); + /************************************************************************************************************************* Class definition for BuildItem **************************************************************************************************************************/ @@ -3024,6 +6088,16 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_querywriter(Lib3MF_Model pModel, const */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_queryreader(Lib3MF_Model pModel, const char * pReaderClass, Lib3MF_Reader * pReaderInstance); +/** +* finds a model resource by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pResource - returns the resource instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getresourcebyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_Resource * pResource); + /** * finds a model texture by its UniqueResourceID * @@ -3124,6 +6198,16 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getcolorgroupbyid(Lib3MF_Model pModel, */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getslicestackbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_SliceStack * pSliceStacInstance); +/** +* finds a level set object by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pLevelSetObjectInstance - returns the level set object instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsetbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_LevelSet * pLevelSetObjectInstance); + /** * returns, whether a build has a UUID and, if true, the build's UUID * @@ -3262,6 +6346,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getmultipropertygroups(Lib3MF_Model pM */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getslicestacks(Lib3MF_Model pModel, Lib3MF_SliceStackIterator * pResourceIterator); +/** +* creates a resource iterator instance with all image3d resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getimage3ds(Lib3MF_Model pModel, Lib3MF_Image3DIterator * 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. * @@ -3271,6 +6364,15 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getslicestacks(Lib3MF_Model pModel, Li */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_mergetomodel(Lib3MF_Model pModel, Lib3MF_Model * pMergedModelInstance); +/** +* Merges the given model into this model. +* +* @param[in] pModel - Model instance. +* @param[in] pModelInstance - model to be merged +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_mergefrommodel(Lib3MF_Model pModel, Lib3MF_Model pModelInstance); + /** * adds an empty mesh object to the model. * @@ -3356,6 +6458,28 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addcompositematerials(Lib3MF_Model pMo */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addmultipropertygroup(Lib3MF_Model pModel, Lib3MF_MultiPropertyGroup * pMultiPropertyGroupInstance); +/** +* creates a new 3D Image Resource +* +* @param[in] pModel - Model instance. +* @param[in] nColumnCount - the number of columns in each sheet. +* @param[in] nRowCount - the number of rows in each sheet. +* @param[in] nSheetCount - the number of sheets in the image stack. +* @param[out] pInstance - returns the new ImageStack instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addimagestack(Lib3MF_Model pModel, Lib3MF_uint32 nColumnCount, Lib3MF_uint32 nRowCount, Lib3MF_uint32 nSheetCount, Lib3MF_ImageStack * pInstance); + +/** +* finds an ImageStack object by its UniqueResourceID +* +* @param[in] pModel - Model instance. +* @param[in] nUniqueResourceID - UniqueResourceID +* @param[out] pImageStackInstance - returns the image stack instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getimagestackbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_ImageStack * pImageStackInstance); + /** * adds a build item to the model. * @@ -3507,6 +6631,70 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_setrandomnumbercallback(Lib3MF_Model p */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getkeystore(Lib3MF_Model pModel, Lib3MF_KeyStore * pKeyStore); +/** +* creates a resource iterator for all functions +* +* @param[in] pModel - Model instance. +* @param[out] pTheResourceIterator - returns the resource iterator +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getfunctions(Lib3MF_Model pModel, Lib3MF_FunctionIterator * pTheResourceIterator); + +/** +* adds a function described by nodes to the model +* +* @param[in] pModel - Model instance. +* @param[out] pFunctionInstance - returns the function instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addimplicitfunction(Lib3MF_Model pModel, Lib3MF_ImplicitFunction * pFunctionInstance); + +/** +* adds a function defined by an image3d to the model +* +* @param[in] pModel - Model instance. +* @param[in] pImage3DInstance - the Image3D-instance used for this function +* @param[out] pFunctionInstance - returns the function instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addfunctionfromimage3d(Lib3MF_Model pModel, Lib3MF_Image3D pImage3DInstance, Lib3MF_FunctionFromImage3D * pFunctionInstance); + +/** +* adds a volume data resource to the model. +* +* @param[in] pModel - Model instance. +* @param[out] pVolumeDataInstance - returns the new volume data instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addvolumedata(Lib3MF_Model pModel, Lib3MF_VolumeData * pVolumeDataInstance); + +/** +* adds an empty boundary shape object to the model. +* +* @param[in] pModel - Model instance. +* @param[out] pLevelSetInstance - returns the mesh object instance +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_addlevelset(Lib3MF_Model pModel, Lib3MF_LevelSet * pLevelSetInstance); + +/** +* creates a resource iterator instance with all boundary shape resources. +* +* @param[in] pModel - Model instance. +* @param[out] pResourceIterator - returns the iterator instance. +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator); + +/** +* Removes a resource from the model +* +* @param[in] pModel - Model instance. +* @param[in] pResource - The resource to remove +* @return error code or 0 (success) +*/ +LIB3MF_DECLSPEC Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource); + /************************************************************************************************************************* Global functions **************************************************************************************************************************/ @@ -3705,7 +6893,9 @@ LIB3MF_DECLSPEC Lib3MFResult lib3mf_getscaletransform(Lib3MF_single fFactorX, Li */ LIB3MF_DECLSPEC Lib3MFResult lib3mf_gettranslationtransform(Lib3MF_single fVectorX, Lib3MF_single fVectorY, Lib3MF_single fVectorZ, Lib3MF::sTransform * pTransform); +#ifdef __cplusplus } +#endif #endif // __LIB3MF_HEADER_CPP diff --git a/Include/lib3mf_interfaceexception.hpp b/Include/lib3mf_interfaceexception.hpp index ae098c8..51201c2 100644 --- a/Include/lib3mf_interfaceexception.hpp +++ b/Include/lib3mf_interfaceexception.hpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,12 +24,12 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. Abstract: This is an autogenerated C++ Header file with the basic internal exception type in order to allow an easy use of the 3MF Library -Interface version: 2.2.0 +Interface version: 2.5.0 */ diff --git a/Include/lib3mf_interfacejournal.hpp b/Include/lib3mf_interfacejournal.hpp index 6c9bffb..ce6e589 100644 --- a/Include/lib3mf_interfacejournal.hpp +++ b/Include/lib3mf_interfacejournal.hpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,12 +24,12 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. Abstract: This is an autogenerated C++ header file in order to allow easy development of the 3MF Library. It provides an automatic Journaling mechanism for the library implementation. -Interface version: 2.2.0 +Interface version: 2.5.0 */ diff --git a/Include/lib3mf_interfaces.hpp b/Include/lib3mf_interfaces.hpp index 3e71cc1..1867748 100644 --- a/Include/lib3mf_interfaces.hpp +++ b/Include/lib3mf_interfaces.hpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,13 +24,13 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. Abstract: This is an autogenerated C++ header file in order to allow easy development of the 3MF Library. The implementer of the 3MF Library needs to derive concrete classes from the abstract classes in this header. -Interface version: 2.2.0 +Interface version: 2.5.0 */ @@ -67,11 +67,22 @@ class IColorGroupIterator; class ITexture2DGroupIterator; class ICompositeMaterialsIterator; class IMultiPropertyGroupIterator; +class IImage3DIterator; +class IFunctionIterator; +class ILevelSetIterator; class IMetaData; class IMetaDataGroup; +class ITriangleSet; class IObject; class IMeshObject; +class ILevelSet; class IBeamLattice; +class IFunctionReference; +class IVolumeDataColor; +class IMaterialMapping; +class IVolumeDataComposite; +class IVolumeDataProperty; +class IVolumeData; class IComponent; class IComponentsObject; class IBeamSet; @@ -80,8 +91,74 @@ class IColorGroup; class ITexture2DGroup; class ICompositeMaterials; class IMultiPropertyGroup; +class IImage3D; +class IImageStack; class IAttachment; class ITexture2D; +class IImplicitPort; +class IIterator; +class IImplicitPortIterator; +class IImplicitNode; +class IOneInputNode; +class ISinNode; +class ICosNode; +class ITanNode; +class IArcSinNode; +class IArcCosNode; +class IArcTanNode; +class ISinhNode; +class ICoshNode; +class ITanhNode; +class IRoundNode; +class ICeilNode; +class IFloorNode; +class ISignNode; +class IFractNode; +class IAbsNode; +class IExpNode; +class ILogNode; +class ILog2Node; +class ILog10Node; +class ILengthNode; +class ITransposeNode; +class IInverseNode; +class ISqrtNode; +class IResourceIdNode; +class ITwoInputNode; +class IAdditionNode; +class ISubtractionNode; +class IMultiplicationNode; +class IDivisionNode; +class IDotNode; +class ICrossNode; +class IArcTan2Node; +class IMatVecMultiplicationNode; +class IMinNode; +class IMaxNode; +class IFmodNode; +class IModNode; +class IPowNode; +class ISelectNode; +class IClampNode; +class IComposeVectorNode; +class IVectorFromScalarNode; +class IDecomposeVectorNode; +class IComposeMatrixNode; +class IMatrixFromRowsNode; +class IMatrixFromColumnsNode; +class IConstantNode; +class IConstVecNode; +class IConstMatNode; +class IMeshNode; +class IUnsignedMeshNode; +class IBeamLatticeNode; +class IFunctionGradientNode; +class INormalizeDistanceNode; +class IFunctionCallNode; +class INodeIterator; +class IFunction; +class IImplicitFunction; +class IFunctionFromImage3D; class IBuildItem; class IBuildItemIterator; class ISlice; @@ -96,11 +173,95 @@ class IModel; +/************************************************************************************************************************* + Parameter Cache definitions +**************************************************************************************************************************/ + +class ParameterCache { + public: + virtual ~ParameterCache() {} +}; + +template class ParameterCache_1 : public ParameterCache { + private: + T1 m_param1; + public: + ParameterCache_1 (const T1 & param1) + : m_param1 (param1) + { + } + + void retrieveData (T1 & param1) + { + param1 = m_param1; + } +}; + +template class ParameterCache_2 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + public: + ParameterCache_2 (const T1 & param1, const T2 & param2) + : m_param1 (param1), m_param2 (param2) + { + } + + void retrieveData (T1 & param1, T2 & param2) + { + param1 = m_param1; + param2 = m_param2; + } +}; + +template class ParameterCache_3 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + public: + ParameterCache_3 (const T1 & param1, const T2 & param2, const T3 & param3) + : m_param1 (param1), m_param2 (param2), m_param3 (param3) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + } +}; + +template class ParameterCache_4 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + T4 m_param4; + public: + ParameterCache_4 (const T1 & param1, const T2 & param2, const T3 & param3, const T4 & param4) + : m_param1 (param1), m_param2 (param2), m_param3 (param3), m_param4 (param4) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3, T4 & param4) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + param4 = m_param4; + } +}; + + /************************************************************************************************************************* Class interface for Base **************************************************************************************************************************/ class IBase { +protected: + std::unique_ptr m_ParameterCache; public: /** * IBase::~IBase - virtual destructor of IBase @@ -158,6 +319,28 @@ public: * @return Has the object been released */ virtual bool DecRefCount() = 0; + + /** + * IBase::_setCache - set parameter cache of object + */ + void _setCache(ParameterCache * pCache) + { + m_ParameterCache.reset(pCache); + } + + /** + * IBase::_getCache - returns parameter cache of object + */ + ParameterCache* _getCache() + { + return m_ParameterCache.get(); + } + + /** + * IBase::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + virtual Lib3MF_uint64 ClassTypeId() = 0; }; @@ -199,6 +382,15 @@ typedef IBaseSharedPtr PIBase; class IWriter : public virtual IBase { public: + /** + * IWriter::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE76F642F363FD7E9UL; // First 64 bits of SHA1 of a string: "Lib3MF::Writer" + } + /** * IWriter::WriteToFile - Writes out the model as file. The file type is specified by the Model Writer class. * @param[in] sFilename - Filename to write into @@ -298,6 +490,15 @@ typedef IBaseSharedPtr PIWriter; class IReader : public virtual IBase { public: + /** + * IReader::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x2D86831DA59FBE72UL; // First 64 bits of SHA1 of a string: "Lib3MF::Reader" + } + /** * IReader::ReadFromFile - Reads a model from a file. The file type is specified by the Model Reader class * @param[in] sFilename - Filename to read from @@ -391,6 +592,15 @@ typedef IBaseSharedPtr PIReader; class IPackagePart : public virtual IBase { public: + /** + * IPackagePart::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE55A826D377483EUL; // First 64 bits of SHA1 of a string: "Lib3MF::PackagePart" + } + /** * IPackagePart::GetPath - Returns the absolute path of this PackagePart. * @return Returns the absolute path of this PackagePart @@ -414,6 +624,15 @@ typedef IBaseSharedPtr PIPackagePart; class IResource : public virtual IBase { public: + /** + * IResource::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xDFE3889D1B269CBBUL; // First 64 bits of SHA1 of a string: "Lib3MF::Resource" + } + /** * IResource::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. @@ -455,6 +674,15 @@ typedef IBaseSharedPtr PIResource; class IResourceIterator : public virtual IBase { public: + /** + * IResourceIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x460F3515E2621DBEUL; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceIterator" + } + /** * IResourceIterator::MoveNext - Iterates to the next resource in the list. * @return Iterates to the next resource in the list. @@ -496,6 +724,15 @@ typedef IBaseSharedPtr PIResourceIterator; class ISliceStackIterator : public virtual IResourceIterator { public: + /** + * ISliceStackIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x69684DB99FA813F6UL; // First 64 bits of SHA1 of a string: "Lib3MF::SliceStackIterator" + } + /** * ISliceStackIterator::GetCurrentSliceStack - Returns the SliceStack the iterator points at. * @return returns the SliceStack instance. @@ -513,6 +750,15 @@ typedef IBaseSharedPtr PISliceStackIterator; class IObjectIterator : public virtual IResourceIterator { public: + /** + * IObjectIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xDE92510BD2112288UL; // First 64 bits of SHA1 of a string: "Lib3MF::ObjectIterator" + } + /** * IObjectIterator::GetCurrentObject - Returns the Object the iterator points at. * @return returns the Object instance. @@ -530,6 +776,15 @@ typedef IBaseSharedPtr PIObjectIterator; class IMeshObjectIterator : public virtual IResourceIterator { public: + /** + * IMeshObjectIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xF4196034E2B9FDE6UL; // First 64 bits of SHA1 of a string: "Lib3MF::MeshObjectIterator" + } + /** * IMeshObjectIterator::GetCurrentMeshObject - Returns the MeshObject the iterator points at. * @return returns the MeshObject instance. @@ -547,6 +802,15 @@ typedef IBaseSharedPtr PIMeshObjectIterator; class IComponentsObjectIterator : public virtual IResourceIterator { public: + /** + * IComponentsObjectIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x564DE4217ED7614AUL; // First 64 bits of SHA1 of a string: "Lib3MF::ComponentsObjectIterator" + } + /** * IComponentsObjectIterator::GetCurrentComponentsObject - Returns the ComponentsObject the iterator points at. * @return returns the ComponentsObject instance. @@ -564,6 +828,15 @@ typedef IBaseSharedPtr PIComponentsObjectIterator; class ITexture2DIterator : public virtual IResourceIterator { public: + /** + * ITexture2DIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x4BD32B4870FFC03BUL; // First 64 bits of SHA1 of a string: "Lib3MF::Texture2DIterator" + } + /** * ITexture2DIterator::GetCurrentTexture2D - Returns the Texture2D the iterator points at. * @return returns the Texture2D instance. @@ -581,6 +854,15 @@ typedef IBaseSharedPtr PITexture2DIterator; class IBaseMaterialGroupIterator : public virtual IResourceIterator { public: + /** + * IBaseMaterialGroupIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x65E6EDD9362C79CBUL; // First 64 bits of SHA1 of a string: "Lib3MF::BaseMaterialGroupIterator" + } + /** * IBaseMaterialGroupIterator::GetCurrentBaseMaterialGroup - Returns the MaterialGroup the iterator points at. * @return returns the BaseMaterialGroup instance. @@ -598,6 +880,15 @@ typedef IBaseSharedPtr PIBaseMaterialGroupIterator; class IColorGroupIterator : public virtual IResourceIterator { public: + /** + * IColorGroupIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x10274A1757C729C0UL; // First 64 bits of SHA1 of a string: "Lib3MF::ColorGroupIterator" + } + /** * IColorGroupIterator::GetCurrentColorGroup - Returns the ColorGroup the iterator points at. * @return returns the ColorGroup instance. @@ -615,6 +906,15 @@ typedef IBaseSharedPtr PIColorGroupIterator; class ITexture2DGroupIterator : public virtual IResourceIterator { public: + /** + * ITexture2DGroupIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x30D55F4DB88FE0CAUL; // First 64 bits of SHA1 of a string: "Lib3MF::Texture2DGroupIterator" + } + /** * ITexture2DGroupIterator::GetCurrentTexture2DGroup - Returns the Texture2DGroup the iterator points at. * @return returns the Texture2DGroup instance. @@ -632,6 +932,15 @@ typedef IBaseSharedPtr PITexture2DGroupIterator; class ICompositeMaterialsIterator : public virtual IResourceIterator { public: + /** + * ICompositeMaterialsIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xA99CC6C3F70FB6F9UL; // First 64 bits of SHA1 of a string: "Lib3MF::CompositeMaterialsIterator" + } + /** * ICompositeMaterialsIterator::GetCurrentCompositeMaterials - Returns the CompositeMaterials the iterator points at. * @return returns the CompositeMaterials instance. @@ -649,6 +958,15 @@ typedef IBaseSharedPtr PICompositeMaterialsIterator class IMultiPropertyGroupIterator : public virtual IResourceIterator { public: + /** + * IMultiPropertyGroupIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xC2BDF5D8CBBDB1F0UL; // First 64 bits of SHA1 of a string: "Lib3MF::MultiPropertyGroupIterator" + } + /** * IMultiPropertyGroupIterator::GetCurrentMultiPropertyGroup - Returns the MultiPropertyGroup the iterator points at. * @return returns the MultiPropertyGroup instance. @@ -660,12 +978,99 @@ public: typedef IBaseSharedPtr PIMultiPropertyGroupIterator; +/************************************************************************************************************************* + Class interface for Image3DIterator +**************************************************************************************************************************/ + +class IImage3DIterator : public virtual IResourceIterator { +public: + /** + * IImage3DIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xC4B8EC00A82BF336UL; // First 64 bits of SHA1 of a string: "Lib3MF::Image3DIterator" + } + + /** + * IImage3DIterator::GetCurrentImage3D - Returns the Image3D the iterator points at. + * @return returns the Image3D instance. + */ + virtual IImage3D * GetCurrentImage3D() = 0; + +}; + +typedef IBaseSharedPtr PIImage3DIterator; + + +/************************************************************************************************************************* + Class interface for FunctionIterator +**************************************************************************************************************************/ + +class IFunctionIterator : public virtual IResourceIterator { +public: + /** + * IFunctionIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x40E9035363ACE65EUL; // First 64 bits of SHA1 of a string: "Lib3MF::FunctionIterator" + } + + /** + * IFunctionIterator::GetCurrentFunction - Returns the Function the iterator points at. + * @return returns the Function instance. + */ + virtual IFunction * GetCurrentFunction() = 0; + +}; + +typedef IBaseSharedPtr PIFunctionIterator; + + +/************************************************************************************************************************* + Class interface for LevelSetIterator +**************************************************************************************************************************/ + +class ILevelSetIterator : public virtual IResourceIterator { +public: + /** + * ILevelSetIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xA0C005C035D5371DUL; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSetIterator" + } + + /** + * ILevelSetIterator::GetCurrentLevelSet - Returns the LevelSet the iterator points at. + * @return returns the MeshObject instance. + */ + virtual ILevelSet * GetCurrentLevelSet() = 0; + +}; + +typedef IBaseSharedPtr PILevelSetIterator; + + /************************************************************************************************************************* Class interface for MetaData **************************************************************************************************************************/ class IMetaData : public virtual IBase { public: + /** + * IMetaData::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD17716D063DE2C22UL; // First 64 bits of SHA1 of a string: "Lib3MF::MetaData" + } + /** * IMetaData::GetNameSpace - returns the namespace URL of the metadata * @return the namespace URL of the metadata @@ -743,6 +1148,15 @@ typedef IBaseSharedPtr PIMetaData; class IMetaDataGroup : public virtual IBase { public: + /** + * IMetaDataGroup::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xC3B85369E9B25D3UL; // First 64 bits of SHA1 of a string: "Lib3MF::MetaDataGroup" + } + /** * IMetaDataGroup::GetMetaDataCount - returns the number of metadata in this metadatagroup * @return returns the number metadata @@ -782,7 +1196,7 @@ public: * @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 + * @param[in] bMustPreserve - should the metadata be preserved * @return a new instance of the metadata */ virtual IMetaData * AddMetaData(const std::string & sNameSpace, const std::string & sName, const std::string & sValue, const std::string & sType, const bool bMustPreserve) = 0; @@ -792,12 +1206,123 @@ public: typedef IBaseSharedPtr PIMetaDataGroup; +/************************************************************************************************************************* + Class interface for TriangleSet +**************************************************************************************************************************/ + +class ITriangleSet : public virtual IBase { +public: + /** + * ITriangleSet::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x5950BB3EE8A82090UL; // First 64 bits of SHA1 of a string: "Lib3MF::TriangleSet" + } + + /** + * ITriangleSet::SetName - sets the name of the triangle set + * @param[in] sName - the new name + */ + virtual void SetName(const std::string & sName) = 0; + + /** + * ITriangleSet::GetName - returns the name of the triangle set + * @return returns the name + */ + virtual std::string GetName() = 0; + + /** + * ITriangleSet::SetIdentifier - sets the identifier of the triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + */ + virtual void SetIdentifier(const std::string & sIdentifier) = 0; + + /** + * ITriangleSet::GetIdentifier - returns the identifier of the triangle set + * @return returns the identifier + */ + virtual std::string GetIdentifier() = 0; + + /** + * ITriangleSet::AddTriangle - adds a triangle to the set. Does nothing if triangle is already in the set. + * @param[in] nTriangleIndex - Triangle index to add. MUST be between 0 and TriangleCount - 1. + */ + virtual void AddTriangle(const Lib3MF_uint32 nTriangleIndex) = 0; + + /** + * ITriangleSet::RemoveTriangle - removes a triangle from the set + * @param[in] nTriangleIndex - Triangle index to remove. MUST be between 0 and TriangleCount - 1. + */ + virtual void RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) = 0; + + /** + * ITriangleSet::Clear - clears all triangles from the list + */ + virtual void Clear() = 0; + + /** + * ITriangleSet::SetTriangleList - Sets all triangles in the list, while clearing old values. Duplicates will be merged. + * @param[in] nTriangleIndicesBufferSize - Number of elements in buffer + * @param[in] pTriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + virtual void SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) = 0; + + /** + * ITriangleSet::GetTriangleList - Retrieves all the triangles in the TriangleSet + * @param[in] nTriangleIndicesBufferSize - Number of elements in buffer + * @param[out] pTriangleIndicesNeededCount - will be filled with the count of the written structs, or needed buffer size. + * @param[out] pTriangleIndicesBuffer - uint32 buffer of retrieves the indices of the triangles in this TriangleSet + */ + virtual void GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) = 0; + + /** + * ITriangleSet::AddTriangleList - Adds multiple triangles in the list. Duplicates will be merged. + * @param[in] nTriangleIndicesBufferSize - Number of elements in buffer + * @param[in] pTriangleIndicesBuffer - Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1. + */ + virtual void AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) = 0; + + /** + * ITriangleSet::Merge - Merges another Triangle set. + * @param[in] pOtherTriangleSet - Other triangle set to merge. + * @param[in] bDeleteOther - Flag if other triangle set is getting removed. + */ + virtual void Merge(ITriangleSet* pOtherTriangleSet, const bool bDeleteOther) = 0; + + /** + * ITriangleSet::DeleteSet - Deletes the whole set from the mesh. + */ + virtual void DeleteSet() = 0; + + /** + * ITriangleSet::Duplicate - Duplicates the set in the mesh. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @return Copy of the triangle set. + */ + virtual ITriangleSet * Duplicate(const std::string & sIdentifier) = 0; + +}; + +typedef IBaseSharedPtr PITriangleSet; + + /************************************************************************************************************************* Class interface for Object **************************************************************************************************************************/ class IObject : public virtual IResource { public: + /** + * IObject::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x2DA2136F577A779CUL; // First 64 bits of SHA1 of a string: "Lib3MF::Object" + } + /** * IObject::GetType - Retrieves an object's type * @return returns object type enum. @@ -846,6 +1371,12 @@ public: */ virtual bool IsComponentsObject() = 0; + /** + * IObject::IsLevelSetObject - Retrieves, if an object is a level set object + * @return returns, whether the object is a level set object + */ + virtual bool IsLevelSetObject() = 0; + /** * IObject::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 @@ -941,6 +1472,15 @@ typedef IBaseSharedPtr PIObject; class IMeshObject : public virtual IObject { public: + /** + * IMeshObject::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x3B3A6DC6EC610497UL; // First 64 bits of SHA1 of a string: "Lib3MF::MeshObject" + } + /** * IMeshObject::GetVertexCount - Returns the vertex count of a mesh object. * @return filled with the vertex count. @@ -1081,17 +1621,189 @@ public: */ virtual IBeamLattice * BeamLattice() = 0; + /** + * IMeshObject::GetVolumeData - Retrieves the VolumeData of this MeshObject. + * @return the VolumeData of this MeshObject + */ + virtual IVolumeData * GetVolumeData() = 0; + + /** + * IMeshObject::SetVolumeData - Sets the VolumeData of this MeshObject. + * @param[in] pTheVolumeData - the VolumeData of this MeshObject + */ + virtual void SetVolumeData(IVolumeData* pTheVolumeData) = 0; + + /** + * IMeshObject::AddTriangleSet - Adds a new triangle set. + * @param[in] sIdentifier - the new identifier. MUST be unique within the mesh. MUST NOT be an empty string + * @param[in] sName - the human readable name. MUST NOT be an empty string + * @return the new Triangle Set Instance. + */ + virtual ITriangleSet * AddTriangleSet(const std::string & sIdentifier, const std::string & sName) = 0; + + /** + * IMeshObject::HasTriangleSet - Checks if a triangle set exists. + * @param[in] sIdentifier - the identifier to be found. + * @return flag if the triangles set exists. + */ + virtual bool HasTriangleSet(const std::string & sIdentifier) = 0; + + /** + * IMeshObject::FindTriangleSet - Finds a new triangle set by identifier. Fails if not existing. + * @param[in] sIdentifier - the identifier to be found. + * @return the triangle Set Instance. + */ + virtual ITriangleSet * FindTriangleSet(const std::string & sIdentifier) = 0; + + /** + * IMeshObject::GetTriangleSetCount - Returns number of triangle sets. + * @return the number of triangle sets of this mesh. + */ + virtual Lib3MF_uint32 GetTriangleSetCount() = 0; + + /** + * IMeshObject::GetTriangleSet - Returns a specific triangle set by index. + * @param[in] nIndex - the index of the triangle set. + * @return the triangle Set Instance. + */ + virtual ITriangleSet * GetTriangleSet(const Lib3MF_uint32 nIndex) = 0; + }; typedef IBaseSharedPtr PIMeshObject; +/************************************************************************************************************************* + Class interface for LevelSet +**************************************************************************************************************************/ + +class ILevelSet : public virtual IObject { +public: + /** + * ILevelSet::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE8A7D9C192EFD0E2UL; // First 64 bits of SHA1 of a string: "Lib3MF::LevelSet" + } + + /** + * ILevelSet::GetFunction - Returns the function that is used as boundary shape. + * @return the function to use as boundary shape + */ + virtual IFunction * GetFunction() = 0; + + /** + * ILevelSet::SetFunction - Sets the function to use as boundary shape. + * @param[in] pTheFunction - the function to use as boundary shape + */ + virtual void SetFunction(IFunction* pTheFunction) = 0; + + /** + * ILevelSet::GetTransform - Returns the transformation matrix into the coordinate system of the referenced Function. + * @return the transformation matrix + */ + virtual Lib3MF::sTransform GetTransform() = 0; + + /** + * ILevelSet::SetTransform - Sets the transformation matrix into the coordinate system of the referenced Function. + * @param[in] Transform - new transformation matrix + */ + virtual void SetTransform(const Lib3MF::sTransform Transform) = 0; + + /** + * ILevelSet::GetChannelName - Returns the name of the function output channel to use. + * @return the name of the function output channel + */ + virtual std::string GetChannelName() = 0; + + /** + * ILevelSet::SetChannelName - Sets the name of the function output channel to use. + * @param[in] sChannelName - new name of the function output channel + */ + virtual void SetChannelName(const std::string & sChannelName) = 0; + + /** + * ILevelSet::SetMinFeatureSize - Sets the minimal feature size as a hint for the function evaluator + * @param[in] dMinFeatureSize - minimal feature size + */ + virtual void SetMinFeatureSize(const Lib3MF_double dMinFeatureSize) = 0; + + /** + * ILevelSet::GetMinFeatureSize - Returns the minimal feature size as a hint for the function evaluator + * @return minimal feature size + */ + virtual Lib3MF_double GetMinFeatureSize() = 0; + + /** + * ILevelSet::SetFallBackValue - Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + virtual void SetFallBackValue(const Lib3MF_double dFallBackValue) = 0; + + /** + * ILevelSet::GetFallBackValue - Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + virtual Lib3MF_double GetFallBackValue() = 0; + + /** + * ILevelSet::SetMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary + * @param[in] bMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary + */ + virtual void SetMeshBBoxOnly(const bool bMeshBBoxOnly) = 0; + + /** + * ILevelSet::GetMeshBBoxOnly - If set only the bounding box of the mesh is intersected with the boundary + * @return If set only the bounding box of the mesh is intersected with the boundary + */ + virtual bool GetMeshBBoxOnly() = 0; + + /** + * ILevelSet::SetMesh - Sets the mesh to use as evaluation domain + * @param[in] pTheMesh - The mesh + */ + virtual void SetMesh(IMeshObject* pTheMesh) = 0; + + /** + * ILevelSet::GetMesh - Returns the mesh that is used as evaluation domain + * @return The mesh + */ + virtual IMeshObject * GetMesh() = 0; + + /** + * ILevelSet::GetVolumeData - Retrieves the VolumeData this Object. + * @return the VolumeData of this Object + */ + virtual IVolumeData * GetVolumeData() = 0; + + /** + * ILevelSet::SetVolumeData - Sets the VolumeData of this LevelSet. + * @param[in] pTheVolumeData - the VolumeData of this MeshObject + */ + virtual void SetVolumeData(IVolumeData* pTheVolumeData) = 0; + +}; + +typedef IBaseSharedPtr PILevelSet; + + /************************************************************************************************************************* Class interface for BeamLattice **************************************************************************************************************************/ class IBeamLattice : public virtual IBase { public: + /** + * IBeamLattice::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x63B3B461B30B4BA5UL; // First 64 bits of SHA1 of a string: "Lib3MF::BeamLattice" + } + /** * IBeamLattice::GetMinLength - Returns the minimal length of beams for the beamlattice. * @return minimal length of beams for the beamlattice @@ -1253,12 +1965,319 @@ public: typedef IBaseSharedPtr PIBeamLattice; +/************************************************************************************************************************* + Class interface for FunctionReference +**************************************************************************************************************************/ + +class IFunctionReference : public virtual IBase { +public: + /** + * IFunctionReference::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x4DF17E76926221C2UL; // First 64 bits of SHA1 of a string: "Lib3MF::FunctionReference" + } + + /** + * IFunctionReference::GetFunctionResourceID - Returns the UniqueResourceID of the Function. Only functions with a 'pos'-input are allowed. + * @return returns the UniqueResourceID. + */ + virtual Lib3MF_uint32 GetFunctionResourceID() = 0; + + /** + * IFunctionReference::SetFunctionResourceID - Sets the UniqueResourceID to refer to. + * @param[in] nUniqueResourceID - UniqueResourceID of the function + */ + virtual void SetFunctionResourceID(const Lib3MF_uint32 nUniqueResourceID) = 0; + + /** + * IFunctionReference::GetTransform - Returns the transformation matrix into the coordinate system of the referenced Function. + * @return the transformation matrix + */ + virtual Lib3MF::sTransform GetTransform() = 0; + + /** + * IFunctionReference::SetTransform - Sets the transformation matrix into the coordinate system of the referenced Function. + * @param[in] Transform - new transformation matrix + */ + virtual void SetTransform(const Lib3MF::sTransform Transform) = 0; + + /** + * IFunctionReference::GetChannelName - Returns the name of the function output channel to use. + * @return the name of the function output channel + */ + virtual std::string GetChannelName() = 0; + + /** + * IFunctionReference::SetChannelName - Sets the name of the function output channel to use. + * @param[in] sChannelName - new name of the function output channel + */ + virtual void SetChannelName(const std::string & sChannelName) = 0; + + /** + * IFunctionReference::SetMinFeatureSize - Sets the minimal feature size as a hint for the function evaluator + * @param[in] dMinFeatureSize - minimal feature size + */ + virtual void SetMinFeatureSize(const Lib3MF_double dMinFeatureSize) = 0; + + /** + * IFunctionReference::GetMinFeatureSize - Returns the minimal feature size as a hint for the function evaluator + * @return minimal feature size + */ + virtual Lib3MF_double GetMinFeatureSize() = 0; + + /** + * IFunctionReference::SetFallBackValue - Sets the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @param[in] dFallBackValue - fallback value + */ + virtual void SetFallBackValue(const Lib3MF_double dFallBackValue) = 0; + + /** + * IFunctionReference::GetFallBackValue - Returns the fallback value to use if the function evaluation fails (e.g. evaluates to NaN or Inf). + * @return fallback value + */ + virtual Lib3MF_double GetFallBackValue() = 0; + +}; + +typedef IBaseSharedPtr PIFunctionReference; + + +/************************************************************************************************************************* + Class interface for VolumeDataColor +**************************************************************************************************************************/ + +class IVolumeDataColor : public virtual IFunctionReference { +public: + /** + * IVolumeDataColor::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD85B5B6143E787E3UL; // First 64 bits of SHA1 of a string: "Lib3MF::VolumeDataColor" + } + +}; + +typedef IBaseSharedPtr PIVolumeDataColor; + + +/************************************************************************************************************************* + Class interface for MaterialMapping +**************************************************************************************************************************/ + +class IMaterialMapping : public virtual IFunctionReference { +public: + /** + * IMaterialMapping::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x241FE6B4817C3FE4UL; // First 64 bits of SHA1 of a string: "Lib3MF::MaterialMapping" + } + +}; + +typedef IBaseSharedPtr PIMaterialMapping; + + +/************************************************************************************************************************* + Class interface for VolumeDataComposite +**************************************************************************************************************************/ + +class IVolumeDataComposite : public virtual IBase { +public: + /** + * IVolumeDataComposite::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x46F1DAC40581B304UL; // First 64 bits of SHA1 of a string: "Lib3MF::VolumeDataComposite" + } + + /** + * IVolumeDataComposite::GetBaseMaterialGroup - Returns the BaseMaterialGroup used within this volume data item + * @return The BaseMaterialGroup instance of this VolumeDataComposite element + */ + virtual IBaseMaterialGroup * GetBaseMaterialGroup() = 0; + + /** + * IVolumeDataComposite::SetBaseMaterialGroup - Sets the BaseMaterialGroup to use within this volume data item. + * @param[in] pBaseMaterialGroupInstance - The new BaseMaterialGroup instance of this VolumeDataComposite element + */ + virtual void SetBaseMaterialGroup(IBaseMaterialGroup* pBaseMaterialGroupInstance) = 0; + + /** + * IVolumeDataComposite::GetMaterialMappingCount - Returns the number of material mappings of this VolumeDataComposite element + * @return the number of material mappings. + */ + virtual Lib3MF_uint32 GetMaterialMappingCount() = 0; + + /** + * IVolumeDataComposite::GetMaterialMapping - Returns MaterialMapping with given index + * @param[in] nIndex - Index of the MaterialMapping in question. + * @return MaterialMapping used in this element + */ + virtual IMaterialMapping * GetMaterialMapping(const Lib3MF_uint32 nIndex) = 0; + + /** + * IVolumeDataComposite::AddMaterialMapping - Adds a MaterialMapping + * @param[in] Transform - new transformation matrix + * @return The new MaterialMapping + */ + virtual IMaterialMapping * AddMaterialMapping(const Lib3MF::sTransform Transform) = 0; + + /** + * IVolumeDataComposite::RemoveMaterialMapping - Removes the MaterialMapping with given index + * @param[in] nIndex - The index of the MaterialMapping to be removed. + */ + virtual void RemoveMaterialMapping(const Lib3MF_uint32 nIndex) = 0; + +}; + +typedef IBaseSharedPtr PIVolumeDataComposite; + + +/************************************************************************************************************************* + Class interface for VolumeDataProperty +**************************************************************************************************************************/ + +class IVolumeDataProperty : public virtual IFunctionReference { +public: + /** + * IVolumeDataProperty::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xFC368AA44ACE42DAUL; // First 64 bits of SHA1 of a string: "Lib3MF::VolumeDataProperty" + } + + /** + * IVolumeDataProperty::GetName - Gets the qualified name of this property. + * @return The qualified name of this property. + */ + virtual std::string GetName() = 0; + + /** + * IVolumeDataProperty::SetIsRequired - Sets whether this property is required to process this 3MF document instance. + * @param[in] bIsRequired - New value for whether this property is required to process this 3MF document instance. + */ + virtual void SetIsRequired(const bool bIsRequired) = 0; + + /** + * IVolumeDataProperty::IsRequired - Returns whether this property is required to process this 3MF document instance. + * @return Is this property required to process this 3MF document instance? + */ + virtual bool IsRequired() = 0; + +}; + +typedef IBaseSharedPtr PIVolumeDataProperty; + + +/************************************************************************************************************************* + Class interface for VolumeData +**************************************************************************************************************************/ + +class IVolumeData : public virtual IResource { +public: + /** + * IVolumeData::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x9200586FB91587A7UL; // First 64 bits of SHA1 of a string: "Lib3MF::VolumeData" + } + + /** + * IVolumeData::GetComposite - Returns the VolumeDataComposite of this VolumeData instance + * @return filled with the VolumeDataComposite of this VolumeData instance. + */ + virtual IVolumeDataComposite * GetComposite() = 0; + + /** + * IVolumeData::CreateNewComposite - Creates a new VolumeDataComposite for this VolumeData instance + * @return The new VolumeDataComposite of this VolumeData instance. + */ + virtual IVolumeDataComposite * CreateNewComposite() = 0; + + /** + * IVolumeData::RemoveComposite - Removes the VolumeDataComposite of this VolumeData instance + */ + virtual void RemoveComposite() = 0; + + /** + * IVolumeData::GetColor - Returns the VolumeDataColor of this VolumeData instance + * @return filled with the VolumeDataColor of this VolumeData instance. + */ + virtual IVolumeDataColor * GetColor() = 0; + + /** + * IVolumeData::CreateNewColor - Creates a new VolumeDataColor for this VolumeData instance + * @param[in] pTheFunction - Function used in this element + * @return The new VolumeDataColor of this VolumeData instance. + */ + virtual IVolumeDataColor * CreateNewColor(IFunction* pTheFunction) = 0; + + /** + * IVolumeData::RemoveColor - Removes the VolumeDataColor of this VolumeData instance + */ + virtual void RemoveColor() = 0; + + /** + * IVolumeData::GetPropertyCount - Returns the number of VolumeDataProperty + * @return the number of VolumeDataProperty-elements within this VolumeData + */ + virtual Lib3MF_uint32 GetPropertyCount() = 0; + + /** + * IVolumeData::GetProperty - Returns the VolumeDataProperty at a given Index + * @param[in] nIndex - the index of the VolumeDataProperty to be returned. + * @return the VolumeDataProperty at the given index. + */ + virtual IVolumeDataProperty * GetProperty(const Lib3MF_uint32 nIndex) = 0; + + /** + * IVolumeData::AddPropertyFromFunction - Adds a new VolumeDataProperty from a Function + * @param[in] sName - the qualified name (namespace+name) of the Property + * @param[in] pTheFunction - Function used in this element + * @return the newly created VolumeDataProperty. + */ + virtual IVolumeDataProperty * AddPropertyFromFunction(const std::string & sName, IFunction* pTheFunction) = 0; + + /** + * IVolumeData::RemoveProperty - Removes the VolumeDataProperty with a given index + * @param[in] nIndex - the index of the VolumeDataProperty to be removed. + */ + virtual void RemoveProperty(const Lib3MF_uint32 nIndex) = 0; + +}; + +typedef IBaseSharedPtr PIVolumeData; + + /************************************************************************************************************************* Class interface for Component **************************************************************************************************************************/ class IComponent : public virtual IBase { public: + /** + * IComponent::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x4ECDB6A6F69F2BEBUL; // First 64 bits of SHA1 of a string: "Lib3MF::Component" + } + /** * IComponent::GetObjectResource - Returns the Resource Instance of the component. * @return filled with the Resource Instance. @@ -1313,6 +2332,15 @@ typedef IBaseSharedPtr PIComponent; class IComponentsObject : public virtual IObject { public: + /** + * IComponentsObject::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x6522CF04EB283FEDUL; // First 64 bits of SHA1 of a string: "Lib3MF::ComponentsObject" + } + /** * IComponentsObject::AddComponent - Adds a new component to a components object. * @param[in] pObjectResource - object to add as component. Must not lead to circular references! @@ -1345,6 +2373,15 @@ typedef IBaseSharedPtr PIComponentsObject; class IBeamSet : public virtual IBase { public: + /** + * IBeamSet::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x30CCDBE90E00B55BUL; // First 64 bits of SHA1 of a string: "Lib3MF::BeamSet" + } + /** * IBeamSet::SetName - Sets a beamset's name string * @param[in] sName - new name of the beamset. @@ -1422,6 +2459,15 @@ typedef IBaseSharedPtr PIBeamSet; class IBaseMaterialGroup : public virtual IResource { public: + /** + * IBaseMaterialGroup::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xB27D4656E16609FAUL; // First 64 bits of SHA1 of a string: "Lib3MF::BaseMaterialGroup" + } + /** * IBaseMaterialGroup::GetCount - Retrieves the count of base materials in the material group. * @return returns the count of base materials. @@ -1489,6 +2535,15 @@ typedef IBaseSharedPtr PIBaseMaterialGroup; class IColorGroup : public virtual IResource { public: + /** + * IColorGroup::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD085FB2E49CDB5B1UL; // First 64 bits of SHA1 of a string: "Lib3MF::ColorGroup" + } + /** * IColorGroup::GetCount - Retrieves the count of base materials in this Color Group. * @return returns the count of colors within this color group. @@ -1541,6 +2596,15 @@ typedef IBaseSharedPtr PIColorGroup; class ITexture2DGroup : public virtual IResource { public: + /** + * ITexture2DGroup::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xBC1208397E37055DUL; // First 64 bits of SHA1 of a string: "Lib3MF::Texture2DGroup" + } + /** * ITexture2DGroup::GetCount - Retrieves the count of tex2coords in the Texture2DGroup. * @return returns the count of tex2coords. @@ -1592,6 +2656,15 @@ typedef IBaseSharedPtr PITexture2DGroup; class ICompositeMaterials : public virtual IResource { public: + /** + * ICompositeMaterials::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xCE16224D688B86F2UL; // First 64 bits of SHA1 of a string: "Lib3MF::CompositeMaterials" + } + /** * ICompositeMaterials::GetCount - Retrieves the count of Composite-s in the CompositeMaterials. * @return returns the count of Composite-s @@ -1646,6 +2719,15 @@ typedef IBaseSharedPtr PICompositeMaterials; class IMultiPropertyGroup : public virtual IResource { public: + /** + * IMultiPropertyGroup::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xB989E02E43158FE6UL; // First 64 bits of SHA1 of a string: "Lib3MF::MultiPropertyGroup" + } + /** * IMultiPropertyGroup::GetCount - Retrieves the count of MultiProperty-s in the MultiPropertyGroup. * @return returns the count of MultiProperty-s @@ -1722,12 +2804,150 @@ public: typedef IBaseSharedPtr PIMultiPropertyGroup; +/************************************************************************************************************************* + Class interface for Image3D +**************************************************************************************************************************/ + +class IImage3D : public virtual IResource { +public: + /** + * IImage3D::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xBD938FF2D2663D61UL; // First 64 bits of SHA1 of a string: "Lib3MF::Image3D" + } + + /** + * IImage3D::GetName - returns the name of this Image3D + * @return the name of this Image3D + */ + virtual std::string GetName() = 0; + + /** + * IImage3D::SetName - sets a new name of this Image3D + * @param[in] sName - the new name of this Image3D + */ + virtual void SetName(const std::string & sName) = 0; + + /** + * IImage3D::IsImageStack - Retrieves, if this Image3D is a ImageStack + * @return returns, whether the Image3D is an ImageStack + */ + virtual bool IsImageStack() = 0; + +}; + +typedef IBaseSharedPtr PIImage3D; + + +/************************************************************************************************************************* + Class interface for ImageStack +**************************************************************************************************************************/ + +class IImageStack : public virtual IImage3D { +public: + /** + * IImageStack::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x13A2561F0CFB712AUL; // First 64 bits of SHA1 of a string: "Lib3MF::ImageStack" + } + + /** + * IImageStack::GetRowCount - Retrieves the number of rows in each image of this image3d + * @return number of rows + */ + virtual Lib3MF_uint32 GetRowCount() = 0; + + /** + * IImageStack::SetRowCount - Sets the number of rows in each image of this image3d + * @param[in] nRowCount - number of rows + */ + virtual void SetRowCount(const Lib3MF_uint32 nRowCount) = 0; + + /** + * IImageStack::GetColumnCount - Retrieves the number of columns in each image of this image3d + * @return number of columns + */ + virtual Lib3MF_uint32 GetColumnCount() = 0; + + /** + * IImageStack::SetColumnCount - Sets the number of columns in each image of this image3d + * @param[in] nColumnCount - number of columns + */ + virtual void SetColumnCount(const Lib3MF_uint32 nColumnCount) = 0; + + /** + * IImageStack::GetSheetCount - Retrieves the number of images in the stack. + * @return number of images + */ + virtual Lib3MF_uint32 GetSheetCount() = 0; + + /** + * IImageStack::GetSheet - Retrieves a sheet of the stack. Raises an error if sheet is not set. + * @param[in] nIndex - index of the image (0-based) + * @return attachment containing the image + */ + virtual IAttachment * GetSheet(const Lib3MF_uint32 nIndex) = 0; + + /** + * IImageStack::SetSheet - Sets a sheet to an existing attachment. + * @param[in] nIndex - index of the image (0-based) + * @param[in] pSheet - attachment containing the image + */ + virtual void SetSheet(const Lib3MF_uint32 nIndex, IAttachment* pSheet) = 0; + + /** + * IImageStack::CreateEmptySheet - Creates a new sheet attachment with empty data. + * @param[in] nIndex - index of the image (0-based) + * @param[in] sPath - path of part in the package + * @return attachment containing the image + */ + virtual IAttachment * CreateEmptySheet(const Lib3MF_uint32 nIndex, const std::string & sPath) = 0; + + /** + * IImageStack::CreateSheetFromBuffer - Creates a new sheet attachment from a memory buffer. + * @param[in] nIndex - index of the image (0-based) + * @param[in] sPath - path of part in the package + * @param[in] nDataBufferSize - Number of elements in buffer + * @param[in] pDataBuffer - binary image data + * @return attachment containing the image + */ + virtual IAttachment * CreateSheetFromBuffer(const Lib3MF_uint32 nIndex, const std::string & sPath, const Lib3MF_uint64 nDataBufferSize, const Lib3MF_uint8 * pDataBuffer) = 0; + + /** + * IImageStack::CreateSheetFromFile - Creates a new sheet attachment from a file on disk. + * @param[in] nIndex - index of the image (0-based) + * @param[in] sPath - path of part in the package + * @param[in] sFileName - file name to read from + * @return attachment containing the image + */ + virtual IAttachment * CreateSheetFromFile(const Lib3MF_uint32 nIndex, const std::string & sPath, const std::string & sFileName) = 0; + +}; + +typedef IBaseSharedPtr PIImageStack; + + /************************************************************************************************************************* Class interface for Attachment **************************************************************************************************************************/ class IAttachment : public virtual IBase { public: + /** + * IAttachment::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x8CE7A1191A63A35DUL; // First 64 bits of SHA1 of a string: "Lib3MF::Attachment" + } + /** * IAttachment::GetPath - Retrieves an attachment's package path. This function will be removed in a later release. * @return returns the attachment's package path string @@ -1765,13 +2985,13 @@ public: virtual void WriteToFile(const std::string & sFileName) = 0; /** - * IAttachment::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. + * IAttachment::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 package, or via the WriteToFile or WriteToBuffer methods. * @param[in] sFileName - file to read from. */ virtual void ReadFromFile(const std::string & sFileName) = 0; /** - * IAttachment::ReadFromCallback - Reads a model and from the data provided by a callback function + * IAttachment::ReadFromCallback - Reads an attachment from the data provided by a callback function. This callback function is only invoked when this attachment is being written as part of the 3MF package, or via the WriteToFile or WriteToBuffer methods. * @param[in] pTheReadCallback - callback function * @param[in] nStreamSize - number of bytes the callback returns * @param[in] pTheSeekCallback - callback function @@ -1794,7 +3014,7 @@ public: virtual void WriteToBuffer(Lib3MF_uint64 nBufferBufferSize, Lib3MF_uint64* pBufferNeededCount, Lib3MF_uint8 * pBufferBuffer) = 0; /** - * IAttachment::ReadFromBuffer - Reads an attachment from a memory buffer + * IAttachment::ReadFromBuffer - Reads an attachment from a memory buffer. This buffer is immediately read (in contrast to the ReadFromCallback and ReadFromFile-methods). * @param[in] nBufferBufferSize - Number of elements in buffer * @param[in] pBufferBuffer - Buffer to read from */ @@ -1811,6 +3031,15 @@ typedef IBaseSharedPtr PIAttachment; class ITexture2D : public virtual IResource { public: + /** + * ITexture2D::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE0441CF976B36319UL; // First 64 bits of SHA1 of a string: "Lib3MF::Texture2D" + } + /** * ITexture2D::GetAttachment - Retrieves the attachment located at the path of the texture. * @return attachment that holds the texture's image information. @@ -1866,12 +3095,2669 @@ public: typedef IBaseSharedPtr PITexture2D; +/************************************************************************************************************************* + Class interface for ImplicitPort +**************************************************************************************************************************/ + +class IImplicitPort : public virtual IBase { +public: + /** + * IImplicitPort::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD5C49B04AF1963CDUL; // First 64 bits of SHA1 of a string: "Lib3MF::ImplicitPort" + } + + /** + * IImplicitPort::GetIdentifier - Retrieves the identifier of the port + * @return the identifier + */ + virtual std::string GetIdentifier() = 0; + + /** + * IImplicitPort::SetIdentifier - Sets the identifier of the port + * @param[in] sIdentifier - the identifier + */ + virtual void SetIdentifier(const std::string & sIdentifier) = 0; + + /** + * IImplicitPort::GetDisplayName - Retrieves the display name of the port + * @return the display name + */ + virtual std::string GetDisplayName() = 0; + + /** + * IImplicitPort::SetDisplayName - Sets the display name of the port + * @param[in] sDisplayName - the display name + */ + virtual void SetDisplayName(const std::string & sDisplayName) = 0; + + /** + * IImplicitPort::SetType - Sets the type of the port + * @param[in] eImplicitPortType - the type + */ + virtual void SetType(const Lib3MF::eImplicitPortType eImplicitPortType) = 0; + + /** + * IImplicitPort::GetType - Retrieves the type of the port + * @return the type + */ + virtual Lib3MF::eImplicitPortType GetType() = 0; + + /** + * IImplicitPort::GetReference - Retrieves the reference of the port, only used for input ports + * @return the reference + */ + virtual std::string GetReference() = 0; + + /** + * IImplicitPort::SetReference - Sets the reference of the port, only used for input ports + * @param[in] sReference - the reference + */ + virtual void SetReference(const std::string & sReference) = 0; + +}; + +typedef IBaseSharedPtr PIImplicitPort; + + +/************************************************************************************************************************* + Class interface for Iterator +**************************************************************************************************************************/ + +class IIterator : public virtual IBase { +public: + /** + * IIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x52F06268CD098EFEUL; // First 64 bits of SHA1 of a string: "Lib3MF::Iterator" + } + + /** + * IIterator::MoveNext - Iterates to the next item in the list. + * @return Iterates to the next item in the list. + */ + virtual bool MoveNext() = 0; + + /** + * IIterator::MovePrevious - Iterates to the previous item in the list. + * @return Iterates to the previous item in the list. + */ + virtual bool MovePrevious() = 0; + + /** + * IIterator::Count - Returns the number of items the iterator captures. + * @return returns the number of items the iterator captures. + */ + virtual Lib3MF_uint64 Count() = 0; + +}; + +typedef IBaseSharedPtr PIIterator; + + +/************************************************************************************************************************* + Class interface for ImplicitPortIterator +**************************************************************************************************************************/ + +class IImplicitPortIterator : public virtual IIterator { +public: + /** + * IImplicitPortIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xC62268F2D7C7012CUL; // First 64 bits of SHA1 of a string: "Lib3MF::ImplicitPortIterator" + } + + /** + * IImplicitPortIterator::GetCurrent - Returns the current element + * @return The current element + */ + virtual IImplicitPort * GetCurrent() = 0; + +}; + +typedef IBaseSharedPtr PIImplicitPortIterator; + + +/************************************************************************************************************************* + Class interface for ImplicitNode +**************************************************************************************************************************/ + +class IImplicitNode : public virtual IBase { +public: + /** + * IImplicitNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE72592A7725AB29BUL; // First 64 bits of SHA1 of a string: "Lib3MF::ImplicitNode" + } + + /** + * IImplicitNode::GetIdentifier - Retrieves the identifier of the node + * @return the identifier + */ + virtual std::string GetIdentifier() = 0; + + /** + * IImplicitNode::SetIdentifier - Sets the identifier of the node + * @param[in] sIdentifier - the identifier + */ + virtual void SetIdentifier(const std::string & sIdentifier) = 0; + + /** + * IImplicitNode::GetDisplayName - Retrieves the display name of the node + * @return the display name + */ + virtual std::string GetDisplayName() = 0; + + /** + * IImplicitNode::SetDisplayName - Sets the display name of the node + * @param[in] sDisplayName - the display name + */ + virtual void SetDisplayName(const std::string & sDisplayName) = 0; + + /** + * IImplicitNode::GetTag - Retrieves the tag of the node + * @return the tag + */ + virtual std::string GetTag() = 0; + + /** + * IImplicitNode::SetTag - Sets the tag of the node + * @param[in] sTag - the tag + */ + virtual void SetTag(const std::string & sTag) = 0; + + /** + * IImplicitNode::GetNodeType - Retrieves the type of the node + * @return the type of the node + */ + virtual Lib3MF::eImplicitNodeType GetNodeType() = 0; + + /** + * IImplicitNode::AddInput - Add an input + * @param[in] sIdentifier - the identifier of the input + * @param[in] sDisplayName - the display name of the input + * @return + */ + virtual IImplicitPort * AddInput(const std::string & sIdentifier, const std::string & sDisplayName) = 0; + + /** + * IImplicitNode::GetInputs - Retrieves the inputs + * @return the iterator for the inputs + */ + virtual IImplicitPortIterator * GetInputs() = 0; + + /** + * IImplicitNode::AddOutput - Add an output + * @param[in] sIdentifier - the identifier of the output + * @param[in] sDisplayName - the display name of the output + * @return + */ + virtual IImplicitPort * AddOutput(const std::string & sIdentifier, const std::string & sDisplayName) = 0; + + /** + * IImplicitNode::GetOutputs - Retrieves the outputs + * @return the iterator the outputs + */ + virtual IImplicitPortIterator * GetOutputs() = 0; + + /** + * IImplicitNode::FindInput - Retrieves an input + * @param[in] sIdentifier - the identifier of the input + * @return the input port + */ + virtual IImplicitPort * FindInput(const std::string & sIdentifier) = 0; + + /** + * IImplicitNode::FindOutput - Retrieves an output + * @param[in] sIdentifier - the identifier of the output + * @return the output port + */ + virtual IImplicitPort * FindOutput(const std::string & sIdentifier) = 0; + + /** + * IImplicitNode::AreTypesValid - Checks if the types of the input and output ports are valid for the node type + * @return true, if the types are valid + */ + virtual bool AreTypesValid() = 0; + +}; + +typedef IBaseSharedPtr PIImplicitNode; + + +/************************************************************************************************************************* + Class interface for OneInputNode +**************************************************************************************************************************/ + +class IOneInputNode : public virtual IImplicitNode { +public: + /** + * IOneInputNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xB19B9FDA94B0A5E7UL; // First 64 bits of SHA1 of a string: "Lib3MF::OneInputNode" + } + + /** + * IOneInputNode::GetInputA - Retrieves the input + * @return the input + */ + virtual IImplicitPort * GetInputA() = 0; + + /** + * IOneInputNode::GetOutputResult - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputResult() = 0; + +}; + +typedef IBaseSharedPtr PIOneInputNode; + + +/************************************************************************************************************************* + Class interface for SinNode +**************************************************************************************************************************/ + +class ISinNode : public virtual IOneInputNode { +public: + /** + * ISinNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD5AEA50A56306722UL; // First 64 bits of SHA1 of a string: "Lib3MF::SinNode" + } + +}; + +typedef IBaseSharedPtr PISinNode; + + +/************************************************************************************************************************* + Class interface for CosNode +**************************************************************************************************************************/ + +class ICosNode : public virtual IOneInputNode { +public: + /** + * ICosNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x59BC328F6FB5C5FFUL; // First 64 bits of SHA1 of a string: "Lib3MF::CosNode" + } + +}; + +typedef IBaseSharedPtr PICosNode; + + +/************************************************************************************************************************* + Class interface for TanNode +**************************************************************************************************************************/ + +class ITanNode : public virtual IOneInputNode { +public: + /** + * ITanNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x2614CC572AF350B7UL; // First 64 bits of SHA1 of a string: "Lib3MF::TanNode" + } + +}; + +typedef IBaseSharedPtr PITanNode; + + +/************************************************************************************************************************* + Class interface for ArcSinNode +**************************************************************************************************************************/ + +class IArcSinNode : public virtual IOneInputNode { +public: + /** + * IArcSinNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE554C8A7E72AAF4DUL; // First 64 bits of SHA1 of a string: "Lib3MF::ArcSinNode" + } + +}; + +typedef IBaseSharedPtr PIArcSinNode; + + +/************************************************************************************************************************* + Class interface for ArcCosNode +**************************************************************************************************************************/ + +class IArcCosNode : public virtual IOneInputNode { +public: + /** + * IArcCosNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x943AF6AE0EFD2B8AUL; // First 64 bits of SHA1 of a string: "Lib3MF::ArcCosNode" + } + +}; + +typedef IBaseSharedPtr PIArcCosNode; + + +/************************************************************************************************************************* + Class interface for ArcTanNode +**************************************************************************************************************************/ + +class IArcTanNode : public virtual IOneInputNode { +public: + /** + * IArcTanNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE47D547615816BADUL; // First 64 bits of SHA1 of a string: "Lib3MF::ArcTanNode" + } + +}; + +typedef IBaseSharedPtr PIArcTanNode; + + +/************************************************************************************************************************* + Class interface for SinhNode +**************************************************************************************************************************/ + +class ISinhNode : public virtual IOneInputNode { +public: + /** + * ISinhNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x3C7756A456F2D089UL; // First 64 bits of SHA1 of a string: "Lib3MF::SinhNode" + } + +}; + +typedef IBaseSharedPtr PISinhNode; + + +/************************************************************************************************************************* + Class interface for CoshNode +**************************************************************************************************************************/ + +class ICoshNode : public virtual IOneInputNode { +public: + /** + * ICoshNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x4A993F91E1DE256DUL; // First 64 bits of SHA1 of a string: "Lib3MF::CoshNode" + } + +}; + +typedef IBaseSharedPtr PICoshNode; + + +/************************************************************************************************************************* + Class interface for TanhNode +**************************************************************************************************************************/ + +class ITanhNode : public virtual IOneInputNode { +public: + /** + * ITanhNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xCF077B19B0B78E9DUL; // First 64 bits of SHA1 of a string: "Lib3MF::TanhNode" + } + +}; + +typedef IBaseSharedPtr PITanhNode; + + +/************************************************************************************************************************* + Class interface for RoundNode +**************************************************************************************************************************/ + +class IRoundNode : public virtual IOneInputNode { +public: + /** + * IRoundNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD9F5A53C657765AEUL; // First 64 bits of SHA1 of a string: "Lib3MF::RoundNode" + } + +}; + +typedef IBaseSharedPtr PIRoundNode; + + +/************************************************************************************************************************* + Class interface for CeilNode +**************************************************************************************************************************/ + +class ICeilNode : public virtual IOneInputNode { +public: + /** + * ICeilNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x627E211653E11D93UL; // First 64 bits of SHA1 of a string: "Lib3MF::CeilNode" + } + +}; + +typedef IBaseSharedPtr PICeilNode; + + +/************************************************************************************************************************* + Class interface for FloorNode +**************************************************************************************************************************/ + +class IFloorNode : public virtual IOneInputNode { +public: + /** + * IFloorNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x392A0F4C041D249CUL; // First 64 bits of SHA1 of a string: "Lib3MF::FloorNode" + } + +}; + +typedef IBaseSharedPtr PIFloorNode; + + +/************************************************************************************************************************* + Class interface for SignNode +**************************************************************************************************************************/ + +class ISignNode : public virtual IOneInputNode { +public: + /** + * ISignNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x8A45165E6C9646D7UL; // First 64 bits of SHA1 of a string: "Lib3MF::SignNode" + } + +}; + +typedef IBaseSharedPtr PISignNode; + + +/************************************************************************************************************************* + Class interface for FractNode +**************************************************************************************************************************/ + +class IFractNode : public virtual IOneInputNode { +public: + /** + * IFractNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x53E62FD67F4D9A65UL; // First 64 bits of SHA1 of a string: "Lib3MF::FractNode" + } + +}; + +typedef IBaseSharedPtr PIFractNode; + + +/************************************************************************************************************************* + Class interface for AbsNode +**************************************************************************************************************************/ + +class IAbsNode : public virtual IOneInputNode { +public: + /** + * IAbsNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x6B641C7060040BE3UL; // First 64 bits of SHA1 of a string: "Lib3MF::AbsNode" + } + +}; + +typedef IBaseSharedPtr PIAbsNode; + + +/************************************************************************************************************************* + Class interface for ExpNode +**************************************************************************************************************************/ + +class IExpNode : public virtual IOneInputNode { +public: + /** + * IExpNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x3390243A8E2410F3UL; // First 64 bits of SHA1 of a string: "Lib3MF::ExpNode" + } + +}; + +typedef IBaseSharedPtr PIExpNode; + + +/************************************************************************************************************************* + Class interface for LogNode +**************************************************************************************************************************/ + +class ILogNode : public virtual IOneInputNode { +public: + /** + * ILogNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x70021D73AA89FDUL; // First 64 bits of SHA1 of a string: "Lib3MF::LogNode" + } + +}; + +typedef IBaseSharedPtr PILogNode; + + +/************************************************************************************************************************* + Class interface for Log2Node +**************************************************************************************************************************/ + +class ILog2Node : public virtual IOneInputNode { +public: + /** + * ILog2Node::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE8C0ABF7C5DC7068UL; // First 64 bits of SHA1 of a string: "Lib3MF::Log2Node" + } + +}; + +typedef IBaseSharedPtr PILog2Node; + + +/************************************************************************************************************************* + Class interface for Log10Node +**************************************************************************************************************************/ + +class ILog10Node : public virtual IOneInputNode { +public: + /** + * ILog10Node::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x87740AD53454E0DFUL; // First 64 bits of SHA1 of a string: "Lib3MF::Log10Node" + } + +}; + +typedef IBaseSharedPtr PILog10Node; + + +/************************************************************************************************************************* + Class interface for LengthNode +**************************************************************************************************************************/ + +class ILengthNode : public virtual IOneInputNode { +public: + /** + * ILengthNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD85889E2739A74B1UL; // First 64 bits of SHA1 of a string: "Lib3MF::LengthNode" + } + +}; + +typedef IBaseSharedPtr PILengthNode; + + +/************************************************************************************************************************* + Class interface for TransposeNode +**************************************************************************************************************************/ + +class ITransposeNode : public virtual IOneInputNode { +public: + /** + * ITransposeNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xA808B7599C158CE6UL; // First 64 bits of SHA1 of a string: "Lib3MF::TransposeNode" + } + +}; + +typedef IBaseSharedPtr PITransposeNode; + + +/************************************************************************************************************************* + Class interface for InverseNode +**************************************************************************************************************************/ + +class IInverseNode : public virtual IOneInputNode { +public: + /** + * IInverseNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xE8601F66A23A0540UL; // First 64 bits of SHA1 of a string: "Lib3MF::InverseNode" + } + +}; + +typedef IBaseSharedPtr PIInverseNode; + + +/************************************************************************************************************************* + Class interface for SqrtNode +**************************************************************************************************************************/ + +class ISqrtNode : public virtual IOneInputNode { +public: + /** + * ISqrtNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x9F831944A3DE31DAUL; // First 64 bits of SHA1 of a string: "Lib3MF::SqrtNode" + } + +}; + +typedef IBaseSharedPtr PISqrtNode; + + +/************************************************************************************************************************* + Class interface for ResourceIdNode +**************************************************************************************************************************/ + +class IResourceIdNode : public virtual IImplicitNode { +public: + /** + * IResourceIdNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xCA86A77C71CD3FAEUL; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceIdNode" + } + + /** + * IResourceIdNode::SetResource - Sets the Resource that the resourceid attribute of the node will point to + * @param[in] pResource - the resource + */ + virtual void SetResource(IResource* pResource) = 0; + + /** + * IResourceIdNode::GetResource - Retrieves the resource of the node + * @return the resource + */ + virtual IResource * GetResource() = 0; + + /** + * IResourceIdNode::GetOutputValue - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputValue() = 0; + +}; + +typedef IBaseSharedPtr PIResourceIdNode; + + +/************************************************************************************************************************* + Class interface for TwoInputNode +**************************************************************************************************************************/ + +class ITwoInputNode : public virtual IOneInputNode { +public: + /** + * ITwoInputNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x7DE3951BA4C1064CUL; // First 64 bits of SHA1 of a string: "Lib3MF::TwoInputNode" + } + + /** + * ITwoInputNode::GetInputB - Retrieves the second input + * @return the second input + */ + virtual IImplicitPort * GetInputB() = 0; + +}; + +typedef IBaseSharedPtr PITwoInputNode; + + +/************************************************************************************************************************* + Class interface for AdditionNode +**************************************************************************************************************************/ + +class IAdditionNode : public virtual ITwoInputNode { +public: + /** + * IAdditionNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x57A2236998DF5248UL; // First 64 bits of SHA1 of a string: "Lib3MF::AdditionNode" + } + +}; + +typedef IBaseSharedPtr PIAdditionNode; + + +/************************************************************************************************************************* + Class interface for SubtractionNode +**************************************************************************************************************************/ + +class ISubtractionNode : public virtual ITwoInputNode { +public: + /** + * ISubtractionNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x6079B12FFF345D02UL; // First 64 bits of SHA1 of a string: "Lib3MF::SubtractionNode" + } + +}; + +typedef IBaseSharedPtr PISubtractionNode; + + +/************************************************************************************************************************* + Class interface for MultiplicationNode +**************************************************************************************************************************/ + +class IMultiplicationNode : public virtual ITwoInputNode { +public: + /** + * IMultiplicationNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xA3C27CF54C2AA76CUL; // First 64 bits of SHA1 of a string: "Lib3MF::MultiplicationNode" + } + +}; + +typedef IBaseSharedPtr PIMultiplicationNode; + + +/************************************************************************************************************************* + Class interface for DivisionNode +**************************************************************************************************************************/ + +class IDivisionNode : public virtual ITwoInputNode { +public: + /** + * IDivisionNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xB896B6413C08CF39UL; // First 64 bits of SHA1 of a string: "Lib3MF::DivisionNode" + } + +}; + +typedef IBaseSharedPtr PIDivisionNode; + + +/************************************************************************************************************************* + Class interface for DotNode +**************************************************************************************************************************/ + +class IDotNode : public virtual ITwoInputNode { +public: + /** + * IDotNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xFE60932A66375FADUL; // First 64 bits of SHA1 of a string: "Lib3MF::DotNode" + } + +}; + +typedef IBaseSharedPtr PIDotNode; + + +/************************************************************************************************************************* + Class interface for CrossNode +**************************************************************************************************************************/ + +class ICrossNode : public virtual ITwoInputNode { +public: + /** + * ICrossNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x106182D38CA5CFE3UL; // First 64 bits of SHA1 of a string: "Lib3MF::CrossNode" + } + +}; + +typedef IBaseSharedPtr PICrossNode; + + +/************************************************************************************************************************* + Class interface for ArcTan2Node +**************************************************************************************************************************/ + +class IArcTan2Node : public virtual ITwoInputNode { +public: + /** + * IArcTan2Node::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xB6153EF5DE7E5E11UL; // First 64 bits of SHA1 of a string: "Lib3MF::ArcTan2Node" + } + +}; + +typedef IBaseSharedPtr PIArcTan2Node; + + +/************************************************************************************************************************* + Class interface for MatVecMultiplicationNode +**************************************************************************************************************************/ + +class IMatVecMultiplicationNode : public virtual ITwoInputNode { +public: + /** + * IMatVecMultiplicationNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x7570C43B9721D0C0UL; // First 64 bits of SHA1 of a string: "Lib3MF::MatVecMultiplicationNode" + } + +}; + +typedef IBaseSharedPtr PIMatVecMultiplicationNode; + + +/************************************************************************************************************************* + Class interface for MinNode +**************************************************************************************************************************/ + +class IMinNode : public virtual ITwoInputNode { +public: + /** + * IMinNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x846AFDE9A091E997UL; // First 64 bits of SHA1 of a string: "Lib3MF::MinNode" + } + +}; + +typedef IBaseSharedPtr PIMinNode; + + +/************************************************************************************************************************* + Class interface for MaxNode +**************************************************************************************************************************/ + +class IMaxNode : public virtual ITwoInputNode { +public: + /** + * IMaxNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x73F910381BF250DUL; // First 64 bits of SHA1 of a string: "Lib3MF::MaxNode" + } + +}; + +typedef IBaseSharedPtr PIMaxNode; + + +/************************************************************************************************************************* + Class interface for FmodNode +**************************************************************************************************************************/ + +class IFmodNode : public virtual ITwoInputNode { +public: + /** + * IFmodNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x1EF703D298223F2AUL; // First 64 bits of SHA1 of a string: "Lib3MF::FmodNode" + } + +}; + +typedef IBaseSharedPtr PIFmodNode; + + +/************************************************************************************************************************* + Class interface for ModNode +**************************************************************************************************************************/ + +class IModNode : public virtual ITwoInputNode { +public: + /** + * IModNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xEA57335849379F22UL; // First 64 bits of SHA1 of a string: "Lib3MF::ModNode" + } + +}; + +typedef IBaseSharedPtr PIModNode; + + +/************************************************************************************************************************* + Class interface for PowNode +**************************************************************************************************************************/ + +class IPowNode : public virtual ITwoInputNode { +public: + /** + * IPowNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x7700AA17CA1AC0F8UL; // First 64 bits of SHA1 of a string: "Lib3MF::PowNode" + } + +}; + +typedef IBaseSharedPtr PIPowNode; + + +/************************************************************************************************************************* + Class interface for SelectNode +**************************************************************************************************************************/ + +class ISelectNode : public virtual IOneInputNode { +public: + /** + * ISelectNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x1127ED71E05A9BD4UL; // First 64 bits of SHA1 of a string: "Lib3MF::SelectNode" + } + + /** + * ISelectNode::GetInputB - Retrieves the second input + * @return the second input + */ + virtual IImplicitPort * GetInputB() = 0; + + /** + * ISelectNode::GetInputC - Retrieves the third input + * @return the third input + */ + virtual IImplicitPort * GetInputC() = 0; + + /** + * ISelectNode::GetInputD - Retrieves the fourth input + * @return the fourth input + */ + virtual IImplicitPort * GetInputD() = 0; + +}; + +typedef IBaseSharedPtr PISelectNode; + + +/************************************************************************************************************************* + Class interface for ClampNode +**************************************************************************************************************************/ + +class IClampNode : public virtual IOneInputNode { +public: + /** + * IClampNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x77AF68C971B1485FUL; // First 64 bits of SHA1 of a string: "Lib3MF::ClampNode" + } + + /** + * IClampNode::GetInputMin - Retrieves the input for the lower limit + * @return the input for the lower limit + */ + virtual IImplicitPort * GetInputMin() = 0; + + /** + * IClampNode::GetInputMax - Retrieves the input for the upper limit + * @return the input for the upper limit + */ + virtual IImplicitPort * GetInputMax() = 0; + +}; + +typedef IBaseSharedPtr PIClampNode; + + +/************************************************************************************************************************* + Class interface for ComposeVectorNode +**************************************************************************************************************************/ + +class IComposeVectorNode : public virtual IImplicitNode { +public: + /** + * IComposeVectorNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x49C24B8840C01F7EUL; // First 64 bits of SHA1 of a string: "Lib3MF::ComposeVectorNode" + } + + /** + * IComposeVectorNode::GetInputX - Retrieves the input for the x component + * @return the input for the x component + */ + virtual IImplicitPort * GetInputX() = 0; + + /** + * IComposeVectorNode::GetInputY - Retrieves the input for the y component + * @return the input for the y component + */ + virtual IImplicitPort * GetInputY() = 0; + + /** + * IComposeVectorNode::GetInputZ - Retrieves the input for the z component + * @return the input for the z component + */ + virtual IImplicitPort * GetInputZ() = 0; + + /** + * IComposeVectorNode::GetOutputResult - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputResult() = 0; + +}; + +typedef IBaseSharedPtr PIComposeVectorNode; + + +/************************************************************************************************************************* + Class interface for VectorFromScalarNode +**************************************************************************************************************************/ + +class IVectorFromScalarNode : public virtual IOneInputNode { +public: + /** + * IVectorFromScalarNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x2E417B93351375E2UL; // First 64 bits of SHA1 of a string: "Lib3MF::VectorFromScalarNode" + } + +}; + +typedef IBaseSharedPtr PIVectorFromScalarNode; + + +/************************************************************************************************************************* + Class interface for DecomposeVectorNode +**************************************************************************************************************************/ + +class IDecomposeVectorNode : public virtual IImplicitNode { +public: + /** + * IDecomposeVectorNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xCC4F8D561CCE35D4UL; // First 64 bits of SHA1 of a string: "Lib3MF::DecomposeVectorNode" + } + + /** + * IDecomposeVectorNode::GetInputA - Retrieves the input + * @return the input port for the vector to decompose + */ + virtual IImplicitPort * GetInputA() = 0; + + /** + * IDecomposeVectorNode::GetOutputX - Retrieves the output for the x component + * @return the output for the x component + */ + virtual IImplicitPort * GetOutputX() = 0; + + /** + * IDecomposeVectorNode::GetOutputY - Retrieves the output for the y component + * @return the output for the y component + */ + virtual IImplicitPort * GetOutputY() = 0; + + /** + * IDecomposeVectorNode::GetOutputZ - Retrieves the output for the z component + * @return the output for the z component + */ + virtual IImplicitPort * GetOutputZ() = 0; + +}; + +typedef IBaseSharedPtr PIDecomposeVectorNode; + + +/************************************************************************************************************************* + Class interface for ComposeMatrixNode +**************************************************************************************************************************/ + +class IComposeMatrixNode : public virtual IImplicitNode { +public: + /** + * IComposeMatrixNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x9EF9EB54A53AA40DUL; // First 64 bits of SHA1 of a string: "Lib3MF::ComposeMatrixNode" + } + + /** + * IComposeMatrixNode::GetInputM00 - Retrieves the input for the element 0 0 + * @return the input for the m00 element + */ + virtual IImplicitPort * GetInputM00() = 0; + + /** + * IComposeMatrixNode::GetInputM01 - Retrieves the input for the element 0 1 + * @return the input for the m01 element + */ + virtual IImplicitPort * GetInputM01() = 0; + + /** + * IComposeMatrixNode::GetInputM02 - Retrieves the input for the element 0 2 + * @return the input for the m02 element + */ + virtual IImplicitPort * GetInputM02() = 0; + + /** + * IComposeMatrixNode::GetInputM03 - Retrieves the input for the element 0 3 + * @return the input for the m03 element + */ + virtual IImplicitPort * GetInputM03() = 0; + + /** + * IComposeMatrixNode::GetInputM10 - Retrieves the input for the element 1 0 + * @return the input for the m10 element + */ + virtual IImplicitPort * GetInputM10() = 0; + + /** + * IComposeMatrixNode::GetInputM11 - Retrieves the input for the element 1 1 + * @return the input for the m11 element + */ + virtual IImplicitPort * GetInputM11() = 0; + + /** + * IComposeMatrixNode::GetInputM12 - Retrieves the input for the element 1 2 + * @return the input for the m12 element + */ + virtual IImplicitPort * GetInputM12() = 0; + + /** + * IComposeMatrixNode::GetInputM13 - Retrieves the input for the element 1 3 + * @return the input for the m13 element + */ + virtual IImplicitPort * GetInputM13() = 0; + + /** + * IComposeMatrixNode::GetInputM20 - Retrieves the input for the element 2 0 + * @return the input for the m20 element + */ + virtual IImplicitPort * GetInputM20() = 0; + + /** + * IComposeMatrixNode::GetInputM21 - Retrieves the input for the element 2 1 + * @return + */ + virtual IImplicitPort * GetInputM21() = 0; + + /** + * IComposeMatrixNode::GetInputM22 - Retrieves the input for the element 2 2 + * @return the input for the m22 element + */ + virtual IImplicitPort * GetInputM22() = 0; + + /** + * IComposeMatrixNode::GetInputM23 - Retrieves the input for the element 2 3 + * @return the input for the m23 element + */ + virtual IImplicitPort * GetInputM23() = 0; + + /** + * IComposeMatrixNode::GetInputM30 - Retrieves the input for the element 3 0 + * @return the input for the m30 element + */ + virtual IImplicitPort * GetInputM30() = 0; + + /** + * IComposeMatrixNode::GetInputM31 - Retrieves the input for the element 3 1 + * @return the input for the m31 element + */ + virtual IImplicitPort * GetInputM31() = 0; + + /** + * IComposeMatrixNode::GetInputM32 - Retrieves the input for the element 3 2 + * @return the input for the m32 element + */ + virtual IImplicitPort * GetInputM32() = 0; + + /** + * IComposeMatrixNode::GetInputM33 - Retrieves the input for the element 3 3 + * @return the input for the m33 element + */ + virtual IImplicitPort * GetInputM33() = 0; + + /** + * IComposeMatrixNode::GetOutputResult - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputResult() = 0; + +}; + +typedef IBaseSharedPtr PIComposeMatrixNode; + + +/************************************************************************************************************************* + Class interface for MatrixFromRowsNode +**************************************************************************************************************************/ + +class IMatrixFromRowsNode : public virtual IImplicitNode { +public: + /** + * IMatrixFromRowsNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD6DFD0A7EB64AC33UL; // First 64 bits of SHA1 of a string: "Lib3MF::MatrixFromRowsNode" + } + + /** + * IMatrixFromRowsNode::GetInputA - Retrieves the input for the first row + * @return the input for the first row + */ + virtual IImplicitPort * GetInputA() = 0; + + /** + * IMatrixFromRowsNode::GetInputB - Retrieves the input for the second row + * @return the input for the second row + */ + virtual IImplicitPort * GetInputB() = 0; + + /** + * IMatrixFromRowsNode::GetInputC - Retrieves the input for the third row + * @return the input for the third row + */ + virtual IImplicitPort * GetInputC() = 0; + + /** + * IMatrixFromRowsNode::GetInputD - Retrieves the input for the fourth row + * @return the input for the fourth row + */ + virtual IImplicitPort * GetInputD() = 0; + + /** + * IMatrixFromRowsNode::GetOutputResult - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputResult() = 0; + +}; + +typedef IBaseSharedPtr PIMatrixFromRowsNode; + + +/************************************************************************************************************************* + Class interface for MatrixFromColumnsNode +**************************************************************************************************************************/ + +class IMatrixFromColumnsNode : public virtual IImplicitNode { +public: + /** + * IMatrixFromColumnsNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xDCBEAFCF83F3AACUL; // First 64 bits of SHA1 of a string: "Lib3MF::MatrixFromColumnsNode" + } + + /** + * IMatrixFromColumnsNode::GetInputA - Retrieves the input for the first column + * @return the input for the first column + */ + virtual IImplicitPort * GetInputA() = 0; + + /** + * IMatrixFromColumnsNode::GetInputB - Retrieves the input for the second column + * @return the input for the second column + */ + virtual IImplicitPort * GetInputB() = 0; + + /** + * IMatrixFromColumnsNode::GetInputC - Retrieves the input for the third column + * @return the input for the third column + */ + virtual IImplicitPort * GetInputC() = 0; + + /** + * IMatrixFromColumnsNode::GetInputD - Retrieves the input for the fourth column + * @return the input for the fourth column + */ + virtual IImplicitPort * GetInputD() = 0; + + /** + * IMatrixFromColumnsNode::GetOutputResult - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputResult() = 0; + +}; + +typedef IBaseSharedPtr PIMatrixFromColumnsNode; + + +/************************************************************************************************************************* + Class interface for ConstantNode +**************************************************************************************************************************/ + +class IConstantNode : public virtual IImplicitNode { +public: + /** + * IConstantNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x3F8E5D082F966B1BUL; // First 64 bits of SHA1 of a string: "Lib3MF::ConstantNode" + } + + /** + * IConstantNode::SetConstant - Sets the constant value of the node + * @param[in] dValue - the value + */ + virtual void SetConstant(const Lib3MF_double dValue) = 0; + + /** + * IConstantNode::GetConstant - Retrieves the constant value of the node + * @return the value + */ + virtual Lib3MF_double GetConstant() = 0; + + /** + * IConstantNode::GetOutputValue - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputValue() = 0; + +}; + +typedef IBaseSharedPtr PIConstantNode; + + +/************************************************************************************************************************* + Class interface for ConstVecNode +**************************************************************************************************************************/ + +class IConstVecNode : public virtual IImplicitNode { +public: + /** + * IConstVecNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x9C9363B3F708D556UL; // First 64 bits of SHA1 of a string: "Lib3MF::ConstVecNode" + } + + /** + * IConstVecNode::SetVector - Sets the vector value of the node + * @param[in] Value - the value + */ + virtual void SetVector(const Lib3MF::sVector Value) = 0; + + /** + * IConstVecNode::GetVector - Retrieves the vector value of the node + * @return the value + */ + virtual Lib3MF::sVector GetVector() = 0; + + /** + * IConstVecNode::GetOutputVector - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputVector() = 0; + +}; + +typedef IBaseSharedPtr PIConstVecNode; + + +/************************************************************************************************************************* + Class interface for ConstMatNode +**************************************************************************************************************************/ + +class IConstMatNode : public virtual IImplicitNode { +public: + /** + * IConstMatNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xF85C90EDCE6F90A4UL; // First 64 bits of SHA1 of a string: "Lib3MF::ConstMatNode" + } + + /** + * IConstMatNode::SetMatrix - Sets the matrix value of the node + * @param[in] Value - the value + */ + virtual void SetMatrix(const Lib3MF::sMatrix4x4 Value) = 0; + + /** + * IConstMatNode::GetMatrix - Retrieves the matrix value of the node + * @return the matrix + */ + virtual Lib3MF::sMatrix4x4 GetMatrix() = 0; + + /** + * IConstMatNode::GetOutputMatrix - Retrieves the output + * @return the output + */ + virtual IImplicitPort * GetOutputMatrix() = 0; + +}; + +typedef IBaseSharedPtr PIConstMatNode; + + +/************************************************************************************************************************* + Class interface for MeshNode +**************************************************************************************************************************/ + +class IMeshNode : public virtual IImplicitNode { +public: + /** + * IMeshNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x53601FD432E3DEF4UL; // First 64 bits of SHA1 of a string: "Lib3MF::MeshNode" + } + + /** + * IMeshNode::GetInputMesh - Retrieves the input for the model resource id of the mesh + * @return the input port for the model resource id of the mesh + */ + virtual IImplicitPort * GetInputMesh() = 0; + + /** + * IMeshNode::GetInputPos - Retrieves the input for the position + * @return the input port for the position + */ + virtual IImplicitPort * GetInputPos() = 0; + + /** + * IMeshNode::GetOutputDistance - Retrieves the output + * @return the output port for the signed distance to the mesh + */ + virtual IImplicitPort * GetOutputDistance() = 0; + +}; + +typedef IBaseSharedPtr PIMeshNode; + + +/************************************************************************************************************************* + Class interface for UnsignedMeshNode +**************************************************************************************************************************/ + +class IUnsignedMeshNode : public virtual IImplicitNode { +public: + /** + * IUnsignedMeshNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x29985A628251A9CDUL; // First 64 bits of SHA1 of a string: "Lib3MF::UnsignedMeshNode" + } + + /** + * IUnsignedMeshNode::GetInputMesh - Retrieves the input for the model resource id of the mesh + * @return the input port for the model resource id of the mesh + */ + virtual IImplicitPort * GetInputMesh() = 0; + + /** + * IUnsignedMeshNode::GetInputPos - Retrieves the input for the position + * @return the input port for the position + */ + virtual IImplicitPort * GetInputPos() = 0; + + /** + * IUnsignedMeshNode::GetOutputDistance - Retrieves the output + * @return the output port for the unsigned distance to the mesh + */ + virtual IImplicitPort * GetOutputDistance() = 0; + +}; + +typedef IBaseSharedPtr PIUnsignedMeshNode; + + +/************************************************************************************************************************* + Class interface for BeamLatticeNode +**************************************************************************************************************************/ + +class IBeamLatticeNode : public virtual IImplicitNode { +public: + /** + * IBeamLatticeNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xF3A4EE98F7FEC0CUL; // First 64 bits of SHA1 of a string: "Lib3MF::BeamLatticeNode" + } + + /** + * IBeamLatticeNode::GetInputBeamLattice - Retrieves the input for the model resource id of the beam lattice + * @return the input port for the model resource id of the beam lattice (mesh with beamlattice extension) + */ + virtual IImplicitPort * GetInputBeamLattice() = 0; + + /** + * IBeamLatticeNode::GetInputPos - Retrieves the input for the position + * @return the input port for the position + */ + virtual IImplicitPort * GetInputPos() = 0; + + /** + * IBeamLatticeNode::GetOutputDistance - Retrieves the output + * @return the output port for the signed distance to the beam lattice + */ + virtual IImplicitPort * GetOutputDistance() = 0; + + /** + * IBeamLatticeNode::SetAccurateRange - Sets the accurate range for distance computation + * @param[in] dAccurateRange - the accurate range in model units + */ + virtual void SetAccurateRange(const Lib3MF_double dAccurateRange) = 0; + + /** + * IBeamLatticeNode::GetAccurateRange - Retrieves the accurate range for distance computation + * @return the accurate range in model units + */ + virtual Lib3MF_double GetAccurateRange() = 0; + +}; + +typedef IBaseSharedPtr PIBeamLatticeNode; + + +/************************************************************************************************************************* + Class interface for FunctionGradientNode +**************************************************************************************************************************/ + +class IFunctionGradientNode : public virtual IImplicitNode { +public: + /** + * IFunctionGradientNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x437E27AEF740121UL; // First 64 bits of SHA1 of a string: "Lib3MF::FunctionGradientNode" + } + + /** + * IFunctionGradientNode::GetInputFunctionID - Retrieves the input for the function id + * @return the input port for the function + */ + virtual IImplicitPort * GetInputFunctionID() = 0; + + /** + * IFunctionGradientNode::GetInputPos - Retrieves the input for the position + * @return the input port for the position + */ + virtual IImplicitPort * GetInputPos() = 0; + + /** + * IFunctionGradientNode::GetInputStep - Retrieves the input for the finite difference step + * @return the input port for the finite difference step + */ + virtual IImplicitPort * GetInputStep() = 0; + + /** + * IFunctionGradientNode::SetScalarOutputName - Sets the name of the referenced scalar output + * @param[in] sScalarOutputName - the name of the scalar output of the referenced function + */ + virtual void SetScalarOutputName(const std::string & sScalarOutputName) = 0; + + /** + * IFunctionGradientNode::GetScalarOutputName - Retrieves the name of the referenced scalar output + * @return the name of the scalar output of the referenced function + */ + virtual std::string GetScalarOutputName() = 0; + + /** + * IFunctionGradientNode::SetVectorInputName - Sets the name of the referenced vector input + * @param[in] sVectorInputName - the name of the vector input (float3) of the referenced function + */ + virtual void SetVectorInputName(const std::string & sVectorInputName) = 0; + + /** + * IFunctionGradientNode::GetVectorInputName - Retrieves the name of the referenced vector input + * @return the name of the vector input (float3) of the referenced function + */ + virtual std::string GetVectorInputName() = 0; + + /** + * IFunctionGradientNode::GetOutputNormalizedGradient - Retrieves the normalized gradient output + * @return the output port for the normalized gradient + */ + virtual IImplicitPort * GetOutputNormalizedGradient() = 0; + + /** + * IFunctionGradientNode::GetOutputGradient - Retrieves the raw gradient output + * @return the output port for the raw gradient + */ + virtual IImplicitPort * GetOutputGradient() = 0; + + /** + * IFunctionGradientNode::GetOutputMagnitude - Retrieves the gradient magnitude output + * @return the output port for the gradient magnitude + */ + virtual IImplicitPort * GetOutputMagnitude() = 0; + +}; + +typedef IBaseSharedPtr PIFunctionGradientNode; + + +/************************************************************************************************************************* + Class interface for NormalizeDistanceNode +**************************************************************************************************************************/ + +class INormalizeDistanceNode : public virtual IImplicitNode { +public: + /** + * INormalizeDistanceNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x817D2E566E73AA8FUL; // First 64 bits of SHA1 of a string: "Lib3MF::NormalizeDistanceNode" + } + + /** + * INormalizeDistanceNode::GetInputFunctionID - Retrieves the input for the function id + * @return the input port for the function + */ + virtual IImplicitPort * GetInputFunctionID() = 0; + + /** + * INormalizeDistanceNode::GetInputPos - Retrieves the input for the position + * @return the input port for the position (vector) + */ + virtual IImplicitPort * GetInputPos() = 0; + + /** + * INormalizeDistanceNode::GetInputStep - Retrieves the input for the finite difference step + * @return the input port for the finite difference step + */ + virtual IImplicitPort * GetInputStep() = 0; + + /** + * INormalizeDistanceNode::SetScalarOutputName - Sets the name of the referenced scalar output + * @param[in] sScalarOutputName - the name of the scalar output of the referenced function + */ + virtual void SetScalarOutputName(const std::string & sScalarOutputName) = 0; + + /** + * INormalizeDistanceNode::GetScalarOutputName - Retrieves the name of the referenced scalar output + * @return the name of the scalar output of the referenced function + */ + virtual std::string GetScalarOutputName() = 0; + + /** + * INormalizeDistanceNode::SetVectorInputName - Sets the name of the referenced vector input + * @param[in] sVectorInputName - the name of the vector input (float3) of the referenced function + */ + virtual void SetVectorInputName(const std::string & sVectorInputName) = 0; + + /** + * INormalizeDistanceNode::GetVectorInputName - Retrieves the name of the referenced vector input + * @return the name of the vector input (float3) of the referenced function + */ + virtual std::string GetVectorInputName() = 0; + + /** + * INormalizeDistanceNode::GetOutputResult - Retrieves the normalized result output + * @return the output port for the normalized distance + */ + virtual IImplicitPort * GetOutputResult() = 0; + +}; + +typedef IBaseSharedPtr PINormalizeDistanceNode; + + +/************************************************************************************************************************* + Class interface for FunctionCallNode +**************************************************************************************************************************/ + +class IFunctionCallNode : public virtual IImplicitNode { +public: + /** + * IFunctionCallNode::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x765C17C952F24E3UL; // First 64 bits of SHA1 of a string: "Lib3MF::FunctionCallNode" + } + + /** + * IFunctionCallNode::GetInputFunctionID - Retrieves the input for the function id + * @return the input port for the function + */ + virtual IImplicitPort * GetInputFunctionID() = 0; + +}; + +typedef IBaseSharedPtr PIFunctionCallNode; + + +/************************************************************************************************************************* + Class interface for NodeIterator +**************************************************************************************************************************/ + +class INodeIterator : public virtual IIterator { +public: + /** + * INodeIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xFC006BC888CAB4D0UL; // First 64 bits of SHA1 of a string: "Lib3MF::NodeIterator" + } + + /** + * INodeIterator::GetCurrent - Returns the current element + * @return The current element + */ + virtual IImplicitNode * GetCurrent() = 0; + +}; + +typedef IBaseSharedPtr PINodeIterator; + + +/************************************************************************************************************************* + Class interface for Function +**************************************************************************************************************************/ + +class IFunction : public virtual IResource { +public: + /** + * IFunction::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x9EFB2757CA1A5231UL; // First 64 bits of SHA1 of a string: "Lib3MF::Function" + } + + /** + * IFunction::GetDisplayName - Retrieves the display name of the function + * @return the display name + */ + virtual std::string GetDisplayName() = 0; + + /** + * IFunction::SetDisplayName - Sets the display name of the function + * @param[in] sDisplayName - the display name + */ + virtual void SetDisplayName(const std::string & sDisplayName) = 0; + + /** + * IFunction::AddInput - Add an input + * @param[in] sIdentifier - the identifier of the input + * @param[in] sDisplayName - the display name of the input + * @param[in] eType - the type of the input + * @return The added input port + */ + virtual IImplicitPort * AddInput(const std::string & sIdentifier, const std::string & sDisplayName, const Lib3MF::eImplicitPortType eType) = 0; + + /** + * IFunction::GetInputs - Retrieves the inputs + * @return iterator for the list of inputs + */ + virtual IImplicitPortIterator * GetInputs() = 0; + + /** + * IFunction::RemoveInput - Removes an input + * @param[in] pInput - The input to be removed + */ + virtual void RemoveInput(IImplicitPort* pInput) = 0; + + /** + * IFunction::AddOutput - Add an output + * @param[in] sIdentifier - the identifier of the output + * @param[in] sDisplayName - the display name of the output + * @param[in] eType - the type of the input + * @return The added input port + */ + virtual IImplicitPort * AddOutput(const std::string & sIdentifier, const std::string & sDisplayName, const Lib3MF::eImplicitPortType eType) = 0; + + /** + * IFunction::GetOutputs - Retrieves the outputs + * @return iterator for the outputs + */ + virtual IImplicitPortIterator * GetOutputs() = 0; + + /** + * IFunction::RemoveOutput - Removes an output + * @param[in] pOutput - The output to be removed + */ + virtual void RemoveOutput(IImplicitPort* pOutput) = 0; + + /** + * IFunction::FindInput - Retrieves an input + * @param[in] sIdentifier - the identifier of the input + * @return the input port + */ + virtual IImplicitPort * FindInput(const std::string & sIdentifier) = 0; + + /** + * IFunction::FindOutput - Retrieves an output + * @param[in] sIdentifier - the identifier of the output + * @return the output port + */ + virtual IImplicitPort * FindOutput(const std::string & sIdentifier) = 0; + +}; + +typedef IBaseSharedPtr PIFunction; + + +/************************************************************************************************************************* + Class interface for ImplicitFunction +**************************************************************************************************************************/ + +class IImplicitFunction : public virtual IFunction { +public: + /** + * IImplicitFunction::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x6CE54469EEA83BC1UL; // First 64 bits of SHA1 of a string: "Lib3MF::ImplicitFunction" + } + + /** + * IImplicitFunction::GetIdentifier - Retrieves the identifier of the function + * @return the identifier + */ + virtual std::string GetIdentifier() = 0; + + /** + * IImplicitFunction::SetIdentifier - Sets the identifier of the function + * @param[in] sIdentifier - the identifier + */ + virtual void SetIdentifier(const std::string & sIdentifier) = 0; + + /** + * IImplicitFunction::AddNode - Add a node + * @param[in] eNodeType - the type of the node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IImplicitNode * AddNode(const Lib3MF::eImplicitNodeType eNodeType, const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddSinNode - Add a SinNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ISinNode * AddSinNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddCosNode - Add a CosNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ICosNode * AddCosNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddTanNode - Add a TanNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ITanNode * AddTanNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddArcSinNode - Add a ArcSinNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IArcSinNode * AddArcSinNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddArcCosNode - Add a ArcCosNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IArcCosNode * AddArcCosNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddArcTan2Node - Add a ArcTan2Node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IArcTan2Node * AddArcTan2Node(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddSinhNode - Add a SinhNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ISinhNode * AddSinhNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddCoshNode - Add a CoshNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ICoshNode * AddCoshNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddTanhNode - Add a TanhNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ITanhNode * AddTanhNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddRoundNode - Add a RoundNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IRoundNode * AddRoundNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddCeilNode - Add a CeilNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ICeilNode * AddCeilNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddFloorNode - Add a FloorNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IFloorNode * AddFloorNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddSignNode - Add a SignNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ISignNode * AddSignNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddFractNode - Add a FractNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IFractNode * AddFractNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddAbsNode - Add a AbsNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IAbsNode * AddAbsNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddExpNode - Add a ExpNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IExpNode * AddExpNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddLogNode - Add a LogNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ILogNode * AddLogNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddLog2Node - Add a Log2Node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ILog2Node * AddLog2Node(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddLog10Node - Add a Log10Node + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ILog10Node * AddLog10Node(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddLengthNode - Add a LengthNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ILengthNode * AddLengthNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddTransposeNode - Add a TransposeNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ITransposeNode * AddTransposeNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddInverseNode - Add a InverseNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IInverseNode * AddInverseNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddSqrtNode - Add a SqrtNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ISqrtNode * AddSqrtNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddResourceIdNode - Add a ResourceIdNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IResourceIdNode * AddResourceIdNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddAdditionNode - Add an AdditionNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IAdditionNode * AddAdditionNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddSubtractionNode - Add a SubtractionNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ISubtractionNode * AddSubtractionNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddMultiplicationNode - Add a MultiplicationNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IMultiplicationNode * AddMultiplicationNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddDivisionNode - Add a DivisionNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IDivisionNode * AddDivisionNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddDotNode - Add a DotNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IDotNode * AddDotNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddCrossNode - Add a CrossNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ICrossNode * AddCrossNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddMatVecMultiplicationNode - Add a MatVecMultiplicationNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IMatVecMultiplicationNode * AddMatVecMultiplicationNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddMinNode - Add a MinNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IMinNode * AddMinNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddMaxNode - Add a MaxNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IMaxNode * AddMaxNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddFmodNode - Add a FmodNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IFmodNode * AddFmodNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddPowNode - Add a PowNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IPowNode * AddPowNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddSelectNode - Add a SelectNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual ISelectNode * AddSelectNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddClampNode - Add a ClampNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] eConfiguration - the configuration of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IClampNode * AddClampNode(const std::string & sIdentifier, const Lib3MF::eImplicitNodeConfiguration eConfiguration, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddComposeVectorNode - Add a ComposeVectorNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IComposeVectorNode * AddComposeVectorNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddVectorFromScalarNode - Add a VectorFromScalar + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IVectorFromScalarNode * AddVectorFromScalarNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddDecomposeVectorNode - Add a DecomposeVectorNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IDecomposeVectorNode * AddDecomposeVectorNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddComposeMatrixNode - Add a ComposeMatrixNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IComposeMatrixNode * AddComposeMatrixNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddMatrixFromRowsNode - Add a MatrixFromRowsNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IMatrixFromRowsNode * AddMatrixFromRowsNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddMatrixFromColumnsNode - Add a MatrixFromColumnsNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IMatrixFromColumnsNode * AddMatrixFromColumnsNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddConstantNode - Add a ConstantNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IConstantNode * AddConstantNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddConstVecNode - Add a ConstVecNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IConstVecNode * AddConstVecNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddConstMatNode - Add a ConstMatNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IConstMatNode * AddConstMatNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddMeshNode - Add a MeshNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IMeshNode * AddMeshNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddUnsignedMeshNode - Add a UnsignedMeshNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IUnsignedMeshNode * AddUnsignedMeshNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddBeamLatticeNode - Add a BeamLatticeNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IBeamLatticeNode * AddBeamLatticeNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddFunctionGradientNode - Add a FunctionGradientNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IFunctionGradientNode * AddFunctionGradientNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddNormalizeDistanceNode - Add a NormalizeDistanceNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual INormalizeDistanceNode * AddNormalizeDistanceNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::AddFunctionCallNode - Add a FunctionCallNode + * @param[in] sIdentifier - the identifier of the node + * @param[in] sDisplayName - the display name of the node + * @param[in] sTag - the tag of the node + * @return the added node + */ + virtual IFunctionCallNode * AddFunctionCallNode(const std::string & sIdentifier, const std::string & sDisplayName, const std::string & sTag) = 0; + + /** + * IImplicitFunction::GetNodes - Retrieves the nodes + * @return iterator for the list of nodes + */ + virtual INodeIterator * GetNodes() = 0; + + /** + * IImplicitFunction::RemoveNode - Removes a node + * @param[in] pNode - The node to be removed + */ + virtual void RemoveNode(IImplicitNode* pNode) = 0; + + /** + * IImplicitFunction::AddLink - Add a link + * @param[in] pSource - the source port + * @param[in] pTarget - the target port + */ + virtual void AddLink(IImplicitPort* pSource, IImplicitPort* pTarget) = 0; + + /** + * IImplicitFunction::AddLinkByNames - Add a link + * @param[in] sSource - name of the source port in the format nodename.portname + * @param[in] sTarget - name of the target port in the format nodename.portname + */ + virtual void AddLinkByNames(const std::string & sSource, const std::string & sTarget) = 0; + + /** + * IImplicitFunction::Clear - Clears the function + */ + virtual void Clear() = 0; + + /** + * IImplicitFunction::SortNodesTopologically - Sorts the nodes topologically + */ + virtual void SortNodesTopologically() = 0; + +}; + +typedef IBaseSharedPtr PIImplicitFunction; + + +/************************************************************************************************************************* + Class interface for FunctionFromImage3D +**************************************************************************************************************************/ + +class IFunctionFromImage3D : public virtual IFunction { +public: + /** + * IFunctionFromImage3D::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x9BD7D3C2026B8CE8UL; // First 64 bits of SHA1 of a string: "Lib3MF::FunctionFromImage3D" + } + + /** + * IFunctionFromImage3D::GetImage3D - Returns the selected 3D image. + * @return image instance + */ + virtual IImage3D * GetImage3D() = 0; + + /** + * IFunctionFromImage3D::SetImage3D - Sets the 3D image of the selector. + * @param[in] pImage3D - image instance + */ + virtual void SetImage3D(IImage3D* pImage3D) = 0; + + /** + * IFunctionFromImage3D::SetFilter - Sets the texture filter of the selector. + * @param[in] eFilter - texture filter + */ + virtual void SetFilter(const Lib3MF::eTextureFilter eFilter) = 0; + + /** + * IFunctionFromImage3D::GetFilter - Returns the texture filter of the selector. + * @return texture filter + */ + virtual Lib3MF::eTextureFilter GetFilter() = 0; + + /** + * IFunctionFromImage3D::SetTileStyles - Sets the tile styles of the selector. + * @param[in] eTileStyleU - tile style in U + * @param[in] eTileStyleV - tile style in V + * @param[in] eTileStyleW - tile style in W + */ + virtual void SetTileStyles(const Lib3MF::eTextureTileStyle eTileStyleU, const Lib3MF::eTextureTileStyle eTileStyleV, const Lib3MF::eTextureTileStyle eTileStyleW) = 0; + + /** + * IFunctionFromImage3D::GetTileStyles - Retrieves the tile styles of the selector. + * @param[out] eTileStyleU - tile style in U + * @param[out] eTileStyleV - tile style in V + * @param[out] eTileStyleW - tile style in W + */ + virtual void GetTileStyles(Lib3MF::eTextureTileStyle & eTileStyleU, Lib3MF::eTextureTileStyle & eTileStyleV, Lib3MF::eTextureTileStyle & eTileStyleW) = 0; + + /** + * IFunctionFromImage3D::GetOffset - returns the offset value for the pixel values in the Image3D + * @return the offset value for the pixel values in the Image3D + */ + virtual Lib3MF_double GetOffset() = 0; + + /** + * IFunctionFromImage3D::SetOffset - Sets the offset value for the pixel values in the Image3D + * @param[in] dOffset - the offset value for the pixel values in the Image3D + */ + virtual void SetOffset(const Lib3MF_double dOffset) = 0; + + /** + * IFunctionFromImage3D::GetScale - returns the scale value for the pixel values in the Image3D + * @return the scale value for the pixel values in the Image3D + */ + virtual Lib3MF_double GetScale() = 0; + + /** + * IFunctionFromImage3D::SetScale - Sets the scale value for the pixel values in the Image3D + * @param[in] dScale - the scale value for the pixel values in the Image3D + */ + virtual void SetScale(const Lib3MF_double dScale) = 0; + +}; + +typedef IBaseSharedPtr PIFunctionFromImage3D; + + /************************************************************************************************************************* Class interface for BuildItem **************************************************************************************************************************/ class IBuildItem : public virtual IBase { public: + /** + * IBuildItem::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x68FB2D5FFC4BA12AUL; // First 64 bits of SHA1 of a string: "Lib3MF::BuildItem" + } + /** * IBuildItem::GetObjectResource - Retrieves the object resource associated to a build item * @return returns the associated resource instance @@ -1950,6 +5836,15 @@ typedef IBaseSharedPtr PIBuildItem; class IBuildItemIterator : public virtual IBase { public: + /** + * IBuildItemIterator::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xA7D21BD364910860UL; // First 64 bits of SHA1 of a string: "Lib3MF::BuildItemIterator" + } + /** * IBuildItemIterator::MoveNext - Iterates to the next build item in the list. * @return Iterates to the next build item in the list. @@ -1991,6 +5886,15 @@ typedef IBaseSharedPtr PIBuildItemIterator; class ISlice : public virtual IBase { public: + /** + * ISlice::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x2198BCF4D8DF9C40UL; // First 64 bits of SHA1 of a string: "Lib3MF::Slice" + } + /** * ISlice::SetVertices - Set all vertices of a slice. All polygons will be cleared. * @param[in] nVerticesBufferSize - Number of elements in buffer @@ -2067,6 +5971,15 @@ typedef IBaseSharedPtr PISlice; class ISliceStack : public virtual IResource { public: + /** + * ISliceStack::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x6594B031B6096238UL; // First 64 bits of SHA1 of a string: "Lib3MF::SliceStack" + } + /** * ISliceStack::GetBottomZ - Get the lower Z-Coordinate of the slice stack. * @return the lower Z-Coordinate the slice stack @@ -2140,6 +6053,15 @@ typedef IBaseSharedPtr PISliceStack; class IConsumer : public virtual IBase { public: + /** + * IConsumer::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD9E46D5E6D8118EEUL; // First 64 bits of SHA1 of a string: "Lib3MF::Consumer" + } + /** * IConsumer::GetConsumerID - Gets the consumerid * @return A unique identifier for the consumers @@ -2169,6 +6091,15 @@ typedef IBaseSharedPtr PIConsumer; class IAccessRight : public virtual IBase { public: + /** + * IAccessRight::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x385C42FC5609498AUL; // First 64 bits of SHA1 of a string: "Lib3MF::AccessRight" + } + /** * IAccessRight::GetConsumer - Gets the consumer associated with this access right * @return The consumer instance @@ -2204,6 +6135,15 @@ typedef IBaseSharedPtr PIAccessRight; class IContentEncryptionParams : public virtual IBase { public: + /** + * IContentEncryptionParams::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x7FB36B91D4CE4671UL; // First 64 bits of SHA1 of a string: "Lib3MF::ContentEncryptionParams" + } + /** * IContentEncryptionParams::GetEncryptionAlgorithm - Returns the encryption method to be used in this encryption process * @return @@ -2272,6 +6212,15 @@ typedef IBaseSharedPtr PIContentEncryptionParams; class IResourceData : public virtual IBase { public: + /** + * IResourceData::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x1A47A5E258E22EF9UL; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceData" + } + /** * IResourceData::GetPath - Gets the encrypted part path * @return The part path @@ -2309,6 +6258,15 @@ typedef IBaseSharedPtr PIResourceData; class IResourceDataGroup : public virtual IBase { public: + /** + * IResourceDataGroup::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0xD59067227E428AA4UL; // First 64 bits of SHA1 of a string: "Lib3MF::ResourceDataGroup" + } + /** * IResourceDataGroup::GetKeyUUID - Sets the resourcedatagroup keyuuid * @return The new resourcedatagroup keyuuid. @@ -2349,6 +6307,15 @@ typedef IBaseSharedPtr PIResourceDataGroup; class IKeyStore : public virtual IBase { public: + /** + * IKeyStore::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x1CC9E0CC082253C6UL; // First 64 bits of SHA1 of a string: "Lib3MF::KeyStore" + } + /** * IKeyStore::AddConsumer - Adds a consumer to the keystore * @param[in] sConsumerID - A unique identifier for the consumer @@ -2478,6 +6445,15 @@ typedef IBaseSharedPtr PIKeyStore; class IModel : public virtual IBase { public: + /** + * IModel::ClassTypeId - Get Class Type Id + * @return Class type as a 64 bits integer + */ + Lib3MF_uint64 ClassTypeId() override + { + return 0x5A8164ECEDB03F09UL; // First 64 bits of SHA1 of a string: "Lib3MF::Model" + } + /** * IModel::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 @@ -2529,6 +6505,13 @@ public: */ virtual IReader * QueryReader(const std::string & sReaderClass) = 0; + /** + * IModel::GetResourceByID - finds a model resource by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the resource instance + */ + virtual IResource * GetResourceByID(const Lib3MF_uint32 nUniqueResourceID) = 0; + /** * IModel::GetTexture2DByID - finds a model texture by its UniqueResourceID * @param[in] nUniqueResourceID - UniqueResourceID @@ -2599,6 +6582,13 @@ public: */ virtual ISliceStack * GetSliceStackByID(const Lib3MF_uint32 nUniqueResourceID) = 0; + /** + * IModel::GetLevelSetByID - finds a level set object by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the level set object instance + */ + virtual ILevelSet * GetLevelSetByID(const Lib3MF_uint32 nUniqueResourceID) = 0; + /** * IModel::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 @@ -2690,12 +6680,24 @@ public: */ virtual ISliceStackIterator * GetSliceStacks() = 0; + /** + * IModel::GetImage3Ds - creates a resource iterator instance with all image3d resources. + * @return returns the iterator instance. + */ + virtual IImage3DIterator * GetImage3Ds() = 0; + /** * IModel::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 */ virtual IModel * MergeToModel() = 0; + /** + * IModel::MergeFromModel - Merges the given model into this model. + * @param[in] pModelInstance - model to be merged + */ + virtual void MergeFromModel(IModel* pModelInstance) = 0; + /** * IModel::AddMeshObject - adds an empty mesh object to the model. * @return returns the mesh object instance @@ -2754,6 +6756,22 @@ public: */ virtual IMultiPropertyGroup * AddMultiPropertyGroup() = 0; + /** + * IModel::AddImageStack - creates a new 3D Image Resource + * @param[in] nColumnCount - the number of columns in each sheet. + * @param[in] nRowCount - the number of rows in each sheet. + * @param[in] nSheetCount - the number of sheets in the image stack. + * @return returns the new ImageStack instance + */ + virtual IImageStack * AddImageStack(const Lib3MF_uint32 nColumnCount, const Lib3MF_uint32 nRowCount, const Lib3MF_uint32 nSheetCount) = 0; + + /** + * IModel::GetImageStackByID - finds an ImageStack object by its UniqueResourceID + * @param[in] nUniqueResourceID - UniqueResourceID + * @return returns the image stack instance + */ + virtual IImageStack * GetImageStackByID(const Lib3MF_uint32 nUniqueResourceID) = 0; + /** * IModel::AddBuildItem - adds a build item to the model. * @param[in] pObject - Object instance. @@ -2857,6 +6875,49 @@ public: */ virtual IKeyStore * GetKeyStore() = 0; + /** + * IModel::GetFunctions - creates a resource iterator for all functions + * @return returns the resource iterator + */ + virtual IFunctionIterator * GetFunctions() = 0; + + /** + * IModel::AddImplicitFunction - adds a function described by nodes to the model + * @return returns the function instance + */ + virtual IImplicitFunction * AddImplicitFunction() = 0; + + /** + * IModel::AddFunctionFromImage3D - adds a function defined by an image3d to the model + * @param[in] pImage3DInstance - the Image3D-instance used for this function + * @return returns the function instance + */ + virtual IFunctionFromImage3D * AddFunctionFromImage3D(IImage3D* pImage3DInstance) = 0; + + /** + * IModel::AddVolumeData - adds a volume data resource to the model. + * @return returns the new volume data instance. + */ + virtual IVolumeData * AddVolumeData() = 0; + + /** + * IModel::AddLevelSet - adds an empty boundary shape object to the model. + * @return returns the mesh object instance + */ + virtual ILevelSet * AddLevelSet() = 0; + + /** + * IModel::GetLevelSets - creates a resource iterator instance with all boundary shape resources. + * @return returns the iterator instance. + */ + virtual ILevelSetIterator * GetLevelSets() = 0; + + /** + * IModel::RemoveResource - Removes a resource from the model + * @param[in] pResource - The resource to remove + */ + virtual void RemoveResource(IResource* pResource) = 0; + }; typedef IBaseSharedPtr PIModel; @@ -3005,6 +7066,8 @@ public: }; +Lib3MFResult Lib3MF_GetProcAddress (const char * pProcName, void ** ppProcAddress); + } // namespace Impl } // namespace Lib3MF diff --git a/Include/lib3mf_types.hpp b/Include/lib3mf_types.hpp index c13c034..2ae400a 100644 --- a/Include/lib3mf_types.hpp +++ b/Include/lib3mf_types.hpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,12 +24,12 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. 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 +Interface version: 2.5.0 */ @@ -83,7 +83,7 @@ typedef void * Lib3MF_pvoid; **************************************************************************************************************************/ #define LIB3MF_VERSION_MAJOR 2 -#define LIB3MF_VERSION_MINOR 2 +#define LIB3MF_VERSION_MINOR 5 #define LIB3MF_VERSION_MICRO 0 #define LIB3MF_VERSION_PRERELEASEINFO "" #define LIB3MF_VERSION_BUILDINFO "" @@ -93,47 +93,117 @@ typedef void * Lib3MF_pvoid; **************************************************************************************************************************/ #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 +#define LIB3MF_ERROR_NOTIMPLEMENTED 1 /** functionality not implemented */ +#define LIB3MF_ERROR_INVALIDPARAM 2 /** an invalid parameter was passed */ +#define LIB3MF_ERROR_INVALIDCAST 3 /** a type cast failed */ +#define LIB3MF_ERROR_BUFFERTOOSMALL 4 /** a provided buffer is too small */ +#define LIB3MF_ERROR_GENERICEXCEPTION 5 /** a generic exception occurred */ +#define LIB3MF_ERROR_COULDNOTLOADLIBRARY 6 /** the library could not be loaded */ +#define LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT 7 /** a required exported symbol could not be found in the library */ +#define LIB3MF_ERROR_INCOMPATIBLEBINARYVERSION 8 /** the version of the binary interface does not match the bindings interface */ +#define LIB3MF_ERROR_CALCULATIONABORTED 10 /** a calculation has been aborted */ +#define LIB3MF_ERROR_SHOULDNOTBECALLED 11 /** functionality should not be called */ +#define LIB3MF_ERROR_READERCLASSUNKNOWN 100 /** the queried reader class is unknown */ +#define LIB3MF_ERROR_WRITERCLASSUNKNOWN 101 /** the queried writer class is unknown */ +#define LIB3MF_ERROR_ITERATORINVALIDINDEX 102 /** the current index of an iterator is invalid */ +#define LIB3MF_ERROR_INVALIDMODELRESOURCE 103 /** no Model Resource has been given */ +#define LIB3MF_ERROR_RESOURCENOTFOUND 104 /** Resource not found */ +#define LIB3MF_ERROR_INVALIDMODEL 105 /** A model is invalid */ +#define LIB3MF_ERROR_INVALIDOBJECT 106 /** An object is invalid */ +#define LIB3MF_ERROR_INVALIDMESHOBJECT 107 /** A mesh object is invalid */ +#define LIB3MF_ERROR_INVALIDCOMPONENTSOBJECT 108 /** A components object is invalid */ +#define LIB3MF_ERROR_INVALIDCOMPONENT 109 /** A component is invalid */ +#define LIB3MF_ERROR_INVALIDBUILDITEM 110 /** A build item is invalid */ +#define LIB3MF_ERROR_INVALIDBASEMATERIALGROUP 111 /** A basematerialgroup is invalid */ +#define LIB3MF_ERROR_INVALIDSLICESTACKRESOURCE 112 /** A slicestack resource is invalid */ +#define LIB3MF_ERROR_INVALIDTEXTURERESOURCE 113 /** A texture resource is invalid */ +#define LIB3MF_ERROR_INVALIDCOLORGROUP 114 /** A color group resource is invalid */ +#define LIB3MF_ERROR_INVALIDTEXTURE2DGROUP 115 /** A texture2d group resource is invalid */ +#define LIB3MF_ERROR_INVALIDCOMPOSITEMATERIALS 116 /** A composite materials resource is invalid */ +#define LIB3MF_ERROR_INVALIDMULTIPROPERTYGROUP 117 /** A MultiPropertyGroup resource is invalid */ +#define LIB3MF_ERROR_INVALIDRESOURCEINDEX 120 /** A resource index is invalid */ +#define LIB3MF_ERROR_ATTACHMENTNOTFOUND 121 /** Attachment not found */ +#define LIB3MF_ERROR_FORBIDDENCYCLICREFERENCE 130 /** A component references one of its ancestors */ +#define LIB3MF_ERROR_INVALIDATTACHMENTSTREAM 131 /** An attachment stream is invalid */ +#define LIB3MF_ERROR_INVALIDPROPERTYCOUNT 132 /** Invalid property count. */ +#define LIB3MF_ERROR_UNKOWNPROGRESSIDENTIFIER 140 /** A progress identifier is unknown */ +#define LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT 141 /** An element buffer exceeds its spec limit */ +#define LIB3MF_ERROR_INVALIDRESOURCE 142 /** A resource is invalid */ +#define LIB3MF_ERROR_INVALIDLEVELSET 143 /** A level set is invalid */ +#define LIB3MF_ERROR_COULDNOTFINDTRIANGLESET 144 /** Could not find triangle set */ +#define LIB3MF_ERROR_INVALIDTRIANGLESETINDEX 145 /** Invalid triangle set index */ +#define LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE 2000 /** This object type is not valid for beamlattices */ +#define LIB3MF_ERROR_INVALIDKEYSTORE 3000 /** The keystore object is invalid */ +#define LIB3MF_ERROR_INVALIDKEYSTORECONSUMER 3001 /** The consumer keystore object is invalid */ +#define LIB3MF_ERROR_KEYSTORECONSUMERNOTFOUND 3002 /** A consumer has not been found */ +#define LIB3MF_ERROR_KEYSTORERESOURCEDATANOTFOUND 3003 /** A resource data has not been found */ +#define LIB3MF_ERROR_SECURECONTEXTNOTREGISTERED 3004 /** A Key or Conentent encryption callback has not been registered */ +#define LIB3MF_ERROR_INVALIDKEYSIZE 3005 /** The key size is invalid */ +#define LIB3MF_ERROR_INCOMPATIBLEPORTTYPES 4000 /** Link could not be added, the port types are incompatible */ +#define LIB3MF_ERROR_GRAPHISCYCLIC 4001 /** The functin graph is cyclic. Only dircected graphs are valid and can be topological sorted. */ +#define LIB3MF_ERROR_INPUTNOTSET 4002 /** The input of a node is not set. */ +#define LIB3MF_ERROR_INVALIDNODECONFIGURATION 4003 /** The selected node configuration is not supported */ + +/************************************************************************************************************************* + Error strings for Lib3MF +**************************************************************************************************************************/ + +inline const char * LIB3MF_GETERRORSTRING (Lib3MFResult nErrorCode) { + switch (nErrorCode) { + case LIB3MF_SUCCESS: return "no error"; + case LIB3MF_ERROR_NOTIMPLEMENTED: return "functionality not implemented"; + case LIB3MF_ERROR_INVALIDPARAM: return "an invalid parameter was passed"; + case LIB3MF_ERROR_INVALIDCAST: return "a type cast failed"; + case LIB3MF_ERROR_BUFFERTOOSMALL: return "a provided buffer is too small"; + case LIB3MF_ERROR_GENERICEXCEPTION: return "a generic exception occurred"; + case LIB3MF_ERROR_COULDNOTLOADLIBRARY: return "the library could not be loaded"; + case LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT: return "a required exported symbol could not be found in the library"; + case LIB3MF_ERROR_INCOMPATIBLEBINARYVERSION: return "the version of the binary interface does not match the bindings interface"; + case LIB3MF_ERROR_CALCULATIONABORTED: return "a calculation has been aborted"; + case LIB3MF_ERROR_SHOULDNOTBECALLED: return "functionality should not be called"; + case LIB3MF_ERROR_READERCLASSUNKNOWN: return "the queried reader class is unknown"; + case LIB3MF_ERROR_WRITERCLASSUNKNOWN: return "the queried writer class is unknown"; + case LIB3MF_ERROR_ITERATORINVALIDINDEX: return "the current index of an iterator is invalid"; + case LIB3MF_ERROR_INVALIDMODELRESOURCE: return "no Model Resource has been given"; + case LIB3MF_ERROR_RESOURCENOTFOUND: return "Resource not found"; + case LIB3MF_ERROR_INVALIDMODEL: return "A model is invalid"; + case LIB3MF_ERROR_INVALIDOBJECT: return "An object is invalid"; + case LIB3MF_ERROR_INVALIDMESHOBJECT: return "A mesh object is invalid"; + case LIB3MF_ERROR_INVALIDCOMPONENTSOBJECT: return "A components object is invalid"; + case LIB3MF_ERROR_INVALIDCOMPONENT: return "A component is invalid"; + case LIB3MF_ERROR_INVALIDBUILDITEM: return "A build item is invalid"; + case LIB3MF_ERROR_INVALIDBASEMATERIALGROUP: return "A basematerialgroup is invalid"; + case LIB3MF_ERROR_INVALIDSLICESTACKRESOURCE: return "A slicestack resource is invalid"; + case LIB3MF_ERROR_INVALIDTEXTURERESOURCE: return "A texture resource is invalid"; + case LIB3MF_ERROR_INVALIDCOLORGROUP: return "A color group resource is invalid"; + case LIB3MF_ERROR_INVALIDTEXTURE2DGROUP: return "A texture2d group resource is invalid"; + case LIB3MF_ERROR_INVALIDCOMPOSITEMATERIALS: return "A composite materials resource is invalid"; + case LIB3MF_ERROR_INVALIDMULTIPROPERTYGROUP: return "A MultiPropertyGroup resource is invalid"; + case LIB3MF_ERROR_INVALIDRESOURCEINDEX: return "A resource index is invalid"; + case LIB3MF_ERROR_ATTACHMENTNOTFOUND: return "Attachment not found"; + case LIB3MF_ERROR_FORBIDDENCYCLICREFERENCE: return "A component references one of its ancestors"; + case LIB3MF_ERROR_INVALIDATTACHMENTSTREAM: return "An attachment stream is invalid"; + case LIB3MF_ERROR_INVALIDPROPERTYCOUNT: return "Invalid property count."; + case LIB3MF_ERROR_UNKOWNPROGRESSIDENTIFIER: return "A progress identifier is unknown"; + case LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT: return "An element buffer exceeds its spec limit"; + case LIB3MF_ERROR_INVALIDRESOURCE: return "A resource is invalid"; + case LIB3MF_ERROR_INVALIDLEVELSET: return "A level set is invalid"; + case LIB3MF_ERROR_COULDNOTFINDTRIANGLESET: return "Could not find triangle set"; + case LIB3MF_ERROR_INVALIDTRIANGLESETINDEX: return "Invalid triangle set index"; + case LIB3MF_ERROR_BEAMLATTICE_INVALID_OBJECTTYPE: return "This object type is not valid for beamlattices"; + case LIB3MF_ERROR_INVALIDKEYSTORE: return "The keystore object is invalid"; + case LIB3MF_ERROR_INVALIDKEYSTORECONSUMER: return "The consumer keystore object is invalid"; + case LIB3MF_ERROR_KEYSTORECONSUMERNOTFOUND: return "A consumer has not been found"; + case LIB3MF_ERROR_KEYSTORERESOURCEDATANOTFOUND: return "A resource data has not been found"; + case LIB3MF_ERROR_SECURECONTEXTNOTREGISTERED: return "A Key or Conentent encryption callback has not been registered"; + case LIB3MF_ERROR_INVALIDKEYSIZE: return "The key size is invalid"; + case LIB3MF_ERROR_INCOMPATIBLEPORTTYPES: return "Link could not be added, the port types are incompatible"; + case LIB3MF_ERROR_GRAPHISCYCLIC: return "The functin graph is cyclic. Only dircected graphs are valid and can be topological sorted."; + case LIB3MF_ERROR_INPUTNOTSET: return "The input of a node is not set."; + case LIB3MF_ERROR_INVALIDNODECONFIGURATION: return "The selected node configuration is not supported"; + default: return "unknown error"; + } +} /************************************************************************************************************************* Declaration of handle classes @@ -155,11 +225,22 @@ typedef Lib3MFHandle Lib3MF_ColorGroupIterator; typedef Lib3MFHandle Lib3MF_Texture2DGroupIterator; typedef Lib3MFHandle Lib3MF_CompositeMaterialsIterator; typedef Lib3MFHandle Lib3MF_MultiPropertyGroupIterator; +typedef Lib3MFHandle Lib3MF_Image3DIterator; +typedef Lib3MFHandle Lib3MF_FunctionIterator; +typedef Lib3MFHandle Lib3MF_LevelSetIterator; typedef Lib3MFHandle Lib3MF_MetaData; typedef Lib3MFHandle Lib3MF_MetaDataGroup; +typedef Lib3MFHandle Lib3MF_TriangleSet; typedef Lib3MFHandle Lib3MF_Object; typedef Lib3MFHandle Lib3MF_MeshObject; +typedef Lib3MFHandle Lib3MF_LevelSet; typedef Lib3MFHandle Lib3MF_BeamLattice; +typedef Lib3MFHandle Lib3MF_FunctionReference; +typedef Lib3MFHandle Lib3MF_VolumeDataColor; +typedef Lib3MFHandle Lib3MF_MaterialMapping; +typedef Lib3MFHandle Lib3MF_VolumeDataComposite; +typedef Lib3MFHandle Lib3MF_VolumeDataProperty; +typedef Lib3MFHandle Lib3MF_VolumeData; typedef Lib3MFHandle Lib3MF_Component; typedef Lib3MFHandle Lib3MF_ComponentsObject; typedef Lib3MFHandle Lib3MF_BeamSet; @@ -168,8 +249,74 @@ typedef Lib3MFHandle Lib3MF_ColorGroup; typedef Lib3MFHandle Lib3MF_Texture2DGroup; typedef Lib3MFHandle Lib3MF_CompositeMaterials; typedef Lib3MFHandle Lib3MF_MultiPropertyGroup; +typedef Lib3MFHandle Lib3MF_Image3D; +typedef Lib3MFHandle Lib3MF_ImageStack; typedef Lib3MFHandle Lib3MF_Attachment; typedef Lib3MFHandle Lib3MF_Texture2D; +typedef Lib3MFHandle Lib3MF_ImplicitPort; +typedef Lib3MFHandle Lib3MF_Iterator; +typedef Lib3MFHandle Lib3MF_ImplicitPortIterator; +typedef Lib3MFHandle Lib3MF_ImplicitNode; +typedef Lib3MFHandle Lib3MF_OneInputNode; +typedef Lib3MFHandle Lib3MF_SinNode; +typedef Lib3MFHandle Lib3MF_CosNode; +typedef Lib3MFHandle Lib3MF_TanNode; +typedef Lib3MFHandle Lib3MF_ArcSinNode; +typedef Lib3MFHandle Lib3MF_ArcCosNode; +typedef Lib3MFHandle Lib3MF_ArcTanNode; +typedef Lib3MFHandle Lib3MF_SinhNode; +typedef Lib3MFHandle Lib3MF_CoshNode; +typedef Lib3MFHandle Lib3MF_TanhNode; +typedef Lib3MFHandle Lib3MF_RoundNode; +typedef Lib3MFHandle Lib3MF_CeilNode; +typedef Lib3MFHandle Lib3MF_FloorNode; +typedef Lib3MFHandle Lib3MF_SignNode; +typedef Lib3MFHandle Lib3MF_FractNode; +typedef Lib3MFHandle Lib3MF_AbsNode; +typedef Lib3MFHandle Lib3MF_ExpNode; +typedef Lib3MFHandle Lib3MF_LogNode; +typedef Lib3MFHandle Lib3MF_Log2Node; +typedef Lib3MFHandle Lib3MF_Log10Node; +typedef Lib3MFHandle Lib3MF_LengthNode; +typedef Lib3MFHandle Lib3MF_TransposeNode; +typedef Lib3MFHandle Lib3MF_InverseNode; +typedef Lib3MFHandle Lib3MF_SqrtNode; +typedef Lib3MFHandle Lib3MF_ResourceIdNode; +typedef Lib3MFHandle Lib3MF_TwoInputNode; +typedef Lib3MFHandle Lib3MF_AdditionNode; +typedef Lib3MFHandle Lib3MF_SubtractionNode; +typedef Lib3MFHandle Lib3MF_MultiplicationNode; +typedef Lib3MFHandle Lib3MF_DivisionNode; +typedef Lib3MFHandle Lib3MF_DotNode; +typedef Lib3MFHandle Lib3MF_CrossNode; +typedef Lib3MFHandle Lib3MF_ArcTan2Node; +typedef Lib3MFHandle Lib3MF_MatVecMultiplicationNode; +typedef Lib3MFHandle Lib3MF_MinNode; +typedef Lib3MFHandle Lib3MF_MaxNode; +typedef Lib3MFHandle Lib3MF_FmodNode; +typedef Lib3MFHandle Lib3MF_ModNode; +typedef Lib3MFHandle Lib3MF_PowNode; +typedef Lib3MFHandle Lib3MF_SelectNode; +typedef Lib3MFHandle Lib3MF_ClampNode; +typedef Lib3MFHandle Lib3MF_ComposeVectorNode; +typedef Lib3MFHandle Lib3MF_VectorFromScalarNode; +typedef Lib3MFHandle Lib3MF_DecomposeVectorNode; +typedef Lib3MFHandle Lib3MF_ComposeMatrixNode; +typedef Lib3MFHandle Lib3MF_MatrixFromRowsNode; +typedef Lib3MFHandle Lib3MF_MatrixFromColumnsNode; +typedef Lib3MFHandle Lib3MF_ConstantNode; +typedef Lib3MFHandle Lib3MF_ConstVecNode; +typedef Lib3MFHandle Lib3MF_ConstMatNode; +typedef Lib3MFHandle Lib3MF_MeshNode; +typedef Lib3MFHandle Lib3MF_UnsignedMeshNode; +typedef Lib3MFHandle Lib3MF_BeamLatticeNode; +typedef Lib3MFHandle Lib3MF_FunctionGradientNode; +typedef Lib3MFHandle Lib3MF_NormalizeDistanceNode; +typedef Lib3MFHandle Lib3MF_FunctionCallNode; +typedef Lib3MFHandle Lib3MF_NodeIterator; +typedef Lib3MFHandle Lib3MF_Function; +typedef Lib3MFHandle Lib3MF_ImplicitFunction; +typedef Lib3MFHandle Lib3MF_FunctionFromImage3D; typedef Lib3MFHandle Lib3MF_BuildItem; typedef Lib3MFHandle Lib3MF_BuildItemIterator; typedef Lib3MFHandle Lib3MF_Slice; @@ -215,7 +362,8 @@ namespace Lib3MF { Other = 0, Model = 1, Support = 2, - SolidSupport = 3 + SolidSupport = 3, + Surface = 4 }; enum class eTextureType : Lib3MF_int32 { @@ -250,7 +398,7 @@ namespace Lib3MF { }; enum class eBeamLatticeBallMode : Lib3MF_int32 { - None = 0, + BeamLatticeBallModeNone = 0, Mixed = 1, All = 2 }; @@ -288,30 +436,130 @@ namespace Lib3MF { Multiply = 2 }; + enum class eChannelName : Lib3MF_int32 { + Red = 0, + Green = 1, + Blue = 2, + Alpha = 3 + }; + + enum class eCompositionMethod : Lib3MF_int32 { + WeightedSum = 0, + Multiply = 1, + Min = 2, + Max = 3, + Mask = 4 + }; + + enum class eCompositionSpace : Lib3MF_int32 { + Raw = 0, + LinearColor = 1 + }; + + /** + * enum class eImplicitNodeType - The type of the node + */ + enum class eImplicitNodeType : Lib3MF_int32 { + Addition = 0, /** Adds to values (scalar or vector) */ + Subtraction = 1, /** Subtracts two values (scalar or vector) */ + Multiplication = 2, /** Multiplies two values (scalar or vector) */ + Division = 3, /** Divides two values (scalar or vector) */ + Constant = 4, /** A constant scalar value */ + ConstVec = 5, /** A constant vector value */ + ConstMat = 6, /** A constant matrix value */ + ComposeVector = 7, /** Creates a vector from three scalar values */ + DecomposeVector = 8, /** Decomposes a vector into three scalar values */ + ComposeMatrix = 9, /** Creates a matrix from nine scalar values */ + MatrixFromColumns = 10, /** Creates a matrix from three column vector values */ + MatrixFromRows = 11, /** Creates a matrix from three row vector values */ + Dot = 12, /** Calculates the dot product of two vector values */ + Cross = 13, /** Calculates the cross product of two vector values */ + MatVecMultiplication = 14, /** Multiplies a matrix with a vector */ + Transpose = 15, /** Transposes a matrix */ + Inverse = 16, /** Computes the inverse of a matrix */ + Sinus = 17, /** Calculates the sine */ + Cosinus = 18, /** Calculates the cosine */ + Tan = 19, /** Calculates the tangent */ + ArcSin = 20, /** Calculates the arcsine */ + ArcCos = 21, /** Calculates the arccosine */ + ArcTan = 22, /** Calculates the arctangent */ + ArcTan2 = 23, /** Calculates the arctangent */ + Min = 24, /** Calculates the minimum of two values */ + Max = 25, /** Calculates the maximum of two values */ + Abs = 26, /** Calculates the absolute value */ + Fmod = 27, /** Computes the remainder of the divison of the inputs (same behavior as C fmod) */ + Pow = 28, /** Calculates the power A^B */ + Sqrt = 29, /** Calculates the square root */ + Exp = 30, /** Exponential function */ + Log = 31, /** Natural logarithm */ + Log2 = 32, /** Logarithm to the base 2 */ + Log10 = 33, /** Logarithm to the base 10 */ + Select = 34, /** If A is less than B returns C, else D */ + Clamp = 35, /** Clamps the input value to min and max */ + Sinh = 36, /** Calculates the hyperbolic sine */ + Cosh = 37, /** Calculates the hyperbolic cosine */ + Tanh = 38, /** Calculates the hyperbolic tangent */ + Round = 39, /** Rounds a scalar value to the nearest integer */ + Ceil = 40, /** Rounds a scalar value up to the nearest integer */ + Floor = 41, /** Rounds a scalar value down to the nearest integer */ + Sign = 42, /** Returns the sign */ + Fract = 43, /** Returns the fractional part */ + FunctionCall = 44, /** Calls a function */ + Mesh = 45, /** Calculates the signed distance to a mesh */ + Length = 46, /** Calculates the length of a vector */ + ConstResourceID = 47, /** Selects a resource (function, mesh etc.) */ + VectorFromScalar = 48, /** Creates a vector from one scalar value */ + UnsignedMesh = 49, /** Calculates the unsigned distance to a mesh */ + Mod = 50, /** Calculates the modulo of two values (same behaviour as glsl mod) */ + BeamLattice = 51, /** Calculates the signed distance to a beam lattice */ + FunctionGradient = 52, /** Calculates the gradient of a function */ + NormalizeDistance = 53 /** Normalizes a distance field */ + }; + + /** + * enum class eImplicitPortType - The type of the port + */ + enum class eImplicitPortType : Lib3MF_int32 { + Scalar = 0, /** Scalar */ + Vector = 1, /** Vector */ + Matrix = 2, /** 4x4 Matrix */ + ResourceID = 3 /** Resource ID */ + }; + + /** + * enum class eImplicitNodeConfiguration - Defines the input and output types of a node + */ + enum class eImplicitNodeConfiguration : Lib3MF_int32 { + Default = 0, /** Default */ + ScalarToScalar = 1, /** Scalar -> Scalar */ + VectorToVector = 2, /** Vector -> Vector */ + MatrixToMatrix = 3 /** Matrix -> Matrix */ + }; + enum class eEncryptionAlgorithm : Lib3MF_int32 { - AES256_GCM = 1 + AES256_GCM = 1 /** http://www.w3.org/2009/xmlenc11#aes256-gcm */ }; enum class eWrappingAlgorithm : Lib3MF_int32 { - RSA_OAEP = 0 + RSA_OAEP = 0 /** http://www.w3.org/2009/xmlenc11#rsa-oaep */ }; enum class eMgfAlgorithm : Lib3MF_int32 { - MGF1_SHA1 = 160, - MGF1_SHA224 = 224, - MGF1_SHA256 = 256, - MGF1_SHA384 = 384, - MGF1_SHA512 = 512 + MGF1_SHA1 = 160, /** http://www.w3.org/2009/xmlenc11#mgf1sha1 */ + MGF1_SHA224 = 224, /** http://www.w3.org/2009/xmlenc11#mgf1sha224 */ + MGF1_SHA256 = 256, /** http://www.w3.org/2009/xmlenc11#mgf1sha256 */ + MGF1_SHA384 = 384, /** http://www.w3.org/2009/xmlenc11#mgf1sha384 */ + MGF1_SHA512 = 512 /** http://www.w3.org/2009/xmlenc11#mgf1sha512 */ }; enum class eDigestMethod : Lib3MF_int32 { - SHA1 = 160, - SHA256 = 256 + SHA1 = 160, /** http://www.w3.org/2000/09/xmldsig#sha1 */ + SHA256 = 256 /** http://www.w3.org/2001/04/xmlenc#sha256 */ }; enum class eCompression : Lib3MF_int32 { - NoCompression = 0, - Deflate = 1 + NoCompression = 0, /** No compression applied */ + Deflate = 1 /** Deflate compression applied */ }; /************************************************************************************************************************* @@ -320,65 +568,73 @@ namespace Lib3MF { #pragma pack (1) - typedef struct { + typedef struct sTriangle { Lib3MF_uint32 m_Indices[3]; } sTriangle; - typedef struct { + typedef struct sTriangleProperties { Lib3MF_uint32 m_ResourceID; Lib3MF_uint32 m_PropertyIDs[3]; } sTriangleProperties; - typedef struct { + typedef struct sPosition { Lib3MF_single m_Coordinates[3]; } sPosition; - typedef struct { + typedef struct sPosition2D { Lib3MF_single m_Coordinates[2]; } sPosition2D; - typedef struct { + typedef struct sCompositeConstituent { Lib3MF_uint32 m_PropertyID; Lib3MF_double m_MixingRatio; } sCompositeConstituent; - typedef struct { + typedef struct sMultiPropertyLayer { Lib3MF_uint32 m_ResourceID; eBlendMethod m_TheBlendMethod; } sMultiPropertyLayer; - typedef struct { + typedef struct sTex2Coord { Lib3MF_double m_U; Lib3MF_double m_V; } sTex2Coord; - typedef struct { + typedef struct sTransform { Lib3MF_single m_Fields[4][3]; } sTransform; - typedef struct { + typedef struct sBox { Lib3MF_single m_MinCoordinate[3]; Lib3MF_single m_MaxCoordinate[3]; } sBox; - typedef struct { + typedef struct sColor { Lib3MF_uint8 m_Red; Lib3MF_uint8 m_Green; Lib3MF_uint8 m_Blue; Lib3MF_uint8 m_Alpha; } sColor; - typedef struct { + typedef struct sBeam { Lib3MF_uint32 m_Indices[2]; Lib3MF_double m_Radii[2]; eBeamLatticeCapMode m_CapModes[2]; } sBeam; - typedef struct { + typedef struct sBall { Lib3MF_uint32 m_Index; Lib3MF_double m_Radius; } sBall; + typedef struct sVector { + Lib3MF_double m_Coordinates[3]; + } sVector; + + typedef struct sMatrix4x4 { + Lib3MF_double m_Field[4][4]; + } sMatrix4x4; + #pragma pack () /************************************************************************************************************************* @@ -474,6 +730,12 @@ typedef Lib3MF::eBeamLatticeClipMode eLib3MFBeamLatticeClipMode; typedef Lib3MF::eBeamLatticeBallMode eLib3MFBeamLatticeBallMode; typedef Lib3MF::eProgressIdentifier eLib3MFProgressIdentifier; typedef Lib3MF::eBlendMethod eLib3MFBlendMethod; +typedef Lib3MF::eChannelName eLib3MFChannelName; +typedef Lib3MF::eCompositionMethod eLib3MFCompositionMethod; +typedef Lib3MF::eCompositionSpace eLib3MFCompositionSpace; +typedef Lib3MF::eImplicitNodeType eLib3MFImplicitNodeType; +typedef Lib3MF::eImplicitPortType eLib3MFImplicitPortType; +typedef Lib3MF::eImplicitNodeConfiguration eLib3MFImplicitNodeConfiguration; typedef Lib3MF::eEncryptionAlgorithm eLib3MFEncryptionAlgorithm; typedef Lib3MF::eWrappingAlgorithm eLib3MFWrappingAlgorithm; typedef Lib3MF::eMgfAlgorithm eLib3MFMgfAlgorithm; @@ -491,6 +753,8 @@ typedef Lib3MF::sBox sLib3MFBox; typedef Lib3MF::sColor sLib3MFColor; typedef Lib3MF::sBeam sLib3MFBeam; typedef Lib3MF::sBall sLib3MFBall; +typedef Lib3MF::sVector sLib3MFVector; +typedef Lib3MF::sMatrix4x4 sLib3MFMatrix4x4; typedef Lib3MF::ProgressCallback Lib3MFProgressCallback; typedef Lib3MF::WriteCallback Lib3MFWriteCallback; typedef Lib3MF::ReadCallback Lib3MFReadCallback; diff --git a/Lib3MF.vcxproj b/Lib3MF.vcxproj index ca7e968..e30fe77 100644 --- a/Lib3MF.vcxproj +++ b/Lib3MF.vcxproj @@ -72,13 +72,13 @@ true - $(Configuration)32\lib3mf.dir + $(Configuration)32\lib3mf.dir\ lib3mfD32 $(SolutionDir)$(Configuration)32\ false - $(Configuration)32\lib3mf.dir + $(Configuration)32\lib3mf.dir\ lib3mfR32 $(SolutionDir)$(Configuration)32\ @@ -90,7 +90,7 @@ false - $(Configuration)64\lib3mf.dir + $(Configuration)64\lib3mf.dir\ lib3mfR64 $(SolutionDir)\$(Configuration)64\ @@ -98,15 +98,16 @@ Level3 true - __LIB3MF_EXPORTS ; NOMINMAX ; WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + GUID_WINDOWS;__LIB3MF_EXPORTS ; NOMINMAX ; WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) false - /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries/zlib;/EgtDev/Lib3MF/Include/Libraries/libzip + /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries;/EgtDev/Lib3MF/Include/Libraries/cpp-base64;/EgtDev/Extern/libzip/Include;/EgtDev/Extern/zlib/Include 4996 stdcpp20 Console true + \EgtDev\Extern\libzip\Lib\zipD32.lib;\EgtDev\Extern\zlib\Lib\zlibD32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) _DEB32; _USING_V110_SDK71_;%(PreprocessorDefinitions) @@ -123,9 +124,9 @@ copy $(TargetPath) \EgtProg\DllD32 true true true - __LIB3MF_EXPORTS; NOMINMAX ; WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + GUID_WINDOWS;__LIB3MF_EXPORTS ; NOMINMAX ;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) false - /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries/zlib;/EgtDev/Lib3MF/Include/Libraries/libzip + /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries;/EgtDev/Lib3MF/Include/Libraries/cpp-base64;/EgtDev/Extern/libzip/Include;/EgtDev/Extern/zlib/Include 4996 stdcpp20 @@ -134,6 +135,7 @@ copy $(TargetPath) \EgtProg\DllD32 true true true + \EgtDev\Extern\libzip\Lib\zipR32.lib;\EgtDev\Extern\zlib\Lib\zlibR32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) NDEB32; _USING_V110_SDK71_;%(PreprocessorDefinitions) @@ -147,15 +149,16 @@ copy $(TargetPath) \EgtProg\Dll32 Level3 true - __LIB3MF_EXPORTS; NOMINMAX; _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + GUID_WINDOWS;__LIB3MF_EXPORTS ; NOMINMAX ;DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries/zlib;/EgtDev/Lib3MF/Include/Libraries/libzip + /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries;/EgtDev/Lib3MF/Include/Libraries/cpp-base64;/EgtDev/Extern/libzip/Include;/EgtDev/Extern/zlib/Include 4996 stdcpp20 Console true + \EgtDev\Extern\libzip\Lib\zipD64.lib;\EgtDev\Extern\zlib\Lib\zlibD64.lib;%(AdditionalDependencies) _DEB64; _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -172,9 +175,9 @@ copy $(TargetPath) \EgtProg\DllD64 true true true - __LIB3MF_EXPORTS; NOMINMAX; NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + GUID_WINDOWS;__LIB3MF_EXPORTS ; NOMINMAX ;DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries/zlib;/EgtDev/Lib3MF/Include/Libraries/libzip + /EgtDev/Lib3MF/Include;/EgtDev/Lib3MF/Include/API;/EgtDev/Lib3MF/Include/Libraries;/EgtDev/Lib3MF/Include/Libraries/cpp-base64;/EgtDev/Extern/libzip/Include;/EgtDev/Extern/zlib/Include 4996 false stdcpp20 @@ -184,6 +187,7 @@ copy $(TargetPath) \EgtProg\DllD64 true true true + \EgtDev\Extern\libzip\Lib\zipR64.lib;\EgtDev\Extern\zlib\Lib\zlibR64.lib;%(AdditionalDependencies) NDEB64; _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -195,50 +199,129 @@ copy $(TargetPath) \EgtProg\Dll64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -256,8 +339,13 @@ copy $(TargetPath) \EgtProg\Dll64 + + + + + @@ -297,130 +385,7 @@ copy $(TargetPath) \EgtProg\Dll64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -438,6 +403,14 @@ copy $(TargetPath) \EgtProg\Dll64 + + + + + + + + @@ -449,6 +422,8 @@ copy $(TargetPath) \EgtProg\Dll64 + + @@ -526,13 +501,37 @@ copy $(TargetPath) \EgtProg\Dll64 + + + + + + + + + + + + + + + + + + + + + + + + @@ -542,6 +541,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/Lib3MF.vcxproj.filters b/Lib3MF.vcxproj.filters index 0a33a44..e7c06ee 100644 --- a/Lib3MF.vcxproj.filters +++ b/Lib3MF.vcxproj.filters @@ -42,12 +42,6 @@ {48d75704-39fe-42a1-81b2-db8ba606d7c0} - - {38b42d24-4f78-4dde-85b4-a0637bcb6bdf} - - - {eb89f557-b73c-4c17-9d3f-f5311f2398bf} - {86587afe-c90c-46e0-b7f6-5e4f1c030c49} @@ -78,8 +72,14 @@ {526e5879-5ef4-49af-8742-ab92144ee416} - - {c27152a2-72e5-4d8d-82d8-8fc37222bf29} + + {1720f33e-1dd7-43df-bfd5-df1bd7e8c04c} + + + {0684b770-a626-4137-b5d8-6911b366d254} + + + {1d99475a-1155-4e88-a993-b4401e7d1623} @@ -380,348 +380,6 @@ File di origine\Common\OPC - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip - - - File di origine\Libraries\libzip\Win - - - File di origine\Libraries\libzip\Win - - - File di origine\Libraries\libzip\Win - - - File di origine\Libraries\libzip\Win - - - File di origine\Libraries - File di origine\Model\Writer @@ -1085,39 +743,6 @@ File di origine\Model\Reader\SecureContent101 - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - - - File di origine\Libraries\zlib - File di origine @@ -1127,6 +752,369 @@ File di origine + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\API + + + File di origine\Common + + + File di origine\Common\Graph + + + File di origine\Common\Graph + + + File di origine\Common\Mesh + + + File di origine\Common\Mesh + + + File di origine\Common\Mesh + + + File di origine\Common\Mesh + + + File di origine\Libraries\cpp-base64 + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Classes + + + File di origine\Model\Reader\v100 + + + File di origine\Model\Reader\v100 + + + File di origine\Model\Reader\v100 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Reader\Volumetric2201 + + + File di origine\Model\Writer\v100 + + + File di origine\Model\Writer + + + File di origine\Model\Writer + + + File di origine\Model\Writer + diff --git a/Resource.rc b/Resource.rc index e308ac0..06a60d3 100644 --- a/Resource.rc +++ b/Resource.rc @@ -56,8 +56,8 @@ VS_VERSION_INFO$(_DEB32) VERSIONINFO #else VS_VERSION_INFO VERSIONINFO #endif - FILEVERSION 2,2,0,0 - PRODUCTVERSION 2,2,0,0 + FILEVERSION 2,5,0,0 + PRODUCTVERSION 2,5,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -73,10 +73,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "lib3mf Debug Version" - VALUE "FileVersion", "2.2.0.0" + VALUE "FileVersion", "2.5.0.0" VALUE "InternalName", "lib3mfD32.dll" VALUE "OriginalFilename", "lib3mfD32.dll" - VALUE "ProductVersion", "2.2.0.0" + VALUE "ProductVersion", "2.5.0.0" END END BLOCK "VarFileInfo" @@ -92,8 +92,8 @@ VS_VERSION_INFO$(NDEB32) VERSIONINFO #else VS_VERSION_INFO VERSIONINFO #endif - FILEVERSION 2,2,0,0 - PRODUCTVERSION 2,2,0,0 + FILEVERSION 2,5,0,0 + PRODUCTVERSION 2,5,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -109,10 +109,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "lib3mf Release Version" - VALUE "FileVersion", "2.2.0.0" + VALUE "FileVersion", "2.5.0.0" VALUE "InternalName", "lib3mfR32.dll" VALUE "OriginalFilename", "lib3mfR32.dll" - VALUE "ProductVersion", "2.2.0.0" + VALUE "ProductVersion", "2.5.0.0" END END BLOCK "VarFileInfo" @@ -128,8 +128,8 @@ VS_VERSION_INFO$(_DEB64) VERSIONINFO #else VS_VERSION_INFO VERSIONINFO #endif - FILEVERSION 2,2,0,0 - PRODUCTVERSION 2,2,0,0 + FILEVERSION 2,5,0,0 + PRODUCTVERSION 2,5,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -145,10 +145,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "lib3mf Debug Version" - VALUE "FileVersion", "2.2.0.0" + VALUE "FileVersion", "2.5.0.0" VALUE "InternalName", "lib3mfD64.dll" VALUE "OriginalFilename", "lib3mfD64.dll" - VALUE "ProductVersion", "2.2.0.0" + VALUE "ProductVersion", "2.5.0.0" END END BLOCK "VarFileInfo" @@ -164,8 +164,8 @@ VS_VERSION_INFO$(NDEB64) VERSIONINFO #else VS_VERSION_INFO VERSIONINFO #endif - FILEVERSION 2,2,0,0 - PRODUCTVERSION 2,2,0,0 + FILEVERSION 2,5,0,0 + PRODUCTVERSION 2,5,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -181,10 +181,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "lib3mf Release Version" - VALUE "FileVersion", "2.2.0.0" + VALUE "FileVersion", "2.5.0.0" VALUE "InternalName", "lib3mfR64.dll" VALUE "OriginalFilename", "lib3mfR64.dll" - VALUE "ProductVersion", "2.2.0.0" + VALUE "ProductVersion", "2.5.0.0" END END BLOCK "VarFileInfo" diff --git a/Source/API/lib3mf.cpp b/Source/API/lib3mf.cpp index 101a1c0..1e0ab85 100644 --- a/Source/API/lib3mf.cpp +++ b/Source/API/lib3mf.cpp @@ -29,7 +29,7 @@ This file has been generated by the Automatic Component Toolkit (ACT) version 1. Abstract: This is an autogenerated C++ implementation file in order to allow easy development of the 3MF Library. It needs to be generated only once. -Interface version: 2.2.0 +Interface version: 2.3.2 */ @@ -102,6 +102,24 @@ void CWrapper::GetSpecificationVersion (const std::string & sSpecificationURL, b nMicro = NMR_SPECVERSION_SECURECONTENT_MICRO; bIsSupported = true; } + else if (!sSpecificationURL.compare(std::string(XML_3MF_NAMESPACE_TRIANGLESETS))) { + nMajor = NMR_SPECVERSION_TRIANGLESETS_MAJOR; + nMinor = NMR_SPECVERSION_TRIANGLESETS_MINOR; + nMicro = NMR_SPECVERSION_TRIANGLESETS_MICRO; + bIsSupported = true; + } + else if (!sSpecificationURL.compare(std::string(XML_3MF_NAMESPACE_VOLUMETRICSPEC))) { + nMajor = NMR_SPECVERSION_VOLUMETRIC_MAJOR; + nMinor = NMR_SPECVERSION_VOLUMETRIC_MINOR; + nMicro = NMR_SPECVERSION_VOLUMETRIC_MICRO; + bIsSupported = true; + } + else if (!sSpecificationURL.compare(std::string(XML_3MF_NAMESPACE_IMPLICITSPEC))) { + nMajor = NMR_SPECVERSION_IMPLICIT_MAJOR; + nMinor = NMR_SPECVERSION_IMPLICIT_MINOR; + nMicro = NMR_SPECVERSION_IMPLICIT_MICRO; + bIsSupported = true; + } else { bIsSupported = false; } diff --git a/Source/API/lib3mf_absnode.cpp b/Source/API/lib3mf_absnode.cpp new file mode 100644 index 0000000..8b842d6 --- /dev/null +++ b/Source/API/lib3mf_absnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CAbsNode + +*/ + +#include "lib3mf_absnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CAbsNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CAbsNode::CAbsNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode(pImplicitNode) +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_additionnode.cpp b/Source/API/lib3mf_additionnode.cpp new file mode 100644 index 0000000..a4fd9f0 --- /dev/null +++ b/Source/API/lib3mf_additionnode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CAdditionNode + +*/ + +#include "lib3mf_additionnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CAdditionNode +**************************************************************************************************************************/ + +CAdditionNode::CAdditionNode( + NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_arccosnode.cpp b/Source/API/lib3mf_arccosnode.cpp new file mode 100644 index 0000000..289cca3 --- /dev/null +++ b/Source/API/lib3mf_arccosnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CArcCosNode + +*/ + +#include "lib3mf_arccosnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CArcCosNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CArcCosNode::CArcCosNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_arcsinnode.cpp b/Source/API/lib3mf_arcsinnode.cpp new file mode 100644 index 0000000..4f41516 --- /dev/null +++ b/Source/API/lib3mf_arcsinnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CArcSinNode + +*/ + +#include "lib3mf_arcsinnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CArcSinNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CArcSinNode::CArcSinNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_arctan2node.cpp b/Source/API/lib3mf_arctan2node.cpp new file mode 100644 index 0000000..3401ab6 --- /dev/null +++ b/Source/API/lib3mf_arctan2node.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CArcTan2Node + +*/ + +#include "lib3mf_arctan2node.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_twoinputnode.hpp" + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CArcTan2Node +**************************************************************************************************************************/ + +Lib3MF::Impl::CArcTan2Node::CArcTan2Node(NMR::PModelImplicitNode pImplicitNode) +: CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_arctannode.cpp b/Source/API/lib3mf_arctannode.cpp new file mode 100644 index 0000000..2439cdd --- /dev/null +++ b/Source/API/lib3mf_arctannode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CArcTanNode + +*/ + +#include "lib3mf_arctannode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CArcTanNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CArcTanNode::CArcTanNode(NMR::PModelImplicitNode pImplicitNode) +: COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_attachment.cpp b/Source/API/lib3mf_attachment.cpp index 9e8dfcf..63c0686 100644 --- a/Source/API/lib3mf_attachment.cpp +++ b/Source/API/lib3mf_attachment.cpp @@ -161,3 +161,8 @@ void CAttachment::ReadFromBuffer(const Lib3MF_uint64 nBufferBufferSize, const Li m_pModelAttachment->setStream(pImportStream); } + +NMR::PModelAttachment CAttachment::getModelAttachment() +{ + return m_pModelAttachment; +} diff --git a/Source/API/lib3mf_base.cpp b/Source/API/lib3mf_base.cpp index 245813f..44203c3 100644 --- a/Source/API/lib3mf_base.cpp +++ b/Source/API/lib3mf_base.cpp @@ -79,3 +79,4 @@ bool CBase::DecRefCount() } return false; } + diff --git a/Source/API/lib3mf_basematerialgroupiterator.cpp b/Source/API/lib3mf_basematerialgroupiterator.cpp index f6f8cba..281dd80 100644 --- a/Source/API/lib3mf_basematerialgroupiterator.cpp +++ b/Source/API/lib3mf_basematerialgroupiterator.cpp @@ -46,3 +46,7 @@ IBaseMaterialGroup * CBaseMaterialGroupIterator::GetCurrentBaseMaterialGroup() return new CBaseMaterialGroup(std::dynamic_pointer_cast(GetCurrentResource())); } +IResource * CBaseMaterialGroupIterator::GetCurrent() +{ + return GetCurrentBaseMaterialGroup(); +} diff --git a/Source/API/lib3mf_beamlattice.cpp b/Source/API/lib3mf_beamlattice.cpp index 53942b7..e2c9a8e 100644 --- a/Source/API/lib3mf_beamlattice.cpp +++ b/Source/API/lib3mf_beamlattice.cpp @@ -139,7 +139,7 @@ void CBeamLattice::GetBallOptions (eLib3MFBeamLatticeBallMode & eBallMode, Lib3M void CBeamLattice::SetBallOptions (const eLib3MFBeamLatticeBallMode eBallMode, const Lib3MF_double dBallRadius) { - if (eBallMode == eLib3MFBeamLatticeBallMode::None || dBallRadius > 0.0) { + if (eBallMode == eLib3MFBeamLatticeBallMode::BeamLatticeBallModeNone || dBallRadius > 0.0) { m_mesh.setBeamLatticeBallMode((NMR::eModelBeamLatticeBallMode)eBallMode); m_mesh.setDefaultBallRadius(dBallRadius); } @@ -307,7 +307,7 @@ sLib3MFBall CBeamLattice::GetBall (const Lib3MF_uint32 nIndex) return ball; } else if (ballMode == eBeamLatticeBallMode::All) { - Lib3MF_uint32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index; + Lib3MF_int32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index; Lib3MF_uint32 meshBallCount = m_mesh.getBallCount(); for (Lib3MF_uint32 iBall = 0; iBall < meshBallCount; iBall++) { @@ -377,7 +377,7 @@ void CBeamLattice::SetBall (const Lib3MF_uint32 nIndex, const sLib3MFBall BallIn meshBall->m_radius = BallInfo.m_Radius; } else if (ballMode == eBeamLatticeBallMode::All) { - Lib3MF_uint32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index; + Lib3MF_int32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index; Lib3MF_uint32 meshBallCount = m_mesh.getBallCount(); for (Lib3MF_uint32 iBall = 0; iBall < meshBallCount; iBall++) { NMR::MESHBALL * meshBall = m_mesh.getBall(iBall); diff --git a/Source/API/lib3mf_beamlatticenode.cpp b/Source/API/lib3mf_beamlatticenode.cpp new file mode 100644 index 0000000..70bc415 --- /dev/null +++ b/Source/API/lib3mf_beamlatticenode.cpp @@ -0,0 +1,74 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CBeamLatticeNode + +*/ + +#include "lib3mf_beamlatticenode.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_implicitport.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CBeamLatticeNode +**************************************************************************************************************************/ + +CBeamLatticeNode::CBeamLatticeNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + m_pImplicitNode = pImplicitNode; +} + +IImplicitPort * CBeamLatticeNode::GetInputBeamLattice() +{ + return FindInputOrThrow("beamlattice"); +} + +IImplicitPort * CBeamLatticeNode::GetInputPos() +{ + return FindInputOrThrow("pos"); +} + +IImplicitPort * CBeamLatticeNode::GetOutputDistance() +{ + return FindOutputOrThrow("distance"); +} + +void CBeamLatticeNode::SetAccurateRange(const Lib3MF_double dAccurateRange) +{ + m_pImplicitNode->setAccurateRange(dAccurateRange); +} + +Lib3MF_double CBeamLatticeNode::GetAccurateRange() +{ + return m_pImplicitNode->getAccurateRange(); +} + diff --git a/Source/API/lib3mf_ceilnode.cpp b/Source/API/lib3mf_ceilnode.cpp new file mode 100644 index 0000000..263aa0e --- /dev/null +++ b/Source/API/lib3mf_ceilnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CCeilNode + +*/ + +#include "lib3mf_ceilnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CCeilNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CCeilNode::CCeilNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_clampnode.cpp b/Source/API/lib3mf_clampnode.cpp new file mode 100644 index 0000000..b0fdfb2 --- /dev/null +++ b/Source/API/lib3mf_clampnode.cpp @@ -0,0 +1,57 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CClampNode + +*/ + +#include "lib3mf_clampnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CClampNode +**************************************************************************************************************************/ + +IImplicitPort* CClampNode::GetInputMin() +{ + return FindInputOrThrow(NMR::InputNames::min); +} + +IImplicitPort* CClampNode::GetInputMax() +{ + return FindInputOrThrow(NMR::InputNames::max); +} + +Lib3MF::Impl::CClampNode::CClampNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_colorgroupiterator.cpp b/Source/API/lib3mf_colorgroupiterator.cpp index d35b93d..d7dea69 100644 --- a/Source/API/lib3mf_colorgroupiterator.cpp +++ b/Source/API/lib3mf_colorgroupiterator.cpp @@ -46,3 +46,7 @@ IColorGroup * CColorGroupIterator::GetCurrentColorGroup () return new CColorGroup(std::dynamic_pointer_cast(GetCurrentResource())); } +IResource * CColorGroupIterator::GetCurrent() +{ + return GetCurrentColorGroup(); +} diff --git a/Source/API/lib3mf_componentsobject.cpp b/Source/API/lib3mf_componentsobject.cpp index 6c0658b..2c6530e 100644 --- a/Source/API/lib3mf_componentsobject.cpp +++ b/Source/API/lib3mf_componentsobject.cpp @@ -126,3 +126,8 @@ bool CComponentsObject::IsComponentsObject() return true; } +bool CComponentsObject::IsLevelSetObject() +{ + return false; +} + diff --git a/Source/API/lib3mf_composematrixnode.cpp b/Source/API/lib3mf_composematrixnode.cpp new file mode 100644 index 0000000..517b7b7 --- /dev/null +++ b/Source/API/lib3mf_composematrixnode.cpp @@ -0,0 +1,133 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CComposeMatrixNode + +*/ + +#include "lib3mf_composematrixnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CComposeMatrixNode +**************************************************************************************************************************/ + +IImplicitPort * CComposeMatrixNode::GetInputM00() +{ + return FindInputOrThrow(NMR::InputNames::m00); +} + +IImplicitPort * CComposeMatrixNode::GetInputM01() +{ + return FindInputOrThrow(NMR::InputNames::m01); +} + +IImplicitPort * CComposeMatrixNode::GetInputM02() +{ + return FindInputOrThrow(NMR::InputNames::m02); +} + +IImplicitPort * CComposeMatrixNode::GetInputM03() +{ + return FindInputOrThrow(NMR::InputNames::m03); +} + +IImplicitPort * CComposeMatrixNode::GetInputM10() +{ + return FindInputOrThrow(NMR::InputNames::m10); +} + +IImplicitPort * CComposeMatrixNode::GetInputM11() +{ + return FindInputOrThrow(NMR::InputNames::m11); +} + +IImplicitPort * CComposeMatrixNode::GetInputM12() +{ + return FindInputOrThrow(NMR::InputNames::m12); +} + +IImplicitPort * CComposeMatrixNode::GetInputM13() +{ + return FindInputOrThrow(NMR::InputNames::m13); +} + +IImplicitPort * CComposeMatrixNode::GetInputM20() +{ + return FindInputOrThrow(NMR::InputNames::m20); +} + +IImplicitPort * CComposeMatrixNode::GetInputM21() +{ + return FindInputOrThrow(NMR::InputNames::m21); +} + +IImplicitPort * CComposeMatrixNode::GetInputM22() +{ + return FindInputOrThrow(NMR::InputNames::m22); +} + +IImplicitPort * CComposeMatrixNode::GetInputM23() +{ + return FindInputOrThrow(NMR::InputNames::m23); +} + +IImplicitPort * CComposeMatrixNode::GetInputM30() +{ + return FindInputOrThrow(NMR::InputNames::m30); +} + +IImplicitPort * CComposeMatrixNode::GetInputM31() +{ + return FindInputOrThrow(NMR::InputNames::m31); +} + +IImplicitPort * CComposeMatrixNode::GetInputM32() +{ + return FindInputOrThrow(NMR::InputNames::m32); +} + +IImplicitPort * CComposeMatrixNode::GetInputM33() +{ + return FindInputOrThrow(NMR::InputNames::m33); +} + +IImplicitPort * CComposeMatrixNode::GetOutputResult() +{ + return FindOutputOrThrow(NMR::OutputNames::result); +} + +Lib3MF::Impl::CComposeMatrixNode::CComposeMatrixNode( + NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_composevectornode.cpp b/Source/API/lib3mf_composevectornode.cpp new file mode 100644 index 0000000..bbef8ad --- /dev/null +++ b/Source/API/lib3mf_composevectornode.cpp @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CComposeVectorNode + +*/ + +#include "lib3mf_composevectornode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CComposeVectorNode +**************************************************************************************************************************/ + +IImplicitPort * CComposeVectorNode::GetInputX() +{ + return FindInputOrThrow(NMR::InputNames::x); +} + +IImplicitPort * CComposeVectorNode::GetInputY() +{ + return FindInputOrThrow(NMR::InputNames::y); +} + +IImplicitPort * CComposeVectorNode::GetInputZ() +{ + return FindInputOrThrow(NMR::InputNames::z); +} + +IImplicitPort * CComposeVectorNode::GetOutputResult() +{ + return FindOutputOrThrow(NMR::OutputNames::result); +} + +Lib3MF::Impl::CComposeVectorNode::CComposeVectorNode( + NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_compositematerialsiterator.cpp b/Source/API/lib3mf_compositematerialsiterator.cpp index a3cebbd..4e67e24 100644 --- a/Source/API/lib3mf_compositematerialsiterator.cpp +++ b/Source/API/lib3mf_compositematerialsiterator.cpp @@ -46,3 +46,8 @@ ICompositeMaterials * CCompositeMaterialsIterator::GetCurrentCompositeMaterials return new CCompositeMaterials(std::dynamic_pointer_cast(GetCurrentResource())); } +IResource * CCompositeMaterialsIterator::GetCurrent() +{ + return GetCurrentCompositeMaterials(); +} + diff --git a/Source/API/lib3mf_constantnode.cpp b/Source/API/lib3mf_constantnode.cpp new file mode 100644 index 0000000..caa3a40 --- /dev/null +++ b/Source/API/lib3mf_constantnode.cpp @@ -0,0 +1,64 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CConstantNode + +*/ + +#include "lib3mf_constantnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CConstantNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CConstantNode::CConstantNode( + NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + +void CConstantNode::SetConstant(const Lib3MF_double dValue) +{ + m_pImplicitNode->setConstant(dValue); +} + +Lib3MF_double CConstantNode::GetConstant() +{ + return m_pImplicitNode->getConstant(); +} + +IImplicitPort * CConstantNode::GetOutputValue() +{ + return FindOutputOrThrow(NMR::OutputNames::value); +} + diff --git a/Source/API/lib3mf_constmatnode.cpp b/Source/API/lib3mf_constmatnode.cpp new file mode 100644 index 0000000..04e9dda --- /dev/null +++ b/Source/API/lib3mf_constmatnode.cpp @@ -0,0 +1,64 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CConstMatNode + +*/ + +#include "lib3mf_constmatnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CConstMatNode +**************************************************************************************************************************/ + +CConstMatNode::CConstMatNode( + NMR::PModelImplicitNode pImplicitNode) +: CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + +void CConstMatNode::SetMatrix(const Lib3MF::sMatrix4x4 Value) +{ + m_pImplicitNode->setMatrix(Value); +} + +Lib3MF::sMatrix4x4 CConstMatNode::GetMatrix() +{ + return m_pImplicitNode->getMatrix(); +} + +IImplicitPort * CConstMatNode::GetOutputMatrix() +{ + return FindOutputOrThrow(NMR::OutputNames::matrix); +} + diff --git a/Source/API/lib3mf_constvecnode.cpp b/Source/API/lib3mf_constvecnode.cpp new file mode 100644 index 0000000..24d004f --- /dev/null +++ b/Source/API/lib3mf_constvecnode.cpp @@ -0,0 +1,64 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CConstVecNode + +*/ + +#include "lib3mf_constvecnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CConstVecNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CConstVecNode::CConstVecNode( + NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + +void CConstVecNode::SetVector(const Lib3MF::sVector Value) +{ + m_pImplicitNode->setVector(Value); +} + +Lib3MF::sVector CConstVecNode::GetVector() +{ + return m_pImplicitNode->getVector(); +} + +IImplicitPort * CConstVecNode::GetOutputVector() +{ + return FindOutputOrThrow(NMR::OutputNames::vector); +} + diff --git a/Source/API/lib3mf_coshnode.cpp b/Source/API/lib3mf_coshnode.cpp new file mode 100644 index 0000000..39f09a2 --- /dev/null +++ b/Source/API/lib3mf_coshnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CCoshNode + +*/ + +#include "lib3mf_coshnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CCoshNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CCoshNode::CCoshNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_cosnode.cpp b/Source/API/lib3mf_cosnode.cpp new file mode 100644 index 0000000..cf867b5 --- /dev/null +++ b/Source/API/lib3mf_cosnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CCosNode + +*/ + +#include "lib3mf_cosnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CCosNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CCosNode::CCosNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_crossnode.cpp b/Source/API/lib3mf_crossnode.cpp new file mode 100644 index 0000000..ec4a65e --- /dev/null +++ b/Source/API/lib3mf_crossnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CCrossNode + +*/ + +#include "lib3mf_crossnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CCrossNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CCrossNode::CCrossNode(NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} + { + CImplicitNode::m_pImplicitNode = pImplicitNode; + } diff --git a/Source/API/lib3mf_decomposevectornode.cpp b/Source/API/lib3mf_decomposevectornode.cpp new file mode 100644 index 0000000..e4e2d9c --- /dev/null +++ b/Source/API/lib3mf_decomposevectornode.cpp @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CDecomposeVectorNode + +*/ + +#include "lib3mf_decomposevectornode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CDecomposeVectorNode +**************************************************************************************************************************/ + +IImplicitPort * CDecomposeVectorNode::GetInputA() +{ + return FindInput("A"); +} + +IImplicitPort * CDecomposeVectorNode::GetOutputX() +{ + return FindOutput("x"); +} + +IImplicitPort * CDecomposeVectorNode::GetOutputY() +{ + return FindOutput("y"); +} + +IImplicitPort * CDecomposeVectorNode::GetOutputZ() +{ + return FindOutput("z"); +} + +Lib3MF::Impl::CDecomposeVectorNode::CDecomposeVectorNode( + NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_divisionnode.cpp b/Source/API/lib3mf_divisionnode.cpp new file mode 100644 index 0000000..6b517d3 --- /dev/null +++ b/Source/API/lib3mf_divisionnode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CDivisionNode + +*/ + +#include "lib3mf_divisionnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CDivisionNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CDivisionNode::CDivisionNode( + NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_dotnode.cpp b/Source/API/lib3mf_dotnode.cpp new file mode 100644 index 0000000..7ba816c --- /dev/null +++ b/Source/API/lib3mf_dotnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CDotNode + +*/ + +#include "lib3mf_dotnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CDotNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CDotNode::CDotNode(NMR::PModelImplicitNode pImplicitNode) +: CTwoInputNode{pImplicitNode} + { + CImplicitNode::m_pImplicitNode = pImplicitNode; + } diff --git a/Source/API/lib3mf_expnode.cpp b/Source/API/lib3mf_expnode.cpp new file mode 100644 index 0000000..fb266e4 --- /dev/null +++ b/Source/API/lib3mf_expnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CExpNode + +*/ + +#include "lib3mf_expnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CExpNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CExpNode::CExpNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_floornode.cpp b/Source/API/lib3mf_floornode.cpp new file mode 100644 index 0000000..8b97baa --- /dev/null +++ b/Source/API/lib3mf_floornode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFloorNode + +*/ + +#include "lib3mf_floornode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFloorNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CFloorNode::CFloorNode(NMR::PModelImplicitNode pImplicitNode) +: COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_fmodnode.cpp b/Source/API/lib3mf_fmodnode.cpp new file mode 100644 index 0000000..731ad48 --- /dev/null +++ b/Source/API/lib3mf_fmodnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFmodNode + +*/ + +#include "lib3mf_fmodnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFmodNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CFmodNode::CFmodNode(NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_fractnode.cpp b/Source/API/lib3mf_fractnode.cpp new file mode 100644 index 0000000..c3e0ff2 --- /dev/null +++ b/Source/API/lib3mf_fractnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFractNode + +*/ + +#include "lib3mf_fractnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFractNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CFractNode::CFractNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_function.cpp b/Source/API/lib3mf_function.cpp new file mode 100644 index 0000000..1825814 --- /dev/null +++ b/Source/API/lib3mf_function.cpp @@ -0,0 +1,126 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFunction + +*/ + +#include "lib3mf_function.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_implicitport.hpp" +#include "lib3mf_implicitportiterator.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFunction +**************************************************************************************************************************/ + +NMR::CModelFunction* Lib3MF::Impl::CFunction::function() +{ + NMR::CModelFunction* pFunction = dynamic_cast(resource().get()); + if (pFunction == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT); + + return pFunction; +} + +Lib3MF::Impl::CFunction::CFunction(NMR::PModelResource pResource) + : CResource(pResource) +{ +} + +std::string CFunction::GetDisplayName() +{ + return function()->getDisplayName(); +} + +void CFunction::SetDisplayName(const std::string& sDisplayName) +{ + function()->setDisplayName(sDisplayName); +} + +IImplicitPort* CFunction::AddInput(const std::string& sIdentifier, + const std::string& sDisplayName, + const Lib3MF::eImplicitPortType eType) +{ + + return new CImplicitPort(function()->addInput(sIdentifier, sDisplayName, eType)); +} + +IImplicitPortIterator* CFunction::GetInputs() +{ + return new CImplicitPortIterator(function()->getInputs()); +} + +void CFunction::RemoveInput(IImplicitPort* pInput) +{ + auto inputs = function()->getInputs(); + auto it = std::find_if(inputs->begin(), inputs->end(), [pInput](const NMR::PModelImplicitPort& port) { + return port->getIdentifier() == pInput->GetIdentifier(); + }); + if (it != inputs->end()) + inputs->erase(it); + else + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); +} + +IImplicitPort* CFunction::AddOutput(const std::string& sIdentifier, + const std::string& sDisplayName, + const Lib3MF::eImplicitPortType eType) +{ + return new CImplicitPort(function()->addOutput(sIdentifier, sDisplayName, eType)); +} + +IImplicitPortIterator* CFunction::GetOutputs() +{ + return new CImplicitPortIterator(function()->getOutputs()); +} + +void CFunction::RemoveOutput(IImplicitPort* pOutput) +{ + auto outputs = function()->getOutputs(); + auto it = std::find_if(outputs->begin(), outputs->end(), [pOutput](const NMR::PModelImplicitPort& port) { + return port->getIdentifier() == pOutput->GetIdentifier(); + }); + if (it != outputs->end()) + outputs->erase(it); + else + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); +} + +IImplicitPort* CFunction::FindInput(const std::string& sIdentifier) +{ + return new CImplicitPort(function()->findInput(sIdentifier)); +} + +IImplicitPort* CFunction::FindOutput(const std::string& sIdentifier) +{ + return new CImplicitPort(function()->findOutput(sIdentifier)); +} diff --git a/Source/API/lib3mf_functioncallnode.cpp b/Source/API/lib3mf_functioncallnode.cpp new file mode 100644 index 0000000..639010a --- /dev/null +++ b/Source/API/lib3mf_functioncallnode.cpp @@ -0,0 +1,53 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFunctionCallNode + +*/ + +#include "lib3mf_functioncallnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFunctionCallNode +**************************************************************************************************************************/ + +CFunctionCallNode::CFunctionCallNode( + NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + +IImplicitPort * CFunctionCallNode::GetInputFunctionID() +{ + return FindInputOrThrow(NMR::InputNames::functionID); +} diff --git a/Source/API/lib3mf_functionfromimage3d.cpp b/Source/API/lib3mf_functionfromimage3d.cpp new file mode 100644 index 0000000..21cb4ce --- /dev/null +++ b/Source/API/lib3mf_functionfromimage3d.cpp @@ -0,0 +1,128 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFunctionFromImage3D + +*/ + +#include "lib3mf_functionfromimage3d.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_image3d.hpp" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFunctionFromImage3D +**************************************************************************************************************************/ + +IImage3D * CFunctionFromImage3D::GetImage3D() +{ + auto id = functionfromimage3d()->getImage3DUniqueResourceID(); + auto image = model()->findImage3D(id); + + + if(!image) + throw ELib3MFInterfaceException(NMR_ERROR_INVALIDMODELRESOURCE); + + return new CImage3D(image); +} + +NMR::CModelFunctionFromImage3D * Lib3MF::Impl::CFunctionFromImage3D::functionfromimage3d() +{ + auto pFunctionFromImage3D = std::dynamic_pointer_cast(resource()); + + if(!pFunctionFromImage3D) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT, "Resource is not a FunctionFromImage3D Object"); + } + + return pFunctionFromImage3D.get(); +} + +Lib3MF::Impl::CFunctionFromImage3D::CFunctionFromImage3D(NMR::PModelResource pResource) + : CResource(pResource) + , CFunction(pResource) +{ +} + +void CFunctionFromImage3D::SetImage3D(IImage3D * pImage3D) +{ + if (pImage3D == nullptr) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + functionfromimage3d()->setImage3DUniqueResourceID(pImage3D->GetUniqueResourceID()); +} + +void CFunctionFromImage3D::SetFilter(const Lib3MF::eTextureFilter eFilter) +{ + functionfromimage3d()->setFilter((NMR::eModelTextureFilter) eFilter); +} + +Lib3MF::eTextureFilter CFunctionFromImage3D::GetFilter() +{ + return (Lib3MF::eTextureFilter) functionfromimage3d()->getFilter(); +} + +void CFunctionFromImage3D::SetTileStyles(const Lib3MF::eTextureTileStyle eTileStyleU, + const Lib3MF::eTextureTileStyle eTileStyleV, + const Lib3MF::eTextureTileStyle eTileStyleW) +{ + functionfromimage3d()->setTileStyleU((NMR::eModelTextureTileStyle) eTileStyleU); + functionfromimage3d()->setTileStyleV((NMR::eModelTextureTileStyle) eTileStyleV); + functionfromimage3d()->setTileStyleW((NMR::eModelTextureTileStyle) eTileStyleW); +} + +void CFunctionFromImage3D::GetTileStyles(Lib3MF::eTextureTileStyle & eTileStyleU, + Lib3MF::eTextureTileStyle & eTileStyleV, + Lib3MF::eTextureTileStyle & eTileStyleW) +{ + eTileStyleU = (Lib3MF::eTextureTileStyle) functionfromimage3d()->getTileStyleU(); + eTileStyleV = (Lib3MF::eTextureTileStyle) functionfromimage3d()->getTileStyleV(); + eTileStyleW = (Lib3MF::eTextureTileStyle) functionfromimage3d()->getTileStyleW(); +} + +Lib3MF_double CFunctionFromImage3D::GetOffset() +{ + return functionfromimage3d()->getOffset(); +} + +void CFunctionFromImage3D::SetOffset(const Lib3MF_double dOffset) +{ + functionfromimage3d()->setOffset(dOffset); +} + +Lib3MF_double CFunctionFromImage3D::GetScale() +{ + return functionfromimage3d()->getScale(); +} + +void CFunctionFromImage3D::SetScale(const Lib3MF_double dScale) +{ + functionfromimage3d()->setScale(dScale); +} diff --git a/Source/API/lib3mf_functiongradientnode.cpp b/Source/API/lib3mf_functiongradientnode.cpp new file mode 100644 index 0000000..c09b53b --- /dev/null +++ b/Source/API/lib3mf_functiongradientnode.cpp @@ -0,0 +1,99 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFunctionGradientNode + +*/ + +#include "lib3mf_functiongradientnode.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_implicitport.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFunctionGradientNode +**************************************************************************************************************************/ + +CFunctionGradientNode::CFunctionGradientNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + m_pImplicitNode = pImplicitNode; +} + +IImplicitPort * CFunctionGradientNode::GetInputFunctionID() +{ + return FindInputOrThrow("functionID"); +} + +IImplicitPort * CFunctionGradientNode::GetInputPos() +{ + return FindInputOrThrow("pos"); +} + +IImplicitPort * CFunctionGradientNode::GetInputStep() +{ + return FindInputOrThrow("step"); +} + +void CFunctionGradientNode::SetScalarOutputName(const std::string & sScalarOutputName) +{ + m_pImplicitNode->setScalarOutputName(sScalarOutputName); +} + +std::string CFunctionGradientNode::GetScalarOutputName() +{ + return m_pImplicitNode->getScalarOutputName(); +} + +void CFunctionGradientNode::SetVectorInputName(const std::string & sVectorInputName) +{ + m_pImplicitNode->setVectorInputName(sVectorInputName); +} + +std::string CFunctionGradientNode::GetVectorInputName() +{ + return m_pImplicitNode->getVectorInputName(); +} + +IImplicitPort * CFunctionGradientNode::GetOutputNormalizedGradient() +{ + return FindOutputOrThrow("normalizedgradient"); +} + +IImplicitPort * CFunctionGradientNode::GetOutputGradient() +{ + return FindOutputOrThrow("gradient"); +} + +IImplicitPort * CFunctionGradientNode::GetOutputMagnitude() +{ + return FindOutputOrThrow("magnitude"); +} + diff --git a/Source/API/lib3mf_functioniterator.cpp b/Source/API/lib3mf_functioniterator.cpp new file mode 100644 index 0000000..36408a7 --- /dev/null +++ b/Source/API/lib3mf_functioniterator.cpp @@ -0,0 +1,51 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFunctionIterator + +*/ + +#include "lib3mf_functioniterator.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_implicitfunction.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFunctionIterator +**************************************************************************************************************************/ + +IFunction * CFunctionIterator::GetCurrentFunction() +{ + auto currentFunction = dynamic_cast(GetCurrent()); + if (currentFunction == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + return currentFunction; +} + diff --git a/Source/API/lib3mf_functionreference.cpp b/Source/API/lib3mf_functionreference.cpp new file mode 100644 index 0000000..b9e0da6 --- /dev/null +++ b/Source/API/lib3mf_functionreference.cpp @@ -0,0 +1,106 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CFunctionReference + +*/ + +#include "lib3mf_functionreference.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_utils.hpp" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CFunctionReference +**************************************************************************************************************************/ + +Lib3MF_uint32 CFunctionReference::GetFunctionResourceID() +{ + return m_pFunctionReference->getFunctionResourceID(); +} + +void CFunctionReference::SetFunctionResourceID( + const Lib3MF_uint32 nUniqueResourceID) +{ + m_pFunctionReference->setFunctionResourceID(nUniqueResourceID); +} + +CFunctionReference::CFunctionReference( + NMR::PFunctionReference pFunctionReference) + : m_pFunctionReference(pFunctionReference) +{ +} + +void CFunctionReference::SetTransform( + const Lib3MF::sTransform Transform) +{ + m_pFunctionReference->setTransform(TransformToMatrix(Transform)); +} + + +Lib3MF::sTransform CFunctionReference::GetTransform() +{ + NMR::NMATRIX3 const matrix = m_pFunctionReference->getTransform(); + return MatrixToTransform(matrix); +} + +//std::string GetChannelName() +std::string CFunctionReference::GetChannelName() +{ + return m_pFunctionReference->getChannelName(); +} + +void CFunctionReference::SetChannelName( + const std::string & sChannelName) +{ + m_pFunctionReference->setChannelName(sChannelName); +} + +void CFunctionReference::SetMinFeatureSize( + const Lib3MF_double dMinFeatureSize) +{ + m_pFunctionReference->setMinFeatureSize(dMinFeatureSize); +} + +Lib3MF_double CFunctionReference::GetMinFeatureSize() +{ + return m_pFunctionReference->getMinFeatureSize(); +} + +void CFunctionReference::SetFallBackValue( + const Lib3MF_double dFallBackValue) +{ + m_pFunctionReference->setFallBackValue(dFallBackValue); +} + +Lib3MF_double CFunctionReference::GetFallBackValue() +{ + return m_pFunctionReference->getFallBackValue(); +} \ No newline at end of file diff --git a/Source/API/lib3mf_image3d.cpp b/Source/API/lib3mf_image3d.cpp new file mode 100644 index 0000000..01a02ce --- /dev/null +++ b/Source/API/lib3mf_image3d.cpp @@ -0,0 +1,70 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CImage3D + +*/ + +#include "lib3mf_image3d.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "Model/Classes/NMR_ModelImageStack.h" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CImage3D +**************************************************************************************************************************/ + +CImage3D::CImage3D(NMR::PModelResource pResource) + :CResource(pResource) +{} + +NMR::CModelImage3D* CImage3D::image3D() +{ + NMR::CModelImage3D* pImage3D = dynamic_cast (resource().get()); + if (pImage3D == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_RESOURCENOTFOUND); + + return pImage3D; +} + +std::string CImage3D::GetName() +{ + return image3D()->getName(); +} + +void CImage3D::SetName(const std::string & sName) +{ + image3D()->setName(sName); +} + +bool CImage3D::IsImageStack() +{ + return (dynamic_cast(image3D()) != nullptr); +} + diff --git a/Source/API/lib3mf_image3diterator.cpp b/Source/API/lib3mf_image3diterator.cpp new file mode 100644 index 0000000..fc8d7e1 --- /dev/null +++ b/Source/API/lib3mf_image3diterator.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CImage3DIterator + +*/ + +#include "lib3mf_image3diterator.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CImage3DIterator +**************************************************************************************************************************/ + +IImage3D * CImage3DIterator::GetCurrentImage3D() +{ + return dynamic_cast(GetCurrent()); +} + diff --git a/Source/API/lib3mf_imagestack.cpp b/Source/API/lib3mf_imagestack.cpp new file mode 100644 index 0000000..9eeaa24 --- /dev/null +++ b/Source/API/lib3mf_imagestack.cpp @@ -0,0 +1,117 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CImageStack + +*/ + +#include "lib3mf_imagestack.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_attachment.hpp" + +#include "Common/Platform/NMR_ImportStream_Shared_Memory.h" +#include "Common/Platform/NMR_ImportStream_Unique_Memory.h" +#include "Common/Platform/NMR_ImportStream_Native.h" + +#include "Common/NMR_StringUtils.h" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CImageStack +**************************************************************************************************************************/ + +CImageStack::CImageStack(NMR::PModelImageStack pModelImageStack) + :CResource(pModelImageStack), CImage3D(pModelImageStack), m_pModelImageStack(pModelImageStack) +{ +} + + +Lib3MF_uint32 CImageStack::GetRowCount() +{ + return m_pModelImageStack->getRowCount(); +} + +void CImageStack::SetRowCount(const Lib3MF_uint32 nRowCount) +{ + m_pModelImageStack->setRowCount(nRowCount); +} + +Lib3MF_uint32 CImageStack::GetColumnCount() +{ + return m_pModelImageStack->getColumnCount(); +} + +void CImageStack::SetColumnCount(const Lib3MF_uint32 nColumnCount) +{ + m_pModelImageStack->setColumnCount(nColumnCount); +} + +Lib3MF_uint32 CImageStack::GetSheetCount() +{ + return m_pModelImageStack->getSheetCount(); +} + +IAttachment * CImageStack::GetSheet(const Lib3MF_uint32 nIndex) +{ + auto pAttachment = m_pModelImageStack->getSheet(nIndex); + return new CAttachment(pAttachment); +} + +void CImageStack::SetSheet(const Lib3MF_uint32 nIndex, IAttachment* pSheet) +{ + if (pSheet == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + CAttachment* pAttachment = dynamic_cast (pSheet); + if (pAttachment == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + m_pModelImageStack->setSheet(nIndex, pAttachment->getModelAttachment()); +} + +IAttachment * CImageStack::CreateEmptySheet(const Lib3MF_uint32 nIndex, const std::string & sPath) +{ + NMR::PImportStream pStream = std::make_shared(); + auto pAttachment = m_pModelImageStack->createSheet(nIndex, sPath, pStream); + return new CAttachment(pAttachment); +} + +IAttachment * CImageStack::CreateSheetFromBuffer(const Lib3MF_uint32 nIndex, const std::string & sPath, const Lib3MF_uint64 nDataBufferSize, const Lib3MF_uint8 * pDataBuffer) +{ + NMR::PImportStream pStream = std::make_shared(pDataBuffer, nDataBufferSize); + auto pAttachment = m_pModelImageStack->createSheet(nIndex, sPath, pStream); + return new CAttachment(pAttachment); +} + +IAttachment * CImageStack::CreateSheetFromFile(const Lib3MF_uint32 nIndex, const std::string & sPath, const std::string & sFileName) +{ + std::wstring sUTF16FileName = NMR::fnUTF8toUTF16(sFileName); + NMR::PImportStream pFileStream = std::make_shared(sUTF16FileName.c_str()); + auto pAttachment = m_pModelImageStack->createSheet(nIndex, sPath, pFileStream->copyToMemory()); + return new CAttachment(pAttachment); +} + diff --git a/Source/API/lib3mf_implicitfunction.cpp b/Source/API/lib3mf_implicitfunction.cpp new file mode 100644 index 0000000..dd86dcf --- /dev/null +++ b/Source/API/lib3mf_implicitfunction.cpp @@ -0,0 +1,755 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CImplicitFunction + +*/ + +#include "lib3mf_implicitfunction.hpp" + +#include "lib3mf_absnode.hpp" +#include "lib3mf_additionnode.hpp" +#include "lib3mf_arccosnode.hpp" +#include "lib3mf_arcsinnode.hpp" +#include "lib3mf_arctan2node.hpp" +#include "lib3mf_ceilnode.hpp" +#include "lib3mf_clampnode.hpp" +#include "lib3mf_composematrixnode.hpp" +#include "lib3mf_composevectornode.hpp" +#include "lib3mf_constantnode.hpp" +#include "lib3mf_constmatnode.hpp" +#include "lib3mf_constvecnode.hpp" +#include "lib3mf_coshnode.hpp" +#include "lib3mf_cosnode.hpp" +#include "lib3mf_crossnode.hpp" +#include "lib3mf_decomposevectornode.hpp" +#include "lib3mf_divisionnode.hpp" +#include "lib3mf_dotnode.hpp" +#include "lib3mf_expnode.hpp" +#include "lib3mf_floornode.hpp" +#include "lib3mf_fmodnode.hpp" +#include "lib3mf_fractnode.hpp" +#include "lib3mf_functioncallnode.hpp" +#include "lib3mf_implicitnode.hpp" +#include "lib3mf_implicitport.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_inversenode.hpp" +#include "lib3mf_lengthnode.hpp" +#include "lib3mf_log10node.hpp" +#include "lib3mf_log2node.hpp" +#include "lib3mf_lognode.hpp" +#include "lib3mf_matrixfromcolumnsnode.hpp" +#include "lib3mf_matrixfromrowsnode.hpp" +#include "lib3mf_matvecmultiplicationnode.hpp" +#include "lib3mf_maxnode.hpp" +#include "lib3mf_meshnode.hpp" +#include "lib3mf_minnode.hpp" +#include "lib3mf_multiplicationnode.hpp" +#include "lib3mf_pownode.hpp" +#include "lib3mf_resourceidnode.hpp" +#include "lib3mf_roundnode.hpp" +#include "lib3mf_selectnode.hpp" +#include "lib3mf_signnode.hpp" +#include "lib3mf_sinhnode.hpp" +#include "lib3mf_sinnode.hpp" +#include "lib3mf_sqrtnode.hpp" +#include "lib3mf_subtractionnode.hpp" +#include "lib3mf_tanhnode.hpp" +#include "lib3mf_tannode.hpp" +#include "lib3mf_transposenode.hpp" +#include "lib3mf_unsignedmeshnode.hpp" +#include "lib3mf_beamlatticenode.hpp" +#include "lib3mf_functiongradientnode.hpp" +#include "lib3mf_normalizedistancenode.hpp" +#include "lib3mf_vectorfromscalarnode.hpp" + +// Include custom headers here. +#include "lib3mf_implicitportiterator.hpp" +#include "lib3mf_nodeiterator.hpp" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CImplicitFunction +**************************************************************************************************************************/ + +NMR::CModelImplicitFunction* CImplicitFunction::function() +{ + NMR::CModelImplicitFunction* pFunction = + dynamic_cast(resource().get()); + if(pFunction == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT); + + return pFunction; +} + +CImplicitFunction::CImplicitFunction(NMR::PModelResource pResource) + : CResource(pResource), CFunction(pResource) +{ +} + +std::string CImplicitFunction::GetIdentifier() +{ + return function()->getIdentifier(); +} + +void CImplicitFunction::SetIdentifier(const std::string& sIdentifier) +{ + function()->setIdentifier(sIdentifier); +} + +IImplicitNode* CImplicitFunction::AddNode( + const Lib3MF::eImplicitNodeType eNodeType, const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = function()->addNode(eNodeType, eConfiguration, sIdentifier, + sDisplayName, sTag); + return new CImplicitNode(newNode); +} + +ISinNode* CImplicitFunction::AddSinNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Sinus, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CSinNode(newNode); +} + +ICosNode* CImplicitFunction::AddCosNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Cosinus, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CCosNode(newNode); +} + +ITanNode* CImplicitFunction::AddTanNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Tan, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CTanNode(newNode); +} + +IArcSinNode* CImplicitFunction::AddArcSinNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ArcSin, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CArcSinNode(newNode); +} + +IArcCosNode* CImplicitFunction::AddArcCosNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ArcCos, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CArcCosNode(newNode); +} + +IArcTan2Node* CImplicitFunction::AddArcTan2Node( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ArcTan2, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CArcTan2Node(newNode); +} + +ISinhNode* CImplicitFunction::AddSinhNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Sinh, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CSinhNode(newNode); +} + +ICoshNode* CImplicitFunction::AddCoshNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Cosh, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CCoshNode(newNode); +} + +ITanhNode* CImplicitFunction::AddTanhNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Tanh, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CTanhNode(newNode); +} + +IRoundNode* CImplicitFunction::AddRoundNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Round, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CRoundNode(newNode); +} + +ICeilNode* CImplicitFunction::AddCeilNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Ceil, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CCeilNode(newNode); +} + +IFloorNode* CImplicitFunction::AddFloorNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Floor, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CFloorNode(newNode); +} + +ISignNode* CImplicitFunction::AddSignNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Sign, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CSignNode(newNode); +} + +IFractNode* CImplicitFunction::AddFractNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Fract, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CFractNode(newNode); +} + +IAbsNode* CImplicitFunction::AddAbsNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Abs, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CAbsNode(newNode); +} + +IExpNode* CImplicitFunction::AddExpNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Exp, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CExpNode(newNode); +} + +ILogNode* CImplicitFunction::AddLogNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Log, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CLogNode(newNode); +} + +ILog2Node* CImplicitFunction::AddLog2Node( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Log2, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CLog2Node(newNode); +} + +ILog10Node* CImplicitFunction::AddLog10Node( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Log10, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CLog10Node(newNode); +} + +ILengthNode* CImplicitFunction::AddLengthNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Length, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CLengthNode(newNode); +} + +ITransposeNode* CImplicitFunction::AddTransposeNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Transpose, + eConfiguration, sIdentifier, sDisplayName, sTag); + return new CTransposeNode(newNode); +} + +IInverseNode* CImplicitFunction::AddInverseNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Inverse, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CInverseNode(newNode); +} + +ISqrtNode* CImplicitFunction::AddSqrtNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Sqrt, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CSqrtNode(newNode); +} + +IResourceIdNode* CImplicitFunction::AddResourceIdNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ConstResourceID, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CResourceIdNode(newNode); +} + +IAdditionNode* CImplicitFunction::AddAdditionNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Addition, eConfiguration, + sIdentifier, sDisplayName, sTag); + + return new CAdditionNode(newNode); +} + +ISubtractionNode* CImplicitFunction::AddSubtractionNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Subtraction, + eConfiguration, sIdentifier, sDisplayName, sTag); + return new CSubtractionNode(newNode); +} + +IMultiplicationNode* CImplicitFunction::AddMultiplicationNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Multiplication, + eConfiguration, sIdentifier, sDisplayName, sTag); + return new CMultiplicationNode(newNode); +} + +IDivisionNode* CImplicitFunction::AddDivisionNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Division, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CDivisionNode(newNode); +} + +IDotNode* CImplicitFunction::AddDotNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Dot, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CDotNode(newNode); +} + +ICrossNode* CImplicitFunction::AddCrossNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Cross, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CCrossNode(newNode); +} + +IMatVecMultiplicationNode* CImplicitFunction::AddMatVecMultiplicationNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::MatVecMultiplication, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CMatVecMultiplicationNode(newNode); +} + +IMinNode* CImplicitFunction::AddMinNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Min, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CMinNode(newNode); +} + +IMaxNode* CImplicitFunction::AddMaxNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Max, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CMaxNode(newNode); +} + +IFmodNode* CImplicitFunction::AddFmodNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Fmod, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CFmodNode(newNode); +} + +IPowNode* CImplicitFunction::AddPowNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Pow, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CPowNode(newNode); +} + +ISelectNode* CImplicitFunction::AddSelectNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Select, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CSelectNode(newNode); +} + +IClampNode* CImplicitFunction::AddClampNode( + const std::string& sIdentifier, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string& sDisplayName, const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Clamp, eConfiguration, + sIdentifier, sDisplayName, sTag); + return new CClampNode(newNode); +} + +IComposeVectorNode* CImplicitFunction::AddComposeVectorNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ComposeVector, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CComposeVectorNode(newNode); +} + +IVectorFromScalarNode * CImplicitFunction::AddVectorFromScalarNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) +{ + auto newNode = function()->addNode(Lib3MF::eImplicitNodeType::VectorFromScalar, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, + sDisplayName, + sTag); + return new CVectorFromScalarNode(newNode); +} + +IDecomposeVectorNode* CImplicitFunction::AddDecomposeVectorNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::DecomposeVector, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CDecomposeVectorNode(newNode); +} + +IComposeMatrixNode* CImplicitFunction::AddComposeMatrixNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ComposeMatrix, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CComposeMatrixNode(newNode); +} + +IMatrixFromRowsNode * CImplicitFunction::AddMatrixFromRowsNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) +{ + auto newNode = function()->addNode(Lib3MF::eImplicitNodeType::MatrixFromRows, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, + sDisplayName, + sTag); + return new CMatrixFromRowsNode(newNode); +} + +IMatrixFromColumnsNode * CImplicitFunction::AddMatrixFromColumnsNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) +{ + auto newNode = function()->addNode(Lib3MF::eImplicitNodeType::MatrixFromColumns, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, + sDisplayName, + sTag); + return new CMatrixFromColumnsNode(newNode); +} + +IConstantNode* CImplicitFunction::AddConstantNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Constant, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CConstantNode(newNode); +} + +IConstVecNode* CImplicitFunction::AddConstVecNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ConstVec, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CConstVecNode(newNode); +} + +IConstMatNode* CImplicitFunction::AddConstMatNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::ConstMat, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CConstMatNode(newNode); +} + +IMeshNode* CImplicitFunction::AddMeshNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::Mesh, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CMeshNode(newNode); +} + +IUnsignedMeshNode * CImplicitFunction::AddUnsignedMeshNode(const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) +{ + auto newNode = function()->addNode(Lib3MF::eImplicitNodeType::UnsignedMesh, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, + sDisplayName, + sTag); + return new CUnsignedMeshNode(newNode); +} + +IBeamLatticeNode* CImplicitFunction::AddBeamLatticeNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::BeamLattice, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CBeamLatticeNode(newNode); +} + +IFunctionGradientNode* CImplicitFunction::AddFunctionGradientNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::FunctionGradient, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CFunctionGradientNode(newNode); +} + +INormalizeDistanceNode* CImplicitFunction::AddNormalizeDistanceNode(const std::string& sIdentifier, + const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::NormalizeDistance, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CNormalizeDistanceNode(newNode); +} + +IFunctionCallNode* CImplicitFunction::AddFunctionCallNode( + const std::string& sIdentifier, const std::string& sDisplayName, + const std::string& sTag) +{ + auto newNode = + function()->addNode(Lib3MF::eImplicitNodeType::FunctionCall, + Lib3MF::eImplicitNodeConfiguration::Default, + sIdentifier, sDisplayName, sTag); + return new CFunctionCallNode(newNode); +} + +INodeIterator* CImplicitFunction::GetNodes() +{ + return new CNodeIterator(function()->getNodes()); +} + +void CImplicitFunction::RemoveNode(IImplicitNode* pNode) +{ + if(pNode == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + function()->removeNode(pNode->GetIdentifier()); +} + +void CImplicitFunction::AddLink(IImplicitPort* pSource, IImplicitPort* pTarget) +{ + if (pSource == nullptr || pTarget == nullptr) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + CImplicitPort* pSourcePort = dynamic_cast(pSource); + CImplicitPort* pTargetPort = dynamic_cast(pTarget); + + if (pSourcePort == nullptr || pTargetPort == nullptr) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + + function()->addLink(pSourcePort->getPort(), pTargetPort->getPort()); +} + +void CImplicitFunction::AddLinkByNames(const std::string& sSource, + const std::string& sTarget) +{ + function()->addLink(sSource, sTarget); +} + +void CImplicitFunction::Clear() +{ + function()->clear(); +} + +void CImplicitFunction::SortNodesTopologically() +{ + function()->sortNodesTopologically(); +} + diff --git a/Source/API/lib3mf_implicitnode.cpp b/Source/API/lib3mf_implicitnode.cpp new file mode 100644 index 0000000..59daa65 --- /dev/null +++ b/Source/API/lib3mf_implicitnode.cpp @@ -0,0 +1,162 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CImplicitNode + +*/ + +#include "lib3mf_implicitnode.hpp" +#include "lib3mf_implicitport.hpp" +#include "lib3mf_implicitportiterator.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_meshobject.hpp" +#include + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CImplicitNode +**************************************************************************************************************************/ + +std::string CImplicitNode::GetIdentifier() +{ + if (!m_pImplicitNode) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + return m_pImplicitNode->getIdentifier(); +} + +void CImplicitNode::SetIdentifier(const std::string & sIdentifier) +{ + m_pImplicitNode->setIdentifier(sIdentifier); +} + +std::string CImplicitNode::GetDisplayName() +{ + return m_pImplicitNode->getDisplayName(); +} + +void CImplicitNode::SetDisplayName(const std::string& sDisplayName) +{ + m_pImplicitNode->setDisplayName(sDisplayName); +} + +std::string CImplicitNode::GetTag() +{ + return m_pImplicitNode->getTag(); +} + +void CImplicitNode::SetTag(const std::string& sTag) +{ + m_pImplicitNode->setTag(sTag); +} + +IImplicitPort* Lib3MF::Impl::CImplicitNode::FindInputOrThrow( + const std::string& sIdentifier) +{ + auto pPort = FindInput(sIdentifier); + if (!pPort) + { + std::string errorMsg = "Input port '" + sIdentifier + "' not found on node '" + + m_pImplicitNode->getIdentifier() + "'"; + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, errorMsg); + } + return pPort; +} + +IImplicitPort* Lib3MF::Impl::CImplicitNode::FindOutputOrThrow( + const std::string& sIdentifier) +{ + auto pPort = FindOutput(sIdentifier); + if (!pPort) + { + std::string errorMsg = "Output port '" + sIdentifier + "' not found on node '" + + m_pImplicitNode->getIdentifier() + "'"; + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, errorMsg); + } + return pPort; +} + +CImplicitNode::CImplicitNode(NMR::PModelImplicitNode pImplicitNode) + : m_pImplicitNode{pImplicitNode} +{ +} + +Lib3MF::eImplicitNodeType CImplicitNode::GetNodeType() +{ + return m_pImplicitNode->getNodeType(); +} + +IImplicitPort * CImplicitNode::AddInput(const std::string & sIdentifier, + const std::string & sDisplayName) +{ + return new CImplicitPort(m_pImplicitNode->addInput(sIdentifier, sDisplayName)); +} + +IImplicitPort * CImplicitNode::AddOutput(const std::string & sIdentifier, + const std::string & sDisplayName) +{ + return new CImplicitPort(m_pImplicitNode->addOutput(sIdentifier, sDisplayName)); +} + +IImplicitPortIterator * CImplicitNode::GetOutputs() +{ + return new CImplicitPortIterator(m_pImplicitNode->getOutputs()); +} + +IImplicitPortIterator * CImplicitNode::GetInputs() +{ + return new CImplicitPortIterator(m_pImplicitNode->getInputs()); +} + +IImplicitPort * CImplicitNode::FindInput(const std::string & sIdentifier) +{ + auto pPort = m_pImplicitNode->findInput(sIdentifier); + if (!pPort) + { + return nullptr; + } + return new CImplicitPort(pPort); +} + +IImplicitPort * CImplicitNode::FindOutput(const std::string & sIdentifier) +{ + auto pPort = m_pImplicitNode->findOutput(sIdentifier); + if (!pPort) + { + return nullptr; + } + return new CImplicitPort(pPort); +} + +bool Lib3MF::Impl::CImplicitNode::AreTypesValid() +{ + return m_pImplicitNode->arePortsValid(); +} + diff --git a/Source/API/lib3mf_implicitport.cpp b/Source/API/lib3mf_implicitport.cpp new file mode 100644 index 0000000..184aacf --- /dev/null +++ b/Source/API/lib3mf_implicitport.cpp @@ -0,0 +1,91 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CImplicitPort + +*/ + +#include "lib3mf_implicitport.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_types.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CImplicitPort +**************************************************************************************************************************/ + +Lib3MF::Impl::CImplicitPort::CImplicitPort(NMR::PModelImplicitPort pImplicitPort) + : m_pImplicitPort(pImplicitPort) +{ +} + +std::string CImplicitPort::GetIdentifier() +{ + return m_pImplicitPort->getIdentifier(); +} + +void CImplicitPort::SetIdentifier(const std::string & sIdentifier) +{ + m_pImplicitPort->setIdentifier(sIdentifier); +} + +std::string CImplicitPort::GetDisplayName() +{ + return m_pImplicitPort->getDisplayName(); +} + +void CImplicitPort::SetDisplayName(const std::string & sDisplayName) +{ + m_pImplicitPort->setDisplayName(sDisplayName); +} + +void CImplicitPort::SetType(const Lib3MF::eImplicitPortType eType) +{ + m_pImplicitPort->setType(eType); +} + +Lib3MF::eImplicitPortType CImplicitPort::GetType() +{ + return m_pImplicitPort->getType(); +} + +std::string CImplicitPort::GetReference() +{ + return m_pImplicitPort->getReference(); +} + +void CImplicitPort::SetReference(const std::string & sReference) +{ + m_pImplicitPort->setReference(sReference); +} + +NMR::PModelImplicitPort Lib3MF::Impl::CImplicitPort::getPort() +{ + return m_pImplicitPort; +} diff --git a/Source/API/lib3mf_implicitportiterator.cpp b/Source/API/lib3mf_implicitportiterator.cpp new file mode 100644 index 0000000..64f9e98 --- /dev/null +++ b/Source/API/lib3mf_implicitportiterator.cpp @@ -0,0 +1,57 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CImplicitPortIterator + +*/ + +#include "lib3mf_implicitportiterator.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_implicitport.hpp" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CImplicitPortIterator +**************************************************************************************************************************/ + +Lib3MF::Impl::CImplicitPortIterator::CImplicitPortIterator(NMR::PPorts pPorts) : m_pPorts(pPorts) +{ +} + +Lib3MF_uint64 Lib3MF::Impl::CImplicitPortIterator::Count() +{ + return static_cast(m_pPorts->size()); +} + +IImplicitPort * CImplicitPortIterator::GetCurrent() +{ + throwIfInvalidIndex(); + return new CImplicitPort(m_pPorts->at(static_cast(getCurrentIndex()))); +} + diff --git a/Source/API/lib3mf_inversenode.cpp b/Source/API/lib3mf_inversenode.cpp new file mode 100644 index 0000000..6275b7b --- /dev/null +++ b/Source/API/lib3mf_inversenode.cpp @@ -0,0 +1,46 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CInverseNode + +*/ + +#include "lib3mf_inversenode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CInverseNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CInverseNode::CInverseNode(NMR::PModelImplicitNode pImplicitNode) +: COneInputNode(std::move(pImplicitNode)) +{ +} diff --git a/Source/API/lib3mf_iterator.cpp b/Source/API/lib3mf_iterator.cpp new file mode 100644 index 0000000..8a4e7e7 --- /dev/null +++ b/Source/API/lib3mf_iterator.cpp @@ -0,0 +1,86 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CIterator + +*/ + +#include "lib3mf_iterator.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CIterator +**************************************************************************************************************************/ + +bool CIterator::MoveNext() +{ + auto const numItems = static_cast(Count()); + m_nCurrentIndex++; + + if (m_nCurrentIndex >= numItems) + { + m_nCurrentIndex = numItems; + return false; + } + else + { + return true; + } +} + +bool CIterator::MovePrevious() +{ + m_nCurrentIndex--; + if (m_nCurrentIndex <= -1) + { + m_nCurrentIndex = -1; + return false; + } + else + { + return true; + } +} + +Lib3MF_uint64 CIterator::Count() +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +Lib3MF_int64 Lib3MF::Impl::CIterator::getCurrentIndex() +{ + return m_nCurrentIndex; +} + +void Lib3MF::Impl::CIterator::throwIfInvalidIndex() +{ + if ((m_nCurrentIndex < 0) || (m_nCurrentIndex >= static_cast(Count()))) + throw ELib3MFInterfaceException(LIB3MF_ERROR_ITERATORINVALIDINDEX); +} diff --git a/Source/API/lib3mf_keystore.cpp b/Source/API/lib3mf_keystore.cpp index d4b7684..a2b28aa 100644 --- a/Source/API/lib3mf_keystore.cpp +++ b/Source/API/lib3mf_keystore.cpp @@ -91,7 +91,7 @@ IResourceDataGroup * Lib3MF::Impl::CKeyStore::AddResourceDataGroup() { //in any case, the spec does not state what happens if different resource datas have different algorithms, //but resourcedatagroups are supposed to group the same key for a group of resources... //so far, this should work as aes256 is the only thing we support. - std::vector key(NMR::fnGetAlgorithmKeySize(NMR::eKeyStoreEncryptAlgorithm::AES256_GCM), 0); + std::vector key((size_t) NMR::fnGetAlgorithmKeySize(NMR::eKeyStoreEncryptAlgorithm::AES256_GCM), 0); m_pModel->generateRandomBytes(key.data(), key.size()); NMR::PKeyStoreResourceDataGroup dg = NMR::CKeyStoreFactory::makeResourceDataGroup(std::make_shared(), key); m_pKeyStore->addResourceDataGroup(dg); diff --git a/Source/API/lib3mf_lengthnode.cpp b/Source/API/lib3mf_lengthnode.cpp new file mode 100644 index 0000000..94819e5 --- /dev/null +++ b/Source/API/lib3mf_lengthnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CLengthNode + +*/ + +#include "lib3mf_lengthnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CLengthNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CLengthNode::CLengthNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_levelset.cpp b/Source/API/lib3mf_levelset.cpp new file mode 100644 index 0000000..f73d39f --- /dev/null +++ b/Source/API/lib3mf_levelset.cpp @@ -0,0 +1,278 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CLevelSet + +*/ + +#include "lib3mf_levelset.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_meshobject.hpp" +#include "lib3mf_utils.hpp" +#include "lib3mf_function.hpp" +#include "lib3mf_volumedata.hpp" +#include "Model/Classes/NMR_ModelLevelSetObject.h" +#include "Model/Classes/NMR_ModelFunction.h" +#include "Model/Classes/NMR_ModelMeshObject.h" + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CLevelSet +**************************************************************************************************************************/ + + +ILevelSet* CLevelSet::fnCreateLevelSetFromModelResource(NMR::PModelResource pResource, bool bFailIfUnkownClass) { + + if (!pResource.get()) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + NMR::CModelLevelSetObject * LevelSetObject = dynamic_cast (pResource.get()); + if (LevelSetObject) { + return new CLevelSet(pResource); + } + + if (bFailIfUnkownClass) + throw ELib3MFInterfaceException(NMR_ERROR_UNKNOWNMODELRESOURCE); + + return nullptr; +} + + + +IFunction * CLevelSet::GetFunction() +{ + auto levelSet = levelSetObject(); + auto function = levelSet->getFunction(); + if (!function) + { + return nullptr; + } + return new CFunction(function); +} + +NMR::PModelLevelSetObject +Lib3MF::Impl::CLevelSet::levelSetObject() +{ + NMR::PModelLevelSetObject pLevelSet = std::dynamic_pointer_cast(resource()); + if (pLevelSet.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT, "Resource is not a LevelSet Object"); + return pLevelSet; +} + +CLevelSet::CLevelSet(NMR::PModelResource pResource) + : CResource(pResource), CObject(pResource) +{ +} + +void CLevelSet::SetFunction(IFunction* pTheFunction) +{ + if(pTheFunction == nullptr) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + + NMR::CModel* pModel = levelSetObject()->getModel(); + if(pModel == nullptr) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT, "LevelSet Object has no Model"); + } + + NMR::PModelFunction pFunction = + std::dynamic_pointer_cast( + pModel->findResource(pTheFunction->GetUniqueResourceID())); + + if(!pFunction) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + levelSetObject()->setFunction(pFunction); +} + +Lib3MF::sTransform CLevelSet::GetTransform() +{ + return MatrixToTransform(levelSetObject()->getTransform()); +} + +void CLevelSet::SetTransform(const Lib3MF::sTransform Transform) +{ + levelSetObject()->setTransform(TransformToMatrix(Transform)); +} + +std::string CLevelSet::GetChannelName() +{ + return levelSetObject()->getChannelName(); +} + +void CLevelSet::SetChannelName(const std::string & sChannelName) +{ + levelSetObject()->setChannelName(sChannelName); +} + +void CLevelSet::SetMinFeatureSize(const Lib3MF_double dMinFeatureSize) +{ + levelSetObject()->setMinFeatureSize(dMinFeatureSize); +} + +Lib3MF_double CLevelSet::GetMinFeatureSize() +{ + return levelSetObject()->getMinFeatureSize(); +} + +void CLevelSet::SetFallBackValue(const Lib3MF_double dFallBackValue) +{ + levelSetObject()->setFallBackValue(dFallBackValue); +} + +Lib3MF_double CLevelSet::GetFallBackValue() +{ + return levelSetObject()->getFallBackValue(); +} + +void CLevelSet::SetMeshBBoxOnly(const bool bMeshBBoxOnly) +{ + levelSetObject()->setMeshBBoxOnly(bMeshBBoxOnly); +} + +bool CLevelSet::GetMeshBBoxOnly() +{ + return levelSetObject()->getMeshBBoxOnly(); +} + +void CLevelSet::SetMesh(IMeshObject* pTheMesh) +{ + if(pTheMesh == nullptr) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + + NMR::CModel* pModel = levelSetObject()->getModel(); + if(pModel == nullptr) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDOBJECT, + "LevelSet Object " + + std::to_string(levelSetObject() + ->getPackageResourceID() + ->getModelResourceID()) + + " has no Model"); + } + + NMR::PModelMeshObject pMesh = + std::dynamic_pointer_cast( + pModel->findResource(pTheMesh->GetUniqueResourceID())); + + if(!pMesh) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDPARAM, + "Referenced Mesh Object not found with resource ID: " + + std::to_string(pTheMesh->GetModelResourceID())); + } + levelSetObject()->setMesh(pMesh); +} + +IMeshObject * CLevelSet::GetMesh() +{ + NMR::PModelMeshObject meshObject = levelSetObject()->getMesh(); + + if(!meshObject) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDOBJECT, + "Referenced Mesh Object of the levelset with the id " + + std::to_string(levelSetObject() + ->getPackageResourceID() + ->getModelResourceID()) + + " could not be found"); + } + + return new CMeshObject(meshObject); +} + +void CLevelSet::SetVolumeData(IVolumeData* pTheVolumeData) +{ + NMR::CModel * pModel = levelSetObject()->getModel(); + if (pModel == nullptr) + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDOBJECT, + "LevelSet Object " + + std::to_string(levelSetObject() + ->getPackageResourceID() + ->getModelResourceID()) + + " has no parent Model"); + + NMR::PModelResource pResource = pModel->findResource(pTheVolumeData->GetResourceID()); + if (pResource == nullptr) + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDOBJECT, + "Referenced VolumeData Resource with ID " + + std::to_string(pTheVolumeData->GetModelResourceID()) + + " not found"); + + NMR::PModelVolumeData pVolumeData = std::dynamic_pointer_cast(pResource); + + if(pVolumeData == nullptr) + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDOBJECT, + "Referenced Resource " + + std::to_string(pTheVolumeData->GetModelResourceID()) + + " by levelset " + + std::to_string(levelSetObject() + ->getPackageResourceID() + ->getModelResourceID()) + + " is not of type VolumeData"); + + levelSetObject()->setVolumeData(pVolumeData); +} + +bool CLevelSet::IsMeshObject() +{ + return false; +} + +bool Lib3MF::Impl::CLevelSet::IsComponentsObject() +{ + return false; +} + +bool CLevelSet::IsLevelSetObject() +{ + return true; +} + +IVolumeData * CLevelSet::GetVolumeData() +{ + NMR::PModelVolumeData pVolumeData = levelSetObject()->getVolumeData(); + if (!pVolumeData) + { + return nullptr; + } + return new CVolumeData(pVolumeData); +} \ No newline at end of file diff --git a/Source/API/lib3mf_levelsetiterator.cpp b/Source/API/lib3mf_levelsetiterator.cpp new file mode 100644 index 0000000..0814f72 --- /dev/null +++ b/Source/API/lib3mf_levelsetiterator.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CLevelSetIterator + +*/ + +#include "lib3mf_levelsetiterator.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_levelset.hpp" + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CLevelSetIterator +**************************************************************************************************************************/ + +ILevelSet * CLevelSetIterator::GetCurrentLevelSet() +{ + return CLevelSet::fnCreateLevelSetFromModelResource(GetCurrentResource(), true); +} + diff --git a/Source/API/lib3mf_log10node.cpp b/Source/API/lib3mf_log10node.cpp new file mode 100644 index 0000000..e69e348 --- /dev/null +++ b/Source/API/lib3mf_log10node.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CLog10Node + +*/ + +#include "lib3mf_log10node.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CLog10Node +**************************************************************************************************************************/ + +Lib3MF::Impl::CLog10Node::CLog10Node(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_log2node.cpp b/Source/API/lib3mf_log2node.cpp new file mode 100644 index 0000000..c37f0a2 --- /dev/null +++ b/Source/API/lib3mf_log2node.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CLog2Node + +*/ + +#include "lib3mf_log2node.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CLog2Node +**************************************************************************************************************************/ + +Lib3MF::Impl::CLog2Node::CLog2Node(NMR::PModelImplicitNode pImplicitNode) +: COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_lognode.cpp b/Source/API/lib3mf_lognode.cpp new file mode 100644 index 0000000..c20b37a --- /dev/null +++ b/Source/API/lib3mf_lognode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CLogNode + +*/ + +#include "lib3mf_lognode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CLogNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CLogNode::CLogNode(NMR::PModelImplicitNode pImplicitNode) +: COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_materialmapping.cpp b/Source/API/lib3mf_materialmapping.cpp new file mode 100644 index 0000000..55a7fe5 --- /dev/null +++ b/Source/API/lib3mf_materialmapping.cpp @@ -0,0 +1,42 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMaterialMapping + +*/ + +#include "lib3mf_materialmapping.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMaterialMapping +**************************************************************************************************************************/ + diff --git a/Source/API/lib3mf_matrixfromcolumnsnode.cpp b/Source/API/lib3mf_matrixfromcolumnsnode.cpp new file mode 100644 index 0000000..d9d023e --- /dev/null +++ b/Source/API/lib3mf_matrixfromcolumnsnode.cpp @@ -0,0 +1,73 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMatrixFromColumnsNode + +*/ + +#include "lib3mf_matrixfromcolumnsnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMatrixFromColumnsNode +**************************************************************************************************************************/ +CMatrixFromColumnsNode:: + CMatrixFromColumnsNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + +IImplicitPort * CMatrixFromColumnsNode::GetInputA() +{ + return FindInputOrThrow(NMR::InputNames::A); +} + +IImplicitPort * CMatrixFromColumnsNode::GetInputB() +{ + return FindInputOrThrow(NMR::InputNames::B); +} + +IImplicitPort * CMatrixFromColumnsNode::GetInputC() +{ + return FindInputOrThrow(NMR::InputNames::C); +} + +IImplicitPort * CMatrixFromColumnsNode::GetInputD() +{ + return FindInputOrThrow(NMR::InputNames::D); +} + +IImplicitPort * CMatrixFromColumnsNode::GetOutputResult() +{ + return FindOutputOrThrow(NMR::OutputNames::result); +} + diff --git a/Source/API/lib3mf_matrixfromrowsnode.cpp b/Source/API/lib3mf_matrixfromrowsnode.cpp new file mode 100644 index 0000000..7f34568 --- /dev/null +++ b/Source/API/lib3mf_matrixfromrowsnode.cpp @@ -0,0 +1,75 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMatrixFromRowsNode + +*/ + +#include "lib3mf_matrixfromrowsnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMatrixFromRowsNode +**************************************************************************************************************************/ + +CMatrixFromRowsNode:: + CMatrixFromRowsNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + + +IImplicitPort * CMatrixFromRowsNode::GetInputA() +{ + return FindInputOrThrow(NMR::InputNames::A); +} + +IImplicitPort * CMatrixFromRowsNode::GetInputB() +{ + return FindInputOrThrow(NMR::InputNames::B); +} + +IImplicitPort * CMatrixFromRowsNode::GetInputC() +{ + return FindInputOrThrow(NMR::InputNames::C); +} + +IImplicitPort * CMatrixFromRowsNode::GetInputD() +{ + return FindInputOrThrow(NMR::InputNames::D); +} + +IImplicitPort * CMatrixFromRowsNode::GetOutputResult() +{ + return FindOutputOrThrow(NMR::OutputNames::result); +} + diff --git a/Source/API/lib3mf_matvecmultiplicationnode.cpp b/Source/API/lib3mf_matvecmultiplicationnode.cpp new file mode 100644 index 0000000..eb113be --- /dev/null +++ b/Source/API/lib3mf_matvecmultiplicationnode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMatVecMultiplicationNode + +*/ + +#include "lib3mf_matvecmultiplicationnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMatVecMultiplicationNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CMatVecMultiplicationNode::CMatVecMultiplicationNode( + NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_maxnode.cpp b/Source/API/lib3mf_maxnode.cpp new file mode 100644 index 0000000..f93b5e0 --- /dev/null +++ b/Source/API/lib3mf_maxnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMaxNode + +*/ + +#include "lib3mf_maxnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMaxNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CMaxNode::CMaxNode(NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_meshnode.cpp b/Source/API/lib3mf_meshnode.cpp new file mode 100644 index 0000000..b919756 --- /dev/null +++ b/Source/API/lib3mf_meshnode.cpp @@ -0,0 +1,64 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMeshNode + +*/ + +#include "lib3mf_meshnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMeshNode +**************************************************************************************************************************/ + +CMeshNode::CMeshNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + +IImplicitPort * CMeshNode::GetInputMesh() +{ + return FindInputOrThrow(NMR::InputNames::mesh); +} + +IImplicitPort * CMeshNode::GetInputPos() +{ + return FindInputOrThrow(NMR::InputNames::pos); +} + + +IImplicitPort * CMeshNode::GetOutputDistance() +{ + return FindOutputOrThrow(NMR::OutputNames::distance); +} + diff --git a/Source/API/lib3mf_meshobject.cpp b/Source/API/lib3mf_meshobject.cpp index 7c7e4f5..d8d71d9 100644 --- a/Source/API/lib3mf_meshobject.cpp +++ b/Source/API/lib3mf_meshobject.cpp @@ -29,11 +29,15 @@ Abstract: This is a stub class definition of CMeshObject */ #include "lib3mf_meshobject.hpp" #include "lib3mf_interfaceexception.hpp" +#include "lib3mf_triangleset.hpp" #include "lib3mf_beamlattice.hpp" +#include "lib3mf_volumedata.hpp" // Include custom headers here. #include "Common/MeshInformation/NMR_MeshInformation_Properties.h" +#include "Model/Classes/NMR_ModelVolumeData.h" +#include "Model/Classes/NMR_ModelResource.h" #include using namespace Lib3MF::Impl; @@ -379,6 +383,11 @@ bool CMeshObject::IsComponentsObject() return false; } +bool CMeshObject::IsLevelSetObject() +{ + return false; +} + bool CMeshObject::IsValid() { return meshObject()->isValid(); @@ -388,3 +397,72 @@ IBeamLattice* CMeshObject::BeamLattice() { return new CBeamLattice(meshObject(), meshObject()->getBeamLatticeAttributes()); } + +IVolumeData * CMeshObject::GetVolumeData() +{ + auto volumeData = meshObject()->getVolumeData(); + if (!volumeData) + { + return nullptr; + } + return new CVolumeData(std::dynamic_pointer_cast(meshObject()->getVolumeData())); +} + +void CMeshObject::SetVolumeData(IVolumeData* pTheVolumeData) +{ + NMR::CModel * pModel = meshObject()->getModel(); + if (pModel == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT); + + NMR::PModelResource pResource = pModel->findResource(pTheVolumeData->GetResourceID()); + + if (pResource == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT, "Referenced VolumeData Resource with ID " + std::to_string(pTheVolumeData->GetModelResourceID()) + " not found"); + + NMR::PModelVolumeData pVolumeData = std::dynamic_pointer_cast(pResource); + + if (pVolumeData == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT, "Referenced Resource is not of type VolumeData"); + + meshObject()->setVolumeData(pVolumeData); +} + +ITriangleSet* CMeshObject::AddTriangleSet(const std::string& sIdentifier, const std::string& sName) +{ + return new CTriangleSet(meshObject()->addTriangleSet(sIdentifier, sName), meshObject()); +} + +bool CMeshObject::HasTriangleSet(const std::string& sIdentifier) +{ + auto pTriangleSet = meshObject()->findTriangleSet(sIdentifier); + return (pTriangleSet.get() != nullptr); +} + +ITriangleSet* CMeshObject::FindTriangleSet(const std::string& sIdentifier) +{ + auto pMeshObject = meshObject(); + auto pTriangleSet = pMeshObject->findTriangleSet(sIdentifier); + if (pTriangleSet.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_COULDNOTFINDTRIANGLESET); + + return new CTriangleSet(pTriangleSet, pMeshObject); + +} + +Lib3MF_uint32 CMeshObject::GetTriangleSetCount() +{ + return meshObject()->getTriangleSetCount(); +} + +ITriangleSet* CMeshObject::GetTriangleSet(const Lib3MF_uint32 nIndex) +{ + auto pMeshObject = meshObject(); + auto nTriangleSetCount = pMeshObject->getTriangleSetCount(); + if (nIndex >= nTriangleSetCount) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDTRIANGLESETINDEX); + + auto pTriangleSet = meshObject()->getTriangleSet (nIndex); + + return new CTriangleSet(pTriangleSet, pMeshObject); +} + diff --git a/Source/API/lib3mf_minnode.cpp b/Source/API/lib3mf_minnode.cpp new file mode 100644 index 0000000..1dce2a3 --- /dev/null +++ b/Source/API/lib3mf_minnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMinNode + +*/ + +#include "lib3mf_minnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMinNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CMinNode::CMinNode(NMR::PModelImplicitNode pImplicitNode) +: CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_model.cpp b/Source/API/lib3mf_model.cpp index 514309b..8bffb59 100644 --- a/Source/API/lib3mf_model.cpp +++ b/Source/API/lib3mf_model.cpp @@ -60,7 +60,15 @@ Abstract: This is a stub class definition of CModel #include "lib3mf_multipropertygroupiterator.hpp" #include "lib3mf_packagepart.hpp" #include "lib3mf_keystore.hpp" - +#include "lib3mf_image3d.hpp" +#include "lib3mf_imagestack.hpp" +#include "lib3mf_image3diterator.hpp" +#include "lib3mf_implicitfunction.hpp" +#include "lib3mf_functioniterator.hpp" +#include "lib3mf_functionfromimage3d.hpp" +#include "lib3mf_volumedata.hpp" +#include "lib3mf_levelset.hpp" +#include "lib3mf_levelsetiterator.hpp" // Include custom headers here. #include "Model/Classes/NMR_ModelMeshObject.h" @@ -69,6 +77,11 @@ Abstract: This is a stub class definition of CModel #include "Model/Classes/NMR_ModelColorGroup.h" #include "Model/Classes/NMR_ModelTexture2DGroup.h" #include "Model/Classes/NMR_ModelMultiPropertyGroup.h" +#include "Model/Classes/NMR_ModelImageStack.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Classes/NMR_ModelFunctionFromImage3D.h" +#include "Model/Classes/NMR_ModelVolumeData.h" +#include "Model/Classes/NMR_ModelLevelSetObject.h" #include "Common/NMR_SecureContentTypes.h" #include "lib3mf_utils.hpp" @@ -84,11 +97,100 @@ CModel::CModel() m_model = std::make_shared(); } +void CModel::mergeModel(NMR::CModel& sourceModel, + NMR::CModel& targetModel) +{ + NMR::UniqueResourceIDMapping oldToNewUniqueResourceIDs; + targetModel.mergeModelAttachments(&sourceModel); + targetModel.mergeTextures2D(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeBaseMaterials(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeColorGroups(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeTexture2DGroups(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeCompositeMaterials(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeMultiPropertyGroups(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeImage3Ds(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeFunctions(&sourceModel, oldToNewUniqueResourceIDs); + targetModel.mergeMetaData(&sourceModel); +} + NMR::CModel& CModel::model() { return *m_model; } +IResource* CModel::createIResourceFromModelResource(NMR::PModelResource pResource, bool bFailIfUnkownClass) +{ + // this is really ugly and should be automated by mapping of Lib3MF::Impl-class to NMR-class + if (!pResource.get()) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CTexture2D(p); + } + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CBaseMaterialGroup(p); + } + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CColorGroup(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CMeshObject(p); + } + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CComponentsObject(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CCompositeMaterials(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CMultiPropertyGroup(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CTexture2DGroup(p); + } + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CTexture2D(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CSliceStack(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CImageStack(p); + } + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CImage3D(p); + } + + if (auto p= std::dynamic_pointer_cast(pResource)) { + return new CImplicitFunction(p); + } + + if(auto p = std::dynamic_pointer_cast( + pResource)) + { + return new CFunctionFromImage3D(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CVolumeData(p); + } + + if (auto p = std::dynamic_pointer_cast(pResource)) { + return new CLevelSet(p); + } + + if (bFailIfUnkownClass) + throw ELib3MFInterfaceException(NMR_ERROR_UNKNOWNMODELRESOURCE); + + return nullptr; +} + IPackagePart* CModel::RootModelPart() { return new CPackagePart(model().rootModelPath()); @@ -129,6 +231,16 @@ IReader * CModel::QueryReader (const std::string & sReaderClass) return new CReader(sReaderClass, m_model); } +IResource* CModel::GetResourceByID(const Lib3MF_uint32 nUniqueResourceID) +{ + NMR::PModelResource pResource = model().findResource(nUniqueResourceID); + if (pResource) { + return createIResourceFromModelResource(pResource, true); + } + else + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDRESOURCE); +} + ITexture2D * CModel::GetTexture2DByID(const Lib3MF_uint32 nUniqueResourceID) { NMR::PModelTexture2DResource pTexture2DResource = model().findTexture2D(nUniqueResourceID); @@ -222,6 +334,17 @@ ISliceStack * CModel::GetSliceStackByID(const Lib3MF_uint32 nUniqueResourceID) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDSLICESTACKRESOURCE); } +ILevelSet* CModel::GetLevelSetByID(const Lib3MF_uint32 nUniqueResourceID) +{ + NMR::PModelResource pResource = model().findResource(nUniqueResourceID); + if (dynamic_cast(pResource.get())) { + return new CLevelSet(std::dynamic_pointer_cast(pResource)); + } + else + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDLEVELSET); + +} + ITexture2DGroup * CModel::GetTexture2DGroupByID(const Lib3MF_uint32 nUniqueResourceID) { NMR::PModelResource pResource = model().findResource(nUniqueResourceID); @@ -441,6 +564,9 @@ IModel * CModel::MergeToModel () newModel.mergeTexture2DGroups(&model(), oldToNewUniqueResourceIDs); newModel.mergeCompositeMaterials(&model(), oldToNewUniqueResourceIDs); newModel.mergeMultiPropertyGroups(&model(), oldToNewUniqueResourceIDs); + newModel.mergeImage3Ds(&model(), oldToNewUniqueResourceIDs); + newModel.mergeFunctions(&model(), oldToNewUniqueResourceIDs); + newModel.mergeMetaData(&model()); pMesh->patchMeshInformationResources(oldToNewUniqueResourceIDs); @@ -457,6 +583,15 @@ IModel * CModel::MergeToModel () return pOutModel.release(); } +void CModel::MergeFromModel(IModel* pModelInstance) +{ + CModel* pLib3MFModel = dynamic_cast (pModelInstance); + if (!pLib3MFModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + mergeModel(pLib3MFModel->model(), model()); +} + IMeshObject * CModel::AddMeshObject () { NMR::ModelResourceID NewResourceID = model().generateResourceID(); @@ -686,11 +821,43 @@ Lib3MF::sBox CModel::GetOutbox() return s; } -IKeyStore * Lib3MF::Impl::CModel::GetKeyStore() { +IImageStack * CModel::AddImageStack(const Lib3MF_uint32 nSizeX, const Lib3MF_uint32 nSizeY, const Lib3MF_uint32 nSheetCount) +{ + NMR::PModelImageStack pResource = NMR::CModelImageStack::make(model().generateResourceID(), &model(), nSizeX, nSizeY, nSheetCount); + model().addResource(pResource); + + return new CImageStack(pResource); +} + +IImageStack* CModel::GetImageStackByID(const Lib3MF_uint32 nUniqueResourceID) +{ + NMR::PModelImageStack pImageStackResource = model().findImageStack(nUniqueResourceID); + if (pImageStackResource) { + return new CImageStack(pImageStackResource); + } + else + throw ELib3MFInterfaceException(LIB3MF_ERROR_RESOURCENOTFOUND); +} + +IImage3DIterator * CModel::GetImage3Ds() +{ + auto pResult = std::unique_ptr(new CImage3DIterator()); + Lib3MF_uint32 nImage3DCount = model().getImage3DCount(); + + for (Lib3MF_uint32 nIdx = 0; nIdx < nImage3DCount; nIdx++) { + auto resource = model().getImage3DResource(nIdx); + pResult->addResource(resource); + } + return pResult.release(); +} + +IKeyStore * Lib3MF::Impl::CModel::GetKeyStore() +{ return new CKeyStore(m_model); } -void Lib3MF::Impl::CModel::SetRandomNumberCallback(Lib3MF::RandomNumberCallback pTheCallback, Lib3MF_pvoid pUserData) { +void Lib3MF::Impl::CModel::SetRandomNumberCallback(Lib3MF::RandomNumberCallback pTheCallback, Lib3MF_pvoid pUserData) +{ if (nullptr == pTheCallback) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); NMR::CryptoRandGenDescriptor descriptor; @@ -706,3 +873,76 @@ void Lib3MF::Impl::CModel::SetRandomNumberCallback(Lib3MF::RandomNumberCallback m_model->setCryptoRandCallback(descriptor); } +IFunctionIterator * CModel::GetFunctions() +{ + auto pResult = std::unique_ptr(new CFunctionIterator()); + Lib3MF_uint32 nFunctionCount = model().getFunctionCount(); + + for (Lib3MF_uint32 nIdx = 0; nIdx < nFunctionCount; nIdx++) { + auto resource = model().getFunctionResource(nIdx); + pResult->addResource(resource); + } + return pResult.release(); +} + +IImplicitFunction* CModel::AddImplicitFunction() +{ + NMR::ModelResourceID NewResourceID = model().generateResourceID(); + NMR::PModelImplicitFunction pNewResource = std::make_shared(NewResourceID, &model()); + + model().addResource(pNewResource); + + return new CImplicitFunction(pNewResource); +} + +IFunctionFromImage3D* CModel::AddFunctionFromImage3D(IImage3D* pImage3DInstance) +{ + NMR::ModelResourceID NewResourceID = model().generateResourceID(); + NMR::PModelFunctionFromImage3D pNewResource = std::make_shared(NewResourceID, &model()); + pNewResource->setImage3DUniqueResourceID(pImage3DInstance->GetUniqueResourceID()); + model().addResource(pNewResource); + auto newFunc = new CFunctionFromImage3D(pNewResource); + return newFunc; +} + + +IVolumeData * CModel::AddVolumeData() +{ + NMR::ModelResourceID NewResourceID = model().generateResourceID(); + NMR::PModelVolumeData pNewResource = std::make_shared(NewResourceID, &model()); + + model().addResource(pNewResource); + + return new CVolumeData(pNewResource); +} + +ILevelSet* CModel::AddLevelSet() +{ + NMR::ModelResourceID NewResourceID = model().generateResourceID(); + NMR::PModelLevelSetObject pNewResource = std::make_shared(NewResourceID, &model()); + + model().addResource(pNewResource); + + return new CLevelSet(pNewResource); +} + +ILevelSetIterator * CModel::GetLevelSets() +{ + auto pResult = std::unique_ptr(new CLevelSetIterator()); + Lib3MF_uint32 nObjectsCount = model().getObjectCount(); + + for (Lib3MF_uint32 nIdx = 0; nIdx < nObjectsCount; nIdx++) { + auto resource = model().getObjectResource(nIdx); + if (dynamic_cast(resource.get())) + pResult->addResource(resource); + } + return pResult.release(); +} + +void CModel::RemoveResource(IResource* pResource) +{ + CResource* pLib3MFResource = dynamic_cast (pResource); + if (!pLib3MFResource) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDRESOURCE); + model().removeResource(pLib3MFResource->resource()); +} diff --git a/Source/API/lib3mf_modnode.cpp b/Source/API/lib3mf_modnode.cpp new file mode 100644 index 0000000..bc59edb --- /dev/null +++ b/Source/API/lib3mf_modnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CModNode + +*/ + +#include "lib3mf_modnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CModNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CModNode::CModNode(NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_multiplicationnode.cpp b/Source/API/lib3mf_multiplicationnode.cpp new file mode 100644 index 0000000..3004465 --- /dev/null +++ b/Source/API/lib3mf_multiplicationnode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMultiplicationNode + +*/ + +#include "lib3mf_multiplicationnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CMultiplicationNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CMultiplicationNode::CMultiplicationNode( + NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_multipropertygroup.cpp b/Source/API/lib3mf_multipropertygroup.cpp index eb88cfa..867114e 100644 --- a/Source/API/lib3mf_multipropertygroup.cpp +++ b/Source/API/lib3mf_multipropertygroup.cpp @@ -118,7 +118,10 @@ void CMultiPropertyGroup::GetMultiProperty (const Lib3MF_uint32 nPropertyID, Lib *pPropertyIDsNeededCount = multiProperty->size(); } - if (pPropertyIDsBuffer && nPropertyIDsBufferSize >= multiProperty->size()) { + if (pPropertyIDsBuffer) { + + if (nPropertyIDsBufferSize < multiProperty->size()) + throw ELib3MFInterfaceException(LIB3MF_ERROR_BUFFERTOOSMALL); if (nPropertyIDsBufferSize > LIB3MF_MAXMULTIPROPERTIES) throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT); diff --git a/Source/API/lib3mf_multipropertygroupiterator.cpp b/Source/API/lib3mf_multipropertygroupiterator.cpp index a66ce81..add3935 100644 --- a/Source/API/lib3mf_multipropertygroupiterator.cpp +++ b/Source/API/lib3mf_multipropertygroupiterator.cpp @@ -45,3 +45,7 @@ IMultiPropertyGroup * CMultiPropertyGroupIterator::GetCurrentMultiPropertyGroup return new CMultiPropertyGroup(std::dynamic_pointer_cast(GetCurrentResource())); } +IResource * CMultiPropertyGroupIterator::GetCurrent() +{ + return GetCurrentMultiPropertyGroup(); +} diff --git a/Source/API/lib3mf_nodeiterator.cpp b/Source/API/lib3mf_nodeiterator.cpp new file mode 100644 index 0000000..18f7ce5 --- /dev/null +++ b/Source/API/lib3mf_nodeiterator.cpp @@ -0,0 +1,290 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CNodeIterator + +*/ + +#include "lib3mf_nodeiterator.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_absnode.hpp" +#include "lib3mf_additionnode.hpp" +#include "lib3mf_arccosnode.hpp" +#include "lib3mf_arcsinnode.hpp" +#include "lib3mf_arctan2node.hpp" +#include "lib3mf_arctannode.hpp" +#include "lib3mf_ceilnode.hpp" +#include "lib3mf_clampnode.hpp" +#include "lib3mf_composematrixnode.hpp" +#include "lib3mf_composevectornode.hpp" +#include "lib3mf_constantnode.hpp" +#include "lib3mf_constmatnode.hpp" +#include "lib3mf_constvecnode.hpp" +#include "lib3mf_coshnode.hpp" +#include "lib3mf_cosnode.hpp" +#include "lib3mf_crossnode.hpp" +#include "lib3mf_decomposevectornode.hpp" +#include "lib3mf_divisionnode.hpp" +#include "lib3mf_dotnode.hpp" +#include "lib3mf_expnode.hpp" +#include "lib3mf_floornode.hpp" +#include "lib3mf_fmodnode.hpp" +#include "lib3mf_fractnode.hpp" +#include "lib3mf_functioncallnode.hpp" +#include "lib3mf_inversenode.hpp" +#include "lib3mf_lengthnode.hpp" +#include "lib3mf_log10node.hpp" +#include "lib3mf_log2node.hpp" +#include "lib3mf_lognode.hpp" +#include "lib3mf_matrixfromcolumnsnode.hpp" +#include "lib3mf_matrixfromrowsnode.hpp" +#include "lib3mf_matvecmultiplicationnode.hpp" +#include "lib3mf_maxnode.hpp" +#include "lib3mf_meshnode.hpp" +#include "lib3mf_minnode.hpp" +#include "lib3mf_multiplicationnode.hpp" +#include "lib3mf_pownode.hpp" +#include "lib3mf_resourceidnode.hpp" +#include "lib3mf_roundnode.hpp" +#include "lib3mf_selectnode.hpp" +#include "lib3mf_signnode.hpp" +#include "lib3mf_sinhnode.hpp" +#include "lib3mf_sinnode.hpp" +#include "lib3mf_sqrtnode.hpp" +#include "lib3mf_subtractionnode.hpp" +#include "lib3mf_tanhnode.hpp" +#include "lib3mf_tannode.hpp" +#include "lib3mf_transposenode.hpp" +#include "lib3mf_unsignedmeshnode.hpp" +#include "lib3mf_vectorfromscalarnode.hpp" +#include "lib3mf_modnode.hpp" +#include "lib3mf_beamlatticenode.hpp" +#include "lib3mf_functiongradientnode.hpp" +#include "lib3mf_normalizedistancenode.hpp" + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CNodeIterator +**************************************************************************************************************************/ + +IImplicitNode * CNodeIterator::GetCurrent() +{ + throwIfInvalidIndex(); + auto pModelNode = m_pNodes->at(static_cast(getCurrentIndex())); + auto pNode = implicitNodeFromModelImplicitNode(pModelNode); + if (!pNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + return pNode; +} + +// enum class eImplicitNodeType : Lib3MF_int32 { +// Addition = 1, /** Adds to values (scalar or vector) */ +// Subtraction = 2, /** Subtracts two values (scalar or vector) */ +// Multiplication = 3, /** Multiplies two values (scalar or vector) */ +// Division = 4, /** Divides two values (scalar or vector) */ +// Constant = 5, /** A constant scalar value */ +// ConstVec = 6, /** A constant vector value */ +// ConstMat = 7, /** A constant matrix value */ +// ComposeVector = 8, /** Creates a vector from three scalar values */ +// DecomposeVector = 9, /** Decomposes a vector into three scalar values */ +// ComposeMatrix = 10, /** Creates a matrix from nine scalar values */ +// ComposeMatrixFromColumnVectors = 11, /** Creates a matrix from three column vector values */ +// ComposeMatrixFromRowVectors = 12, /** Creates a matrix from three row vector values */ +// Dot = 13, /** Calculates the dot product of two vector values */ +// Cross = 14, /** Calculates the cross product of two vector values */ +// MatVecMultiplication = 15, /** Multiplies a matrix with a vector */ +// Transpose = 16, /** Transposes a matrix */ +// Inverse = 17, /** Computes the inverse of a matrix */ +// Sinus = 18, /** Calculates the sinus */ +// Cosinus = 19, /** Calculates the cosinus */ +// Tan = 20, /** Calculates the tangent */ +// ArcSin = 21, /** Calculates the arcsinus */ +// ArcCos = 22, /** Calculates the arccosinus */ +// ArcTan = 23, /** Calculates the arctangent */ +// ArcTan2 = 24, /** Calculates the arctangent */ +// Min = 25, /** Calculates the minimum tow values */ +// Max = 26, /** Calculates the maximum of two values */ +// Abs = 27, /** Calcul the absolute value */ +// Fmod = 28, /** Calculates the modulo of two values */ +// Pow = 29, /** Calculates the power A^B */ +// Sqrt = 30, /** Calculates the square root */ +// Exp = 31, /** Exponential function */ +// Log = 32, /** Natural logarithmus */ +// Log2 = 33, /** Logarithmus to the base 2 */ +// Log10 = 34, /** Logarithmus to the base 10 */ +// Select = 35, /** If A is less B returns C, else D */ +// Clamp = 36, /** Clamps the input value to min and max */ +// Sinh = 37, /** Calculates the hyperbolic sine */ +// Cosh = 38, /** Calculates the hyperbolic cosine */ +// Tanh = 39, /** Calculates the hyperbolic tangent */ +// Round = 40, /** Rounds a scalar value to the nearest integer */ +// Ceil = 41, /** Rounds a scalar value up to the nearest integer */ +// Floor = 42, /** Rounds a scalar value down to the nearest integer */ +// Sign = 43, /** Returns the sign */ +// Fract = 44, /** Returns the fractional part */ +// FunctionCall = 45, /** Calls a function */ +// Mesh = 46, /** Calculates the signed distance to a mesh */ +// Length = 47, /** Calculates the length of a vector */ +// Resource = 48 /** Selects a resource (function, mesh etc.) */ +// }; + +IImplicitNode* Lib3MF::Impl::CNodeIterator::implicitNodeFromModelImplicitNode( + NMR::PModelImplicitNode pNode) +{ + if (!pNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + + switch (pNode->getNodeType()) + { + case eImplicitNodeType::Addition: + return new CAdditionNode(pNode); + case eImplicitNodeType::Subtraction: + return new CSubtractionNode(pNode); + case eImplicitNodeType::Multiplication: + return new CMultiplicationNode(pNode); + case eImplicitNodeType::Division: + return new CDivisionNode(pNode); + case eImplicitNodeType::Constant: + return new CConstantNode(pNode); + case eImplicitNodeType::ConstVec: + return new CConstVecNode(pNode); + case eImplicitNodeType::ConstMat: + return new CConstMatNode(pNode); + case eImplicitNodeType::ComposeVector: + return new CComposeVectorNode(pNode); + case eImplicitNodeType::VectorFromScalar: + return new CVectorFromScalarNode(pNode); + case eImplicitNodeType::DecomposeVector: + return new CDecomposeVectorNode(pNode); + case eImplicitNodeType::ComposeMatrix: + return new CComposeMatrixNode(pNode); + case eImplicitNodeType::MatrixFromColumns: + return new CMatrixFromColumnsNode(pNode); + case eImplicitNodeType::MatrixFromRows: + return new CMatrixFromRowsNode(pNode); + case eImplicitNodeType::Dot: + return new CDotNode(pNode); + case eImplicitNodeType::Cross: + return new CCrossNode(pNode); + case eImplicitNodeType::MatVecMultiplication: + return new CMatVecMultiplicationNode(pNode); + case eImplicitNodeType::Transpose: + return new CTransposeNode(pNode); + case eImplicitNodeType::Inverse: + return new CInverseNode(pNode); + case eImplicitNodeType::Sinus: + return new CSinNode(pNode); + case eImplicitNodeType::Cosinus: + return new CCosNode(pNode); + case eImplicitNodeType::Tan: + return new CTanNode(pNode); + case eImplicitNodeType::ArcSin: + return new CArcSinNode(pNode); + case eImplicitNodeType::ArcCos: + return new CArcCosNode(pNode); + case eImplicitNodeType::ArcTan: + return new CArcTanNode(pNode); + case eImplicitNodeType::ArcTan2: + return new CArcTan2Node(pNode); + case eImplicitNodeType::Min: + return new CMinNode(pNode); + case eImplicitNodeType::Max: + return new CMaxNode(pNode); + case eImplicitNodeType::Abs: + return new CAbsNode(pNode); + case eImplicitNodeType::Fmod: + return new CFmodNode(pNode); + case eImplicitNodeType::Pow: + return new CPowNode(pNode); + case eImplicitNodeType::Sqrt: + return new CSqrtNode(pNode); + case eImplicitNodeType::Exp: + return new CExpNode(pNode); + case eImplicitNodeType::Log: + return new CLogNode(pNode); + case eImplicitNodeType::Log2: + return new CLog2Node(pNode); + case eImplicitNodeType::Log10: + return new CLog10Node(pNode); + case eImplicitNodeType::Select: + return new CSelectNode(pNode); + case eImplicitNodeType::Clamp: + return new CClampNode(pNode); + case eImplicitNodeType::Sinh: + return new CSinhNode(pNode); + case eImplicitNodeType::Cosh: + return new CCoshNode(pNode); + case eImplicitNodeType::Tanh: + return new CTanhNode(pNode); + case eImplicitNodeType::Round: + return new CRoundNode(pNode); + case eImplicitNodeType::Ceil: + return new CCeilNode(pNode); + case eImplicitNodeType::Floor: + return new CFloorNode(pNode); + case eImplicitNodeType::Sign: + return new CSignNode(pNode); + case eImplicitNodeType::Fract: + return new CFractNode(pNode); + case eImplicitNodeType::FunctionCall: + return new CFunctionCallNode(pNode); + case eImplicitNodeType::Mesh: + return new CMeshNode(pNode); + case eImplicitNodeType::UnsignedMesh: + return new CUnsignedMeshNode(pNode); + case eImplicitNodeType::Length: + return new CLengthNode(pNode); + case eImplicitNodeType::ConstResourceID: + return new CResourceIdNode(pNode); + case eImplicitNodeType::Mod: + return new CModNode(pNode); + case eImplicitNodeType::BeamLattice: + return new CBeamLatticeNode(pNode); + case eImplicitNodeType::FunctionGradient: + return new CFunctionGradientNode(pNode); + case eImplicitNodeType::NormalizeDistance: + return new CNormalizeDistanceNode(pNode); + + default: + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + +} + +Lib3MF::Impl::CNodeIterator::CNodeIterator(NMR::PImplicitNodes pNodes) + : m_pNodes(pNodes) +{ +} + +Lib3MF_uint64 Lib3MF::Impl::CNodeIterator::Count() +{ + return static_cast(m_pNodes->size()); +} diff --git a/Source/API/lib3mf_normalizedistancenode.cpp b/Source/API/lib3mf_normalizedistancenode.cpp new file mode 100644 index 0000000..dd84f08 --- /dev/null +++ b/Source/API/lib3mf_normalizedistancenode.cpp @@ -0,0 +1,89 @@ +/*++ + +Copyright (C) 2024 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CNormalizeDistanceNode + +*/ + +#include "lib3mf_normalizedistancenode.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_implicitport.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CNormalizeDistanceNode +**************************************************************************************************************************/ + +CNormalizeDistanceNode::CNormalizeDistanceNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + m_pImplicitNode = pImplicitNode; +} + +IImplicitPort * CNormalizeDistanceNode::GetInputFunctionID() +{ + return FindInputOrThrow("functionID"); +} + +IImplicitPort * CNormalizeDistanceNode::GetInputPos() +{ + return FindInputOrThrow("pos"); +} + +IImplicitPort * CNormalizeDistanceNode::GetInputStep() +{ + return FindInputOrThrow("step"); +} + +void CNormalizeDistanceNode::SetScalarOutputName(const std::string & sScalarOutputName) +{ + m_pImplicitNode->setScalarOutputName(sScalarOutputName); +} + +std::string CNormalizeDistanceNode::GetScalarOutputName() +{ + return m_pImplicitNode->getScalarOutputName(); +} + +void CNormalizeDistanceNode::SetVectorInputName(const std::string & sVectorInputName) +{ + m_pImplicitNode->setVectorInputName(sVectorInputName); +} + +std::string CNormalizeDistanceNode::GetVectorInputName() +{ + return m_pImplicitNode->getVectorInputName(); +} + +IImplicitPort * CNormalizeDistanceNode::GetOutputResult() +{ + return FindOutputOrThrow("result"); +} + diff --git a/Source/API/lib3mf_object.cpp b/Source/API/lib3mf_object.cpp index aa87cec..12ef901 100644 --- a/Source/API/lib3mf_object.cpp +++ b/Source/API/lib3mf_object.cpp @@ -32,6 +32,7 @@ Abstract: This is a stub class definition of CObject #include "lib3mf_interfaceexception.hpp" #include "lib3mf_meshobject.hpp" +#include "lib3mf_levelset.hpp" #include "lib3mf_componentsobject.hpp" #include "lib3mf_metadatagroup.hpp" #include "lib3mf_slicestack.hpp" @@ -39,6 +40,7 @@ Abstract: This is a stub class definition of CObject // Include custom headers here. #include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelLevelSetObject.h" #include "Model/Classes/NMR_ModelComponentsObject.h" using namespace Lib3MF::Impl; @@ -65,6 +67,11 @@ IObject* CObject::fnCreateObjectFromModelResource(NMR::PModelResource pResource, return new CMeshObject(pResource); } + NMR::CModelLevelSetObject * PILevelSet = dynamic_cast (pResource.get()); + if (PILevelSet) { + return new CLevelSet(pResource); + } + NMR::CModelComponentsObject * pComponentsResource = dynamic_cast (pResource.get()); if (pComponentsResource) { return new CComponentsObject(pResource); @@ -124,6 +131,13 @@ bool CObject::IsComponentsObject () throw ELib3MFInterfaceException(LIB3MF_ERROR_SHOULDNOTBECALLED); } +bool CObject::IsLevelSetObject() +{ + // overwritten by child class + throw ELib3MFInterfaceException(LIB3MF_ERROR_SHOULDNOTBECALLED); +} + + IMeshObject * CObject::AsMeshObject() { if (dynamic_cast(resource().get())) diff --git a/Source/API/lib3mf_objectiterator.cpp b/Source/API/lib3mf_objectiterator.cpp index 1274a41..c0102d0 100644 --- a/Source/API/lib3mf_objectiterator.cpp +++ b/Source/API/lib3mf_objectiterator.cpp @@ -45,3 +45,7 @@ IObject * CObjectIterator::GetCurrentObject () return CObject::fnCreateObjectFromModelResource(GetCurrentResource(), true); } +IResource * CObjectIterator::GetCurrent() +{ + return GetCurrentObject(); +} diff --git a/Source/API/lib3mf_oneinputnode.cpp b/Source/API/lib3mf_oneinputnode.cpp new file mode 100644 index 0000000..94bcc4d --- /dev/null +++ b/Source/API/lib3mf_oneinputnode.cpp @@ -0,0 +1,57 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of COneInputNode + +*/ + +#include "lib3mf_oneinputnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of COneInputNode +**************************************************************************************************************************/ + +IImplicitPort * COneInputNode::GetInputA() +{ + return FindInputOrThrow(NMR::InputNames::A); +} + +IImplicitPort * COneInputNode::GetOutputResult() +{ + return FindOutputOrThrow(NMR::OutputNames::result); +} + +COneInputNode::COneInputNode( + NMR::PModelImplicitNode pImplicitNode) : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_pownode.cpp b/Source/API/lib3mf_pownode.cpp new file mode 100644 index 0000000..28716b1 --- /dev/null +++ b/Source/API/lib3mf_pownode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CPowNode + +*/ + +#include "lib3mf_pownode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CPowNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CPowNode::CPowNode(NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_reader.cpp b/Source/API/lib3mf_reader.cpp index 9754233..2f4e4f6 100644 --- a/Source/API/lib3mf_reader.cpp +++ b/Source/API/lib3mf_reader.cpp @@ -200,7 +200,10 @@ void Lib3MF::Impl::CReader::AddKeyWrappingCallback(const std::string &sConsumerI if (result == 0) throw ELib3MFInterfaceException(LIB3MF_ERROR_CALCULATIONABORTED); - plain.resize(needed, 0); + if (needed > LIB3MF_READER_MAXKEYSIZE) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDKEYSIZE); + + plain.resize((size_t)needed, 0); result = 0; (*pTheCallback)(entityHandle, cipher.size(), cipher.data(), diff --git a/Source/API/lib3mf_resource.cpp b/Source/API/lib3mf_resource.cpp index d06de18..d05afdd 100644 --- a/Source/API/lib3mf_resource.cpp +++ b/Source/API/lib3mf_resource.cpp @@ -46,12 +46,24 @@ using namespace Lib3MF::Impl; NMR::PModelResource CResource::resource() { - if (m_pResource.get()==nullptr) + if (m_pResource.get() == nullptr) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT); return m_pResource; } +NMR::CModel* CResource::model() +{ + if (m_pResource.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT); + + + if (m_pResource->getModel() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDMODEL); + + return m_pResource->getModel(); +} + CResource::CResource(NMR::PModelResource pResource) { if (pResource.get() == nullptr) diff --git a/Source/API/lib3mf_resourceidnode.cpp b/Source/API/lib3mf_resourceidnode.cpp new file mode 100644 index 0000000..8d7ac3c --- /dev/null +++ b/Source/API/lib3mf_resourceidnode.cpp @@ -0,0 +1,63 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CResourceIdNode + +*/ + +#include "lib3mf_resourceidnode.hpp" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_resource.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CResourceIdNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CResourceIdNode::CResourceIdNode( + NMR::PModelImplicitNode pImplicitNode) : CImplicitNode(std::move(pImplicitNode)) +{ +} + +void CResourceIdNode::SetResource(IResource* pResource) +{ + m_pImplicitNode->setModelResourceID(pResource->GetModelResourceID()); +} + +IResource * CResourceIdNode::GetResource() +{ + return new CResource(m_pImplicitNode->getResource()); +} + +IImplicitPort * CResourceIdNode::GetOutputValue() +{ + return FindOutputOrThrow(NMR::OutputNames::value); +} + diff --git a/Source/API/lib3mf_resourceiterator.cpp b/Source/API/lib3mf_resourceiterator.cpp index 4a913e6..7a21aee 100644 --- a/Source/API/lib3mf_resourceiterator.cpp +++ b/Source/API/lib3mf_resourceiterator.cpp @@ -29,6 +29,7 @@ Abstract: This is a stub class definition of CResourceIterator */ #include "lib3mf_resource.hpp" +#include "lib3mf_model.hpp" #include "lib3mf_resourceiterator.hpp" #include "lib3mf_interfaceexception.hpp" @@ -98,7 +99,7 @@ NMR::PModelResource CResourceIterator::GetCurrentResource() IResource * CResourceIterator::GetCurrent () { // Create specific API class - return new CResource(GetCurrentResource()); + return CModel::createIResourceFromModelResource(GetCurrentResource(), true); } IResourceIterator * CResourceIterator::Clone () diff --git a/Source/API/lib3mf_roundnode.cpp b/Source/API/lib3mf_roundnode.cpp new file mode 100644 index 0000000..fcff1e8 --- /dev/null +++ b/Source/API/lib3mf_roundnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CRoundNode + +*/ + +#include "lib3mf_roundnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CRoundNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CRoundNode::CRoundNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_selectnode.cpp b/Source/API/lib3mf_selectnode.cpp new file mode 100644 index 0000000..1c25113 --- /dev/null +++ b/Source/API/lib3mf_selectnode.cpp @@ -0,0 +1,62 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CSelectNode + +*/ + +#include "lib3mf_selectnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CSelectNode +**************************************************************************************************************************/ + +IImplicitPort * CSelectNode::GetInputB() +{ + return FindInputOrThrow(NMR::InputNames::B); +} + +IImplicitPort * CSelectNode::GetInputC() +{ + return FindInputOrThrow(NMR::InputNames::C); +} + +IImplicitPort * CSelectNode::GetInputD() +{ + return FindInputOrThrow(NMR::InputNames::D); +} + +Lib3MF::Impl::CSelectNode::CSelectNode(NMR::PModelImplicitNode pImplicitNode) +: COneInputNode{pImplicitNode} + { + CImplicitNode::m_pImplicitNode = pImplicitNode; + } diff --git a/Source/API/lib3mf_signnode.cpp b/Source/API/lib3mf_signnode.cpp new file mode 100644 index 0000000..5d9a72f --- /dev/null +++ b/Source/API/lib3mf_signnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CSignNode + +*/ + +#include "lib3mf_signnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CSignNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CSignNode::CSignNode(NMR::PModelImplicitNode pImplicitNode) +: COneInputNode{pImplicitNode} + { + CImplicitNode::m_pImplicitNode = pImplicitNode; + } diff --git a/Source/API/lib3mf_sinhnode.cpp b/Source/API/lib3mf_sinhnode.cpp new file mode 100644 index 0000000..4c8011d --- /dev/null +++ b/Source/API/lib3mf_sinhnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CSinhNode + +*/ + +#include "lib3mf_sinhnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CSinhNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CSinhNode::CSinhNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_sinnode.cpp b/Source/API/lib3mf_sinnode.cpp new file mode 100644 index 0000000..ac3f2f7 --- /dev/null +++ b/Source/API/lib3mf_sinnode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CSinNode + +*/ + +#include "lib3mf_sinnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. +#include "lib3mf_oneinputnode.hpp" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CSinNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CSinNode::CSinNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + diff --git a/Source/API/lib3mf_slicestackiterator.cpp b/Source/API/lib3mf_slicestackiterator.cpp index 77ac6c3..a646c94 100644 --- a/Source/API/lib3mf_slicestackiterator.cpp +++ b/Source/API/lib3mf_slicestackiterator.cpp @@ -44,3 +44,8 @@ ISliceStack * CSliceStackIterator::GetCurrentSliceStack () { return new CSliceStack(std::dynamic_pointer_cast(GetCurrentResource())); } + +IResource * CSliceStackIterator::GetCurrent() +{ + return GetCurrentSliceStack(); +} diff --git a/Source/API/lib3mf_sqrtnode.cpp b/Source/API/lib3mf_sqrtnode.cpp new file mode 100644 index 0000000..d3e70da --- /dev/null +++ b/Source/API/lib3mf_sqrtnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CSqrtNode + +*/ + +#include "lib3mf_sqrtnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CSqrtNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CSqrtNode::CSqrtNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_subtractionnode.cpp b/Source/API/lib3mf_subtractionnode.cpp new file mode 100644 index 0000000..63333a8 --- /dev/null +++ b/Source/API/lib3mf_subtractionnode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CSubtractionNode + +*/ + +#include "lib3mf_subtractionnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CSubtractionNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CSubtractionNode::CSubtractionNode( + NMR::PModelImplicitNode pImplicitNode) + : CTwoInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_tanhnode.cpp b/Source/API/lib3mf_tanhnode.cpp new file mode 100644 index 0000000..7d78e0e --- /dev/null +++ b/Source/API/lib3mf_tanhnode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CTanhNode + +*/ + +#include "lib3mf_tanhnode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CTanhNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CTanhNode::CTanhNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_tannode.cpp b/Source/API/lib3mf_tannode.cpp new file mode 100644 index 0000000..d9b29e8 --- /dev/null +++ b/Source/API/lib3mf_tannode.cpp @@ -0,0 +1,47 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CTanNode + +*/ + +#include "lib3mf_tannode.hpp" + +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CTanNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CTanNode::CTanNode(NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_texture2dgroupiterator.cpp b/Source/API/lib3mf_texture2dgroupiterator.cpp index aaa3ec5..e5ee0a2 100644 --- a/Source/API/lib3mf_texture2dgroupiterator.cpp +++ b/Source/API/lib3mf_texture2dgroupiterator.cpp @@ -45,3 +45,7 @@ ITexture2DGroup * CTexture2DGroupIterator::GetCurrentTexture2DGroup() return new CTexture2DGroup(std::dynamic_pointer_cast(GetCurrentResource())); } +IResource * CTexture2DGroupIterator::GetCurrent() +{ + return GetCurrentTexture2DGroup(); +} diff --git a/Source/API/lib3mf_texture2diterator.cpp b/Source/API/lib3mf_texture2diterator.cpp index 3af9bec..58408e7 100644 --- a/Source/API/lib3mf_texture2diterator.cpp +++ b/Source/API/lib3mf_texture2diterator.cpp @@ -47,3 +47,8 @@ ITexture2D * CTexture2DIterator::GetCurrentTexture2D () return new CTexture2D(std::dynamic_pointer_cast(GetCurrentResource())); } +IResource * CTexture2DIterator::GetCurrent() +{ + return GetCurrentTexture2D(); +} + diff --git a/Source/API/lib3mf_transposenode.cpp b/Source/API/lib3mf_transposenode.cpp new file mode 100644 index 0000000..ae4705e --- /dev/null +++ b/Source/API/lib3mf_transposenode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CTransposeNode + +*/ + +#include "lib3mf_transposenode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CTransposeNode +**************************************************************************************************************************/ + +Lib3MF::Impl::CTransposeNode::CTransposeNode( + NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_triangleset.cpp b/Source/API/lib3mf_triangleset.cpp new file mode 100644 index 0000000..7c84df6 --- /dev/null +++ b/Source/API/lib3mf_triangleset.cpp @@ -0,0 +1,161 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CMeshObject + +*/ +#include "lib3mf_triangleset.hpp" +#include "lib3mf_interfaceexception.hpp" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" +#include "Model/Classes/NMR_ModelMeshObject.h" + +#include + +using namespace Lib3MF::Impl; + +CTriangleSet::CTriangleSet(NMR::PModelTriangleSet pTriangleSet, NMR::PModelMeshObject pMeshObject) + : m_pTriangleSet (pTriangleSet), m_pMeshObject (pMeshObject) +{ + if (pTriangleSet.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + if (pMeshObject.get() == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + +} + +CTriangleSet::~CTriangleSet() +{ + +} + +void CTriangleSet::SetName(const std::string& sName) +{ + m_pTriangleSet->setName(sName); +} + +std::string CTriangleSet::GetName() +{ + return m_pTriangleSet->getName(); +} + +void CTriangleSet::SetIdentifier(const std::string& sIdentifier) +{ + m_pTriangleSet->setIdentifier(sIdentifier); +} + +std::string CTriangleSet::GetIdentifier() +{ + return m_pTriangleSet->getIdentifier(); +} + +void CTriangleSet::AddTriangle(const Lib3MF_uint32 nTriangleIndex) +{ + m_pTriangleSet->addTriangle(nTriangleIndex); +} + +void CTriangleSet::RemoveTriangle(const Lib3MF_uint32 nTriangleIndex) +{ + m_pTriangleSet->removeTriangle(nTriangleIndex); +} + +void CTriangleSet::Clear() +{ + m_pTriangleSet->clear(); +} + +void CTriangleSet::SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) +{ + if (pTriangleIndicesBuffer) { + m_pTriangleSet->clear(); + const uint32_t* pPtr = pTriangleIndicesBuffer; + for (uint64_t nIndex = 0; nIndex < nTriangleIndicesBufferSize; nIndex++) { + m_pTriangleSet->addTriangle(*pPtr); + pPtr++; + } + } +} + +void CTriangleSet::GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64 * pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + auto triangleIndicesSet = m_pTriangleSet->getTriangles(); + Lib3MF_uint32 count = (Lib3MF_uint32)triangleIndicesSet.size(); + if (pTriangleIndicesNeededCount) + *pTriangleIndicesNeededCount = count; + + if (nTriangleIndicesBufferSize >= count && pTriangleIndicesBuffer) + { + Lib3MF_uint32* pIndex = pTriangleIndicesBuffer; + for (auto index : triangleIndicesSet) + { + *pIndex = index; + pIndex++; + } + } +} + +void CTriangleSet::AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) +{ + if (pTriangleIndicesBuffer) { + const uint32_t* pPtr = pTriangleIndicesBuffer; + for (uint64_t nIndex = 0; nIndex < nTriangleIndicesBufferSize; nIndex++) { + m_pTriangleSet->addTriangle(*pPtr); + pPtr++; + } + } + +} + +void CTriangleSet::Merge(ITriangleSet* pOtherTriangleSet, const bool bDeleteOther) +{ + if (pOtherTriangleSet == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + auto pOtherTriangleSetInstance = dynamic_cast (pOtherTriangleSet); + if (pOtherTriangleSetInstance == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + m_pTriangleSet->merge (pOtherTriangleSetInstance->triangleSet()); + + if (bDeleteOther) + pOtherTriangleSet->DeleteSet(); +} + +void CTriangleSet::DeleteSet() +{ + m_pMeshObject->deleteTriangleSet (m_pTriangleSet.get ()); +} + +ITriangleSet* CTriangleSet::Duplicate(const std::string& sIdentifier) +{ + return new CTriangleSet(m_pTriangleSet->duplicate (sIdentifier), m_pMeshObject); +} + +NMR::PModelTriangleSet CTriangleSet::triangleSet() +{ + return m_pTriangleSet; +} \ No newline at end of file diff --git a/Source/API/lib3mf_twoinputnode.cpp b/Source/API/lib3mf_twoinputnode.cpp new file mode 100644 index 0000000..ae97e13 --- /dev/null +++ b/Source/API/lib3mf_twoinputnode.cpp @@ -0,0 +1,54 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CTwoInputNode + +*/ + +#include "lib3mf_twoinputnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CTwoInputNode +**************************************************************************************************************************/ + +IImplicitPort * CTwoInputNode::GetInputB() +{ + return FindInput("B"); +} + + +Lib3MF::Impl::CTwoInputNode::CTwoInputNode( + NMR::PModelImplicitNode pImplicitNode) + : COneInputNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_unsignedmeshnode.cpp b/Source/API/lib3mf_unsignedmeshnode.cpp new file mode 100644 index 0000000..6d0f9a9 --- /dev/null +++ b/Source/API/lib3mf_unsignedmeshnode.cpp @@ -0,0 +1,63 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CUnsignedMeshNode + +*/ + +#include "lib3mf_unsignedmeshnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CUnsignedMeshNode +**************************************************************************************************************************/ +CUnsignedMeshNode:: + CUnsignedMeshNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} + +IImplicitPort * CUnsignedMeshNode::GetInputMesh() +{ + return FindInputOrThrow(NMR::InputNames::mesh); +} + +IImplicitPort * CUnsignedMeshNode::GetInputPos() +{ + return FindInputOrThrow(NMR::InputNames::pos); +} + +IImplicitPort * CUnsignedMeshNode::GetOutputDistance() +{ + return FindOutputOrThrow(NMR::OutputNames::distance); +} + diff --git a/Source/API/lib3mf_utils.cpp b/Source/API/lib3mf_utils.cpp index c58611b..b58e01d 100644 --- a/Source/API/lib3mf_utils.cpp +++ b/Source/API/lib3mf_utils.cpp @@ -57,7 +57,6 @@ sLib3MFTransform Lib3MF::MatrixToTransform(const NMR::NMATRIX3 matrix) return transform; } - eLib3MFEncryptionAlgorithm Lib3MF::translateEncryptionAlgorithm(const NMR::eKeyStoreEncryptAlgorithm algorithm) { if (NMR::eKeyStoreEncryptAlgorithm::AES256_GCM == algorithm) return eLib3MFEncryptionAlgorithm::AES256_GCM; @@ -80,8 +79,6 @@ NMR::eKeyStoreWrapAlgorithm Lib3MF::translateWrappingAlgorithm(const eLib3MFWrap throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); } - - eLib3MFCompression Lib3MF::translateCompression(bool compression) { if (compression) return eLib3MFCompression::Deflate; @@ -90,4 +87,4 @@ eLib3MFCompression Lib3MF::translateCompression(bool compression) { bool Lib3MF::translateCompression(const eLib3MFCompression compression) { return eLib3MFCompression::Deflate == compression; -} \ No newline at end of file +} diff --git a/Source/API/lib3mf_vectorfromscalarnode.cpp b/Source/API/lib3mf_vectorfromscalarnode.cpp new file mode 100644 index 0000000..2f313a7 --- /dev/null +++ b/Source/API/lib3mf_vectorfromscalarnode.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2023 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CVectorFromScalarNode + +*/ + +#include "lib3mf_vectorfromscalarnode.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CVectorFromScalarNode +**************************************************************************************************************************/ + +CVectorFromScalarNode:: + CVectorFromScalarNode(NMR::PModelImplicitNode pImplicitNode) + : CImplicitNode{pImplicitNode} +{ + CImplicitNode::m_pImplicitNode = pImplicitNode; +} diff --git a/Source/API/lib3mf_volumedata.cpp b/Source/API/lib3mf_volumedata.cpp new file mode 100644 index 0000000..adac4da --- /dev/null +++ b/Source/API/lib3mf_volumedata.cpp @@ -0,0 +1,161 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CVolumeData + +*/ + +#include "lib3mf_volumedata.hpp" +#include "lib3mf_interfaceexception.hpp" + +#include "lib3mf_volumedataproperty.hpp" +#include "lib3mf_volumedatacolor.hpp" +#include "lib3mf_volumedatacomposite.hpp" + +// Include custom headers here. +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_ModelFunction.h" + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CVolumeData +**************************************************************************************************************************/ + + +CVolumeData::CVolumeData(NMR::PModelResource pResource) + : CResource(pResource) +{ + if (!pResource.get()) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + + m_pVolumeData = std::dynamic_pointer_cast(pResource); + if (!m_pVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); +} + + +IVolumeDataComposite * CVolumeData::GetComposite() +{ + auto pComposite = m_pVolumeData->getComposite(); + if (!pComposite) { + return nullptr; + } + return new CVolumeDataComposite(pComposite); +} + +IVolumeDataComposite * CVolumeData::CreateNewComposite() +{ + auto pComposite = m_pVolumeData->createComposite(); + if (!pComposite) { + return nullptr; + } + return new CVolumeDataComposite(pComposite); +} + +void CVolumeData::RemoveComposite() +{ + m_pVolumeData->removeComposite(); +} + +IVolumeDataColor * CVolumeData::GetColor() +{ + auto pColor = m_pVolumeData->getColor(); + if (!pColor) { + return nullptr; + } + return new CVolumeDataColor(pColor); +} + +void CVolumeData::RemoveColor() +{ + m_pVolumeData->removeColor(); +} + +Lib3MF_uint32 CVolumeData::GetPropertyCount() +{ + return m_pVolumeData->getPropertyCount(); +} + +IVolumeDataProperty * CVolumeData::GetProperty(const Lib3MF_uint32 nIndex) +{ + NMR::PVolumeDataProperty pProperty = m_pVolumeData->getProperty(nIndex); + if (!pProperty) { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + return new CVolumeDataProperty(pProperty); +} + +void CVolumeData::RemoveProperty(const Lib3MF_uint32 nIndex) +{ + auto pProperty = m_pVolumeData->getProperty(nIndex); + if (!pProperty) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + m_pVolumeData->removeProperty(pProperty->getName()); +} + + +IVolumeDataColor* Lib3MF::Impl::CVolumeData::CreateNewColor( + IFunction* pTheFunction) +{ + NMR::CModel* pModel = m_pVolumeData->getModel(); + + NMR::PModelResource pResource = pModel->findResource(pTheFunction->GetUniqueResourceID()); + NMR::PModelFunction pFunction = std::dynamic_pointer_cast(pResource); + + if (!pFunction) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + + NMR::PVolumeDataColor pColor = m_pVolumeData->createColor(pFunction); + if(!pColor) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + return new CVolumeDataColor(pColor); +} + +IVolumeDataProperty * Lib3MF::Impl::CVolumeData::AddPropertyFromFunction(const std::string & sName, IFunction * pTheFunction) +{ + NMR::CModel* pModel = m_pVolumeData->getModel(); + + NMR::PModelResource pResource = pModel->findResource(pTheFunction->GetUniqueResourceID()); + NMR::PModelFunction pFunction = std::dynamic_pointer_cast(pResource); + + if (!pFunction) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + + NMR::PVolumeDataProperty pProperty = m_pVolumeData->addProperty(sName, pFunction); + if(!pProperty) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + } + return new CVolumeDataProperty(pProperty); +} diff --git a/Source/API/lib3mf_volumedatacolor.cpp b/Source/API/lib3mf_volumedatacolor.cpp new file mode 100644 index 0000000..f6c6c2a --- /dev/null +++ b/Source/API/lib3mf_volumedatacolor.cpp @@ -0,0 +1,48 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CVolumeDataColor + +*/ + +#include "lib3mf_volumedatacolor.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CVolumeDataColor +**************************************************************************************************************************/ + +CVolumeDataColor::CVolumeDataColor(NMR::PVolumeDataColor pColor) + : CFunctionReference(pColor) +{ + +} + diff --git a/Source/API/lib3mf_volumedatacomposite.cpp b/Source/API/lib3mf_volumedatacomposite.cpp new file mode 100644 index 0000000..0a73086 --- /dev/null +++ b/Source/API/lib3mf_volumedatacomposite.cpp @@ -0,0 +1,84 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CVolumeDataComposite + +*/ + +#include "lib3mf_volumedatacomposite.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CVolumeDataComposite +**************************************************************************************************************************/ + +CVolumeDataComposite::CVolumeDataComposite(NMR::PVolumeDataComposite pComposite): + m_pVolumeDataComposite(pComposite) +{ + +} + +NMR::PVolumeDataComposite CVolumeDataComposite::volumeDataComposite() +{ + if (!m_pVolumeDataComposite) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM); + return m_pVolumeDataComposite; +} + +IBaseMaterialGroup * CVolumeDataComposite::GetBaseMaterialGroup() +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +void CVolumeDataComposite::SetBaseMaterialGroup(IBaseMaterialGroup* pBaseMaterialGroupInstance) +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +Lib3MF_uint32 CVolumeDataComposite::GetMaterialMappingCount() +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +IMaterialMapping * CVolumeDataComposite::GetMaterialMapping(const Lib3MF_uint32 nIndex) +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +IMaterialMapping * CVolumeDataComposite::AddMaterialMapping(const Lib3MF::sTransform Transform) +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + +void CVolumeDataComposite::RemoveMaterialMapping(const Lib3MF_uint32 nIndex) +{ + throw ELib3MFInterfaceException(LIB3MF_ERROR_NOTIMPLEMENTED); +} + diff --git a/Source/API/lib3mf_volumedataproperty.cpp b/Source/API/lib3mf_volumedataproperty.cpp new file mode 100644 index 0000000..68f2fce --- /dev/null +++ b/Source/API/lib3mf_volumedataproperty.cpp @@ -0,0 +1,69 @@ +/*++ + +Copyright (C) 2019 3MF Consortium (Original Author) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: This is a stub class definition of CVolumeDataProperty + +*/ + +#include "lib3mf_volumedataproperty.hpp" +#include "lib3mf_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace Lib3MF::Impl; + +/************************************************************************************************************************* + Class definition of CVolumeDataProperty +**************************************************************************************************************************/ + +CVolumeDataProperty::CVolumeDataProperty(NMR::PVolumeDataProperty pProperty) + : CFunctionReference(pProperty) +{ +} + +NMR::PVolumeDataProperty CVolumeDataProperty::asVolumeDataProperty() +{ + NMR::PVolumeDataProperty pProperty = std::dynamic_pointer_cast(m_pFunctionReference); + if (pProperty) + return pProperty; + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); +} + +std::string CVolumeDataProperty::GetName() +{ + return asVolumeDataProperty()->getName(); +} + +void CVolumeDataProperty::SetIsRequired(const bool bIsRequired) +{ + asVolumeDataProperty()->setIsRequired(bIsRequired); +} + +bool CVolumeDataProperty::IsRequired() +{ + return asVolumeDataProperty()->isRequired(); +} \ No newline at end of file diff --git a/Source/API/lib3mf_writer.cpp b/Source/API/lib3mf_writer.cpp index 33b26c4..27d4ac9 100644 --- a/Source/API/lib3mf_writer.cpp +++ b/Source/API/lib3mf_writer.cpp @@ -213,7 +213,9 @@ void Lib3MF::Impl::CWriter::AddKeyWrappingCallback(const std::string & sConsumer if (result == 0) throw ELib3MFInterfaceException(LIB3MF_ERROR_CALCULATIONABORTED); - cipher.resize(needed, 0); + if (needed > LIB3MF_WRITER_MAXKEYSIZE) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDKEYSIZE); + cipher.resize((size_t)needed, 0); result = 0; (*pTheCallback)(entityHandle, plain.size(), plain.data(), plain.size(), diff --git a/Source/Common/Graph/DirectedGraph.cpp b/Source/Common/Graph/DirectedGraph.cpp new file mode 100644 index 0000000..a37614c --- /dev/null +++ b/Source/Common/Graph/DirectedGraph.cpp @@ -0,0 +1,103 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification,276529 are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Common/Graph/DirectedGraph.h" + +#include + +namespace NMR::common::graph +{ + DirectedGraph::DirectedGraph(size_t const size) + : IDirectedGraph(size), + m_size(size), + m_graphData((m_size + 1) * (m_size + 1), false) + { + } + + void DirectedGraph::addDependency(Identifier id, Identifier idOfDependency) + { + if(id == idOfDependency) + { + return; + } + auto const index = id * m_size + idOfDependency; + m_graphData[index] = true; + } + + void DirectedGraph::removeDependency(Identifier id, + Identifier idOfDependency) + { + auto const index = id * m_size + idOfDependency; + m_graphData[index] = false; + } + + bool DirectedGraph::isDirectlyDependingOn( + Identifier id, Identifier dependencyInQuestion) const + { + auto const index = id * m_size + dependencyInQuestion; + return m_graphData[index]; + } + + size_t DirectedGraph::getSize() const + { + return m_size; + } + + void DirectedGraph::removeVertex(Identifier id) + { + auto const iterElemToRemove = + std::find(std::begin(m_vertices), std::end(m_vertices), id); + if(iterElemToRemove == std::end(m_vertices)) + { + return; + } + m_vertices.erase(iterElemToRemove); + + for(auto vertex : m_vertices) + { + removeDependency(id, vertex); + removeDependency(vertex, id); + } + } + + auto DirectedGraph::getVertices() const -> const DependencySet& + { + return m_vertices; + } + + void DirectedGraph::addVertex(Identifier id) + { + m_vertices.insert(id); + } + + auto DirectedGraph::hasPredecessors(Identifier id) const -> bool + { + return !m_predecessors[id].empty(); + } +} // namespace NMR::common::graph diff --git a/Source/Common/Graph/GraphAlgorithms.cpp b/Source/Common/Graph/GraphAlgorithms.cpp new file mode 100644 index 0000000..23980d9 --- /dev/null +++ b/Source/Common/Graph/GraphAlgorithms.cpp @@ -0,0 +1,133 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification,276529 +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Common/Graph/GraphAlgorithms.h" +#include "Common/Graph/IDirectedGraph.h" + +#include +#include +#include +#include + +namespace NMR::common::graph +{ + bool isCyclicUtil(const IDirectedGraph & graph, Identifier node, std::vector & visited, std::vector & recStack) + { + if (!visited[node]) + { + visited[node] = true; + recStack[node] = true; + + for (Identifier dep = 0u; dep < static_cast(graph.getSize()); ++dep) + { + if (graph.isDirectlyDependingOn(node, dep)) + { + if (!visited[dep] && isCyclicUtil(graph, dep, visited, recStack)) + { + return true; + } + else if (recStack[dep]) + { + return true; + } + } + } + } + recStack[node] = false; + return false; + } + + bool isCyclic(const IDirectedGraph & graph) + { + std::vector visited(graph.getSize(), false); + std::vector recStack(graph.getSize(), false); + + for (Identifier id = 0u; id < static_cast(graph.getSize()); ++id) + { + if (isCyclicUtil(graph, id, visited, recStack)) + { + return true; + } + } + return false; + } + + VertexList topologicalSort(const IDirectedGraph & graph) + { + if (isCyclic(graph)) + { + return {}; + } + + // tsort based on DFS + enum class NodeType + { + CHILD, + PARENT + }; + std::stack> nodesToVisit; + std::vector visited(graph.getSize(), false); + VertexList topologicalOrder; + + for (Identifier id = 0u; id < static_cast(graph.getSize()); ++id) + { + if (!visited[id]) + { + nodesToVisit.push({NodeType::CHILD, id}); + + while (!nodesToVisit.empty()) + { + auto [nodeType, nodeId] = nodesToVisit.top(); + nodesToVisit.pop(); + + if (nodeType == NodeType::PARENT) + { + topologicalOrder.push_back(nodeId); + continue; + } + + visited[nodeId] = true; + nodesToVisit.push({NodeType::PARENT, nodeId}); + + for (Identifier dep = 0u; dep < static_cast(graph.getSize()); ++dep) + { + if (!visited[dep]) + { + if (graph.isDirectlyDependingOn(nodeId, dep)) + { + nodesToVisit.push({NodeType::CHILD, dep}); + } + } + } + + } + } + } + return topologicalOrder; + } +} // namespace gladius::nodes::graph diff --git a/Source/Common/Mesh/NMR_BeamLattice.cpp b/Source/Common/Mesh/NMR_BeamLattice.cpp index ae5a4f1..00a1b59 100644 --- a/Source/Common/Mesh/NMR_BeamLattice.cpp +++ b/Source/Common/Mesh/NMR_BeamLattice.cpp @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Abstract: -NMR_MeshBeamLattice.h implements the class CMeshBeamLattice. +NMR_MeshBeamLattice.cpp implements the class CMeshBeamLattice. --*/ diff --git a/Source/Common/Mesh/NMR_Mesh.cpp b/Source/Common/Mesh/NMR_Mesh.cpp index b02d3dc..e2fdb20 100644 --- a/Source/Common/Mesh/NMR_Mesh.cpp +++ b/Source/Common/Mesh/NMR_Mesh.cpp @@ -547,7 +547,7 @@ namespace NMR { try { addBall(getNode(ballData[iBall].m_nodeindex), ballData[iBall].m_radius); } - catch (CNMRException) {} + catch (CNMRException &) {} } delete [] ballData; diff --git a/Source/Common/Mesh/NMR_VolumeDataBoundary.cpp b/Source/Common/Mesh/NMR_VolumeDataBoundary.cpp new file mode 100644 index 0000000..8a26874 --- /dev/null +++ b/Source/Common/Mesh/NMR_VolumeDataBoundary.cpp @@ -0,0 +1,53 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeDataBoundary.cpp implements the class CVolumeDataBoundary. + +--*/ + +#include "Common/Mesh/NMR_VolumeDataBoundary.h" +#include "Model/Classes/NMR_ModelFunction.h" + +namespace NMR { + + CVolumeDataBoundary::CVolumeDataBoundary(PModelFunction pFunction) + : CFunctionReference(pFunction) + { + + } + + bool CVolumeDataBoundary::getMeshBBoxOnly() + { + return m_meshBBoxOnly; + } + + void CVolumeDataBoundary::setMeshBBoxOnly(bool bMeshBBoxOnly) + { + m_meshBBoxOnly = bMeshBBoxOnly; + } +} diff --git a/Source/Common/Mesh/NMR_VolumeDataColor.cpp b/Source/Common/Mesh/NMR_VolumeDataColor.cpp new file mode 100644 index 0000000..47494c3 --- /dev/null +++ b/Source/Common/Mesh/NMR_VolumeDataColor.cpp @@ -0,0 +1,42 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeDataColor.cpp implements the class CVolumeDataColor. + +--*/ + +#include "Common/Mesh/NMR_VolumeDataColor.h" + +namespace NMR { + + CVolumeDataColor::CVolumeDataColor(PModelFunction pFunction) + : CFunctionReference(pFunction) + { + } + +} diff --git a/Source/Common/Mesh/NMR_VolumeDataComposite.cpp b/Source/Common/Mesh/NMR_VolumeDataComposite.cpp new file mode 100644 index 0000000..0148309 --- /dev/null +++ b/Source/Common/Mesh/NMR_VolumeDataComposite.cpp @@ -0,0 +1,74 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeComposite.cpp implements the class CVolumeDataComposite. + +--*/ + +#include "Common/Mesh/NMR_VolumeDataComposite.h" + +namespace NMR { + + CVolumeDataComposite::CVolumeDataComposite() + { + + } + + NMR::PModelBaseMaterialResource CVolumeDataComposite::getBaseMaterialGroup() + { + return m_pBaseMaterialGroup; + } + + void CVolumeDataComposite::setBaseMaterialGroup(PModelBaseMaterialResource pBaseMaterialGroup) + { + m_pBaseMaterialGroup = pBaseMaterialGroup; + } + + nfUint32 CVolumeDataComposite::materialMappingCount() const + { + return (nfUint32)m_vctFunctionReferences.size(); + } + + PFunctionReference CVolumeDataComposite::getMaterialMapping(nfUint32 nIndex) + { + if (nIndex >= materialMappingCount()) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + return m_vctFunctionReferences[nIndex]; + } + + PFunctionReference CVolumeDataComposite::addMaterialMapping(PModelFunction pFunction) + { + PFunctionReference pFunctionReference = std::make_shared(pFunction); + m_vctFunctionReferences.push_back(pFunctionReference); + return pFunctionReference; + } + + void CVolumeDataComposite::removeMaterialMapping(nfUint32) + {} + +} diff --git a/Source/Common/Mesh/NMR_VolumeDataProperty.cpp b/Source/Common/Mesh/NMR_VolumeDataProperty.cpp new file mode 100644 index 0000000..c41e173 --- /dev/null +++ b/Source/Common/Mesh/NMR_VolumeDataProperty.cpp @@ -0,0 +1,70 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_VolumeDataProperty.cpp implements the class CVolumeDataProperty. + +--*/ + +#include "Common/Mesh/NMR_VolumeDataProperty.h" + +#include "Model/Classes/NMR_ModelFunction.h" + +namespace NMR +{ + + CVolumeDataProperty::CVolumeDataProperty(PModelFunction pFunction) + : CFunctionReference(pFunction), m_sName({}), m_bIsRequired(true) + { + } + + CVolumeDataProperty::CVolumeDataProperty(PModelFunction pFunction, + std::string sName) + : CFunctionReference(pFunction), m_sName(sName), m_bIsRequired(true) + { + } + + std::string CVolumeDataProperty::getName() + { + return m_sName; + } + + void CVolumeDataProperty::setName(std::string sPropertyName) + { + m_sName = sPropertyName; + } + + bool CVolumeDataProperty::isRequired() + { + return m_bIsRequired; + } + + void CVolumeDataProperty::setIsRequired(bool bIsRequired) + { + m_bIsRequired = bIsRequired; + } +} // namespace NMR diff --git a/Source/Common/MeshImport/NMR_MeshImporter_STL.cpp b/Source/Common/MeshImport/NMR_MeshImporter_STL.cpp index f99bbdf..7de693b 100644 --- a/Source/Common/MeshImport/NMR_MeshImporter_STL.cpp +++ b/Source/Common/MeshImport/NMR_MeshImporter_STL.cpp @@ -127,7 +127,7 @@ namespace NMR { std::array aSTLHeader; nfUint32 nFaceCount = 0; - nfUint32 nGlobalColor = 0xffffffff; + // nfUint32 nGlobalColor = 0xffffffff; pStream->readIntoBuffer(&aSTLHeader[0], 80, true); pStream->readIntoBuffer((nfByte*)&nFaceCount, sizeof(nFaceCount), true); @@ -138,14 +138,14 @@ namespace NMR { if (nFaceCount > NMR_MESH_MAXFACECOUNT) throw CNMRException(NMR_ERROR_INVALIDFACECOUNT); - std::string sHeaderString(std::begin(aSTLHeader), std::end(aSTLHeader)); - std::size_t nFound = sHeaderString.find("COLOR="); - if (nFound != std::string::npos) { - if (nFound <= 76) { - nGlobalColor = ((nfUint32)aSTLHeader[nFound + 6]) + (((nfUint32)aSTLHeader[nFound + 7]) << 8) + (((nfUint32)aSTLHeader[nFound + 8]) << 16) + - (((nfUint32)aSTLHeader[nFound + 9]) << 24); - } - } + // std::string sHeaderString(std::begin(aSTLHeader), std::end(aSTLHeader)); + // std::size_t nFound = sHeaderString.find("COLOR="); + // if (nFound != std::string::npos) { + // if (nFound <= 76) { + // nGlobalColor = ((nfUint32)aSTLHeader[nFound + 6]) + (((nfUint32)aSTLHeader[nFound + 7]) << 8) + (((nfUint32)aSTLHeader[nFound + 8]) << 16) + + // (((nfUint32)aSTLHeader[nFound + 9]) << 24); + // } + // } nfUint32 nNodeIdx; MESHNODE * pNodes[3]; @@ -193,7 +193,8 @@ namespace NMR { throw CNMRException(NMR_ERROR_INVALIDCOORDINATES); if (bIsValid) { - MESHFACE * pFace = pMesh->addFace(pNodes[0], pNodes[1], pNodes[2]); + pMesh->addFace(pNodes[0], pNodes[1], pNodes[2]); + // MESHFACE * pFace = pMesh->addFace(pNodes[0], pNodes[1], pNodes[2]); //if (pProperties) { // nfUint32 nRed = (nfUint32) ((nfFloat) (Facet.m_attribute & 0x1f) / (255.0f / 31.0f)); // nfUint32 nGreen = (nfUint32)((nfFloat)((Facet.m_attribute >> 5) & 0x1f) / (255.0f / 31.0f)); diff --git a/Source/Common/MeshInformation/NMR_MeshInformationHandler.cpp b/Source/Common/MeshInformation/NMR_MeshInformationHandler.cpp index dbf223b..791c126 100644 --- a/Source/Common/MeshInformation/NMR_MeshInformationHandler.cpp +++ b/Source/Common/MeshInformation/NMR_MeshInformationHandler.cpp @@ -119,8 +119,10 @@ namespace NMR { { nfInt32 eType; for (eType = emiAbstract; eType < emiLastType; eType++) { - if ((pOtherInfoHandler->m_pLookup[eType]) && (m_pLookup[eType])) - m_pLookup[eType]->cloneDefaultInfosFrom(pOtherInfoHandler->m_pLookup[eType]); + if ((pOtherInfoHandler->m_pLookup[eType]) && (m_pLookup[eType])) { + if (pOtherInfoHandler->m_pLookup[eType]->getDefaultData()) + m_pLookup[eType]->cloneDefaultInfosFrom(pOtherInfoHandler->m_pLookup[eType]); + } } } @@ -128,7 +130,7 @@ namespace NMR { { nfInt32 eType; for (eType = emiAbstract; eType < emiLastType; eType++) { - if ((pOtherInfoHandler->m_pLookup[eType]) && (m_pLookup[eType])) + if ((pOtherInfoHandler->m_pLookup[eType]) && (m_pLookup[eType]) && (m_pLookup[eType]->getDefaultData())) m_pLookup[eType]->cloneFaceInfosFrom(nFaceIdx, pOtherInfoHandler->m_pLookup[eType], nOtherFaceIndex); } } diff --git a/Source/Common/MeshInformation/NMR_MeshInformation_Properties.cpp b/Source/Common/MeshInformation/NMR_MeshInformation_Properties.cpp index 1e55b34..29ca1d3 100644 --- a/Source/Common/MeshInformation/NMR_MeshInformation_Properties.cpp +++ b/Source/Common/MeshInformation/NMR_MeshInformation_Properties.cpp @@ -117,12 +117,16 @@ namespace NMR { void CMeshInformation_Properties::cloneDefaultInfosFrom(_In_ CMeshInformation * pOtherInformation) { + MESHINFORMATION_PROPERTIES* pSourceDefaultData = (MESHINFORMATION_PROPERTIES*)pOtherInformation->getDefaultData(); + if (!pSourceDefaultData) + return; + MESHINFORMATION_PROPERTIES * pTargetDefaultData = (MESHINFORMATION_PROPERTIES*)getDefaultData(); if (!pTargetDefaultData) { setDefaultData((MESHINFORMATIONFACEDATA*)new MESHINFORMATION_PROPERTIES); pTargetDefaultData = (MESHINFORMATION_PROPERTIES*)getDefaultData(); } - MESHINFORMATION_PROPERTIES * pSourceDefaultData = (MESHINFORMATION_PROPERTIES*)pOtherInformation->getDefaultData(); + if (pTargetDefaultData && pSourceDefaultData) { for (nfUint32 j = 0; j < 3; j++) pTargetDefaultData->m_nPropertyIDs[j] = pSourceDefaultData->m_nPropertyIDs[j]; diff --git a/Source/Common/NMR_Exception.cpp b/Source/Common/NMR_Exception.cpp index 607b32d..7d37618 100644 --- a/Source/Common/NMR_Exception.cpp +++ b/Source/Common/NMR_Exception.cpp @@ -36,15 +36,9 @@ Each exception is identified via a global ErrorCode #include namespace NMR { - - CNMRException::CNMRException(_In_ nfError errorcode) : std::exception() + std::string errorCodeToMessage(nfError errorcode) { - m_errorcode = errorcode; - } - - const char * CNMRException::what() const throw () - { - switch (m_errorcode) { + switch (errorcode) { // Success / user interaction (0x0XXX) case NMR_USERABORTED: return "The called function was aborted by the user"; // General error codes (0x1XXX) @@ -128,7 +122,10 @@ namespace NMR { case NMR_ERROR_ZIPCONTAINSINCONSISTENCIES: return "ZIP file contains inconsistencies. It might load with errors or incorrectly."; case NMR_ERROR_XMLNAMESPACEALREADYREGISTERED: return "An XML namespace is already registered."; case NMR_ERROR_XMLPREFIXALREADYREGISTERED: return "An XML prefix is already registered."; - + case NMR_ERROR_COULDNOTINITINFLATE: return "Failed to initialize a zlib buffer"; + case NMR_ERROR_COULDNOTINFLATE: return "Failed to decompress part"; + case NMR_ERROR_COULDNOTINITDEFLATE: return "Failed to initialize a zlib buffer"; + case NMR_ERROR_TOOMANYSLICES: return "Too many slices"; // Unhandled exception case NMR_ERROR_GENERICEXCEPTION: return NMR_GENERICEXCEPTIONSTRING; @@ -195,6 +192,15 @@ namespace NMR { case NMR_ERROR_INVALIDMESHINFORMATIONDATA: return "Mesh Information Block was not assigned"; case NMR_ERROR_INVALIDMESHINFORMATION: return "Mesh Information Object was not assigned"; case NMR_ERROR_TOOMANYBEAMS: return "The mesh exceeds more than NMR_MESH_MAXBEAMCOUNT (2^31-1, around two billion) beams"; + case NMR_ERROR_TOOMANYBALLS: return "The mesh exceeds more than NMR_MESH_MAXBALLCOUNT (2^31-1, around two billion) balls"; + case NMR_ERROR_INVALIDSLICEPOLYGON: return "Invalid slice polygon index"; + case NMR_ERROR_INVALIDSLICEVERTEX: return "Invalid slice vertex index"; + case NMR_ERROR_DUPLICATETRIANGLESET: return "Duplicate triangle set"; + case NMR_ERROR_TOOMANYTRIANGLESETS: return "Too many triangle sets"; + case NMR_ERROR_TRIANGLESETINVALIDATTRIBUTE: return "Invalid triangle set attribute"; + case NMR_ERROR_TRIANGLESETMISSINGREFERENCEINDEX: return "Missing triangle set reference index"; + case NMR_ERROR_TRIANGLESETNAMEMISSING: return "Triangle set name missing"; + case NMR_ERROR_TRIANGLESETIDENTIFIERMISSING : return "Triangle set identifier missing"; // Model error codes (0x8XXX) case NMR_ERROR_OPCREADFAILED: return "3MF Loading - OPC could not be loaded"; @@ -213,7 +219,7 @@ namespace NMR { case NMR_ERROR_OPCCONTENTTYPEMISMATCH: return "Content type mismatch"; case NMR_ERROR_OPCRELATIONSHIPENUMERATIONFAILED: return "Could not enumerate relationships"; case NMR_ERROR_OPCRELATIONSHIPNOTFOUND: return "Could not find relationship type"; - case NMR_ERROR_OPCRELATIONSHIPNOTUNIQUE: return "Ambiguous relationship type"; + case NMR_ERROR_OPCRELATIONSHIPNOTUNIQUE: return "Relationship type not unique"; case NMR_ERROR_OPCCOULDNOTGETMODELSTREAM: return "Could not get OPC Model Stream"; case NMR_ERROR_CREATEXMLREADERFAILED: return "Could not create XML Reader"; case NMR_ERROR_SETXMLREADERINPUTFAILED: return "Could not set XML reader input"; @@ -402,6 +408,9 @@ namespace NMR { case NMR_ERROR_MODELRESOURCE_IN_DIFFERENT_MODEL: return "Referenced model resource must not be in a different model."; case NMR_ERROR_PATH_NOT_ABSOLUTE: return "A path attribute element is not absolute."; case NMR_ERROR_BEAMSET_IDENTIFIER_NOT_UNIQUE: return "A beamset identifier is not unique."; + case NMR_ERROR_DUPLICATETRANSFORM: return "A transform attribute is duplicated"; + case NMR_ERROR_INVALIDCOMPONENTRESOURCE: return "A component resource is invalid."; + //keystore error codes case NMR_ERROR_KEYSTOREDUPLICATECONSUMER: return "A consumer already exists for this consumerid"; case NMR_ERROR_KEYSTOREDUPLICATECONSUMERID: return "The attribute consumerid is duplicated"; @@ -412,6 +421,7 @@ namespace NMR { case NMR_ERROR_KEYSTOREDUPLICATEACCESSRIGHT: return "An AccessRight already exists for this consumer in a ResourceDataGroup"; case NMR_ERROR_KEYSTOREDUPLICATERESOURCEDATAGROUP: return "A resource data group already exist for this keyuuid"; case NMR_ERROR_KEYSTOREINVALIDALGORITHM: return "The algorithm attribute is invalid"; + case NMR_ERROR_KEYSTOREINVALIDENCODING: return "The keystore element value is not base64 encoded."; case NMR_ERROR_KEYSTOREINVALIDCOMPRESSION: return "The KeyStore ResourceData compression is invalid"; case NMR_ERROR_KEYSTOREINVALIDCIPHERVALUE: return "Invalid CipherValue elment value"; case NMR_ERROR_KEYSTOREINVALIDMGF: return "The mfgalgorithm attribute has invalid value"; @@ -431,6 +441,82 @@ namespace NMR { case NMR_ERROR_KEYSTOREUNSUPPORTEDALGORITHM: return "The algorithm attribute is unsupported"; case NMR_ERROR_KEYSTORETOOMANYELEMENTS: return "Too many elements added to a keystore tree"; + case NMR_ERROR_INVALIDIMAGE3DSIZE: return "Invalid Image3D Size"; + case NMR_ERROR_TOOMANYCHANNELSELECTORS: return "Too many channel selectors"; + case NMR_ERROR_TOOMANYVOLUMETRICCHANNELS: return "Too many volumetric channels"; + case NMR_ERROR_COULDNOTMAPPACKAGEID: return "Could not map package ID"; + case NMR_ERROR_DUPLICATEVOLUMETRICCHANNEL: return "Duplicate volumetric channel"; + case NMR_ERROR_COULDNOTREMOVEVOLUMETRICLAYER: return "Could not remove volumetric layer"; + case NMR_ERROR_COULDNOTREINDEXVOLUMETRICLAYER: return "Could not reindex volumetric layer"; + case NMR_ERROR_COULDNOTREINDEXCHANNELSELECTOR: return "Could not reindex channel selector"; + case NMR_ERROR_DUPLICATEIMAGE3DNAME: return "Duplicate Image3D Name"; + case NMR_ERROR_DUPLICATEIMAGESTACKSIZE: return "Duplicate Image3D Size"; + case NMR_ERROR_DUPLICATEIMAGESTACKSHEETCOUNT: return "Duplicate Image3D Sheet count"; + case NMR_ERROR_MISSINGIMAGESTACKSIZE: return "Missing 3D Image Size"; + case NMR_ERROR_MISSINGIMAGESTACKSHEETCOUNT: return "Missing 3D Image Sheetcount"; + case NMR_ERROR_MISSINGIMAGE3DNAME: return "Missing 3D Image Name"; + case NMR_ERROR_INVALIDIMAGSHEETCOUNT: return "Invalid Image3D Sheet Count"; + case NMR_ERROR_IMAGESHEETNOTFOUND: return "Image 3D Sheet not found"; + case NMR_ERROR_TOOMANYIMAGESHEETS: return "Too many Image3D sheets"; + case NMR_ERROR_MISSINGIMAGE3DSHEETPATH: return "Missing Image3D sheet path"; + case NMR_ERROR_DUPLICATEVOLUMETRICBACKGROUND: return "Duplicate Volumetric Background"; + case NMR_ERROR_INVALIDVOLUMETRICBACKGROUND: return "Invalid Volumetric Background"; + case NMR_ERROR_MISSINGVOLUMETRICDSTCHANNELNAME: return "Missing Volumetric DstChannel Name"; + case NMR_ERROR_MISSINGVOLUMETRICLAYERBLENDMETHOD: return "Missing Volumetric Layer Blend Method"; + case NMR_ERROR_DUPLICATEVOLUMETRICBLENDMETHOD: return "Duplicate Volumetric Blend Method"; + case NMR_ERROR_MISSINGVOLUMETRICLAYERTRANSFORM: return "Missing Volumetric Layer Transform"; + case NMR_ERROR_DUPLICATEVOLUMETRICTRANSFORM: return "Duplicate Volumetric Transform"; + case NMR_ERROR_DUPLICATEVOLUMETRICSRCALPHA: return "Duplicate Volumetric Src Alpha"; + case NMR_ERROR_INVALIDVOLUMETRICSRCALPHA: return "Invalid Volumetric Src Alpha"; + case NMR_ERROR_DUPLICATEVOLUMETRICDSTALPHA: return "Duplicate Volumetric Dst Alpha"; + case NMR_ERROR_INVALIDVOLUMETRICDSTALPHA: return "Invalid Volumetric Dst Alpha"; + case NMR_ERROR_DUPLICATEMASKCHANNELSELECTOR: return "Duplicate Mask Channel Selector"; + case NMR_ERROR_DUPLICATEVOLUMETRICMINVALUE: return "Duplicate Volumetric Min Value"; + case NMR_ERROR_INVALIDVOLUMETRICMINVALUE: return "Invalid Volumetric Min Value"; + case NMR_ERROR_DUPLICATEVOLUMETRICMAXVALUE: return "Duplicate Volumetric Max Value"; + case NMR_ERROR_INVALIDVOLUMETRICMAXVALUE: return "Invalid Volumetric Max Value"; + case NMR_ERROR_MISSINGCHANNELSELECTORID: return "Missing Channel Selector ID"; + case NMR_ERROR_MISSINGCHANNELSELECTORTILESTYLE: return "Missing Channel Selector TileStyle"; + case NMR_ERROR_DUPLICATEVOLUMETRICTILESTYLE: return "Duplicate Volumetric TileStyle"; + case NMR_ERROR_DUPLICATEVOLUMETRICFILTER: return "Duplicate Volumetric Filter"; + case NMR_ERROR_DUPLICATEVOLUMETRICSOURCECHANNEL: return "Duplicate Volumetric Source Channel"; + case NMR_ERROR_DUPLICATEVOLUMETRICDESTINATIONCHANNEL: return "Duplicate Volumetric Destination Channel"; + case NMR_ERROR_DUPLICATEVOLUMEDATABOUNDARY: return "Duplicate VolumeData Levelset"; + case NMR_ERROR_DUPLICATEVOLUMEDATATRANSFORM: return "Duplicate VolumeData Transform"; + case NMR_ERROR_DUPLICATEVOLUMEDATACHANNEL: return "Duplicate VolumeData Channel"; + case NMR_ERROR_DUPLICATEVOLUMEDATAFIELDID: return "Duplicate VolumeData VolumetricStackID"; + case NMR_ERROR_DUPLICATEVOLUMEDATASOLIDTHRESHOLD: return "Duplicate VolumeData Solid Threshold"; + case NMR_ERROR_MISSINGVOLUMEDATACHANNEL: return "Missing VolumeData Channel"; + case NMR_ERROR_MISSINGVOLUMEDATAFIELDID: return "Missing VolumeData VolumetricStackID"; + case NMR_ERROR_INVALIDVOLUMEDATASOLIDTHRESHOLD: return "Invalid VolumeData Solid Threshold"; + case NMR_ERROR_DUPLICATEVOLUMEDATAPROPERTY: return "Duplicate VolumeData Property"; + case NMR_ERROR_MISSINGVOLUMEDATAPROPERTYNAME: return "Missing VolumeData Property"; + case NMR_ERROR_MISSINGVOLUMETRICSRCALPHA: return "Missing Volumetric Source Alpha"; + case NMR_ERROR_MISSINGVOLUMETRICDSTALPHA: return "Missing Volumetric Destination Alpha"; + case NMR_ERROR_MISSING_ATTRIBUTE_SCALARFIELDCOMPOSED: return "Missing attribute in a ScalarFieldComposed element"; + case NMR_ERROR_DUPLICATE_ATTRIBUTE_SCALARFIELDCOMPOSED: return "Duplicate attribute in a ScalarFieldComposed element"; + case NMR_ERROR_MISSING_ATTRIBUTE_VECTOR3DFIELDCOMPOSED: return "Missing attribute in a Vector3DFieldComposed element"; + case NMR_ERROR_DUPLICATE_ATTRIBUTE_VECTOR3DFIELDCOMPOSED: return "Duplicate attribute in a Vector3DFieldComposed element"; + case NMR_ERROR_UNKNOWN_NODETYPE_IMPLICITMODEL: return "Unknown node type in implicit model"; + case NMR_ERROR_IMPLICIT_FUNCTION_INVALID_SOURCE_NODE : return "Invalid source node in implicit function"; + case NMR_ERROR_IMPLICIT_FUNCTION_INVALID_TARGET_NODE : return "Invalid target node in implicit function"; + case NMR_ERROR_IMPLICIT_FUNCTION_INVALID_SOURCE_PORT : return "Invalid source port in implicit function"; + case NMR_ERROR_IMPLICIT_FUNCTION_INVALID_TARGET_PORT : return "Invalid target port in implicit function"; + case NMR_ERROR_IMPLICIT_FUNCTION_INVALID_PORT_TYPE : return "Invalid port type in implicit function"; + case NMR_ERROR_IMPLICIT_PORT_DOES_NOT_EXIST : return "The port does not exist"; + case NMR_ERROR_DUPLICATE_VOLUMEDATA_MESHBBOXONLY : return "Duplicate VolumeData MeshBBoxOnly"; + case NMR_ERROR_DUPLICATE_VOLUMEDATA_MINFEATURESIZE : return "Duplicate VolumeData MinFeatureSize"; + case NMR_ERROR_IMPLICIT_FUNCTION_CYCLIC_GRAPH : return "Cyclic graph in implicit function"; + case NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE : return "Duplicate VolumeData FallbackValue"; + + case NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_FUNCTION_ID: return "Duplicate attribute functionid in levelset element"; + case NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_CHANNEL: return "Duplicate attribute channel in levelset element"; + case NMR_ERROR_DUPLICATE_BOUNDARY_SHAOE_FALLBACKVALUE: return "Duplicate attribute fallbackvalue in levelset element"; + case NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_TRANSFORM: return "Duplicate attribute transform in levelset element"; + case NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_MIN_FEATURE_SIZE: return "Duplicate attribute minfeaturesize in levelset element"; + case NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_FALLBACK_VALUE: return "Duplicate attribute fallbackvalue in levelset element"; + case NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_VOLUME_ID: return "Duplicate attribute volumeid in levelset element"; + // XML Parser Error Constants(0x9XXX) case NMR_ERROR_XMLPARSER_INVALIDATTRIBVALUE: return "Invalid XML attribute value"; case NMR_ERROR_XMLPARSER_INVALIDPARSERESULT: return "Invalid XML parse result"; @@ -474,6 +560,23 @@ namespace NMR { } } + CNMRException::CNMRException(_In_ nfError errorcode) : std::exception(), m_errorcode(errorcode) + { + m_message = errorCodeToMessage(errorcode); + } + + CNMRException::CNMRException(nfError errorcode, + const std::string& message): m_errorcode(errorcode), m_message(message) + { + m_message = errorCodeToMessage(errorcode) + ": " + message; + } + + const char* CNMRException::what() const throw() + { + return m_message.c_str(); + + } + nfError CNMRException::getErrorCode() const { return m_errorcode; diff --git a/Source/Common/NMR_FunctionReference.cpp b/Source/Common/NMR_FunctionReference.cpp new file mode 100644 index 0000000..602d5f5 --- /dev/null +++ b/Source/Common/NMR_FunctionReference.cpp @@ -0,0 +1,108 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +This file implements the CFunctionReference class, which represents a reference +to a function resource in a 3D Manufacturing Format (3MF) file. The class +provides methods for setting and getting the unique resource ID of the +referenced function. + +--*/ + +#include "Common/NMR_FunctionReference.h" + +#include "Model/Classes/NMR_ModelFunction.h" + +namespace NMR +{ + CFunctionReference::CFunctionReference(UniqueResourceID functionResourceId) + : m_pFunctionResourceID(functionResourceId) + { + } + + CFunctionReference::CFunctionReference(PModelFunction pFunction) + : m_pFunctionResourceID( + pFunction ? pFunction->getPackageResourceID()->getUniqueID() : 0) + { + } + + void CFunctionReference::setFunctionResourceID(UniqueResourceID functionID) + { + m_pFunctionResourceID = functionID; + } + + UniqueResourceID CFunctionReference::getFunctionResourceID() const + { + return m_pFunctionResourceID; + } + + void NMR::CFunctionReference::setChannelName(std::string outputPortName) + { + m_outputPortName = std::move(outputPortName); + } + + std::string const& NMR::CFunctionReference::getChannelName() const + { + return m_outputPortName; + } + + void CFunctionReference::setTransform(NMR::NMATRIX3 transform) + { + m_transform = transform; + m_bHasTransform = true; + } + + bool CFunctionReference::hasTransform() const + { + return m_bHasTransform; + } + + NMR::NMATRIX3 CFunctionReference::getTransform() const + { + return m_transform; + } + + void CFunctionReference::setMinFeatureSize(double minFeatureSize) + { + m_minFeatureSize = minFeatureSize; + } + + double CFunctionReference::getMinFeatureSize() const + { + return m_minFeatureSize; + } + + void CFunctionReference::setFallBackValue(double fallBackValue) + { + m_fallBackValue = fallBackValue; + } + + double CFunctionReference::getFallBackValue() const + { + return m_fallBackValue; + } +} // namespace NMR diff --git a/Source/Common/NMR_StringUtils.cpp b/Source/Common/NMR_StringUtils.cpp index a6d37dd..d07b7d3 100644 --- a/Source/Common/NMR_StringUtils.cpp +++ b/Source/Common/NMR_StringUtils.cpp @@ -38,6 +38,7 @@ correctly and Exception-safe #include #include #include +#include namespace NMR { @@ -153,18 +154,24 @@ namespace NMR { __NMRASSERT(pwszValue); nfDouble dResult = 0.0; - // Convert to double and make a input and range check! - nfChar * pEndPtr; + //skip leading whitespaces + for (; *pszValue && *pszValue == ' '; pszValue++); - dResult = strtod(pszValue, &pEndPtr); + // Convert to double and make a input and range check! + auto answer = fast_float::from_chars(pszValue, pszValue + strlen(pszValue), dResult); // Check if any conversion happened - if ((pEndPtr == pszValue) || (!pEndPtr)) + if (answer.ec != std::errc()) + { throw CNMRException(NMR_ERROR_EMPTYSTRINGTODOUBLECONVERSION); - - if ((*pEndPtr != '\0') && (*pEndPtr != ' ')) - throw CNMRException(NMR_ERROR_INVALIDSTRINGTODOUBLECONVERSION); - + } + else if (answer.ptr) // Invalidate comma as decimal separator + { + if (answer.ptr[0] == ',') + { + throw CNMRException(NMR_ERROR_INVALIDSTRINGTODOUBLECONVERSION); + } + } if ((dResult == HUGE_VAL) || (dResult == -HUGE_VAL)) throw CNMRException(NMR_ERROR_STRINGTODOUBLECONVERSIONOUTOFRANGE); diff --git a/Source/Common/NMR_UUID.cpp b/Source/Common/NMR_UUID.cpp index 8fdd0c9..a01f106 100644 --- a/Source/Common/NMR_UUID.cpp +++ b/Source/Common/NMR_UUID.cpp @@ -37,25 +37,34 @@ NMR_UUID.cpp implements a datatype and functions to handle UUIDs #include -#ifdef _WIN32 +#ifdef GUID_WINDOWS #include #include -#else +#endif + +#ifdef GUID_LIBUUID +#include +#endif + +#ifdef GUID_CFUUID +#include +#endif + +#ifdef GUID_CUSTOM #include #endif namespace NMR { -#ifndef _WIN32 - bool CUUID::S_mtwister_initialised = false; + +#ifdef GUID_CUSTOM std::mutex CUUID::S_uuid_gen_mutex; - std::random_device CUUID::S_rand_dev; - std::mt19937 CUUID::S_mtwister; + std::unique_ptr CUUID::S_mtwister; #endif CUUID::CUUID() { -#ifdef _WIN32 +#ifdef GUID_WINDOWS GUID guid; if (CoCreateGuid(&guid) != S_OK) throw CNMRException(NMR_ERROR_UUIDGENERATIONFAILED); @@ -63,23 +72,49 @@ namespace NMR if (StringFromCLSID(guid, &str) != S_OK) throw CNMRException(NMR_ERROR_UUIDGENERATIONFAILED); set(fnUTF16toUTF8(str).c_str()); -#else +#endif + +#ifdef GUID_LIBUUID + uuid_t uuid; + uuid_generate_random(uuid); + char s[37]; + uuid_unparse(uuid, s); + set(std::string(s).c_str()); +#endif + +#ifdef GUID_CFUUID + auto newId = CFUUIDCreate(NULL); + auto bytes = CFUUIDGetUUIDBytes(newId); + CFRelease(newId); + + char out[16*2+3+1+1]; + out[36] = 0; + snprintf(out, 37, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + bytes.byte0, bytes.byte1, bytes.byte2, bytes.byte3, + bytes.byte4, bytes.byte5, + bytes.byte6, bytes.byte7, + bytes.byte8, bytes.byte9, + bytes.byte10, bytes.byte11, bytes.byte12, bytes.byte13, bytes.byte14, bytes.byte15); + set(out); +#endif + +#ifdef GUID_CUSTOM std::lock_guard l_lock(S_uuid_gen_mutex); - if (!S_mtwister_initialised) + if (!S_mtwister) { + S_mtwister.reset(new std::mt19937); + std::random_device rand_dev; // Prepare seed data uint32_t l_seed_data[std::mt19937::state_size]; uint32_t l_cur_time = static_cast(time(nullptr)); for (size_t i = 0; i < std::mt19937::state_size; ++i) { - l_seed_data[i] = S_rand_dev() ^ l_cur_time; + l_seed_data[i] = rand_dev() ^ l_cur_time; } // Init Mersenne Twister pseudo-random generator std::seed_seq l_seed_seq(std::begin(l_seed_data), std::end(l_seed_data)); - S_mtwister.seed(l_seed_seq); - - S_mtwister_initialised = true; + S_mtwister->seed(l_seed_seq); } // generation of a v4 UUID according to https://tools.ietf.org/html/rfc4122#section-4.4 @@ -88,9 +123,9 @@ namespace NMR const nfChar* hexaDec = "0123456789abcdef"; nfChar string[33]; for (int i = 0; i < 32; i++) - string[i] = hexaDec[distHexaDec(S_mtwister)]; + string[i] = hexaDec[distHexaDec(*S_mtwister)]; string[12] = hexaDec[4]; // set version 4 - string[16] = hexaDec[8 + dist4(S_mtwister)]; + string[16] = hexaDec[8 + dist4(*S_mtwister)]; string[32] = 0; set(string); diff --git a/Source/Common/OPC/NMR_OpcPackageContentTypesReader.cpp b/Source/Common/OPC/NMR_OpcPackageContentTypesReader.cpp index f5303c5..adf3a58 100644 --- a/Source/Common/OPC/NMR_OpcPackageContentTypesReader.cpp +++ b/Source/Common/OPC/NMR_OpcPackageContentTypesReader.cpp @@ -193,11 +193,12 @@ namespace NMR { if (sPartName.empty()) throw CNMRException(NMR_ERROR_CONTENTTYPE_EMPTY_PARTNAME); - POpcPackageContentType_Override pRelationShip = std::make_shared(sPartName, sContentType); + std::string sRelativePartName = fnRemoveLeadingPathDelimiter(sPartName); for (auto it : m_Overrides) { - if (it->m_partName == sPartName) + if (it->m_partName == sRelativePartName) throw CNMRException(NMR_ERROR_DUPLICATE_CONTENTTYPE); } + POpcPackageContentType_Override pRelationShip = std::make_shared(sRelativePartName, sContentType); m_Overrides.push_back(pRelationShip); } else { diff --git a/Source/Common/OPC/NMR_OpcPackageWriter.cpp b/Source/Common/OPC/NMR_OpcPackageWriter.cpp index c0112f9..7e2d162 100644 --- a/Source/Common/OPC/NMR_OpcPackageWriter.cpp +++ b/Source/Common/OPC/NMR_OpcPackageWriter.cpp @@ -170,8 +170,10 @@ namespace NMR { auto iOverrideIterator = m_OverrideContentTypes.begin(); while (iOverrideIterator != m_OverrideContentTypes.end()) { + std::string sAbsolutePartName = fnIncludeLeadingPathDelimiter(iOverrideIterator->first); + pXMLWriter->WriteStartElement(nullptr, OPC_CONTENTTYPES_NODE_OVERRIDE, nullptr); - pXMLWriter->WriteAttributeString(nullptr, OPC_CONTENTTYPES_ATTRIB_PARTNAME, nullptr, iOverrideIterator->first.c_str()); + pXMLWriter->WriteAttributeString(nullptr, OPC_CONTENTTYPES_ATTRIB_PARTNAME, nullptr, sAbsolutePartName.c_str()); pXMLWriter->WriteAttributeString(nullptr, OPC_CONTENTTYPES_ATTRIB_CONTENTTYPE, nullptr, iOverrideIterator->second.c_str()); pXMLWriter->WriteEndElement(); diff --git a/Source/Common/Platform/NMR_EncryptionHeader.cpp b/Source/Common/Platform/NMR_EncryptionHeader.cpp index bf7720c..d2e2d74 100644 --- a/Source/Common/Platform/NMR_EncryptionHeader.cpp +++ b/Source/Common/Platform/NMR_EncryptionHeader.cpp @@ -8,7 +8,11 @@ #include "Common/Platform/NMR_ExportStream.h" #include "Common/NMR_Architecture_Utils.h" +#include #include + +#define LIB3MF_MAXENCRYPTIONHEADERSIZE (1UL << 31) + namespace NMR { CEncryptionHeader::CEncryptionHeader(std::vector const & additionalData) @@ -28,18 +32,27 @@ namespace NMR { if (header.Header.majorVersion != 0 || header.Header.minorVersion != 0) throw CNMRException(NMR_ERROR_ENCRYPTEDCONTENTVERSIONUNSUPPORTED); constexpr size_t headerSize = sizeof(header); + + if (header.Header.Length.length < (uint64_t) headerSize) + throw CNMRException(NMR_ERROR_COULDNOTREADENCRYPTEDSTREAM); + if (header.Header.Length.length > LIB3MF_MAXENCRYPTIONHEADERSIZE) + throw CNMRException(NMR_ERROR_COULDNOTREADENCRYPTEDSTREAM); + nfUint32 remainingBytes = header.Header.Length.length - headerSize; if (remainingBytes > 0) { m_rgAdditionalData.resize(remainingBytes, 0); from->readIntoBuffer(m_rgAdditionalData.data(), remainingBytes, true); } - m_nfHeaderSize = header.Header.Length.length; - return m_nfHeaderSize; + m_nfHeaderSize = (size_t) header.Header.Length.length; + return (size_t) m_nfHeaderSize; } size_t CEncryptionHeader::writeTo(PExportStream to) { uEncryptedFileHeader header = { { '%', '3', 'M', 'c', 'F', 0, 0, 0, 0, 0, 0, 0 } }; constexpr size_t headerSize = sizeof(header); m_nfHeaderSize = (nfUint32)(headerSize + m_rgAdditionalData.size()); + if (m_nfHeaderSize > LIB3MF_MAXENCRYPTIONHEADERSIZE) + throw CNMRException(NMR_ERROR_COULDNOTWRITESTREAM); + header.Header.Length.length = (nfUint32)m_nfHeaderSize; if (isBigEndian()) { header.Header.Length.length = swapBytes(header.Header.Length.length); @@ -47,7 +60,7 @@ namespace NMR { to->writeBuffer(header.bytes, headerSize); if (m_rgAdditionalData.size() > 0) to->writeBuffer(m_rgAdditionalData.data(), m_rgAdditionalData.size()); - return m_nfHeaderSize; + return (size_t)m_nfHeaderSize; } std::vector const & CEncryptionHeader::additionalData() const { return m_rgAdditionalData; diff --git a/Source/Common/Platform/NMR_ExportStream_Compressed.cpp b/Source/Common/Platform/NMR_ExportStream_Compressed.cpp index e4b7453..759b236 100644 --- a/Source/Common/Platform/NMR_ExportStream_Compressed.cpp +++ b/Source/Common/Platform/NMR_ExportStream_Compressed.cpp @@ -44,7 +44,8 @@ namespace NMR { m_strm.zalloc = Z_NULL; m_strm.zfree = Z_NULL; m_strm.opaque = Z_NULL; - if (deflateInit(&m_strm, Z_DEFAULT_COMPRESSION) != Z_OK) + + if (deflateInit2(&m_strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) throw CNMRException(NMR_ERROR_COULDNOTINITDEFLATE); } diff --git a/Source/Common/Platform/NMR_ExportStream_Encrypted.cpp b/Source/Common/Platform/NMR_ExportStream_Encrypted.cpp index 16c28be..a62e063 100644 --- a/Source/Common/Platform/NMR_ExportStream_Encrypted.cpp +++ b/Source/Common/Platform/NMR_ExportStream_Encrypted.cpp @@ -39,7 +39,7 @@ namespace NMR { { nfUint64 encryptedBytes = 0; if (cbTotalBytesToWrite > 0) { - std::vector encryptBuffer(cbTotalBytesToWrite, 0); + std::vector encryptBuffer((size_t) cbTotalBytesToWrite, 0); encryptedBytes = m_pDecryptContext.m_fnCrypt(cbTotalBytesToWrite, (const nfByte *)pBuffer, encryptBuffer.data(), m_pDecryptContext.m_sDekDecryptData); if (encryptedBytes > 0) { auto writtenBytes = m_pEncryptedStream->writeBuffer(encryptBuffer.data(), encryptedBytes); diff --git a/Source/Common/Platform/NMR_ImportStream_Compressed.cpp b/Source/Common/Platform/NMR_ImportStream_Compressed.cpp index 53cbbf8..3c1342c 100644 --- a/Source/Common/Platform/NMR_ImportStream_Compressed.cpp +++ b/Source/Common/Platform/NMR_ImportStream_Compressed.cpp @@ -50,7 +50,7 @@ namespace NMR { m_strm.avail_in = 0; m_strm.next_in = Z_NULL; - if (inflateInit(&m_strm) != Z_OK) + if (inflateInit2(&m_strm, -MAX_WBITS) != Z_OK) throw CNMRException(NMR_ERROR_COULDNOTINITINFLATE); } @@ -128,8 +128,9 @@ namespace NMR { nfUint64 currentPosition = 0; nfUint64 chunkSize = IMPORTSTREAM_READ_BUFFER_CHUNKSIZE; do { - m_decompressedBuffer.resize(m_decompressedBuffer.size() + chunkSize); - bytesRead = readIntoBuffer(&m_decompressedBuffer[currentPosition], chunkSize, false); + m_decompressedBuffer.resize((size_t) m_decompressedBuffer.size() + (size_t) chunkSize); + bytesRead = readIntoBuffer(&m_decompressedBuffer[(size_t)currentPosition], chunkSize, false); + currentPosition += bytesRead; } while (chunkSize == bytesRead); return std::make_shared(m_decompressedBuffer.data(), m_decompressedBuffer.size()); diff --git a/Source/Common/Platform/NMR_ImportStream_Encrypted.cpp b/Source/Common/Platform/NMR_ImportStream_Encrypted.cpp index bdb46be..4d40497 100644 --- a/Source/Common/Platform/NMR_ImportStream_Encrypted.cpp +++ b/Source/Common/Platform/NMR_ImportStream_Encrypted.cpp @@ -60,7 +60,7 @@ namespace NMR { } nfUint64 CImportStream_Encrypted::readIntoBuffer(nfByte * pBuffer, nfUint64 cbTotalBytesToRead, nfBool bNeedsToReadAll) { - std::vector decBuffer(cbTotalBytesToRead, 0); + std::vector decBuffer((size_t)cbTotalBytesToRead, 0); nfUint64 bytesRead = m_pEncryptedStream->readIntoBuffer(decBuffer.data(), cbTotalBytesToRead, bNeedsToReadAll); if (bytesRead > 0) { nfUint64 decryted = m_pDecryptContext.m_fnCrypt(bytesRead, decBuffer.data(), pBuffer, m_pDecryptContext.m_sDekDecryptData); diff --git a/Source/Common/Platform/NMR_ImportStream_Unique_Memory.cpp b/Source/Common/Platform/NMR_ImportStream_Unique_Memory.cpp index 43fd428..e966aa0 100644 --- a/Source/Common/Platform/NMR_ImportStream_Unique_Memory.cpp +++ b/Source/Common/Platform/NMR_ImportStream_Unique_Memory.cpp @@ -35,6 +35,8 @@ This is a platform independent class for keeping data in a memory stream that ow #include "Common/NMR_Exception.h" #include "Common/NMR_Exception_Windows.h" +#include + namespace NMR { CImportStream_Unique_Memory::CImportStream_Unique_Memory() diff --git a/Source/Common/Platform/NMR_ImportStream_ZIP.cpp b/Source/Common/Platform/NMR_ImportStream_ZIP.cpp index 2ef6ba2..589116b 100644 --- a/Source/Common/Platform/NMR_ImportStream_ZIP.cpp +++ b/Source/Common/Platform/NMR_ImportStream_ZIP.cpp @@ -35,7 +35,7 @@ This is a stream class for importing from a libZIP object. #include "Common/Platform/NMR_ImportStream_Unique_Memory.h" #include "Common/NMR_Exception.h" #include "Common/NMR_Exception_Windows.h" -#include +#include #include namespace NMR { diff --git a/Source/Common/Platform/NMR_PortableZIPWriterEntry.cpp b/Source/Common/Platform/NMR_PortableZIPWriterEntry.cpp index 3e07fc8..817b1bf 100644 --- a/Source/Common/Platform/NMR_PortableZIPWriterEntry.cpp +++ b/Source/Common/Platform/NMR_PortableZIPWriterEntry.cpp @@ -34,7 +34,7 @@ NMR_PortableZIPWriterEntry.cpp implements a portable and fast writer of ZIP file #include "Common/Platform/NMR_ExportStream_ZIP.h" #include "Common/NMR_Exception.h" #include "Common/NMR_StringUtils.h" -#include "Libraries/zlib/zlib.h" +#include "zlib.h" namespace NMR { diff --git a/Source/Libraries/cpp-base64/base64.cpp b/Source/Libraries/cpp-base64/base64.cpp index 82a175a..7666ef8 100644 --- a/Source/Libraries/cpp-base64/base64.cpp +++ b/Source/Libraries/cpp-base64/base64.cpp @@ -1,11 +1,13 @@ -/* +/* base64.cpp and base64.h base64 encoding and decoding with C++. + More information at + https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp - Version: 1.01.00 + Version: 2.rc.08 (release candidate) - Copyright (C) 2004-2017 René Nyffenegger + Copyright (C) 2004-2017, 2020, 2021 René Nyffenegger This source code is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages @@ -27,99 +29,254 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch - DISCLAIMER - This is a modified version. */ -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" -static const std::string base64_chars = +#include +#include + + // + // Depending on the url parameter in base64_chars, one of + // two sets of base64 characters needs to be chosen. + // They differ in their last two characters. + // +static const char* base64_chars[2] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; + "0123456789" + "+/", + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "-_"}; -static inline bool is_base64(unsigned char c) { - return (isalnum(c) || (c == '+') || (c == '/')); +static unsigned int pos_of_char(const unsigned char chr) { + // + // Return the position of chr within base64_encode() + // + + if (chr >= 'A' && chr <= 'Z') return chr - 'A'; + else if (chr >= 'a' && chr <= 'z') return chr - 'a' + ('Z' - 'A') + 1; + else if (chr >= '0' && chr <= '9') return chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2; + else if (chr == '+' || chr == '-') return 62; // Be liberal with input and accept both url ('-') and non-url ('+') base 64 characters ( + else if (chr == '/' || chr == '_') return 63; // Ditto for '/' and '_' + else + // + // 2020-10-23: Throw std::exception rather than const char* + //(Pablo Martin-Gomez, https://github.com/Bouska) + // + throw std::runtime_error("Input is not valid base64-encoded data."); } -std::string base64_encode(std::vector const & buffer) { - size_t in_len = buffer.size(); - unsigned char const * bytes_to_encode = buffer.data(); - std::string ret; - int i = 0; - int j = 0; - unsigned char char_array_3[3]; - unsigned char char_array_4[4]; - - while (in_len--) { - char_array_3[i++] = *(bytes_to_encode++); - if (i == 3) { - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for(i = 0; (i <4) ; i++) - ret += base64_chars[char_array_4[i]]; - i = 0; +static std::string insert_linebreaks(std::string str, size_t distance) { + // + // Provided by https://github.com/JomaCorpFX, adapted by me. + // + if (!str.length()) { + return ""; } - } - if (i) - { - for(j = i; j < 3; j++) - char_array_3[j] = '\0'; + size_t pos = distance; - char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - - for (j = 0; (j < i + 1); j++) - ret += base64_chars[char_array_4[j]]; - - while((i++ < 3)) - ret += '='; - - } - - return ret; - -} - -std::vector base64_decode(std::string const& encoded_string) { - size_t in_len = encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - unsigned char char_array_4[4], char_array_3[3]; - std::vector ret; - - while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { - char_array_4[i++] = encoded_string[in_]; in_++; - if (i ==4) { - for (i = 0; i <4; i++) - char_array_4[i] = base64_chars.find(char_array_4[i]) & 0xff; - - char_array_3[0] = ( char_array_4[0] << 2 ) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (i = 0; (i < 3); i++) - ret.push_back(char_array_3[i]); - i = 0; + while (pos < str.size()) { + str.insert(pos, "\n"); + pos += distance + 1; } - } - if (i) { - for (j = 0; j < i; j++) - char_array_4[j] = base64_chars.find(char_array_4[j]) & 0xff; - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - - for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); - } - - return ret; + return str; } + +template +static std::string encode_with_line_breaks(String s) { + return insert_linebreaks(base64_encode(s, false), line_length); +} + +template +static std::string encode_pem(String s) { + return encode_with_line_breaks(s); +} + +template +static std::string encode_mime(String s) { + return encode_with_line_breaks(s); +} + +template +static std::string encode(String s, bool url) { + return base64_encode(reinterpret_cast(s.data()), s.length(), url); +} + +std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, bool url) { + + size_t len_encoded = (in_len +2) / 3 * 4; + + unsigned char trailing_char = url ? '.' : '='; + + // + // Choose set of base64 characters. They differ + // for the last two positions, depending on the url + // parameter. + // A bool (as is the parameter url) is guaranteed + // to evaluate to either 0 or 1 in C++ therefore, + // the correct character set is chosen by subscripting + // base64_chars with url. + // + const char* base64_chars_ = base64_chars[url]; + + std::string ret; + ret.reserve(len_encoded); + + unsigned int pos = 0; + + while (pos < in_len) { + ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0xfc) >> 2]); + + if (pos+1 < in_len) { + ret.push_back(base64_chars_[((bytes_to_encode[pos + 0] & 0x03) << 4) + ((bytes_to_encode[pos + 1] & 0xf0) >> 4)]); + + if (pos+2 < in_len) { + ret.push_back(base64_chars_[((bytes_to_encode[pos + 1] & 0x0f) << 2) + ((bytes_to_encode[pos + 2] & 0xc0) >> 6)]); + ret.push_back(base64_chars_[ bytes_to_encode[pos + 2] & 0x3f]); + } + else { + ret.push_back(base64_chars_[(bytes_to_encode[pos + 1] & 0x0f) << 2]); + ret.push_back(trailing_char); + } + } + else { + + ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0x03) << 4]); + ret.push_back(trailing_char); + ret.push_back(trailing_char); + } + + pos += 3; + } + + + return ret; +} + +template +static std::string decode(String encoded_string, bool remove_linebreaks) { + // + // decode(…) is templated so that it can be used with String = const std::string& + // or std::string_view (requires at least C++17) + // + + if (encoded_string.empty()) return std::string(); + + if (remove_linebreaks) { + + std::string copy(encoded_string); + + copy.erase(std::remove(copy.begin(), copy.end(), '\n'), copy.end()); + + return base64_decode(copy, false); + } + + size_t length_of_string = encoded_string.length(); + size_t pos = 0; + + // + // The approximate length (bytes) of the decoded string might be one or + // two bytes smaller, depending on the amount of trailing equal signs + // in the encoded string. This approximation is needed to reserve + // enough space in the string to be returned. + // + size_t approx_length_of_decoded_string = length_of_string / 4 * 3; + std::string ret; + ret.reserve(approx_length_of_decoded_string); + + while (pos < length_of_string) { + // + // Iterate over encoded input string in chunks. The size of all + // chunks except the last one is 4 bytes. + // + // The last chunk might be padded with equal signs or dots + // in order to make it 4 bytes in size as well, but this + // is not required as per RFC 2045. + // + // All chunks except the last one produce three output bytes. + // + // The last chunk produces at least one and up to three bytes. + // + + size_t pos_of_char_1 = pos_of_char(encoded_string[pos+1] ); + + // + // Emit the first output byte that is produced in each chunk: + // + ret.push_back(static_cast( ( (pos_of_char(encoded_string[pos+0]) ) << 2 ) + ( (pos_of_char_1 & 0x30 ) >> 4))); + + if ( ( pos + 2 < length_of_string ) && // Check for data that is not padded with equal signs (which is allowed by RFC 2045) + encoded_string[pos+2] != '=' && + encoded_string[pos+2] != '.' // accept URL-safe base 64 strings, too, so check for '.' also. + ) + { + // + // Emit a chunk's second byte (which might not be produced in the last chunk). + // + unsigned int pos_of_char_2 = pos_of_char(encoded_string[pos+2] ); + ret.push_back(static_cast( (( pos_of_char_1 & 0x0f) << 4) + (( pos_of_char_2 & 0x3c) >> 2))); + + if ( ( pos + 3 < length_of_string ) && + encoded_string[pos+3] != '=' && + encoded_string[pos+3] != '.' + ) + { + // + // Emit a chunk's third byte (which might not be produced in the last chunk). + // + ret.push_back(static_cast( ( (pos_of_char_2 & 0x03 ) << 6 ) + pos_of_char(encoded_string[pos+3]) )); + } + } + + pos += 4; + } + + return ret; +} + +std::string base64_decode(std::string const& s, bool remove_linebreaks) { + return decode(s, remove_linebreaks); +} + +std::string base64_encode(std::string const& s, bool url) { + return encode(s, url); +} + +std::string base64_encode_pem (std::string const& s) { + return encode_pem(s); +} + +std::string base64_encode_mime(std::string const& s) { + return encode_mime(s); +} + +#if __cplusplus >= 201703L +// +// Interface with std::string_view rather than const std::string& +// Requires C++17 +// Provided by Yannic Bonenberger (https://github.com/Yannic) +// + +std::string base64_encode(std::string_view s, bool url) { + return encode(s, url); +} + +std::string base64_encode_pem(std::string_view s) { + return encode_pem(s); +} + +std::string base64_encode_mime(std::string_view s) { + return encode_mime(s); +} + +std::string base64_decode(std::string_view s, bool remove_linebreaks) { + return decode(s, remove_linebreaks); +} + +#endif // __cplusplus >= 201703L diff --git a/Source/Libraries/libzip/Unix/zip_mkstempm.c b/Source/Libraries/libzip/Unix/zip_mkstempm.c deleted file mode 100644 index 41516d2..0000000 --- a/Source/Libraries/libzip/Unix/zip_mkstempm.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - zip_mkstempm.c -- mkstemp replacement that accepts a mode argument - Copyright (C) 2019-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include - -#include "zipint.h" - -/* - * create temporary file with same permissions as previous one; - * or default permissions if there is no previous file - */ -int -_zip_mkstempm(char *path, int mode) { - int fd; - char *start, *end, *xs; - - int xcnt = 0; - - end = path + strlen(path); - start = end - 1; - while (start >= path && *start == 'X') { - xcnt++; - start--; - } - - if (xcnt == 0) { - errno = EINVAL; - return -1; - } - - start++; - - for (;;) { - zip_uint32_t value = zip_random_uint32(); - - xs = start; - - while (xs < end) { - char digit = value % 36; - if (digit < 10) { - *(xs++) = digit + '0'; - } - else { - *(xs++) = digit - 10 + 'a'; - } - value /= 36; - } - - if ((fd = open(path, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, mode == -1 ? 0666 : (mode_t)mode)) >= 0) { - if (mode != -1) { - /* open() honors umask(), which we don't want in this case */ - (void)chmod(path, (mode_t)mode); - } - return fd; - } - if (errno != EEXIST) { - return -1; - } - } -} diff --git a/Source/Libraries/libzip/Unix/zip_random_unix.c b/Source/Libraries/libzip/Unix/zip_random_unix.c deleted file mode 100644 index 4aa9cc2..0000000 --- a/Source/Libraries/libzip/Unix/zip_random_unix.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - zip_random_unix.c -- fill the user's buffer with random stuff (Unix version) - Copyright (C) 2016-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" - -#ifdef HAVE_CRYPTO -#include "zip_crypto.h" -#endif - -#ifdef HAVE_ARC4RANDOM - -#include - -#ifndef HAVE_SECURE_RANDOM -ZIP_EXTERN bool -zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { - arc4random_buf(buffer, length); - return true; -} -#endif - -#ifndef HAVE_RANDOM_UINT32 -zip_uint32_t -zip_random_uint32(void) { - return arc4random(); -} -#endif - -#else /* HAVE_ARC4RANDOM */ - -#ifndef HAVE_SECURE_RANDOM -#include -#include - -ZIP_EXTERN bool -zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { - int fd; - - if ((fd = open("/dev/urandom", O_RDONLY)) < 0) { - return false; - } - - if (read(fd, buffer, length) != length) { - close(fd); - return false; - } - - close(fd); - return true; -} -#endif - -#ifndef HAVE_RANDOM_UINT32 -#include - -zip_uint32_t -zip_random_uint32(void) { - static bool seeded = false; - - zip_uint32_t value; - - if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) { - return value; - } - - if (!seeded) { - srandom((unsigned int)time(NULL)); - } - - return (zip_uint32_t)random(); -} -#endif - -#endif /* HAVE_ARC4RANDOM */ diff --git a/Source/Libraries/libzip/Unix/zip_source_file_stdio_named.c b/Source/Libraries/libzip/Unix/zip_source_file_stdio_named.c deleted file mode 100644 index 5387c76..0000000 --- a/Source/Libraries/libzip/Unix/zip_source_file_stdio_named.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - zip_source_file_stdio_named.c -- source for stdio file opened by name - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" - -#include "zip_source_file.h" -#include "zip_source_file_stdio.h" - -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_CLONEFILE -#include -#include -#define CAN_CLONE -#endif -#ifdef HAVE_FICLONERANGE -#include -#include -#define CAN_CLONE -#endif - -static zip_int64_t _zip_stdio_op_commit_write(zip_source_file_context_t *ctx); -static zip_int64_t _zip_stdio_op_create_temp_output(zip_source_file_context_t *ctx); -#ifdef CAN_CLONE -static zip_int64_t _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uint64_t offset); -#endif -static bool _zip_stdio_op_open(zip_source_file_context_t *ctx); -static zip_int64_t _zip_stdio_op_remove(zip_source_file_context_t *ctx); -static void _zip_stdio_op_rollback_write(zip_source_file_context_t *ctx); -static char *_zip_stdio_op_strdup(zip_source_file_context_t *ctx, const char *string); -static zip_int64_t _zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len); - -/* clang-format off */ -static zip_source_file_operations_t ops_stdio_named = { - _zip_stdio_op_close, - _zip_stdio_op_commit_write, - _zip_stdio_op_create_temp_output, -#ifdef CAN_CLONE - _zip_stdio_op_create_temp_output_cloning, -#else - NULL, -#endif - _zip_stdio_op_open, - _zip_stdio_op_read, - _zip_stdio_op_remove, - _zip_stdio_op_rollback_write, - _zip_stdio_op_seek, - _zip_stdio_op_stat, - _zip_stdio_op_strdup, - _zip_stdio_op_tell, - _zip_stdio_op_write -}; -/* clang-format on */ - -ZIP_EXTERN zip_source_t * -zip_source_file(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { - if (za == NULL) - return NULL; - - return zip_source_file_create(fname, start, len, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (fname == NULL || length < -1) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - return zip_source_file_common_new(fname, NULL, start, length, NULL, &ops_stdio_named, NULL, error); -} - - -static zip_int64_t -_zip_stdio_op_commit_write(zip_source_file_context_t *ctx) { - if (fclose(ctx->fout) < 0) { - zip_error_set(&ctx->error, ZIP_ER_WRITE, errno); - return -1; - } - if (rename(ctx->tmpname, ctx->fname) < 0) { - zip_error_set(&ctx->error, ZIP_ER_RENAME, errno); - return -1; - } - - return 0; -} - - -static zip_int64_t -_zip_stdio_op_create_temp_output(zip_source_file_context_t *ctx) { - char *temp; - int tfd; - int mode; - FILE *tfp; - struct stat st; - - if ((temp = (char *)malloc(strlen(ctx->fname) + 8)) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); - return -1; - } - - if (stat(ctx->fname, &st) == 0) { - mode = st.st_mode; - } - else { - mode = -1; - } - - sprintf(temp, "%s.XXXXXX", ctx->fname); - - if ((tfd = _zip_mkstempm(temp, mode)) == -1) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - free(temp); - return -1; - } - - if ((tfp = fdopen(tfd, "r+b")) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - close(tfd); - (void)remove(temp); - free(temp); - return -1; - } - - ctx->fout = tfp; - ctx->tmpname = temp; - - return 0; -} - -#ifdef CAN_CLONE -static zip_int64_t -_zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uint64_t offset) { - char *temp; - FILE *tfp; - - if (offset > ZIP_OFF_MAX) { - zip_error_set(&ctx->error, ZIP_ER_SEEK, E2BIG); - return -1; - } - - if ((temp = (char *)malloc(strlen(ctx->fname) + 8)) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); - return -1; - } - sprintf(temp, "%s.XXXXXX", ctx->fname); - -#ifdef HAVE_CLONEFILE -#ifndef __clang_analyzer__ - /* we can't use mkstemp, since clonefile insists on creating the file */ - if (mktemp(temp) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - free(temp); - return -1; - } -#endif - - if (clonefile(ctx->fname, temp, 0) < 0) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - free(temp); - return -1; - } - if ((tfp = _zip_fopen_close_on_exec(temp, true)) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - (void)remove(temp); - free(temp); - return -1; - } -#else - { - int fd; - struct file_clone_range range; - struct stat st; - - if (fstat(fileno(ctx->f), &st) < 0) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - free(temp); - return -1; - } - - if ((fd = mkstemp(temp)) < 0) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - free(temp); - return -1; - } - - range.src_fd = fileno(ctx->f); - range.src_offset = 0; - range.src_length = ((offset + st.st_blksize - 1) / st.st_blksize) * st.st_blksize; - if (range.src_length > st.st_size) { - range.src_length = 0; - } - range.dest_offset = 0; - if (ioctl(fd, FICLONERANGE, &range) < 0) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - (void)close(fd); - (void)remove(temp); - free(temp); - return -1; - } - - if ((tfp = fdopen(fd, "r+b")) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - (void)close(fd); - (void)remove(temp); - free(temp); - return -1; - } - } -#endif - - if (ftruncate(fileno(tfp), (off_t)offset) < 0) { - (void)fclose(tfp); - (void)remove(temp); - free(temp); - return -1; - } - if (fseeko(tfp, (off_t)offset, SEEK_SET) < 0) { - (void)fclose(tfp); - (void)remove(temp); - free(temp); - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - } - - ctx->fout = tfp; - ctx->tmpname = temp; - - return 0; -} -#endif - -static bool -_zip_stdio_op_open(zip_source_file_context_t *ctx) { - if ((ctx->f = _zip_fopen_close_on_exec(ctx->fname, false)) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_OPEN, errno); - return false; - } - return true; -} - - -static zip_int64_t -_zip_stdio_op_remove(zip_source_file_context_t *ctx) { - if (remove(ctx->fname) < 0) { - zip_error_set(&ctx->error, ZIP_ER_REMOVE, errno); - return -1; - } - return 0; -} - - -static void -_zip_stdio_op_rollback_write(zip_source_file_context_t *ctx) { - if (ctx->fout) { - fclose(ctx->fout); - } - (void)remove(ctx->tmpname); -} - -static char * -_zip_stdio_op_strdup(zip_source_file_context_t *ctx, const char *string) { - return strdup(string); -} - - -static zip_int64_t -_zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len) { - size_t ret; - - clearerr((FILE *)ctx->fout); - ret = fwrite(data, 1, len, (FILE *)ctx->fout); - if (ret != len || ferror((FILE *)ctx->fout)) { - zip_error_set(&ctx->error, ZIP_ER_WRITE, errno); - return -1; - } - - return (zip_int64_t)ret; -} diff --git a/Source/Libraries/libzip/Win/zip_source_file_win32.c b/Source/Libraries/libzip/Win/zip_source_file_win32.c deleted file mode 100644 index 6547fc2..0000000 --- a/Source/Libraries/libzip/Win/zip_source_file_win32.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - zip_source_file_win32.c -- read-only Windows file source implementation - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zip_source_file_win32.h" - -static bool _zip_win32_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); - -static bool _zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HANDLE h); - -/* clang-format off */ - -static zip_source_file_operations_t ops_win32_read = { - _zip_win32_op_close, - NULL, - NULL, - NULL, - NULL, - _zip_win32_op_read, - NULL, - NULL, - _zip_win32_op_seek, - _zip_win32_op_stat, - NULL, - _zip_win32_op_tell, - NULL -}; - -/* clang-format on */ - -ZIP_EXTERN zip_source_t * -zip_source_win32handle(zip_t *za, HANDLE h, zip_uint64_t start, zip_int64_t len) { - if (za == NULL) { - return NULL; - } - - return zip_source_win32handle_create(h, start, len, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_win32handle_create(HANDLE h, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (h == INVALID_HANDLE_VALUE || length < -1) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - return zip_source_file_common_new(NULL, h, start, length, NULL, &ops_win32_read, NULL, error); -} - - -void -_zip_win32_op_close(zip_source_file_context_t *ctx) { - CloseHandle((HANDLE)ctx->f); -} - - -zip_int64_t -_zip_win32_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len) { - DWORD i; - - /* TODO: cap len to "DWORD_MAX" */ - if (!ReadFile((HANDLE)ctx->f, buf, (DWORD)len, &i, NULL)) { - zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - return (zip_int64_t)i; -} - - -bool -_zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence) { - LARGE_INTEGER li; - DWORD method; - - switch (whence) { - case SEEK_SET: - method = FILE_BEGIN; - break; - case SEEK_END: - method = FILE_END; - break; - case SEEK_CUR: - method = FILE_CURRENT; - break; - default: - zip_error_set(&ctx->error, ZIP_ER_SEEK, EINVAL); - return -1; - } - - li.QuadPart = (LONGLONG)offset; - if (!SetFilePointerEx((HANDLE)f, li, NULL, method)) { - zip_error_set(&ctx->error, ZIP_ER_SEEK, _zip_win32_error_to_errno(GetLastError())); - return false; - } - - return true; -} - - -static bool -_zip_win32_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) { - return _zip_stat_win32(ctx, st, (HANDLE)ctx->f); -} - - -zip_int64_t -_zip_win32_op_tell(zip_source_file_context_t *ctx, void *f) { - LARGE_INTEGER zero; - LARGE_INTEGER new_offset; - - zero.QuadPart = 0; - if (!SetFilePointerEx((HANDLE)f, zero, &new_offset, FILE_CURRENT)) { - zip_error_set(&ctx->error, ZIP_ER_SEEK, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - return (zip_int64_t)new_offset.QuadPart; -} - - -int -_zip_win32_error_to_errno(DWORD win32err) { - /* Note: This list isn't exhaustive, but should cover common cases. */ - switch (win32err) { - case ERROR_INVALID_PARAMETER: - return EINVAL; - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - return ENOENT; - case ERROR_INVALID_HANDLE: - return EBADF; - case ERROR_ACCESS_DENIED: - return EACCES; - case ERROR_FILE_EXISTS: - return EEXIST; - case ERROR_TOO_MANY_OPEN_FILES: - return EMFILE; - case ERROR_DISK_FULL: - return ENOSPC; - default: - return 10000 + win32err; - } -} - - -static bool -_zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HANDLE h) { - FILETIME mtimeft; - time_t mtime; - LARGE_INTEGER size; - - if (!GetFileTime(h, NULL, NULL, &mtimeft)) { - zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); - return false; - } - if (_zip_filetime_to_time_t(mtimeft, &mtime) < 0) { - zip_error_set(&ctx->error, ZIP_ER_READ, ERANGE); - return false; - } - - st->exists = true; - st->mtime = mtime; - - if (GetFileType(h) == FILE_TYPE_DISK) { - st->regular_file = 1; - - if (!GetFileSizeEx(h, &size)) { - zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); - return false; - } - - st->size = (zip_uint64_t)size.QuadPart; - } - - /* TODO: fill in ctx->attributes */ - - return true; -} - - -bool -_zip_filetime_to_time_t(FILETIME ft, time_t *t) { - /* - Inspired by http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux - */ - const zip_int64_t WINDOWS_TICK = 10000000LL; - const zip_int64_t SEC_TO_UNIX_EPOCH = 11644473600LL; - ULARGE_INTEGER li; - zip_int64_t secs; - time_t temp; - - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; - secs = (li.QuadPart / WINDOWS_TICK - SEC_TO_UNIX_EPOCH); - - temp = (time_t)secs; - if (secs != (zip_int64_t)temp) { - return false; - } - - *t = temp; - return true; -} diff --git a/Source/Libraries/libzip/Win/zip_source_file_win32_named.c b/Source/Libraries/libzip/Win/zip_source_file_win32_named.c deleted file mode 100644 index 1fe5591..0000000 --- a/Source/Libraries/libzip/Win/zip_source_file_win32_named.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - zip_source_file_win32_named.c -- source for Windows file opened by name - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zip_source_file_win32.h" - -static zip_int64_t _zip_win32_named_op_commit_write(zip_source_file_context_t *ctx); -static zip_int64_t _zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx); -static bool _zip_win32_named_op_open(zip_source_file_context_t *ctx); -static zip_int64_t _zip_win32_named_op_remove(zip_source_file_context_t *ctx); -static void _zip_win32_named_op_rollback_write(zip_source_file_context_t *ctx); -static bool _zip_win32_named_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); -static char *_zip_win32_named_op_string_duplicate(zip_source_file_context_t *ctx, const char *string); -static zip_int64_t _zip_win32_named_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len); - -static HANDLE win32_named_open(zip_source_file_context_t *ctx, const char *name, bool temporary, PSECURITY_ATTRIBUTES security_attributes); - -/* clang-format off */ -zip_source_file_operations_t _zip_source_file_win32_named_ops = { - _zip_win32_op_close, - _zip_win32_named_op_commit_write, - _zip_win32_named_op_create_temp_output, - NULL, - _zip_win32_named_op_open, - _zip_win32_op_read, - _zip_win32_named_op_remove, - _zip_win32_named_op_rollback_write, - _zip_win32_op_seek, - _zip_win32_named_op_stat, - _zip_win32_named_op_string_duplicate, - _zip_win32_op_tell, - _zip_win32_named_op_write -}; -/* clang-format on */ - -static zip_int64_t -_zip_win32_named_op_commit_write(zip_source_file_context_t *ctx) { - zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; - DWORD attributes; - - if (!CloseHandle((HANDLE)ctx->fout)) { - zip_error_set(&ctx->error, ZIP_ER_WRITE, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - attributes = file_ops->get_file_attributes(ctx->tmpname); - if (attributes == INVALID_FILE_ATTRIBUTES) { - zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - if (attributes & FILE_ATTRIBUTE_TEMPORARY) { - if (!file_ops->set_file_attributes(ctx->tmpname, attributes & ~FILE_ATTRIBUTE_TEMPORARY)) { - zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - } - - if (!file_ops->move_file(ctx->tmpname, ctx->fname, MOVEFILE_REPLACE_EXISTING)) { - zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - return 0; -} - -static zip_int64_t -_zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx) { - zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; - - zip_uint32_t value, i; - HANDLE th = INVALID_HANDLE_VALUE; - void *temp = NULL; - PSECURITY_DESCRIPTOR psd = NULL; - PSECURITY_ATTRIBUTES psa = NULL; - SECURITY_ATTRIBUTES sa; - SECURITY_INFORMATION si; - DWORD success; - PACL dacl = NULL; - char *tempname = NULL; - size_t tempname_size = 0; - - if ((HANDLE)ctx->f != INVALID_HANDLE_VALUE && GetFileType((HANDLE)ctx->f) == FILE_TYPE_DISK) { - si = DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION; - success = GetSecurityInfo((HANDLE)ctx->f, SE_FILE_OBJECT, si, NULL, NULL, &dacl, NULL, &psd); - if (success == ERROR_SUCCESS) { - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.bInheritHandle = FALSE; - sa.lpSecurityDescriptor = psd; - psa = &sa; - } - } - -#ifndef MS_UWP - value = GetTickCount(); -#else - value = (zip_uint32_t)(GetTickCount64() & 0xffffffff); -#endif - - if ((tempname = file_ops->allocate_tempname(ctx->fname, 10, &tempname_size)) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); - return -1; - } - - for (i = 0; i < 1024 && th == INVALID_HANDLE_VALUE; i++) { - file_ops->make_tempname(tempname, tempname_size, ctx->fname, value + i); - - th = win32_named_open(ctx, tempname, true, psa); - if (th == INVALID_HANDLE_VALUE && GetLastError() != ERROR_FILE_EXISTS) - break; - } - - if (th == INVALID_HANDLE_VALUE) { - free(tempname); - LocalFree(psd); - zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - LocalFree(psd); - ctx->fout = th; - ctx->tmpname = tempname; - - return 0; -} - - -static bool -_zip_win32_named_op_open(zip_source_file_context_t *ctx) { - HANDLE h = win32_named_open(ctx, ctx->fname, false, NULL); - - if (h == INVALID_HANDLE_VALUE) { - return false; - } - - ctx->f = h; - return true; -} - - -static zip_int64_t -_zip_win32_named_op_remove(zip_source_file_context_t *ctx) { - zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; - - if (!file_ops->delete_file(ctx->fname)) { - zip_error_set(&ctx->error, ZIP_ER_REMOVE, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - return 0; -} - - -static void -_zip_win32_named_op_rollback_write(zip_source_file_context_t *ctx) { - zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; - - if (ctx->fout) { - CloseHandle((HANDLE)ctx->fout); - } - file_ops->delete_file(ctx->tmpname); -} - - -static bool -_zip_win32_named_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) { - zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; - - WIN32_FILE_ATTRIBUTE_DATA file_attributes; - - if (!file_ops->get_file_attributes_ex(ctx->fname, GetFileExInfoStandard, &file_attributes)) { - DWORD error = GetLastError(); - if (error == ERROR_FILE_NOT_FOUND) { - st->exists = false; - return true; - } - zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(error)); - return false; - } - - st->exists = true; - st->regular_file = false; - - if (file_attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) { - if ((file_attributes.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT)) == 0) { - st->regular_file = true; - } - } - - if (!_zip_filetime_to_time_t(file_attributes.ftLastWriteTime, &st->mtime)) { - zip_error_set(&ctx->error, ZIP_ER_READ, ERANGE); - return false; - } - st->size = ((zip_uint64_t)file_attributes.nFileSizeHigh << 32) | file_attributes.nFileSizeLow; - - /* TODO: fill in ctx->attributes */ - - return true; -} - - -static char * -_zip_win32_named_op_string_duplicate(zip_source_file_context_t *ctx, const char *string) { - zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; - - return file_ops->string_duplicate(string); -} - - -static zip_int64_t -_zip_win32_named_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len) { - DWORD ret; - if (!WriteFile((HANDLE)ctx->fout, data, (DWORD)len, &ret, NULL) || ret != len) { - zip_error_set(&ctx->error, ZIP_ER_WRITE, _zip_win32_error_to_errno(GetLastError())); - return -1; - } - - return (zip_int64_t)ret; -} - - -static HANDLE -win32_named_open(zip_source_file_context_t *ctx, const char *name, bool temporary, PSECURITY_ATTRIBUTES security_attributes) { - zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; - - DWORD access = GENERIC_READ; - DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; - DWORD creation_disposition = OPEN_EXISTING; - DWORD file_attributes = FILE_ATTRIBUTE_NORMAL; - HANDLE h; - - if (temporary) { - access = GENERIC_READ | GENERIC_WRITE; - share_mode = FILE_SHARE_READ; - creation_disposition = CREATE_NEW; - file_attributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY; - } - - h = file_ops->create_file(name, access, share_mode, security_attributes, creation_disposition, file_attributes, NULL); - - if (h == INVALID_HANDLE_VALUE) { - zip_error_set(&ctx->error, ZIP_ER_OPEN, _zip_win32_error_to_errno(GetLastError())); - } - - return h; -} diff --git a/Source/Libraries/libzip/Win/zip_source_file_win32_utf16.c b/Source/Libraries/libzip/Win/zip_source_file_win32_utf16.c deleted file mode 100644 index 4b5b798..0000000 --- a/Source/Libraries/libzip/Win/zip_source_file_win32_utf16.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - zip_source_file_win32_utf16.c -- source for Windows file opened by UTF-16 name - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zip_source_file_win32.h" - -static char *utf16_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp); -static HANDLE __stdcall utf16_create_file(const char *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file); -static void utf16_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i); -static char *utf16_strdup(const char *string); - -/* clang-format off */ -#ifdef __clang__ -_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wincompatible-function-pointer-types\"") -#endif - -zip_win32_file_operations_t ops_utf16 = { - utf16_allocate_tempname, - utf16_create_file, - DeleteFileW, - GetFileAttributesW, - GetFileAttributesExW, - utf16_make_tempname, - MoveFileExW, - SetFileAttributesW, - utf16_strdup -}; - -#ifdef __clang__ -_Pragma("GCC diagnostic pop") -#endif -/* clang-format on */ - -ZIP_EXTERN zip_source_t * -zip_source_win32w(zip_t *za, const wchar_t *fname, zip_uint64_t start, zip_int64_t len) { - if (za == NULL) - return NULL; - - return zip_source_win32w_create(fname, start, len, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_win32w_create(const wchar_t *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (fname == NULL || length < -1) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - - return zip_source_file_common_new((const char *)fname, NULL, start, length, NULL, &_zip_source_file_win32_named_ops, &ops_utf16, error); -} - - -static char * -utf16_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp) { - *lengthp = wcslen((const wchar_t *)name) + extra_chars; - return (char *)malloc(*lengthp * sizeof(wchar_t)); -} - - -static HANDLE __stdcall utf16_create_file(const char *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file) { -#ifdef MS_UWP - CREATEFILE2_EXTENDED_PARAMETERS extParams = {0}; - extParams.dwFileAttributes = file_attributes; - extParams.dwFileFlags = FILE_FLAG_RANDOM_ACCESS; - extParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; - extParams.dwSize = sizeof(extParams); - extParams.hTemplateFile = template_file; - extParams.lpSecurityAttributes = security_attributes; - - return CreateFile2((const wchar_t *)name, access, share_mode, creation_disposition, &extParams); -#else - return CreateFileW((const wchar_t *)name, access, share_mode, security_attributes, creation_disposition, file_attributes, template_file); -#endif -} - - -static void -utf16_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i) { - _snwprintf((wchar_t *)buf, len, L"%s.%08x", (const wchar_t *)name, i); -} - - -static char * -utf16_strdup(const char *string) { - return (char *)_wcsdup((const wchar_t *)string); -} diff --git a/Source/Libraries/libzip/Win/zip_source_file_win32_utf8.c b/Source/Libraries/libzip/Win/zip_source_file_win32_utf8.c deleted file mode 100644 index d6728e3..0000000 --- a/Source/Libraries/libzip/Win/zip_source_file_win32_utf8.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - zip_source_file_win32_ansi.c -- source for Windows file opened by UTF-8 name - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zip_source_file_win32.h" - -ZIP_EXTERN zip_source_t * -zip_source_file(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { - if (za == NULL) { - return NULL; - } - - return zip_source_file_create(fname, start, len, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - int size; - wchar_t *wfname; - zip_source_t *source; - - if (fname == NULL || length < -1) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - /* Convert fname from UTF-8 to Windows-friendly UTF-16. */ - size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, NULL, 0); - if (size == 0) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - if ((wfname = (wchar_t *)malloc(sizeof(wchar_t) * size)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, wfname, size); - - source = zip_source_win32w_create(wfname, start, length, error); - - free(wfname); - return source; -} diff --git a/Source/Libraries/libzip/zip_add.c b/Source/Libraries/libzip/zip_add.c deleted file mode 100644 index ef04f1e..0000000 --- a/Source/Libraries/libzip/zip_add.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - zip_add.c -- add file via callback function - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -/* - NOTE: Return type is signed so we can return -1 on error. - The index can not be larger than ZIP_INT64_MAX since the size - of the central directory cannot be larger than - ZIP_UINT64_MAX, and each entry is larger than 2 bytes. -*/ - -ZIP_EXTERN zip_int64_t -zip_add(zip_t *za, const char *name, zip_source_t *source) { - return zip_file_add(za, name, source, 0); -} diff --git a/Source/Libraries/libzip/zip_add_dir.c b/Source/Libraries/libzip/zip_add_dir.c deleted file mode 100644 index 9999c8d..0000000 --- a/Source/Libraries/libzip/zip_add_dir.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - zip_add_dir.c -- add directory - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ - -ZIP_EXTERN zip_int64_t -zip_add_dir(zip_t *za, const char *name) { - return zip_dir_add(za, name, 0); -} diff --git a/Source/Libraries/libzip/zip_add_entry.c b/Source/Libraries/libzip/zip_add_entry.c deleted file mode 100644 index 1c9fcff..0000000 --- a/Source/Libraries/libzip/zip_add_entry.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - zip_add_entry.c -- create and init struct zip_entry - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ - -zip_int64_t -_zip_add_entry(zip_t *za) { - zip_uint64_t idx; - - if (za->nentry + 1 >= za->nentry_alloc) { - zip_entry_t *rentries; - zip_uint64_t nalloc = za->nentry_alloc; - zip_uint64_t additional_entries = 2 * nalloc; - zip_uint64_t realloc_size; - - if (additional_entries < 16) { - additional_entries = 16; - } - else if (additional_entries > 1024) { - additional_entries = 1024; - } - /* neither + nor * overflows can happen: nentry_alloc * sizeof(struct zip_entry) < UINT64_MAX */ - nalloc += additional_entries; - realloc_size = sizeof(struct zip_entry) * (size_t)nalloc; - - if (sizeof(struct zip_entry) * (size_t)za->nentry_alloc > realloc_size) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - rentries = (zip_entry_t *)realloc(za->entry, sizeof(struct zip_entry) * (size_t)nalloc); - if (!rentries) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - za->entry = rentries; - za->nentry_alloc = nalloc; - } - - idx = za->nentry++; - - _zip_entry_init(za->entry + idx); - - return (zip_int64_t)idx; -} diff --git a/Source/Libraries/libzip/zip_algorithm_deflate.c b/Source/Libraries/libzip/zip_algorithm_deflate.c deleted file mode 100644 index 99d8a59..0000000 --- a/Source/Libraries/libzip/zip_algorithm_deflate.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - zip_algorithm_deflate.c -- deflate (de)compression routines - Copyright (C) 2017-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" - -#include -#include -#include - -struct ctx { - zip_error_t *error; - bool compress; - int compression_flags; - bool end_of_input; - z_stream zstr; -}; - - -static zip_uint64_t -maximum_compressed_size(zip_uint64_t uncompressed_size) { - /* max deflate size increase: size + ceil(size/16k)*5+6 */ - - zip_uint64_t compressed_size = uncompressed_size + (uncompressed_size + 16383) / 16384 * 5 + 6; - - if (compressed_size < uncompressed_size) { - return ZIP_UINT64_MAX; - } - return compressed_size; -} - - -static void * -allocate(bool compress, int compression_flags, zip_error_t *error) { - struct ctx *ctx; - - if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) { - zip_error_set(error, ZIP_ET_SYS, errno); - return NULL; - } - - ctx->error = error; - ctx->compress = compress; - ctx->compression_flags = compression_flags; - if (ctx->compression_flags < 1 || ctx->compression_flags > 9) { - ctx->compression_flags = Z_BEST_COMPRESSION; - } - ctx->end_of_input = false; - - ctx->zstr.zalloc = Z_NULL; - ctx->zstr.zfree = Z_NULL; - ctx->zstr.opaque = NULL; - - return ctx; -} - - -static void * -compress_allocate(zip_uint16_t method, int compression_flags, zip_error_t *error) { - return allocate(true, compression_flags, error); -} - - -static void * -decompress_allocate(zip_uint16_t method, int compression_flags, zip_error_t *error) { - return allocate(false, compression_flags, error); -} - - -static void -deallocate(void *ud) { - struct ctx *ctx = (struct ctx *)ud; - - free(ctx); -} - - -static zip_uint16_t -general_purpose_bit_flags(void *ud) { - struct ctx *ctx = (struct ctx *)ud; - - if (!ctx->compress) { - return 0; - } - - if (ctx->compression_flags < 3) { - return 2 << 1; - } - else if (ctx->compression_flags > 7) { - return 1 << 1; - } - return 0; -} - - -static bool -start(void *ud, zip_stat_t *st, zip_file_attributes_t *attributes) { - struct ctx *ctx = (struct ctx *)ud; - int ret; - - ctx->zstr.avail_in = 0; - ctx->zstr.next_in = NULL; - ctx->zstr.avail_out = 0; - ctx->zstr.next_out = NULL; - - if (ctx->compress) { - /* negative value to tell zlib not to write a header */ - ret = deflateInit2(&ctx->zstr, ctx->compression_flags, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); - } - else { - ret = inflateInit2(&ctx->zstr, -MAX_WBITS); - } - - if (ret != Z_OK) { - zip_error_set(ctx->error, ZIP_ER_ZLIB, ret); - return false; - } - - - return true; -} - - -static bool -end(void *ud) { - struct ctx *ctx = (struct ctx *)ud; - int err; - - if (ctx->compress) { - err = deflateEnd(&ctx->zstr); - } - else { - err = inflateEnd(&ctx->zstr); - } - - if (err != Z_OK) { - zip_error_set(ctx->error, ZIP_ER_ZLIB, err); - return false; - } - - return true; -} - - -static bool -input(void *ud, zip_uint8_t *data, zip_uint64_t length) { - struct ctx *ctx = (struct ctx *)ud; - - if (length > UINT_MAX || ctx->zstr.avail_in > 0) { - zip_error_set(ctx->error, ZIP_ER_INVAL, 0); - return false; - } - - ctx->zstr.avail_in = (uInt)length; - ctx->zstr.next_in = (Bytef *)data; - - return true; -} - - -static void -end_of_input(void *ud) { - struct ctx *ctx = (struct ctx *)ud; - - ctx->end_of_input = true; -} - - -static zip_compression_status_t -process(void *ud, zip_uint8_t *data, zip_uint64_t *length) { - struct ctx *ctx = (struct ctx *)ud; - - int ret; - - ctx->zstr.avail_out = (uInt)ZIP_MIN(UINT_MAX, *length); - ctx->zstr.next_out = (Bytef *)data; - - if (ctx->compress) { - ret = deflate(&ctx->zstr, ctx->end_of_input ? Z_FINISH : 0); - } - else { - ret = inflate(&ctx->zstr, Z_SYNC_FLUSH); - } - - *length = *length - ctx->zstr.avail_out; - - switch (ret) { - case Z_OK: - return ZIP_COMPRESSION_OK; - - case Z_STREAM_END: - return ZIP_COMPRESSION_END; - - case Z_BUF_ERROR: - if (ctx->zstr.avail_in == 0) { - return ZIP_COMPRESSION_NEED_DATA; - } - - /* fallthrough */ - - default: - zip_error_set(ctx->error, ZIP_ER_ZLIB, ret); - return ZIP_COMPRESSION_ERROR; - } -} - -/* clang-format off */ - -zip_compression_algorithm_t zip_algorithm_deflate_compress = { - maximum_compressed_size, - compress_allocate, - deallocate, - general_purpose_bit_flags, - 20, - start, - end, - input, - end_of_input, - process -}; - - -zip_compression_algorithm_t zip_algorithm_deflate_decompress = { - maximum_compressed_size, - decompress_allocate, - deallocate, - general_purpose_bit_flags, - 20, - start, - end, - input, - end_of_input, - process -}; - -/* clang-format on */ diff --git a/Source/Libraries/libzip/zip_buffer.c b/Source/Libraries/libzip/zip_buffer.c deleted file mode 100644 index 3bfcc82..0000000 --- a/Source/Libraries/libzip/zip_buffer.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - zip_buffer.c -- bounds checked access to memory buffer - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "zipint.h" - -zip_uint8_t * -_zip_buffer_data(zip_buffer_t *buffer) { - return buffer->data; -} - - -void -_zip_buffer_free(zip_buffer_t *buffer) { - if (buffer == NULL) { - return; - } - - if (buffer->free_data) { - free(buffer->data); - } - - free(buffer); -} - - -bool -_zip_buffer_eof(zip_buffer_t *buffer) { - return buffer->ok && buffer->offset == buffer->size; -} - - -zip_uint8_t * -_zip_buffer_get(zip_buffer_t *buffer, zip_uint64_t length) { - zip_uint8_t *data; - - data = _zip_buffer_peek(buffer, length); - - if (data != NULL) { - buffer->offset += length; - } - - return data; -} - - -zip_uint16_t -_zip_buffer_get_16(zip_buffer_t *buffer) { - zip_uint8_t *data = _zip_buffer_get(buffer, 2); - - if (data == NULL) { - return 0; - } - - return (zip_uint16_t)(data[0] + (data[1] << 8)); -} - - -zip_uint32_t -_zip_buffer_get_32(zip_buffer_t *buffer) { - zip_uint8_t *data = _zip_buffer_get(buffer, 4); - - if (data == NULL) { - return 0; - } - - return ((((((zip_uint32_t)data[3] << 8) + data[2]) << 8) + data[1]) << 8) + data[0]; -} - - -zip_uint64_t -_zip_buffer_get_64(zip_buffer_t *buffer) { - zip_uint8_t *data = _zip_buffer_get(buffer, 8); - - if (data == NULL) { - return 0; - } - - return ((zip_uint64_t)data[7] << 56) + ((zip_uint64_t)data[6] << 48) + ((zip_uint64_t)data[5] << 40) + ((zip_uint64_t)data[4] << 32) + ((zip_uint64_t)data[3] << 24) + ((zip_uint64_t)data[2] << 16) + ((zip_uint64_t)data[1] << 8) + (zip_uint64_t)data[0]; -} - - -zip_uint8_t -_zip_buffer_get_8(zip_buffer_t *buffer) { - zip_uint8_t *data = _zip_buffer_get(buffer, 1); - - if (data == NULL) { - return 0; - } - - return data[0]; -} - - -zip_uint64_t -_zip_buffer_left(zip_buffer_t *buffer) { - return buffer->ok ? buffer->size - buffer->offset : 0; -} - - -zip_uint64_t -_zip_buffer_read(zip_buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length) { - if (_zip_buffer_left(buffer) < length) { - length = _zip_buffer_left(buffer); - } - - memcpy(data, _zip_buffer_get(buffer, length), length); - - return length; -} - - -zip_buffer_t * -_zip_buffer_new(zip_uint8_t *data, zip_uint64_t size) { - bool free_data = (data == NULL); - zip_buffer_t *buffer; - - if (data == NULL) { - if ((data = (zip_uint8_t *)malloc(size)) == NULL) { - return NULL; - } - } - - if ((buffer = (zip_buffer_t *)malloc(sizeof(*buffer))) == NULL) { - if (free_data) { - free(data); - } - return NULL; - } - - buffer->ok = true; - buffer->data = data; - buffer->size = size; - buffer->offset = 0; - buffer->free_data = free_data; - - return buffer; -} - - -zip_buffer_t * -_zip_buffer_new_from_source(zip_source_t *src, zip_uint64_t size, zip_uint8_t *buf, zip_error_t *error) { - zip_buffer_t *buffer; - - if ((buffer = _zip_buffer_new(buf, size)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - if (_zip_read(src, buffer->data, size, error) < 0) { - _zip_buffer_free(buffer); - return NULL; - } - - return buffer; -} - - -zip_uint64_t -_zip_buffer_offset(zip_buffer_t *buffer) { - return buffer->ok ? buffer->offset : 0; -} - - -bool -_zip_buffer_ok(zip_buffer_t *buffer) { - return buffer->ok; -} - - -zip_uint8_t * -_zip_buffer_peek(zip_buffer_t *buffer, zip_uint64_t length) { - zip_uint8_t *data; - - if (!buffer->ok || buffer->offset + length < length || buffer->offset + length > buffer->size) { - buffer->ok = false; - return NULL; - } - - data = buffer->data + buffer->offset; - return data; -} - -int -_zip_buffer_put(zip_buffer_t *buffer, const void *src, size_t length) { - zip_uint8_t *dst = _zip_buffer_get(buffer, length); - - if (dst == NULL) { - return -1; - } - - memcpy(dst, src, length); - return 0; -} - - -int -_zip_buffer_put_16(zip_buffer_t *buffer, zip_uint16_t i) { - zip_uint8_t *data = _zip_buffer_get(buffer, 2); - - if (data == NULL) { - return -1; - } - - data[0] = (zip_uint8_t)(i & 0xff); - data[1] = (zip_uint8_t)((i >> 8) & 0xff); - - return 0; -} - - -int -_zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i) { - zip_uint8_t *data = _zip_buffer_get(buffer, 4); - - if (data == NULL) { - return -1; - } - - data[0] = (zip_uint8_t)(i & 0xff); - data[1] = (zip_uint8_t)((i >> 8) & 0xff); - data[2] = (zip_uint8_t)((i >> 16) & 0xff); - data[3] = (zip_uint8_t)((i >> 24) & 0xff); - - return 0; -} - - -int -_zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i) { - zip_uint8_t *data = _zip_buffer_get(buffer, 8); - - if (data == NULL) { - return -1; - } - - data[0] = (zip_uint8_t)(i & 0xff); - data[1] = (zip_uint8_t)((i >> 8) & 0xff); - data[2] = (zip_uint8_t)((i >> 16) & 0xff); - data[3] = (zip_uint8_t)((i >> 24) & 0xff); - data[4] = (zip_uint8_t)((i >> 32) & 0xff); - data[5] = (zip_uint8_t)((i >> 40) & 0xff); - data[6] = (zip_uint8_t)((i >> 48) & 0xff); - data[7] = (zip_uint8_t)((i >> 56) & 0xff); - - return 0; -} - - -int -_zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i) { - zip_uint8_t *data = _zip_buffer_get(buffer, 1); - - if (data == NULL) { - return -1; - } - - data[0] = i; - - return 0; -} - - -int -_zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset) { - if (offset > buffer->size) { - buffer->ok = false; - return -1; - } - - buffer->ok = true; - buffer->offset = offset; - - return 0; -} - - -int -_zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length) { - zip_uint64_t offset = buffer->offset + length; - - if (offset < buffer->offset) { - buffer->ok = false; - return -1; - } - return _zip_buffer_set_offset(buffer, offset); -} - -zip_uint64_t -_zip_buffer_size(zip_buffer_t *buffer) { - return buffer->size; -} diff --git a/Source/Libraries/libzip/zip_close.c b/Source/Libraries/libzip/zip_close.c deleted file mode 100644 index 5bd327b..0000000 --- a/Source/Libraries/libzip/zip_close.c +++ /dev/null @@ -1,700 +0,0 @@ -/* - zip_close.c -- close zip archive and update changes - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -#include -#include -#ifdef _WIN32 -#include -#include -#endif - - -static int add_data(zip_t *, zip_source_t *, zip_dirent_t *, zip_uint32_t); -static int copy_data(zip_t *, zip_uint64_t); -static int copy_source(zip_t *, zip_source_t *, zip_int64_t); -static int write_cdir(zip_t *, const zip_filelist_t *, zip_uint64_t); -static int write_data_descriptor(zip_t *za, const zip_dirent_t *dirent, int is_zip64); - -ZIP_EXTERN int -zip_close(zip_t *za) { - zip_uint64_t i, j, survivors, unchanged_offset; - zip_int64_t off; - int error; - zip_filelist_t *filelist; - int changed; - - if (za == NULL) - return -1; - - changed = _zip_changed(za, &survivors); - - /* don't create zip files with no entries */ - if (survivors == 0) { - if ((za->open_flags & ZIP_TRUNCATE) || changed) { - if (zip_source_remove(za->src) < 0) { - if (!((zip_error_code_zip(zip_source_error(za->src)) == ZIP_ER_REMOVE) && (zip_error_code_system(zip_source_error(za->src)) == ENOENT))) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - } - } - zip_discard(za); - return 0; - } - - if (!changed) { - zip_discard(za); - return 0; - } - - if (survivors > za->nentry) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - return -1; - } - - if ((filelist = (zip_filelist_t *)malloc(sizeof(filelist[0]) * (size_t)survivors)) == NULL) - return -1; - - unchanged_offset = ZIP_UINT64_MAX; - /* create list of files with index into original archive */ - for (i = j = 0; i < za->nentry; i++) { - if (za->entry[i].orig != NULL && ZIP_ENTRY_HAS_CHANGES(&za->entry[i])) { - unchanged_offset = ZIP_MIN(unchanged_offset, za->entry[i].orig->offset); - } - if (za->entry[i].deleted) { - continue; - } - - if (j >= survivors) { - free(filelist); - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - return -1; - } - - filelist[j].idx = i; - j++; - } - if (j < survivors) { - free(filelist); - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - return -1; - } - - if ((zip_source_supports(za->src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE_CLONING)) == 0) { - unchanged_offset = 0; - } - else { - if (unchanged_offset == ZIP_UINT64_MAX) { - /* we're keeping all file data, find the end of the last one */ - zip_uint64_t last_index = ZIP_UINT64_MAX; - unchanged_offset = 0; - - for (i = 0; i < za->nentry; i++) { - if (za->entry[i].orig != NULL) { - if (za->entry[i].orig->offset >= unchanged_offset) { - unchanged_offset = za->entry[i].orig->offset; - last_index = i; - } - } - } - if (last_index != ZIP_UINT64_MAX) { - if ((unchanged_offset = _zip_file_get_end(za, last_index, &za->error)) == 0) { - free(filelist); - return -1; - } - } - } - if (unchanged_offset > 0) { - if (zip_source_begin_write_cloning(za->src, unchanged_offset) < 0) { - /* cloning not supported, need to copy everything */ - unchanged_offset = 0; - } - } - } - if (unchanged_offset == 0) { - if (zip_source_begin_write(za->src) < 0) { - _zip_error_set_from_source(&za->error, za->src); - free(filelist); - return -1; - } - } - - if (_zip_progress_start(za->progress) != 0) { - zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); - zip_source_rollback_write(za->src); - free(filelist); - return -1; - } - error = 0; - for (j = 0; j < survivors; j++) { - int new_data; - zip_entry_t *entry; - zip_dirent_t *de; - - if (_zip_progress_subrange(za->progress, (double)j / (double)survivors, (double)(j + 1) / (double)survivors) != 0) { - zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); - error = 1; - break; - } - - i = filelist[j].idx; - entry = za->entry + i; - - if (entry->orig != NULL && entry->orig->offset < unchanged_offset) { - /* already implicitly copied by cloning */ - continue; - } - - new_data = (ZIP_ENTRY_DATA_CHANGED(entry) || ZIP_ENTRY_CHANGED(entry, ZIP_DIRENT_COMP_METHOD) || ZIP_ENTRY_CHANGED(entry, ZIP_DIRENT_ENCRYPTION_METHOD)); - - /* create new local directory entry */ - if (entry->changes == NULL) { - if ((entry->changes = _zip_dirent_clone(entry->orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - error = 1; - break; - } - } - de = entry->changes; - - if (_zip_read_local_ef(za, i) < 0) { - error = 1; - break; - } - - if ((off = zip_source_tell_write(za->src)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - error = 1; - break; - } - de->offset = (zip_uint64_t)off; - - if (new_data) { - zip_source_t *zs; - - zs = NULL; - if (!ZIP_ENTRY_DATA_CHANGED(entry)) { - if ((zs = _zip_source_zip_new(za, za, i, ZIP_FL_UNCHANGED, 0, 0, NULL)) == NULL) { - error = 1; - break; - } - } - - /* add_data writes dirent */ - if (add_data(za, zs ? zs : entry->source, de, entry->changes ? entry->changes->changed : 0) < 0) { - error = 1; - if (zs) - zip_source_free(zs); - break; - } - if (zs) - zip_source_free(zs); - } - else { - zip_uint64_t offset; - - if (de->encryption_method != ZIP_EM_TRAD_PKWARE) { - /* when copying data, all sizes are known -> no data descriptor needed */ - /* except for PKWare encryption, where removing the data descriptor breaks password validation */ - de->bitflags &= (zip_uint16_t)~ZIP_GPBF_DATA_DESCRIPTOR; - } - if (_zip_dirent_write(za, de, ZIP_FL_LOCAL) < 0) { - error = 1; - break; - } - if ((offset = _zip_file_get_offset(za, i, &za->error)) == 0) { - error = 1; - break; - } - if (zip_source_seek(za->src, (zip_int64_t)offset, SEEK_SET) < 0) { - _zip_error_set_from_source(&za->error, za->src); - error = 1; - break; - } - if (copy_data(za, de->comp_size) < 0) { - error = 1; - break; - } - - if (de->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { - if (write_data_descriptor(za, de, _zip_dirent_needs_zip64(de, 0)) < 0) { - error = 1; - break; - } - } - } - } - - if (!error) { - if (write_cdir(za, filelist, survivors) < 0) - error = 1; - } - - free(filelist); - - if (!error) { - if (zip_source_commit_write(za->src) != 0) { - _zip_error_set_from_source(&za->error, za->src); - error = 1; - } - _zip_progress_end(za->progress); - } - - if (error) { - zip_source_rollback_write(za->src); - return -1; - } - - zip_discard(za); - - return 0; -} - - -static int -add_data(zip_t *za, zip_source_t *src, zip_dirent_t *de, zip_uint32_t changed) { - zip_int64_t offstart, offdata, offend, data_length; - zip_stat_t st; - zip_file_attributes_t attributes; - zip_source_t *src_final, *src_tmp; - int ret; - int is_zip64; - zip_flags_t flags; - bool needs_recompress, needs_decompress, needs_crc, needs_compress, needs_reencrypt, needs_decrypt, needs_encrypt; - - if (zip_source_stat(src, &st) < 0) { - _zip_error_set_from_source(&za->error, src); - return -1; - } - - if ((st.valid & ZIP_STAT_COMP_METHOD) == 0) { - st.valid |= ZIP_STAT_COMP_METHOD; - st.comp_method = ZIP_CM_STORE; - } - - if (ZIP_CM_IS_DEFAULT(de->comp_method) && st.comp_method != ZIP_CM_STORE) - de->comp_method = st.comp_method; - else if (de->comp_method == ZIP_CM_STORE && (st.valid & ZIP_STAT_SIZE)) { - st.valid |= ZIP_STAT_COMP_SIZE; - st.comp_size = st.size; - } - else { - /* we'll recompress */ - st.valid &= ~ZIP_STAT_COMP_SIZE; - } - - if ((st.valid & ZIP_STAT_ENCRYPTION_METHOD) == 0) { - st.valid |= ZIP_STAT_ENCRYPTION_METHOD; - st.encryption_method = ZIP_EM_NONE; - } - - flags = ZIP_EF_LOCAL; - - if ((st.valid & ZIP_STAT_SIZE) == 0) { - flags |= ZIP_FL_FORCE_ZIP64; - data_length = -1; - } - else { - de->uncomp_size = st.size; - /* this is technically incorrect (copy_source counts compressed data), but it's the best we have */ - data_length = (zip_int64_t)st.size; - - if ((st.valid & ZIP_STAT_COMP_SIZE) == 0) { - zip_uint64_t max_compressed_size; - zip_uint16_t compression_method = ZIP_CM_ACTUAL(de->comp_method); - - if (compression_method == ZIP_CM_STORE) { - max_compressed_size = st.size; - } - else { - zip_compression_algorithm_t *algorithm = _zip_get_compression_algorithm(compression_method, true); - if (algorithm == NULL) { - max_compressed_size = ZIP_UINT64_MAX; - } - else { - max_compressed_size = algorithm->maximum_compressed_size(st.size); - } - } - - if (max_compressed_size > 0xffffffffu) { - flags |= ZIP_FL_FORCE_ZIP64; - } - } - else { - de->comp_size = st.comp_size; - data_length = (zip_int64_t)st.comp_size; - } - } - - if ((offstart = zip_source_tell_write(za->src)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - - /* as long as we don't support non-seekable output, clear data descriptor bit */ - de->bitflags &= (zip_uint16_t)~ZIP_GPBF_DATA_DESCRIPTOR; - if ((is_zip64 = _zip_dirent_write(za, de, flags)) < 0) { - return -1; - } - - needs_recompress = st.comp_method != ZIP_CM_ACTUAL(de->comp_method); - needs_decompress = needs_recompress && (st.comp_method != ZIP_CM_STORE); - /* in these cases we can compute the CRC ourselves, so we do */ - needs_crc = (st.comp_method == ZIP_CM_STORE) || needs_decompress; - needs_compress = needs_recompress && (de->comp_method != ZIP_CM_STORE); - - needs_reencrypt = needs_recompress || (de->changed & ZIP_DIRENT_PASSWORD) || (de->encryption_method != st.encryption_method); - needs_decrypt = needs_reencrypt && (st.encryption_method != ZIP_EM_NONE); - needs_encrypt = needs_reencrypt && (de->encryption_method != ZIP_EM_NONE); - - src_final = src; - zip_source_keep(src_final); - - if (needs_decrypt) { - zip_encryption_implementation impl; - - if ((impl = _zip_get_encryption_implementation(st.encryption_method, ZIP_CODEC_DECODE)) == NULL) { - zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); - zip_source_free(src_final); - return -1; - } - if ((src_tmp = impl(za, src_final, st.encryption_method, ZIP_CODEC_DECODE, za->default_password)) == NULL) { - /* error set by impl */ - zip_source_free(src_final); - return -1; - } - - zip_source_free(src_final); - src_final = src_tmp; - } - - if (needs_decompress) { - if ((src_tmp = zip_source_decompress(za, src_final, st.comp_method)) == NULL) { - zip_source_free(src_final); - return -1; - } - - zip_source_free(src_final); - src_final = src_tmp; - } - - if (needs_crc) { - if ((src_tmp = zip_source_crc(za, src_final, 0)) == NULL) { - zip_source_free(src_final); - return -1; - } - - zip_source_free(src_final); - src_final = src_tmp; - } - - if (needs_compress) { - if ((src_tmp = zip_source_compress(za, src_final, de->comp_method, de->compression_level)) == NULL) { - zip_source_free(src_final); - return -1; - } - - zip_source_free(src_final); - src_final = src_tmp; - } - - - if (needs_encrypt) { - zip_encryption_implementation impl; - const char *password = NULL; - - if (de->password) { - password = de->password; - } - else if (za->default_password) { - password = za->default_password; - } - - if ((impl = _zip_get_encryption_implementation(de->encryption_method, ZIP_CODEC_ENCODE)) == NULL) { - zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); - zip_source_free(src_final); - return -1; - } - if ((src_tmp = impl(za, src_final, de->encryption_method, ZIP_CODEC_ENCODE, password)) == NULL) { - /* error set by impl */ - zip_source_free(src_final); - return -1; - } - if (de->encryption_method == ZIP_EM_TRAD_PKWARE) { - de->bitflags |= ZIP_GPBF_DATA_DESCRIPTOR; - } - - zip_source_free(src_final); - src_final = src_tmp; - } - - - if ((offdata = zip_source_tell_write(za->src)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - - ret = copy_source(za, src_final, data_length); - - if (zip_source_stat(src_final, &st) < 0) { - _zip_error_set_from_source(&za->error, src_final); - ret = -1; - } - - if (zip_source_get_file_attributes(src_final, &attributes) != 0) { - _zip_error_set_from_source(&za->error, src_final); - ret = -1; - } - - zip_source_free(src_final); - - if (ret < 0) { - return -1; - } - - if ((offend = zip_source_tell_write(za->src)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - - if (zip_source_seek_write(za->src, offstart, SEEK_SET) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - - if ((st.valid & (ZIP_STAT_COMP_METHOD | ZIP_STAT_CRC | ZIP_STAT_SIZE)) != (ZIP_STAT_COMP_METHOD | ZIP_STAT_CRC | ZIP_STAT_SIZE)) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - return -1; - } - - if ((de->changed & ZIP_DIRENT_LAST_MOD) == 0) { - if (st.valid & ZIP_STAT_MTIME) - de->last_mod = st.mtime; - else - time(&de->last_mod); - } - de->comp_method = st.comp_method; - de->crc = st.crc; - de->uncomp_size = st.size; - de->comp_size = (zip_uint64_t)(offend - offdata); - _zip_dirent_apply_attributes(de, &attributes, (flags & ZIP_FL_FORCE_ZIP64) != 0, changed); - - if ((ret = _zip_dirent_write(za, de, flags)) < 0) - return -1; - - if (is_zip64 != ret) { - /* Zip64 mismatch between preliminary file header written before data and final file header written afterwards */ - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - return -1; - } - - if (zip_source_seek_write(za->src, offend, SEEK_SET) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - - if (de->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { - if (write_data_descriptor(za, de, is_zip64) < 0) { - return -1; - } - } - - return 0; -} - - -static int -copy_data(zip_t *za, zip_uint64_t len) { - DEFINE_BYTE_ARRAY(buf, BUFSIZE); - size_t n; - double total = (double)len; - - if (!byte_array_init(buf, BUFSIZE)) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - - while (len > 0) { - n = len > BUFSIZE ? BUFSIZE : len; - if (_zip_read(za->src, buf, n, &za->error) < 0) { - byte_array_fini(buf); - return -1; - } - - if (_zip_write(za, buf, n) < 0) { - byte_array_fini(buf); - return -1; - } - - len -= n; - - if (_zip_progress_update(za->progress, (total - (double)len) / total) != 0) { - zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); - return -1; - } - } - - byte_array_fini(buf); - return 0; -} - - -static int -copy_source(zip_t *za, zip_source_t *src, zip_int64_t data_length) { - DEFINE_BYTE_ARRAY(buf, BUFSIZE); - zip_int64_t n, current; - int ret; - - if (zip_source_open(src) < 0) { - _zip_error_set_from_source(&za->error, src); - return -1; - } - - if (!byte_array_init(buf, BUFSIZE)) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - - ret = 0; - current = 0; - while ((n = zip_source_read(src, buf, BUFSIZE)) > 0) { - if (_zip_write(za, buf, (zip_uint64_t)n) < 0) { - ret = -1; - break; - } - if (n == BUFSIZE && za->progress && data_length > 0) { - current += n; - if (_zip_progress_update(za->progress, (double)current / (double)data_length) != 0) { - zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); - ret = -1; - break; - } - } - } - - if (n < 0) { - _zip_error_set_from_source(&za->error, src); - ret = -1; - } - - byte_array_fini(buf); - - zip_source_close(src); - - return ret; -} - -static int -write_cdir(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors) { - zip_int64_t cd_start, end, size; - - if ((cd_start = zip_source_tell_write(za->src)) < 0) { - return -1; - } - - if ((size = _zip_cdir_write(za, filelist, survivors)) < 0) { - return -1; - } - - if ((end = zip_source_tell_write(za->src)) < 0) { - return -1; - } - - return 0; -} - - -int -_zip_changed(const zip_t *za, zip_uint64_t *survivorsp) { - int changed; - zip_uint64_t i, survivors; - - changed = 0; - survivors = 0; - - if (za->comment_changed || za->ch_flags != za->flags) { - changed = 1; - } - - for (i = 0; i < za->nentry; i++) { - if (ZIP_ENTRY_HAS_CHANGES(&za->entry[i])) { - changed = 1; - } - if (!za->entry[i].deleted) { - survivors++; - } - } - - if (survivorsp) { - *survivorsp = survivors; - } - - return changed; -} - -static int -write_data_descriptor(zip_t *za, const zip_dirent_t *de, int is_zip64) { - zip_buffer_t *buffer = _zip_buffer_new(NULL, MAX_DATA_DESCRIPTOR_LENGTH); - int ret = 0; - - if (buffer == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - - _zip_buffer_put(buffer, DATADES_MAGIC, 4); - _zip_buffer_put_32(buffer, de->crc); - if (is_zip64) { - _zip_buffer_put_64(buffer, de->comp_size); - _zip_buffer_put_64(buffer, de->uncomp_size); - } - else { - _zip_buffer_put_32(buffer, (zip_uint32_t)de->comp_size); - _zip_buffer_put_32(buffer, (zip_uint32_t)de->uncomp_size); - } - - if (!_zip_buffer_ok(buffer)) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - ret = -1; - } - else { - ret = _zip_write(za, _zip_buffer_data(buffer), _zip_buffer_offset(buffer)); - } - - _zip_buffer_free(buffer); - - return ret; -} diff --git a/Source/Libraries/libzip/zip_delete.c b/Source/Libraries/libzip/zip_delete.c deleted file mode 100644 index 4ff4c1a..0000000 --- a/Source/Libraries/libzip/zip_delete.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - zip_delete.c -- delete file from zip archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_delete(zip_t *za, zip_uint64_t idx) { - const char *name; - - if (idx >= za->nentry) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if ((name = _zip_get_name(za, idx, 0, &za->error)) == NULL) { - return -1; - } - - if (!_zip_hash_delete(za->names, (const zip_uint8_t *)name, &za->error)) { - return -1; - } - - /* allow duplicate file names, because the file will - * be removed directly afterwards */ - if (_zip_unchange(za, idx, 1) != 0) - return -1; - - za->entry[idx].deleted = 1; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_dir_add.c b/Source/Libraries/libzip/zip_dir_add.c deleted file mode 100644 index da1e4a4..0000000 --- a/Source/Libraries/libzip/zip_dir_add.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - zip_dir_add.c -- add directory - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - - -/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ - -ZIP_EXTERN zip_int64_t -zip_dir_add(zip_t *za, const char *name, zip_flags_t flags) { - size_t len; - zip_int64_t idx; - char *s; - zip_source_t *source; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (name == NULL) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - s = NULL; - len = strlen(name); - - if (name[len - 1] != '/') { - if ((s = (char *)malloc(len + 2)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - strcpy(s, name); - s[len] = '/'; - s[len + 1] = '\0'; - } - - if ((source = zip_source_buffer(za, NULL, 0, 0)) == NULL) { - free(s); - return -1; - } - - idx = _zip_file_replace(za, ZIP_UINT64_MAX, s ? s : name, source, flags); - - free(s); - - if (idx < 0) - zip_source_free(source); - else { - if (zip_file_set_external_attributes(za, (zip_uint64_t)idx, 0, ZIP_OPSYS_DEFAULT, ZIP_EXT_ATTRIB_DEFAULT_DIR) < 0) { - zip_delete(za, (zip_uint64_t)idx); - return -1; - } - } - - return idx; -} diff --git a/Source/Libraries/libzip/zip_dirent.c b/Source/Libraries/libzip/zip_dirent.c deleted file mode 100644 index 5226a6e..0000000 --- a/Source/Libraries/libzip/zip_dirent.c +++ /dev/null @@ -1,1163 +0,0 @@ -/* - zip_dirent.c -- read directory entry (local or central), clean dirent - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include -#include -#include -#include - -#include "zipint.h" - -static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str); -static zip_extra_field_t *_zip_ef_utf8(zip_uint16_t, zip_string_t *, zip_error_t *); -static bool _zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error); - - -void -_zip_cdir_free(zip_cdir_t *cd) { - zip_uint64_t i; - - if (!cd) - return; - - for (i = 0; i < cd->nentry; i++) - _zip_entry_finalize(cd->entry + i); - free(cd->entry); - _zip_string_free(cd->comment); - free(cd); -} - - -zip_cdir_t * -_zip_cdir_new(zip_uint64_t nentry, zip_error_t *error) { - zip_cdir_t *cd; - - if ((cd = (zip_cdir_t *)malloc(sizeof(*cd))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - cd->entry = NULL; - cd->nentry = cd->nentry_alloc = 0; - cd->size = cd->offset = 0; - cd->comment = NULL; - cd->is_zip64 = false; - - if (!_zip_cdir_grow(cd, nentry, error)) { - _zip_cdir_free(cd); - return NULL; - } - - return cd; -} - - -bool -_zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error) { - zip_uint64_t i, new_alloc; - zip_entry_t *new_entry; - - if (additional_entries == 0) { - return true; - } - - new_alloc = cd->nentry_alloc + additional_entries; - - if (new_alloc < additional_entries || new_alloc > SIZE_MAX / sizeof(*(cd->entry))) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return false; - } - - if ((new_entry = (zip_entry_t *)realloc(cd->entry, sizeof(*(cd->entry)) * (size_t)new_alloc)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return false; - } - - cd->entry = new_entry; - - for (i = cd->nentry; i < new_alloc; i++) { - _zip_entry_init(cd->entry + i); - } - - cd->nentry = cd->nentry_alloc = new_alloc; - - return true; -} - - -zip_int64_t -_zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors) { - zip_uint64_t offset, size; - zip_string_t *comment; - zip_uint8_t buf[EOCDLEN + EOCD64LEN + EOCD64LOCLEN]; - zip_buffer_t *buffer; - zip_int64_t off; - zip_uint64_t i; - bool is_zip64; - int ret; - - if ((off = zip_source_tell_write(za->src)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - offset = (zip_uint64_t)off; - - is_zip64 = false; - - for (i = 0; i < survivors; i++) { - zip_entry_t *entry = za->entry + filelist[i].idx; - - if ((ret = _zip_dirent_write(za, entry->changes ? entry->changes : entry->orig, ZIP_FL_CENTRAL)) < 0) - return -1; - if (ret) - is_zip64 = true; - } - - if ((off = zip_source_tell_write(za->src)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - size = (zip_uint64_t)off - offset; - - if (offset > ZIP_UINT32_MAX || survivors > ZIP_UINT16_MAX) - is_zip64 = true; - - - if ((buffer = _zip_buffer_new(buf, sizeof(buf))) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - - if (is_zip64) { - _zip_buffer_put(buffer, EOCD64_MAGIC, 4); - _zip_buffer_put_64(buffer, EOCD64LEN - 12); - _zip_buffer_put_16(buffer, 45); - _zip_buffer_put_16(buffer, 45); - _zip_buffer_put_32(buffer, 0); - _zip_buffer_put_32(buffer, 0); - _zip_buffer_put_64(buffer, survivors); - _zip_buffer_put_64(buffer, survivors); - _zip_buffer_put_64(buffer, size); - _zip_buffer_put_64(buffer, offset); - _zip_buffer_put(buffer, EOCD64LOC_MAGIC, 4); - _zip_buffer_put_32(buffer, 0); - _zip_buffer_put_64(buffer, offset + size); - _zip_buffer_put_32(buffer, 1); - } - - _zip_buffer_put(buffer, EOCD_MAGIC, 4); - _zip_buffer_put_32(buffer, 0); - _zip_buffer_put_16(buffer, (zip_uint16_t)(survivors >= ZIP_UINT16_MAX ? ZIP_UINT16_MAX : survivors)); - _zip_buffer_put_16(buffer, (zip_uint16_t)(survivors >= ZIP_UINT16_MAX ? ZIP_UINT16_MAX : survivors)); - _zip_buffer_put_32(buffer, size >= ZIP_UINT32_MAX ? ZIP_UINT32_MAX : (zip_uint32_t)size); - _zip_buffer_put_32(buffer, offset >= ZIP_UINT32_MAX ? ZIP_UINT32_MAX : (zip_uint32_t)offset); - - comment = za->comment_changed ? za->comment_changes : za->comment_orig; - - _zip_buffer_put_16(buffer, (zip_uint16_t)(comment ? comment->length : 0)); - - if (!_zip_buffer_ok(buffer)) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(buffer); - return -1; - } - - if (_zip_write(za, _zip_buffer_data(buffer), _zip_buffer_offset(buffer)) < 0) { - _zip_buffer_free(buffer); - return -1; - } - - _zip_buffer_free(buffer); - - if (comment) { - if (_zip_write(za, comment->raw, comment->length) < 0) { - return -1; - } - } - - return (zip_int64_t)size; -} - - -zip_dirent_t * -_zip_dirent_clone(const zip_dirent_t *sde) { - zip_dirent_t *tde; - - if ((tde = (zip_dirent_t *)malloc(sizeof(*tde))) == NULL) - return NULL; - - if (sde) - memcpy(tde, sde, sizeof(*sde)); - else - _zip_dirent_init(tde); - - tde->changed = 0; - tde->cloned = 1; - - return tde; -} - - -void -_zip_dirent_finalize(zip_dirent_t *zde) { - if (!zde->cloned || zde->changed & ZIP_DIRENT_FILENAME) { - _zip_string_free(zde->filename); - zde->filename = NULL; - } - if (!zde->cloned || zde->changed & ZIP_DIRENT_EXTRA_FIELD) { - _zip_ef_free(zde->extra_fields); - zde->extra_fields = NULL; - } - if (!zde->cloned || zde->changed & ZIP_DIRENT_COMMENT) { - _zip_string_free(zde->comment); - zde->comment = NULL; - } - if (!zde->cloned || zde->changed & ZIP_DIRENT_PASSWORD) { - if (zde->password) { - _zip_crypto_clear(zde->password, strlen(zde->password)); - } - free(zde->password); - zde->password = NULL; - } -} - - -void -_zip_dirent_free(zip_dirent_t *zde) { - if (zde == NULL) - return; - - _zip_dirent_finalize(zde); - free(zde); -} - - -void -_zip_dirent_init(zip_dirent_t *de) { - de->changed = 0; - de->local_extra_fields_read = 0; - de->cloned = 0; - - de->crc_valid = true; - de->version_madeby = 63 | (ZIP_OPSYS_DEFAULT << 8); - de->version_needed = 10; /* 1.0 */ - de->bitflags = 0; - de->comp_method = ZIP_CM_DEFAULT; - de->last_mod = 0; - de->crc = 0; - de->comp_size = 0; - de->uncomp_size = 0; - de->filename = NULL; - de->extra_fields = NULL; - de->comment = NULL; - de->disk_number = 0; - de->int_attrib = 0; - de->ext_attrib = ZIP_EXT_ATTRIB_DEFAULT; - de->offset = 0; - de->compression_level = 0; - de->encryption_method = ZIP_EM_NONE; - de->password = NULL; -} - - -bool -_zip_dirent_needs_zip64(const zip_dirent_t *de, zip_flags_t flags) { - if (de->uncomp_size >= ZIP_UINT32_MAX || de->comp_size >= ZIP_UINT32_MAX || ((flags & ZIP_FL_CENTRAL) && de->offset >= ZIP_UINT32_MAX)) - return true; - - return false; -} - - -zip_dirent_t * -_zip_dirent_new(void) { - zip_dirent_t *de; - - if ((de = (zip_dirent_t *)malloc(sizeof(*de))) == NULL) - return NULL; - - _zip_dirent_init(de); - return de; -} - - -/* _zip_dirent_read(zde, fp, bufp, left, localp, error): - Fills the zip directory entry zde. - - If buffer is non-NULL, data is taken from there; otherwise data is read from fp as needed. - - If local is true, it reads a local header instead of a central directory entry. - - Returns size of dirent read if successful. On error, error is filled in and -1 is returned. -*/ - -zip_int64_t -_zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error) { - zip_uint8_t buf[CDENTRYSIZE]; - zip_uint16_t dostime, dosdate; - zip_uint32_t size, variable_size; - zip_uint16_t filename_len, comment_len, ef_len; - - bool from_buffer = (buffer != NULL); - - size = local ? LENTRYSIZE : CDENTRYSIZE; - - if (buffer) { - if (_zip_buffer_left(buffer) < size) { - zip_error_set(error, ZIP_ER_NOZIP, 0); - return -1; - } - } - else { - if ((buffer = _zip_buffer_new_from_source(src, size, buf, error)) == NULL) { - return -1; - } - } - - if (memcmp(_zip_buffer_get(buffer, 4), (local ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) { - zip_error_set(error, ZIP_ER_NOZIP, 0); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - - /* convert buffercontents to zip_dirent */ - - _zip_dirent_init(zde); - if (!local) - zde->version_madeby = _zip_buffer_get_16(buffer); - else - zde->version_madeby = 0; - zde->version_needed = _zip_buffer_get_16(buffer); - zde->bitflags = _zip_buffer_get_16(buffer); - zde->comp_method = _zip_buffer_get_16(buffer); - - /* convert to time_t */ - dostime = _zip_buffer_get_16(buffer); - dosdate = _zip_buffer_get_16(buffer); - zde->last_mod = _zip_d2u_time(dostime, dosdate); - - zde->crc = _zip_buffer_get_32(buffer); - zde->comp_size = _zip_buffer_get_32(buffer); - zde->uncomp_size = _zip_buffer_get_32(buffer); - - filename_len = _zip_buffer_get_16(buffer); - ef_len = _zip_buffer_get_16(buffer); - - if (local) { - comment_len = 0; - zde->disk_number = 0; - zde->int_attrib = 0; - zde->ext_attrib = 0; - zde->offset = 0; - } - else { - comment_len = _zip_buffer_get_16(buffer); - zde->disk_number = _zip_buffer_get_16(buffer); - zde->int_attrib = _zip_buffer_get_16(buffer); - zde->ext_attrib = _zip_buffer_get_32(buffer); - zde->offset = _zip_buffer_get_32(buffer); - } - - if (!_zip_buffer_ok(buffer)) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - - if (zde->bitflags & ZIP_GPBF_ENCRYPTED) { - if (zde->bitflags & ZIP_GPBF_STRONG_ENCRYPTION) { - /* TODO */ - zde->encryption_method = ZIP_EM_UNKNOWN; - } - else { - zde->encryption_method = ZIP_EM_TRAD_PKWARE; - } - } - else { - zde->encryption_method = ZIP_EM_NONE; - } - - zde->filename = NULL; - zde->extra_fields = NULL; - zde->comment = NULL; - - variable_size = (zip_uint32_t)filename_len + (zip_uint32_t)ef_len + (zip_uint32_t)comment_len; - - if (from_buffer) { - if (_zip_buffer_left(buffer) < variable_size) { - zip_error_set(error, ZIP_ER_INCONS, 0); - return -1; - } - } - else { - _zip_buffer_free(buffer); - - if ((buffer = _zip_buffer_new_from_source(src, variable_size, NULL, error)) == NULL) { - return -1; - } - } - - if (filename_len) { - zde->filename = _zip_read_string(buffer, src, filename_len, 1, error); - if (!zde->filename) { - if (zip_error_code_zip(error) == ZIP_ER_EOF) { - zip_error_set(error, ZIP_ER_INCONS, 0); - } - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - - if (zde->bitflags & ZIP_GPBF_ENCODING_UTF_8) { - if (_zip_guess_encoding(zde->filename, ZIP_ENCODING_UTF8_KNOWN) == ZIP_ENCODING_ERROR) { - zip_error_set(error, ZIP_ER_INCONS, 0); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - } - } - - if (ef_len) { - zip_uint8_t *ef = _zip_read_data(buffer, src, ef_len, 0, error); - - if (ef == NULL) { - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - if (!_zip_ef_parse(ef, ef_len, local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL, &zde->extra_fields, error)) { - free(ef); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - free(ef); - if (local) - zde->local_extra_fields_read = 1; - } - - if (comment_len) { - zde->comment = _zip_read_string(buffer, src, comment_len, 0, error); - if (!zde->comment) { - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - if (zde->bitflags & ZIP_GPBF_ENCODING_UTF_8) { - if (_zip_guess_encoding(zde->comment, ZIP_ENCODING_UTF8_KNOWN) == ZIP_ENCODING_ERROR) { - zip_error_set(error, ZIP_ER_INCONS, 0); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - } - } - - zde->filename = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_NAME, zde->filename); - zde->comment = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_COMMENT, zde->comment); - - /* Zip64 */ - - if (zde->uncomp_size == ZIP_UINT32_MAX || zde->comp_size == ZIP_UINT32_MAX || zde->offset == ZIP_UINT32_MAX) { - zip_uint16_t got_len; - zip_buffer_t *ef_buffer; - const zip_uint8_t *ef = _zip_ef_get_by_id(zde->extra_fields, &got_len, ZIP_EF_ZIP64, 0, local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL, error); - /* TODO: if got_len == 0 && !ZIP64_EOCD: no error, 0xffffffff is valid value */ - if (ef == NULL) { - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - - if ((ef_buffer = _zip_buffer_new((zip_uint8_t *)ef, got_len)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - - if (zde->uncomp_size == ZIP_UINT32_MAX) { - zde->uncomp_size = _zip_buffer_get_64(ef_buffer); - } - else if (local) { - /* From appnote.txt: This entry in the Local header MUST - include BOTH original and compressed file size fields. */ - (void)_zip_buffer_skip(ef_buffer, 8); /* error is caught by _zip_buffer_eof() call */ - } - if (zde->comp_size == ZIP_UINT32_MAX) { - zde->comp_size = _zip_buffer_get_64(ef_buffer); - } - if (!local) { - if (zde->offset == ZIP_UINT32_MAX) { - zde->offset = _zip_buffer_get_64(ef_buffer); - } - if (zde->disk_number == ZIP_UINT16_MAX) { - zde->disk_number = _zip_buffer_get_32(ef_buffer); - } - } - - if (!_zip_buffer_eof(ef_buffer)) { - /* accept additional fields if values match */ - bool ok = true; - switch (got_len) { - case 28: - _zip_buffer_set_offset(ef_buffer, 24); - if (zde->disk_number != _zip_buffer_get_32(ef_buffer)) { - ok = false; - } - /* fallthrough */ - case 24: - _zip_buffer_set_offset(ef_buffer, 0); - if ((zde->uncomp_size != _zip_buffer_get_64(ef_buffer)) || (zde->comp_size != _zip_buffer_get_64(ef_buffer)) || (zde->offset != _zip_buffer_get_64(ef_buffer))) { - ok = false; - } - break; - - default: - ok = false; - } - if (!ok) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_buffer_free(ef_buffer); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - } - _zip_buffer_free(ef_buffer); - } - - if (!_zip_buffer_ok(buffer)) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - if (!from_buffer) { - _zip_buffer_free(buffer); - } - return -1; - } - if (!from_buffer) { - _zip_buffer_free(buffer); - } - - /* zip_source_seek / zip_source_tell don't support values > ZIP_INT64_MAX */ - if (zde->offset > ZIP_INT64_MAX) { - zip_error_set(error, ZIP_ER_SEEK, EFBIG); - return -1; - } - - if (!_zip_dirent_process_winzip_aes(zde, error)) { - return -1; - } - - zde->extra_fields = _zip_ef_remove_internal(zde->extra_fields); - - return (zip_int64_t)size + (zip_int64_t)variable_size; -} - - -static zip_string_t * -_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str) { - zip_uint16_t ef_len; - zip_uint32_t ef_crc; - zip_buffer_t *buffer; - - const zip_uint8_t *ef = _zip_ef_get_by_id(de->extra_fields, &ef_len, id, 0, ZIP_EF_BOTH, NULL); - - if (ef == NULL || ef_len < 5 || ef[0] != 1) { - return str; - } - - if ((buffer = _zip_buffer_new((zip_uint8_t *)ef, ef_len)) == NULL) { - return str; - } - - _zip_buffer_get_8(buffer); - ef_crc = _zip_buffer_get_32(buffer); - - if (_zip_string_crc32(str) == ef_crc) { - zip_uint16_t len = (zip_uint16_t)_zip_buffer_left(buffer); - zip_string_t *ef_str = _zip_string_new(_zip_buffer_get(buffer, len), len, ZIP_FL_ENC_UTF_8, NULL); - - if (ef_str != NULL) { - _zip_string_free(str); - str = ef_str; - } - } - - _zip_buffer_free(buffer); - - return str; -} - - -static bool -_zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error) { - zip_uint16_t ef_len; - zip_buffer_t *buffer; - const zip_uint8_t *ef; - bool crc_valid; - zip_uint16_t enc_method; - - - if (de->comp_method != ZIP_CM_WINZIP_AES) { - return true; - } - - ef = _zip_ef_get_by_id(de->extra_fields, &ef_len, ZIP_EF_WINZIP_AES, 0, ZIP_EF_BOTH, NULL); - - if (ef == NULL || ef_len < 7) { - zip_error_set(error, ZIP_ER_INCONS, 0); - return false; - } - - if ((buffer = _zip_buffer_new((zip_uint8_t *)ef, ef_len)) == NULL) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - return false; - } - - /* version */ - - crc_valid = true; - switch (_zip_buffer_get_16(buffer)) { - case 1: - break; - - case 2: - if (de->uncomp_size < 20 /* TODO: constant */) { - crc_valid = false; - } - break; - - default: - zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0); - _zip_buffer_free(buffer); - return false; - } - - /* vendor */ - if (memcmp(_zip_buffer_get(buffer, 2), "AE", 2) != 0) { - zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0); - _zip_buffer_free(buffer); - return false; - } - - /* mode */ - switch (_zip_buffer_get_8(buffer)) { - case 1: - enc_method = ZIP_EM_AES_128; - break; - case 2: - enc_method = ZIP_EM_AES_192; - break; - case 3: - enc_method = ZIP_EM_AES_256; - break; - default: - zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0); - _zip_buffer_free(buffer); - return false; - } - - if (ef_len != 7) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_buffer_free(buffer); - return false; - } - - de->crc_valid = crc_valid; - de->encryption_method = enc_method; - de->comp_method = _zip_buffer_get_16(buffer); - - _zip_buffer_free(buffer); - return true; -} - - -zip_int32_t -_zip_dirent_size(zip_source_t *src, zip_uint16_t flags, zip_error_t *error) { - zip_int32_t size; - bool local = (flags & ZIP_EF_LOCAL) != 0; - int i; - zip_uint8_t b[6]; - zip_buffer_t *buffer; - - size = local ? LENTRYSIZE : CDENTRYSIZE; - - if (zip_source_seek(src, local ? 26 : 28, SEEK_CUR) < 0) { - _zip_error_set_from_source(error, src); - return -1; - } - - if ((buffer = _zip_buffer_new_from_source(src, local ? 4 : 6, b, error)) == NULL) { - return -1; - } - - for (i = 0; i < (local ? 2 : 3); i++) { - size += _zip_buffer_get_16(buffer); - } - - if (!_zip_buffer_eof(buffer)) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(buffer); - return -1; - } - - _zip_buffer_free(buffer); - return size; -} - - -/* _zip_dirent_write - Writes zip directory entry. - - If flags & ZIP_EF_LOCAL, it writes a local header instead of a central - directory entry. If flags & ZIP_EF_FORCE_ZIP64, a ZIP64 extra field is written, even if not needed. - - Returns 0 if successful, 1 if successful and wrote ZIP64 extra field. On error, error is filled in and -1 is - returned. -*/ - -int -_zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags) { - zip_uint16_t dostime, dosdate; - zip_encoding_type_t com_enc, name_enc; - zip_extra_field_t *ef; - zip_extra_field_t *ef64; - zip_uint32_t ef_total_size; - bool is_zip64; - bool is_really_zip64; - bool is_winzip_aes; - zip_uint8_t buf[CDENTRYSIZE]; - zip_buffer_t *buffer; - - ef = NULL; - - name_enc = _zip_guess_encoding(de->filename, ZIP_ENCODING_UNKNOWN); - com_enc = _zip_guess_encoding(de->comment, ZIP_ENCODING_UNKNOWN); - - if ((name_enc == ZIP_ENCODING_UTF8_KNOWN && com_enc == ZIP_ENCODING_ASCII) || (name_enc == ZIP_ENCODING_ASCII && com_enc == ZIP_ENCODING_UTF8_KNOWN) || (name_enc == ZIP_ENCODING_UTF8_KNOWN && com_enc == ZIP_ENCODING_UTF8_KNOWN)) - de->bitflags |= ZIP_GPBF_ENCODING_UTF_8; - else { - de->bitflags &= (zip_uint16_t)~ZIP_GPBF_ENCODING_UTF_8; - if (name_enc == ZIP_ENCODING_UTF8_KNOWN) { - ef = _zip_ef_utf8(ZIP_EF_UTF_8_NAME, de->filename, &za->error); - if (ef == NULL) - return -1; - } - if ((flags & ZIP_FL_LOCAL) == 0 && com_enc == ZIP_ENCODING_UTF8_KNOWN) { - zip_extra_field_t *ef2 = _zip_ef_utf8(ZIP_EF_UTF_8_COMMENT, de->comment, &za->error); - if (ef2 == NULL) { - _zip_ef_free(ef); - return -1; - } - ef2->next = ef; - ef = ef2; - } - } - - if (de->encryption_method == ZIP_EM_NONE) { - de->bitflags &= (zip_uint16_t)~ZIP_GPBF_ENCRYPTED; - } - else { - de->bitflags |= (zip_uint16_t)ZIP_GPBF_ENCRYPTED; - } - - is_really_zip64 = _zip_dirent_needs_zip64(de, flags); - is_zip64 = (flags & (ZIP_FL_LOCAL | ZIP_FL_FORCE_ZIP64)) == (ZIP_FL_LOCAL | ZIP_FL_FORCE_ZIP64) || is_really_zip64; - is_winzip_aes = de->encryption_method == ZIP_EM_AES_128 || de->encryption_method == ZIP_EM_AES_192 || de->encryption_method == ZIP_EM_AES_256; - - if (is_zip64) { - zip_uint8_t ef_zip64[EFZIP64SIZE]; - zip_buffer_t *ef_buffer = _zip_buffer_new(ef_zip64, sizeof(ef_zip64)); - if (ef_buffer == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - _zip_ef_free(ef); - return -1; - } - - if (flags & ZIP_FL_LOCAL) { - if ((flags & ZIP_FL_FORCE_ZIP64) || de->comp_size > ZIP_UINT32_MAX || de->uncomp_size > ZIP_UINT32_MAX) { - _zip_buffer_put_64(ef_buffer, de->uncomp_size); - _zip_buffer_put_64(ef_buffer, de->comp_size); - } - } - else { - if ((flags & ZIP_FL_FORCE_ZIP64) || de->comp_size > ZIP_UINT32_MAX || de->uncomp_size > ZIP_UINT32_MAX || de->offset > ZIP_UINT32_MAX) { - if (de->uncomp_size >= ZIP_UINT32_MAX) { - _zip_buffer_put_64(ef_buffer, de->uncomp_size); - } - if (de->comp_size >= ZIP_UINT32_MAX) { - _zip_buffer_put_64(ef_buffer, de->comp_size); - } - if (de->offset >= ZIP_UINT32_MAX) { - _zip_buffer_put_64(ef_buffer, de->offset); - } - } - } - - if (!_zip_buffer_ok(ef_buffer)) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(ef_buffer); - _zip_ef_free(ef); - return -1; - } - - ef64 = _zip_ef_new(ZIP_EF_ZIP64, (zip_uint16_t)(_zip_buffer_offset(ef_buffer)), ef_zip64, ZIP_EF_BOTH); - _zip_buffer_free(ef_buffer); - ef64->next = ef; - ef = ef64; - } - - if (is_winzip_aes) { - zip_uint8_t data[EF_WINZIP_AES_SIZE]; - zip_buffer_t *ef_buffer = _zip_buffer_new(data, sizeof(data)); - zip_extra_field_t *ef_winzip; - - if (ef_buffer == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - _zip_ef_free(ef); - return -1; - } - - _zip_buffer_put_16(ef_buffer, 2); - _zip_buffer_put(ef_buffer, "AE", 2); - _zip_buffer_put_8(ef_buffer, (zip_uint8_t)(de->encryption_method & 0xff)); - _zip_buffer_put_16(ef_buffer, (zip_uint16_t)de->comp_method); - - if (!_zip_buffer_ok(ef_buffer)) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(ef_buffer); - _zip_ef_free(ef); - return -1; - } - - ef_winzip = _zip_ef_new(ZIP_EF_WINZIP_AES, EF_WINZIP_AES_SIZE, data, ZIP_EF_BOTH); - _zip_buffer_free(ef_buffer); - ef_winzip->next = ef; - ef = ef_winzip; - } - - if ((buffer = _zip_buffer_new(buf, sizeof(buf))) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - _zip_ef_free(ef); - return -1; - } - - _zip_buffer_put(buffer, (flags & ZIP_FL_LOCAL) ? LOCAL_MAGIC : CENTRAL_MAGIC, 4); - - if ((flags & ZIP_FL_LOCAL) == 0) { - _zip_buffer_put_16(buffer, de->version_madeby); - } - _zip_buffer_put_16(buffer, ZIP_MAX(is_really_zip64 ? 45 : 0, de->version_needed)); - _zip_buffer_put_16(buffer, de->bitflags); - if (is_winzip_aes) { - _zip_buffer_put_16(buffer, ZIP_CM_WINZIP_AES); - } - else { - _zip_buffer_put_16(buffer, (zip_uint16_t)de->comp_method); - } - - _zip_u2d_time(de->last_mod, &dostime, &dosdate); - _zip_buffer_put_16(buffer, dostime); - _zip_buffer_put_16(buffer, dosdate); - - if (is_winzip_aes && de->uncomp_size < 20) { - _zip_buffer_put_32(buffer, 0); - } - else { - _zip_buffer_put_32(buffer, de->crc); - } - - if (((flags & ZIP_FL_LOCAL) == ZIP_FL_LOCAL) && ((de->comp_size >= ZIP_UINT32_MAX) || (de->uncomp_size >= ZIP_UINT32_MAX))) { - /* In local headers, if a ZIP64 EF is written, it MUST contain - * both compressed and uncompressed sizes (even if one of the - * two is smaller than 0xFFFFFFFF); on the other hand, those - * may only appear when the corresponding standard entry is - * 0xFFFFFFFF. (appnote.txt 4.5.3) */ - _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); - _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); - } - else { - if (de->comp_size < ZIP_UINT32_MAX) { - _zip_buffer_put_32(buffer, (zip_uint32_t)de->comp_size); - } - else { - _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); - } - if (de->uncomp_size < ZIP_UINT32_MAX) { - _zip_buffer_put_32(buffer, (zip_uint32_t)de->uncomp_size); - } - else { - _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); - } - } - - _zip_buffer_put_16(buffer, _zip_string_length(de->filename)); - /* TODO: check for overflow */ - ef_total_size = (zip_uint32_t)_zip_ef_size(de->extra_fields, flags) + (zip_uint32_t)_zip_ef_size(ef, ZIP_EF_BOTH); - _zip_buffer_put_16(buffer, (zip_uint16_t)ef_total_size); - - if ((flags & ZIP_FL_LOCAL) == 0) { - _zip_buffer_put_16(buffer, _zip_string_length(de->comment)); - _zip_buffer_put_16(buffer, (zip_uint16_t)de->disk_number); - _zip_buffer_put_16(buffer, de->int_attrib); - _zip_buffer_put_32(buffer, de->ext_attrib); - if (de->offset < ZIP_UINT32_MAX) - _zip_buffer_put_32(buffer, (zip_uint32_t)de->offset); - else - _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); - } - - if (!_zip_buffer_ok(buffer)) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(buffer); - _zip_ef_free(ef); - return -1; - } - - if (_zip_write(za, buf, _zip_buffer_offset(buffer)) < 0) { - _zip_buffer_free(buffer); - _zip_ef_free(ef); - return -1; - } - - _zip_buffer_free(buffer); - - if (de->filename) { - if (_zip_string_write(za, de->filename) < 0) { - _zip_ef_free(ef); - return -1; - } - } - - if (ef) { - if (_zip_ef_write(za, ef, ZIP_EF_BOTH) < 0) { - _zip_ef_free(ef); - return -1; - } - } - _zip_ef_free(ef); - if (de->extra_fields) { - if (_zip_ef_write(za, de->extra_fields, flags) < 0) { - return -1; - } - } - - if ((flags & ZIP_FL_LOCAL) == 0) { - if (de->comment) { - if (_zip_string_write(za, de->comment) < 0) { - return -1; - } - } - } - - - return is_zip64; -} - - -time_t -_zip_d2u_time(zip_uint16_t dtime, zip_uint16_t ddate) { - struct tm tm; - - memset(&tm, 0, sizeof(tm)); - - /* let mktime decide if DST is in effect */ - tm.tm_isdst = -1; - - tm.tm_year = ((ddate >> 9) & 127) + 1980 - 1900; - tm.tm_mon = ((ddate >> 5) & 15) - 1; - tm.tm_mday = ddate & 31; - - tm.tm_hour = (dtime >> 11) & 31; - tm.tm_min = (dtime >> 5) & 63; - tm.tm_sec = (dtime << 1) & 62; - - return mktime(&tm); -} - - -static zip_extra_field_t * -_zip_ef_utf8(zip_uint16_t id, zip_string_t *str, zip_error_t *error) { - const zip_uint8_t *raw; - zip_uint32_t len; - zip_buffer_t *buffer; - zip_extra_field_t *ef; - - if ((raw = _zip_string_get(str, &len, ZIP_FL_ENC_RAW, NULL)) == NULL) { - /* error already set */ - return NULL; - } - - if (len + 5 > ZIP_UINT16_MAX) { - zip_error_set(error, ZIP_ER_INVAL, 0); /* TODO: better error code? */ - return NULL; - } - - if ((buffer = _zip_buffer_new(NULL, len + 5)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - _zip_buffer_put_8(buffer, 1); - _zip_buffer_put_32(buffer, _zip_string_crc32(str)); - _zip_buffer_put(buffer, raw, len); - - if (!_zip_buffer_ok(buffer)) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(buffer); - return NULL; - } - - ef = _zip_ef_new(id, (zip_uint16_t)(_zip_buffer_offset(buffer)), _zip_buffer_data(buffer), ZIP_EF_BOTH); - _zip_buffer_free(buffer); - - return ef; -} - - -zip_dirent_t * -_zip_get_dirent(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error) { - if (error == NULL) - error = &za->error; - - if (idx >= za->nentry) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((flags & ZIP_FL_UNCHANGED) || za->entry[idx].changes == NULL) { - if (za->entry[idx].orig == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - if (za->entry[idx].deleted && (flags & ZIP_FL_UNCHANGED) == 0) { - zip_error_set(error, ZIP_ER_DELETED, 0); - return NULL; - } - return za->entry[idx].orig; - } - else - return za->entry[idx].changes; -} - - -void -_zip_u2d_time(time_t intime, zip_uint16_t *dtime, zip_uint16_t *ddate) { - struct tm *tpm; - -#ifdef HAVE_LOCALTIME_R - struct tm tm; - tpm = localtime_r(&intime, &tm); -#else - tpm = localtime(&intime); -#endif - if (tpm == NULL) { - /* if localtime() fails, return an arbitrary date (1980-01-01 00:00:00) */ - *ddate = (1 << 5) + 1; - *dtime = 0; - return; - } - if (tpm->tm_year < 80) { - tpm->tm_year = 80; - } - - *ddate = (zip_uint16_t)(((tpm->tm_year + 1900 - 1980) << 9) + ((tpm->tm_mon + 1) << 5) + tpm->tm_mday); - *dtime = (zip_uint16_t)(((tpm->tm_hour) << 11) + ((tpm->tm_min) << 5) + ((tpm->tm_sec) >> 1)); - - return; -} - - -void -_zip_dirent_apply_attributes(zip_dirent_t *de, zip_file_attributes_t *attributes, bool force_zip64, zip_uint32_t changed) { - zip_uint16_t length; - - if (attributes->valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS) { - zip_uint16_t mask = attributes->general_purpose_bit_mask & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK; - de->bitflags = (de->bitflags & ~mask) | (attributes->general_purpose_bit_flags & mask); - } - if (attributes->valid & ZIP_FILE_ATTRIBUTES_ASCII) { - de->int_attrib = (de->int_attrib & ~0x1) | (attributes->ascii ? 1 : 0); - } - /* manually set attributes are preferred over attributes provided by source */ - if ((changed & ZIP_DIRENT_ATTRIBUTES) == 0 && (attributes->valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES)) { - de->ext_attrib = attributes->external_file_attributes; - } - - if (de->comp_method == ZIP_CM_LZMA) { - de->version_needed = 63; - } - else if (de->encryption_method == ZIP_EM_AES_128 || de->encryption_method == ZIP_EM_AES_192 || de->encryption_method == ZIP_EM_AES_256) { - de->version_needed = 51; - } - else if (de->comp_method == ZIP_CM_BZIP2) { - de->version_needed = 46; - } - else if (force_zip64 || _zip_dirent_needs_zip64(de, 0)) { - de->version_needed = 45; - } - else if (de->comp_method == ZIP_CM_DEFLATE || de->encryption_method == ZIP_EM_TRAD_PKWARE) { - de->version_needed = 20; - } - else if ((length = _zip_string_length(de->filename)) > 0 && de->filename->raw[length - 1] == '/') { - de->version_needed = 20; - } - else { - de->version_needed = 10; - } - - if (attributes->valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED) { - de->version_needed = ZIP_MAX(de->version_needed, attributes->version_needed); - } - - de->version_madeby = 63 | (de->version_madeby & 0xff00); - if ((changed & ZIP_DIRENT_ATTRIBUTES) == 0 && (attributes->valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM)) { - de->version_madeby = (de->version_madeby & 0xff) | (zip_uint16_t)(attributes->host_system << 8); - } -} diff --git a/Source/Libraries/libzip/zip_discard.c b/Source/Libraries/libzip/zip_discard.c deleted file mode 100644 index a29a288..0000000 --- a/Source/Libraries/libzip/zip_discard.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - zip_discard.c -- discard and free struct zip - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -/* zip_discard: - frees the space allocated to a zipfile struct, and closes the - corresponding file. */ - -void -zip_discard(zip_t *za) { - zip_uint64_t i; - - if (za == NULL) - return; - - if (za->src) { - zip_source_close(za->src); - zip_source_free(za->src); - } - - free(za->default_password); - _zip_string_free(za->comment_orig); - _zip_string_free(za->comment_changes); - - _zip_hash_free(za->names); - - if (za->entry) { - for (i = 0; i < za->nentry; i++) - _zip_entry_finalize(za->entry + i); - free(za->entry); - } - - for (i = 0; i < za->nopen_source; i++) { - _zip_source_invalidate(za->open_source[i]); - } - free(za->open_source); - - _zip_progress_free(za->progress); - - zip_error_fini(&za->error); - - free(za); - - return; -} diff --git a/Source/Libraries/libzip/zip_entry.c b/Source/Libraries/libzip/zip_entry.c deleted file mode 100644 index 837b59c..0000000 --- a/Source/Libraries/libzip/zip_entry.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - zip_entry.c -- struct zip_entry helper functions - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -void -_zip_entry_finalize(zip_entry_t *e) { - _zip_unchange_data(e); - _zip_dirent_free(e->orig); - _zip_dirent_free(e->changes); -} - - -void -_zip_entry_init(zip_entry_t *e) { - e->orig = NULL; - e->changes = NULL; - e->source = NULL; - e->deleted = 0; -} diff --git a/Source/Libraries/libzip/zip_err_str.c b/Source/Libraries/libzip/zip_err_str.c deleted file mode 100644 index c46258b..0000000 --- a/Source/Libraries/libzip/zip_err_str.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - This file was generated automatically by CMake - from zip.h; make changes there. -*/ - -#include "zipint.h" - -const char * const _zip_err_str[] = { - "No error", - "Multi-disk zip archives not supported", - "Renaming temporary file failed", - "Closing zip archive failed", - "Seek error", - "Read error", - "Write error", - "CRC error", - "Containing zip archive was closed", - "No such file", - "File already exists", - "Can't open file", - "Failure to create temporary file", - "Zlib error", - "Malloc failure", - "Entry has been changed", - "Compression method not supported", - "Premature end of file", - "Invalid argument", - "Not a zip archive", - "Internal error", - "Zip archive inconsistent", - "Can't remove file", - "Entry has been deleted", - "Encryption method not supported", - "Read-only archive", - "No password provided", - "Wrong password provided", - "Operation not supported", - "Resource still in use", - "Tell error", - "Compressed data invalid", - "Operation cancelled", -}; - -const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]); - -#define N ZIP_ET_NONE -#define S ZIP_ET_SYS -#define Z ZIP_ET_ZLIB - -const int _zip_err_type[] = { - N, - N, - S, - S, - S, - S, - S, - N, - N, - N, - N, - S, - S, - Z, - N, - N, - N, - N, - N, - N, - N, - N, - S, - N, - N, - N, - N, - N, - N, - N, - S, - N, - N, -}; diff --git a/Source/Libraries/libzip/zip_error.c b/Source/Libraries/libzip/zip_error.c deleted file mode 100644 index 9381d5b..0000000 --- a/Source/Libraries/libzip/zip_error.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - zip_error.c -- zip_error_t helper functions - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_error_code_system(const zip_error_t *error) { - return error->sys_err; -} - - -ZIP_EXTERN int -zip_error_code_zip(const zip_error_t *error) { - return error->zip_err; -} - - -ZIP_EXTERN void -zip_error_fini(zip_error_t *err) { - free(err->str); - err->str = NULL; -} - - -ZIP_EXTERN void -zip_error_init(zip_error_t *err) { - err->zip_err = ZIP_ER_OK; - err->sys_err = 0; - err->str = NULL; -} - -ZIP_EXTERN void -zip_error_init_with_code(zip_error_t *error, int ze) { - zip_error_init(error); - error->zip_err = ze; - switch (zip_error_system_type(error)) { - case ZIP_ET_SYS: - error->sys_err = errno; - break; - - default: - error->sys_err = 0; - break; - } -} - - -ZIP_EXTERN int -zip_error_system_type(const zip_error_t *error) { - if (error->zip_err < 0 || error->zip_err >= _zip_nerr_str) - return ZIP_ET_NONE; - - return _zip_err_type[error->zip_err]; -} - - -void -_zip_error_clear(zip_error_t *err) { - if (err == NULL) - return; - - err->zip_err = ZIP_ER_OK; - err->sys_err = 0; -} - - -void -_zip_error_copy(zip_error_t *dst, const zip_error_t *src) { - if (dst == NULL) { - return; - } - - dst->zip_err = src->zip_err; - dst->sys_err = src->sys_err; -} - - -void -_zip_error_get(const zip_error_t *err, int *zep, int *sep) { - if (zep) - *zep = err->zip_err; - if (sep) { - if (zip_error_system_type(err) != ZIP_ET_NONE) - *sep = err->sys_err; - else - *sep = 0; - } -} - - -void -zip_error_set(zip_error_t *err, int ze, int se) { - if (err) { - err->zip_err = ze; - err->sys_err = se; - } -} - - -void -_zip_error_set_from_source(zip_error_t *err, zip_source_t *src) { - _zip_error_copy(err, zip_source_error(src)); -} - - -zip_int64_t -zip_error_to_data(const zip_error_t *error, void *data, zip_uint64_t length) { - int *e = (int *)data; - - if (length < sizeof(int) * 2) { - return -1; - } - - e[0] = zip_error_code_zip(error); - e[1] = zip_error_code_system(error); - return sizeof(int) * 2; -} diff --git a/Source/Libraries/libzip/zip_error_clear.c b/Source/Libraries/libzip/zip_error_clear.c deleted file mode 100644 index 9bcd506..0000000 --- a/Source/Libraries/libzip/zip_error_clear.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - zip_error_clear.c -- clear zip error - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN void -zip_error_clear(zip_t *za) { - if (za == NULL) - return; - - _zip_error_clear(&za->error); -} diff --git a/Source/Libraries/libzip/zip_error_get.c b/Source/Libraries/libzip/zip_error_get.c deleted file mode 100644 index 9d0ec03..0000000 --- a/Source/Libraries/libzip/zip_error_get.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - zip_error_get.c -- get zip error - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN void -zip_error_get(zip_t *za, int *zep, int *sep) { - _zip_error_get(&za->error, zep, sep); -} - - -ZIP_EXTERN zip_error_t * -zip_get_error(zip_t *za) { - return &za->error; -} - - -ZIP_EXTERN zip_error_t * -zip_file_get_error(zip_file_t *f) { - return &f->error; -} diff --git a/Source/Libraries/libzip/zip_error_get_sys_type.c b/Source/Libraries/libzip/zip_error_get_sys_type.c deleted file mode 100644 index 3c9998c..0000000 --- a/Source/Libraries/libzip/zip_error_get_sys_type.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - zip_error_get_sys_type.c -- return type of system error code - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN int -zip_error_get_sys_type(int ze) { - if (ze < 0 || ze >= _zip_nerr_str) - return 0; - - return _zip_err_type[ze]; -} diff --git a/Source/Libraries/libzip/zip_error_strerror.c b/Source/Libraries/libzip/zip_error_strerror.c deleted file mode 100644 index d20b3b2..0000000 --- a/Source/Libraries/libzip/zip_error_strerror.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - zip_error_sterror.c -- get string representation of struct zip_error - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include -#include -#include - -#include "zipint.h" - - -ZIP_EXTERN const char * -zip_error_strerror(zip_error_t *err) { - const char *zs, *ss; - char buf[128], *s; - - zip_error_fini(err); - - if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) { - sprintf(buf, "Unknown error %d", err->zip_err); - zs = NULL; - ss = buf; - } - else { - zs = _zip_err_str[err->zip_err]; - - switch (_zip_err_type[err->zip_err]) { - case ZIP_ET_SYS: - ss = strerror(err->sys_err); - break; - - case ZIP_ET_ZLIB: - ss = zError(err->sys_err); - break; - - default: - ss = NULL; - } - } - - if (ss == NULL) - return zs; - else { - if ((s = (char *)malloc(strlen(ss) + (zs ? strlen(zs) + 2 : 0) + 1)) == NULL) - return _zip_err_str[ZIP_ER_MEMORY]; - - sprintf(s, "%s%s%s", (zs ? zs : ""), (zs ? ": " : ""), ss); - err->str = s; - - return s; - } -} diff --git a/Source/Libraries/libzip/zip_error_to_str.c b/Source/Libraries/libzip/zip_error_to_str.c deleted file mode 100644 index d315b19..0000000 --- a/Source/Libraries/libzip/zip_error_to_str.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - zip_error_to_str.c -- get string representation of zip error code - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include -#include - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN int -zip_error_to_str(char *buf, zip_uint64_t len, int ze, int se) { - const char *zs, *ss; - - if (ze < 0 || ze >= _zip_nerr_str) - return snprintf(buf, len, "Unknown error %d", ze); - - zs = _zip_err_str[ze]; - - switch (_zip_err_type[ze]) { - case ZIP_ET_SYS: - ss = strerror(se); - break; - - case ZIP_ET_ZLIB: - ss = zError(se); - break; - - default: - ss = NULL; - } - - return snprintf(buf, len, "%s%s%s", zs, (ss ? ": " : ""), (ss ? ss : "")); -} diff --git a/Source/Libraries/libzip/zip_extra_field.c b/Source/Libraries/libzip/zip_extra_field.c deleted file mode 100644 index 7424d88..0000000 --- a/Source/Libraries/libzip/zip_extra_field.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - zip_extra_field.c -- manipulate extra fields - Copyright (C) 2012-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include - -#include "zipint.h" - - -zip_extra_field_t * -_zip_ef_clone(const zip_extra_field_t *ef, zip_error_t *error) { - zip_extra_field_t *head, *prev, *def; - - head = prev = NULL; - - while (ef) { - if ((def = _zip_ef_new(ef->id, ef->size, ef->data, ef->flags)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - _zip_ef_free(head); - return NULL; - } - - if (head == NULL) - head = def; - if (prev) - prev->next = def; - prev = def; - - ef = ef->next; - } - - return head; -} - - -zip_extra_field_t * -_zip_ef_delete_by_id(zip_extra_field_t *ef, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags) { - zip_extra_field_t *head, *prev; - int i; - - i = 0; - head = ef; - prev = NULL; - for (; ef; ef = (prev ? prev->next : head)) { - if ((ef->flags & flags & ZIP_EF_BOTH) && ((ef->id == id) || (id == ZIP_EXTRA_FIELD_ALL))) { - if (id_idx == ZIP_EXTRA_FIELD_ALL || i == id_idx) { - ef->flags &= ~(flags & ZIP_EF_BOTH); - if ((ef->flags & ZIP_EF_BOTH) == 0) { - if (prev) - prev->next = ef->next; - else - head = ef->next; - ef->next = NULL; - _zip_ef_free(ef); - - if (id_idx == ZIP_EXTRA_FIELD_ALL) - continue; - } - } - - i++; - if (i > id_idx) - break; - } - prev = ef; - } - - return head; -} - - -void -_zip_ef_free(zip_extra_field_t *ef) { - zip_extra_field_t *ef2; - - while (ef) { - ef2 = ef->next; - free(ef->data); - free(ef); - ef = ef2; - } -} - - -const zip_uint8_t * -_zip_ef_get_by_id(const zip_extra_field_t *ef, zip_uint16_t *lenp, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags, zip_error_t *error) { - static const zip_uint8_t empty[1] = {'\0'}; - - int i; - - i = 0; - for (; ef; ef = ef->next) { - if (ef->id == id && (ef->flags & flags & ZIP_EF_BOTH)) { - if (i < id_idx) { - i++; - continue; - } - - if (lenp) - *lenp = ef->size; - if (ef->size > 0) - return ef->data; - else - return empty; - } - } - - zip_error_set(error, ZIP_ER_NOENT, 0); - return NULL; -} - - -zip_extra_field_t * -_zip_ef_merge(zip_extra_field_t *to, zip_extra_field_t *from) { - zip_extra_field_t *ef2, *tt, *tail; - int duplicate; - - if (to == NULL) - return from; - - for (tail = to; tail->next; tail = tail->next) - ; - - for (; from; from = ef2) { - ef2 = from->next; - - duplicate = 0; - for (tt = to; tt; tt = tt->next) { - if (tt->id == from->id && tt->size == from->size && (tt->size == 0 || memcmp(tt->data, from->data, tt->size) == 0)) { - tt->flags |= (from->flags & ZIP_EF_BOTH); - duplicate = 1; - break; - } - } - - from->next = NULL; - if (duplicate) - _zip_ef_free(from); - else - tail = tail->next = from; - } - - return to; -} - - -zip_extra_field_t * -_zip_ef_new(zip_uint16_t id, zip_uint16_t size, const zip_uint8_t *data, zip_flags_t flags) { - zip_extra_field_t *ef; - - if ((ef = (zip_extra_field_t *)malloc(sizeof(*ef))) == NULL) - return NULL; - - ef->next = NULL; - ef->flags = flags; - ef->id = id; - ef->size = size; - if (size > 0) { - if ((ef->data = (zip_uint8_t *)_zip_memdup(data, size, NULL)) == NULL) { - free(ef); - return NULL; - } - } - else - ef->data = NULL; - - return ef; -} - - -bool -_zip_ef_parse(const zip_uint8_t *data, zip_uint16_t len, zip_flags_t flags, zip_extra_field_t **ef_head_p, zip_error_t *error) { - zip_buffer_t *buffer; - zip_extra_field_t *ef, *ef2, *ef_head; - - if ((buffer = _zip_buffer_new((zip_uint8_t *)data, len)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return false; - } - - ef_head = ef = NULL; - - while (_zip_buffer_ok(buffer) && _zip_buffer_left(buffer) >= 4) { - zip_uint16_t fid, flen; - zip_uint8_t *ef_data; - - fid = _zip_buffer_get_16(buffer); - flen = _zip_buffer_get_16(buffer); - ef_data = _zip_buffer_get(buffer, flen); - - if (ef_data == NULL) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_buffer_free(buffer); - _zip_ef_free(ef_head); - return false; - } - - if ((ef2 = _zip_ef_new(fid, flen, ef_data, flags)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - _zip_buffer_free(buffer); - _zip_ef_free(ef_head); - return false; - } - - if (ef_head) { - ef->next = ef2; - ef = ef2; - } - else - ef_head = ef = ef2; - } - - if (!_zip_buffer_eof(buffer)) { - /* Android APK files align stored file data with padding in extra fields; ignore. */ - /* see https://android.googlesource.com/platform/build/+/master/tools/zipalign/ZipAlign.cpp */ - size_t glen = _zip_buffer_left(buffer); - zip_uint8_t *garbage; - garbage = _zip_buffer_get(buffer, glen); - if (glen >= 4 || garbage == NULL || memcmp(garbage, "\0\0\0", glen) != 0) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_buffer_free(buffer); - _zip_ef_free(ef_head); - return false; - } - } - - _zip_buffer_free(buffer); - - if (ef_head_p) { - *ef_head_p = ef_head; - } - else { - _zip_ef_free(ef_head); - } - - return true; -} - - -zip_extra_field_t * -_zip_ef_remove_internal(zip_extra_field_t *ef) { - zip_extra_field_t *ef_head; - zip_extra_field_t *prev, *next; - - ef_head = ef; - prev = NULL; - - while (ef) { - if (ZIP_EF_IS_INTERNAL(ef->id)) { - next = ef->next; - if (ef_head == ef) - ef_head = next; - ef->next = NULL; - _zip_ef_free(ef); - if (prev) - prev->next = next; - ef = next; - } - else { - prev = ef; - ef = ef->next; - } - } - - return ef_head; -} - - -zip_uint16_t -_zip_ef_size(const zip_extra_field_t *ef, zip_flags_t flags) { - zip_uint16_t size; - - size = 0; - for (; ef; ef = ef->next) { - if (ef->flags & flags & ZIP_EF_BOTH) - size = (zip_uint16_t)(size + 4 + ef->size); - } - - return size; -} - - -int -_zip_ef_write(zip_t *za, const zip_extra_field_t *ef, zip_flags_t flags) { - zip_uint8_t b[4]; - zip_buffer_t *buffer = _zip_buffer_new(b, sizeof(b)); - - if (buffer == NULL) { - return -1; - } - - for (; ef; ef = ef->next) { - if (ef->flags & flags & ZIP_EF_BOTH) { - _zip_buffer_set_offset(buffer, 0); - _zip_buffer_put_16(buffer, ef->id); - _zip_buffer_put_16(buffer, ef->size); - if (!_zip_buffer_ok(buffer)) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(buffer); - return -1; - } - if (_zip_write(za, b, 4) < 0) { - _zip_buffer_free(buffer); - return -1; - } - if (ef->size > 0) { - if (_zip_write(za, ef->data, ef->size) < 0) { - _zip_buffer_free(buffer); - return -1; - } - } - } - } - - _zip_buffer_free(buffer); - return 0; -} - - -int -_zip_read_local_ef(zip_t *za, zip_uint64_t idx) { - zip_entry_t *e; - unsigned char b[4]; - zip_buffer_t *buffer; - zip_uint16_t fname_len, ef_len; - - if (idx >= za->nentry) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - e = za->entry + idx; - - if (e->orig == NULL || e->orig->local_extra_fields_read) - return 0; - - if (e->orig->offset + 26 > ZIP_INT64_MAX) { - zip_error_set(&za->error, ZIP_ER_SEEK, EFBIG); - return -1; - } - - if (zip_source_seek(za->src, (zip_int64_t)(e->orig->offset + 26), SEEK_SET) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - - if ((buffer = _zip_buffer_new_from_source(za->src, sizeof(b), b, &za->error)) == NULL) { - return -1; - } - - fname_len = _zip_buffer_get_16(buffer); - ef_len = _zip_buffer_get_16(buffer); - - if (!_zip_buffer_eof(buffer)) { - _zip_buffer_free(buffer); - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - return -1; - } - - _zip_buffer_free(buffer); - - if (ef_len > 0) { - zip_extra_field_t *ef; - zip_uint8_t *ef_raw; - - if (zip_source_seek(za->src, fname_len, SEEK_CUR) < 0) { - zip_error_set(&za->error, ZIP_ER_SEEK, errno); - return -1; - } - - ef_raw = _zip_read_data(NULL, za->src, ef_len, 0, &za->error); - - if (ef_raw == NULL) - return -1; - - if (!_zip_ef_parse(ef_raw, ef_len, ZIP_EF_LOCAL, &ef, &za->error)) { - free(ef_raw); - return -1; - } - free(ef_raw); - - if (ef) { - ef = _zip_ef_remove_internal(ef); - e->orig->extra_fields = _zip_ef_merge(e->orig->extra_fields, ef); - } - } - - e->orig->local_extra_fields_read = 1; - - if (e->changes && e->changes->local_extra_fields_read == 0) { - e->changes->extra_fields = e->orig->extra_fields; - e->changes->local_extra_fields_read = 1; - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_extra_field_api.c b/Source/Libraries/libzip/zip_extra_field_api.c deleted file mode 100644 index cf2b0e7..0000000 --- a/Source/Libraries/libzip/zip_extra_field_api.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - zip_extra_field_api.c -- public extra fields API functions - Copyright (C) 2012-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_file_extra_field_delete(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_idx, zip_flags_t flags) { - zip_dirent_t *de; - - if ((flags & ZIP_EF_BOTH) == 0) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (_zip_get_dirent(za, idx, 0, NULL) == NULL) - return -1; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (_zip_file_extra_field_prepare_for_change(za, idx) < 0) - return -1; - - de = za->entry[idx].changes; - - de->extra_fields = _zip_ef_delete_by_id(de->extra_fields, ZIP_EXTRA_FIELD_ALL, ef_idx, flags); - return 0; -} - - -ZIP_EXTERN int -zip_file_extra_field_delete_by_id(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, zip_flags_t flags) { - zip_dirent_t *de; - - if ((flags & ZIP_EF_BOTH) == 0) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (_zip_get_dirent(za, idx, 0, NULL) == NULL) - return -1; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (_zip_file_extra_field_prepare_for_change(za, idx) < 0) - return -1; - - de = za->entry[idx].changes; - - de->extra_fields = _zip_ef_delete_by_id(de->extra_fields, ef_id, ef_idx, flags); - return 0; -} - - -ZIP_EXTERN const zip_uint8_t * -zip_file_extra_field_get(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_idx, zip_uint16_t *idp, zip_uint16_t *lenp, zip_flags_t flags) { - static const zip_uint8_t empty[1] = {'\0'}; - - zip_dirent_t *de; - zip_extra_field_t *ef; - int i; - - if ((flags & ZIP_EF_BOTH) == 0) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) - return NULL; - - if (flags & ZIP_FL_LOCAL) - if (_zip_read_local_ef(za, idx) < 0) - return NULL; - - i = 0; - for (ef = de->extra_fields; ef; ef = ef->next) { - if (ef->flags & flags & ZIP_EF_BOTH) { - if (i < ef_idx) { - i++; - continue; - } - - if (idp) - *idp = ef->id; - if (lenp) - *lenp = ef->size; - if (ef->size > 0) - return ef->data; - else - return empty; - } - } - - zip_error_set(&za->error, ZIP_ER_NOENT, 0); - return NULL; -} - - -ZIP_EXTERN const zip_uint8_t * -zip_file_extra_field_get_by_id(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, zip_uint16_t *lenp, zip_flags_t flags) { - zip_dirent_t *de; - - if ((flags & ZIP_EF_BOTH) == 0) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) - return NULL; - - if (flags & ZIP_FL_LOCAL) - if (_zip_read_local_ef(za, idx) < 0) - return NULL; - - return _zip_ef_get_by_id(de->extra_fields, lenp, ef_id, ef_idx, flags, &za->error); -} - - -ZIP_EXTERN zip_int16_t -zip_file_extra_fields_count(zip_t *za, zip_uint64_t idx, zip_flags_t flags) { - zip_dirent_t *de; - zip_extra_field_t *ef; - zip_uint16_t n; - - if ((flags & ZIP_EF_BOTH) == 0) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) - return -1; - - if (flags & ZIP_FL_LOCAL) - if (_zip_read_local_ef(za, idx) < 0) - return -1; - - n = 0; - for (ef = de->extra_fields; ef; ef = ef->next) - if (ef->flags & flags & ZIP_EF_BOTH) - n++; - - return (zip_int16_t)n; -} - - -ZIP_EXTERN zip_int16_t -zip_file_extra_fields_count_by_id(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_flags_t flags) { - zip_dirent_t *de; - zip_extra_field_t *ef; - zip_uint16_t n; - - if ((flags & ZIP_EF_BOTH) == 0) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) - return -1; - - if (flags & ZIP_FL_LOCAL) - if (_zip_read_local_ef(za, idx) < 0) - return -1; - - n = 0; - for (ef = de->extra_fields; ef; ef = ef->next) - if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH)) - n++; - - return (zip_int16_t)n; -} - - -ZIP_EXTERN int -zip_file_extra_field_set(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, const zip_uint8_t *data, zip_uint16_t len, zip_flags_t flags) { - zip_dirent_t *de; - zip_uint16_t ls, cs; - zip_extra_field_t *ef, *ef_prev, *ef_new; - int i, found, new_len; - - if ((flags & ZIP_EF_BOTH) == 0) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (_zip_get_dirent(za, idx, 0, NULL) == NULL) - return -1; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (ZIP_EF_IS_INTERNAL(ef_id)) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (_zip_file_extra_field_prepare_for_change(za, idx) < 0) - return -1; - - de = za->entry[idx].changes; - - ef = de->extra_fields; - ef_prev = NULL; - i = 0; - found = 0; - - for (; ef; ef = ef->next) { - if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH)) { - if (i == ef_idx) { - found = 1; - break; - } - i++; - } - ef_prev = ef; - } - - if (i < ef_idx && ef_idx != ZIP_EXTRA_FIELD_NEW) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (flags & ZIP_EF_LOCAL) - ls = _zip_ef_size(de->extra_fields, ZIP_EF_LOCAL); - else - ls = 0; - if (flags & ZIP_EF_CENTRAL) - cs = _zip_ef_size(de->extra_fields, ZIP_EF_CENTRAL); - else - cs = 0; - - new_len = ls > cs ? ls : cs; - if (found) - new_len -= ef->size + 4; - new_len += len + 4; - - if (new_len > ZIP_UINT16_MAX) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if ((ef_new = _zip_ef_new(ef_id, len, data, flags)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - - if (found) { - if ((ef->flags & ZIP_EF_BOTH) == (flags & ZIP_EF_BOTH)) { - ef_new->next = ef->next; - ef->next = NULL; - _zip_ef_free(ef); - if (ef_prev) - ef_prev->next = ef_new; - else - de->extra_fields = ef_new; - } - else { - ef->flags &= ~(flags & ZIP_EF_BOTH); - ef_new->next = ef->next; - ef->next = ef_new; - } - } - else if (ef_prev) { - ef_new->next = ef_prev->next; - ef_prev->next = ef_new; - } - else - de->extra_fields = ef_new; - - return 0; -} - - -int -_zip_file_extra_field_prepare_for_change(zip_t *za, zip_uint64_t idx) { - zip_entry_t *e; - - if (idx >= za->nentry) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - e = za->entry + idx; - - if (e->changes && (e->changes->changed & ZIP_DIRENT_EXTRA_FIELD)) - return 0; - - if (e->orig) { - if (_zip_read_local_ef(za, idx) < 0) - return -1; - } - - if (e->changes == NULL) { - if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - - if (e->orig && e->orig->extra_fields) { - if ((e->changes->extra_fields = _zip_ef_clone(e->orig->extra_fields, &za->error)) == NULL) - return -1; - } - e->changes->changed |= ZIP_DIRENT_EXTRA_FIELD; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_fclose.c b/Source/Libraries/libzip/zip_fclose.c deleted file mode 100644 index 4d6fc59..0000000 --- a/Source/Libraries/libzip/zip_fclose.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - zip_fclose.c -- close file in zip archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_fclose(zip_file_t *zf) { - int ret; - - if (zf->src) - zip_source_free(zf->src); - - ret = 0; - if (zf->error.zip_err) - ret = zf->error.zip_err; - - zip_error_fini(&zf->error); - free(zf); - return ret; -} diff --git a/Source/Libraries/libzip/zip_fdopen.c b/Source/Libraries/libzip/zip_fdopen.c deleted file mode 100644 index 14f243f..0000000 --- a/Source/Libraries/libzip/zip_fdopen.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - zip_fdopen.c -- open read-only archive from file descriptor - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" -#ifdef HAVE_UNISTD_H -#include -#endif - - -ZIP_EXTERN zip_t * -zip_fdopen(int fd_orig, int _flags, int *zep) { - int fd; - FILE *fp; - zip_t *za; - zip_source_t *src; - struct zip_error error; - - if (_flags < 0 || (_flags & ~(ZIP_CHECKCONS | ZIP_RDONLY))) { - _zip_set_open_error(zep, NULL, ZIP_ER_INVAL); - return NULL; - } - - /* We dup() here to avoid messing with the passed in fd. - We could not restore it to the original state in case of error. */ - - if ((fd = dup(fd_orig)) < 0) { - _zip_set_open_error(zep, NULL, ZIP_ER_OPEN); - return NULL; - } - - if ((fp = fdopen(fd, "rb")) == NULL) { - close(fd); - _zip_set_open_error(zep, NULL, ZIP_ER_OPEN); - return NULL; - } - - zip_error_init(&error); - if ((src = zip_source_filep_create(fp, 0, -1, &error)) == NULL) { - fclose(fp); - _zip_set_open_error(zep, &error, 0); - zip_error_fini(&error); - return NULL; - } - - if ((za = zip_open_from_source(src, _flags, &error)) == NULL) { - zip_source_free(src); - _zip_set_open_error(zep, &error, 0); - zip_error_fini(&error); - return NULL; - } - - zip_error_fini(&error); - close(fd_orig); - return za; -} diff --git a/Source/Libraries/libzip/zip_file_add.c b/Source/Libraries/libzip/zip_file_add.c deleted file mode 100644 index 40386c0..0000000 --- a/Source/Libraries/libzip/zip_file_add.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - zip_file_add.c -- add file via callback function - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -/* - NOTE: Return type is signed so we can return -1 on error. - The index can not be larger than ZIP_INT64_MAX since the size - of the central directory cannot be larger than - ZIP_UINT64_MAX, and each entry is larger than 2 bytes. -*/ - -ZIP_EXTERN zip_int64_t -zip_file_add(zip_t *za, const char *name, zip_source_t *source, zip_flags_t flags) { - if (name == NULL || source == NULL) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - return _zip_file_replace(za, ZIP_UINT64_MAX, name, source, flags); -} diff --git a/Source/Libraries/libzip/zip_file_error_clear.c b/Source/Libraries/libzip/zip_file_error_clear.c deleted file mode 100644 index 863dae7..0000000 --- a/Source/Libraries/libzip/zip_file_error_clear.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - zip_file_error_clear.c -- clear zip file error - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN void -zip_file_error_clear(zip_file_t *zf) { - if (zf == NULL) - return; - - _zip_error_clear(&zf->error); -} diff --git a/Source/Libraries/libzip/zip_file_error_get.c b/Source/Libraries/libzip/zip_file_error_get.c deleted file mode 100644 index a477976..0000000 --- a/Source/Libraries/libzip/zip_file_error_get.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - zip_file_error_get.c -- get zip file error - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN void -zip_file_error_get(zip_file_t *zf, int *zep, int *sep) { - _zip_error_get(&zf->error, zep, sep); -} diff --git a/Source/Libraries/libzip/zip_file_get_comment.c b/Source/Libraries/libzip/zip_file_get_comment.c deleted file mode 100644 index 746186a..0000000 --- a/Source/Libraries/libzip/zip_file_get_comment.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - zip_file_get_comment.c -- get file comment - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -/* lenp is 32 bit because converted comment can be longer than ZIP_UINT16_MAX */ - -ZIP_EXTERN const char * -zip_file_get_comment(zip_t *za, zip_uint64_t idx, zip_uint32_t *lenp, zip_flags_t flags) { - zip_dirent_t *de; - zip_uint32_t len; - const zip_uint8_t *str; - - if ((de = _zip_get_dirent(za, idx, flags, NULL)) == NULL) - return NULL; - - if ((str = _zip_string_get(de->comment, &len, flags, &za->error)) == NULL) - return NULL; - - if (lenp) - *lenp = len; - - return (const char *)str; -} diff --git a/Source/Libraries/libzip/zip_file_get_external_attributes.c b/Source/Libraries/libzip/zip_file_get_external_attributes.c deleted file mode 100644 index 6d4e0e4..0000000 --- a/Source/Libraries/libzip/zip_file_get_external_attributes.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - zip_file_get_external_attributes.c -- get opsys/external attributes - Copyright (C) 2013-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" - -int -zip_file_get_external_attributes(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_uint8_t *opsys, zip_uint32_t *attributes) { - zip_dirent_t *de; - - if ((de = _zip_get_dirent(za, idx, flags, NULL)) == NULL) - return -1; - - if (opsys) - *opsys = (zip_uint8_t)((de->version_madeby >> 8) & 0xff); - - if (attributes) - *attributes = de->ext_attrib; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_file_get_offset.c b/Source/Libraries/libzip/zip_file_get_offset.c deleted file mode 100644 index eb9b017..0000000 --- a/Source/Libraries/libzip/zip_file_get_offset.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - zip_file_get_offset.c -- get offset of file data in archive. - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - - -/* _zip_file_get_offset(za, ze): - Returns the offset of the file data for entry ze. - - On error, fills in za->error and returns 0. -*/ - -zip_uint64_t -_zip_file_get_offset(const zip_t *za, zip_uint64_t idx, zip_error_t *error) { - zip_uint64_t offset; - zip_int32_t size; - - if (za->entry[idx].orig == NULL) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - return 0; - } - - offset = za->entry[idx].orig->offset; - - if (zip_source_seek(za->src, (zip_int64_t)offset, SEEK_SET) < 0) { - _zip_error_set_from_source(error, za->src); - return 0; - } - - /* TODO: cache? */ - if ((size = _zip_dirent_size(za->src, ZIP_EF_LOCAL, error)) < 0) - return 0; - - if (offset + (zip_uint32_t)size > ZIP_INT64_MAX) { - zip_error_set(error, ZIP_ER_SEEK, EFBIG); - return 0; - } - - return offset + (zip_uint32_t)size; -} - -zip_uint64_t -_zip_file_get_end(const zip_t *za, zip_uint64_t index, zip_error_t *error) { - zip_uint64_t offset; - zip_dirent_t *entry; - - if ((offset = _zip_file_get_offset(za, index, error)) == 0) { - return 0; - } - - entry = za->entry[index].orig; - - if (offset + entry->comp_size < offset || offset + entry->comp_size > ZIP_INT64_MAX) { - zip_error_set(error, ZIP_ER_SEEK, EFBIG); - return 0; - } - offset += entry->comp_size; - - if (entry->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { - zip_uint8_t buf[4]; - if (zip_source_seek(za->src, (zip_int64_t)offset, SEEK_SET) < 0) { - _zip_error_set_from_source(error, za->src); - return 0; - } - if (zip_source_read(za->src, buf, 4) != 4) { - _zip_error_set_from_source(error, za->src); - return 0; - } - if (memcmp(buf, DATADES_MAGIC, 4) == 0) { - offset += 4; - } - offset += 12; - if (_zip_dirent_needs_zip64(entry, 0)) { - offset += 8; - } - if (offset > ZIP_INT64_MAX) { - zip_error_set(error, ZIP_ER_SEEK, EFBIG); - return 0; - } - } - - return offset; -} diff --git a/Source/Libraries/libzip/zip_file_rename.c b/Source/Libraries/libzip/zip_file_rename.c deleted file mode 100644 index a830b6a..0000000 --- a/Source/Libraries/libzip/zip_file_rename.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - zip_file_rename.c -- rename file in zip archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_file_rename(zip_t *za, zip_uint64_t idx, const char *name, zip_flags_t flags) { - const char *old_name; - int old_is_dir, new_is_dir; - - if (idx >= za->nentry || (name != NULL && strlen(name) > ZIP_UINT16_MAX)) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if ((old_name = zip_get_name(za, idx, 0)) == NULL) - return -1; - - new_is_dir = (name != NULL && name[strlen(name) - 1] == '/'); - old_is_dir = (old_name[strlen(old_name) - 1] == '/'); - - if (new_is_dir != old_is_dir) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - return _zip_set_name(za, idx, name, flags); -} diff --git a/Source/Libraries/libzip/zip_file_replace.c b/Source/Libraries/libzip/zip_file_replace.c deleted file mode 100644 index c824d7f..0000000 --- a/Source/Libraries/libzip/zip_file_replace.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - zip_file_replace.c -- replace file via callback function - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_file_replace(zip_t *za, zip_uint64_t idx, zip_source_t *source, zip_flags_t flags) { - if (idx >= za->nentry || source == NULL) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (_zip_file_replace(za, idx, NULL, source, flags) == -1) - return -1; - - return 0; -} - - -/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ - -zip_int64_t -_zip_file_replace(zip_t *za, zip_uint64_t idx, const char *name, zip_source_t *source, zip_flags_t flags) { - zip_uint64_t za_nentry_prev; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - za_nentry_prev = za->nentry; - if (idx == ZIP_UINT64_MAX) { - zip_int64_t i = -1; - - if (flags & ZIP_FL_OVERWRITE) - i = _zip_name_locate(za, name, flags, NULL); - - if (i == -1) { - /* create and use new entry, used by zip_add */ - if ((i = _zip_add_entry(za)) < 0) - return -1; - } - idx = (zip_uint64_t)i; - } - - if (name && _zip_set_name(za, idx, name, flags) != 0) { - if (za->nentry != za_nentry_prev) { - _zip_entry_finalize(za->entry + idx); - za->nentry = za_nentry_prev; - } - return -1; - } - - /* does not change any name related data, so we can do it here; - * needed for a double add of the same file name */ - _zip_unchange_data(za->entry + idx); - - if (za->entry[idx].orig != NULL && (za->entry[idx].changes == NULL || (za->entry[idx].changes->changed & ZIP_DIRENT_COMP_METHOD) == 0)) { - if (za->entry[idx].changes == NULL) { - if ((za->entry[idx].changes = _zip_dirent_clone(za->entry[idx].orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - - za->entry[idx].changes->comp_method = ZIP_CM_REPLACED_DEFAULT; - za->entry[idx].changes->changed |= ZIP_DIRENT_COMP_METHOD; - } - - za->entry[idx].source = source; - - return (zip_int64_t)idx; -} diff --git a/Source/Libraries/libzip/zip_file_set_comment.c b/Source/Libraries/libzip/zip_file_set_comment.c deleted file mode 100644 index 8c76f25..0000000 --- a/Source/Libraries/libzip/zip_file_set_comment.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - zip_file_set_comment.c -- set comment for file in archive - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_file_set_comment(zip_t *za, zip_uint64_t idx, const char *comment, zip_uint16_t len, zip_flags_t flags) { - zip_entry_t *e; - zip_string_t *cstr; - int changed; - - if (_zip_get_dirent(za, idx, 0, NULL) == NULL) - return -1; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (len > 0 && comment == NULL) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (len > 0) { - if ((cstr = _zip_string_new((const zip_uint8_t *)comment, len, flags, &za->error)) == NULL) - return -1; - if ((flags & ZIP_FL_ENCODING_ALL) == ZIP_FL_ENC_GUESS && _zip_guess_encoding(cstr, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_UTF8_GUESSED) - cstr->encoding = ZIP_ENCODING_UTF8_KNOWN; - } - else - cstr = NULL; - - e = za->entry + idx; - - if (e->changes) { - _zip_string_free(e->changes->comment); - e->changes->comment = NULL; - e->changes->changed &= ~ZIP_DIRENT_COMMENT; - } - - if (e->orig && e->orig->comment) - changed = !_zip_string_equal(e->orig->comment, cstr); - else - changed = (cstr != NULL); - - if (changed) { - if (e->changes == NULL) { - if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - _zip_string_free(cstr); - return -1; - } - } - e->changes->comment = cstr; - e->changes->changed |= ZIP_DIRENT_COMMENT; - } - else { - _zip_string_free(cstr); - if (e->changes && e->changes->changed == 0) { - _zip_dirent_free(e->changes); - e->changes = NULL; - } - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_file_set_encryption.c b/Source/Libraries/libzip/zip_file_set_encryption.c deleted file mode 100644 index 6025e4a..0000000 --- a/Source/Libraries/libzip/zip_file_set_encryption.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - zip_file_set_encryption.c -- set encryption for file in archive - Copyright (C) 2016-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -#include -#include - -ZIP_EXTERN int -zip_file_set_encryption(zip_t *za, zip_uint64_t idx, zip_uint16_t method, const char *password) { - zip_entry_t *e; - zip_uint16_t old_method; - - if (idx >= za->nentry) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (method != ZIP_EM_NONE && _zip_get_encryption_implementation(method, ZIP_CODEC_ENCODE) == NULL) { - zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); - return -1; - } - - e = za->entry + idx; - - old_method = (e->orig == NULL ? ZIP_EM_NONE : e->orig->encryption_method); - - if (method == old_method && password == NULL) { - if (e->changes) { - if (e->changes->changed & ZIP_DIRENT_PASSWORD) { - _zip_crypto_clear(e->changes->password, strlen(e->changes->password)); - free(e->changes->password); - e->changes->password = (e->orig == NULL ? NULL : e->orig->password); - } - e->changes->changed &= ~(ZIP_DIRENT_ENCRYPTION_METHOD | ZIP_DIRENT_PASSWORD); - if (e->changes->changed == 0) { - _zip_dirent_free(e->changes); - e->changes = NULL; - } - } - } - else { - char *our_password = NULL; - - if (password) { - if ((our_password = strdup(password)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - - if (e->changes == NULL) { - if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { - if (our_password) { - _zip_crypto_clear(our_password, strlen(our_password)); - } - free(our_password); - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - - e->changes->encryption_method = method; - e->changes->changed |= ZIP_DIRENT_ENCRYPTION_METHOD; - if (password) { - e->changes->password = our_password; - e->changes->changed |= ZIP_DIRENT_PASSWORD; - } - else { - if (e->changes->changed & ZIP_DIRENT_PASSWORD) { - _zip_crypto_clear(e->changes->password, strlen(e->changes->password)); - free(e->changes->password); - e->changes->password = e->orig ? e->orig->password : NULL; - e->changes->changed &= ~ZIP_DIRENT_PASSWORD; - } - } - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_file_set_external_attributes.c b/Source/Libraries/libzip/zip_file_set_external_attributes.c deleted file mode 100644 index 0662f60..0000000 --- a/Source/Libraries/libzip/zip_file_set_external_attributes.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - zip_file_set_external_attributes.c -- set external attributes for entry - Copyright (C) 2013-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" - -ZIP_EXTERN int -zip_file_set_external_attributes(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_uint8_t opsys, zip_uint32_t attributes) { - zip_entry_t *e; - int changed; - zip_uint8_t unchanged_opsys; - zip_uint32_t unchanged_attributes; - - if (_zip_get_dirent(za, idx, 0, NULL) == NULL) - return -1; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - e = za->entry + idx; - - unchanged_opsys = (e->orig ? (zip_uint8_t)(e->orig->version_madeby >> 8) : (zip_uint8_t)ZIP_OPSYS_DEFAULT); - unchanged_attributes = e->orig ? e->orig->ext_attrib : ZIP_EXT_ATTRIB_DEFAULT; - - changed = (opsys != unchanged_opsys || attributes != unchanged_attributes); - - if (changed) { - if (e->changes == NULL) { - if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - e->changes->version_madeby = (zip_uint16_t)((opsys << 8) | (e->changes->version_madeby & 0xff)); - e->changes->ext_attrib = attributes; - e->changes->changed |= ZIP_DIRENT_ATTRIBUTES; - } - else if (e->changes) { - e->changes->changed &= ~ZIP_DIRENT_ATTRIBUTES; - if (e->changes->changed == 0) { - _zip_dirent_free(e->changes); - e->changes = NULL; - } - else { - e->changes->version_madeby = (zip_uint16_t)((unchanged_opsys << 8) | (e->changes->version_madeby & 0xff)); - e->changes->ext_attrib = unchanged_attributes; - } - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_file_set_mtime.c b/Source/Libraries/libzip/zip_file_set_mtime.c deleted file mode 100644 index 2753d59..0000000 --- a/Source/Libraries/libzip/zip_file_set_mtime.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - zip_file_set_mtime.c -- set modification time of entry. - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "zipint.h" - -ZIP_EXTERN int -zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) { - time_t mtime; - mtime = _zip_d2u_time(dtime, ddate); - return zip_file_set_mtime(za, idx, mtime, flags); -} - -ZIP_EXTERN int -zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) { - zip_entry_t *e; - - if (_zip_get_dirent(za, idx, 0, NULL) == NULL) - return -1; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - e = za->entry + idx; - - if (e->changes == NULL) { - if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - - e->changes->last_mod = mtime; - e->changes->changed |= ZIP_DIRENT_LAST_MOD; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_file_strerror.c b/Source/Libraries/libzip/zip_file_strerror.c deleted file mode 100644 index 2dcdba7..0000000 --- a/Source/Libraries/libzip/zip_file_strerror.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - zip_file_sterror.c -- get string representation of zip file error - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN const char * -zip_file_strerror(zip_file_t *zf) { - return zip_error_strerror(&zf->error); -} diff --git a/Source/Libraries/libzip/zip_fopen.c b/Source/Libraries/libzip/zip_fopen.c deleted file mode 100644 index 2da0cc5..0000000 --- a/Source/Libraries/libzip/zip_fopen.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_fopen.c -- open file in zip archive for reading - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_file_t * -zip_fopen(zip_t *za, const char *fname, zip_flags_t flags) { - zip_int64_t idx; - - if ((idx = zip_name_locate(za, fname, flags)) < 0) - return NULL; - - return zip_fopen_index_encrypted(za, (zip_uint64_t)idx, flags, za->default_password); -} diff --git a/Source/Libraries/libzip/zip_fopen_encrypted.c b/Source/Libraries/libzip/zip_fopen_encrypted.c deleted file mode 100644 index 8016015..0000000 --- a/Source/Libraries/libzip/zip_fopen_encrypted.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_fopen_encrypted.c -- open file for reading with password - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_file_t * -zip_fopen_encrypted(zip_t *za, const char *fname, zip_flags_t flags, const char *password) { - zip_int64_t idx; - - if ((idx = zip_name_locate(za, fname, flags)) < 0) - return NULL; - - return zip_fopen_index_encrypted(za, (zip_uint64_t)idx, flags, password); -} diff --git a/Source/Libraries/libzip/zip_fopen_index.c b/Source/Libraries/libzip/zip_fopen_index.c deleted file mode 100644 index 5fd5f1a..0000000 --- a/Source/Libraries/libzip/zip_fopen_index.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - zip_fopen_index.c -- open file in zip archive for reading by index - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_file_t * -zip_fopen_index(zip_t *za, zip_uint64_t index, zip_flags_t flags) { - return zip_fopen_index_encrypted(za, index, flags, za->default_password); -} diff --git a/Source/Libraries/libzip/zip_fopen_index_encrypted.c b/Source/Libraries/libzip/zip_fopen_index_encrypted.c deleted file mode 100644 index 280a5bd..0000000 --- a/Source/Libraries/libzip/zip_fopen_index_encrypted.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - zip_fopen_index_encrypted.c -- open file for reading by index w/ password - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - -static zip_file_t *_zip_file_new(zip_t *za); - - -ZIP_EXTERN zip_file_t * -zip_fopen_index_encrypted(zip_t *za, zip_uint64_t index, zip_flags_t flags, const char *password) { - zip_file_t *zf; - zip_source_t *src; - - if (password != NULL && password[0] == '\0') { - password = NULL; - } - - if ((src = _zip_source_zip_new(za, za, index, flags, 0, 0, password)) == NULL) - return NULL; - - if (zip_source_open(src) < 0) { - _zip_error_set_from_source(&za->error, src); - zip_source_free(src); - return NULL; - } - - if ((zf = _zip_file_new(za)) == NULL) { - zip_source_free(src); - return NULL; - } - - zf->src = src; - - return zf; -} - - -static zip_file_t * -_zip_file_new(zip_t *za) { - zip_file_t *zf; - - if ((zf = (zip_file_t *)malloc(sizeof(struct zip_file))) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return NULL; - } - - zf->za = za; - zip_error_init(&zf->error); - zf->eof = 0; - zf->src = NULL; - - return zf; -} diff --git a/Source/Libraries/libzip/zip_fread.c b/Source/Libraries/libzip/zip_fread.c deleted file mode 100644 index ecf0c3b..0000000 --- a/Source/Libraries/libzip/zip_fread.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - zip_fread.c -- read from file - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_int64_t -zip_fread(zip_file_t *zf, void *outbuf, zip_uint64_t toread) { - zip_int64_t n; - - if (!zf) - return -1; - - if (zf->error.zip_err != 0) - return -1; - - if (toread > ZIP_INT64_MAX) { - zip_error_set(&zf->error, ZIP_ER_INVAL, 0); - return -1; - } - - if ((zf->eof) || (toread == 0)) - return 0; - - if ((n = zip_source_read(zf->src, outbuf, toread)) < 0) { - _zip_error_set_from_source(&zf->error, zf->src); - return -1; - } - - return n; -} diff --git a/Source/Libraries/libzip/zip_fseek.c b/Source/Libraries/libzip/zip_fseek.c deleted file mode 100644 index 21f344a..0000000 --- a/Source/Libraries/libzip/zip_fseek.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - zip_fseek.c -- seek in file - Copyright (C) 2016-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -ZIP_EXTERN zip_int8_t -zip_fseek(zip_file_t *zf, zip_int64_t offset, int whence) { - if (!zf) - return -1; - - if (zf->error.zip_err != 0) - return -1; - - if (zip_source_seek(zf->src, offset, whence) < 0) { - _zip_error_set_from_source(&zf->error, zf->src); - return -1; - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_ftell.c b/Source/Libraries/libzip/zip_ftell.c deleted file mode 100644 index 2b36770..0000000 --- a/Source/Libraries/libzip/zip_ftell.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - zip_ftell.c -- tell position in file - Copyright (C) 2016-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -ZIP_EXTERN zip_int64_t -zip_ftell(zip_file_t *zf) { - zip_int64_t res; - - if (!zf) - return -1; - - if (zf->error.zip_err != 0) - return -1; - - res = zip_source_tell(zf->src); - if (res < 0) { - _zip_error_set_from_source(&zf->error, zf->src); - return -1; - } - - return res; -} diff --git a/Source/Libraries/libzip/zip_get_archive_comment.c b/Source/Libraries/libzip/zip_get_archive_comment.c deleted file mode 100644 index 18a4b61..0000000 --- a/Source/Libraries/libzip/zip_get_archive_comment.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - zip_get_archive_comment.c -- get archive comment - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN const char * -zip_get_archive_comment(zip_t *za, int *lenp, zip_flags_t flags) { - zip_string_t *comment; - zip_uint32_t len; - const zip_uint8_t *str; - - if ((flags & ZIP_FL_UNCHANGED) || (za->comment_changes == NULL)) - comment = za->comment_orig; - else - comment = za->comment_changes; - - if ((str = _zip_string_get(comment, &len, flags, &za->error)) == NULL) - return NULL; - - if (lenp) - *lenp = (int)len; - - return (const char *)str; -} diff --git a/Source/Libraries/libzip/zip_get_archive_flag.c b/Source/Libraries/libzip/zip_get_archive_flag.c deleted file mode 100644 index 3185ac5..0000000 --- a/Source/Libraries/libzip/zip_get_archive_flag.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - zip_get_archive_flag.c -- get archive global flag - Copyright (C) 2008-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_get_archive_flag(zip_t *za, zip_flags_t flag, zip_flags_t flags) { - unsigned int fl; - - fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags; - - return (fl & flag) ? 1 : 0; -} diff --git a/Source/Libraries/libzip/zip_get_encryption_implementation.c b/Source/Libraries/libzip/zip_get_encryption_implementation.c deleted file mode 100644 index 3270b84..0000000 --- a/Source/Libraries/libzip/zip_get_encryption_implementation.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - zip_get_encryption_implementation.c -- get encryption implementation - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -zip_encryption_implementation -_zip_get_encryption_implementation(zip_uint16_t em, int operation) { - switch (em) { - case ZIP_EM_TRAD_PKWARE: - return operation == ZIP_CODEC_DECODE ? zip_source_pkware_decode : zip_source_pkware_encode; - -#if defined(HAVE_CRYPTO) - case ZIP_EM_AES_128: - case ZIP_EM_AES_192: - case ZIP_EM_AES_256: - return operation == ZIP_CODEC_DECODE ? zip_source_winzip_aes_decode : zip_source_winzip_aes_encode; -#endif - - default: - return NULL; - } -} - -ZIP_EXTERN int -zip_encryption_method_supported(zip_uint16_t method, int encode) { - if (method == ZIP_EM_NONE) { - return 1; - } - return _zip_get_encryption_implementation(method, encode ? ZIP_CODEC_ENCODE : ZIP_CODEC_DECODE) != NULL; -} diff --git a/Source/Libraries/libzip/zip_get_file_comment.c b/Source/Libraries/libzip/zip_get_file_comment.c deleted file mode 100644 index 28429bc..0000000 --- a/Source/Libraries/libzip/zip_get_file_comment.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - zip_get_file_comment.c -- get file comment - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN const char * -zip_get_file_comment(zip_t *za, zip_uint64_t idx, int *lenp, int flags) { - zip_uint32_t len; - const char *s; - - if ((s = zip_file_get_comment(za, idx, &len, (zip_flags_t)flags)) != NULL) { - if (lenp) - *lenp = (int)len; - } - - return s; -} diff --git a/Source/Libraries/libzip/zip_get_name.c b/Source/Libraries/libzip/zip_get_name.c deleted file mode 100644 index 1a4bab8..0000000 --- a/Source/Libraries/libzip/zip_get_name.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - zip_get_name.c -- get filename for a file in zip file - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN const char * -zip_get_name(zip_t *za, zip_uint64_t idx, zip_flags_t flags) { - return _zip_get_name(za, idx, flags, &za->error); -} - - -const char * -_zip_get_name(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error) { - zip_dirent_t *de; - const zip_uint8_t *str; - - if ((de = _zip_get_dirent(za, idx, flags, error)) == NULL) - return NULL; - - if ((str = _zip_string_get(de->filename, NULL, flags, error)) == NULL) - return NULL; - - return (const char *)str; -} diff --git a/Source/Libraries/libzip/zip_get_num_entries.c b/Source/Libraries/libzip/zip_get_num_entries.c deleted file mode 100644 index 3b18c74..0000000 --- a/Source/Libraries/libzip/zip_get_num_entries.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - zip_get_num_entries.c -- get number of entries in archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_int64_t -zip_get_num_entries(zip_t *za, zip_flags_t flags) { - zip_uint64_t n; - - if (za == NULL) - return -1; - - if (flags & ZIP_FL_UNCHANGED) { - n = za->nentry; - while (n > 0 && za->entry[n - 1].orig == NULL) - --n; - return (zip_int64_t)n; - } - return (zip_int64_t)za->nentry; -} diff --git a/Source/Libraries/libzip/zip_get_num_files.c b/Source/Libraries/libzip/zip_get_num_files.c deleted file mode 100644 index 23d7c9c..0000000 --- a/Source/Libraries/libzip/zip_get_num_files.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - zip_get_num_files.c -- get number of files in archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" -#include - - -ZIP_EXTERN int -zip_get_num_files(zip_t *za) { - if (za == NULL) - return -1; - - if (za->nentry > INT_MAX) { - zip_error_set(&za->error, ZIP_ER_OPNOTSUPP, 0); - return -1; - } - - return (int)za->nentry; -} diff --git a/Source/Libraries/libzip/zip_hash.c b/Source/Libraries/libzip/zip_hash.c deleted file mode 100644 index 56e8d78..0000000 --- a/Source/Libraries/libzip/zip_hash.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - zip_hash.c -- hash table string -> uint64 - Copyright (C) 2015-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" -#include -#include - -/* parameter for the string hash function */ -#define HASH_MULTIPLIER 33 -#define HASH_START 5381 - -/* hash table's fill ratio is kept between these by doubling/halfing its size as necessary */ -#define HASH_MAX_FILL .75 -#define HASH_MIN_FILL .01 - -/* but hash table size is kept between these */ -#define HASH_MIN_SIZE 256 -#define HASH_MAX_SIZE 0x80000000ul - -struct zip_hash_entry { - const zip_uint8_t *name; - zip_int64_t orig_index; - zip_int64_t current_index; - struct zip_hash_entry *next; - zip_uint32_t hash_value; -}; -typedef struct zip_hash_entry zip_hash_entry_t; - -struct zip_hash { - zip_uint32_t table_size; - zip_uint64_t nentries; - zip_hash_entry_t **table; -}; - - -/* free list of entries */ -static void -free_list(zip_hash_entry_t *entry) { - while (entry != NULL) { - zip_hash_entry_t *next = entry->next; - free(entry); - entry = next; - } -} - - -/* compute hash of string, full 32 bit value */ -static zip_uint32_t -hash_string(const zip_uint8_t *name) { - zip_uint64_t value = HASH_START; - - if (name == NULL) { - return 0; - } - - while (*name != 0) { - value = (zip_uint64_t)(((value * HASH_MULTIPLIER) + (zip_uint8_t)*name) % 0x100000000ul); - name++; - } - - return (zip_uint32_t)value; -} - - -/* resize hash table; new_size must be a power of 2, can be larger or smaller than current size */ -static bool -hash_resize(zip_hash_t *hash, zip_uint32_t new_size, zip_error_t *error) { - zip_hash_entry_t **new_table; - - if (new_size == hash->table_size) { - return true; - } - - if ((new_table = (zip_hash_entry_t **)calloc(new_size, sizeof(zip_hash_entry_t *))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return false; - } - - if (hash->nentries > 0) { - zip_uint32_t i; - - for (i = 0; i < hash->table_size; i++) { - zip_hash_entry_t *entry = hash->table[i]; - while (entry) { - zip_hash_entry_t *next = entry->next; - - zip_uint32_t new_index = entry->hash_value % new_size; - - entry->next = new_table[new_index]; - new_table[new_index] = entry; - - entry = next; - } - } - } - - free(hash->table); - hash->table = new_table; - hash->table_size = new_size; - - return true; -} - - -static zip_uint32_t -size_for_capacity(zip_uint64_t capacity) { - double needed_size = capacity / HASH_MAX_FILL; - zip_uint32_t v; - - if (needed_size > ZIP_UINT32_MAX) { - v = ZIP_UINT32_MAX; - } - else { - v = (zip_uint32_t)needed_size; - } - - if (v > HASH_MAX_SIZE) { - return HASH_MAX_SIZE; - } - - /* From Bit Twiddling Hacks by Sean Eron Anderson - (http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2). */ - - v--; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - v++; - - return v; -} - - -zip_hash_t * -_zip_hash_new(zip_error_t *error) { - zip_hash_t *hash; - - if ((hash = (zip_hash_t *)malloc(sizeof(zip_hash_t))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - hash->table_size = 0; - hash->nentries = 0; - hash->table = NULL; - - return hash; -} - - -void -_zip_hash_free(zip_hash_t *hash) { - zip_uint32_t i; - - if (hash == NULL) { - return; - } - - if (hash->table != NULL) { - for (i = 0; i < hash->table_size; i++) { - if (hash->table[i] != NULL) { - free_list(hash->table[i]); - } - } - free(hash->table); - } - free(hash); -} - - -/* insert into hash, return error on existence or memory issues */ -bool -_zip_hash_add(zip_hash_t *hash, const zip_uint8_t *name, zip_uint64_t index, zip_flags_t flags, zip_error_t *error) { - zip_uint32_t hash_value, table_index; - zip_hash_entry_t *entry; - - if (hash == NULL || name == NULL || index > ZIP_INT64_MAX) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return false; - } - - if (hash->table_size == 0) { - if (!hash_resize(hash, HASH_MIN_SIZE, error)) { - return false; - } - } - - hash_value = hash_string(name); - table_index = hash_value % hash->table_size; - - for (entry = hash->table[table_index]; entry != NULL; entry = entry->next) { - if (entry->hash_value == hash_value && strcmp((const char *)name, (const char *)entry->name) == 0) { - if (((flags & ZIP_FL_UNCHANGED) && entry->orig_index != -1) || entry->current_index != -1) { - zip_error_set(error, ZIP_ER_EXISTS, 0); - return false; - } - else { - break; - } - } - } - - if (entry == NULL) { - if ((entry = (zip_hash_entry_t *)malloc(sizeof(zip_hash_entry_t))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return false; - } - entry->name = name; - entry->next = hash->table[table_index]; - hash->table[table_index] = entry; - entry->hash_value = hash_value; - entry->orig_index = -1; - hash->nentries++; - if (hash->nentries > hash->table_size * HASH_MAX_FILL && hash->table_size < HASH_MAX_SIZE) { - if (!hash_resize(hash, hash->table_size * 2, error)) { - return false; - } - } - } - - if (flags & ZIP_FL_UNCHANGED) { - entry->orig_index = (zip_int64_t)index; - } - entry->current_index = (zip_int64_t)index; - - return true; -} - - -/* remove entry from hash, error if not found */ -bool -_zip_hash_delete(zip_hash_t *hash, const zip_uint8_t *name, zip_error_t *error) { - zip_uint32_t hash_value, index; - zip_hash_entry_t *entry, *previous; - - if (hash == NULL || name == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return false; - } - - if (hash->nentries > 0) { - hash_value = hash_string(name); - index = hash_value % hash->table_size; - previous = NULL; - entry = hash->table[index]; - while (entry) { - if (entry->hash_value == hash_value && strcmp((const char *)name, (const char *)entry->name) == 0) { - if (entry->orig_index == -1) { - if (previous) { - previous->next = entry->next; - } - else { - hash->table[index] = entry->next; - } - free(entry); - hash->nentries--; - if (hash->nentries < hash->table_size * HASH_MIN_FILL && hash->table_size > HASH_MIN_SIZE) { - if (!hash_resize(hash, hash->table_size / 2, error)) { - return false; - } - } - } - else { - entry->current_index = -1; - } - return true; - } - previous = entry; - entry = entry->next; - } - } - - zip_error_set(error, ZIP_ER_NOENT, 0); - return false; -} - - -/* find value for entry in hash, -1 if not found */ -zip_int64_t -_zip_hash_lookup(zip_hash_t *hash, const zip_uint8_t *name, zip_flags_t flags, zip_error_t *error) { - zip_uint32_t hash_value, index; - zip_hash_entry_t *entry; - - if (hash == NULL || name == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return -1; - } - - if (hash->nentries > 0) { - hash_value = hash_string(name); - index = hash_value % hash->table_size; - for (entry = hash->table[index]; entry != NULL; entry = entry->next) { - if (strcmp((const char *)name, (const char *)entry->name) == 0) { - if (flags & ZIP_FL_UNCHANGED) { - if (entry->orig_index != -1) { - return entry->orig_index; - } - } - else { - if (entry->current_index != -1) { - return entry->current_index; - } - } - break; - } - } - } - - zip_error_set(error, ZIP_ER_NOENT, 0); - return -1; -} - - -bool -_zip_hash_reserve_capacity(zip_hash_t *hash, zip_uint64_t capacity, zip_error_t *error) { - zip_uint32_t new_size; - - if (capacity == 0) { - return true; - } - - new_size = size_for_capacity(capacity); - - if (new_size <= hash->table_size) { - return true; - } - - if (!hash_resize(hash, new_size, error)) { - return false; - } - - return true; -} - - -bool -_zip_hash_revert(zip_hash_t *hash, zip_error_t *error) { - zip_uint32_t i; - zip_hash_entry_t *entry, *previous; - - for (i = 0; i < hash->table_size; i++) { - previous = NULL; - entry = hash->table[i]; - while (entry) { - if (entry->orig_index == -1) { - zip_hash_entry_t *p; - if (previous) { - previous->next = entry->next; - } - else { - hash->table[i] = entry->next; - } - p = entry; - entry = entry->next; - /* previous does not change */ - free(p); - hash->nentries--; - } - else { - entry->current_index = entry->orig_index; - previous = entry; - entry = entry->next; - } - } - } - - if (hash->nentries < hash->table_size * HASH_MIN_FILL && hash->table_size > HASH_MIN_SIZE) { - zip_uint32_t new_size = hash->table_size / 2; - while (hash->nentries < new_size * HASH_MIN_FILL && new_size > HASH_MIN_SIZE) { - new_size /= 2; - } - if (!hash_resize(hash, new_size, error)) { - return false; - } - } - - return true; -} diff --git a/Source/Libraries/libzip/zip_io_util.c b/Source/Libraries/libzip/zip_io_util.c deleted file mode 100644 index 3678dd5..0000000 --- a/Source/Libraries/libzip/zip_io_util.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - zip_io_util.c -- I/O helper functions - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "zipint.h" - -int -_zip_read(zip_source_t *src, zip_uint8_t *b, zip_uint64_t length, zip_error_t *error) { - zip_int64_t n; - - if (length > ZIP_INT64_MAX) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - return -1; - } - - if ((n = zip_source_read(src, b, length)) < 0) { - _zip_error_set_from_source(error, src); - return -1; - } - - if (n < (zip_int64_t)length) { - zip_error_set(error, ZIP_ER_EOF, 0); - return -1; - } - - return 0; -} - - -zip_uint8_t * -_zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp, zip_error_t *error) { - zip_uint8_t *r; - - if (length == 0 && !nulp) { - return NULL; - } - - r = (zip_uint8_t *)malloc(length + (nulp ? 1 : 0)); - if (!r) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - if (buffer) { - zip_uint8_t *data = _zip_buffer_get(buffer, length); - - if (data == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - free(r); - return NULL; - } - memcpy(r, data, length); - } - else { - if (_zip_read(src, r, length, error) < 0) { - free(r); - return NULL; - } - } - - if (nulp) { - zip_uint8_t *o; - /* replace any in-string NUL characters with spaces */ - r[length] = 0; - for (o = r; o < r + length; o++) - if (*o == '\0') - *o = ' '; - } - - return r; -} - - -zip_string_t * -_zip_read_string(zip_buffer_t *buffer, zip_source_t *src, zip_uint16_t len, bool nulp, zip_error_t *error) { - zip_uint8_t *raw; - zip_string_t *s; - - if ((raw = _zip_read_data(buffer, src, len, nulp, error)) == NULL) - return NULL; - - s = _zip_string_new(raw, len, ZIP_FL_ENC_GUESS, error); - free(raw); - return s; -} - - -int -_zip_write(zip_t *za, const void *data, zip_uint64_t length) { - zip_int64_t n; - - if ((n = zip_source_write(za->src, data, length)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return -1; - } - if ((zip_uint64_t)n != length) { - zip_error_set(&za->error, ZIP_ER_WRITE, EINTR); - return -1; - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_libzip_version.c b/Source/Libraries/libzip/zip_libzip_version.c deleted file mode 100644 index df1e55b..0000000 --- a/Source/Libraries/libzip/zip_libzip_version.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - zip_libzip_version.c -- return run-time version of library - Copyright (C) 2017-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN const char * -zip_libzip_version(void) { - return LIBZIP_VERSION; -} diff --git a/Source/Libraries/libzip/zip_memdup.c b/Source/Libraries/libzip/zip_memdup.c deleted file mode 100644 index 1691860..0000000 --- a/Source/Libraries/libzip/zip_memdup.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - zip_memdup.c -- internal zip function, "strdup" with len - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include - -#include "zipint.h" - - -void * -_zip_memdup(const void *mem, size_t len, zip_error_t *error) { - void *ret; - - if (len == 0) - return NULL; - - ret = malloc(len); - if (!ret) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - memcpy(ret, mem, len); - - return ret; -} diff --git a/Source/Libraries/libzip/zip_name_locate.c b/Source/Libraries/libzip/zip_name_locate.c deleted file mode 100644 index 308d843..0000000 --- a/Source/Libraries/libzip/zip_name_locate.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - zip_name_locate.c -- get index by name - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#ifdef HAVE_STRINGS_H -#include -#endif - -#include "zipint.h" - - -ZIP_EXTERN zip_int64_t -zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags) { - return _zip_name_locate(za, fname, flags, &za->error); -} - - -zip_int64_t -_zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags, zip_error_t *error) { - int (*cmp)(const char *, const char *); - const char *fn, *p; - zip_uint64_t i; - - if (za == NULL) - return -1; - - if (fname == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return -1; - } - - if (flags & (ZIP_FL_NOCASE | ZIP_FL_NODIR | ZIP_FL_ENC_CP437)) { - /* can't use hash table */ - cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp; - - for (i = 0; i < za->nentry; i++) { - fn = _zip_get_name(za, i, flags, error); - - /* newly added (partially filled) entry or error */ - if (fn == NULL) - continue; - - if (flags & ZIP_FL_NODIR) { - p = strrchr(fn, '/'); - if (p) - fn = p + 1; - } - - if (cmp(fname, fn) == 0) { - _zip_error_clear(error); - return (zip_int64_t)i; - } - } - - zip_error_set(error, ZIP_ER_NOENT, 0); - return -1; - } - else { - return _zip_hash_lookup(za->names, (const zip_uint8_t *)fname, flags, error); - } -} diff --git a/Source/Libraries/libzip/zip_new.c b/Source/Libraries/libzip/zip_new.c deleted file mode 100644 index d2a5fa1..0000000 --- a/Source/Libraries/libzip/zip_new.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - zip_new.c -- create and init struct zip - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -/* _zip_new: - creates a new zipfile struct, and sets the contents to zero; returns - the new struct. */ - -zip_t * -_zip_new(zip_error_t *error) { - zip_t *za; - - za = (zip_t *)malloc(sizeof(struct zip)); - if (!za) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - if ((za->names = _zip_hash_new(error)) == NULL) { - free(za); - return NULL; - } - - za->src = NULL; - za->open_flags = 0; - zip_error_init(&za->error); - za->flags = za->ch_flags = 0; - za->default_password = NULL; - za->comment_orig = za->comment_changes = NULL; - za->comment_changed = 0; - za->nentry = za->nentry_alloc = 0; - za->entry = NULL; - za->nopen_source = za->nopen_source_alloc = 0; - za->open_source = NULL; - za->progress = NULL; - - return za; -} diff --git a/Source/Libraries/libzip/zip_open.c b/Source/Libraries/libzip/zip_open.c deleted file mode 100644 index 292bfc8..0000000 --- a/Source/Libraries/libzip/zip_open.c +++ /dev/null @@ -1,849 +0,0 @@ -/* - zip_open.c -- open zip archive by name - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include -#include - -#include "zipint.h" - -typedef enum { EXISTS_ERROR = -1, EXISTS_NOT = 0, EXISTS_OK } exists_t; -static zip_t *_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error); -static zip_int64_t _zip_checkcons(zip_t *za, zip_cdir_t *cdir, zip_error_t *error); -static zip_cdir_t *_zip_find_central_dir(zip_t *za, zip_uint64_t len); -static exists_t _zip_file_exists(zip_source_t *src, zip_error_t *error); -static int _zip_headercomp(const zip_dirent_t *, const zip_dirent_t *); -static unsigned char *_zip_memmem(const unsigned char *, size_t, const unsigned char *, size_t); -static zip_cdir_t *_zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error); -static zip_cdir_t *_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error); -static zip_cdir_t *_zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error); - - -ZIP_EXTERN zip_t * -zip_open(const char *fn, int _flags, int *zep) { - zip_t *za; - zip_source_t *src; - struct zip_error error; - - zip_error_init(&error); - if ((src = zip_source_file_create(fn, 0, -1, &error)) == NULL) { - _zip_set_open_error(zep, &error, 0); - zip_error_fini(&error); - return NULL; - } - - if ((za = zip_open_from_source(src, _flags, &error)) == NULL) { - zip_source_free(src); - _zip_set_open_error(zep, &error, 0); - zip_error_fini(&error); - return NULL; - } - - zip_error_fini(&error); - return za; -} - - -ZIP_EXTERN zip_t * -zip_open_from_source(zip_source_t *src, int _flags, zip_error_t *error) { - static zip_int64_t needed_support_read = -1; - static zip_int64_t needed_support_write = -1; - - unsigned int flags; - zip_int64_t supported; - exists_t exists; - - if (_flags < 0 || src == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - flags = (unsigned int)_flags; - - supported = zip_source_supports(src); - if (needed_support_read == -1) { - needed_support_read = zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_SEEK, ZIP_SOURCE_TELL, ZIP_SOURCE_STAT, -1); - needed_support_write = zip_source_make_command_bitmap(ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_REMOVE, -1); - } - if ((supported & needed_support_read) != needed_support_read) { - zip_error_set(error, ZIP_ER_OPNOTSUPP, 0); - return NULL; - } - if ((supported & needed_support_write) != needed_support_write) { - flags |= ZIP_RDONLY; - } - - if ((flags & (ZIP_RDONLY | ZIP_TRUNCATE)) == (ZIP_RDONLY | ZIP_TRUNCATE)) { - zip_error_set(error, ZIP_ER_RDONLY, 0); - return NULL; - } - - exists = _zip_file_exists(src, error); - switch (exists) { - case EXISTS_ERROR: - return NULL; - - case EXISTS_NOT: - if ((flags & ZIP_CREATE) == 0) { - zip_error_set(error, ZIP_ER_NOENT, 0); - return NULL; - } - return _zip_allocate_new(src, flags, error); - - default: { - zip_t *za; - if (flags & ZIP_EXCL) { - zip_error_set(error, ZIP_ER_EXISTS, 0); - return NULL; - } - if (zip_source_open(src) < 0) { - _zip_error_set_from_source(error, src); - return NULL; - } - - if (flags & ZIP_TRUNCATE) { - za = _zip_allocate_new(src, flags, error); - } - else { - /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL, just like open() */ - za = _zip_open(src, flags, error); - } - - if (za == NULL) { - zip_source_close(src); - return NULL; - } - return za; - } - } -} - - -zip_t * -_zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error) { - zip_t *za; - zip_cdir_t *cdir; - struct zip_stat st; - zip_uint64_t len, idx; - - zip_stat_init(&st); - if (zip_source_stat(src, &st) < 0) { - _zip_error_set_from_source(error, src); - return NULL; - } - if ((st.valid & ZIP_STAT_SIZE) == 0) { - zip_error_set(error, ZIP_ER_SEEK, EOPNOTSUPP); - return NULL; - } - len = st.size; - - - if ((za = _zip_allocate_new(src, flags, error)) == NULL) { - return NULL; - } - - /* treat empty files as empty archives */ - if (len == 0 && zip_source_accept_empty(src)) { - return za; - } - - if ((cdir = _zip_find_central_dir(za, len)) == NULL) { - _zip_error_copy(error, &za->error); - /* keep src so discard does not get rid of it */ - zip_source_keep(src); - zip_discard(za); - return NULL; - } - - za->entry = cdir->entry; - za->nentry = cdir->nentry; - za->nentry_alloc = cdir->nentry_alloc; - za->comment_orig = cdir->comment; - - free(cdir); - - _zip_hash_reserve_capacity(za->names, za->nentry, &za->error); - - for (idx = 0; idx < za->nentry; idx++) { - const zip_uint8_t *name = _zip_string_get(za->entry[idx].orig->filename, NULL, 0, error); - if (name == NULL) { - /* keep src so discard does not get rid of it */ - zip_source_keep(src); - zip_discard(za); - return NULL; - } - - if (_zip_hash_add(za->names, name, idx, ZIP_FL_UNCHANGED, &za->error) == false) { - if (za->error.zip_err != ZIP_ER_EXISTS || (flags & ZIP_CHECKCONS)) { - _zip_error_copy(error, &za->error); - /* keep src so discard does not get rid of it */ - zip_source_keep(src); - zip_discard(za); - return NULL; - } - } - } - - za->ch_flags = za->flags; - - return za; -} - - -void -_zip_set_open_error(int *zep, const zip_error_t *err, int ze) { - if (err) { - ze = zip_error_code_zip(err); - if (zip_error_system_type(err) == ZIP_ET_SYS) { - errno = zip_error_code_system(err); - } - } - - if (zep) - *zep = ze; -} - - -/* _zip_readcdir: - tries to find a valid end-of-central-directory at the beginning of - buf, and then the corresponding central directory entries. - Returns a struct zip_cdir which contains the central directory - entries, or NULL if unsuccessful. */ - -static zip_cdir_t * -_zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error) { - zip_cdir_t *cd; - zip_uint16_t comment_len; - zip_uint64_t i, left; - zip_uint64_t eocd_offset = _zip_buffer_offset(buffer); - zip_buffer_t *cd_buffer; - - if (_zip_buffer_left(buffer) < EOCDLEN) { - /* not enough bytes left for comment */ - zip_error_set(error, ZIP_ER_NOZIP, 0); - return NULL; - } - - /* check for end-of-central-dir magic */ - if (memcmp(_zip_buffer_get(buffer, 4), EOCD_MAGIC, 4) != 0) { - zip_error_set(error, ZIP_ER_NOZIP, 0); - return NULL; - } - - if (eocd_offset >= EOCD64LOCLEN && memcmp(_zip_buffer_data(buffer) + eocd_offset - EOCD64LOCLEN, EOCD64LOC_MAGIC, 4) == 0) { - _zip_buffer_set_offset(buffer, eocd_offset - EOCD64LOCLEN); - cd = _zip_read_eocd64(za->src, buffer, buf_offset, za->flags, error); - } - else { - _zip_buffer_set_offset(buffer, eocd_offset); - cd = _zip_read_eocd(buffer, buf_offset, za->flags, error); - } - - if (cd == NULL) - return NULL; - - _zip_buffer_set_offset(buffer, eocd_offset + 20); - comment_len = _zip_buffer_get_16(buffer); - - if (cd->offset + cd->size > buf_offset + eocd_offset) { - /* cdir spans past EOCD record */ - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_cdir_free(cd); - return NULL; - } - - if (comment_len || (za->open_flags & ZIP_CHECKCONS)) { - zip_uint64_t tail_len; - - _zip_buffer_set_offset(buffer, eocd_offset + EOCDLEN); - tail_len = _zip_buffer_left(buffer); - - if (tail_len < comment_len || ((za->open_flags & ZIP_CHECKCONS) && tail_len != comment_len)) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_cdir_free(cd); - return NULL; - } - - if (comment_len) { - if ((cd->comment = _zip_string_new(_zip_buffer_get(buffer, comment_len), comment_len, ZIP_FL_ENC_GUESS, error)) == NULL) { - _zip_cdir_free(cd); - return NULL; - } - } - } - - if (cd->offset >= buf_offset) { - zip_uint8_t *data; - /* if buffer already read in, use it */ - _zip_buffer_set_offset(buffer, cd->offset - buf_offset); - - if ((data = _zip_buffer_get(buffer, cd->size)) == NULL) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_cdir_free(cd); - return NULL; - } - if ((cd_buffer = _zip_buffer_new(data, cd->size)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - _zip_cdir_free(cd); - return NULL; - } - } - else { - cd_buffer = NULL; - - if (zip_source_seek(za->src, (zip_int64_t)cd->offset, SEEK_SET) < 0) { - _zip_error_set_from_source(error, za->src); - _zip_cdir_free(cd); - return NULL; - } - - /* possible consistency check: cd->offset = len-(cd->size+cd->comment_len+EOCDLEN) ? */ - if (zip_source_tell(za->src) != (zip_int64_t)cd->offset) { - zip_error_set(error, ZIP_ER_NOZIP, 0); - _zip_cdir_free(cd); - return NULL; - } - } - - left = (zip_uint64_t)cd->size; - i = 0; - while (left > 0) { - bool grown = false; - zip_int64_t entry_size; - - if (i == cd->nentry) { - /* InfoZIP has a hack to avoid using Zip64: it stores nentries % 0x10000 */ - /* This hack isn't applicable if we're using Zip64, or if there is no central directory entry following. */ - - if (cd->is_zip64 || left < CDENTRYSIZE) { - break; - } - - if (!_zip_cdir_grow(cd, 0x10000, error)) { - _zip_cdir_free(cd); - _zip_buffer_free(cd_buffer); - return NULL; - } - grown = true; - } - - if ((cd->entry[i].orig = _zip_dirent_new()) == NULL || (entry_size = _zip_dirent_read(cd->entry[i].orig, za->src, cd_buffer, false, error)) < 0) { - if (grown && zip_error_code_zip(error) == ZIP_ER_NOZIP) { - zip_error_set(error, ZIP_ER_INCONS, 0); - } - _zip_cdir_free(cd); - _zip_buffer_free(cd_buffer); - return NULL; - } - i++; - left -= (zip_uint64_t)entry_size; - } - - if (i != cd->nentry || left > 0) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_buffer_free(cd_buffer); - _zip_cdir_free(cd); - return NULL; - } - - if (za->open_flags & ZIP_CHECKCONS) { - bool ok; - - if (cd_buffer) { - ok = _zip_buffer_eof(cd_buffer); - } - else { - zip_int64_t offset = zip_source_tell(za->src); - - if (offset < 0) { - _zip_error_set_from_source(error, za->src); - _zip_cdir_free(cd); - return NULL; - } - ok = ((zip_uint64_t)offset == cd->offset + cd->size); - } - - if (!ok) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_buffer_free(cd_buffer); - _zip_cdir_free(cd); - return NULL; - } - } - - _zip_buffer_free(cd_buffer); - return cd; -} - - -/* _zip_checkcons: - Checks the consistency of the central directory by comparing central - directory entries with local headers and checking for plausible - file and header offsets. Returns -1 if not plausible, else the - difference between the lowest and the highest fileposition reached */ - -static zip_int64_t -_zip_checkcons(zip_t *za, zip_cdir_t *cd, zip_error_t *error) { - zip_uint64_t i; - zip_uint64_t min, max, j; - struct zip_dirent temp; - - _zip_dirent_init(&temp); - if (cd->nentry) { - max = cd->entry[0].orig->offset; - min = cd->entry[0].orig->offset; - } - else - min = max = 0; - - for (i = 0; i < cd->nentry; i++) { - if (cd->entry[i].orig->offset < min) - min = cd->entry[i].orig->offset; - if (min > (zip_uint64_t)cd->offset) { - zip_error_set(error, ZIP_ER_NOZIP, 0); - return -1; - } - - j = cd->entry[i].orig->offset + cd->entry[i].orig->comp_size + _zip_string_length(cd->entry[i].orig->filename) + LENTRYSIZE; - if (j > max) - max = j; - if (max > (zip_uint64_t)cd->offset) { - zip_error_set(error, ZIP_ER_NOZIP, 0); - return -1; - } - - if (zip_source_seek(za->src, (zip_int64_t)cd->entry[i].orig->offset, SEEK_SET) < 0) { - _zip_error_set_from_source(error, za->src); - return -1; - } - - if (_zip_dirent_read(&temp, za->src, NULL, true, error) == -1) { - _zip_dirent_finalize(&temp); - return -1; - } - - if (_zip_headercomp(cd->entry[i].orig, &temp) != 0) { - zip_error_set(error, ZIP_ER_INCONS, 0); - _zip_dirent_finalize(&temp); - return -1; - } - - cd->entry[i].orig->extra_fields = _zip_ef_merge(cd->entry[i].orig->extra_fields, temp.extra_fields); - cd->entry[i].orig->local_extra_fields_read = 1; - temp.extra_fields = NULL; - - _zip_dirent_finalize(&temp); - } - - return (max - min) < ZIP_INT64_MAX ? (zip_int64_t)(max - min) : ZIP_INT64_MAX; -} - - -/* _zip_headercomp: - compares a central directory entry and a local file header - Return 0 if they are consistent, -1 if not. */ - -static int -_zip_headercomp(const zip_dirent_t *central, const zip_dirent_t *local) { - if ((central->version_needed < local->version_needed) -#if 0 - /* some zip-files have different values in local - and global headers for the bitflags */ - || (central->bitflags != local->bitflags) -#endif - || (central->comp_method != local->comp_method) || (central->last_mod != local->last_mod) || !_zip_string_equal(central->filename, local->filename)) - return -1; - - if ((central->crc != local->crc) || (central->comp_size != local->comp_size) || (central->uncomp_size != local->uncomp_size)) { - /* InfoZip stores valid values in local header even when data descriptor is used. - This is in violation of the appnote. */ - if (((local->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local->crc != 0 || local->comp_size != 0 || local->uncomp_size != 0)) - return -1; - } - - return 0; -} - - -static zip_t * -_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error) { - zip_t *za; - - if ((za = _zip_new(error)) == NULL) { - return NULL; - } - - za->src = src; - za->open_flags = flags; - if (flags & ZIP_RDONLY) { - za->flags |= ZIP_AFL_RDONLY; - za->ch_flags |= ZIP_AFL_RDONLY; - } - return za; -} - - -/* - * tests for file existence - */ -static exists_t -_zip_file_exists(zip_source_t *src, zip_error_t *error) { - struct zip_stat st; - - zip_stat_init(&st); - if (zip_source_stat(src, &st) != 0) { - zip_error_t *src_error = zip_source_error(src); - if (zip_error_code_zip(src_error) == ZIP_ER_READ && zip_error_code_system(src_error) == ENOENT) { - return EXISTS_NOT; - } - _zip_error_copy(error, src_error); - return EXISTS_ERROR; - } - - return EXISTS_OK; -} - - -static zip_cdir_t * -_zip_find_central_dir(zip_t *za, zip_uint64_t len) { - zip_cdir_t *cdir, *cdirnew; - zip_uint8_t *match; - zip_int64_t buf_offset; - zip_uint64_t buflen; - zip_int64_t a; - zip_int64_t best; - zip_error_t error; - zip_buffer_t *buffer; - - if (len < EOCDLEN) { - zip_error_set(&za->error, ZIP_ER_NOZIP, 0); - return NULL; - } - - buflen = (len < CDBUFSIZE ? len : CDBUFSIZE); - if (zip_source_seek(za->src, -(zip_int64_t)buflen, SEEK_END) < 0) { - zip_error_t *src_error = zip_source_error(za->src); - if (zip_error_code_zip(src_error) != ZIP_ER_SEEK || zip_error_code_system(src_error) != EFBIG) { - /* seek before start of file on my machine */ - _zip_error_copy(&za->error, src_error); - return NULL; - } - } - if ((buf_offset = zip_source_tell(za->src)) < 0) { - _zip_error_set_from_source(&za->error, za->src); - return NULL; - } - - if ((buffer = _zip_buffer_new_from_source(za->src, buflen, NULL, &za->error)) == NULL) { - return NULL; - } - - best = -1; - cdir = NULL; - if (buflen >= CDBUFSIZE) { - /* EOCD64 locator is before EOCD, so leave place for it */ - _zip_buffer_set_offset(buffer, EOCD64LOCLEN); - } - zip_error_set(&error, ZIP_ER_NOZIP, 0); - - match = _zip_buffer_get(buffer, 0); - while ((match = _zip_memmem(match, _zip_buffer_left(buffer) - (EOCDLEN - 4), (const unsigned char *)EOCD_MAGIC, 4)) != NULL) { - _zip_buffer_set_offset(buffer, (zip_uint64_t)(match - _zip_buffer_data(buffer))); - if ((cdirnew = _zip_read_cdir(za, buffer, (zip_uint64_t)buf_offset, &error)) != NULL) { - if (cdir) { - if (best <= 0) { - best = _zip_checkcons(za, cdir, &error); - } - - a = _zip_checkcons(za, cdirnew, &error); - if (best < a) { - _zip_cdir_free(cdir); - cdir = cdirnew; - best = a; - } - else { - _zip_cdir_free(cdirnew); - } - } - else { - cdir = cdirnew; - if (za->open_flags & ZIP_CHECKCONS) - best = _zip_checkcons(za, cdir, &error); - else { - best = 0; - } - } - cdirnew = NULL; - } - - match++; - _zip_buffer_set_offset(buffer, (zip_uint64_t)(match - _zip_buffer_data(buffer))); - } - - _zip_buffer_free(buffer); - - if (best < 0) { - _zip_error_copy(&za->error, &error); - _zip_cdir_free(cdir); - return NULL; - } - - return cdir; -} - - -static unsigned char * -_zip_memmem(const unsigned char *big, size_t biglen, const unsigned char *little, size_t littlelen) { - const unsigned char *p; - - if ((biglen < littlelen) || (littlelen == 0)) - return NULL; - p = big - 1; - while ((p = (const unsigned char *)memchr(p + 1, little[0], (size_t)(big - (p + 1)) + (size_t)(biglen - littlelen) + 1)) != NULL) { - if (memcmp(p + 1, little + 1, littlelen - 1) == 0) - return (unsigned char *)p; - } - - return NULL; -} - - -static zip_cdir_t * -_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error) { - zip_cdir_t *cd; - zip_uint64_t i, nentry, size, offset, eocd_offset; - - if (_zip_buffer_left(buffer) < EOCDLEN) { - zip_error_set(error, ZIP_ER_INCONS, 0); - return NULL; - } - - eocd_offset = _zip_buffer_offset(buffer); - - _zip_buffer_get(buffer, 4); /* magic already verified */ - - if (_zip_buffer_get_32(buffer) != 0) { - zip_error_set(error, ZIP_ER_MULTIDISK, 0); - return NULL; - } - - /* number of cdir-entries on this disk */ - i = _zip_buffer_get_16(buffer); - /* number of cdir-entries */ - nentry = _zip_buffer_get_16(buffer); - - if (nentry != i) { - zip_error_set(error, ZIP_ER_NOZIP, 0); - return NULL; - } - - size = _zip_buffer_get_32(buffer); - offset = _zip_buffer_get_32(buffer); - - if (offset + size < offset) { - zip_error_set(error, ZIP_ER_SEEK, EFBIG); - return NULL; - } - - if (offset + size > buf_offset + eocd_offset) { - /* cdir spans past EOCD record */ - zip_error_set(error, ZIP_ER_INCONS, 0); - return NULL; - } - - if ((flags & ZIP_CHECKCONS) && offset + size != buf_offset + eocd_offset) { - zip_error_set(error, ZIP_ER_INCONS, 0); - return NULL; - } - - if ((cd = _zip_cdir_new(nentry, error)) == NULL) - return NULL; - - cd->is_zip64 = false; - cd->size = size; - cd->offset = offset; - - return cd; -} - - -static zip_cdir_t * -_zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error) { - zip_cdir_t *cd; - zip_uint64_t offset; - zip_uint8_t eocd[EOCD64LEN]; - zip_uint64_t eocd_offset; - zip_uint64_t size, nentry, i, eocdloc_offset; - bool free_buffer; - zip_uint32_t num_disks, num_disks64, eocd_disk, eocd_disk64; - - eocdloc_offset = _zip_buffer_offset(buffer); - - _zip_buffer_get(buffer, 4); /* magic already verified */ - - num_disks = _zip_buffer_get_16(buffer); - eocd_disk = _zip_buffer_get_16(buffer); - eocd_offset = _zip_buffer_get_64(buffer); - - /* valid seek value for start of EOCD */ - if (eocd_offset > ZIP_INT64_MAX) { - zip_error_set(error, ZIP_ER_SEEK, EFBIG); - return NULL; - } - - /* does EOCD fit before EOCD locator? */ - if (eocd_offset + EOCD64LEN > eocdloc_offset + buf_offset) { - zip_error_set(error, ZIP_ER_INCONS, 0); - return NULL; - } - - /* make sure current position of buffer is beginning of EOCD */ - if (eocd_offset >= buf_offset && eocd_offset + EOCD64LEN <= buf_offset + _zip_buffer_size(buffer)) { - _zip_buffer_set_offset(buffer, eocd_offset - buf_offset); - free_buffer = false; - } - else { - if (zip_source_seek(src, (zip_int64_t)eocd_offset, SEEK_SET) < 0) { - _zip_error_set_from_source(error, src); - return NULL; - } - if ((buffer = _zip_buffer_new_from_source(src, EOCD64LEN, eocd, error)) == NULL) { - return NULL; - } - free_buffer = true; - } - - if (memcmp(_zip_buffer_get(buffer, 4), EOCD64_MAGIC, 4) != 0) { - zip_error_set(error, ZIP_ER_INCONS, 0); - if (free_buffer) { - _zip_buffer_free(buffer); - } - return NULL; - } - - /* size of EOCD */ - size = _zip_buffer_get_64(buffer); - - /* is there a hole between EOCD and EOCD locator, or do they overlap? */ - if ((flags & ZIP_CHECKCONS) && size + eocd_offset + 12 != buf_offset + eocdloc_offset) { - zip_error_set(error, ZIP_ER_INCONS, 0); - if (free_buffer) { - _zip_buffer_free(buffer); - } - return NULL; - } - - _zip_buffer_get(buffer, 4); /* skip version made by/needed */ - - num_disks64 = _zip_buffer_get_32(buffer); - eocd_disk64 = _zip_buffer_get_32(buffer); - - /* if eocd values are 0xffff, we have to use eocd64 values. - otherwise, if the values are not the same, it's inconsistent; - in any case, if the value is not 0, we don't support it */ - if (num_disks == 0xffff) { - num_disks = num_disks64; - } - if (eocd_disk == 0xffff) { - eocd_disk = eocd_disk64; - } - if ((flags & ZIP_CHECKCONS) && (eocd_disk != eocd_disk64 || num_disks != num_disks64)) { - zip_error_set(error, ZIP_ER_INCONS, 0); - if (free_buffer) { - _zip_buffer_free(buffer); - } - return NULL; - } - if (num_disks != 0 || eocd_disk != 0) { - zip_error_set(error, ZIP_ER_MULTIDISK, 0); - if (free_buffer) { - _zip_buffer_free(buffer); - } - return NULL; - } - - nentry = _zip_buffer_get_64(buffer); - i = _zip_buffer_get_64(buffer); - - if (nentry != i) { - zip_error_set(error, ZIP_ER_MULTIDISK, 0); - if (free_buffer) { - _zip_buffer_free(buffer); - } - return NULL; - } - - size = _zip_buffer_get_64(buffer); - offset = _zip_buffer_get_64(buffer); - - /* did we read past the end of the buffer? */ - if (!_zip_buffer_ok(buffer)) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - if (free_buffer) { - _zip_buffer_free(buffer); - } - return NULL; - } - - if (free_buffer) { - _zip_buffer_free(buffer); - } - - if (offset > ZIP_INT64_MAX || offset + size < offset) { - zip_error_set(error, ZIP_ER_SEEK, EFBIG); - return NULL; - } - if (offset + size > buf_offset + eocd_offset) { - /* cdir spans past EOCD record */ - zip_error_set(error, ZIP_ER_INCONS, 0); - return NULL; - } - if ((flags & ZIP_CHECKCONS) && offset + size != buf_offset + eocd_offset) { - zip_error_set(error, ZIP_ER_INCONS, 0); - return NULL; - } - - if (nentry > size / CDENTRYSIZE) { - zip_error_set(error, ZIP_ER_INCONS, 0); - return NULL; - } - - if ((cd = _zip_cdir_new(nentry, error)) == NULL) - return NULL; - - cd->is_zip64 = true; - cd->size = size; - cd->offset = offset; - - return cd; -} diff --git a/Source/Libraries/libzip/zip_pkware.c b/Source/Libraries/libzip/zip_pkware.c deleted file mode 100644 index 1b1b461..0000000 --- a/Source/Libraries/libzip/zip_pkware.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - zip_pkware.c -- Traditional PKWARE de/encryption backend routines - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - -#define PKWARE_KEY0 305419896 -#define PKWARE_KEY1 591751049 -#define PKWARE_KEY2 878082192 - - -static void -update_keys(zip_pkware_keys_t *keys, zip_uint8_t b) { - keys->key[0] = (zip_uint32_t)crc32(keys->key[0] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL; - keys->key[1] = (keys->key[1] + (keys->key[0] & 0xff)) * 134775813 + 1; - b = (zip_uint8_t)(keys->key[1] >> 24); - keys->key[2] = (zip_uint32_t)crc32(keys->key[2] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL; -} - - -static zip_uint8_t -crypt_byte(zip_pkware_keys_t *keys) { - zip_uint16_t tmp; - tmp = (zip_uint16_t)(keys->key[2] | 2); - tmp = (zip_uint16_t)(((zip_uint32_t)tmp * (tmp ^ 1)) >> 8); - return (zip_uint8_t)tmp; -} - - -void -_zip_pkware_keys_reset(zip_pkware_keys_t *keys) { - keys->key[0] = PKWARE_KEY0; - keys->key[1] = PKWARE_KEY1; - keys->key[2] = PKWARE_KEY2; -} - - -void -_zip_pkware_encrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len) { - zip_uint64_t i; - zip_uint8_t b; - zip_uint8_t tmp; - - for (i = 0; i < len; i++) { - b = in[i]; - - if (out != NULL) { - tmp = crypt_byte(keys); - update_keys(keys, b); - b ^= tmp; - out[i] = b; - } - else { - /* during initialization, we're only interested in key updates */ - update_keys(keys, b); - } - } -} - - -void -_zip_pkware_decrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len) { - zip_uint64_t i; - zip_uint8_t b; - zip_uint8_t tmp; - - for (i = 0; i < len; i++) { - b = in[i]; - - /* during initialization, we're only interested in key updates */ - if (out != NULL) { - tmp = crypt_byte(keys); - b ^= tmp; - out[i] = b; - } - - update_keys(keys, b); - } -} diff --git a/Source/Libraries/libzip/zip_progress.c b/Source/Libraries/libzip/zip_progress.c deleted file mode 100644 index a881df4..0000000 --- a/Source/Libraries/libzip/zip_progress.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - zip_progress.c -- progress reporting - Copyright (C) 2017-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - -struct zip_progress { - zip_t *za; - - zip_progress_callback callback_progress; - void (*ud_progress_free)(void *); - void *ud_progress; - - zip_cancel_callback callback_cancel; - void (*ud_cancel_free)(void *); - void *ud_cancel; - - double precision; - - /* state */ - double last_update; /* last value callback function was called with */ - - double start; /* start of sub-progress section */ - double end; /* end of sub-progress section */ -}; - -static void _zip_progress_free_cancel_callback(zip_progress_t *progress); -static void _zip_progress_free_progress_callback(zip_progress_t *progress); -static zip_progress_t *_zip_progress_new(zip_t *za); -static void _zip_progress_set_cancel_callback(zip_progress_t *progress, zip_cancel_callback callback, void (*ud_free)(void *), void *ud); -static void _zip_progress_set_progress_callback(zip_progress_t *progress, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud); - -void -_zip_progress_end(zip_progress_t *progress) { - _zip_progress_update(progress, 1.0); -} - - -void -_zip_progress_free(zip_progress_t *progress) { - if (progress == NULL) { - return; - } - - _zip_progress_free_progress_callback(progress); - _zip_progress_free_cancel_callback(progress); - - free(progress); -} - - -static zip_progress_t * -_zip_progress_new(zip_t *za) { - zip_progress_t *progress = (zip_progress_t *)malloc(sizeof(*progress)); - - if (progress == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return NULL; - } - - progress->za = za; - - progress->callback_progress = NULL; - progress->ud_progress_free = NULL; - progress->ud_progress = NULL; - progress->precision = 0.0; - - progress->callback_cancel = NULL; - progress->ud_cancel_free = NULL; - progress->ud_cancel = NULL; - - return progress; -} - -static void -_zip_progress_free_progress_callback(zip_progress_t *progress) { - if (progress->ud_progress_free) { - progress->ud_progress_free(progress->ud_progress); - } - - progress->callback_progress = NULL; - progress->ud_progress = NULL; - progress->ud_progress_free = NULL; -} - -static void -_zip_progress_free_cancel_callback(zip_progress_t *progress) { - if (progress->ud_cancel_free) { - progress->ud_cancel_free(progress->ud_cancel); - } - - progress->callback_cancel = NULL; - progress->ud_cancel = NULL; - progress->ud_cancel_free = NULL; -} - -static void -_zip_progress_set_progress_callback(zip_progress_t *progress, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud) { - _zip_progress_free_progress_callback(progress); - - progress->callback_progress = callback; - progress->ud_progress_free = ud_free; - progress->ud_progress = ud; - progress->precision = precision; -} - -void -_zip_progress_set_cancel_callback(zip_progress_t *progress, zip_cancel_callback callback, void (*ud_free)(void *), void *ud) { - _zip_progress_free_cancel_callback(progress); - - progress->callback_cancel = callback; - progress->ud_cancel_free = ud_free; - progress->ud_cancel = ud; -} - -int -_zip_progress_start(zip_progress_t *progress) { - if (progress == NULL) { - return 0; - } - - if (progress->callback_progress != NULL) { - progress->last_update = 0.0; - progress->callback_progress(progress->za, 0.0, progress->ud_progress); - } - - if (progress->callback_cancel != NULL) { - if (progress->callback_cancel(progress->za, progress->ud_cancel)) { - return -1; - } - } - - return 0; -} - - -int -_zip_progress_subrange(zip_progress_t *progress, double start, double end) { - if (progress == NULL) { - return 0; - } - - progress->start = start; - progress->end = end; - - return _zip_progress_update(progress, 0.0); -} - -int -_zip_progress_update(zip_progress_t *progress, double sub_current) { - double current; - - if (progress == NULL) { - return 0; - } - - if (progress->callback_progress != NULL) { - current = ZIP_MIN(ZIP_MAX(sub_current, 0.0), 1.0) * (progress->end - progress->start) + progress->start; - - if (current - progress->last_update > progress->precision) { - progress->callback_progress(progress->za, current, progress->ud_progress); - progress->last_update = current; - } - } - - if (progress->callback_cancel != NULL) { - if (progress->callback_cancel(progress->za, progress->ud_cancel)) { - return -1; - } - } - - return 0; -} - - -ZIP_EXTERN int -zip_register_progress_callback_with_state(zip_t *za, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud) { - if (callback != NULL) { - if (za->progress == NULL) { - if ((za->progress = _zip_progress_new(za)) == NULL) { - return -1; - } - } - - _zip_progress_set_progress_callback(za->progress, precision, callback, ud_free, ud); - } - else { - if (za->progress != NULL) { - if (za->progress->callback_cancel == NULL) { - _zip_progress_free(za->progress); - za->progress = NULL; - } - else { - _zip_progress_free_progress_callback(za->progress); - } - } - } - - return 0; -} - - -ZIP_EXTERN int -zip_register_cancel_callback_with_state(zip_t *za, zip_cancel_callback callback, void (*ud_free)(void *), void *ud) { - if (callback != NULL) { - if (za->progress == NULL) { - if ((za->progress = _zip_progress_new(za)) == NULL) { - return -1; - } - } - - _zip_progress_set_cancel_callback(za->progress, callback, ud_free, ud); - } - else { - if (za->progress != NULL) { - if (za->progress->callback_progress == NULL) { - _zip_progress_free(za->progress); - za->progress = NULL; - } - else { - _zip_progress_free_cancel_callback(za->progress); - } - } - } - - return 0; -} - - -struct legacy_ud { - zip_progress_callback_t callback; -}; - - -static void -_zip_legacy_progress_callback(zip_t *za, double progress, void *vud) { - struct legacy_ud *ud = (struct legacy_ud *)vud; - - ud->callback(progress); -} - -ZIP_EXTERN void -zip_register_progress_callback(zip_t *za, zip_progress_callback_t progress_callback) { - struct legacy_ud *ud; - - if (progress_callback == NULL) { - zip_register_progress_callback_with_state(za, 0, NULL, NULL, NULL); - } - - if ((ud = (struct legacy_ud *)malloc(sizeof(*ud))) == NULL) { - return; - } - - ud->callback = progress_callback; - - if (zip_register_progress_callback_with_state(za, 0.001, _zip_legacy_progress_callback, free, ud) < 0) { - free(ud); - } -} diff --git a/Source/Libraries/libzip/zip_rename.c b/Source/Libraries/libzip/zip_rename.c deleted file mode 100644 index eb1b395..0000000 --- a/Source/Libraries/libzip/zip_rename.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - zip_rename.c -- rename file in zip archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN int -zip_rename(zip_t *za, zip_uint64_t idx, const char *name) { - return zip_file_rename(za, idx, name, 0); -} diff --git a/Source/Libraries/libzip/zip_replace.c b/Source/Libraries/libzip/zip_replace.c deleted file mode 100644 index 2140223..0000000 --- a/Source/Libraries/libzip/zip_replace.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - zip_replace.c -- replace file via callback function - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN int -zip_replace(zip_t *za, zip_uint64_t idx, zip_source_t *source) { - return zip_file_replace(za, idx, source, 0); -} diff --git a/Source/Libraries/libzip/zip_set_archive_comment.c b/Source/Libraries/libzip/zip_set_archive_comment.c deleted file mode 100644 index ce0c5d3..0000000 --- a/Source/Libraries/libzip/zip_set_archive_comment.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - zip_set_archive_comment.c -- set archive comment - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_set_archive_comment(zip_t *za, const char *comment, zip_uint16_t len) { - zip_string_t *cstr; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (len > 0 && comment == NULL) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (len > 0) { - if ((cstr = _zip_string_new((const zip_uint8_t *)comment, len, ZIP_FL_ENC_GUESS, &za->error)) == NULL) - return -1; - - if (_zip_guess_encoding(cstr, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_CP437) { - _zip_string_free(cstr); - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - } - else - cstr = NULL; - - _zip_string_free(za->comment_changes); - za->comment_changes = NULL; - - if (((za->comment_orig && _zip_string_equal(za->comment_orig, cstr)) || (za->comment_orig == NULL && cstr == NULL))) { - _zip_string_free(cstr); - za->comment_changed = 0; - } - else { - za->comment_changes = cstr; - za->comment_changed = 1; - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_set_archive_flag.c b/Source/Libraries/libzip/zip_set_archive_flag.c deleted file mode 100644 index fe9f62f..0000000 --- a/Source/Libraries/libzip/zip_set_archive_flag.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - zip_get_archive_flag.c -- set archive global flag - Copyright (C) 2008-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_set_archive_flag(zip_t *za, zip_flags_t flag, int value) { - unsigned int new_flags; - - if (value) - new_flags = za->ch_flags | flag; - else - new_flags = za->ch_flags & ~flag; - - if (new_flags == za->ch_flags) - return 0; - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if ((flag & ZIP_AFL_RDONLY) && value && (za->ch_flags & ZIP_AFL_RDONLY) == 0) { - if (_zip_changed(za, NULL)) { - zip_error_set(&za->error, ZIP_ER_CHANGED, 0); - return -1; - } - } - - za->ch_flags = new_flags; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_set_default_password.c b/Source/Libraries/libzip/zip_set_default_password.c deleted file mode 100644 index d893949..0000000 --- a/Source/Libraries/libzip/zip_set_default_password.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - zip_set_default_password.c -- set default password for decryption - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_set_default_password(zip_t *za, const char *passwd) { - if (za == NULL) - return -1; - - free(za->default_password); - - if (passwd && passwd[0] != '\0') { - if ((za->default_password = strdup(passwd)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - else - za->default_password = NULL; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_set_file_comment.c b/Source/Libraries/libzip/zip_set_file_comment.c deleted file mode 100644 index d19121f..0000000 --- a/Source/Libraries/libzip/zip_set_file_comment.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_set_file_comment.c -- set comment for file in archive - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. -*/ - - -#define _ZIP_COMPILING_DEPRECATED -#include "zipint.h" - - -ZIP_EXTERN int -zip_set_file_comment(zip_t *za, zip_uint64_t idx, const char *comment, int len) { - if (len < 0 || len > ZIP_UINT16_MAX) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - return zip_file_set_comment(za, idx, comment, (zip_uint16_t)len, 0); -} diff --git a/Source/Libraries/libzip/zip_set_file_compression.c b/Source/Libraries/libzip/zip_set_file_compression.c deleted file mode 100644 index 511c7d5..0000000 --- a/Source/Libraries/libzip/zip_set_file_compression.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - zip_set_file_compression.c -- set compression for file in archive - Copyright (C) 2012-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_set_file_compression(zip_t *za, zip_uint64_t idx, zip_int32_t method, zip_uint32_t flags) { - zip_entry_t *e; - zip_int32_t old_method; - - if (idx >= za->nentry || flags > 9) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (!zip_compression_method_supported(method, true)) { - zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0); - return -1; - } - - e = za->entry + idx; - - old_method = (e->orig == NULL ? ZIP_CM_DEFAULT : e->orig->comp_method); - - /* TODO: do we want to recompress if level is set? Only if it's - * different than what bit flags tell us, but those are not - * defined for all compression methods, or not directly mappable - * to levels */ - - if (method == old_method) { - if (e->changes) { - e->changes->changed &= ~ZIP_DIRENT_COMP_METHOD; - e->changes->compression_level = 0; - if (e->changes->changed == 0) { - _zip_dirent_free(e->changes); - e->changes = NULL; - } - } - } - else { - if (e->changes == NULL) { - if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - } - - e->changes->comp_method = method; - e->changes->compression_level = (zip_uint16_t)flags; - e->changes->changed |= ZIP_DIRENT_COMP_METHOD; - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_set_name.c b/Source/Libraries/libzip/zip_set_name.c deleted file mode 100644 index 5267685..0000000 --- a/Source/Libraries/libzip/zip_set_name.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - zip_set_name.c -- rename helper function - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - - -int -_zip_set_name(zip_t *za, zip_uint64_t idx, const char *name, zip_flags_t flags) { - zip_entry_t *e; - zip_string_t *str; - bool same_as_orig; - zip_int64_t i; - const zip_uint8_t *old_name, *new_name; - zip_string_t *old_str; - - if (idx >= za->nentry) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (ZIP_IS_RDONLY(za)) { - zip_error_set(&za->error, ZIP_ER_RDONLY, 0); - return -1; - } - - if (name && name[0] != '\0') { - /* TODO: check for string too long */ - if ((str = _zip_string_new((const zip_uint8_t *)name, (zip_uint16_t)strlen(name), flags, &za->error)) == NULL) - return -1; - if ((flags & ZIP_FL_ENCODING_ALL) == ZIP_FL_ENC_GUESS && _zip_guess_encoding(str, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_UTF8_GUESSED) - str->encoding = ZIP_ENCODING_UTF8_KNOWN; - } - else - str = NULL; - - /* TODO: encoding flags needed for CP437? */ - if ((i = _zip_name_locate(za, name, 0, NULL)) >= 0 && (zip_uint64_t)i != idx) { - _zip_string_free(str); - zip_error_set(&za->error, ZIP_ER_EXISTS, 0); - return -1; - } - - /* no effective name change */ - if (i >= 0 && (zip_uint64_t)i == idx) { - _zip_string_free(str); - return 0; - } - - e = za->entry + idx; - - if (e->orig) - same_as_orig = _zip_string_equal(e->orig->filename, str); - else - same_as_orig = false; - - if (!same_as_orig && e->changes == NULL) { - if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - _zip_string_free(str); - return -1; - } - } - - if ((new_name = _zip_string_get(same_as_orig ? e->orig->filename : str, NULL, 0, &za->error)) == NULL) { - _zip_string_free(str); - return -1; - } - - if (e->changes) { - old_str = e->changes->filename; - } - else if (e->orig) { - old_str = e->orig->filename; - } - else { - old_str = NULL; - } - - if (old_str) { - if ((old_name = _zip_string_get(old_str, NULL, 0, &za->error)) == NULL) { - _zip_string_free(str); - return -1; - } - } - else { - old_name = NULL; - } - - if (_zip_hash_add(za->names, new_name, idx, 0, &za->error) == false) { - _zip_string_free(str); - return -1; - } - if (old_name) { - _zip_hash_delete(za->names, old_name, NULL); - } - - if (same_as_orig) { - if (e->changes) { - if (e->changes->changed & ZIP_DIRENT_FILENAME) { - _zip_string_free(e->changes->filename); - e->changes->changed &= ~ZIP_DIRENT_FILENAME; - if (e->changes->changed == 0) { - _zip_dirent_free(e->changes); - e->changes = NULL; - } - else { - /* TODO: what if not cloned? can that happen? */ - e->changes->filename = e->orig->filename; - } - } - } - _zip_string_free(str); - } - else { - if (e->changes->changed & ZIP_DIRENT_FILENAME) { - _zip_string_free(e->changes->filename); - } - e->changes->changed |= ZIP_DIRENT_FILENAME; - e->changes->filename = str; - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_accept_empty.c b/Source/Libraries/libzip/zip_source_accept_empty.c deleted file mode 100644 index 754b80b..0000000 --- a/Source/Libraries/libzip/zip_source_accept_empty.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - zip_source_accept_empty.c -- if empty source is a valid archive - Copyright (C) 2019-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -bool -zip_source_accept_empty(zip_source_t *src) { - int ret; - - if ((zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY)) == 0) { - if (ZIP_SOURCE_IS_LAYERED(src)) { - return zip_source_accept_empty(src->src); - } - return true; - } - - ret = (int)_zip_source_call(src, NULL, 0, ZIP_SOURCE_ACCEPT_EMPTY); - - return ret != 0; -} diff --git a/Source/Libraries/libzip/zip_source_begin_write.c b/Source/Libraries/libzip/zip_source_begin_write.c deleted file mode 100644 index 3981dc1..0000000 --- a/Source/Libraries/libzip/zip_source_begin_write.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - zip_source_begin_write.c -- start a new file for writing - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_source_begin_write(zip_source_t *src) { - if (ZIP_SOURCE_IS_OPEN_WRITING(src)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_BEGIN_WRITE) < 0) { - return -1; - } - - src->write_state = ZIP_SOURCE_WRITE_OPEN; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_begin_write_cloning.c b/Source/Libraries/libzip/zip_source_begin_write_cloning.c deleted file mode 100644 index bfc63c8..0000000 --- a/Source/Libraries/libzip/zip_source_begin_write_cloning.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - zip_source_begin_write_cloning.c -- clone part of file for writing - Copyright (C) 2017-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_source_begin_write_cloning(zip_source_t *src, zip_uint64_t offset) { - if (ZIP_SOURCE_IS_OPEN_WRITING(src)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (_zip_source_call(src, NULL, offset, ZIP_SOURCE_BEGIN_WRITE_CLONING) < 0) { - return -1; - } - - src->write_state = ZIP_SOURCE_WRITE_OPEN; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_buffer.c b/Source/Libraries/libzip/zip_source_buffer.c deleted file mode 100644 index a54c4fc..0000000 --- a/Source/Libraries/libzip/zip_source_buffer.c +++ /dev/null @@ -1,620 +0,0 @@ -/* - zip_source_buffer.c -- create zip data source from buffer - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include - -#include "zipint.h" - -#ifndef WRITE_FRAGMENT_SIZE -#define WRITE_FRAGMENT_SIZE (64 * 1024) -#endif - -struct buffer { - zip_buffer_fragment_t *fragments; /* fragments */ - zip_uint64_t *fragment_offsets; /* offset of each fragment from start of buffer, nfragments+1 entries */ - zip_uint64_t nfragments; /* number of allocated fragments */ - zip_uint64_t fragments_capacity; /* size of fragments (number of pointers) */ - - zip_uint64_t first_owned_fragment; /* first fragment to free data from */ - - zip_uint64_t shared_fragments; /* number of shared fragments */ - struct buffer *shared_buffer; /* buffer fragments are shared with */ - zip_uint64_t size; /* size of buffer */ - - zip_uint64_t offset; /* current offset in buffer */ - zip_uint64_t current_fragment; /* fragment current offset is in */ -}; - -typedef struct buffer buffer_t; - -struct read_data { - zip_error_t error; - time_t mtime; - zip_file_attributes_t attributes; - buffer_t *in; - buffer_t *out; -}; - -#define buffer_capacity(buffer) ((buffer)->fragment_offsets[(buffer)->nfragments]) -#define buffer_size(buffer) ((buffer)->size) - -static buffer_t *buffer_clone(buffer_t *buffer, zip_uint64_t length, zip_error_t *error); -static zip_uint64_t buffer_find_fragment(const buffer_t *buffer, zip_uint64_t offset); -static void buffer_free(buffer_t *buffer); -static bool buffer_grow_fragments(buffer_t *buffer, zip_uint64_t capacity, zip_error_t *error); -static buffer_t *buffer_new(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int free_data, zip_error_t *error); -static zip_int64_t buffer_read(buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length); -static int buffer_seek(buffer_t *buffer, void *data, zip_uint64_t len, zip_error_t *error); -static zip_int64_t buffer_write(buffer_t *buffer, const zip_uint8_t *data, zip_uint64_t length, zip_error_t *); - -static zip_int64_t read_data(void *, void *, zip_uint64_t, zip_source_cmd_t); - -zip_source_t *zip_source_buffer_with_attributes_create(const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes, zip_error_t *error); -zip_source_t *zip_source_buffer_fragment_with_attributes_create(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep, zip_file_attributes_t *attributes, zip_error_t *error); - - -ZIP_EXTERN zip_source_t * -zip_source_buffer(zip_t *za, const void *data, zip_uint64_t len, int freep) { - if (za == NULL) - return NULL; - - return zip_source_buffer_with_attributes_create(data, len, freep, NULL, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_buffer_create(const void *data, zip_uint64_t len, int freep, zip_error_t *error) { - return zip_source_buffer_with_attributes_create(data, len, freep, NULL, error); -} - - -zip_source_t * -zip_source_buffer_with_attributes_create(const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes, zip_error_t *error) { - zip_buffer_fragment_t fragment; - - if (data == NULL) { - if (len > 0) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - return zip_source_buffer_fragment_with_attributes_create(NULL, 0, freep, attributes, error); - } - - fragment.data = (zip_uint8_t *)data; - fragment.length = len; - - return zip_source_buffer_fragment_with_attributes_create(&fragment, 1, freep, attributes, error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_buffer_fragment(zip_t *za, const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep) { - if (za == NULL) { - return NULL; - } - - return zip_source_buffer_fragment_with_attributes_create(fragments, nfragments, freep, NULL, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_buffer_fragment_create(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep, zip_error_t *error) { - return zip_source_buffer_fragment_with_attributes_create(fragments, nfragments, freep, NULL, error); -} - -zip_source_t * -zip_source_buffer_fragment_with_attributes_create(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep, zip_file_attributes_t *attributes, zip_error_t *error) { - struct read_data *ctx; - zip_source_t *zs; - buffer_t *buffer; - - if (fragments == NULL && nfragments > 0) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((buffer = buffer_new(fragments, nfragments, freep, error)) == NULL) { - return NULL; - } - - if ((ctx = (struct read_data *)malloc(sizeof(*ctx))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - buffer_free(buffer); - return NULL; - } - - ctx->in = buffer; - ctx->out = NULL; - ctx->mtime = time(NULL); - if (attributes) { - memcpy(&ctx->attributes, attributes, sizeof(ctx->attributes)); - } - else { - zip_file_attributes_init(&ctx->attributes); - } - zip_error_init(&ctx->error); - - if ((zs = zip_source_function_create(read_data, ctx, error)) == NULL) { - buffer_free(ctx->in); - free(ctx); - return NULL; - } - - return zs; -} - - -zip_source_t * -zip_source_buffer_with_attributes(zip_t *za, const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes) { - return zip_source_buffer_with_attributes_create(data, len, freep, attributes, &za->error); -} - -static zip_int64_t -read_data(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { - struct read_data *ctx = (struct read_data *)state; - - switch (cmd) { - case ZIP_SOURCE_BEGIN_WRITE: - if ((ctx->out = buffer_new(NULL, 0, 0, &ctx->error)) == NULL) { - return -1; - } - ctx->out->offset = 0; - ctx->out->current_fragment = 0; - return 0; - - case ZIP_SOURCE_BEGIN_WRITE_CLONING: - if ((ctx->out = buffer_clone(ctx->in, len, &ctx->error)) == NULL) { - return -1; - } - ctx->out->offset = len; - ctx->out->current_fragment = ctx->out->nfragments; - return 0; - - case ZIP_SOURCE_CLOSE: - return 0; - - case ZIP_SOURCE_COMMIT_WRITE: - buffer_free(ctx->in); - ctx->in = ctx->out; - ctx->out = NULL; - return 0; - - case ZIP_SOURCE_ERROR: - return zip_error_to_data(&ctx->error, data, len); - - case ZIP_SOURCE_FREE: - buffer_free(ctx->in); - buffer_free(ctx->out); - free(ctx); - return 0; - - case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { - if (len < sizeof(ctx->attributes)) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - - memcpy(data, &ctx->attributes, sizeof(ctx->attributes)); - - return sizeof(ctx->attributes); - } - - case ZIP_SOURCE_OPEN: - ctx->in->offset = 0; - ctx->in->current_fragment = 0; - return 0; - - case ZIP_SOURCE_READ: - if (len > ZIP_INT64_MAX) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - return buffer_read(ctx->in, data, len); - - case ZIP_SOURCE_REMOVE: { - buffer_t *empty = buffer_new(NULL, 0, 0, &ctx->error); - if (empty == NULL) { - return -1; - } - - buffer_free(ctx->in); - ctx->in = empty; - return 0; - } - - case ZIP_SOURCE_ROLLBACK_WRITE: - buffer_free(ctx->out); - ctx->out = NULL; - return 0; - - case ZIP_SOURCE_SEEK: - return buffer_seek(ctx->in, data, len, &ctx->error); - - case ZIP_SOURCE_SEEK_WRITE: - return buffer_seek(ctx->out, data, len, &ctx->error); - - case ZIP_SOURCE_STAT: { - zip_stat_t *st; - - if (len < sizeof(*st)) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - - st = (zip_stat_t *)data; - - zip_stat_init(st); - st->mtime = ctx->mtime; - st->size = ctx->in->size; - st->comp_size = st->size; - st->comp_method = ZIP_CM_STORE; - st->encryption_method = ZIP_EM_NONE; - st->valid = ZIP_STAT_MTIME | ZIP_STAT_SIZE | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD; - - return sizeof(*st); - } - - case ZIP_SOURCE_SUPPORTS: - return zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_SEEK, ZIP_SOURCE_TELL, ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_BEGIN_WRITE_CLONING, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_REMOVE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_WRITE, -1); - - case ZIP_SOURCE_TELL: - if (ctx->in->offset > ZIP_INT64_MAX) { - zip_error_set(&ctx->error, ZIP_ER_TELL, EOVERFLOW); - return -1; - } - return (zip_int64_t)ctx->in->offset; - - - case ZIP_SOURCE_TELL_WRITE: - if (ctx->out->offset > ZIP_INT64_MAX) { - zip_error_set(&ctx->error, ZIP_ER_TELL, EOVERFLOW); - return -1; - } - return (zip_int64_t)ctx->out->offset; - - case ZIP_SOURCE_WRITE: - if (len > ZIP_INT64_MAX) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - return buffer_write(ctx->out, data, len, &ctx->error); - - default: - zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); - return -1; - } -} - - -static buffer_t * -buffer_clone(buffer_t *buffer, zip_uint64_t offset, zip_error_t *error) { - zip_uint64_t fragment, fragment_offset, waste; - buffer_t *clone; - - if (offset == 0) { - return buffer_new(NULL, 0, 1, error); - } - - if (offset > buffer->size) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - if (buffer->shared_buffer != NULL) { - zip_error_set(error, ZIP_ER_INUSE, 0); - return NULL; - } - - fragment = buffer_find_fragment(buffer, offset); - fragment_offset = offset - buffer->fragment_offsets[fragment]; - - if (fragment_offset == 0) { - fragment--; - fragment_offset = buffer->fragments[fragment].length; - } - - waste = buffer->fragments[fragment].length - fragment_offset; - if (waste > offset) { - zip_error_set(error, ZIP_ER_OPNOTSUPP, 0); - return NULL; - } - - if ((clone = buffer_new(buffer->fragments, fragment + 1, 0, error)) == NULL) { - return NULL; - } - -#ifndef __clang_analyzer__ - /* clone->fragments can't be null, since it was created with at least one fragment */ - clone->fragments[clone->nfragments - 1].length = fragment_offset; -#endif - clone->fragment_offsets[clone->nfragments] = offset; - clone->size = offset; - - clone->first_owned_fragment = ZIP_MIN(buffer->first_owned_fragment, clone->nfragments - 1); - - buffer->shared_buffer = clone; - clone->shared_buffer = buffer; - buffer->shared_fragments = clone->nfragments; - clone->shared_fragments = fragment + 1; - - return clone; -} - - -static zip_uint64_t -buffer_find_fragment(const buffer_t *buffer, zip_uint64_t offset) { - zip_uint64_t low, high, mid; - - low = 0; - high = buffer->nfragments - 1; - - while (low < high) { - mid = (high - low) / 2 + low; - if (buffer->fragment_offsets[mid] > offset) { - high = mid - 1; - } - else if (mid == buffer->nfragments || buffer->fragment_offsets[mid + 1] > offset) { - return mid; - } - else { - low = mid + 1; - } - } - - return low; -} - - -static void -buffer_free(buffer_t *buffer) { - zip_uint64_t i; - - if (buffer == NULL) { - return; - } - - if (buffer->shared_buffer != NULL) { - buffer->shared_buffer->shared_buffer = NULL; - buffer->shared_buffer->shared_fragments = 0; - - buffer->first_owned_fragment = ZIP_MAX(buffer->first_owned_fragment, buffer->shared_fragments); - } - - for (i = buffer->first_owned_fragment; i < buffer->nfragments; i++) { - free(buffer->fragments[i].data); - } - free(buffer->fragments); - free(buffer->fragment_offsets); - free(buffer); -} - - -static bool -buffer_grow_fragments(buffer_t *buffer, zip_uint64_t capacity, zip_error_t *error) { - zip_buffer_fragment_t *fragments; - zip_uint64_t *offsets; - - if (capacity < buffer->fragments_capacity) { - return true; - } - - if ((fragments = realloc(buffer->fragments, sizeof(buffer->fragments[0]) * capacity)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return false; - } - buffer->fragments = fragments; - if ((offsets = realloc(buffer->fragment_offsets, sizeof(buffer->fragment_offsets[0]) * (capacity + 1))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return false; - } - buffer->fragment_offsets = offsets; - buffer->fragments_capacity = capacity; - - return true; -} - - -static buffer_t * -buffer_new(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int free_data, zip_error_t *error) { - buffer_t *buffer; - - if ((buffer = malloc(sizeof(*buffer))) == NULL) { - return NULL; - } - - buffer->offset = 0; - buffer->first_owned_fragment = 0; - buffer->size = 0; - buffer->fragments = NULL; - buffer->fragment_offsets = NULL; - buffer->nfragments = 0; - buffer->fragments_capacity = 0; - buffer->shared_buffer = NULL; - buffer->shared_fragments = 0; - - if (nfragments == 0) { - if ((buffer->fragment_offsets = malloc(sizeof(buffer->fragment_offsets[0]))) == NULL) { - free(buffer); - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - buffer->fragment_offsets[0] = 0; - } - else { - zip_uint64_t i, j, offset; - - if (!buffer_grow_fragments(buffer, nfragments, NULL)) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - buffer_free(buffer); - return NULL; - } - - offset = 0; - for (i = 0, j = 0; i < nfragments; i++) { - if (fragments[i].length == 0) { - continue; - } - if (fragments[i].data == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - buffer_free(buffer); - return NULL; - } - buffer->fragments[j].data = fragments[i].data; - buffer->fragments[j].length = fragments[i].length; - buffer->fragment_offsets[i] = offset; - offset += fragments[i].length; - j++; - } - buffer->nfragments = j; - buffer->first_owned_fragment = free_data ? 0 : buffer->nfragments; - buffer->fragment_offsets[buffer->nfragments] = offset; - buffer->size = offset; - } - - return buffer; -} - -static zip_int64_t -buffer_read(buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length) { - zip_uint64_t n, i, fragment_offset; - - length = ZIP_MIN(length, buffer->size - buffer->offset); - - if (length == 0) { - return 0; - } - if (length > ZIP_INT64_MAX) { - return -1; - } - - i = buffer->current_fragment; - fragment_offset = buffer->offset - buffer->fragment_offsets[i]; - n = 0; - while (n < length) { - zip_uint64_t left = ZIP_MIN(length - n, buffer->fragments[i].length - fragment_offset); - - memcpy(data + n, buffer->fragments[i].data + fragment_offset, left); - - if (left == buffer->fragments[i].length - fragment_offset) { - i++; - } - n += left; - fragment_offset = 0; - } - - buffer->offset += n; - buffer->current_fragment = i; - return (zip_int64_t)n; -} - - -static int -buffer_seek(buffer_t *buffer, void *data, zip_uint64_t len, zip_error_t *error) { - zip_int64_t new_offset = zip_source_seek_compute_offset(buffer->offset, buffer->size, data, len, error); - - if (new_offset < 0) { - return -1; - } - - buffer->offset = (zip_uint64_t)new_offset; - buffer->current_fragment = buffer_find_fragment(buffer, buffer->offset); - return 0; -} - - -static zip_int64_t -buffer_write(buffer_t *buffer, const zip_uint8_t *data, zip_uint64_t length, zip_error_t *error) { - zip_uint64_t n, i, fragment_offset, capacity; - - if (buffer->offset + length + WRITE_FRAGMENT_SIZE - 1 < length) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return -1; - } - - /* grow buffer if needed */ - capacity = buffer_capacity(buffer); - if (buffer->offset + length > capacity) { - zip_uint64_t needed_fragments = buffer->nfragments + (length - (capacity - buffer->offset) + WRITE_FRAGMENT_SIZE - 1) / WRITE_FRAGMENT_SIZE; - - if (needed_fragments > buffer->fragments_capacity) { - zip_uint64_t new_capacity = buffer->fragments_capacity; - - if (new_capacity == 0) { - new_capacity = 16; - } - while (new_capacity < needed_fragments) { - new_capacity *= 2; - } - - if (!buffer_grow_fragments(buffer, new_capacity, error)) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return -1; - } - } - - while (buffer->nfragments < needed_fragments) { - if ((buffer->fragments[buffer->nfragments].data = malloc(WRITE_FRAGMENT_SIZE)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return -1; - } - buffer->fragments[buffer->nfragments].length = WRITE_FRAGMENT_SIZE; - buffer->nfragments++; - capacity += WRITE_FRAGMENT_SIZE; - buffer->fragment_offsets[buffer->nfragments] = capacity; - } - } - - i = buffer->current_fragment; - fragment_offset = buffer->offset - buffer->fragment_offsets[i]; - n = 0; - while (n < length) { - zip_uint64_t left = ZIP_MIN(length - n, buffer->fragments[i].length - fragment_offset); - - memcpy(buffer->fragments[i].data + fragment_offset, data + n, left); - - if (left == buffer->fragments[i].length - fragment_offset) { - i++; - } - n += left; - fragment_offset = 0; - } - - buffer->offset += n; - buffer->current_fragment = i; - if (buffer->offset > buffer->size) { - buffer->size = buffer->offset; - } - - return (zip_int64_t)n; -} diff --git a/Source/Libraries/libzip/zip_source_call.c b/Source/Libraries/libzip/zip_source_call.c deleted file mode 100644 index 66b13d6..0000000 --- a/Source/Libraries/libzip/zip_source_call.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - zip_source_call.c -- invoke callback command on zip_source - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "zipint.h" - - -zip_int64_t -_zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command) { - zip_int64_t ret; - - if ((src->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(command)) == 0) { - zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); - return -1; - } - - if (src->src == NULL) { - ret = src->cb.f(src->ud, data, length, command); - } - else { - ret = src->cb.l(src->src, src->ud, data, length, command); - } - - if (ret < 0) { - if (command != ZIP_SOURCE_ERROR && command != ZIP_SOURCE_SUPPORTS) { - int e[2]; - - if (_zip_source_call(src, e, sizeof(e), ZIP_SOURCE_ERROR) < 0) { - zip_error_set(&src->error, ZIP_ER_INTERNAL, 0); - } - else { - zip_error_set(&src->error, e[0], e[1]); - } - } - } - - return ret; -} diff --git a/Source/Libraries/libzip/zip_source_close.c b/Source/Libraries/libzip/zip_source_close.c deleted file mode 100644 index 264e4b0..0000000 --- a/Source/Libraries/libzip/zip_source_close.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - zip_source_close.c -- close zip_source (stop reading) - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -int -zip_source_close(zip_source_t *src) { - if (!ZIP_SOURCE_IS_OPEN_READING(src)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - src->open_count--; - if (src->open_count == 0) { - _zip_source_call(src, NULL, 0, ZIP_SOURCE_CLOSE); - - if (ZIP_SOURCE_IS_LAYERED(src)) { - if (zip_source_close(src->src) < 0) { - zip_error_set(&src->error, ZIP_ER_INTERNAL, 0); - } - } - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_commit_write.c b/Source/Libraries/libzip/zip_source_commit_write.c deleted file mode 100644 index ec8cd8b..0000000 --- a/Source/Libraries/libzip/zip_source_commit_write.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - zip_source_commit_write.c -- commit changes to file - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_source_commit_write(zip_source_t *src) { - if (!ZIP_SOURCE_IS_OPEN_WRITING(src)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (src->open_count > 1) { - zip_error_set(&src->error, ZIP_ER_INUSE, 0); - return -1; - } - else if (ZIP_SOURCE_IS_OPEN_READING(src)) { - if (zip_source_close(src) < 0) { - return -1; - } - } - - if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_COMMIT_WRITE) < 0) { - src->write_state = ZIP_SOURCE_WRITE_FAILED; - return -1; - } - - src->write_state = ZIP_SOURCE_WRITE_CLOSED; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_compress.c b/Source/Libraries/libzip/zip_source_compress.c deleted file mode 100644 index 35a022c..0000000 --- a/Source/Libraries/libzip/zip_source_compress.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - zip_source_compress.c -- (de)compression routines - Copyright (C) 2017-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include - -#include "zipint.h" - -struct context { - zip_error_t error; - - bool end_of_input; - bool end_of_stream; - bool can_store; - bool is_stored; /* only valid if end_of_stream is true */ - bool compress; - zip_int32_t method; - - zip_uint64_t size; - zip_int64_t first_read; - zip_uint8_t buffer[BUFSIZE]; - - zip_compression_algorithm_t *algorithm; - void *ud; -}; - - -struct implementation { - zip_uint16_t method; - zip_compression_algorithm_t *compress; - zip_compression_algorithm_t *decompress; -}; - -static struct implementation implementations[] = { - {ZIP_CM_DEFLATE, &zip_algorithm_deflate_compress, &zip_algorithm_deflate_decompress}, -#if defined(HAVE_LIBBZ2) - {ZIP_CM_BZIP2, &zip_algorithm_bzip2_compress, &zip_algorithm_bzip2_decompress}, -#endif -#if defined(HAVE_LIBLZMA) - {ZIP_CM_LZMA, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress}, - /* Disabled - because 7z isn't able to unpack ZIP+LZMA2 - archives made this way - and vice versa. - - {ZIP_CM_LZMA2, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress}, - */ - {ZIP_CM_XZ, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress}, -#endif -#if defined(HAVE_LIBZSTD) - {ZIP_CM_ZSTD, &zip_algorithm_zstd_compress, &zip_algorithm_zstd_decompress}, -#endif - -}; - -static size_t implementations_size = sizeof(implementations) / sizeof(implementations[0]); - -static zip_source_t *compression_source_new(zip_t *za, zip_source_t *src, zip_int32_t method, bool compress, int compression_flags); -static zip_int64_t compress_callback(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); -static void context_free(struct context *ctx); -static struct context *context_new(zip_int32_t method, bool compress, int compression_flags, zip_compression_algorithm_t *algorithm); -static zip_int64_t compress_read(zip_source_t *, struct context *, void *, zip_uint64_t); - -zip_compression_algorithm_t * -_zip_get_compression_algorithm(zip_int32_t method, bool compress) { - size_t i; - zip_uint16_t real_method = ZIP_CM_ACTUAL(method); - - for (i = 0; i < implementations_size; i++) { - if (implementations[i].method == real_method) { - if (compress) { - return implementations[i].compress; - } - else { - return implementations[i].decompress; - } - } - } - - return NULL; -} - -ZIP_EXTERN int -zip_compression_method_supported(zip_int32_t method, int compress) { - if (method == ZIP_CM_STORE) { - return 1; - } - return _zip_get_compression_algorithm(method, compress) != NULL; -} - -zip_source_t * -zip_source_compress(zip_t *za, zip_source_t *src, zip_int32_t method, int compression_flags) { - return compression_source_new(za, src, method, true, compression_flags); -} - -zip_source_t * -zip_source_decompress(zip_t *za, zip_source_t *src, zip_int32_t method) { - return compression_source_new(za, src, method, false, 0); -} - - -static zip_source_t * -compression_source_new(zip_t *za, zip_source_t *src, zip_int32_t method, bool compress, int compression_flags) { - struct context *ctx; - zip_source_t *s2; - zip_compression_algorithm_t *algorithm = NULL; - - if (src == NULL) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((algorithm = _zip_get_compression_algorithm(method, compress)) == NULL) { - zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0); - return NULL; - } - - if ((ctx = context_new(method, compress, compression_flags, algorithm)) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return NULL; - } - - if ((s2 = zip_source_layered(za, src, compress_callback, ctx)) == NULL) { - context_free(ctx); - return NULL; - } - - return s2; -} - - -static struct context * -context_new(zip_int32_t method, bool compress, int compression_flags, zip_compression_algorithm_t *algorithm) { - struct context *ctx; - - if ((ctx = (struct context *)malloc(sizeof(*ctx))) == NULL) { - return NULL; - } - zip_error_init(&ctx->error); - ctx->can_store = compress ? ZIP_CM_IS_DEFAULT(method) : false; - ctx->algorithm = algorithm; - ctx->method = method; - ctx->compress = compress; - ctx->end_of_input = false; - ctx->end_of_stream = false; - ctx->is_stored = false; - - if ((ctx->ud = ctx->algorithm->allocate(ZIP_CM_ACTUAL(method), compression_flags, &ctx->error)) == NULL) { - zip_error_fini(&ctx->error); - free(ctx); - return NULL; - } - - return ctx; -} - - -static void -context_free(struct context *ctx) { - if (ctx == NULL) { - return; - } - - ctx->algorithm->deallocate(ctx->ud); - zip_error_fini(&ctx->error); - - free(ctx); -} - - -static zip_int64_t -compress_read(zip_source_t *src, struct context *ctx, void *data, zip_uint64_t len) { - zip_compression_status_t ret; - bool end; - zip_int64_t n; - zip_uint64_t out_offset; - zip_uint64_t out_len; - - if (zip_error_code_zip(&ctx->error) != ZIP_ER_OK) { - return -1; - } - - if (len == 0 || ctx->end_of_stream) { - return 0; - } - - out_offset = 0; - - end = false; - while (!end && out_offset < len) { - out_len = len - out_offset; - ret = ctx->algorithm->process(ctx->ud, (zip_uint8_t *)data + out_offset, &out_len); - - if (ret != ZIP_COMPRESSION_ERROR) { - out_offset += out_len; - } - - switch (ret) { - case ZIP_COMPRESSION_END: - ctx->end_of_stream = true; - - if (!ctx->end_of_input) { - /* TODO: garbage after stream, or compression ended before all data read */ - } - - if (ctx->first_read < 0) { - /* we got end of processed stream before reading any input data */ - zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); - end = true; - break; - } - if (ctx->can_store && (zip_uint64_t)ctx->first_read <= out_offset) { - ctx->is_stored = true; - ctx->size = (zip_uint64_t)ctx->first_read; - memcpy(data, ctx->buffer, ctx->size); - return (zip_int64_t)ctx->size; - } - end = true; - break; - - case ZIP_COMPRESSION_OK: - break; - - case ZIP_COMPRESSION_NEED_DATA: - if (ctx->end_of_input) { - /* TODO: error: stream not ended, but no more input */ - end = true; - break; - } - - if ((n = zip_source_read(src, ctx->buffer, sizeof(ctx->buffer))) < 0) { - _zip_error_set_from_source(&ctx->error, src); - end = true; - break; - } - else if (n == 0) { - ctx->end_of_input = true; - ctx->algorithm->end_of_input(ctx->ud); - if (ctx->first_read < 0) { - ctx->first_read = 0; - } - } - else { - if (ctx->first_read >= 0) { - /* we overwrote a previously filled ctx->buffer */ - ctx->can_store = false; - } - else { - ctx->first_read = n; - } - - ctx->algorithm->input(ctx->ud, ctx->buffer, (zip_uint64_t)n); - } - break; - - case ZIP_COMPRESSION_ERROR: - /* error set by algorithm */ - if (zip_error_code_zip(&ctx->error) == ZIP_ER_OK) { - zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); - } - end = true; - break; - } - } - - if (out_offset > 0) { - ctx->can_store = false; - ctx->size += out_offset; - return (zip_int64_t)out_offset; - } - - return (zip_error_code_zip(&ctx->error) == ZIP_ER_OK) ? 0 : -1; -} - - -static zip_int64_t -compress_callback(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { - struct context *ctx; - - ctx = (struct context *)ud; - - switch (cmd) { - case ZIP_SOURCE_OPEN: { - zip_stat_t st; - zip_file_attributes_t attributes; - - ctx->size = 0; - ctx->end_of_input = false; - ctx->end_of_stream = false; - ctx->is_stored = false; - ctx->first_read = -1; - - if (zip_source_stat(src, &st) < 0 || zip_source_get_file_attributes(src, &attributes) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - if (!ctx->algorithm->start(ctx->ud, &st, &attributes)) { - return -1; - } - - return 0; - } - - case ZIP_SOURCE_READ: - return compress_read(src, ctx, data, len); - - case ZIP_SOURCE_CLOSE: - if (!ctx->algorithm->end(ctx->ud)) { - return -1; - } - return 0; - - case ZIP_SOURCE_STAT: { - zip_stat_t *st; - - st = (zip_stat_t *)data; - - if (ctx->compress) { - if (ctx->end_of_stream) { - st->comp_method = ctx->is_stored ? ZIP_CM_STORE : ZIP_CM_ACTUAL(ctx->method); - st->comp_size = ctx->size; - st->valid |= ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD; - } - else { - st->valid &= ~(ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD); - } - } - else { - st->comp_method = ZIP_CM_STORE; - st->valid |= ZIP_STAT_COMP_METHOD; - if (ctx->end_of_stream) { - st->size = ctx->size; - st->valid |= ZIP_STAT_SIZE; - } - } - } - return 0; - - case ZIP_SOURCE_ERROR: - return zip_error_to_data(&ctx->error, data, len); - - case ZIP_SOURCE_FREE: - context_free(ctx); - return 0; - - case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { - zip_file_attributes_t *attributes = (zip_file_attributes_t *)data; - - if (len < sizeof(*attributes)) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - - attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED | ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS; - attributes->version_needed = ctx->algorithm->version_needed; - attributes->general_purpose_bit_mask = ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK; - attributes->general_purpose_bit_flags = (ctx->is_stored ? 0 : ctx->algorithm->general_purpose_bit_flags(ctx->ud)); - - return sizeof(*attributes); - } - - case ZIP_SOURCE_SUPPORTS: - return ZIP_SOURCE_SUPPORTS_READABLE | zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, -1); - - default: - zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); - return -1; - } -} diff --git a/Source/Libraries/libzip/zip_source_crc.c b/Source/Libraries/libzip/zip_source_crc.c deleted file mode 100644 index cae7363..0000000 --- a/Source/Libraries/libzip/zip_source_crc.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - zip_source_crc.c -- pass-through source that calculates CRC32 and size - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include -#include - -#include "zipint.h" - -struct crc_context { - int validate; /* whether to check CRC on EOF and return error on mismatch */ - int crc_complete; /* whether CRC was computed for complete file */ - zip_error_t error; - zip_uint64_t size; - zip_uint64_t position; /* current reading position */ - zip_uint64_t crc_position; /* how far we've computed the CRC */ - zip_uint32_t crc; -}; - -static zip_int64_t crc_read(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); - - -zip_source_t * -zip_source_crc(zip_t *za, zip_source_t *src, int validate) { - struct crc_context *ctx; - - if (src == NULL) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((ctx = (struct crc_context *)malloc(sizeof(*ctx))) == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return NULL; - } - - zip_error_init(&ctx->error); - ctx->validate = validate; - ctx->crc_complete = 0; - ctx->crc_position = 0; - ctx->crc = (zip_uint32_t)crc32(0, NULL, 0); - ctx->size = 0; - - return zip_source_layered(za, src, crc_read, ctx); -} - - -static zip_int64_t -crc_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { - struct crc_context *ctx; - zip_int64_t n; - - ctx = (struct crc_context *)_ctx; - - switch (cmd) { - case ZIP_SOURCE_OPEN: - ctx->position = 0; - return 0; - - case ZIP_SOURCE_READ: - if ((n = zip_source_read(src, data, len)) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - if (n == 0) { - if (ctx->crc_position == ctx->position) { - ctx->crc_complete = 1; - ctx->size = ctx->position; - - if (ctx->validate) { - struct zip_stat st; - - if (zip_source_stat(src, &st) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - if ((st.valid & ZIP_STAT_CRC) && st.crc != ctx->crc) { - zip_error_set(&ctx->error, ZIP_ER_CRC, 0); - return -1; - } - if ((st.valid & ZIP_STAT_SIZE) && st.size != ctx->size) { - zip_error_set(&ctx->error, ZIP_ER_INCONS, 0); - return -1; - } - } - } - } - else if (!ctx->crc_complete && ctx->position <= ctx->crc_position) { - zip_uint64_t i, nn; - - for (i = ctx->crc_position - ctx->position; i < (zip_uint64_t)n; i += nn) { - nn = ZIP_MIN(UINT_MAX, (zip_uint64_t)n - i); - - ctx->crc = (zip_uint32_t)crc32(ctx->crc, (const Bytef *)data + i, (uInt)nn); - ctx->crc_position += nn; - } - } - ctx->position += (zip_uint64_t)n; - return n; - - case ZIP_SOURCE_CLOSE: - return 0; - - case ZIP_SOURCE_STAT: { - zip_stat_t *st; - - st = (zip_stat_t *)data; - - if (ctx->crc_complete) { - /* TODO: Set comp_size, comp_method, encryption_method? - After all, this only works for uncompressed data. */ - st->size = ctx->size; - st->crc = ctx->crc; - st->comp_size = ctx->size; - st->comp_method = ZIP_CM_STORE; - st->encryption_method = ZIP_EM_NONE; - st->valid |= ZIP_STAT_SIZE | ZIP_STAT_CRC | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD; - } - return 0; - } - - case ZIP_SOURCE_ERROR: - return zip_error_to_data(&ctx->error, data, len); - - case ZIP_SOURCE_FREE: - free(ctx); - return 0; - - case ZIP_SOURCE_SUPPORTS: { - zip_int64_t mask = zip_source_supports(src); - - if (mask < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - return mask & ~zip_source_make_command_bitmap(ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_REMOVE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, -1); - } - - case ZIP_SOURCE_SEEK: { - zip_int64_t new_position; - zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, len, &ctx->error); - - if (args == NULL) { - return -1; - } - if (zip_source_seek(src, args->offset, args->whence) < 0 || (new_position = zip_source_tell(src)) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - ctx->position = (zip_uint64_t)new_position; - - return 0; - } - - case ZIP_SOURCE_TELL: - return (zip_int64_t)ctx->position; - - default: - zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); - return -1; - } -} diff --git a/Source/Libraries/libzip/zip_source_error.c b/Source/Libraries/libzip/zip_source_error.c deleted file mode 100644 index 00998e8..0000000 --- a/Source/Libraries/libzip/zip_source_error.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_source_error.c -- get last error from zip_source - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -zip_error_t * -zip_source_error(zip_source_t *src) { - return &src->error; -} - -bool -_zip_source_had_error(zip_source_t *src) { - return zip_source_error(src)->zip_err != ZIP_ER_OK; -} diff --git a/Source/Libraries/libzip/zip_source_file_common.c b/Source/Libraries/libzip/zip_source_file_common.c deleted file mode 100644 index 3241436..0000000 --- a/Source/Libraries/libzip/zip_source_file_common.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - zip_source_file_common.c -- create data source from file - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include - -#include "zipint.h" - -#include "zip_source_file.h" - -static zip_int64_t read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd); - -static void -zip_source_file_stat_init(zip_source_file_stat_t *st) { - st->size = 0; - st->mtime = time(NULL); - st->exists = false; - st->regular_file = false; -} - -zip_source_t * -zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error) { - zip_source_file_context_t *ctx; - zip_source_t *zs; - zip_source_file_stat_t sb; - - if (ops == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - if (ops->close == NULL || ops->read == NULL || ops->seek == NULL || ops->stat == NULL) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - return NULL; - } - - if (ops->write != NULL && (ops->commit_write == NULL || ops->create_temp_output == NULL || ops->remove == NULL || ops->rollback_write == NULL || ops->tell == NULL)) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - return NULL; - } - - if (fname != NULL) { - if (ops->open == NULL || ops->string_duplicate == NULL) { - zip_error_set(error, ZIP_ER_INTERNAL, 0); - return NULL; - } - } - else if (file == NULL) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - if (len < 0) { - len = 0; - } - - if (start > ZIP_INT64_MAX || start + (zip_uint64_t)len < start) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((ctx = (zip_source_file_context_t *)malloc(sizeof(zip_source_file_context_t))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - ctx->ops = ops; - ctx->ops_userdata = ops_userdata; - ctx->fname = NULL; - if (fname) { - if ((ctx->fname = ops->string_duplicate(ctx, fname)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - free(ctx); - return NULL; - } - } - ctx->f = file; - ctx->start = start; - ctx->len = (zip_uint64_t)len; - if (st) { - memcpy(&ctx->st, st, sizeof(ctx->st)); - ctx->st.name = NULL; - ctx->st.valid &= ~ZIP_STAT_NAME; - } - else { - zip_stat_init(&ctx->st); - } - - if (ctx->len > 0) { - ctx->st.size = ctx->len; - ctx->st.valid |= ZIP_STAT_SIZE; - } - - zip_error_init(&ctx->stat_error); - - ctx->tmpname = NULL; - ctx->fout = NULL; - - zip_error_init(&ctx->error); - zip_file_attributes_init(&ctx->attributes); - - ctx->supports = ZIP_SOURCE_SUPPORTS_READABLE | zip_source_make_command_bitmap(ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, -1); - - zip_source_file_stat_init(&sb); - if (!ops->stat(ctx, &sb)) { - _zip_error_copy(error, &ctx->error); - free(ctx->fname); - free(ctx); - return NULL; - } - - if (!sb.exists) { - if (ctx->fname && ctx->start == 0 && ctx->len == 0 && ops->write != NULL) { - ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; - /* zip_open_from_source checks for this to detect non-existing files */ - zip_error_set(&ctx->stat_error, ZIP_ER_READ, ENOENT); - } - else { - zip_error_set(&ctx->stat_error, ZIP_ER_READ, ENOENT); - free(ctx->fname); - free(ctx); - return NULL; - } - } - else { - if ((ctx->st.valid & ZIP_STAT_MTIME) == 0) { - ctx->st.mtime = sb.mtime; - ctx->st.valid |= ZIP_STAT_MTIME; - } - if (sb.regular_file) { - ctx->supports = ZIP_SOURCE_SUPPORTS_SEEKABLE; - - if (ctx->start + ctx->len > sb.size) { - zip_error_set(error, ZIP_ER_INVAL, 0); - free(ctx->fname); - free(ctx); - return NULL; - } - - if (ctx->len == 0) { - ctx->len = sb.size - ctx->start; - ctx->st.size = ctx->len; - ctx->st.valid |= ZIP_STAT_SIZE; - - /* when using a partial file, don't allow writing */ - if (ctx->fname && start == 0 && ops->write != NULL) { - ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; - } - } - } - - ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_FILE_ATTRIBUTES); - } - - ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY); - if (ops->create_temp_output_cloning != NULL) { - if (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE)) { - ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE_CLONING); - } - } - - if ((zs = zip_source_function_create(read_file, ctx, error)) == NULL) { - free(ctx->fname); - free(ctx); - return NULL; - } - - return zs; -} - - -static zip_int64_t -read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { - zip_source_file_context_t *ctx; - char *buf; - - ctx = (zip_source_file_context_t *)state; - buf = (char *)data; - - switch (cmd) { - case ZIP_SOURCE_ACCEPT_EMPTY: - return 0; - - case ZIP_SOURCE_BEGIN_WRITE: - /* write support should not be set if fname is NULL */ - if (ctx->fname == NULL) { - zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); - return -1; - } - return ctx->ops->create_temp_output(ctx); - - case ZIP_SOURCE_BEGIN_WRITE_CLONING: - /* write support should not be set if fname is NULL */ - if (ctx->fname == NULL) { - zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); - return -1; - } - return ctx->ops->create_temp_output_cloning(ctx, len); - - case ZIP_SOURCE_CLOSE: - if (ctx->fname) { - ctx->ops->close(ctx); - ctx->f = NULL; - } - return 0; - - case ZIP_SOURCE_COMMIT_WRITE: { - zip_int64_t ret = ctx->ops->commit_write(ctx); - ctx->fout = NULL; - if (ret == 0) { - free(ctx->tmpname); - ctx->tmpname = NULL; - } - return ret; - } - - case ZIP_SOURCE_ERROR: - return zip_error_to_data(&ctx->error, data, len); - - case ZIP_SOURCE_FREE: - free(ctx->fname); - free(ctx->tmpname); - if (ctx->f) { - ctx->ops->close(ctx); - } - free(ctx); - return 0; - - case ZIP_SOURCE_GET_FILE_ATTRIBUTES: - if (len < sizeof(ctx->attributes)) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - memcpy(data, &ctx->attributes, sizeof(ctx->attributes)); - return sizeof(ctx->attributes); - - case ZIP_SOURCE_OPEN: - if (ctx->fname) { - if (ctx->ops->open(ctx) == false) { - return -1; - } - } - - if (ctx->start > 0) { // TODO: rewind on re-open - if (ctx->ops->seek(ctx, ctx->f, (zip_int64_t)ctx->start, SEEK_SET) == false) { - /* TODO: skip by reading */ - return -1; - } - } - ctx->offset = 0; - return 0; - - case ZIP_SOURCE_READ: { - zip_int64_t i; - zip_uint64_t n; - - if (ctx->len > 0) { - n = ZIP_MIN(ctx->len - ctx->offset, len); - } - else { - n = len; - } - - if ((i = ctx->ops->read(ctx, buf, n)) < 0) { - zip_error_set(&ctx->error, ZIP_ER_READ, errno); - return -1; - } - ctx->offset += (zip_uint64_t)i; - - return i; - } - - case ZIP_SOURCE_REMOVE: - return ctx->ops->remove(ctx); - - case ZIP_SOURCE_ROLLBACK_WRITE: - ctx->ops->rollback_write(ctx); - ctx->fout = NULL; - free(ctx->tmpname); - ctx->tmpname = NULL; - return 0; - - case ZIP_SOURCE_SEEK: { - zip_int64_t new_offset = zip_source_seek_compute_offset(ctx->offset, ctx->len, data, len, &ctx->error); - - if (new_offset < 0) { - return -1; - } - - /* The actual offset inside the file must be representable as zip_int64_t. */ - if (new_offset > ZIP_INT64_MAX - (zip_int64_t)ctx->start) { - zip_error_set(&ctx->error, ZIP_ER_SEEK, EOVERFLOW); - return -1; - } - - ctx->offset = (zip_uint64_t)new_offset; - - if (ctx->ops->seek(ctx, ctx->f, (zip_int64_t)(ctx->offset + ctx->start), SEEK_SET) == false) { - return -1; - } - return 0; - } - - case ZIP_SOURCE_SEEK_WRITE: { - zip_source_args_seek_t *args; - - args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, len, &ctx->error); - if (args == NULL) { - return -1; - } - - if (ctx->ops->seek(ctx, ctx->fout, args->offset, args->whence) == false) { - return -1; - } - return 0; - } - - case ZIP_SOURCE_STAT: { - if (len < sizeof(ctx->st)) - return -1; - - if (zip_error_code_zip(&ctx->stat_error) != 0) { - zip_error_set(&ctx->error, zip_error_code_zip(&ctx->stat_error), zip_error_code_system(&ctx->stat_error)); - return -1; - } - - memcpy(data, &ctx->st, sizeof(ctx->st)); - return sizeof(ctx->st); - } - - case ZIP_SOURCE_SUPPORTS: - return ctx->supports; - - case ZIP_SOURCE_TELL: - return (zip_int64_t)ctx->offset; - - case ZIP_SOURCE_TELL_WRITE: - return ctx->ops->tell(ctx, ctx->fout); - - case ZIP_SOURCE_WRITE: - return ctx->ops->write(ctx, data, len); - - default: - zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); - return -1; - } -} diff --git a/Source/Libraries/libzip/zip_source_file_stdio.c b/Source/Libraries/libzip/zip_source_file_stdio.c deleted file mode 100644 index 1581771..0000000 --- a/Source/Libraries/libzip/zip_source_file_stdio.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - zip_source_file_stdio.c -- read-only stdio file source implementation - Copyright (C) 2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" - -#include "zip_source_file.h" -#include "zip_source_file_stdio.h" - -#include -#include -#include -#include - -#ifdef _WIN32 -#ifndef S_IWUSR -#define S_IWUSR _S_IWRITE -#endif -#endif - -/* clang-format off */ -static zip_source_file_operations_t ops_stdio_read = { - _zip_stdio_op_close, - NULL, - NULL, - NULL, - NULL, - _zip_stdio_op_read, - NULL, - NULL, - _zip_stdio_op_seek, - _zip_stdio_op_stat, - NULL, - _zip_stdio_op_tell, - NULL -}; -/* clang-format on */ - - -ZIP_EXTERN zip_source_t * -zip_source_filep(zip_t *za, FILE *file, zip_uint64_t start, zip_int64_t len) { - if (za == NULL) { - return NULL; - } - - return zip_source_filep_create(file, start, len, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_filep_create(FILE *file, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (file == NULL || length < -1) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - return zip_source_file_common_new(NULL, file, start, length, NULL, &ops_stdio_read, NULL, error); -} - - -void -_zip_stdio_op_close(zip_source_file_context_t *ctx) { - fclose((FILE *)ctx->f); -} - - -zip_int64_t -_zip_stdio_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len) { - size_t i; - if (len > SIZE_MAX) { - len = SIZE_MAX; - } - - if ((i = fread(buf, 1, (size_t)len, ctx->f)) == 0) { - if (ferror((FILE *)ctx->f)) { - zip_error_set(&ctx->error, ZIP_ER_READ, errno); - return -1; - } - } - - return (zip_int64_t)i; -} - - -bool -_zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence) { -#if ZIP_FSEEK_MAX > ZIP_INT64_MAX - if (offset > ZIP_FSEEK_MAX || offset < ZIP_FSEEK_MIN) { - zip_error_set(&ctx->error, ZIP_ER_SEEK, EOVERFLOW); - return false; - } -#endif - - if (fseeko((FILE *)f, (off_t)offset, whence) < 0) { - zip_error_set(&ctx->error, ZIP_ER_SEEK, errno); - return false; - } - return true; -} - - -bool -_zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) { - struct stat sb; - - int ret; - - if (ctx->fname) { - ret = stat(ctx->fname, &sb); - } - else { - ret = fstat(fileno((FILE *)ctx->f), &sb); - } - - if (ret < 0) { - if (errno == ENOENT) { - st->exists = false; - return true; - } - zip_error_set(&ctx->error, ZIP_ER_READ, errno); - return false; - } - - st->size = (zip_uint64_t)sb.st_size; - st->mtime = sb.st_mtime; - - st->regular_file = S_ISREG(sb.st_mode); - st->exists = true; - - /* We're using UNIX file API, even on Windows; thus, we supply external file attributes with Unix values. */ - /* TODO: This could be improved on Windows by providing Windows-specific file attributes */ - ctx->attributes.valid = ZIP_FILE_ATTRIBUTES_HOST_SYSTEM | ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES; - ctx->attributes.host_system = ZIP_OPSYS_UNIX; - ctx->attributes.external_file_attributes = (((zip_uint32_t)sb.st_mode) << 16) | ((sb.st_mode & S_IWUSR) ? 0 : 1); - - return true; -} - - -zip_int64_t -_zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f) { - off_t offset = ftello((FILE *)f); - - if (offset < 0) { - zip_error_set(&ctx->error, ZIP_ER_SEEK, errno); - } - - return offset; -} - - -/* - * fopen replacement that sets the close-on-exec flag - * some implementations support an fopen 'e' flag for that, - * but e.g. macOS doesn't. - */ -FILE * -_zip_fopen_close_on_exec(const char *name, bool writeable) { - int fd; - int flags; - FILE *fp; - - flags = O_CLOEXEC; - if (writeable) { - flags |= O_RDWR; - } - else { - flags |= O_RDONLY; - } - - /* mode argument needed on Windows */ - if ((fd = open(name, flags, 0666)) < 0) { - return NULL; - } - if ((fp = fdopen(fd, writeable ? "r+b" : "rb")) == NULL) { - return NULL; - } - return fp; -} diff --git a/Source/Libraries/libzip/zip_source_free.c b/Source/Libraries/libzip/zip_source_free.c deleted file mode 100644 index 2650493..0000000 --- a/Source/Libraries/libzip/zip_source_free.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - zip_source_free.c -- free zip data source - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN void -zip_source_free(zip_source_t *src) { - if (src == NULL) - return; - - if (src->refcount > 0) { - src->refcount--; - } - if (src->refcount > 0) { - return; - } - - if (ZIP_SOURCE_IS_OPEN_READING(src)) { - src->open_count = 1; /* force close */ - zip_source_close(src); - } - if (ZIP_SOURCE_IS_OPEN_WRITING(src)) { - zip_source_rollback_write(src); - } - - if (src->source_archive && !src->source_closed) { - _zip_deregister_source(src->source_archive, src); - } - - (void)_zip_source_call(src, NULL, 0, ZIP_SOURCE_FREE); - - if (src->src) { - zip_source_free(src->src); - } - - free(src); -} diff --git a/Source/Libraries/libzip/zip_source_function.c b/Source/Libraries/libzip/zip_source_function.c deleted file mode 100644 index 5602f1d..0000000 --- a/Source/Libraries/libzip/zip_source_function.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - zip_source_function.c -- create zip data source from callback function - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN zip_source_t * -zip_source_function(zip_t *za, zip_source_callback zcb, void *ud) { - if (za == NULL) { - return NULL; - } - - return zip_source_function_create(zcb, ud, &za->error); -} - - -ZIP_EXTERN zip_source_t * -zip_source_function_create(zip_source_callback zcb, void *ud, zip_error_t *error) { - zip_source_t *zs; - - if ((zs = _zip_source_new(error)) == NULL) - return NULL; - - zs->cb.f = zcb; - zs->ud = ud; - - zs->supports = zcb(ud, NULL, 0, ZIP_SOURCE_SUPPORTS); - if (zs->supports < 0) { - zs->supports = ZIP_SOURCE_SUPPORTS_READABLE; - } - - return zs; -} - - -ZIP_EXTERN void -zip_source_keep(zip_source_t *src) { - src->refcount++; -} - - -zip_source_t * -_zip_source_new(zip_error_t *error) { - zip_source_t *src; - - if ((src = (zip_source_t *)malloc(sizeof(*src))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - src->src = NULL; - src->cb.f = NULL; - src->ud = NULL; - src->open_count = 0; - src->write_state = ZIP_SOURCE_WRITE_CLOSED; - src->source_closed = false; - src->source_archive = NULL; - src->refcount = 1; - zip_error_init(&src->error); - src->eof = false; - src->had_read_error = false; - src->bytes_read = 0; - - return src; -} diff --git a/Source/Libraries/libzip/zip_source_get_file_attributes.c b/Source/Libraries/libzip/zip_source_get_file_attributes.c deleted file mode 100644 index 734767a..0000000 --- a/Source/Libraries/libzip/zip_source_get_file_attributes.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - zip_source_get_file_attributes.c -- get attributes for file from source - Copyright (C) 2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "zipint.h" - -ZIP_EXTERN void -zip_file_attributes_init(zip_file_attributes_t *attributes) { - attributes->valid = 0; - attributes->version = 1; -} - -int -zip_source_get_file_attributes(zip_source_t *src, zip_file_attributes_t *attributes) { - if (src->source_closed) { - return -1; - } - if (attributes == NULL) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - zip_file_attributes_init(attributes); - - if (src->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_FILE_ATTRIBUTES)) { - if (_zip_source_call(src, attributes, sizeof(*attributes), ZIP_SOURCE_GET_FILE_ATTRIBUTES) < 0) { - return -1; - } - } - - if (ZIP_SOURCE_IS_LAYERED(src)) { - zip_file_attributes_t lower_attributes; - - if (zip_source_get_file_attributes(src->src, &lower_attributes) < 0) { - _zip_error_set_from_source(&src->error, src->src); - return -1; - } - - if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM) && (attributes->valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM) == 0) { - attributes->host_system = lower_attributes.host_system; - attributes->valid |= ZIP_FILE_ATTRIBUTES_HOST_SYSTEM; - } - if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_ASCII) && (attributes->valid & ZIP_FILE_ATTRIBUTES_ASCII) == 0) { - attributes->ascii = lower_attributes.ascii; - attributes->valid |= ZIP_FILE_ATTRIBUTES_ASCII; - } - if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED)) { - if (attributes->valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED) { - attributes->version_needed = ZIP_MAX(lower_attributes.version_needed, attributes->version_needed); - } - else { - attributes->version_needed = lower_attributes.version_needed; - attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED; - } - } - if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES) && (attributes->valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES) == 0) { - attributes->external_file_attributes = lower_attributes.external_file_attributes; - attributes->valid |= ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES; - } - if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS)) { - if (attributes->valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS) { - /* only take from lower level what is not defined at current level */ - lower_attributes.general_purpose_bit_mask &= ~attributes->general_purpose_bit_mask; - - attributes->general_purpose_bit_flags |= lower_attributes.general_purpose_bit_flags & lower_attributes.general_purpose_bit_mask; - attributes->general_purpose_bit_mask |= lower_attributes.general_purpose_bit_mask; - } - else { - attributes->valid |= ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS; - attributes->general_purpose_bit_flags = lower_attributes.general_purpose_bit_flags; - attributes->general_purpose_bit_mask = lower_attributes.general_purpose_bit_mask; - } - } - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_is_deleted.c b/Source/Libraries/libzip/zip_source_is_deleted.c deleted file mode 100644 index 27c931f..0000000 --- a/Source/Libraries/libzip/zip_source_is_deleted.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - zip_source_is_deleted.c -- was archive was removed? - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_source_is_deleted(zip_source_t *src) { - return src->write_state == ZIP_SOURCE_WRITE_REMOVED; -} diff --git a/Source/Libraries/libzip/zip_source_layered.c b/Source/Libraries/libzip/zip_source_layered.c deleted file mode 100644 index a029869..0000000 --- a/Source/Libraries/libzip/zip_source_layered.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - zip_source_layered.c -- create layered source - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -zip_source_t * -zip_source_layered(zip_t *za, zip_source_t *src, zip_source_layered_callback cb, void *ud) { - if (za == NULL) - return NULL; - - return zip_source_layered_create(src, cb, ud, &za->error); -} - - -zip_source_t * -zip_source_layered_create(zip_source_t *src, zip_source_layered_callback cb, void *ud, zip_error_t *error) { - zip_source_t *zs; - - if ((zs = _zip_source_new(error)) == NULL) - return NULL; - - zip_source_keep(src); - zs->src = src; - zs->cb.l = cb; - zs->ud = ud; - - zs->supports = cb(src, ud, NULL, 0, ZIP_SOURCE_SUPPORTS); - if (zs->supports < 0) { - zs->supports = ZIP_SOURCE_SUPPORTS_READABLE; - } - - return zs; -} diff --git a/Source/Libraries/libzip/zip_source_open.c b/Source/Libraries/libzip/zip_source_open.c deleted file mode 100644 index 442f189..0000000 --- a/Source/Libraries/libzip/zip_source_open.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - zip_source_open.c -- open zip_source (prepare for reading) - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -ZIP_EXTERN int -zip_source_open(zip_source_t *src) { - if (src->source_closed) { - return -1; - } - if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) { - zip_error_set(&src->error, ZIP_ER_DELETED, 0); - return -1; - } - - if (ZIP_SOURCE_IS_OPEN_READING(src)) { - if ((zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK)) == 0) { - zip_error_set(&src->error, ZIP_ER_INUSE, 0); - return -1; - } - } - else { - if (ZIP_SOURCE_IS_LAYERED(src)) { - if (zip_source_open(src->src) < 0) { - _zip_error_set_from_source(&src->error, src->src); - return -1; - } - } - - if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_OPEN) < 0) { - if (ZIP_SOURCE_IS_LAYERED(src)) { - zip_source_close(src->src); - } - return -1; - } - } - - src->eof = false; - src->had_read_error = false; - _zip_error_clear(&src->error); - src->bytes_read = 0; - src->open_count++; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_pkware_decode.c b/Source/Libraries/libzip/zip_source_pkware_decode.c deleted file mode 100644 index a1c9e3a..0000000 --- a/Source/Libraries/libzip/zip_source_pkware_decode.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - zip_source_pkware_decode.c -- Traditional PKWARE decryption routines - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - -struct trad_pkware { - char *password; - zip_pkware_keys_t keys; - zip_error_t error; -}; - - -static int decrypt_header(zip_source_t *, struct trad_pkware *); -static zip_int64_t pkware_decrypt(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); -static struct trad_pkware *trad_pkware_new(const char *password, zip_error_t *error); -static void trad_pkware_free(struct trad_pkware *); - - -zip_source_t * -zip_source_pkware_decode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flags, const char *password) { - struct trad_pkware *ctx; - zip_source_t *s2; - - if (password == NULL || src == NULL || em != ZIP_EM_TRAD_PKWARE) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - if (flags & ZIP_CODEC_ENCODE) { - zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); - return NULL; - } - - if ((ctx = trad_pkware_new(password, &za->error)) == NULL) { - return NULL; - } - - if ((s2 = zip_source_layered(za, src, pkware_decrypt, ctx)) == NULL) { - trad_pkware_free(ctx); - return NULL; - } - - return s2; -} - - -static int -decrypt_header(zip_source_t *src, struct trad_pkware *ctx) { - zip_uint8_t header[ZIP_CRYPTO_PKWARE_HEADERLEN]; - struct zip_stat st; - zip_int64_t n; - bool ok = false; - - if ((n = zip_source_read(src, header, ZIP_CRYPTO_PKWARE_HEADERLEN)) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - if (n != ZIP_CRYPTO_PKWARE_HEADERLEN) { - zip_error_set(&ctx->error, ZIP_ER_EOF, 0); - return -1; - } - - _zip_pkware_decrypt(&ctx->keys, header, header, ZIP_CRYPTO_PKWARE_HEADERLEN); - - if (zip_source_stat(src, &st)) { - /* stat failed, skip password validation */ - return 0; - } - - /* password verification - two ways: - * mtime - InfoZIP way, to avoid computing complete CRC before encrypting data - * CRC - old PKWare way - */ - - if (st.valid & ZIP_STAT_MTIME) { - unsigned short dostime, dosdate; - _zip_u2d_time(st.mtime, &dostime, &dosdate); - if (header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == dostime >> 8) { - ok = true; - } - } - - if (st.valid & ZIP_STAT_CRC) { - if (header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == st.crc >> 24) { - ok = true; - } - } - - if (!ok && ((st.valid & (ZIP_STAT_MTIME | ZIP_STAT_CRC)) != 0)) { - zip_error_set(&ctx->error, ZIP_ER_WRONGPASSWD, 0); - return -1; - } - - return 0; -} - - -static zip_int64_t -pkware_decrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { - struct trad_pkware *ctx; - zip_int64_t n; - - ctx = (struct trad_pkware *)ud; - - switch (cmd) { - case ZIP_SOURCE_OPEN: - _zip_pkware_keys_reset(&ctx->keys); - _zip_pkware_decrypt(&ctx->keys, NULL, (const zip_uint8_t *)ctx->password, strlen(ctx->password)); - if (decrypt_header(src, ctx) < 0) { - return -1; - } - return 0; - - case ZIP_SOURCE_READ: - if ((n = zip_source_read(src, data, len)) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - _zip_pkware_decrypt(&ctx->keys, (zip_uint8_t *)data, (zip_uint8_t *)data, (zip_uint64_t)n); - return n; - - case ZIP_SOURCE_CLOSE: - return 0; - - case ZIP_SOURCE_STAT: { - zip_stat_t *st; - - st = (zip_stat_t *)data; - - st->encryption_method = ZIP_EM_NONE; - st->valid |= ZIP_STAT_ENCRYPTION_METHOD; - if (st->valid & ZIP_STAT_COMP_SIZE) { - st->comp_size -= ZIP_CRYPTO_PKWARE_HEADERLEN; - } - - return 0; - } - - case ZIP_SOURCE_SUPPORTS: - return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, -1); - - case ZIP_SOURCE_ERROR: - return zip_error_to_data(&ctx->error, data, len); - - case ZIP_SOURCE_FREE: - trad_pkware_free(ctx); - return 0; - - default: - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } -} - - -static struct trad_pkware * -trad_pkware_new(const char *password, zip_error_t *error) { - struct trad_pkware *ctx; - - if ((ctx = (struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - if ((ctx->password = strdup(password)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - free(ctx); - return NULL; - } - - zip_error_init(&ctx->error); - - return ctx; -} - - -static void -trad_pkware_free(struct trad_pkware *ctx) { - if (ctx == NULL) { - return; - } - - free(ctx->password); - free(ctx); -} diff --git a/Source/Libraries/libzip/zip_source_pkware_encode.c b/Source/Libraries/libzip/zip_source_pkware_encode.c deleted file mode 100644 index 941e64f..0000000 --- a/Source/Libraries/libzip/zip_source_pkware_encode.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - zip_source_pkware_encode.c -- Traditional PKWARE encryption routines - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - -struct trad_pkware { - char *password; - zip_pkware_keys_t keys; - zip_buffer_t *buffer; - bool eof; - zip_error_t error; -}; - - -static int encrypt_header(zip_source_t *, struct trad_pkware *); -static zip_int64_t pkware_encrypt(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); -static void trad_pkware_free(struct trad_pkware *); -static struct trad_pkware *trad_pkware_new(const char *password, zip_error_t *error); - - -zip_source_t * -zip_source_pkware_encode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flags, const char *password) { - struct trad_pkware *ctx; - zip_source_t *s2; - - if (password == NULL || src == NULL || em != ZIP_EM_TRAD_PKWARE) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - if (!(flags & ZIP_CODEC_ENCODE)) { - zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); - return NULL; - } - - if ((ctx = trad_pkware_new(password, &za->error)) == NULL) { - return NULL; - } - - if ((s2 = zip_source_layered(za, src, pkware_encrypt, ctx)) == NULL) { - trad_pkware_free(ctx); - return NULL; - } - - return s2; -} - - -static int -encrypt_header(zip_source_t *src, struct trad_pkware *ctx) { - struct zip_stat st; - unsigned short dostime, dosdate; - zip_uint8_t *header; - - if (zip_source_stat(src, &st) != 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - _zip_u2d_time(st.mtime, &dostime, &dosdate); - - if ((ctx->buffer = _zip_buffer_new(NULL, ZIP_CRYPTO_PKWARE_HEADERLEN)) == NULL) { - zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); - return -1; - } - - header = _zip_buffer_data(ctx->buffer); - - /* generate header from random bytes and mtime - see appnote.iz, XIII. Decryption, Step 2, last paragraph */ - // if (!zip_secure_random(header, ZIP_CRYPTO_PKWARE_HEADERLEN - 1)) { - if (0==0) { - zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); - _zip_buffer_free(ctx->buffer); - ctx->buffer = NULL; - return -1; - } - header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] = (zip_uint8_t)((dostime >> 8) & 0xff); - - _zip_pkware_encrypt(&ctx->keys, header, header, ZIP_CRYPTO_PKWARE_HEADERLEN); - - return 0; -} - - -static zip_int64_t -pkware_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length, zip_source_cmd_t cmd) { - struct trad_pkware *ctx; - zip_int64_t n; - zip_uint64_t buffer_n; - - ctx = (struct trad_pkware *)ud; - - switch (cmd) { - case ZIP_SOURCE_OPEN: - ctx->eof = false; - - /* initialize keys */ - _zip_pkware_keys_reset(&ctx->keys); - _zip_pkware_encrypt(&ctx->keys, NULL, (const zip_uint8_t *)ctx->password, strlen(ctx->password)); - - if (encrypt_header(src, ctx) < 0) { - return -1; - } - return 0; - - case ZIP_SOURCE_READ: - buffer_n = 0; - - if (ctx->buffer) { - /* write header values to data */ - buffer_n = _zip_buffer_read(ctx->buffer, data, length); - data = (zip_uint8_t *)data + buffer_n; - length -= buffer_n; - - if (_zip_buffer_eof(ctx->buffer)) { - _zip_buffer_free(ctx->buffer); - ctx->buffer = NULL; - } - } - - if (ctx->eof) { - return (zip_int64_t)buffer_n; - } - - if ((n = zip_source_read(src, data, length)) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - - _zip_pkware_encrypt(&ctx->keys, (zip_uint8_t *)data, (zip_uint8_t *)data, (zip_uint64_t)n); - - if ((zip_uint64_t)n < length) { - ctx->eof = true; - } - - return (zip_int64_t)buffer_n + n; - - case ZIP_SOURCE_CLOSE: - _zip_buffer_free(ctx->buffer); - ctx->buffer = NULL; - return 0; - - case ZIP_SOURCE_STAT: { - zip_stat_t *st; - - st = (zip_stat_t *)data; - st->encryption_method = ZIP_EM_TRAD_PKWARE; - st->valid |= ZIP_STAT_ENCRYPTION_METHOD; - if (st->valid & ZIP_STAT_COMP_SIZE) { - st->comp_size += ZIP_CRYPTO_PKWARE_HEADERLEN; - } - - return 0; - } - - case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { - zip_file_attributes_t *attributes = (zip_file_attributes_t *)data; - if (length < sizeof(*attributes)) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED; - attributes->version_needed = 20; - - return 0; - } - - case ZIP_SOURCE_SUPPORTS: - return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, -1); - - case ZIP_SOURCE_ERROR: - return zip_error_to_data(&ctx->error, data, length); - - case ZIP_SOURCE_FREE: - trad_pkware_free(ctx); - return 0; - - default: - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } -} - - -static struct trad_pkware * -trad_pkware_new(const char *password, zip_error_t *error) { - struct trad_pkware *ctx; - - if ((ctx = (struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - if ((ctx->password = strdup(password)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - free(ctx); - return NULL; - } - ctx->buffer = NULL; - zip_error_init(&ctx->error); - - return ctx; -} - - -static void -trad_pkware_free(struct trad_pkware *ctx) { - if (ctx == NULL) { - return; - } - - free(ctx->password); - _zip_buffer_free(ctx->buffer); - zip_error_fini(&ctx->error); - free(ctx); -} diff --git a/Source/Libraries/libzip/zip_source_read.c b/Source/Libraries/libzip/zip_source_read.c deleted file mode 100644 index f146ab0..0000000 --- a/Source/Libraries/libzip/zip_source_read.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - zip_source_read.c -- read data from zip_source - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -zip_int64_t -zip_source_read(zip_source_t *src, void *data, zip_uint64_t len) { - zip_uint64_t bytes_read; - zip_int64_t n; - - if (src->source_closed) { - return -1; - } - if (!ZIP_SOURCE_IS_OPEN_READING(src) || len > ZIP_INT64_MAX || (len > 0 && data == NULL)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (src->had_read_error) { - return -1; - } - - if (_zip_source_eof(src)) { - return 0; - } - - if (len == 0) { - return 0; - } - - bytes_read = 0; - while (bytes_read < len) { - if ((n = _zip_source_call(src, (zip_uint8_t *)data + bytes_read, len - bytes_read, ZIP_SOURCE_READ)) < 0) { - src->had_read_error = true; - if (bytes_read == 0) { - return -1; - } - else { - return (zip_int64_t)bytes_read; - } - } - - if (n == 0) { - src->eof = 1; - break; - } - - bytes_read += (zip_uint64_t)n; - } - - if (src->bytes_read + bytes_read < src->bytes_read) { - src->bytes_read = ZIP_UINT64_MAX; - } - else { - src->bytes_read += bytes_read; - } - return (zip_int64_t)bytes_read; -} - - -bool -_zip_source_eof(zip_source_t *src) { - return src->eof; -} diff --git a/Source/Libraries/libzip/zip_source_remove.c b/Source/Libraries/libzip/zip_source_remove.c deleted file mode 100644 index a6ccd7e..0000000 --- a/Source/Libraries/libzip/zip_source_remove.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - zip_source_remove.c -- remove empty archive - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "zipint.h" - - -int -zip_source_remove(zip_source_t *src) { - if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) { - return 0; - } - - if (ZIP_SOURCE_IS_OPEN_READING(src)) { - if (zip_source_close(src) < 0) { - return -1; - } - } - if (src->write_state != ZIP_SOURCE_WRITE_CLOSED) { - zip_source_rollback_write(src); - } - - if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_REMOVE) < 0) { - return -1; - } - - src->write_state = ZIP_SOURCE_WRITE_REMOVED; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_rollback_write.c b/Source/Libraries/libzip/zip_source_rollback_write.c deleted file mode 100644 index d21b1ff..0000000 --- a/Source/Libraries/libzip/zip_source_rollback_write.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_source_rollback_write.c -- discard changes - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN void -zip_source_rollback_write(zip_source_t *src) { - if (src->write_state != ZIP_SOURCE_WRITE_OPEN && src->write_state != ZIP_SOURCE_WRITE_FAILED) { - return; - } - - _zip_source_call(src, NULL, 0, ZIP_SOURCE_ROLLBACK_WRITE); - src->write_state = ZIP_SOURCE_WRITE_CLOSED; -} diff --git a/Source/Libraries/libzip/zip_source_seek.c b/Source/Libraries/libzip/zip_source_seek.c deleted file mode 100644 index 29d1e96..0000000 --- a/Source/Libraries/libzip/zip_source_seek.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - zip_source_seek.c -- seek to offset - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_source_seek(zip_source_t *src, zip_int64_t offset, int whence) { - zip_source_args_seek_t args; - - if (src->source_closed) { - return -1; - } - if (!ZIP_SOURCE_IS_OPEN_READING(src) || (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - args.offset = offset; - args.whence = whence; - - if (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK) < 0) { - return -1; - } - - src->eof = 0; - return 0; -} - - -zip_int64_t -zip_source_seek_compute_offset(zip_uint64_t offset, zip_uint64_t length, void *data, zip_uint64_t data_length, zip_error_t *error) { - zip_int64_t new_offset; - zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, data_length, error); - - if (args == NULL) { - return -1; - } - - switch (args->whence) { - case SEEK_CUR: - new_offset = (zip_int64_t)offset + args->offset; - break; - - case SEEK_END: - new_offset = (zip_int64_t)length + args->offset; - break; - - case SEEK_SET: - new_offset = args->offset; - break; - - default: - zip_error_set(error, ZIP_ER_INVAL, 0); - return -1; - } - - if (new_offset < 0 || (zip_uint64_t)new_offset > length) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return -1; - } - - return new_offset; -} diff --git a/Source/Libraries/libzip/zip_source_seek_write.c b/Source/Libraries/libzip/zip_source_seek_write.c deleted file mode 100644 index 5fa2a81..0000000 --- a/Source/Libraries/libzip/zip_source_seek_write.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - zip_source_seek_write.c -- seek to offset for writing - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_source_seek_write(zip_source_t *src, zip_int64_t offset, int whence) { - zip_source_args_seek_t args; - - if (!ZIP_SOURCE_IS_OPEN_WRITING(src) || (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - args.offset = offset; - args.whence = whence; - - return (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK_WRITE) < 0 ? -1 : 0); -} diff --git a/Source/Libraries/libzip/zip_source_stat.c b/Source/Libraries/libzip/zip_source_stat.c deleted file mode 100644 index 46eb92d..0000000 --- a/Source/Libraries/libzip/zip_source_stat.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - zip_source_stat.c -- get meta information from zip_source - Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_source_stat(zip_source_t *src, zip_stat_t *st) { - if (src->source_closed) { - return -1; - } - if (st == NULL) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - zip_stat_init(st); - - if (ZIP_SOURCE_IS_LAYERED(src)) { - if (zip_source_stat(src->src, st) < 0) { - _zip_error_set_from_source(&src->error, src->src); - return -1; - } - } - - if (_zip_source_call(src, st, sizeof(*st), ZIP_SOURCE_STAT) < 0) { - return -1; - } - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_supports.c b/Source/Libraries/libzip/zip_source_supports.c deleted file mode 100644 index b4575a7..0000000 --- a/Source/Libraries/libzip/zip_source_supports.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - zip_source_supports.c -- check for supported functions - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -zip_int64_t -zip_source_supports(zip_source_t *src) { - return src->supports; -} - - -ZIP_EXTERN zip_int64_t -zip_source_make_command_bitmap(zip_source_cmd_t cmd0, ...) { - zip_int64_t bitmap; - va_list ap; - - bitmap = ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd0); - - - va_start(ap, cmd0); - for (;;) { - int cmd = va_arg(ap, int); - if (cmd < 0) { - break; - } - bitmap |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd); - } - va_end(ap); - - return bitmap; -} diff --git a/Source/Libraries/libzip/zip_source_tell.c b/Source/Libraries/libzip/zip_source_tell.c deleted file mode 100644 index b17412b..0000000 --- a/Source/Libraries/libzip/zip_source_tell.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - zip_source_tell.c -- report current offset - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_int64_t -zip_source_tell(zip_source_t *src) { - if (src->source_closed) { - return -1; - } - if (!ZIP_SOURCE_IS_OPEN_READING(src)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - if ((src->supports & (ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL) | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK))) == 0) { - if (src->bytes_read > ZIP_INT64_MAX) { - zip_error_set(&src->error, ZIP_ER_TELL, EOVERFLOW); - return -1; - } - return (zip_int64_t)src->bytes_read; - } - - return _zip_source_call(src, NULL, 0, ZIP_SOURCE_TELL); -} diff --git a/Source/Libraries/libzip/zip_source_tell_write.c b/Source/Libraries/libzip/zip_source_tell_write.c deleted file mode 100644 index c09a79f..0000000 --- a/Source/Libraries/libzip/zip_source_tell_write.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_source_tell_write.c -- report current offset for writing - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_int64_t -zip_source_tell_write(zip_source_t *src) { - if (!ZIP_SOURCE_IS_OPEN_WRITING(src)) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - return _zip_source_call(src, NULL, 0, ZIP_SOURCE_TELL_WRITE); -} diff --git a/Source/Libraries/libzip/zip_source_window.c b/Source/Libraries/libzip/zip_source_window.c deleted file mode 100644 index b63ba1d..0000000 --- a/Source/Libraries/libzip/zip_source_window.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - zip_source_window.c -- return part of lower source - Copyright (C) 2012-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include - -#include "zipint.h" - -struct window { - zip_uint64_t start; /* where in file we start reading */ - zip_uint64_t end; /* where in file we stop reading */ - - /* if not NULL, read file data for this file */ - zip_t *source_archive; - zip_uint64_t source_index; - - zip_uint64_t offset; /* offset in src for next read */ - - zip_stat_t stat; - zip_file_attributes_t attributes; - zip_error_t error; - zip_int64_t supports; - bool needs_seek; -}; - -static zip_int64_t window_read(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); - - -zip_source_t * -zip_source_window(zip_t *za, zip_source_t *src, zip_uint64_t start, zip_uint64_t len) { - return _zip_source_window_new(src, start, len, NULL, 0, NULL, 0, &za->error); -} - - -zip_source_t * -_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_uint64_t length, zip_stat_t *st, zip_file_attributes_t *attributes, zip_t *source_archive, zip_uint64_t source_index, zip_error_t *error) { - struct window *ctx; - - if (src == NULL || start + length < start || (source_archive == NULL && source_index != 0)) { - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((ctx = (struct window *)malloc(sizeof(*ctx))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - ctx->start = start; - ctx->end = start + length; - zip_stat_init(&ctx->stat); - if (attributes != NULL) { - memcpy(&ctx->attributes, attributes, sizeof(ctx->attributes)); - } - else { - zip_file_attributes_init(&ctx->attributes); - } - ctx->source_archive = source_archive; - ctx->source_index = source_index; - zip_error_init(&ctx->error); - ctx->supports = (zip_source_supports(src) & ZIP_SOURCE_SUPPORTS_SEEKABLE) | (zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, -1)); - ctx->needs_seek = (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK)) ? true : false; - - if (st) { - if (_zip_stat_merge(&ctx->stat, st, error) < 0) { - free(ctx); - return NULL; - } - } - - return zip_source_layered_create(src, window_read, ctx, error); -} - - -int -_zip_source_set_source_archive(zip_source_t *src, zip_t *za) { - src->source_archive = za; - return _zip_register_source(za, src); -} - - -/* called by zip_discard to avoid operating on file from closed archive */ -void -_zip_source_invalidate(zip_source_t *src) { - src->source_closed = 1; - - if (zip_error_code_zip(&src->error) == ZIP_ER_OK) { - zip_error_set(&src->error, ZIP_ER_ZIPCLOSED, 0); - } -} - - -static zip_int64_t -window_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { - struct window *ctx; - zip_int64_t ret; - zip_uint64_t n, i; - - ctx = (struct window *)_ctx; - - switch (cmd) { - case ZIP_SOURCE_CLOSE: - return 0; - - case ZIP_SOURCE_ERROR: - return zip_error_to_data(&ctx->error, data, len); - - case ZIP_SOURCE_FREE: - free(ctx); - return 0; - - case ZIP_SOURCE_OPEN: - if (ctx->source_archive) { - zip_uint64_t offset; - - if ((offset = _zip_file_get_offset(ctx->source_archive, ctx->source_index, &ctx->error)) == 0) { - return -1; - } - if (ctx->end + offset < ctx->end) { - /* zip archive data claims end of data past zip64 limits */ - zip_error_set(&ctx->error, ZIP_ER_INCONS, 0); - return -1; - } - ctx->start += offset; - ctx->end += offset; - ctx->source_archive = NULL; - } - - if (!ctx->needs_seek) { - DEFINE_BYTE_ARRAY(b, BUFSIZE); - - if (!byte_array_init(b, BUFSIZE)) { - zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); - return -1; - } - - for (n = 0; n < ctx->start; n += (zip_uint64_t)ret) { - i = (ctx->start - n > BUFSIZE ? BUFSIZE : ctx->start - n); - if ((ret = zip_source_read(src, b, i)) < 0) { - _zip_error_set_from_source(&ctx->error, src); - byte_array_fini(b); - return -1; - } - if (ret == 0) { - zip_error_set(&ctx->error, ZIP_ER_EOF, 0); - byte_array_fini(b); - return -1; - } - } - - byte_array_fini(b); - } - - ctx->offset = ctx->start; - return 0; - - case ZIP_SOURCE_READ: - if (len > ctx->end - ctx->offset) - len = ctx->end - ctx->offset; - - if (len == 0) - return 0; - - if (ctx->needs_seek) { - if (zip_source_seek(src, (zip_int64_t)ctx->offset, SEEK_SET) < 0) { - _zip_error_set_from_source(&ctx->error, src); - return -1; - } - } - - if ((ret = zip_source_read(src, data, len)) < 0) { - zip_error_set(&ctx->error, ZIP_ER_EOF, 0); - return -1; - } - - ctx->offset += (zip_uint64_t)ret; - - if (ret == 0) { - if (ctx->offset < ctx->end) { - zip_error_set(&ctx->error, ZIP_ER_EOF, 0); - return -1; - } - } - return ret; - - case ZIP_SOURCE_SEEK: { - zip_int64_t new_offset = zip_source_seek_compute_offset(ctx->offset - ctx->start, ctx->end - ctx->start, data, len, &ctx->error); - - if (new_offset < 0) { - return -1; - } - - ctx->offset = (zip_uint64_t)new_offset + ctx->start; - return 0; - } - - case ZIP_SOURCE_STAT: { - zip_stat_t *st; - - st = (zip_stat_t *)data; - - if (_zip_stat_merge(st, &ctx->stat, &ctx->error) < 0) { - return -1; - } - return 0; - } - - case ZIP_SOURCE_GET_FILE_ATTRIBUTES: - if (len < sizeof(ctx->attributes)) { - zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); - return -1; - } - - memcpy(data, &ctx->attributes, sizeof(ctx->attributes)); - return sizeof(ctx->attributes); - - case ZIP_SOURCE_SUPPORTS: - return ctx->supports; - - case ZIP_SOURCE_TELL: - return (zip_int64_t)(ctx->offset - ctx->start); - - default: - zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); - return -1; - } -} - - -void -_zip_deregister_source(zip_t *za, zip_source_t *src) { - unsigned int i; - - for (i = 0; i < za->nopen_source; i++) { - if (za->open_source[i] == src) { - za->open_source[i] = za->open_source[za->nopen_source - 1]; - za->nopen_source--; - break; - } - } -} - - -int -_zip_register_source(zip_t *za, zip_source_t *src) { - zip_source_t **open_source; - - if (za->nopen_source + 1 >= za->nopen_source_alloc) { - unsigned int n; - n = za->nopen_source_alloc + 10; - open_source = (zip_source_t **)realloc(za->open_source, n * sizeof(zip_source_t *)); - if (open_source == NULL) { - zip_error_set(&za->error, ZIP_ER_MEMORY, 0); - return -1; - } - za->nopen_source_alloc = n; - za->open_source = open_source; - } - - za->open_source[za->nopen_source++] = src; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_source_write.c b/Source/Libraries/libzip/zip_source_write.c deleted file mode 100644 index 33bf9c9..0000000 --- a/Source/Libraries/libzip/zip_source_write.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_source_write.c -- start a new file for writing - Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN zip_int64_t -zip_source_write(zip_source_t *src, const void *data, zip_uint64_t length) { - if (!ZIP_SOURCE_IS_OPEN_WRITING(src) || length > ZIP_INT64_MAX) { - zip_error_set(&src->error, ZIP_ER_INVAL, 0); - return -1; - } - - return _zip_source_call(src, (void *)data, length, ZIP_SOURCE_WRITE); -} diff --git a/Source/Libraries/libzip/zip_source_zip.c b/Source/Libraries/libzip/zip_source_zip.c deleted file mode 100644 index cb62540..0000000 --- a/Source/Libraries/libzip/zip_source_zip.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - zip_source_zip.c -- create data source from zip file - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN zip_source_t * -zip_source_zip(zip_t *za, zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len) { - if (len < -1) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - if (len == -1) - len = 0; - - if (start == 0 && len == 0) - flags |= ZIP_FL_COMPRESSED; - else - flags &= ~ZIP_FL_COMPRESSED; - - return _zip_source_zip_new(za, srcza, srcidx, flags, start, (zip_uint64_t)len, NULL); -} diff --git a/Source/Libraries/libzip/zip_source_zip_new.c b/Source/Libraries/libzip/zip_source_zip_new.c deleted file mode 100644 index ffb2bdf..0000000 --- a/Source/Libraries/libzip/zip_source_zip_new.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - zip_source_zip_new.c -- prepare data structures for zip_fopen/zip_source_zip - Copyright (C) 2012-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - -static void _zip_file_attributes_from_dirent(zip_file_attributes_t *attributes, zip_dirent_t *de); - -zip_source_t * -_zip_source_zip_new(zip_t *za, zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_uint64_t len, const char *password) { - zip_source_t *src, *s2; - zip_stat_t st; - zip_file_attributes_t attributes; - zip_dirent_t *de; - bool partial_data, needs_crc, needs_decrypt, needs_decompress; - - if (za == NULL) { - return NULL; - } - - if (srcza == NULL || srcidx >= srcza->nentry) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((flags & ZIP_FL_UNCHANGED) == 0 && (ZIP_ENTRY_DATA_CHANGED(srcza->entry + srcidx) || srcza->entry[srcidx].deleted)) { - zip_error_set(&za->error, ZIP_ER_CHANGED, 0); - return NULL; - } - - if (zip_stat_index(srcza, srcidx, flags | ZIP_FL_UNCHANGED, &st) < 0) { - zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); - return NULL; - } - - if (flags & ZIP_FL_ENCRYPTED) { - flags |= ZIP_FL_COMPRESSED; - } - - if ((start > 0 || len > 0) && (flags & ZIP_FL_COMPRESSED)) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - /* overflow or past end of file */ - if ((start > 0 || len > 0) && (start + len < start || start + len > st.size)) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return NULL; - } - - if (len == 0) { - len = st.size - start; - } - - partial_data = len < st.size; - needs_decrypt = ((flags & ZIP_FL_ENCRYPTED) == 0) && (st.encryption_method != ZIP_EM_NONE); - needs_decompress = ((flags & ZIP_FL_COMPRESSED) == 0) && (st.comp_method != ZIP_CM_STORE); - /* when reading the whole file, check for CRC errors */ - needs_crc = ((flags & ZIP_FL_COMPRESSED) == 0 || st.comp_method == ZIP_CM_STORE) && !partial_data; - - if (needs_decrypt) { - if (password == NULL) { - password = za->default_password; - } - if (password == NULL) { - zip_error_set(&za->error, ZIP_ER_NOPASSWD, 0); - return NULL; - } - } - - if ((de = _zip_get_dirent(srcza, srcidx, flags, &za->error)) == NULL) { - return NULL; - } - _zip_file_attributes_from_dirent(&attributes, de); - - if (st.comp_size == 0) { - return zip_source_buffer_with_attributes(za, NULL, 0, 0, &attributes); - } - - if (partial_data && !needs_decrypt && !needs_decompress) { - struct zip_stat st2; - - st2.size = len; - st2.comp_size = len; - st2.comp_method = ZIP_CM_STORE; - st2.mtime = st.mtime; - st2.valid = ZIP_STAT_SIZE | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_MTIME; - - if ((src = _zip_source_window_new(srcza->src, start, len, &st2, &attributes, srcza, srcidx, &za->error)) == NULL) { - return NULL; - } - } - else { - if ((src = _zip_source_window_new(srcza->src, 0, st.comp_size, &st, &attributes, srcza, srcidx, &za->error)) == NULL) { - return NULL; - } - } - - if (_zip_source_set_source_archive(src, srcza) < 0) { - zip_source_free(src); - return NULL; - } - - /* creating a layered source calls zip_keep() on the lower layer, so we free it */ - - if (needs_decrypt) { - zip_encryption_implementation enc_impl; - - if ((enc_impl = _zip_get_encryption_implementation(st.encryption_method, ZIP_CODEC_DECODE)) == NULL) { - zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); - return NULL; - } - - s2 = enc_impl(za, src, st.encryption_method, 0, password); - zip_source_free(src); - if (s2 == NULL) { - return NULL; - } - src = s2; - } - if (needs_decompress) { - s2 = zip_source_decompress(za, src, st.comp_method); - zip_source_free(src); - if (s2 == NULL) { - return NULL; - } - src = s2; - } - if (needs_crc) { - s2 = zip_source_crc(za, src, 1); - zip_source_free(src); - if (s2 == NULL) { - return NULL; - } - src = s2; - } - - if (partial_data && (needs_decrypt || needs_decompress)) { - s2 = zip_source_window(za, src, start, len); - zip_source_free(src); - if (s2 == NULL) { - return NULL; - } - src = s2; - } - - return src; -} - -static void -_zip_file_attributes_from_dirent(zip_file_attributes_t *attributes, zip_dirent_t *de) { - zip_file_attributes_init(attributes); - attributes->valid = ZIP_FILE_ATTRIBUTES_ASCII | ZIP_FILE_ATTRIBUTES_HOST_SYSTEM | ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES | ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS; - attributes->ascii = de->int_attrib & 1; - attributes->host_system = de->version_madeby >> 8; - attributes->external_file_attributes = de->ext_attrib; - attributes->general_purpose_bit_flags = de->bitflags; - attributes->general_purpose_bit_mask = ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK; -} diff --git a/Source/Libraries/libzip/zip_stat.c b/Source/Libraries/libzip/zip_stat.c deleted file mode 100644 index c328dcf..0000000 --- a/Source/Libraries/libzip/zip_stat.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - zip_stat.c -- get information about file by name - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_stat(zip_t *za, const char *fname, zip_flags_t flags, zip_stat_t *st) { - zip_int64_t idx; - - if ((idx = zip_name_locate(za, fname, flags)) < 0) - return -1; - - return zip_stat_index(za, (zip_uint64_t)idx, flags, st); -} diff --git a/Source/Libraries/libzip/zip_stat_index.c b/Source/Libraries/libzip/zip_stat_index.c deleted file mode 100644 index 62dc045..0000000 --- a/Source/Libraries/libzip/zip_stat_index.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - zip_stat_index.c -- get information about file by index - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st) { - const char *name; - zip_dirent_t *de; - - if ((de = _zip_get_dirent(za, index, flags, NULL)) == NULL) - return -1; - - if ((name = zip_get_name(za, index, flags)) == NULL) - return -1; - - - if ((flags & ZIP_FL_UNCHANGED) == 0 && ZIP_ENTRY_DATA_CHANGED(za->entry + index)) { - zip_entry_t *entry = za->entry + index; - - if (zip_source_stat(entry->source, st) < 0) { - zip_error_set(&za->error, ZIP_ER_CHANGED, 0); - return -1; - } - - if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) { - st->mtime = de->last_mod; - st->valid |= ZIP_STAT_MTIME; - } - } - else { - zip_stat_init(st); - - st->crc = de->crc; - st->size = de->uncomp_size; - st->mtime = de->last_mod; - st->comp_size = de->comp_size; - st->comp_method = (zip_uint16_t)de->comp_method; - st->encryption_method = de->encryption_method; - st->valid = (de->crc_valid ? ZIP_STAT_CRC : 0) | ZIP_STAT_SIZE | ZIP_STAT_MTIME | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD; - } - - st->index = index; - st->name = name; - st->valid |= ZIP_STAT_INDEX | ZIP_STAT_NAME; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_stat_init.c b/Source/Libraries/libzip/zip_stat_init.c deleted file mode 100644 index 0cf51ef..0000000 --- a/Source/Libraries/libzip/zip_stat_init.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - zip_stat_init.c -- initialize struct zip_stat. - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -#include "zipint.h" - - -ZIP_EXTERN void -zip_stat_init(zip_stat_t *st) { - st->valid = 0; - st->name = NULL; - st->index = ZIP_UINT64_MAX; - st->crc = 0; - st->mtime = (time_t)-1; - st->size = 0; - st->comp_size = 0; - st->comp_method = ZIP_CM_STORE; - st->encryption_method = ZIP_EM_NONE; -} - - -int -_zip_stat_merge(zip_stat_t *dst, const zip_stat_t *src, zip_error_t *error) { - /* name is not merged, since zip_stat_t doesn't own it, and src may not be valid as long as dst */ - if (src->valid & ZIP_STAT_INDEX) { - dst->index = src->index; - } - if (src->valid & ZIP_STAT_SIZE) { - dst->size = src->size; - } - if (src->valid & ZIP_STAT_COMP_SIZE) { - dst->comp_size = src->comp_size; - } - if (src->valid & ZIP_STAT_MTIME) { - dst->mtime = src->mtime; - } - if (src->valid & ZIP_STAT_CRC) { - dst->crc = src->crc; - } - if (src->valid & ZIP_STAT_COMP_METHOD) { - dst->comp_method = src->comp_method; - } - if (src->valid & ZIP_STAT_ENCRYPTION_METHOD) { - dst->encryption_method = src->encryption_method; - } - if (src->valid & ZIP_STAT_FLAGS) { - dst->flags = src->flags; - } - dst->valid |= src->valid; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_strerror.c b/Source/Libraries/libzip/zip_strerror.c deleted file mode 100644 index 6adec16..0000000 --- a/Source/Libraries/libzip/zip_strerror.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - zip_sterror.c -- get string representation of zip error - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN const char * -zip_strerror(zip_t *za) { - return zip_error_strerror(&za->error); -} diff --git a/Source/Libraries/libzip/zip_string.c b/Source/Libraries/libzip/zip_string.c deleted file mode 100644 index 2c6f428..0000000 --- a/Source/Libraries/libzip/zip_string.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - zip_string.c -- string handling (with encoding) - Copyright (C) 2012-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include -#include -#include - -#include "zipint.h" - -zip_uint32_t -_zip_string_crc32(const zip_string_t *s) { - zip_uint32_t crc; - - crc = (zip_uint32_t)crc32(0L, Z_NULL, 0); - - if (s != NULL) - crc = (zip_uint32_t)crc32(crc, s->raw, s->length); - - return crc; -} - - -int -_zip_string_equal(const zip_string_t *a, const zip_string_t *b) { - if (a == NULL || b == NULL) - return a == b; - - if (a->length != b->length) - return 0; - - /* TODO: encoding */ - - return (memcmp(a->raw, b->raw, a->length) == 0); -} - - -void -_zip_string_free(zip_string_t *s) { - if (s == NULL) - return; - - free(s->raw); - free(s->converted); - free(s); -} - - -const zip_uint8_t * -_zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip_error_t *error) { - static const zip_uint8_t empty[1] = ""; - - if (string == NULL) { - if (lenp) - *lenp = 0; - return empty; - } - - if ((flags & ZIP_FL_ENC_RAW) == 0) { - /* start guessing */ - if (string->encoding == ZIP_ENCODING_UNKNOWN) - _zip_guess_encoding(string, ZIP_ENCODING_UNKNOWN); - - if (((flags & ZIP_FL_ENC_STRICT) && string->encoding != ZIP_ENCODING_ASCII && string->encoding != ZIP_ENCODING_UTF8_KNOWN) || (string->encoding == ZIP_ENCODING_CP437)) { - if (string->converted == NULL) { - if ((string->converted = _zip_cp437_to_utf8(string->raw, string->length, &string->converted_length, error)) == NULL) - return NULL; - } - if (lenp) - *lenp = string->converted_length; - return string->converted; - } - } - - if (lenp) - *lenp = string->length; - return string->raw; -} - - -zip_uint16_t -_zip_string_length(const zip_string_t *s) { - if (s == NULL) - return 0; - - return s->length; -} - - -zip_string_t * -_zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, zip_error_t *error) { - zip_string_t *s; - zip_encoding_type_t expected_encoding; - - if (length == 0) - return NULL; - - switch (flags & ZIP_FL_ENCODING_ALL) { - case ZIP_FL_ENC_GUESS: - expected_encoding = ZIP_ENCODING_UNKNOWN; - break; - case ZIP_FL_ENC_UTF_8: - expected_encoding = ZIP_ENCODING_UTF8_KNOWN; - break; - case ZIP_FL_ENC_CP437: - expected_encoding = ZIP_ENCODING_CP437; - break; - default: - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - - if ((s = (zip_string_t *)malloc(sizeof(*s))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - if ((s->raw = (zip_uint8_t *)malloc((size_t)length + 1)) == NULL) { - free(s); - return NULL; - } - - memcpy(s->raw, raw, length); - s->raw[length] = '\0'; - s->length = length; - s->encoding = ZIP_ENCODING_UNKNOWN; - s->converted = NULL; - s->converted_length = 0; - - if (expected_encoding != ZIP_ENCODING_UNKNOWN) { - if (_zip_guess_encoding(s, expected_encoding) == ZIP_ENCODING_ERROR) { - _zip_string_free(s); - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } - } - - return s; -} - - -int -_zip_string_write(zip_t *za, const zip_string_t *s) { - if (s == NULL) - return 0; - - return _zip_write(za, s->raw, s->length); -} diff --git a/Source/Libraries/libzip/zip_unchange.c b/Source/Libraries/libzip/zip_unchange.c deleted file mode 100644 index 17e2500..0000000 --- a/Source/Libraries/libzip/zip_unchange.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - zip_unchange.c -- undo changes to file in zip archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_unchange(zip_t *za, zip_uint64_t idx) { - return _zip_unchange(za, idx, 0); -} - - -int -_zip_unchange(zip_t *za, zip_uint64_t idx, int allow_duplicates) { - zip_int64_t i; - const char *orig_name, *changed_name; - - if (idx >= za->nentry) { - zip_error_set(&za->error, ZIP_ER_INVAL, 0); - return -1; - } - - if (!allow_duplicates && za->entry[idx].changes && (za->entry[idx].changes->changed & ZIP_DIRENT_FILENAME)) { - if (za->entry[idx].orig != NULL) { - if ((orig_name = _zip_get_name(za, idx, ZIP_FL_UNCHANGED, &za->error)) == NULL) { - return -1; - } - - i = _zip_name_locate(za, orig_name, 0, NULL); - if (i >= 0 && (zip_uint64_t)i != idx) { - zip_error_set(&za->error, ZIP_ER_EXISTS, 0); - return -1; - } - } - else { - orig_name = NULL; - } - - if ((changed_name = _zip_get_name(za, idx, 0, &za->error)) == NULL) { - return -1; - } - - if (orig_name) { - if (_zip_hash_add(za->names, (const zip_uint8_t *)orig_name, idx, 0, &za->error) == false) { - return -1; - } - } - if (_zip_hash_delete(za->names, (const zip_uint8_t *)changed_name, &za->error) == false) { - _zip_hash_delete(za->names, (const zip_uint8_t *)orig_name, NULL); - return -1; - } - } - - _zip_dirent_free(za->entry[idx].changes); - za->entry[idx].changes = NULL; - - _zip_unchange_data(za->entry + idx); - - return 0; -} diff --git a/Source/Libraries/libzip/zip_unchange_all.c b/Source/Libraries/libzip/zip_unchange_all.c deleted file mode 100644 index b8bfd70..0000000 --- a/Source/Libraries/libzip/zip_unchange_all.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - zip_unchange.c -- undo changes to all files in zip archive - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - - -ZIP_EXTERN int -zip_unchange_all(zip_t *za) { - int ret; - zip_uint64_t i; - - if (!_zip_hash_revert(za->names, &za->error)) { - return -1; - } - - ret = 0; - for (i = 0; i < za->nentry; i++) - ret |= _zip_unchange(za, i, 1); - - ret |= zip_unchange_archive(za); - - return ret; -} diff --git a/Source/Libraries/libzip/zip_unchange_archive.c b/Source/Libraries/libzip/zip_unchange_archive.c deleted file mode 100644 index ebf2bd5..0000000 --- a/Source/Libraries/libzip/zip_unchange_archive.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - zip_unchange_archive.c -- undo global changes to ZIP archive - Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include - -#include "zipint.h" - - -ZIP_EXTERN int -zip_unchange_archive(zip_t *za) { - if (za->comment_changed) { - _zip_string_free(za->comment_changes); - za->comment_changes = NULL; - za->comment_changed = 0; - } - - za->ch_flags = za->flags; - - return 0; -} diff --git a/Source/Libraries/libzip/zip_unchange_data.c b/Source/Libraries/libzip/zip_unchange_data.c deleted file mode 100644 index 2a393ad..0000000 --- a/Source/Libraries/libzip/zip_unchange_data.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - zip_unchange_data.c -- undo helper function - Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -void -_zip_unchange_data(zip_entry_t *ze) { - if (ze->source) { - zip_source_free(ze->source); - ze->source = NULL; - } - - if (ze->changes != NULL && (ze->changes->changed & ZIP_DIRENT_COMP_METHOD) && ze->changes->comp_method == ZIP_CM_REPLACED_DEFAULT) { - ze->changes->changed &= ~ZIP_DIRENT_COMP_METHOD; - if (ze->changes->changed == 0) { - _zip_dirent_free(ze->changes); - ze->changes = NULL; - } - } - - ze->deleted = 0; -} diff --git a/Source/Libraries/libzip/zip_utf-8.c b/Source/Libraries/libzip/zip_utf-8.c deleted file mode 100644 index 51a4722..0000000 --- a/Source/Libraries/libzip/zip_utf-8.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - zip_utf-8.c -- UTF-8 support functions for libzip - Copyright (C) 2011-2020 Dieter Baron and Thomas Klausner - - This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at - - 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. - 3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "zipint.h" - -#include - - -static const zip_uint16_t _cp437_to_unicode[256] = { - /* 0x00 - 0x0F */ - 0x0000, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, 0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C, - - /* 0x10 - 0x1F */ - 0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8, 0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC, - - /* 0x20 - 0x2F */ - 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, - - /* 0x30 - 0x3F */ - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, - - /* 0x40 - 0x4F */ - 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, - - /* 0x50 - 0x5F */ - 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, - - /* 0x60 - 0x6F */ - 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, - - /* 0x70 - 0x7F */ - 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2302, - - /* 0x80 - 0x8F */ - 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, - - /* 0x90 - 0x9F */ - 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, - - /* 0xA0 - 0xAF */ - 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, - - /* 0xB0 - 0xBF */ - 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, - - /* 0xC0 - 0xCF */ - 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, - - /* 0xD0 - 0xDF */ - 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, - - /* 0xE0 - 0xEF */ - 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, - - /* 0xF0 - 0xFF */ - 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0}; - -#define UTF_8_LEN_2_MASK 0xe0 -#define UTF_8_LEN_2_MATCH 0xc0 -#define UTF_8_LEN_3_MASK 0xf0 -#define UTF_8_LEN_3_MATCH 0xe0 -#define UTF_8_LEN_4_MASK 0xf8 -#define UTF_8_LEN_4_MATCH 0xf0 -#define UTF_8_CONTINUE_MASK 0xc0 -#define UTF_8_CONTINUE_MATCH 0x80 - - -zip_encoding_type_t -_zip_guess_encoding(zip_string_t *str, zip_encoding_type_t expected_encoding) { - zip_encoding_type_t enc; - const zip_uint8_t *name; - zip_uint32_t i, j, ulen; - - if (str == NULL) - return ZIP_ENCODING_ASCII; - - name = str->raw; - - if (str->encoding != ZIP_ENCODING_UNKNOWN) - enc = str->encoding; - else { - enc = ZIP_ENCODING_ASCII; - for (i = 0; i < str->length; i++) { - if ((name[i] > 31 && name[i] < 128) || name[i] == '\r' || name[i] == '\n' || name[i] == '\t') - continue; - - enc = ZIP_ENCODING_UTF8_GUESSED; - if ((name[i] & UTF_8_LEN_2_MASK) == UTF_8_LEN_2_MATCH) - ulen = 1; - else if ((name[i] & UTF_8_LEN_3_MASK) == UTF_8_LEN_3_MATCH) - ulen = 2; - else if ((name[i] & UTF_8_LEN_4_MASK) == UTF_8_LEN_4_MATCH) - ulen = 3; - else { - enc = ZIP_ENCODING_CP437; - break; - } - - if (i + ulen >= str->length) { - enc = ZIP_ENCODING_CP437; - break; - } - - for (j = 1; j <= ulen; j++) { - if ((name[i + j] & UTF_8_CONTINUE_MASK) != UTF_8_CONTINUE_MATCH) { - enc = ZIP_ENCODING_CP437; - goto done; - } - } - i += ulen; - } - } - -done: - str->encoding = enc; - - if (expected_encoding != ZIP_ENCODING_UNKNOWN) { - if (expected_encoding == ZIP_ENCODING_UTF8_KNOWN && enc == ZIP_ENCODING_UTF8_GUESSED) - str->encoding = enc = ZIP_ENCODING_UTF8_KNOWN; - - if (expected_encoding != enc && enc != ZIP_ENCODING_ASCII) - return ZIP_ENCODING_ERROR; - } - - return enc; -} - - -static zip_uint32_t -_zip_unicode_to_utf8_len(zip_uint32_t codepoint) { - if (codepoint < 0x0080) - return 1; - if (codepoint < 0x0800) - return 2; - if (codepoint < 0x10000) - return 3; - return 4; -} - - -static zip_uint32_t -_zip_unicode_to_utf8(zip_uint32_t codepoint, zip_uint8_t *buf) { - if (codepoint < 0x0080) { - buf[0] = codepoint & 0xff; - return 1; - } - if (codepoint < 0x0800) { - buf[0] = (zip_uint8_t)(UTF_8_LEN_2_MATCH | ((codepoint >> 6) & 0x1f)); - buf[1] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | (codepoint & 0x3f)); - return 2; - } - if (codepoint < 0x10000) { - buf[0] = (zip_uint8_t)(UTF_8_LEN_3_MATCH | ((codepoint >> 12) & 0x0f)); - buf[1] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | ((codepoint >> 6) & 0x3f)); - buf[2] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | (codepoint & 0x3f)); - return 3; - } - buf[0] = (zip_uint8_t)(UTF_8_LEN_4_MATCH | ((codepoint >> 18) & 0x07)); - buf[1] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | ((codepoint >> 12) & 0x3f)); - buf[2] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | ((codepoint >> 6) & 0x3f)); - buf[3] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | (codepoint & 0x3f)); - return 4; -} - - -zip_uint8_t * -_zip_cp437_to_utf8(const zip_uint8_t *const _cp437buf, zip_uint32_t len, zip_uint32_t *utf8_lenp, zip_error_t *error) { - zip_uint8_t *cp437buf = (zip_uint8_t *)_cp437buf; - zip_uint8_t *utf8buf; - zip_uint32_t buflen, i, offset; - - if (len == 0) { - if (utf8_lenp) - *utf8_lenp = 0; - return NULL; - } - - buflen = 1; - for (i = 0; i < len; i++) - buflen += _zip_unicode_to_utf8_len(_cp437_to_unicode[cp437buf[i]]); - - if ((utf8buf = (zip_uint8_t *)malloc(buflen)) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; - } - - offset = 0; - for (i = 0; i < len; i++) - offset += _zip_unicode_to_utf8(_cp437_to_unicode[cp437buf[i]], utf8buf + offset); - - utf8buf[buflen - 1] = 0; - if (utf8_lenp) - *utf8_lenp = buflen - 1; - return utf8buf; -} diff --git a/Source/Libraries/zlib/FAQ b/Source/Libraries/zlib/FAQ deleted file mode 100644 index 99b7cf9..0000000 --- a/Source/Libraries/zlib/FAQ +++ /dev/null @@ -1,368 +0,0 @@ - - Frequently Asked Questions about zlib - - -If your question is not there, please check the zlib home page -http://zlib.net/ which may have more recent information. -The lastest zlib FAQ is at http://zlib.net/zlib_faq.html - - - 1. Is zlib Y2K-compliant? - - Yes. zlib doesn't handle dates. - - 2. Where can I get a Windows DLL version? - - The zlib sources can be compiled without change to produce a DLL. See the - file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the - precompiled DLL are found in the zlib web site at http://zlib.net/ . - - 3. Where can I get a Visual Basic interface to zlib? - - See - * http://marknelson.us/1997/01/01/zlib-engine/ - * win32/DLL_FAQ.txt in the zlib distribution - - 4. compress() returns Z_BUF_ERROR. - - Make sure that before the call of compress(), the length of the compressed - buffer is equal to the available size of the compressed buffer and not - zero. For Visual Basic, check that this parameter is passed by reference - ("as any"), not by value ("as long"). - - 5. deflate() or inflate() returns Z_BUF_ERROR. - - Before making the call, make sure that avail_in and avail_out are not zero. - When setting the parameter flush equal to Z_FINISH, also make sure that - avail_out is big enough to allow processing all pending input. Note that a - Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be - made with more input or output space. A Z_BUF_ERROR may in fact be - unavoidable depending on how the functions are used, since it is not - possible to tell whether or not there is more output pending when - strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a - heavily annotated example. - - 6. Where's the zlib documentation (man pages, etc.)? - - It's in zlib.h . Examples of zlib usage are in the files test/example.c - and test/minigzip.c, with more in examples/ . - - 7. Why don't you use GNU autoconf or libtool or ...? - - Because we would like to keep zlib as a very small and simple package. - zlib is rather portable and doesn't need much configuration. - - 8. I found a bug in zlib. - - Most of the time, such problems are due to an incorrect usage of zlib. - Please try to reproduce the problem with a small program and send the - corresponding source to us at zlib@gzip.org . Do not send multi-megabyte - data files without prior agreement. - - 9. Why do I get "undefined reference to gzputc"? - - If "make test" produces something like - - example.o(.text+0x154): undefined reference to `gzputc' - - check that you don't have old files libz.* in /usr/lib, /usr/local/lib or - /usr/X11R6/lib. Remove any old versions, then do "make install". - -10. I need a Delphi interface to zlib. - - See the contrib/delphi directory in the zlib distribution. - -11. Can zlib handle .zip archives? - - Not by itself, no. See the directory contrib/minizip in the zlib - distribution. - -12. Can zlib handle .Z files? - - No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt - the code of uncompress on your own. - -13. How can I make a Unix shared library? - - By default a shared (and a static) library is built for Unix. So: - - make distclean - ./configure - make - -14. How do I install a shared zlib library on Unix? - - After the above, then: - - make install - - However, many flavors of Unix come with a shared zlib already installed. - Before going to the trouble of compiling a shared version of zlib and - trying to install it, you may want to check if it's already there! If you - can #include , it's there. The -lz option will probably link to - it. You can check the version at the top of zlib.h or with the - ZLIB_VERSION symbol defined in zlib.h . - -15. I have a question about OttoPDF. - - We are not the authors of OttoPDF. The real author is on the OttoPDF web - site: Joel Hainley, jhainley@myndkryme.com. - -16. Can zlib decode Flate data in an Adobe PDF file? - - Yes. See http://www.pdflib.com/ . To modify PDF forms, see - http://sourceforge.net/projects/acroformtool/ . - -17. Why am I getting this "register_frame_info not found" error on Solaris? - - After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib - generates an error such as: - - ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: - symbol __register_frame_info: referenced symbol not found - - The symbol __register_frame_info is not part of zlib, it is generated by - the C compiler (cc or gcc). You must recompile applications using zlib - which have this problem. This problem is specific to Solaris. See - http://www.sunfreeware.com for Solaris versions of zlib and applications - using zlib. - -18. Why does gzip give an error on a file I make with compress/deflate? - - The compress and deflate functions produce data in the zlib format, which - is different and incompatible with the gzip format. The gz* functions in - zlib on the other hand use the gzip format. Both the zlib and gzip formats - use the same compressed data format internally, but have different headers - and trailers around the compressed data. - -19. Ok, so why are there two different formats? - - The gzip format was designed to retain the directory information about a - single file, such as the name and last modification date. The zlib format - on the other hand was designed for in-memory and communication channel - applications, and has a much more compact header and trailer and uses a - faster integrity check than gzip. - -20. Well that's nice, but how do I make a gzip file in memory? - - You can request that deflate write the gzip format instead of the zlib - format using deflateInit2(). You can also request that inflate decode the - gzip format using inflateInit2(). Read zlib.h for more details. - -21. Is zlib thread-safe? - - Yes. However any library routines that zlib uses and any application- - provided memory allocation routines must also be thread-safe. zlib's gz* - functions use stdio library routines, and most of zlib's functions use the - library memory allocation routines by default. zlib's *Init* functions - allow for the application to provide custom memory allocation routines. - - Of course, you should only operate on any given zlib or gzip stream from a - single thread at a time. - -22. Can I use zlib in my commercial application? - - Yes. Please read the license in zlib.h. - -23. Is zlib under the GNU license? - - No. Please read the license in zlib.h. - -24. The license says that altered source versions must be "plainly marked". So - what exactly do I need to do to meet that requirement? - - You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In - particular, the final version number needs to be changed to "f", and an - identification string should be appended to ZLIB_VERSION. Version numbers - x.x.x.f are reserved for modifications to zlib by others than the zlib - maintainers. For example, if the version of the base zlib you are altering - is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and - ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also - update the version strings in deflate.c and inftrees.c. - - For altered source distributions, you should also note the origin and - nature of the changes in zlib.h, as well as in ChangeLog and README, along - with the dates of the alterations. The origin should include at least your - name (or your company's name), and an email address to contact for help or - issues with the library. - - Note that distributing a compiled zlib library along with zlib.h and - zconf.h is also a source distribution, and so you should change - ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes - in zlib.h as you would for a full source distribution. - -25. Will zlib work on a big-endian or little-endian architecture, and can I - exchange compressed data between them? - - Yes and yes. - -26. Will zlib work on a 64-bit machine? - - Yes. It has been tested on 64-bit machines, and has no dependence on any - data types being limited to 32-bits in length. If you have any - difficulties, please provide a complete problem report to zlib@gzip.org - -27. Will zlib decompress data from the PKWare Data Compression Library? - - No. The PKWare DCL uses a completely different compressed data format than - does PKZIP and zlib. However, you can look in zlib's contrib/blast - directory for a possible solution to your problem. - -28. Can I access data randomly in a compressed stream? - - No, not without some preparation. If when compressing you periodically use - Z_FULL_FLUSH, carefully write all the pending data at those points, and - keep an index of those locations, then you can start decompression at those - points. You have to be careful to not use Z_FULL_FLUSH too often, since it - can significantly degrade compression. Alternatively, you can scan a - deflate stream once to generate an index, and then use that index for - random access. See examples/zran.c . - -29. Does zlib work on MVS, OS/390, CICS, etc.? - - It has in the past, but we have not heard of any recent evidence. There - were working ports of zlib 1.1.4 to MVS, but those links no longer work. - If you know of recent, successful applications of zlib on these operating - systems, please let us know. Thanks. - -30. Is there some simpler, easier to read version of inflate I can look at to - understand the deflate format? - - First off, you should read RFC 1951. Second, yes. Look in zlib's - contrib/puff directory. - -31. Does zlib infringe on any patents? - - As far as we know, no. In fact, that was originally the whole point behind - zlib. Look here for some more information: - - http://www.gzip.org/#faq11 - -32. Can zlib work with greater than 4 GB of data? - - Yes. inflate() and deflate() will process any amount of data correctly. - Each call of inflate() or deflate() is limited to input and output chunks - of the maximum value that can be stored in the compiler's "unsigned int" - type, but there is no limit to the number of chunks. Note however that the - strm.total_in and strm_total_out counters may be limited to 4 GB. These - counters are provided as a convenience and are not used internally by - inflate() or deflate(). The application can easily set up its own counters - updated after each call of inflate() or deflate() to count beyond 4 GB. - compress() and uncompress() may be limited to 4 GB, since they operate in a - single call. gzseek() and gztell() may be limited to 4 GB depending on how - zlib is compiled. See the zlibCompileFlags() function in zlib.h. - - The word "may" appears several times above since there is a 4 GB limit only - if the compiler's "long" type is 32 bits. If the compiler's "long" type is - 64 bits, then the limit is 16 exabytes. - -33. Does zlib have any security vulnerabilities? - - The only one that we are aware of is potentially in gzprintf(). If zlib is - compiled to use sprintf() or vsprintf(), then there is no protection - against a buffer overflow of an 8K string space (or other value as set by - gzbuffer()), other than the caller of gzprintf() assuring that the output - will not exceed 8K. On the other hand, if zlib is compiled to use - snprintf() or vsnprintf(), which should normally be the case, then there is - no vulnerability. The ./configure script will display warnings if an - insecure variation of sprintf() will be used by gzprintf(). Also the - zlibCompileFlags() function will return information on what variant of - sprintf() is used by gzprintf(). - - If you don't have snprintf() or vsnprintf() and would like one, you can - find a portable implementation here: - - http://www.ijs.si/software/snprintf/ - - Note that you should be using the most recent version of zlib. Versions - 1.1.3 and before were subject to a double-free vulnerability, and versions - 1.2.1 and 1.2.2 were subject to an access exception when decompressing - invalid compressed data. - -34. Is there a Java version of zlib? - - Probably what you want is to use zlib in Java. zlib is already included - as part of the Java SDK in the java.util.zip package. If you really want - a version of zlib written in the Java language, look on the zlib home - page for links: http://zlib.net/ . - -35. I get this or that compiler or source-code scanner warning when I crank it - up to maximally-pedantic. Can't you guys write proper code? - - Many years ago, we gave up attempting to avoid warnings on every compiler - in the universe. It just got to be a waste of time, and some compilers - were downright silly as well as contradicted each other. So now, we simply - make sure that the code always works. - -36. Valgrind (or some similar memory access checker) says that deflate is - performing a conditional jump that depends on an uninitialized value. - Isn't that a bug? - - No. That is intentional for performance reasons, and the output of deflate - is not affected. This only started showing up recently since zlib 1.2.x - uses malloc() by default for allocations, whereas earlier versions used - calloc(), which zeros out the allocated memory. Even though the code was - correct, versions 1.2.4 and later was changed to not stimulate these - checkers. - -37. Will zlib read the (insert any ancient or arcane format here) compressed - data format? - - Probably not. Look in the comp.compression FAQ for pointers to various - formats and associated software. - -38. How can I encrypt/decrypt zip files with zlib? - - zlib doesn't support encryption. The original PKZIP encryption is very - weak and can be broken with freely available programs. To get strong - encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib - compression. For PKZIP compatible "encryption", look at - http://www.info-zip.org/ - -39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? - - "gzip" is the gzip format, and "deflate" is the zlib format. They should - probably have called the second one "zlib" instead to avoid confusion with - the raw deflate compressed data format. While the HTTP 1.1 RFC 2616 - correctly points to the zlib specification in RFC 1950 for the "deflate" - transfer encoding, there have been reports of servers and browsers that - incorrectly produce or expect raw deflate data per the deflate - specification in RFC 1951, most notably Microsoft. So even though the - "deflate" transfer encoding using the zlib format would be the more - efficient approach (and in fact exactly what the zlib format was designed - for), using the "gzip" transfer encoding is probably more reliable due to - an unfortunate choice of name on the part of the HTTP 1.1 authors. - - Bottom line: use the gzip format for HTTP 1.1 encoding. - -40. Does zlib support the new "Deflate64" format introduced by PKWare? - - No. PKWare has apparently decided to keep that format proprietary, since - they have not documented it as they have previous compression formats. In - any case, the compression improvements are so modest compared to other more - modern approaches, that it's not worth the effort to implement. - -41. I'm having a problem with the zip functions in zlib, can you help? - - There are no zip functions in zlib. You are probably using minizip by - Giles Vollant, which is found in the contrib directory of zlib. It is not - part of zlib. In fact none of the stuff in contrib is part of zlib. The - files in there are not supported by the zlib authors. You need to contact - the authors of the respective contribution for help. - -42. The match.asm code in contrib is under the GNU General Public License. - Since it's part of zlib, doesn't that mean that all of zlib falls under the - GNU GPL? - - No. The files in contrib are not part of zlib. They were contributed by - other authors and are provided as a convenience to the user within the zlib - distribution. Each item in contrib has its own license. - -43. Is zlib subject to export controls? What is its ECCN? - - zlib is not subject to export controls, and so is classified as EAR99. - -44. Can you please sign these lengthy legal documents and fax them back to us - so that we can use your software in our product? - - No. Go away. Shoo. diff --git a/Source/Libraries/zlib/README b/Source/Libraries/zlib/README deleted file mode 100644 index 51106de..0000000 --- a/Source/Libraries/zlib/README +++ /dev/null @@ -1,115 +0,0 @@ -ZLIB DATA COMPRESSION LIBRARY - -zlib 1.2.11 is a general purpose data compression library. All the code is -thread safe. The data format used by the zlib library is described by RFCs -(Request for Comments) 1950 to 1952 in the files -http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and -rfc1952 (gzip format). - -All functions of the compression library are documented in the file zlib.h -(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example -of the library is given in the file test/example.c which also tests that -the library is working correctly. Another example is given in the file -test/minigzip.c. The compression library itself is composed of all source -files in the root directory. - -To compile all files and run the test program, follow the instructions given at -the top of Makefile.in. In short "./configure; make test", and if that goes -well, "make install" should work for most flavors of Unix. For Windows, use -one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use -make_vms.com. - -Questions about zlib should be sent to , or to Gilles Vollant - for the Windows DLL version. The zlib home page is -http://zlib.net/ . Before reporting a problem, please check this site to -verify that you have the latest version of zlib; otherwise get the latest -version and check whether the problem still exists or not. - -PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. - -Mark Nelson wrote an article about zlib for the Jan. 1997 -issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . - -The changes made in version 1.2.11 are documented in the file ChangeLog. - -Unsupported third party contributions are provided in directory contrib/ . - -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . - -A Perl interface to zlib written by Paul Marquess is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . - -A Python interface to zlib written by A.M. Kuchling is -available in Python 1.5 and later versions, see -http://docs.python.org/library/zlib.html . - -zlib is built into tcl: http://wiki.tcl.tk/4610 . - -An experimental package to read and write files in .zip format, written on top -of zlib by Gilles Vollant , is available in the -contrib/minizip directory of zlib. - - -Notes for some targets: - -- For Windows DLL versions, please see win32/DLL_FAQ.txt - -- For 64-bit Irix, deflate.c must be compiled without any optimization. With - -O, one libpng test fails. The test works in 32 bit mode (with the -n32 - compiler flag). The compiler bug has been reported to SGI. - -- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works - when compiled with cc. - -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is - necessary to get gzprintf working correctly. This is done by configure. - -- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with - other compilers. Use "make test" to check your compiler. - -- gzdopen is not supported on RISCOS or BEOS. - -- For PalmOs, see http://palmzlib.sourceforge.net/ - - -Acknowledgments: - - The deflate format used by zlib was defined by Phil Katz. The deflate and - zlib specifications were written by L. Peter Deutsch. Thanks to all the - people who reported problems and suggested various improvements in zlib; they - are too numerous to cite here. - -Copyright notice: - - (C) 1995-2017 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - -If you use the zlib library in a product, we would appreciate *not* receiving -lengthy legal documents to sign. The sources are provided for free but without -warranty of any kind. The library has been entirely written by Jean-loup -Gailly and Mark Adler; it does not include third-party code. - -If you redistribute modified sources, we would appreciate that you include in -the file ChangeLog history information documenting your changes. Please read -the FAQ for more information on the distribution of modified source versions. diff --git a/Source/Libraries/zlib/adler32.c b/Source/Libraries/zlib/adler32.c deleted file mode 100644 index d0be438..0000000 --- a/Source/Libraries/zlib/adler32.c +++ /dev/null @@ -1,186 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2011, 2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" - -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); - -#define BASE 65521U /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware -- - try it both ways to see which is faster */ -#ifdef NO_DIVIDE -/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 - (thank you to John Reiser for pointing this out) */ -# define CHOP(a) \ - do { \ - unsigned long tmp = a >> 16; \ - a &= 0xffffUL; \ - a += (tmp << 4) - tmp; \ - } while (0) -# define MOD28(a) \ - do { \ - CHOP(a); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD(a) \ - do { \ - CHOP(a); \ - MOD28(a); \ - } while (0) -# define MOD63(a) \ - do { /* this assumes a is not negative */ \ - z_off64_t tmp = a >> 32; \ - a &= 0xffffffffL; \ - a += (tmp << 8) - (tmp << 5) + tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD28(a) a %= BASE -# define MOD63(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32_z(adler, buf, len) - uLong adler; - const Bytef *buf; - z_size_t len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD28(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - return adler32_z(adler, buf, len); -} - -/* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* for negative len, return invalid adler32 as a clue for debugging */ - if (len2 < 0) - return 0xffffffffUL; - - /* the derivation of this formula is left as an exercise for the reader */ - MOD63(len2); /* assumes len2 >= 0 */ - rem = (unsigned)len2; - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 >= BASE) sum1 -= BASE; - if (sum1 >= BASE) sum1 -= BASE; - if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); - if (sum2 >= BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} - -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} diff --git a/Source/Libraries/zlib/compress.c b/Source/Libraries/zlib/compress.c deleted file mode 100644 index e2db404..0000000 --- a/Source/Libraries/zlib/compress.c +++ /dev/null @@ -1,86 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ - z_stream stream; - int err; - const uInt max = (uInt)-1; - uLong left; - - left = *destLen; - *destLen = 0; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = deflateInit(&stream, level); - if (err != Z_OK) return err; - - stream.next_out = dest; - stream.avail_out = 0; - stream.next_in = (z_const Bytef *)source; - stream.avail_in = 0; - - do { - if (stream.avail_out == 0) { - stream.avail_out = left > (uLong)max ? max : (uInt)left; - left -= stream.avail_out; - } - if (stream.avail_in == 0) { - stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; - sourceLen -= stream.avail_in; - } - err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); - } while (err == Z_OK); - - *destLen = stream.total_out; - deflateEnd(&stream); - return err == Z_STREAM_END ? Z_OK : err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} - -/* =========================================================================== - If the default memLevel or windowBits for deflateInit() is changed, then - this function needs to be updated. - */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13; -} diff --git a/Source/Libraries/zlib/crc32.c b/Source/Libraries/zlib/crc32.c deleted file mode 100644 index 9580440..0000000 --- a/Source/Libraries/zlib/crc32.c +++ /dev/null @@ -1,442 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -/* @(#) $Id$ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - - DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. - */ - -#ifdef MAKECRCH -# include -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for STDC and FAR definitions */ - -/* Definitions for doing the crc four data bytes at a time. */ -#if !defined(NOBYFOUR) && defined(Z_U4) -# define BYFOUR -#endif -#ifdef BYFOUR - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, z_size_t)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, z_size_t)); -# define TBLS 8 -#else -# define TBLS 1 -#endif /* BYFOUR */ - -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); -local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); - - -#ifdef DYNAMIC_CRC_TABLE - -local volatile int crc_table_empty = 1; -local z_crc_t FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); -#ifdef MAKECRCH - local void write_table OF((FILE *, const z_crc_t FAR *)); -#endif /* MAKECRCH */ -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - z_crc_t c; - int n, k; - z_crc_t poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0; - for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) - poly |= (z_crc_t)1 << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (z_crc_t)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = ZSWAP32(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = ZSWAP32(c); - } - } -#endif /* BYFOUR */ - - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; - } - -#ifdef MAKECRCH - /* write out CRC tables to crc32.h */ - { - FILE *out; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const z_crc_t FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); - } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const z_crc_t FAR *table; -{ - int n; - - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", - (unsigned long)(table[n]), - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} -#endif /* MAKECRCH */ - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const z_crc_t FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - return (const z_crc_t FAR *)crc_table; -} - -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -/* ========================================================================= */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - if (buf == Z_NULL) return 0UL; - -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - z_crc_t endian; - - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); - } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; - } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ - return crc32_z(crc, buf, len); -} - -#ifdef BYFOUR - -/* - This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit - integer pointer type. This violates the strict aliasing rule, where a - compiler can assume, for optimization purposes, that two pointers to - fundamentally different types won't ever point to the same memory. This can - manifest as a problem only if one of the pointers is written to. This code - only reads from those pointers. So long as this code remains isolated in - this compilation unit, there won't be a problem. For this reason, this code - should not be copied and pasted into a compilation unit in which other code - writes to the buffer that is passed to these routines. - */ - -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 - -/* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - register z_crc_t c; - register const z_crc_t FAR *buf4; - - c = (z_crc_t)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } - - buf4 = (const z_crc_t FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} - -/* ========================================================================= */ -#define DOBIG4 c ^= *buf4++; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 - -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - register z_crc_t c; - register const z_crc_t FAR *buf4; - - c = ZSWAP32((z_crc_t)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; - } - - buf4 = (const z_crc_t FAR *)(const void FAR *)buf; - while (len >= 32) { - DOBIG32; - len -= 32; - } - while (len >= 4) { - DOBIG4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(ZSWAP32(c)); -} - -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - -/* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - -/* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= */ -local uLong crc32_combine_(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case (also disallow negative lengths) */ - if (len2 <= 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } - - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - return crc32_combine_(crc1, crc2, len2); -} - -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - return crc32_combine_(crc1, crc2, len2); -} diff --git a/Source/Libraries/zlib/deflate.c b/Source/Libraries/zlib/deflate.c deleted file mode 100644 index 1ec7614..0000000 --- a/Source/Libraries/zlib/deflate.c +++ /dev/null @@ -1,2163 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://tools.ietf.org/html/rfc1951 - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id$ */ - -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local int deflateStateCheck OF((z_streamp strm)); -local void slide_hash OF((deflate_state *s)); -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -#ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifdef ASMV -# pragma message("Assembler code may have bugs -- use at your own risk") - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif - -#ifdef ZLIB_DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -#ifdef FASTEST -local const config configuration_table[2] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ -#else -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ -#endif - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ -#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to UPDATE_HASH are made with consecutive input - * characters, so that a running hash key can be computed from the previous - * key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to INSERT_STRING are made with consecutive input - * characters and the first MIN_MATCH bytes of str are valid (except for - * the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* =========================================================================== - * Slide the hash table when sliding the window down (could be avoided with 32 - * bit values at the expense of memory usage). We slide even when level == 0 to - * keep the hash table consistent if we switch back to level > 0 later. - */ -local void slide_hash(s) - deflate_state *s; -{ - unsigned n, m; - Posf *p; - uInt wsize = s->w_size; - - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m - wsize : NIL); - } while (--n); - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m - wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif -} - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - s->status = INIT_STATE; /* to pass state test in deflateReset() */ - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = (uInt)windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = (uInt)memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->high_water = 0; /* nothing written to s->window yet */ - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= - * Check for a valid deflate stream state. Return 0 if ok, 1 if not. - */ -local int deflateStateCheck (strm) - z_streamp strm; -{ - deflate_state *s; - if (strm == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) - return 1; - s = strm->state; - if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE && -#ifdef GZIP - s->status != GZIP_STATE && -#endif - s->status != EXTRA_STATE && - s->status != NAME_STATE && - s->status != COMMENT_STATE && - s->status != HCRC_STATE && - s->status != BUSY_STATE && - s->status != FINISH_STATE)) - return 1; - return 0; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt str, n; - int wrap; - unsigned avail; - z_const unsigned char *next; - - if (deflateStateCheck(strm) || dictionary == Z_NULL) - return Z_STREAM_ERROR; - s = strm->state; - wrap = s->wrap; - if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) - return Z_STREAM_ERROR; - - /* when using zlib wrappers, compute Adler-32 for provided dictionary */ - if (wrap == 1) - strm->adler = adler32(strm->adler, dictionary, dictLength); - s->wrap = 0; /* avoid computing Adler-32 in read_buf */ - - /* if dictionary would fill window, just replace the history */ - if (dictLength >= s->w_size) { - if (wrap == 0) { /* already empty otherwise */ - CLEAR_HASH(s); - s->strstart = 0; - s->block_start = 0L; - s->insert = 0; - } - dictionary += dictLength - s->w_size; /* use the tail */ - dictLength = s->w_size; - } - - /* insert dictionary into window and hash */ - avail = strm->avail_in; - next = strm->next_in; - strm->avail_in = dictLength; - strm->next_in = (z_const Bytef *)dictionary; - fill_window(s); - while (s->lookahead >= MIN_MATCH) { - str = s->strstart; - n = s->lookahead - (MIN_MATCH-1); - do { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - } while (--n); - s->strstart = str; - s->lookahead = MIN_MATCH-1; - fill_window(s); - } - s->strstart += s->lookahead; - s->block_start = (long)s->strstart; - s->insert = s->lookahead; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - strm->next_in = next; - strm->avail_in = avail; - s->wrap = wrap; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) - z_streamp strm; - Bytef *dictionary; - uInt *dictLength; -{ - deflate_state *s; - uInt len; - - if (deflateStateCheck(strm)) - return Z_STREAM_ERROR; - s = strm->state; - len = s->strstart + s->lookahead; - if (len > s->w_size) - len = s->w_size; - if (dictionary != Z_NULL && len) - zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len); - if (dictLength != Z_NULL) - *dictLength = len; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateResetKeep (strm) - z_streamp strm; -{ - deflate_state *s; - - if (deflateStateCheck(strm)) { - return Z_STREAM_ERROR; - } - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->wrap < 0) { - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - } - s->status = -#ifdef GZIP - s->wrap == 2 ? GZIP_STATE : -#endif - s->wrap ? INIT_STATE : BUSY_STATE; - strm->adler = -#ifdef GZIP - s->wrap == 2 ? crc32(0L, Z_NULL, 0) : -#endif - adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - int ret; - - ret = deflateResetKeep(strm); - if (ret == Z_OK) - lm_init(strm->state); - return ret; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ - if (deflateStateCheck(strm) || strm->state->wrap != 2) - return Z_STREAM_ERROR; - strm->state->gzhead = head; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePending (strm, pending, bits) - unsigned *pending; - int *bits; - z_streamp strm; -{ - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - if (pending != Z_NULL) - *pending = strm->state->pending; - if (bits != Z_NULL) - *bits = strm->state->bi_valid; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ - deflate_state *s; - int put; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - s = strm->state; - if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) - return Z_BUF_ERROR; - do { - put = Buf_size - s->bi_valid; - if (put > bits) - put = bits; - s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); - s->bi_valid += put; - _tr_flush_bits(s); - value >>= put; - bits -= put; - } while (bits); - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - s = strm->state; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if ((strategy != s->strategy || func != configuration_table[level].func) && - s->high_water) { - /* Flush the last buffer: */ - int err = deflate(strm, Z_BLOCK); - if (err == Z_STREAM_ERROR) - return err; - if (strm->avail_out == 0) - return Z_BUF_ERROR; - } - if (s->level != level) { - if (s->level == 0 && s->matches != 0) { - if (s->matches == 1) - slide_hash(s); - else - CLEAR_HASH(s); - s->matches = 0; - } - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ - deflate_state *s; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - s = strm->state; - s->good_match = (uInt)good_length; - s->max_lazy_match = (uInt)max_lazy; - s->nice_match = nice_length; - s->max_chain_length = (uInt)max_chain; - return Z_OK; -} - -/* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. - * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. - * - * This function could be more sophisticated to provide closer upper bounds for - * every combination of windowBits and memLevel. But even the conservative - * upper bound of about 14% expansion does not seem onerous for output buffer - * allocation. - */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ - deflate_state *s; - uLong complen, wraplen; - - /* conservative upper bound for compressed data */ - complen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; - - /* if can't get parameters, return conservative bound plus zlib wrapper */ - if (deflateStateCheck(strm)) - return complen + 6; - - /* compute wrapper length */ - s = strm->state; - switch (s->wrap) { - case 0: /* raw deflate */ - wraplen = 0; - break; - case 1: /* zlib wrapper */ - wraplen = 6 + (s->strstart ? 4 : 0); - break; -#ifdef GZIP - case 2: /* gzip wrapper */ - wraplen = 18; - if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ - Bytef *str; - if (s->gzhead->extra != Z_NULL) - wraplen += 2 + s->gzhead->extra_len; - str = s->gzhead->name; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - str = s->gzhead->comment; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - if (s->gzhead->hcrc) - wraplen += 2; - } - break; -#endif - default: /* for compiler happiness */ - wraplen = 6; - } - - /* if not default parameters, return conservative bound */ - if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return complen + wraplen; - - /* default settings: return tight bound for that case */ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13 - 6 + wraplen; -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output, except for - * some deflate_stored() output, goes through this function so some - * applications may wish to modify it to avoid allocating a large - * strm->next_out buffer and copying into it. (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len; - deflate_state *s = strm->state; - - _tr_flush_bits(s); - len = s->pending; - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, s->pending_out, len); - strm->next_out += len; - s->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - s->pending -= len; - if (s->pending == 0) { - s->pending_out = s->pending_buf; - } -} - -/* =========================================================================== - * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1]. - */ -#define HCRC_UPDATE(beg) \ - do { \ - if (s->gzhead->hcrc && s->pending > (beg)) \ - strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ - s->pending - (beg)); \ - } while (0) - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->avail_in != 0 && strm->next_in == Z_NULL) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - old_flush = s->last_flush; - s->last_flush = flush; - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Write the header */ - if (s->status == INIT_STATE) { - /* zlib header */ - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - - /* Compression must start with an empty pending buffer */ - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } -#ifdef GZIP - if (s->status == GZIP_STATE) { - /* gzip header */ - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == Z_NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - - /* Compression must start with an empty pending buffer */ - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != Z_NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != Z_NULL) { - ulg beg = s->pending; /* start of bytes to update crc */ - uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex; - while (s->pending + left > s->pending_buf_size) { - uInt copy = s->pending_buf_size - s->pending; - zmemcpy(s->pending_buf + s->pending, - s->gzhead->extra + s->gzindex, copy); - s->pending = s->pending_buf_size; - HCRC_UPDATE(beg); - s->gzindex += copy; - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - beg = 0; - left -= copy; - } - zmemcpy(s->pending_buf + s->pending, - s->gzhead->extra + s->gzindex, left); - s->pending += left; - HCRC_UPDATE(beg); - s->gzindex = 0; - } - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != Z_NULL) { - ulg beg = s->pending; /* start of bytes to update crc */ - int val; - do { - if (s->pending == s->pending_buf_size) { - HCRC_UPDATE(beg); - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - beg = 0; - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - HCRC_UPDATE(beg); - s->gzindex = 0; - } - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != Z_NULL) { - ulg beg = s->pending; /* start of bytes to update crc */ - int val; - do { - if (s->pending == s->pending_buf_size) { - HCRC_UPDATE(beg); - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - beg = 0; - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - HCRC_UPDATE(beg); - } - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) { - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - } - s->status = BUSY_STATE; - - /* Compression must start with an empty pending buffer */ - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } -#endif - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = s->level == 0 ? deflate_stored(s, flush) : - s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : - s->strategy == Z_RLE ? deflate_rle(s, flush) : - (*(configuration_table[s->level].func))(s, flush); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - if (s->lookahead == 0) { - s->strstart = 0; - s->block_start = 0L; - s->insert = 0; - } - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - - status = strm->state->status; - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - - if (deflateStateCheck(source) || dest == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif /* MAXSEG_64K */ -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local unsigned read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - zmemcpy(buf, strm->next_in, len); - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, buf, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, buf, len); - } -#endif - strm->next_in += len; - strm->total_in += len; - - return len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->insert = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - -#ifndef FASTEST -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = (int)s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} -#endif /* ASMV */ - -#else /* FASTEST */ - -/* --------------------------------------------------------------------------- - * Optimized version for FASTEST only - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; -} - -#endif /* FASTEST */ - -#ifdef ZLIB_DEBUG - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif /* ZLIB_DEBUG */ - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - unsigned n; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - slide_hash(s); - more += wsize; - } - if (s->strm->avail_in == 0) break; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead + s->insert >= MIN_MATCH) { - uInt str = s->strstart - s->insert; - s->ins_h = s->window[str]; - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - while (s->insert) { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - s->insert--; - if (s->lookahead + s->insert < MIN_MATCH) - break; - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } - - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - "not enough room for search"); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, last) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (last)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, last) { \ - FLUSH_BLOCK_ONLY(s, last); \ - if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ -} - -/* Maximum stored block length in deflate format (not including header). */ -#define MAX_STORED 65535 - -/* Minimum of a and b. */ -#define MIN(a, b) ((a) > (b) ? (b) : (a)) - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * - * In case deflateParams() is used to later switch to a non-zero compression - * level, s->matches (otherwise unused when storing) keeps track of the number - * of hash table slides to perform. If s->matches is 1, then one hash table - * slide will be done when switching. If s->matches is 2, the maximum value - * allowed here, then the hash table will be cleared, since two or more slides - * is the same as a clear. - * - * deflate_stored() is written to minimize the number of times an input byte is - * copied. It is most efficient with large input and output buffers, which - * maximizes the opportunites to have a single copy from next_in to next_out. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Smallest worthy block size when not flushing or finishing. By default - * this is 32K. This can be as small as 507 bytes for memLevel == 1. For - * large input and output buffers, the stored block size will be larger. - */ - unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); - - /* Copy as many min_block or larger stored blocks directly to next_out as - * possible. If flushing, copy the remaining available input to next_out as - * stored blocks, if there is enough space. - */ - unsigned len, left, have, last = 0; - unsigned used = s->strm->avail_in; - do { - /* Set len to the maximum size block that we can copy directly with the - * available input data and output space. Set left to how much of that - * would be copied from what's left in the window. - */ - len = MAX_STORED; /* maximum deflate stored block length */ - have = (s->bi_valid + 42) >> 3; /* number of header bytes */ - if (s->strm->avail_out < have) /* need room for header */ - break; - /* maximum stored block length that will fit in avail_out: */ - have = s->strm->avail_out - have; - left = s->strstart - s->block_start; /* bytes left in window */ - if (len > (ulg)left + s->strm->avail_in) - len = left + s->strm->avail_in; /* limit len to the input */ - if (len > have) - len = have; /* limit len to the output */ - - /* If the stored block would be less than min_block in length, or if - * unable to copy all of the available input when flushing, then try - * copying to the window and the pending buffer instead. Also don't - * write an empty block when flushing -- deflate() does that. - */ - if (len < min_block && ((len == 0 && flush != Z_FINISH) || - flush == Z_NO_FLUSH || - len != left + s->strm->avail_in)) - break; - - /* Make a dummy stored block in pending to get the header bytes, - * including any pending bits. This also updates the debugging counts. - */ - last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; - _tr_stored_block(s, (char *)0, 0L, last); - - /* Replace the lengths in the dummy stored block with len. */ - s->pending_buf[s->pending - 4] = len; - s->pending_buf[s->pending - 3] = len >> 8; - s->pending_buf[s->pending - 2] = ~len; - s->pending_buf[s->pending - 1] = ~len >> 8; - - /* Write the stored block header bytes. */ - flush_pending(s->strm); - -#ifdef ZLIB_DEBUG - /* Update debugging counts for the data about to be copied. */ - s->compressed_len += len << 3; - s->bits_sent += len << 3; -#endif - - /* Copy uncompressed bytes from the window to next_out. */ - if (left) { - if (left > len) - left = len; - zmemcpy(s->strm->next_out, s->window + s->block_start, left); - s->strm->next_out += left; - s->strm->avail_out -= left; - s->strm->total_out += left; - s->block_start += left; - len -= left; - } - - /* Copy uncompressed bytes directly from next_in to next_out, updating - * the check value. - */ - if (len) { - read_buf(s->strm, s->strm->next_out, len); - s->strm->next_out += len; - s->strm->avail_out -= len; - s->strm->total_out += len; - } - } while (last == 0); - - /* Update the sliding window with the last s->w_size bytes of the copied - * data, or append all of the copied data to the existing window if less - * than s->w_size bytes were copied. Also update the number of bytes to - * insert in the hash tables, in the event that deflateParams() switches to - * a non-zero compression level. - */ - used -= s->strm->avail_in; /* number of input bytes directly copied */ - if (used) { - /* If any input was used, then no unused input remains in the window, - * therefore s->block_start == s->strstart. - */ - if (used >= s->w_size) { /* supplant the previous history */ - s->matches = 2; /* clear hash */ - zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size); - s->strstart = s->w_size; - } - else { - if (s->window_size - s->strstart <= used) { - /* Slide the window down. */ - s->strstart -= s->w_size; - zmemcpy(s->window, s->window + s->w_size, s->strstart); - if (s->matches < 2) - s->matches++; /* add a pending slide_hash() */ - } - zmemcpy(s->window + s->strstart, s->strm->next_in - used, used); - s->strstart += used; - } - s->block_start = s->strstart; - s->insert += MIN(used, s->w_size - s->insert); - } - if (s->high_water < s->strstart) - s->high_water = s->strstart; - - /* If the last block was written to next_out, then done. */ - if (last) - return finish_done; - - /* If flushing and all input has been consumed, then done. */ - if (flush != Z_NO_FLUSH && flush != Z_FINISH && - s->strm->avail_in == 0 && (long)s->strstart == s->block_start) - return block_done; - - /* Fill the window with any remaining input. */ - have = s->window_size - s->strstart - 1; - if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { - /* Slide the window down. */ - s->block_start -= s->w_size; - s->strstart -= s->w_size; - zmemcpy(s->window, s->window + s->w_size, s->strstart); - if (s->matches < 2) - s->matches++; /* add a pending slide_hash() */ - have += s->w_size; /* more space now */ - } - if (have > s->strm->avail_in) - have = s->strm->avail_in; - if (have) { - read_buf(s->strm, s->window + s->strstart, have); - s->strstart += have; - } - if (s->high_water < s->strstart) - s->high_water = s->strstart; - - /* There was not enough avail_out to write a complete worthy or flushed - * stored block to next_out. Write a stored block to pending instead, if we - * have enough input for a worthy block, or if flushing and there is enough - * room for the remaining input as a stored block in the pending buffer. - */ - have = (s->bi_valid + 42) >> 3; /* number of header bytes */ - /* maximum stored block length that will fit in pending: */ - have = MIN(s->pending_buf_size - have, MAX_STORED); - min_block = MIN(have, s->w_size); - left = s->strstart - s->block_start; - if (left >= min_block || - ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && - s->strm->avail_in == 0 && left <= have)) { - len = MIN(left, have); - last = flush == Z_FINISH && s->strm->avail_in == 0 && - len == left ? 1 : 0; - _tr_stored_block(s, (charf *)s->window + s->block_start, len, last); - s->block_start += len; - flush_pending(s->strm); - } - - /* We've done all we can with the available input and output. */ - return last ? finish_started : need_more; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} - -#ifndef FASTEST -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED -#if TOO_FAR <= 32767 - || (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR) -#endif - )) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} -#endif /* FASTEST */ - -/* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - uInt prev; /* byte at distance one to match */ - Bytef *scan, *strend; /* scan goes up to strend for length of run */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest run, plus one for the unrolled loop. - */ - if (s->lookahead <= MAX_MATCH) { - fill_window(s); - if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - s->match_length = 0; - if (s->lookahead >= MIN_MATCH && s->strstart > 0) { - scan = s->window + s->strstart - 1; - prev = *scan; - if (prev == *++scan && prev == *++scan && prev == *++scan) { - strend = s->window + s->strstart + MAX_MATCH; - do { - } while (prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - scan < strend); - s->match_length = MAX_MATCH - (uInt)(strend - scan); - if (s->match_length > s->lookahead) - s->match_length = s->lookahead; - } - Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, s->match_length); - - _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - s->strstart += s->match_length; - s->match_length = 0; - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} - -/* =========================================================================== - * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. - * (It will be regenerated if this run of deflate switches away from Huffman.) - */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we have a literal to write. */ - if (s->lookahead == 0) { - fill_window(s); - if (s->lookahead == 0) { - if (flush == Z_NO_FLUSH) - return need_more; - break; /* flush the current block */ - } - } - - /* Output a literal byte */ - s->match_length = 0; - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->last_lit) - FLUSH_BLOCK(s, 0); - return block_done; -} diff --git a/Source/Libraries/zlib/infback.c b/Source/Libraries/zlib/infback.c deleted file mode 100644 index 59679ec..0000000 --- a/Source/Libraries/zlib/infback.c +++ /dev/null @@ -1,640 +0,0 @@ -/* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - This code is largely copied from inflate.c. Normally either infback.o or - inflate.o would be linked into an application--not both. The interface - with inffast.c is retained so that optimized assembler-coded versions of - inflate_fast() can be used with either inflate.c or infback.c. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - windowBits is in the range 8..15, and window is a user-supplied - window and output buffer that is 2**windowBits bytes. - */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL || - windowBits < 8 || windowBits > 15) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->dmax = 32768U; - state->wbits = (uInt)windowBits; - state->wsize = 1U << windowBits; - state->window = window; - state->wnext = 0; - state->whave = 0; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -/* Macros for inflateBack(): */ - -/* Load returned state from inflate_fast() */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Set state from registers for inflate_fast() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = state->window; \ - left = state->wsize; \ - state->whave = left; \ - if (out(out_desc, put, left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - state->mode = TYPE; - state->last = 0; - state->whave = 0; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = state->window; - left = state->wsize; - - /* Inflate until end of block marked as last */ - for (;;) - switch (state->mode) { - case TYPE: - /* determine and dispatch block type */ - if (state->last) { - BYTEBITS(); - state->mode = DONE; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - - /* copy stored block from input to output */ - while (state->length != 0) { - copy = state->length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - state->mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= 6 && left >= 258) { - RESTORE(); - if (state->whave < state->wsize) - state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); - LOAD(); - break; - } - - /* get a literal, length, or end-of-block code */ - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - state->length = (unsigned)here.val; - - /* process literal */ - if (here.op == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - ROOM(); - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - } - - /* process end of block */ - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - - /* invalid code */ - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - state->extra = (unsigned)(here.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - - /* get distance code */ - for (;;) { - here = state->distcode[BITS(state->distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)here.val; - - /* get distance extra bits, if any */ - state->extra = (unsigned)(here.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->wsize - (state->whave < state->wsize ? - left : 0)) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = state->wsize - state->offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - state->offset; - copy = left; - } - if (copy > state->length) copy = state->length; - state->length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (state->length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/Source/Libraries/zlib/inffast.c b/Source/Libraries/zlib/inffast.c deleted file mode 100644 index 0dbd1db..0000000 --- a/Source/Libraries/zlib/inffast.c +++ /dev/null @@ -1,323 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2017 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef ASMINF -# pragma message("Assembler code may have bugs -- use at your own risk") -#else - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *in; /* local strm->next_in */ - z_const unsigned char FAR *last; /* have enough input while in < last */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code here; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in; - last = in + (strm->avail_in - 5); - out = strm->next_out; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - wnext = state->wnext; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - here = lcode[hold & lmask]; - dolen: - op = (unsigned)(here.bits); - hold >>= op; - bits -= op; - op = (unsigned)(here.op); - if (op == 0) { /* literal */ - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - *out++ = (unsigned char)(here.val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(here.val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - here = dcode[hold & dmask]; - dodist: - op = (unsigned)(here.bits); - hold >>= op; - bits -= op; - op = (unsigned)(here.op); - if (op & 16) { /* distance base */ - dist = (unsigned)(here.val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - if (state->sane) { - strm->msg = - (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - if (len <= op - whave) { - do { - *out++ = 0; - } while (--len); - continue; - } - len -= op - whave; - do { - *out++ = 0; - } while (--op > whave); - if (op == 0) { - from = out - dist; - do { - *out++ = *from++; - } while (--len); - continue; - } -#endif - } - from = window; - if (wnext == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - *out++ = *from++; - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (wnext < op) { /* wrap around window */ - from += wsize + wnext - op; - op -= wnext; - if (op < len) { /* some from end of window */ - len -= op; - do { - *out++ = *from++; - } while (--op); - from = window; - if (wnext < len) { /* some from start of window */ - op = wnext; - len -= op; - do { - *out++ = *from++; - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += wnext - op; - if (op < len) { /* some from window */ - len -= op; - do { - *out++ = *from++; - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - *out++ = *from++; - *out++ = *from++; - *out++ = *from++; - len -= 3; - } - if (len) { - *out++ = *from++; - if (len > 1) - *out++ = *from++; - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - *out++ = *from++; - *out++ = *from++; - *out++ = *from++; - len -= 3; - } while (len > 2); - if (len) { - *out++ = *from++; - if (len > 1) - *out++ = *from++; - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - here = dcode[here.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - here = lcode[here.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in; - strm->next_out = out; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and wnext == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/Source/Libraries/zlib/inflate.c b/Source/Libraries/zlib/inflate.c deleted file mode 100644 index ac333e8..0000000 --- a/Source/Libraries/zlib/inflate.c +++ /dev/null @@ -1,1561 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common wnext == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local int inflateStateCheck OF((z_streamp strm)); -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, - unsigned copy)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, - unsigned len)); - -local int inflateStateCheck(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) - return 1; - state = (struct inflate_state FAR *)strm->state; - if (state == Z_NULL || state->strm != strm || - state->mode < HEAD || state->mode > SYNC) - return 1; - return 0; -} - -int ZEXPORT inflateResetKeep(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - if (state->wrap) /* to support ill-conceived Java test suite */ - strm->adler = state->wrap & 1; - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = Z_NULL; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - state->sane = 1; - state->back = -1; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - state->wsize = 0; - state->whave = 0; - state->wnext = 0; - return inflateResetKeep(strm); -} - -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ - int wrap; - struct inflate_state FAR *state; - - /* get the state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* extract wrap request from windowBits parameter */ - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } - else { - wrap = (windowBits >> 4) + 5; -#ifdef GUNZIP - if (windowBits < 48) - windowBits &= 15; -#endif - } - - /* set number of window bits, free window if different */ - if (windowBits && (windowBits < 8 || windowBits > 15)) - return Z_STREAM_ERROR; - if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { - ZFREE(strm, state->window); - state->window = Z_NULL; - } - - /* update state and reset the rest of it */ - state->wrap = wrap; - state->wbits = (unsigned)windowBits; - return inflateReset(strm); -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - int ret; - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->strm = strm; - state->window = Z_NULL; - state->mode = HEAD; /* to pass state test in inflateReset2() */ - ret = inflateReset2(strm, windowBits); - if (ret != Z_OK) { - ZFREE(strm, state); - strm->state = Z_NULL; - } - return ret; -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits < 0) { - state->hold = 0; - state->bits = 0; - return Z_OK; - } - if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += (unsigned)value << state->bits; - state->bits += (uInt)bits; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, - state.lencode[low].bits, state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, end, copy) -z_streamp strm; -const Bytef *end; -unsigned copy; -{ - struct inflate_state FAR *state; - unsigned dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->wnext = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - if (copy >= state->wsize) { - zmemcpy(state->window, end - state->wsize, state->wsize); - state->wnext = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->wnext; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->wnext, end - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, end - copy, copy); - state->wnext = copy; - state->whave = state->wsize; - } - else { - state->wnext += dist; - if (state->wnext == state->wsize) state->wnext = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (inflateStateCheck(strm) || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - if (state->wbits == 0) - state->wbits = 15; - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - state->flags = 0; /* expect zlib header */ - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (state->wbits == 0) - state->wbits = len; - if (len > 15 || len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = (Bytef)len; - } while (len && copy < have); - if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = (Bytef)len; - } while (len && copy < have); - if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if ((state->wrap & 4) && hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = ZSWAP32(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN_; /* decode codes */ - if (flush == Z_TREES) { - DROPBITS(2); - goto inf_leave; - } - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY_; - if (flush == Z_TREES) goto inf_leave; - case COPY_: - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (const code FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - state->mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - state->lencode = (const code FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (const code FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN_; - if (flush == Z_TREES) goto inf_leave; - case LEN_: - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - if (state->mode == TYPE) - state->back = -1; - break; - } - state->back = 0; - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - state->length = (unsigned)here.val; - if ((int)(here.op) == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - state->mode = LIT; - break; - } - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->back = -1; - state->mode = TYPE; - break; - } - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(here.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->was = state->length; - state->mode = DIST; - case DIST: - for (;;) { - here = state->distcode[BITS(state->distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)here.val; - state->extra = (unsigned)(here.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->whave) { - if (state->sane) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - Trace((stderr, "inflate.c too far\n")); - copy -= state->whave; - if (copy > state->length) copy = state->length; - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = 0; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; -#endif - } - if (copy > state->wnext) { - copy -= state->wnext; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->wnext - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if ((state->wrap & 4) && out) - strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if ((state->wrap & 4) && ( -#ifdef GUNZIP - state->flags ? hold : -#endif - ZSWAP32(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (out != strm->avail_out && state->mode < BAD && - (state->mode < CHECK || flush != Z_FINISH))) - if (updatewindow(strm, strm->next_out, out - strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if ((state->wrap & 4) && out) - strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); - strm->data_type = (int)state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0) + - (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (inflateStateCheck(strm)) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) -z_streamp strm; -Bytef *dictionary; -uInt *dictLength; -{ - struct inflate_state FAR *state; - - /* check state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* copy dictionary */ - if (state->whave && dictionary != Z_NULL) { - zmemcpy(dictionary, state->window + state->wnext, - state->whave - state->wnext); - zmemcpy(dictionary + state->whave - state->wnext, - state->window, state->wnext); - } - if (dictLength != Z_NULL) - *dictLength = state->whave; - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long dictid; - int ret; - - /* check state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary identifier */ - if (state->mode == DICT) { - dictid = adler32(0L, Z_NULL, 0); - dictid = adler32(dictid, dictionary, dictLength); - if (dictid != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window using updatewindow(), which will amend the - existing dictionary if appropriate */ - ret = updatewindow(strm, dictionary + dictLength, dictLength); - if (ret) { - state->mode = MEM; - return Z_MEM_ERROR; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -const unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (inflateStateCheck(source) || dest == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); - zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); - copy->strm = dest; - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} - -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - state->sane = !subvert; - return Z_OK; -#else - (void)subvert; - state->sane = 1; - return Z_DATA_ERROR; -#endif -} - -int ZEXPORT inflateValidate(strm, check) -z_streamp strm; -int check; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (check) - state->wrap |= 4; - else - state->wrap &= ~4; - return Z_OK; -} - -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) - return -(1L << 16); - state = (struct inflate_state FAR *)strm->state; - return (long)(((unsigned long)((long)state->back)) << 16) + - (state->mode == COPY ? state->length : - (state->mode == MATCH ? state->was - state->length : 0)); -} - -unsigned long ZEXPORT inflateCodesUsed(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (inflateStateCheck(strm)) return (unsigned long)-1; - state = (struct inflate_state FAR *)strm->state; - return (unsigned long)(state->next - state->codes); -} diff --git a/Source/Libraries/zlib/inftrees.c b/Source/Libraries/zlib/inftrees.c deleted file mode 100644 index 2ea08fc..0000000 --- a/Source/Libraries/zlib/inftrees.c +++ /dev/null @@ -1,304 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2017 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code here; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - unsigned match; /* use base and extra for symbol >= match */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)1; - here.val = (unsigned short)0; - *(*table)++ = here; /* make a table to force an error */ - *(*table)++ = here; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min < max; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked for LENS and DIST tables against - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in - the initial root table size constants. See the comments in inftrees.h - for more information. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - match = 20; - break; - case LENS: - base = lbase; - extra = lext; - match = 257; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - match = 0; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if ((type == LENS && used > ENOUGH_LENS) || - (type == DISTS && used > ENOUGH_DISTS)) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - here.bits = (unsigned char)(len - drop); - if (work[sym] + 1U < match) { - here.op = (unsigned char)0; - here.val = work[sym]; - } - else if (work[sym] >= match) { - here.op = (unsigned char)(extra[work[sym] - match]); - here.val = base[work[sym] - match]; - } - else { - here.op = (unsigned char)(32 + 64); /* end of block */ - here.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = here; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if ((type == LENS && used > ENOUGH_LENS) || - (type == DISTS && used > ENOUGH_DISTS)) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* fill in remaining table entry if code is incomplete (guaranteed to have - at most one remaining entry, since if the code is incomplete, the - maximum code length that was allowed to get this far is one bit) */ - if (huff != 0) { - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)(len - drop); - here.val = (unsigned short)0; - next[huff] = here; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/Source/Libraries/zlib/trees.c b/Source/Libraries/zlib/trees.c deleted file mode 100644 index 50cf4b4..0000000 --- a/Source/Libraries/zlib/trees.c +++ /dev/null @@ -1,1203 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2017 Jean-loup Gailly - * detect_data_type() function provided freely by Cosmin Truta, 2006 - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id$ */ - -/* #define GEN_TREES_H */ - -#include "deflate.h" - -#ifdef ZLIB_DEBUG -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local const static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local const static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local const static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, const ct_data *ltree, - const ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef ZLIB_DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* !ZLIB_DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef ZLIB_DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (ush)value << s->bi_valid; - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= (ush)value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !ZLIB_DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = (int)value;\ - s->bi_buf |= (ush)val << s->bi_valid;\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (ush)(value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* ZLIB_DEBUG */ - - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ -#ifdef NO_INIT_GLOBAL_POINTERS - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; -#endif - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef ZLIB_DEBUG -# include -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, - "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (unsigned)(bits + xbits); - if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); - } - if (overflow == 0) return; - - Tracev((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if ((unsigned) tree[m].Len != (unsigned) bits) { - Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - unsigned code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - code = (code + bl_count[bits-1]) << 1; - next_code[bits] = (ush)code; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ - bi_windup(s); /* align on byte boundary */ - put_short(s, (ush)stored_len); - put_short(s, (ush)~stored_len); - zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); - s->pending += stored_len; -#ifdef ZLIB_DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; - s->bits_sent += 2*16; - s->bits_sent += stored_len<<3; -#endif -} - -/* =========================================================================== - * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) - */ -void ZLIB_INTERNAL _tr_flush_bits(s) - deflate_state *s; -{ - bi_flush(s); -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef ZLIB_DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and write out the encoded block. - */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is binary or text */ - if (s->strm->data_type == Z_UNKNOWN) - s->strm->data_type = detect_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, last); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+last, 3); - compress_block(s, (const ct_data *)static_ltree, - (const ct_data *)static_dtree); -#ifdef ZLIB_DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+last, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (const ct_data *)s->dyn_ltree, - (const ct_data *)s->dyn_dtree); -#ifdef ZLIB_DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (last) { - bi_windup(s); -#ifdef ZLIB_DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*last)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int ZLIB_INTERNAL _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - const ct_data *ltree; /* literal tree */ - const ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= (unsigned)base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "black list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* black_mask is the bit mask of black-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long black_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("black-listed") bytes. */ - for (n = 0; n <= 31; n++, black_mask >>= 1) - if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("white-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "black-listed" or "white-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} diff --git a/Source/Libraries/zlib/uncompr.c b/Source/Libraries/zlib/uncompr.c deleted file mode 100644 index f03a1a8..0000000 --- a/Source/Libraries/zlib/uncompr.c +++ /dev/null @@ -1,93 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. *sourceLen is - the byte length of the source buffer. Upon entry, *destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, - *destLen is the size of the decompressed data and *sourceLen is the number - of source bytes consumed. Upon return, source + *sourceLen points to the - first unused input byte. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, or - Z_DATA_ERROR if the input data was corrupted, including if the input data is - an incomplete zlib stream. -*/ -int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong *sourceLen; -{ - z_stream stream; - int err; - const uInt max = (uInt)-1; - uLong len, left; - Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ - - len = *sourceLen; - if (*destLen) { - left = *destLen; - *destLen = 0; - } - else { - left = 1; - dest = buf; - } - - stream.next_in = (z_const Bytef *)source; - stream.avail_in = 0; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - stream.next_out = dest; - stream.avail_out = 0; - - do { - if (stream.avail_out == 0) { - stream.avail_out = left > (uLong)max ? max : (uInt)left; - left -= stream.avail_out; - } - if (stream.avail_in == 0) { - stream.avail_in = len > (uLong)max ? max : (uInt)len; - len -= stream.avail_in; - } - err = inflate(&stream, Z_NO_FLUSH); - } while (err == Z_OK); - - *sourceLen -= len + stream.avail_in; - if (dest != buf) - *destLen = stream.total_out; - else if (stream.total_out && err == Z_BUF_ERROR) - left = 1; - - inflateEnd(&stream); - return err == Z_STREAM_END ? Z_OK : - err == Z_NEED_DICT ? Z_DATA_ERROR : - err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : - err; -} - -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return uncompress2(dest, destLen, source, &sourceLen); -} diff --git a/Source/Libraries/zlib/zutil.c b/Source/Libraries/zlib/zutil.c deleted file mode 100644 index a76c6b0..0000000 --- a/Source/Libraries/zlib/zutil.c +++ /dev/null @@ -1,325 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2017 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" -#ifndef Z_SOLO -# include "gzguts.h" -#endif - -z_const char * const z_errmsg[10] = { - (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ - (z_const char *)"stream end", /* Z_STREAM_END 1 */ - (z_const char *)"", /* Z_OK 0 */ - (z_const char *)"file error", /* Z_ERRNO (-1) */ - (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ - (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ - (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ - (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ - (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ - (z_const char *)"" -}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch ((int)(sizeof(uInt))) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch ((int)(sizeof(uLong))) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch ((int)(sizeof(voidpf))) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch ((int)(sizeof(z_off_t))) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef ZLIB_DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef ZLIB_DEBUG -#include -# ifndef verbose -# define verbose 0 -# endif -int ZLIB_INTERNAL z_verbose = verbose; - -void ZLIB_INTERNAL z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - -#ifndef Z_SOLO - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf; - ulg bsize = (ulg)items*size; - - (void)opaque; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - int n; - - (void)opaque; - - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) -{ - (void)opaque; - return _halloc((long)items, size); -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - (void)opaque; - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - (void)opaque; - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void ZLIB_INTERNAL zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - (void)opaque; - free(ptr); -} - -#endif /* MY_ZCALLOC */ - -#endif /* !Z_SOLO */ diff --git a/Source/Model/Classes/NMR_ImplicitNodeTypes.cpp b/Source/Model/Classes/NMR_ImplicitNodeTypes.cpp new file mode 100644 index 0000000..de6fe8e --- /dev/null +++ b/Source/Model/Classes/NMR_ImplicitNodeTypes.cpp @@ -0,0 +1,553 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Classes/NMR_ImplicitNodeTypes.h" + +#include "Common/NMR_Exception.h" +#include "Model/Classes/NMR_ModelImplicitNode.h" +#include "lib3mf_interfaceexception.hpp" + +namespace NMR +{ + namespace implicit + { + + NodeType::NodeType(std::string const& name, + AllowedInputOutputs const& allowedInputOutputs) + : m_name(name), m_allowedInputOutputs(allowedInputOutputs) + { + } + + std::string const& NodeType::getName() const + { + return m_name; + } + + AllowedInputOutputs const& NodeType::getAllowedInputOutputs() const + { + return m_allowedInputOutputs; + } + + using namespace Lib3MF; + NodeTypes::NodeTypes() + { + static AllowedInputOutputs const twoParameterSameDimensions{ + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, + In{{"A", eImplicitPortType::Scalar}, + {"B", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Scalar}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::VectorToVector, + In{{"A", eImplicitPortType::Vector}, + {"B", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Vector}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::MatrixToMatrix, + In{{"A", eImplicitPortType::Matrix}, + {"B", eImplicitPortType::Matrix}}, + Out{{"result", eImplicitPortType::Matrix}}}}; + + static AllowedInputOutputs const oneParameterFunctionSameDimensions{ + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, + In{{"A", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Scalar}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::VectorToVector, + In{{"A", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Vector}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::MatrixToMatrix, + In{{"A", eImplicitPortType::Matrix}}, + Out{{"result", eImplicitPortType::Matrix}}}}; + + m_nodeTypes = NodeTypesMap{ + {eImplicitNodeType::Addition, + {"addition", twoParameterSameDimensions}}, + {eImplicitNodeType::Subtraction, + {"subtraction", twoParameterSameDimensions}}, + {eImplicitNodeType::Constant, + {"constant", + {InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, In{}, + Out{{"value", eImplicitPortType::Scalar}}}}}}, + {eImplicitNodeType::Multiplication, + {"multiplication", twoParameterSameDimensions}}, + {eImplicitNodeType::Division, + {"division", twoParameterSameDimensions}}, + {eImplicitNodeType::ConstVec, + { + "constvec", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, In{}, + Out{{"vector", eImplicitPortType::Vector}}}, + }, + }}, + {eImplicitNodeType::ConstMat, + { + "constmat", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, In{}, + Out{{"matrix", eImplicitPortType::Matrix}}}, + }, + }}, + {eImplicitNodeType::ComposeVector, + { + "composevector", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"x", eImplicitPortType::Scalar}, + {"y", eImplicitPortType::Scalar}, + {"z", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Vector}}}, + }, + }}, + {eImplicitNodeType::DecomposeVector, + { + "decomposevector", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Vector}}, + Out{{"x", eImplicitPortType::Scalar}, + {"y", eImplicitPortType::Scalar}, + {"z", eImplicitPortType::Scalar}}}, + }, + }}, + {eImplicitNodeType::ComposeMatrix, + {"composematrix", // 4x4 + {InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"m00", eImplicitPortType::Scalar}, + {"m01", eImplicitPortType::Scalar}, + {"m02", eImplicitPortType::Scalar}, + {"m03", eImplicitPortType::Scalar}, + {"m10", eImplicitPortType::Scalar}, + {"m11", eImplicitPortType::Scalar}, + {"m12", eImplicitPortType::Scalar}, + {"m13", eImplicitPortType::Scalar}, + {"m20", eImplicitPortType::Scalar}, + {"m21", eImplicitPortType::Scalar}, + {"m22", eImplicitPortType::Scalar}, + {"m23", eImplicitPortType::Scalar}, + {"m30", eImplicitPortType::Scalar}, + {"m31", eImplicitPortType::Scalar}, + {"m32", eImplicitPortType::Scalar}, + {"m33", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Matrix}}}}}}, + {eImplicitNodeType::MatrixFromColumns, + {"matrixfromcolumns", // 4x4 + {InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Vector}, + {"B", eImplicitPortType::Vector}, + {"C", eImplicitPortType::Vector}, + {"D", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Matrix}}}}}}, + {eImplicitNodeType::MatrixFromRows, + { + "matrixfromrows", // 4x4 + {InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Vector}, + {"B", eImplicitPortType::Vector}, + {"C", eImplicitPortType::Vector}, + {"D", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Matrix}}}}, + }}, + {eImplicitNodeType::Dot, + {"dot", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Vector}, + {"B", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Scalar}}}, + }}}, + {eImplicitNodeType::Cross, + {"cross", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Vector}, + {"B", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Vector}}}, + }}}, + {eImplicitNodeType::MatVecMultiplication, + {"matvecmultiplication", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Matrix}, + {"B", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Vector}}}, + }}}, + {eImplicitNodeType::Transpose, + {"transpose", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Matrix}}, + Out{{"result", eImplicitPortType::Matrix}}}, + }}}, + {eImplicitNodeType::Inverse, + {"inverse", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Matrix}}, + Out{{"result", eImplicitPortType::Matrix}}}, + }}}, + {eImplicitNodeType::Sinus, + {"sin", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Cosinus, + {"cos", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Tan, + {"tan", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::ArcSin, + {"asin", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::ArcCos, + {"acos", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::ArcTan, + {"atan", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::ArcTan2, + {"atan2", twoParameterSameDimensions}}, + {eImplicitNodeType::Min, {"min", twoParameterSameDimensions}}, + {eImplicitNodeType::Max, {"max", twoParameterSameDimensions}}, + {eImplicitNodeType::Abs, + {"abs", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Fmod, {"fmod", twoParameterSameDimensions}}, + {eImplicitNodeType::Mod, {"mod", twoParameterSameDimensions}}, + {eImplicitNodeType::Pow, {"pow", twoParameterSameDimensions}}, + {eImplicitNodeType::Sqrt, + {"sqrt", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Exp, + {"exp", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Log, + {"log", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Log2, + {"log2", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Log10, + {"log10", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Cosh, + {"cosh", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Sinh, + {"sinh", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Tanh, + {"tanh", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Round, + {"round", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Ceil, + {"ceil", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Floor, + {"floor", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Sign, + {"sign", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Fract, + {"fract", oneParameterFunctionSameDimensions}}, + {eImplicitNodeType::Select, + {"select", // result = A < B ? C : D + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, + In{{"A", eImplicitPortType::Scalar}, + {"B", eImplicitPortType::Scalar}, + {"C", eImplicitPortType::Scalar}, + {"D", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Scalar}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::VectorToVector, + In{{"A", eImplicitPortType::Vector}, + {"B", eImplicitPortType::Vector}, + {"C", eImplicitPortType::Vector}, + {"D", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Vector}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::MatrixToMatrix, + In{{"A", eImplicitPortType::Matrix}, + {"B", eImplicitPortType::Matrix}, + {"C", eImplicitPortType::Matrix}, + {"D", eImplicitPortType::Matrix}}, + Out{{"result", eImplicitPortType::Matrix}}}, + + }}}, + {eImplicitNodeType::Clamp, // result = min(max(A, min), max) + {"clamp", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::ScalarToScalar, + In{{"A", eImplicitPortType::Scalar}, + {"min", eImplicitPortType::Scalar}, + {"max", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Scalar}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::VectorToVector, + In{{"A", eImplicitPortType::Vector}, + {"min", eImplicitPortType::Vector}, + {"max", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Vector}}}, + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::MatrixToMatrix, + In{{"A", eImplicitPortType::Matrix}, + {"min", eImplicitPortType::Matrix}, + {"max", eImplicitPortType::Matrix}}, + Out{{"result", eImplicitPortType::Matrix}}}, + }}}, + {eImplicitNodeType::Length, + {"length", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Vector}}, + Out{{"result", eImplicitPortType::Scalar}}}, + }}}, + {eImplicitNodeType::VectorFromScalar, + {"vectorfromscalar", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"A", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Vector}}}, + }}}, + {eImplicitNodeType::ConstResourceID, + {"constresourceid", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, In{}, + Out{{"value", eImplicitPortType::ResourceID}}}, + }}}, + {eImplicitNodeType::Mesh, + {"mesh", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"pos", eImplicitPortType::Vector}, + {"mesh", eImplicitPortType::ResourceID}}, + Out{{"distance", eImplicitPortType::Scalar}}}, + }}}, + {eImplicitNodeType::UnsignedMesh, + {"mesh", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"pos", eImplicitPortType::Vector}, + {"mesh", eImplicitPortType::ResourceID}}, + Out{{"distance", eImplicitPortType::Scalar}}}, + }}}, + {eImplicitNodeType::BeamLattice, + {"beamlattice", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"pos", eImplicitPortType::Vector}, + {"beamlattice", eImplicitPortType::ResourceID}}, + Out{{"distance", eImplicitPortType::Scalar}}}, + }}}, + {eImplicitNodeType::FunctionGradient, + {"functiongradient", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"functionID", eImplicitPortType::ResourceID}, + {"pos", eImplicitPortType::Vector}, + {"step", eImplicitPortType::Scalar}}, + Out{{"normalizedgradient", eImplicitPortType::Vector}, + {"gradient", eImplicitPortType::Vector}, + {"magnitude", eImplicitPortType::Scalar}}}, + }}}, + {eImplicitNodeType::NormalizeDistance, + {"normalizedistance", + { + InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"functionID", eImplicitPortType::ResourceID}, + {"pos", eImplicitPortType::Vector}, + {"step", eImplicitPortType::Scalar}}, + Out{{"result", eImplicitPortType::Scalar}}}, + }}}, + {eImplicitNodeType::FunctionCall, + {"functioncall", + {InputOutputRule{ + Lib3MF::eImplicitNodeConfiguration::Default, + In{{"functionID", + eImplicitPortType::ResourceID}}, // not predefined + // besides the + // functionID + Out{} // not predefined + }}}}}; + } + + NodeType const& NodeTypes::getNodeType( + Lib3MF::eImplicitNodeType type) const + { + auto it = m_nodeTypes.find(type); + if(it == m_nodeTypes.end()) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDNODECONFIGURATION, + "Unknown node type " + + std::to_string(static_cast(type))); + } + return it->second; + } + NodeTypesMap const& NodeTypes::getTypes() const + { + return m_nodeTypes; + } + + void NodeTypes::addExpectedPortsToNode( + NMR::CModelImplicitNode& node) const + { + auto const& nodeType = getNodeType(node.getNodeType()); + + if(nodeType.getAllowedInputOutputs().empty()) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDNODECONFIGURATION, + "No known configuration for node type " + + std::to_string(static_cast(node.getNodeType()))); + } + applyInputOutputRuleToNode( + node, nodeType.getAllowedInputOutputs().front()); + } + + void NodeTypes::addExpectedPortsToNode( + NMR::CModelImplicitNode& node, + Lib3MF::eImplicitNodeConfiguration const configuration) const + { + if(configuration == Lib3MF::eImplicitNodeConfiguration::Default) + { + addExpectedPortsToNode(node); + return; + } + + auto const& nodeType = getNodeType(node.getNodeType()); + if(nodeType.getAllowedInputOutputs().empty()) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDNODECONFIGURATION, + "No known configuration for node type " + + std::to_string(static_cast(node.getNodeType()))); + } + + if((nodeType.getAllowedInputOutputs().size() == 1u) && + configuration != Lib3MF::eImplicitNodeConfiguration::Default) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDNODECONFIGURATION, + "Node type: " + + std::to_string(static_cast(node.getNodeType())) + + " only supports the default configuration"); + } + + for(auto const& rule : nodeType.getAllowedInputOutputs()) + { + if(rule.configuration == configuration) + { + applyInputOutputRuleToNode(node, rule); + return; + } + } + + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDNODECONFIGURATION, + "Node type: " + + std::to_string(static_cast(node.getNodeType())) + + " does not support configuration: " + + std::to_string(static_cast(configuration))); + } + + void NodeTypes::applyInputOutputRuleToNode( + NMR::CModelImplicitNode& node, InputOutputRule const& rule) const + { + for(auto const& input : rule.inputs) + { + auto inPort = node.addInput(input.first, input.first); + inPort->setType(input.second); + } + for(auto const& output : rule.outputs) + { + auto outPort = node.addOutput(output.first, output.first); + outPort->setType(output.second); + } + } + + bool NodeTypes::arePortsValidForNode( + NMR::CModelImplicitNode const& node) const + { + auto const& nodeType = getNodeType(node.getNodeType()); + for(auto const& rule : nodeType.getAllowedInputOutputs()) + { + if(arePortsValidForRule(node, rule)) + { + return true; + } + } + return false; + } + + bool NodeTypes::arePortsValidForRule( + NMR::CModelImplicitNode const& node, + InputOutputRule const& rule) const + { + for(auto const& input : rule.inputs) + { + auto inPort = node.findInput(input.first); + if(inPort == nullptr) + { + return false; + } + if(inPort->getType() != input.second) + { + return false; + } + } + + for(auto const& output : rule.outputs) + { + auto outPort = node.findOutput(output.first); + if(outPort == nullptr) + { + return false; + } + if(outPort->getType() != output.second) + { + return false; + } + } + + return true; + } + + } // namespace implicit + +} // namespace NMR diff --git a/Source/Model/Classes/NMR_Model.cpp b/Source/Model/Classes/NMR_Model.cpp index 3a92be9..32e58c3 100644 --- a/Source/Model/Classes/NMR_Model.cpp +++ b/Source/Model/Classes/NMR_Model.cpp @@ -45,9 +45,13 @@ A model is an in memory representation of the 3MF file. #include "Model/Classes/NMR_ModelCompositeMaterials.h" #include "Model/Classes/NMR_ModelMultiPropertyGroup.h" #include "Model/Classes/NMR_ModelTexture2D.h" +#include "Model/Classes/NMR_ModelImage3D.h" +#include "Model/Classes/NMR_ModelImageStack.h" #include "Model/Classes/NMR_ModelSliceStack.h" #include "Model/Classes/NMR_ModelMetaDataGroup.h" #include "Model/Classes/NMR_KeyStore.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Classes/NMR_ModelFunctionFromImage3D.h" #include "Common/Mesh/NMR_Mesh.h" #include "Common/MeshInformation/NMR_MeshInformation.h" @@ -278,6 +282,11 @@ namespace NMR { m_ResourceMap.insert(std::make_pair(nID, pResource)); m_Resources.push_back(pResource); + const ModelResourceID currentModelResourceId = pResource->getPackageResourceID()->getModelResourceID(); + if(currentModelResourceId > m_MaxResourceId) { + m_MaxResourceId = currentModelResourceId; + } + // Create correct lookup table addResourceToLookupTable(pResource); } @@ -391,19 +400,34 @@ namespace NMR { } } - // Retrieve a unique Resource ID ModelResourceID CModel::generateResourceID() { - // TODO: is this truly safe? - auto iIterator = m_ResourceMap.rbegin(); - if (iIterator != m_ResourceMap.rend()) - return iIterator->first + 1; - else + if(m_ResourceMap.empty()) + { return 1; + } + + // find the lowest unoccupied ModelResourceID + std::unordered_set occupiedIDs; + for(const auto &entry : m_ResourceMap) + { + occupiedIDs.insert( + entry.second->getPackageResourceID()->getModelResourceID()); + } + + ModelResourceID newResourceID = 1; + + // Loop until we find an unoccupied resource ID + while(occupiedIDs.find(newResourceID) != occupiedIDs.end()) + { + ++newResourceID; + } + + return newResourceID; } - void CModel::updateUniqueResourceID(UniqueResourceID nOldID, UniqueResourceID nNewID) + void CModel::updateUniqueResourceID(UniqueResourceID nOldID, UniqueResourceID nNewID) { if (m_ResourceMap.find(nNewID) != m_ResourceMap.end()) { throw CNMRException(NMR_ERROR_DUPLICATEMODELRESOURCE); @@ -531,6 +555,24 @@ namespace NMR { CModelSliceStack *pSliceStack = dynamic_cast(pResource.get()); if (pSliceStack != nullptr) m_SliceStackLookup.push_back(pResource); + + CModelImage3D* pImage3d = dynamic_cast(pResource.get()); + if (pImage3d != nullptr) + m_Image3DLookup.push_back(pResource); + + + CModelImplicitFunction* pImplicitFunction = dynamic_cast(pResource.get()); + if (pImplicitFunction != nullptr) + m_FunctionLookup.push_back(pResource); + + CModelFunctionFromImage3D* pFunctionFromImage3D = dynamic_cast(pResource.get()); + if (pFunctionFromImage3D != nullptr) + m_FunctionLookup.push_back(pResource); + + CModelVolumeData* pVolumeData = dynamic_cast(pResource.get()); + if (pVolumeData != nullptr) + m_VolumeDataLookup.push_back(pResource); + } // Clear all build items and Resources @@ -549,8 +591,12 @@ namespace NMR { m_SliceStackLookup.clear(); m_CompositeMaterialsLookup.clear(); m_MultiPropertyGroupLookup.clear(); + m_Image3DLookup.clear(); m_MetaDataGroup->clear(); + + m_FunctionLookup.clear(); + m_VolumeDataLookup.clear(); } _Ret_maybenull_ PModelBaseMaterialResource CModel::findBaseMaterial(_In_ PPackageResourceID pID) @@ -917,7 +963,225 @@ namespace NMR { oldToNewMapping[pTextureResource->getPackageResourceID()->getUniqueID()] = pNewTextureResource->getPackageResourceID()->getUniqueID(); } } - + + // Convenience functions for 3D Textures + PModelImage3D CModel::findImage3D(_In_ UniqueResourceID nResourceID) + { + PModelResource pResource = findResource(nResourceID); + if (pResource != nullptr) { + PModelImage3D pImage3DResource = std::dynamic_pointer_cast(pResource); + if (pImage3DResource.get() == nullptr) + throw CNMRException(NMR_ERROR_RESOURCETYPEMISMATCH); + return pImage3DResource; + } + return nullptr; + } + + // Convenience functions for 3D Textures + PModelImageStack CModel::findImageStack(_In_ UniqueResourceID nResourceID) + { + PModelResource pResource = findResource(nResourceID); + if (pResource != nullptr) { + PModelImageStack pImageStack = std::dynamic_pointer_cast(pResource); + if (pImageStack.get() == nullptr) + throw CNMRException(NMR_ERROR_RESOURCETYPEMISMATCH); + return pImageStack; + } + return nullptr; + } + + nfUint32 CModel::getImage3DCount() + { + return (nfUint32)m_Image3DLookup.size(); + } + + PModelResource CModel::getImage3DResource(_In_ nfUint32 nIndex) + { + nfUint32 nCount = getImage3DCount(); + if (nIndex >= nCount) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return m_Image3DLookup[nIndex]; + + } + + CModelImage3D * CModel::getImage3D(_In_ nfUint32 nIndex) + { + CModelImage3D * pImage3D = dynamic_cast (getImage3DResource(nIndex).get()); + if (pImage3D == nullptr) + throw CNMRException(NMR_ERROR_RESOURCETYPEMISMATCH); + + return pImage3D; + + } + + void CModel::mergeImage3Ds(_In_ CModel * pSourceModel, _In_ UniqueResourceIDMapping& oldToNewMapping) + { + if (pSourceModel == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + nfUint32 nCount = pSourceModel->getImage3DCount(); + nfUint32 nIndex; + + for (nIndex = 0; nIndex < nCount; nIndex++) + { + CModelImage3D* pOldImage3D = pSourceModel->getImage3D(nIndex); + if (pOldImage3D == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + CModelImageStack* pOldImageStack = dynamic_cast(pOldImage3D); + if (pOldImageStack) + { + nfUint32 nSheetCount = pOldImageStack->getSheetCount();; + nfUint32 nIndex; + PModelImageStack pNewImageStack = CModelImageStack::make(generateResourceID(), this, pOldImageStack->getRowCount(), pOldImageStack->getColumnCount(), nSheetCount); + + for (nIndex = 0; nIndex < nSheetCount; nIndex++) { + PModelAttachment pSheet = pOldImageStack->getSheet(nIndex); + if (pSheet.get() != nullptr) { + PModelAttachment pNewSheet = findModelAttachment(pSheet->getPathURI()); + if (pNewSheet.get() == nullptr) + throw CNMRException(NMR_ERROR_ATTACHMENTNOTFOUND); + + pNewImageStack->setSheet(nIndex, pNewSheet); + } + } + + addResource(pNewImageStack); + + oldToNewMapping[pOldImageStack->getPackageResourceID()->getUniqueID()] = pNewImageStack->getPackageResourceID()->getUniqueID(); + } + else + { + throw CNMRException(NMR_ERROR_NOTIMPLEMENTED); + } + } + } + + void CModel::mergeFunctions(CModel *pSourceModel, + UniqueResourceIDMapping &oldToNewMapping) + { + if (pSourceModel == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + nfUint32 previousTargetFunctionCount = getFunctionCount(); + + nfUint32 nCount = pSourceModel->getFunctionCount(); + nfUint32 nIndex; + + for (nIndex = 0; nIndex < nCount; nIndex++) + { + CModelFunctionFromImage3D *pOldFunctionFromImage3D = pSourceModel->getFunctionFromImage3D(nIndex); + CModelImplicitFunction *pOldImplicitFunction = pSourceModel->getImplicitFunction(nIndex); + + if (pOldFunctionFromImage3D) + { + PModelFunctionFromImage3D pNewFunctionFromImage3D = std::make_shared(*pOldFunctionFromImage3D); + auto newPkgId = generatePackageResourceID(currentPath(), generateResourceID()); + pNewFunctionFromImage3D->setModel(nullptr); // Hack: Allows us to set the package resource ID without updating the model + pNewFunctionFromImage3D->setPackageResourceID(newPkgId); + pNewFunctionFromImage3D->setModel(this); + + + // Update the referenced image3D resource ID + auto newIdIter = oldToNewMapping.find(pOldFunctionFromImage3D->getImage3DUniqueResourceID()); + if (newIdIter != oldToNewMapping.cend()) + { + auto const newId = findPackageResourceID(newIdIter->second); + if (!newId) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } + pNewFunctionFromImage3D->setImage3DUniqueResourceID(newId->getUniqueID()); + } + else + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } + + addResource(pNewFunctionFromImage3D); + oldToNewMapping[pOldFunctionFromImage3D->getPackageResourceID()->getUniqueID()] = pNewFunctionFromImage3D->getPackageResourceID()->getUniqueID(); + } + else if (pOldImplicitFunction) + { + PModelImplicitFunction pNewImplicitFunction = std::make_shared(*pOldImplicitFunction); + + + auto newPkgId = generatePackageResourceID(currentPath(), generateResourceID()); + pNewImplicitFunction->setModel(nullptr); // Hack: Allows us to set the package resource ID without updating the model + pNewImplicitFunction->setPackageResourceID(newPkgId); + pNewImplicitFunction->setModel(this); + + for (auto &node : *pNewImplicitFunction->getNodes()) + { + node->setParent(pNewImplicitFunction.get()); + } + + addResource(pNewImplicitFunction); + oldToNewMapping[pOldImplicitFunction->getPackageResourceID()->getUniqueID()] = pNewImplicitFunction->getPackageResourceID()->getUniqueID(); + + // std::cout << "Merged implicit function (unique ids) " << pOldImplicitFunction->getPackageResourceID()->getUniqueID() << " to " << pNewImplicitFunction->getPackageResourceID()->getUniqueID() << std::endl; + + // std::cout << "Merged implicit function (model resource ids) " << pOldImplicitFunction->getPackageResourceID()->getModelResourceID() << " to " << pNewImplicitFunction->getPackageResourceID()->getModelResourceID() << std::endl; + } + else + { + throw CNMRException(NMR_ERROR_NOTIMPLEMENTED); + } + } + + nCount = getFunctionCount(); + + // loop over all newly added functions and update the references in ConstResourceID nodes + for (nIndex = previousTargetFunctionCount; nIndex < nCount; nIndex++) + { + CModelImplicitFunction * pImplicitFunction = getImplicitFunction(nIndex); + + for (auto & node : *pImplicitFunction->getNodes()) + { + if (node->getNodeType() == Lib3MF::eImplicitNodeType::ConstResourceID) + { + auto const oldId = pSourceModel->findPackageResourceID(pSourceModel->currentPath(), node->getModelResourceID()); + if (!oldId) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND, "Resource ID " + std::to_string(node->getModelResourceID()) + + " not found in source model, this might happen when the file contains forward references"); + } + + auto const newIdIter = oldToNewMapping.find(oldId->getUniqueID()); + if (newIdIter == oldToNewMapping.cend()) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND, "Resource ID " + std::to_string(oldId->getUniqueID()) + " not found in mapping"); + } + + auto const newId = findPackageResourceID(newIdIter->second); + if (!newId) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } + + node->setModelResourceID(newId->getModelResourceID()); + + + // check if the resource is available + auto res = findResource(currentPath(), newId->getModelResourceID()); + if (!res) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } + + auto resource = node->getResource(); + if (!resource) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + + } + } + } + } + + } + nfUint32 CModel::createHandle() { if (m_nHandleCounter >= NMR_MAXHANDLE) @@ -1223,7 +1487,34 @@ namespace NMR { return false; } - return false; + if(sExtension == XML_3MF_NAMESPACE_VOLUMETRICSPEC) + { + for(size_t i = 0; i < m_ObjectLookup.size(); i++) + { + CModelMeshObject *pMeshObject = + dynamic_cast( + m_ObjectLookup[i].get()); + if(pMeshObject == nullptr || + pMeshObject->getMesh() == nullptr) + continue; + + auto volumeData = pMeshObject->getVolumeData(); + if (!volumeData) + continue; + + if (volumeData->hasColor() || volumeData->getPropertyCount() > 0 || volumeData->hasComposite()) + { + return true; + } + } + } + + if (sExtension == XML_3MF_NAMESPACE_IMPLICITSPEC) + { + if (m_FunctionLookup.size() > 0) + return true; + } + return false; } nfUint32 CModel::getSliceStackCount() { @@ -1315,4 +1606,214 @@ namespace NMR { return size; } -} + ModelResourceID CModel::getMaxModelResourceID() + { + auto maxResourceID = std::max_element( + m_Resources.begin(), m_Resources.end(), + [](const PModelResource &a, const PModelResource &b) + { + return a->getPackageResourceID()->getModelResourceID() < + b->getPackageResourceID()->getModelResourceID(); + }); + if(maxResourceID == m_Resources.end()) return 0; + + return (*maxResourceID)->getPackageResourceID()->getModelResourceID(); + } + + PModelFunction CModel::findFunction(_In_ UniqueResourceID nResourceID) + { + for(size_t i = 0; i < m_FunctionLookup.size(); i++) + { + PModelFunction pFunction = + std::dynamic_pointer_cast( + m_FunctionLookup[i]); + if(pFunction->getPackageResourceID()->getUniqueID() == + nResourceID) + return pFunction; + } + return nullptr; + } + + nfUint32 CModel::getFunctionCount() { + return (nfUint32)m_FunctionLookup.size(); + } + + PModelResource CModel::getFunctionResource(_In_ nfUint32 nIndex) { + nfUint32 nCount = getFunctionCount(); + if (nIndex >= nCount) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return m_FunctionLookup[nIndex]; + } + + CModelImplicitFunction* CModel::getImplicitFunction(_In_ nfUint32 nIndex) { + PModelResource pResource = getFunctionResource(nIndex); + if (pResource.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return dynamic_cast(pResource.get()); + } + + CModelFunctionFromImage3D * CModel::getFunctionFromImage3D(nfUint32 nIndex) + { + PModelResource pResource = getFunctionResource(nIndex); + if (pResource.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return dynamic_cast(pResource.get()); + } + + PModelVolumeData CModel::findVolumeData(UniqueResourceID nResourceID) + { + for(size_t i = 0; i < m_VolumeDataLookup.size(); i++) + { + PModelVolumeData pVolumeData = + std::dynamic_pointer_cast( + m_VolumeDataLookup[i]); + if(pVolumeData->getPackageResourceID()->getUniqueID() == + nResourceID) + return pVolumeData; + } + return nullptr; + } + + nfUint32 NMR::CModel::getVolumeDataCount() + { + return (nfUint32)m_VolumeDataLookup.size(); + } + + PModelResource CModel::getVolumeDataResource(nfUint32 nIndex) + { + nfUint32 nCount = getVolumeDataCount(); + if (nIndex >= nCount) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return m_VolumeDataLookup[nIndex]; + } + + CModelVolumeData * CModel::getVolumeData(nfUint32 nIndex) + { + PModelResource pResource = getVolumeDataResource(nIndex); + if (pResource.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return dynamic_cast(pResource.get()); + } + + + void CModel::removeResource(PModelResource pResource) + { + if (pResource.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + // Remove from resource list + auto resourceIterator = std::find(m_Resources.begin(), m_Resources.end(), pResource); + if (resourceIterator == m_Resources.end()) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + + } + + m_Resources.erase(resourceIterator); + + // Remove from Resource map + auto resourceMapIterator = m_ResourceMap.find(pResource->getPackageResourceID()->getUniqueID()); + if (resourceMapIterator == m_ResourceMap.end()) + { + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } + + m_ResourceMap.erase(resourceMapIterator); + + m_resourceHandler.removePackageResourceID(pResource->getPackageResourceID()); + + // Remove from specific resource lists + + auto objectIterator = std::find(m_ObjectLookup.begin(), m_ObjectLookup.end(), pResource); + if (objectIterator != m_ObjectLookup.end()) + { + m_ObjectLookup.erase(objectIterator); + return; + } + + auto baseMaterialIterator = std::find(m_BaseMaterialLookup.begin(), m_BaseMaterialLookup.end(), pResource); + if (baseMaterialIterator != m_BaseMaterialLookup.end()) + { + m_BaseMaterialLookup.erase(baseMaterialIterator); + return; + } + + auto textureIterator = std::find(m_TextureLookup.begin(), m_TextureLookup.end(), pResource); + if (textureIterator != m_TextureLookup.end()) + { + m_TextureLookup.erase(textureIterator); + return; + } + + auto sliceStackIterator = std::find(m_SliceStackLookup.begin(), m_SliceStackLookup.end(), pResource); + if (sliceStackIterator != m_SliceStackLookup.end()) + { + m_SliceStackLookup.erase(sliceStackIterator); + return; + } + + auto colorGroupIterator = std::find(m_ColorGroupLookup.begin(), m_ColorGroupLookup.end(), pResource); + if (colorGroupIterator != m_ColorGroupLookup.end()) + { + m_ColorGroupLookup.erase(colorGroupIterator); + return; + } + + auto texture2DGroupIterator = std::find(m_Texture2DGroupLookup.begin(), m_Texture2DGroupLookup.end(), pResource); + if (texture2DGroupIterator != m_Texture2DGroupLookup.end()) + { + m_Texture2DGroupLookup.erase(texture2DGroupIterator); + return; + } + + auto compositeMaterialsIterator = std::find(m_CompositeMaterialsLookup.begin(), m_CompositeMaterialsLookup.end(), pResource); + if (compositeMaterialsIterator != m_CompositeMaterialsLookup.end()) + { + m_CompositeMaterialsLookup.erase(compositeMaterialsIterator); + return; + } + + auto multiPropertyGroupIterator = std::find(m_MultiPropertyGroupLookup.begin(), m_MultiPropertyGroupLookup.end(), pResource); + if (multiPropertyGroupIterator != m_MultiPropertyGroupLookup.end()) + { + m_MultiPropertyGroupLookup.erase(multiPropertyGroupIterator); + return; + } + + auto image3DIterator = std::find(m_Image3DLookup.begin(), m_Image3DLookup.end(), pResource); + if (image3DIterator != m_Image3DLookup.end()) + { + m_Image3DLookup.erase(image3DIterator); + return; + } + + auto functionIterator = std::find(m_FunctionLookup.begin(), m_FunctionLookup.end(), pResource); + if (functionIterator != m_FunctionLookup.end()) + { + m_FunctionLookup.erase(functionIterator); + return; + } + + auto volumeDataIterator = std::find(m_VolumeDataLookup.begin(), m_VolumeDataLookup.end(), pResource); + if (volumeDataIterator != m_VolumeDataLookup.end()) + { + m_VolumeDataLookup.erase(volumeDataIterator); + return; + } + + auto levelSetObjectIterator = std::find(m_levelSetObjectLookup.begin(), m_levelSetObjectLookup.end(), pResource); + if (levelSetObjectIterator != m_levelSetObjectLookup.end()) + { + m_levelSetObjectLookup.erase(levelSetObjectIterator); + return; + } + + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + } +} // namespace NMR + diff --git a/Source/Model/Classes/NMR_ModelAttachment.cpp b/Source/Model/Classes/NMR_ModelAttachment.cpp index 68e851d..d36f9d9 100644 --- a/Source/Model/Classes/NMR_ModelAttachment.cpp +++ b/Source/Model/Classes/NMR_ModelAttachment.cpp @@ -82,6 +82,20 @@ namespace NMR { m_sRelationShipType = sRelationShipType; } + PModelAttachment CModelAttachment::cloneIntoNewModel(_In_ CModel * pModel, _In_ nfBool bCloneMemory) + { + PImportStream pNewStream; + if (m_pStream.get() != nullptr) { + if (bCloneMemory) { + pNewStream = m_pStream->copyToMemory(); + } + else { + pNewStream = m_pStream; + } + } + + return pModel->addAttachment (m_sPathURI, m_sRelationShipType, pNewStream); + } } diff --git a/Source/Model/Classes/NMR_ModelComponentsObject.cpp b/Source/Model/Classes/NMR_ModelComponentsObject.cpp index d77b8a3..b2f71f8 100644 --- a/Source/Model/Classes/NMR_ModelComponentsObject.cpp +++ b/Source/Model/Classes/NMR_ModelComponentsObject.cpp @@ -149,8 +149,26 @@ namespace NMR { void CModelComponentsObject::extendOutbox(_Out_ NOUTBOX3& vOutBox, _In_ const NMATRIX3 mAccumulatedMatrix) { - for (auto iIterator = m_Components.begin(); iIterator != m_Components.end(); iIterator++) { - (*iIterator)->getObject()->extendOutbox(vOutBox, fnMATRIX3_multiply(mAccumulatedMatrix, (*iIterator)->getTransform())); + for(auto & component : m_Components) + { + component->getObject()->extendOutbox(vOutBox, fnMATRIX3_multiply(mAccumulatedMatrix, component->getTransform())); } } -} + + ResourceDependencies CModelComponentsObject::getDependencies() + { + ResourceDependencies dependencies; + + for(auto & component : m_Components) + { + auto objectResource = component->getObject(); + + if (objectResource) + { + dependencies.push_back(objectResource->getPackageResourceID()); + } + } + + return dependencies; + } +} // namespace NMR diff --git a/Source/Model/Classes/NMR_ModelFunction.cpp b/Source/Model/Classes/NMR_ModelFunction.cpp new file mode 100644 index 0000000..6268bef --- /dev/null +++ b/Source/Model/Classes/NMR_ModelFunction.cpp @@ -0,0 +1,112 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification,276529 +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Classes/NMR_ModelFunction.h" + +#include "Common/NMR_Exception.h" + +namespace NMR +{ + + CModelFunction::CModelFunction(const ModelResourceID sID, CModel * pModel) + : CModelResource(sID, pModel) + { + m_inputs = std::make_shared(); + m_outputs = std::make_shared(); + } + + std::string const & CModelFunction::getDisplayName() const + { + return m_displayname; + } + + void CModelFunction::setDisplayName(std::string const & displayname) + { + m_displayname = displayname; + } + + PModelImplicitPort CModelFunction::addInput(const std::string & sPortIdentifier, + const std::string & sDisplayName, + const Lib3MF::eImplicitPortType ePortType) + { + auto newPort = + std::make_shared(sPortIdentifier, sDisplayName, ePortType); + m_inputs->push_back(newPort); + return newPort; + } + + PModelImplicitPort CModelFunction::addOutput(const std::string & sPortIdentifier, + const std::string & sDisplayName, + const Lib3MF::eImplicitPortType ePortType) + { + auto newPort = + std::make_shared(sPortIdentifier, sDisplayName, ePortType); + m_outputs->push_back(newPort); + return newPort; + } + + PPorts const& CModelFunction::getInputs() const + { + return m_inputs; + } + + PPorts const& CModelFunction::getOutputs() const + { + return m_outputs; + } + + PModelImplicitPort CModelFunction::findInput(const std::string & sIdentifier) const + { + for (auto & port : *m_inputs) + { + if (port->getIdentifier() == sIdentifier) + { + return port; + } + } + return {}; + } + + PModelImplicitPort CModelFunction::findOutput(const std::string & sIdentifier) const + { + for (auto & port : *m_outputs) + { + if (port->getIdentifier() == sIdentifier) + { + return port; + } + } + return {}; + } + + void CModelFunction::clear() + { + m_inputs->clear(); + m_outputs->clear(); + } +} diff --git a/Source/Model/Classes/NMR_ModelFunctionFromImage3D.cpp b/Source/Model/Classes/NMR_ModelFunctionFromImage3D.cpp new file mode 100644 index 0000000..d33ff30 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelFunctionFromImage3D.cpp @@ -0,0 +1,134 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification,276529 +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Classes/NMR_ModelFunctionFromImage3D.h" + +namespace NMR +{ + NMR::CModelFunctionFromImage3D::CModelFunctionFromImage3D(const ModelResourceID sID, + CModel * pModel) + : CModelFunction(sID, pModel) + { + } + + void CModelFunctionFromImage3D::setImage3DUniqueResourceID(const UniqueResourceID sID) + { + m_image3DUniqueResourceID = sID; + } + + UniqueResourceID CModelFunctionFromImage3D::getImage3DUniqueResourceID() + { + return m_image3DUniqueResourceID; + } + + void CModelFunctionFromImage3D::setImage3DModelResourceID( + const ModelResourceID modelResoureId) + { + auto * model = getModel(); + PModelResource pResource = model->findResource(model->currentPath(), modelResoureId); + if (pResource == nullptr) + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + m_image3DUniqueResourceID = pResource->getPackageResourceID()->getUniqueID(); + } + + ModelResourceID CModelFunctionFromImage3D::getImage3DModelResourceID() + { + auto * model = getModel(); + PModelResource pResource = model->findResource(m_image3DUniqueResourceID); + if (pResource == nullptr) + throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); + auto const modelResId = pResource->getPackageResourceID()->getModelResourceID(); + if (modelResId != 2) // for debugging only + { + return modelResId; + } + + return modelResId; + } + + void CModelFunctionFromImage3D::setTileStyleU( + const eModelTextureTileStyle tileStyleU) + { + m_tileStyleU = tileStyleU; + } + + eModelTextureTileStyle CModelFunctionFromImage3D::getTileStyleU() + { + return m_tileStyleU; + } + + void CModelFunctionFromImage3D::setTileStyleV(const eModelTextureTileStyle tileStyleV) + { + m_tileStyleV = tileStyleV; + } + + eModelTextureTileStyle CModelFunctionFromImage3D::getTileStyleV() + { + return m_tileStyleV; + } + + void CModelFunctionFromImage3D::setTileStyleW(const eModelTextureTileStyle tileStyleW) + { + m_tileStyleW = tileStyleW; + } + + eModelTextureTileStyle CModelFunctionFromImage3D::getTileStyleW() + { + return m_tileStyleW; + } + + void CModelFunctionFromImage3D::setFilter(const eModelTextureFilter filter) + { + m_filter = filter; + } + + eModelTextureFilter CModelFunctionFromImage3D::getFilter() + { + return m_filter; + } + + void CModelFunctionFromImage3D::setOffset(double offset) + { + m_offset = offset; + } + + double CModelFunctionFromImage3D::getOffset() + { + return m_offset; + } + + void CModelFunctionFromImage3D::setScale(double scale) + { + m_scale = scale; + } + + double CModelFunctionFromImage3D::getScale() + { + return m_scale; + } +} // namespace NMR \ No newline at end of file diff --git a/Source/Model/Classes/NMR_ModelImage3D.cpp b/Source/Model/Classes/NMR_ModelImage3D.cpp new file mode 100644 index 0000000..e243c8e --- /dev/null +++ b/Source/Model/Classes/NMR_ModelImage3D.cpp @@ -0,0 +1,59 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelImage3D.cpp implements a 3D image for the volumetric extension + +--*/ + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelImage3D.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + + CModelImage3D::CModelImage3D(_In_ const ModelResourceID sID, _In_ CModel* pModel) + : CModelResource(sID, pModel) + { + + } + + std::string CModelImage3D::getName() const + { + return m_sName; + } + + void CModelImage3D::setName(_In_ std::string sName) + { + m_sName = sName; + } +} diff --git a/Source/Model/Classes/NMR_ModelImageStack.cpp b/Source/Model/Classes/NMR_ModelImageStack.cpp new file mode 100644 index 0000000..491f6a9 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelImageStack.cpp @@ -0,0 +1,130 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelImageStack.cpp implements an image stack for the volumetric extension + +--*/ + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelImageStack.h" +#include "Model/Classes/NMR_ModelAttachment.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + CModelImageStack::CModelImageStack(_In_ const ModelResourceID sID, _In_ CModel* pModel, _In_ nfUint32 nRowCount, _In_ nfUint32 nColumCount, nfUint32 nSheetCount) + : CModelImage3D(sID, pModel), m_nRowCount(nRowCount), m_nColumnCount(nColumCount), m_nSheetCount(nSheetCount) + { + m_Sheets.resize(m_nSheetCount); + } + + PModelImageStack CModelImageStack::make(_In_ const ModelResourceID sID, _In_ CModel* pModel, _In_ nfUint32 nRowCount, _In_ nfUint32 nColumCount, nfUint32 nSheetCount) + { + if (!pModel) + throw CNMRException(NMR_ERROR_INVALIDPOINTER); + if (nRowCount > MAX_IMAGESTACK_SIZE) + throw CNMRException(NMR_ERROR_INVALIDIMAGE3DSIZE); + if (nColumCount > MAX_IMAGESTACK_SIZE) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + if (nSheetCount > MAX_IMAGESTACK_SIZE) + throw CNMRException(MAX_IMAGESTACK_SIZE); + + return std::make_shared(CModelImageStack(sID, pModel, nRowCount, nColumCount, nSheetCount)); + } + + nfUint32 CModelImageStack::getRowCount() const + { + return m_nRowCount; + } + + nfUint32 CModelImageStack::getColumnCount() const + { + return m_nColumnCount; + } + + nfUint32 CModelImageStack::getSheetCount() const + { + return m_nSheetCount; + } + + void CModelImageStack::setRowCount(nfUint32 nRowCount) + { + if ((nRowCount == 0) || (nRowCount > MAX_IMAGESTACK_SIZE)) + throw CNMRException(NMR_ERROR_INVALIDIMAGE3DSIZE); + m_nRowCount = nRowCount; + } + + void CModelImageStack::setColumnCount(nfUint32 nColumnCount) + { + if ((nColumnCount == 0) || (nColumnCount > MAX_IMAGESTACK_SIZE)) + throw CNMRException(NMR_ERROR_INVALIDIMAGE3DSIZE); + m_nColumnCount = nColumnCount; + } + + void CModelImageStack::setSheetCount(nfUint32 nSheetCount) + { + if ((nSheetCount == 0) || (nSheetCount > MAX_IMAGESTACK_SIZE)) + throw CNMRException(NMR_ERROR_INVALIDIMAGE3DSIZE); + m_nSheetCount = nSheetCount; + m_Sheets.resize(m_nSheetCount); + } + + void CModelImageStack::setSheet(nfUint32 nSheetIndex, PModelAttachment pAttachment) + { + if (!pAttachment.get()) + throw CNMRException(NMR_ERROR_INVALIDTEXTURE); + if (pAttachment->getRelationShipType() != PACKAGE_TEXTURE_RELATIONSHIP_TYPE) + throw CNMRException(NMR_ERROR_INVALIDRELATIONSHIPTYPEFORTEXTURE); + if (nSheetIndex >= m_nSheetCount) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + if (pAttachment->getModel() != getModel()) + throw CNMRException(NMR_ERROR_ATTACHMENTMODELMISMATCH); + + m_Sheets[nSheetIndex] = pAttachment; + } + + PModelAttachment CModelImageStack::getSheet(nfUint32 nSheetIndex) + { + if (nSheetIndex >= m_nSheetCount) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + return m_Sheets[nSheetIndex]; + } + + PModelAttachment CModelImageStack::createSheet(nfUint32 nSheetIndex, const std::string& sPath, PImportStream pCopiedStream) + { + PModelAttachment pAttachment = getModel()->addAttachment(sPath, PACKAGE_TEXTURE_RELATIONSHIP_TYPE, pCopiedStream); + setSheet(nSheetIndex, pAttachment); + return pAttachment; + } + +} diff --git a/Source/Model/Classes/NMR_ModelImplicitFunction.cpp b/Source/Model/Classes/NMR_ModelImplicitFunction.cpp new file mode 100644 index 0000000..dd5f968 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelImplicitFunction.cpp @@ -0,0 +1,474 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification,276529 +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Classes/NMR_ModelImplicitFunction.h" + +#include "Common/NMR_Exception.h" +#include "lib3mf_interfaceexception.hpp" +#include "lib3mf_types.hpp" +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Classes/NMR_ModelImplicitPort.h" +#include "Common/Graph/GraphAlgorithms.h" +#include "Common/Graph/DirectedGraph.h" + +#include +#include + +namespace NMR +{ + const implicit::NodeTypes CModelImplicitFunction::m_nodeTypes; + + CModelImplicitNode * + CModelImplicitFunction::findNode(const ImplicitIdentifier & sIdentifier) const + { + for (auto & node : *m_nodes) + { + if (node->getIdentifier() == sIdentifier) + { + return node.get(); + } + } + return nullptr; + } + + CModelImplicitFunction::CModelImplicitFunction(const ModelResourceID sID, + CModel* pModel) + : CModelFunction(sID, pModel) + { + m_nodes = std::make_shared(); + } + + std::string const & CModelImplicitFunction::getIdentifier() const + { + return m_identifier; + } + + void CModelImplicitFunction::setIdentifier(std::string const & identifier) + { + m_identifier = identifier; + } + + PModelImplicitNode CModelImplicitFunction::addNode(const Lib3MF::eImplicitNodeType eNodeType, + const Lib3MF::eImplicitNodeConfiguration eConfiguration, + const std::string & sIdentifier, + const std::string & sDisplayName, + const std::string & sTag) + { + auto node = std::make_shared(eNodeType, sIdentifier, sDisplayName, sTag, this); + + m_nodeTypes.addExpectedPortsToNode(*node, eConfiguration); + m_nodes->push_back(node); + return node; + } + + PModelImplicitNode CModelImplicitFunction::addNode(const Lib3MF::eImplicitNodeType eNodeType, const Lib3MF::eImplicitNodeConfiguration eConfiguration) + { + return addNode(eNodeType, eConfiguration, "", "", ""); + } + + PImplicitNodes NMR::CModelImplicitFunction::getNodes() const + { + return m_nodes; + } + + void NMR::CModelImplicitFunction::addLink( + const ImplicitIdentifier& sSourceNodeIdentifier, + const ImplicitIdentifier& sTargetNodeIdentifier) + + { + auto const sourceNodeName = extractNodeName(sSourceNodeIdentifier); + + PModelImplicitPort sourcePort; + if(sourceNodeName == "inputs") + { + auto const sourcePortName = extractPortName(sSourceNodeIdentifier); + sourcePort = findInput(sourcePortName); + } + else + { + auto const sourceNode = findNode(sourceNodeName); + if(sourceNode == nullptr) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDPARAM, + "Source node " + sourceNodeName + " does not exist."); + } + auto const sourcePortName = extractPortName(sSourceNodeIdentifier); + if(sourcePortName.empty()) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDPARAM, + "Source port " + sourcePortName + " of node " + + sourceNodeName + " does not exist."); + } + sourcePort = sourceNode->findOutput(sourcePortName); + } + if(!sourcePort) + { + throw CNMRException( + NMR_ERROR_IMPLICIT_FUNCTION_INVALID_SOURCE_PORT); + } + + auto const targetNodeName = extractNodeName(sTargetNodeIdentifier); + auto const targetPortName = extractPortName(sTargetNodeIdentifier); + NMR::PModelImplicitPort targetPort; + if(targetNodeName == "outputs") + { + targetPort = findOutput(targetPortName); + } + else + { + auto const targetNode = findNode(targetNodeName); + if(targetNode == nullptr) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDPARAM, + "Target node " + targetNodeName + " does not exist."); + } + + if(targetPortName.empty()) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDPARAM, + "Target port " + targetPortName + " of node " + + targetNodeName + " does not exist."); + } + + targetPort = targetNode->findInput(targetPortName); + } + + if(!targetPort) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDPARAM, + "Target port " + targetPortName + " of node " + + targetNodeName + " does not exist."); + } + + if(sourcePort->getType() != targetPort->getType()) + { + std::string sourceNodeIdentifier = "function inputs"; + std::string targetNodeIdentifier = "function outputs"; + + if(sourcePort->getParent()) + { + sourceNodeIdentifier = sourcePort->getParent()->getIdentifier(); + } + + if(targetPort->getParent()) + { + targetNodeIdentifier = targetPort->getParent()->getIdentifier(); + } + + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INCOMPATIBLEPORTTYPES, + "Output " + sourcePort->getIdentifier() + " of node " + + sourceNodeIdentifier + " has type " + + std::to_string(static_cast(sourcePort->getType())) + + " while target input " + targetPort->getIdentifier() + + " of node " + targetNodeIdentifier + " has type " + + std::to_string(static_cast(targetPort->getType())) + + "."); + + } + + targetPort->setReferencedPort(sourcePort); + } + + void CModelImplicitFunction::addLink(PModelImplicitPort pSourcePort, + PModelImplicitPort pTargetPort) + { + if (!pSourcePort) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Source port is nullptr."); + } + + if (!pTargetPort) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Target port is nullptr."); + } + + if(pSourcePort->getType() != pTargetPort->getType()) + { + std::string sourceNodeIdentifier = "function inputs"; + std::string targetNodeIdentifier = "function outputs"; + + if(pSourcePort->getParent()) + { + sourceNodeIdentifier = pSourcePort->getParent()->getIdentifier(); + } + + if(pTargetPort->getParent()) + { + targetNodeIdentifier = pTargetPort->getParent()->getIdentifier(); + } + + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INCOMPATIBLEPORTTYPES, + "Output " + pSourcePort->getIdentifier() + " of node " + + sourceNodeIdentifier + " has type " + + std::to_string(static_cast(pSourcePort->getType())) + + " while target input " + pTargetPort->getIdentifier() + + " of node " + targetNodeIdentifier + " has type " + + std::to_string(static_cast(pTargetPort->getType())) + + "."); + } + + pTargetPort->setReferencedPort(pSourcePort); + } + + implicit::NodeTypes const& CModelImplicitFunction::getNodeTypes() const + { + return m_nodeTypes; + } + + void CModelImplicitFunction::removeNode( + ImplicitIdentifier const& sIdentifier) + { + auto node = findNode(sIdentifier); + if(node == nullptr) + { + throw CNMRException(NMR_ERROR_INVALIDPOINTER); + } + m_nodes->erase(std::remove_if(m_nodes->begin(), m_nodes->end(), + [node](PModelImplicitNode const& n) + { return n.get() == node; }), + m_nodes->end()); + } + + void CModelImplicitFunction::clear() + { + CModelFunction::clear(); + m_nodes->clear(); + } + + void CModelImplicitFunction::replaceResourceID(const ModelResourceID sOldID, + const ModelResourceID sNewID) + { + for (auto & node : *m_nodes) + { + if (node->getModelResourceID() == sOldID) + { + node->setModelResourceID(sNewID); + } + } + } + + + std::string extractNodeName(const ImplicitIdentifier& sIdentifier) + { + auto pos = sIdentifier.find_last_of("."); + if (pos == std::string::npos) + { + return ""; + } + return sIdentifier.substr(0, pos); + } + + std::string extractPortName(const ImplicitIdentifier & sIdentifier) + { + auto pos = sIdentifier.find_last_of("."); + if (pos == std::string::npos) + { + return sIdentifier; + } + return sIdentifier.substr(pos + 1); + } + + ImplicitIdentifier makeReferenceIdentifier(const ImplicitIdentifier & sNodeIdentifier, + const ImplicitIdentifier & sPortIdentifier) + { + if (sNodeIdentifier.empty()) + { + return "inputs." + sPortIdentifier; + } + return sNodeIdentifier + "." + sPortIdentifier; + } + + NMR::common::graph::DirectedGraph directedGraphFromNodes(const PImplicitNodes & nodes) + { + if (!nodes) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Nodes must not be nullptr."); + } + + using namespace NMR::common; + graph::DirectedGraph graph(nodes->size()+1); + + std::unordered_map identifierToIndex; + graph::Identifier InputsIndex = 0; + + graph::Identifier index = 1; + for (auto const& node : *nodes) + { + if (!node) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Node must not be nullptr."); + } + + auto const& identifier = node->getIdentifier(); + identifierToIndex[identifier] = index; + ++index; + } + + for (auto const& node : *nodes) + { + auto const& inputs = node->getInputs(); + + if (!inputs) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Inputs must not be nullptr."); + } + + for (auto const& input : *inputs) + { + auto const& sourcePort = input->getReferencedPort(); + if (sourcePort) + { + auto const& sourceNode = sourcePort->getParent(); + if (sourceNode) + { + auto const& sourceNodeIdentifier = sourceNode->getIdentifier(); + graph::Identifier const sourceIndex = identifierToIndex[sourceNodeIdentifier]; + graph::Identifier const targetIndex = identifierToIndex[node->getIdentifier()]; + if (sourceIndex >= graph.getSize()) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Source index " + std::to_string(sourceIndex) + " is out of range."); + } + + if (targetIndex >= graph.getSize()) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Target index " + std::to_string(targetIndex) + " is out of range."); + } + graph.addDependency(sourceIndex, targetIndex); + } + else + { + graph.addDependency(InputsIndex, identifierToIndex[node->getIdentifier()]); + } + } + + } + } + return graph; + } + + void CModelImplicitFunction::sortNodesTopologically() + { + using namespace NMR::common; + auto graph = directedGraphFromNodes(m_nodes); + auto const sortedIndices = NMR::common::graph::topologicalSort(graph); + if (sortedIndices.empty()) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_GRAPHISCYCLIC); + } + + PImplicitNodes sortedNodes = std::make_shared(); + sortedNodes->reserve(sortedIndices.size()); + + for (auto const & index : sortedIndices) + { + if (index == 0) + { + continue; + } + + auto nodeIndex = index - 1; + + if (nodeIndex >= m_nodes->size()) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Invalid node index " + std::to_string(nodeIndex) + ". Node index must be between 0 and " + std::to_string(m_nodes->size()) + "."); + } + + sortedNodes->push_back(m_nodes->at(nodeIndex)); + } + std::swap(m_nodes, sortedNodes); + } + + PModelImplicitPort + NMR::CModelImplicitFunction::findPort(const ImplicitIdentifier & sIdentifier) const + { + auto const nodeName = extractNodeName(sIdentifier); + auto const portName = extractPortName(sIdentifier); + if (nodeName == "inputs") + { + return findInput(portName); + } + auto const node = findNode(nodeName); + if (node == nullptr) + { + return {}; + } + if (portName.empty()) + { + return {}; + } + return node->findOutput(portName); + } + + ResourceDependencies CModelImplicitFunction::getDependencies() + { + ResourceDependencies dependencies; + for (auto const& node : *m_nodes) + { + if (!node) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Node must not be nullptr."); + } + if (node->getNodeType() == Lib3MF::eImplicitNodeType::ConstResourceID) + { + auto * model = getModel(); + if (!model) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Model must not be nullptr."); + } + + auto referendedResource = model->findResource(model->currentPath(), node->getModelResourceID()); + if (!referendedResource) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Referenced resource must not be nullptr."); + } + dependencies.push_back(referendedResource->getPackageResourceID()); + } + } + return dependencies; + } +} + diff --git a/Source/Model/Classes/NMR_ModelImplicitNode.cpp b/Source/Model/Classes/NMR_ModelImplicitNode.cpp new file mode 100644 index 0000000..626f4b7 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelImplicitNode.cpp @@ -0,0 +1,321 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Classes/NMR_ModelImplicitNode.h" + +#include "Common/NMR_Exception.h" +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Classes/NMR_ModelImplicitNode.h" + +#include + +namespace NMR +{ + + CModelImplicitNode::CModelImplicitNode(Lib3MF::eImplicitNodeType type, + ImplicitIdentifier const & identifier, + std::string const & displayname, + std::string const & tag, + CModelImplicitFunction * parent) + : m_type(type) + , m_identifier(identifier) + , m_displayname(displayname) + , m_tag(tag) + , m_parent(parent) + { + m_outputs = std::make_shared(); + m_inputs = std::make_shared(); + } + + CModelImplicitNode::CModelImplicitNode(Lib3MF::eImplicitNodeType type, + CModelImplicitFunction * parent) + : m_type(type) + , m_parent(parent) + { + m_outputs = std::make_shared(); + m_inputs = std::make_shared(); + } + + ImplicitIdentifier const & CModelImplicitNode::getIdentifier() const + { + return m_identifier; + } + + std::string const & CModelImplicitNode::getDisplayName() const + { + return m_displayname; + } + + void CModelImplicitNode::setIdentifier(ImplicitIdentifier const & identifier) + { + m_identifier = identifier; + } + + void CModelImplicitNode::setDisplayName(std::string const & displayname) + { + m_displayname = displayname; + } + + void NMR::CModelImplicitNode::setType(Lib3MF::eImplicitNodeType type) + { + m_type = type; + } + + void CModelImplicitNode::setTag(std::string const & tag) + { + m_tag = tag; + } + + std::string const & CModelImplicitNode::getTag() const + { + return m_tag; + } + + Lib3MF::eImplicitNodeType CModelImplicitNode::getNodeType() const + { + return m_type; + } + + PModelImplicitPort CModelImplicitNode::addInput(const std::string & sIdentifier, + const std::string & sDisplayName) + { + auto newPort = std::make_shared(this, sIdentifier, sDisplayName); + m_inputs->push_back(newPort); + return newPort; + } + + PModelImplicitPort CModelImplicitNode::addOutput(const std::string & sIdentifier, + const std::string & sDisplayName) + { + auto newPort = std::make_shared(this, sIdentifier, sDisplayName); + m_outputs->push_back(newPort); + return newPort; + } + + PPorts NMR::CModelImplicitNode::getInputs() const + { + return m_inputs; + } + + PPorts CModelImplicitNode::getOutputs() const + { + return m_outputs; + } + + PModelImplicitPort NMR::CModelImplicitNode::findInput(const std::string & sIdentifier) const + { + for (auto & port : *m_inputs) + { + if (port->getIdentifier() == sIdentifier) + { + return port; + } + } + return {}; + } + + PModelImplicitPort CModelImplicitNode::findOutput(const std::string & sIdentifier) const + { + for (auto & port : *m_outputs) + { + if (port->getIdentifier() == sIdentifier) + { + return port; + } + } + return {}; + } + + void NMR::CModelImplicitNode::setConstant(double value) + { + if (m_type != Lib3MF::eImplicitNodeType::Constant) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "setConstant can only be called on Constant nodes"); + m_constant = value; + } + double CModelImplicitNode::getConstant() const + { + if (m_type != Lib3MF::eImplicitNodeType::Constant) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getConstant can only be called on Constant nodes"); + + return m_constant; + } + + void NMR::CModelImplicitNode::setVector(const Lib3MF::sVector & value) + { + if (m_type != Lib3MF::eImplicitNodeType::ConstVec) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "setVector can only be called on ConstVec nodes"); + m_vector = std::unique_ptr(new Lib3MF::sVector(value)); + } + + Lib3MF::sVector CModelImplicitNode::getVector() const + { + if (m_type != Lib3MF::eImplicitNodeType::ConstVec) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getVector can only be called on ConstVec nodes"); + + if (!m_vector) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getVector: vector value not initialized"); + return *m_vector; + } + + void CModelImplicitNode::setMatrix(const Lib3MF::sMatrix4x4 & value) + { + if (m_type != Lib3MF::eImplicitNodeType::ConstMat) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "setMatrix can only be called on ConstMat nodes"); + m_matrix = std::unique_ptr(new Lib3MF::sMatrix4x4(value)); + } + + Lib3MF::sMatrix4x4 CModelImplicitNode::getMatrix() const + { + if (m_type != Lib3MF::eImplicitNodeType::ConstMat) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getMatrix can only be called on ConstMat nodes"); + + if (!m_matrix) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getMatrix: matrix value not initialized"); + return *m_matrix; + } + + void CModelImplicitNode::setModelResourceID(ModelResourceID resourceID) + { + if (m_type != Lib3MF::eImplicitNodeType::ConstResourceID) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "setModelResourceID can only be called on ConstResourceID nodes"); + m_modelResourceID = resourceID; + } + + ModelResourceID CModelImplicitNode::getModelResourceID() const + { + if (m_type != Lib3MF::eImplicitNodeType::ConstResourceID) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getModelResourceID can only be called on ConstResourceID nodes"); + + return m_modelResourceID; + } + + PModelResource NMR::CModelImplicitNode::getResource() const + { + if (m_parent == nullptr) + { + return nullptr; + } + + auto model = m_parent->getModel(); + + if (model == nullptr) + { + return nullptr; + } + + return model->findResource(model->currentPath(), m_modelResourceID); + } + + void CModelImplicitNode::setAccurateRange(double accurateRange) + { + if (m_type != Lib3MF::eImplicitNodeType::BeamLattice) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "setAccurateRange can only be called on BeamLattice nodes"); + m_accurateRange = std::max(0.0, accurateRange); // Clamp to >= 0.0 per schema + } + + double CModelImplicitNode::getAccurateRange() const + { + if (m_type != Lib3MF::eImplicitNodeType::BeamLattice) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getAccurateRange can only be called on BeamLattice nodes"); + return m_accurateRange; + } + + void CModelImplicitNode::setScalarOutputName(const std::string& name) + { + if (m_type != Lib3MF::eImplicitNodeType::FunctionGradient && + m_type != Lib3MF::eImplicitNodeType::NormalizeDistance) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "setScalarOutputName can only be called on FunctionGradient or NormalizeDistance nodes"); + m_scalarOutputName = name; + } + + std::string CModelImplicitNode::getScalarOutputName() const + { + if (m_type != Lib3MF::eImplicitNodeType::FunctionGradient && + m_type != Lib3MF::eImplicitNodeType::NormalizeDistance) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getScalarOutputName can only be called on FunctionGradient or NormalizeDistance nodes"); + return m_scalarOutputName; + } + + void CModelImplicitNode::setVectorInputName(const std::string& name) + { + if (m_type != Lib3MF::eImplicitNodeType::FunctionGradient && + m_type != Lib3MF::eImplicitNodeType::NormalizeDistance) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "setVectorInputName can only be called on FunctionGradient or NormalizeDistance nodes"); + m_vectorInputName = name; + } + + std::string CModelImplicitNode::getVectorInputName() const + { + if (m_type != Lib3MF::eImplicitNodeType::FunctionGradient && + m_type != Lib3MF::eImplicitNodeType::NormalizeDistance) + throw CNMRException(NMR_ERROR_INVALIDPARAM, + "getVectorInputName can only be called on FunctionGradient or NormalizeDistance nodes"); + return m_vectorInputName; + } + + bool CModelImplicitNode::arePortsValid() const + { + return m_parent->getNodeTypes().arePortsValidForNode(*this); + } + + void CModelImplicitNode::setGraphID(GraphID id) + { + m_graphId = id; + } + + GraphID CModelImplicitNode::getGraphID() const + { + return m_graphId; + } + + CModelImplicitFunction * CModelImplicitNode::getParent() const + { + return m_parent; + } + + void CModelImplicitNode::setParent(CModelImplicitFunction* parent) + { + m_parent = parent; + } +} // namespace NMR diff --git a/Source/Model/Classes/NMR_ModelImplicitPort.cpp b/Source/Model/Classes/NMR_ModelImplicitPort.cpp new file mode 100644 index 0000000..b97ce30 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelImplicitPort.cpp @@ -0,0 +1,161 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Classes/NMR_ModelImplicitPort.h" +#include "Model/Classes/NMR_ModelImplicitNode.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Common/NMR_Exception.h" +#include "lib3mf_interfaceexception.hpp" + +namespace NMR +{ + CModelImplicitPort::CModelImplicitPort(CModelImplicitNode * parent, + ImplicitIdentifier const & identifier, + std::string const & displayname) + : m_parent(parent) + , m_identifier(identifier) + , m_displayname(displayname) + { + } + + CModelImplicitPort::CModelImplicitPort(ImplicitIdentifier const & identifier, + std::string const & displayname, + Lib3MF::eImplicitPortType type) + : m_identifier(identifier) + , m_displayname(displayname) + , m_type(type) + { + } + + ImplicitIdentifier const & CModelImplicitPort::getIdentifier() const + { + return m_identifier; + } + + std::string const & CModelImplicitPort::getDisplayName() const + { + return m_displayname; + } + + void CModelImplicitPort::setIdentifier(std::string const & identifier) + { + m_identifier = identifier; + } + + void CModelImplicitPort::setDisplayName(std::string const & displayname) + { + m_displayname = displayname; + } + + Lib3MF::eImplicitPortType CModelImplicitPort::getType() const + { + return m_type; + } + + void CModelImplicitPort::setType(Lib3MF::eImplicitPortType type) + { + m_type = type; + } + + ImplicitIdentifier CModelImplicitPort::getReference() const + { + if (!m_referencedPort) + { + updateReference(); + } + if (!m_referencedPort) + { + return m_reference; + } + + auto sourceParentNode = m_referencedPort->getParent(); + + if (!sourceParentNode) // Function input ports don't have a node as parent + { + return "inputs." + m_referencedPort->getIdentifier(); + } + + return makeReferenceIdentifier(sourceParentNode->getIdentifier(), m_referencedPort->getIdentifier()); + } + + void CModelImplicitPort::setReference(ImplicitIdentifier const & reference) + { + m_referencedPort.reset(); + m_reference = reference; + updateReference(); + } + + CModelImplicitNode * CModelImplicitPort::getParent() const + { + return m_parent; + } + + std::shared_ptr CModelImplicitPort::getReferencedPort() const + { + if (!m_referencedPort) + { + updateReference(); + } + if (!m_referencedPort) + { + std::string nodeName; + if (m_parent) + { + nodeName = m_parent->getIdentifier(); + } + else + { + nodeName = "inputs"; + } + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, "Referenced port of port " + nodeName + "." + m_identifier + " is not set."); + } + return m_referencedPort; + } + + void CModelImplicitPort::setReferencedPort( + std::shared_ptr const & referencedPort) + { + m_referencedPort = referencedPort; + } + + void CModelImplicitPort::updateReference() const + { + if (!m_parent) + { + return; + } + + auto * function = m_parent->getParent(); + if (!function) + { + return; + } + + m_referencedPort = function->findPort(m_reference); + } +} //namespace NMR diff --git a/Source/Model/Classes/NMR_ModelLevelSetObject.cpp b/Source/Model/Classes/NMR_ModelLevelSetObject.cpp new file mode 100644 index 0000000..4859372 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelLevelSetObject.cpp @@ -0,0 +1,201 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelLevelSetObject.cpp implements the Model LevelSet Object +Class. A model levelset object is an in memory representation of the 3MF +levelset object. + +--*/ + +#include "Model/Classes/NMR_ModelLevelSetObject.h" + +#include "Common/Math/NMR_PairMatchingTree.h" +#include "Common/Mesh/NMR_Mesh.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelObject.h" +#include "Model/Classes/NMR_ModelVolumeData.h" + +namespace NMR +{ + + CModelLevelSetObject::CModelLevelSetObject( + const ModelResourceID sID, CModel* pModel) + : CModelObject(sID, pModel) + { + } + + CModelLevelSetObject::~CModelLevelSetObject() {} + + void CModelLevelSetObject::mergeToMesh(CMesh* pMesh, + const NMATRIX3 mMatrix) + { + throw CNMRException(NMR_ERROR_NOTIMPLEMENTED); + } + + PModelMeshObject CModelLevelSetObject::getMesh() + { + return m_pMesh; + } + + void CModelLevelSetObject::setMesh(PModelMeshObject pMesh) + { + if(!pMesh) throw CNMRException(NMR_ERROR_INVALIDPARAM); + + m_pMesh = pMesh; + } + + nfBool CModelLevelSetObject::isValid() + { + return true; + } + + nfBool CModelLevelSetObject::hasSlices(nfBool bRecursive) + { + return (this->getSliceStack().get() != nullptr); + } + + nfBool CModelLevelSetObject::isValidForSlices( + const NMATRIX3& totalParentMatrix) + { + if(!this->getSliceStack().get()) + { + return true; + } + else + { + return fnMATRIX3_isplanar(totalParentMatrix); + } + } + + void CModelLevelSetObject::extendOutbox( + NOUTBOX3& vOutBox, const NMATRIX3 mAccumulatedMatrix) + { + throw CNMRException(NMR_ERROR_NOTIMPLEMENTED); + } + + PModelFunction CModelLevelSetObject::getFunction() + { + return m_pFunction; + } + + void CModelLevelSetObject::setFunction(PModelFunction pFunction) + { + if(!pFunction) throw CNMRException(NMR_ERROR_INVALIDPARAM); + + m_pFunction = pFunction; + } + + PModelVolumeData CModelLevelSetObject::getVolumeData() + { + return m_pVolumeData; + } + + void CModelLevelSetObject::setVolumeData( + _In_ PModelVolumeData pVolumeData) + { + if(!pVolumeData) throw CNMRException(NMR_ERROR_INVALIDPARAM); + + m_pVolumeData = pVolumeData; + } + + void CModelLevelSetObject::setChannelName(std::string outputPortName) + { + m_outputPortName = std::move(outputPortName); + } + + std::string const& CModelLevelSetObject::getChannelName() const + { + return m_outputPortName; + } + + void CModelLevelSetObject::setTransform(NMR::NMATRIX3 transform) + { + m_transform = transform; + m_bHasTransform = true; + } + + NMR::NMATRIX3 CModelLevelSetObject::getTransform() const + { + return m_transform; + } + + bool CModelLevelSetObject::hasTransform() const + { + return m_bHasTransform; + } + + void CModelLevelSetObject::setMinFeatureSize(double minFeatureSize) + { + m_minFeatureSize = minFeatureSize; + } + + double CModelLevelSetObject::getMinFeatureSize() const + { + return m_minFeatureSize; + } + + void CModelLevelSetObject::setFallBackValue(double fallBackValue) + { + m_fallBackValue = fallBackValue; + } + + double CModelLevelSetObject::getFallBackValue() const + { + return m_fallBackValue; + } + + void CModelLevelSetObject::setMeshBBoxOnly(bool bMeshBBoxOnly) + { + m_meshBBoxOnly = bMeshBBoxOnly; + } + + bool CModelLevelSetObject::getMeshBBoxOnly() const + { + return m_meshBBoxOnly; + } + + ResourceDependencies CModelLevelSetObject::getDependencies() + { + ResourceDependencies dependencies; + if (m_pFunction) + { + dependencies.push_back(m_pFunction->getPackageResourceID()); + } + + if (m_pVolumeData) + { + dependencies.push_back(m_pVolumeData->getPackageResourceID()); + // concatenate dependencies + auto volumeDataDependencies = m_pVolumeData->getDependencies(); + dependencies.insert(dependencies.end(), volumeDataDependencies.begin(), volumeDataDependencies.end()); + } + + return dependencies; + } +} // namespace NMR + diff --git a/Source/Model/Classes/NMR_ModelMeshObject.cpp b/Source/Model/Classes/NMR_ModelMeshObject.cpp index 4829ea7..c318f16 100644 --- a/Source/Model/Classes/NMR_ModelMeshObject.cpp +++ b/Source/Model/Classes/NMR_ModelMeshObject.cpp @@ -36,6 +36,8 @@ mesh object. #include "Model/Classes/NMR_ModelMeshObject.h" #include "Common/Math/NMR_PairMatchingTree.h" +#define TRIANGLESET_MAXCOUNT (1024 * 1024 * 1024) + namespace NMR { CModelMeshObject::CModelMeshObject(_In_ const ModelResourceID sID, _In_ CModel * pModel) @@ -221,10 +223,110 @@ namespace NMR { m_pBeamLatticeAttributes = pBeamLatticeAttributes; } + PModelVolumeData CModelMeshObject::getVolumeData() + { + return m_pVolumeData; + } + + void CModelMeshObject::setVolumeData(_In_ PModelVolumeData pVolumeData) + { + if (!pVolumeData) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + m_pVolumeData = pVolumeData; + } + void CModelMeshObject::extendOutbox(_Out_ NOUTBOX3& vOutBox, _In_ const NMATRIX3 mAccumulatedMatrix) { m_pMesh->extendOutbox(vOutBox, mAccumulatedMatrix); } + + ResourceDependencies CModelMeshObject::getDependencies() + { + ResourceDependencies dependencies; + if(m_pVolumeData) + { + dependencies.push_back( + m_pVolumeData->getPackageResourceID()); + } + + return dependencies; + } + + void CModelMeshObject::deleteTriangleSet(_In_ CModelTriangleSet* pTriangleSet) + { + if (pTriangleSet != nullptr) { + auto sIdentifier = pTriangleSet->getIdentifier(); + m_TriangleSets.erase(std::remove_if( + m_TriangleSets.begin(), + m_TriangleSets.end(), + [sIdentifier](PModelTriangleSet const& pSet) { return (pSet->getIdentifier() == sIdentifier); } + )); + + m_TriangleSetMap.erase(sIdentifier); + + } + } + + PModelTriangleSet CModelMeshObject::findTriangleSet(const std::string& sIdentifier) + { + auto iIterator = m_TriangleSetMap.find(sIdentifier); + if (iIterator == m_TriangleSetMap.end()) + return nullptr; + + return iIterator->second; + + } + + PModelTriangleSet CModelMeshObject::addTriangleSet(const std::string& sIdentifier, const std::string& sName) + { + auto iIterator = m_TriangleSetMap.find(sIdentifier); + if (iIterator != m_TriangleSetMap.end()) + throw CNMRException(NMR_ERROR_DUPLICATETRIANGLESET); + + if (m_TriangleSets.size() >= TRIANGLESET_MAXCOUNT) + throw CNMRException(NMR_ERROR_TOOMANYTRIANGLESETS); + + auto pTriangleSet = std::make_shared(sName, sIdentifier); + m_TriangleSets.push_back(pTriangleSet); + m_TriangleSetMap.insert(std::make_pair (sIdentifier, pTriangleSet)); + + return pTriangleSet; + + } + + PModelTriangleSet CModelMeshObject::addTriangleSet(PModelTriangleSet pModelTriangleSet) + { + if (pModelTriangleSet.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + auto iIterator = m_TriangleSetMap.find(pModelTriangleSet->getIdentifier()); + if (iIterator != m_TriangleSetMap.end()) + throw CNMRException(NMR_ERROR_DUPLICATETRIANGLESET); + + if (m_TriangleSets.size() >= TRIANGLESET_MAXCOUNT) + throw CNMRException(NMR_ERROR_TOOMANYTRIANGLESETS); + + m_TriangleSets.push_back(pModelTriangleSet); + m_TriangleSetMap.insert(std::make_pair(pModelTriangleSet->getIdentifier(), pModelTriangleSet)); + + return pModelTriangleSet; + } + + uint32_t CModelMeshObject::getTriangleSetCount() + { + return (uint32_t)m_TriangleSets.size(); + } + + PModelTriangleSet CModelMeshObject::getTriangleSet(const uint32_t nIndex) + { + if (nIndex >= m_TriangleSets.size()) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + return m_TriangleSets[nIndex]; + + } + } diff --git a/Source/Model/Classes/NMR_ModelMetaDataGroup.cpp b/Source/Model/Classes/NMR_ModelMetaDataGroup.cpp index a2608ca..e3265d3 100644 --- a/Source/Model/Classes/NMR_ModelMetaDataGroup.cpp +++ b/Source/Model/Classes/NMR_ModelMetaDataGroup.cpp @@ -47,7 +47,6 @@ namespace NMR { m_MetaDataMap.clear(); } - PModelMetaData CModelMetaDataGroup::addMetaData(_In_ std::string sNameSpace, _In_ std::string sName, _In_ std::string sValue, _In_ std::string sType, _In_ nfBool bPreserve) { if (hasMetaData(composeNamespaceAndNameIntoKey(sNameSpace, sName))) { @@ -114,7 +113,11 @@ namespace NMR { std::string sName; std::string sValue; PModelMetaData metaData = pSourceMetaDataGroup->getMetaData(nIndex); - addMetaData(metaData->getNameSpace(), metaData->getName(), metaData->getValue(), metaData->getType(), metaData->getPreserve()); + + // only add metadata, if the key does not exist yet + if (!hasMetaData(metaData->getKey())) { + addMetaData(metaData->getNameSpace(), metaData->getName(), metaData->getValue(), metaData->getType(), metaData->getPreserve()); + } } } } diff --git a/Source/Model/Classes/NMR_ModelMultiPropertyGroup.cpp b/Source/Model/Classes/NMR_ModelMultiPropertyGroup.cpp index 6c6a312..9170a6b 100644 --- a/Source/Model/Classes/NMR_ModelMultiPropertyGroup.cpp +++ b/Source/Model/Classes/NMR_ModelMultiPropertyGroup.cpp @@ -221,6 +221,7 @@ namespace NMR { switch (eBlendMethod) { case MODELBLENDMETHOD_MIX: return XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MIX; case MODELBLENDMETHOD_MULTIPLY: return XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MULTIPLY; + case MODELBLENDMETHOD_MASK: return XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MASK; default: return XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MIX; } @@ -229,9 +230,13 @@ namespace NMR { { if (sBlendMethod == XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MIX) { return MODELBLENDMETHOD_MIX; - } else if (sBlendMethod == XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MULTIPLY) { + } + else if (sBlendMethod == XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MULTIPLY) { return MODELBLENDMETHOD_MULTIPLY; } + else if (sBlendMethod == XML_3MF_ATTRIBUTE_MULTIPROPERTIES_BLENDMETHOD_MASK) { + return MODELBLENDMETHOD_MASK; + } else { throw CNMRException(NMR_ERROR_INVALID_BLENDMETHOD_ATTRIBUTE); } diff --git a/Source/Model/Classes/NMR_ModelObject.cpp b/Source/Model/Classes/NMR_ModelObject.cpp index ccfd31e..b1aa7da 100644 --- a/Source/Model/Classes/NMR_ModelObject.cpp +++ b/Source/Model/Classes/NMR_ModelObject.cpp @@ -208,6 +208,4 @@ namespace NMR { if (nLevel >= m_nComponentDepthLevel) m_nComponentDepthLevel = nLevel; } - - } diff --git a/Source/Model/Classes/NMR_ModelResource.cpp b/Source/Model/Classes/NMR_ModelResource.cpp index c9a31d9..8776154 100644 --- a/Source/Model/Classes/NMR_ModelResource.cpp +++ b/Source/Model/Classes/NMR_ModelResource.cpp @@ -34,7 +34,7 @@ resource object. #include "Model/Classes/NMR_Model.h" #include "Model/Classes/NMR_ModelResource.h" -#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception.h" namespace NMR { @@ -64,8 +64,12 @@ namespace NMR { void CModelResource::setPackageResourceID(PPackageResourceID pID) { - m_pModel->updateUniqueResourceID(m_pPackageResourceID->getUniqueID(), pID->getUniqueID()); + if (m_pModel) + { + m_pModel->updateUniqueResourceID(m_pPackageResourceID->getUniqueID(), pID->getUniqueID()); + } m_pPackageResourceID = pID; + } _Ret_notnull_ CModel * CModelResource::getModel() @@ -73,6 +77,15 @@ namespace NMR { return m_pModel; } + void CModelResource::setModel(CModel* pModel) + { + m_pModel = pModel; + } + + ResourceDependencies CModelResource::getDependencies() + { + return {}; + } void CModelResource::clearResourceIndexMap() { diff --git a/Source/Model/Classes/NMR_ModelSliceStack.cpp b/Source/Model/Classes/NMR_ModelSliceStack.cpp index 7a25395..c8eb99d 100644 --- a/Source/Model/Classes/NMR_ModelSliceStack.cpp +++ b/Source/Model/Classes/NMR_ModelSliceStack.cpp @@ -132,7 +132,12 @@ namespace NMR { for (auto pStack : m_pSliceRefs) { nSlices += pStack->getSliceCount(); } - m_pSlices.reserve(nSlices); + + if (nSlices > LIB3MF_MAXSLICEREFERENCES) + throw CNMRException(NMR_ERROR_TOOMANYSLICES); + + + m_pSlices.reserve((size_t)nSlices); for (auto pStack : m_pSliceRefs) { for (auto pOldSlice : pStack->m_pSlices) { m_pSlices.push_back(std::make_shared(*pOldSlice.get())); diff --git a/Source/Model/Classes/NMR_ModelTriangleSet.cpp b/Source/Model/Classes/NMR_ModelTriangleSet.cpp new file mode 100644 index 0000000..b25bdf6 --- /dev/null +++ b/Source/Model/Classes/NMR_ModelTriangleSet.cpp @@ -0,0 +1,115 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +--*/ + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelTriangleSet.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + + CModelTriangleSet::CModelTriangleSet(_In_ const std::string& sName, _In_ const std::string& sIdentifier) + : m_sName (sName), m_sIdentifier (sIdentifier) + { + + } + + PModelTriangleSet CModelTriangleSet::make(_In_ const std::string& sName, _In_ const std::string& sIdentifier) + { + return std::make_shared(sName, sIdentifier); + } + + std::string CModelTriangleSet::getName() + { + return m_sName; + } + + std::string CModelTriangleSet::getIdentifier() + { + return m_sIdentifier; + } + + void CModelTriangleSet::setName(_In_ const std::string& sName) + { + m_sName = sName; + } + + void CModelTriangleSet::setIdentifier(_In_ const std::string& sIdentifier) + { + m_sIdentifier = sIdentifier; + } + + void CModelTriangleSet::clear() + { + m_sTriangles.clear(); + } + + void CModelTriangleSet::addTriangle(const uint32_t nTriangleIndex) + { + m_sTriangles.insert(nTriangleIndex); + } + + void CModelTriangleSet::removeTriangle(const uint32_t nTriangleIndex) + { + m_sTriangles.erase(nTriangleIndex); + } + + PModelTriangleSet CModelTriangleSet::duplicate(const std::string& sIdentifier) + { + auto pTriangleSet = std::make_shared(m_sName, sIdentifier); + + for (auto nTriangleIndex : m_sTriangles) + { + pTriangleSet->m_sTriangles.insert(nTriangleIndex); + } + + return pTriangleSet; + } + + void CModelTriangleSet::merge(PModelTriangleSet pTriangleSet) + { + if (pTriangleSet.get() == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + for (auto nTriangleIndex : pTriangleSet->m_sTriangles) + { + m_sTriangles.insert(nTriangleIndex); + } + + } + + std::set& CModelTriangleSet::getTriangles() + { + return m_sTriangles; + + } +} diff --git a/Source/Model/Classes/NMR_ModelVolumeData.cpp b/Source/Model/Classes/NMR_ModelVolumeData.cpp new file mode 100644 index 0000000..b9689dc --- /dev/null +++ b/Source/Model/Classes/NMR_ModelVolumeData.cpp @@ -0,0 +1,229 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelVolumeData.cpp implements the class CModelVolumeData. + +--*/ + +#include "Model/Classes/NMR_ModelVolumeData.h" + +#include "Model/Classes/NMR_ModelFunction.h" +#include "lib3mf_interfaceexception.hpp" + +namespace NMR +{ + CModelVolumeData::CModelVolumeData(ModelResourceID sResourceID, CModel * pModel) : CModelResource(sResourceID, pModel) + { + clear(); + } + + void CModelVolumeData::clear() + { + m_pComposite.reset(); + m_pColor.reset(); + m_mapProperties.clear(); + } + + nfBool CModelVolumeData::hasProperty(std::string sName) + { + std::map::iterator iIterator = m_mapProperties.find(sName); + return iIterator != m_mapProperties.end(); + } + + nfUint32 CModelVolumeData::getPropertyCount() const + { + return (nfUint32)m_mapProperties.size(); + } + + PVolumeDataProperty CModelVolumeData::getProperty(nfUint32 nIndex) + { + auto iIterator = m_mapProperties.begin(); + if (nIndex >= m_mapProperties.size()) + throw CNMRException(NMR_ERROR_INVALIDINDEX); + + while (nIndex > 0) { + nIndex--; + iIterator++; + } + return iIterator->second; + } + + PVolumeDataProperty CModelVolumeData::findProperty(std::string sName) + { + std::map::iterator iIterator = m_mapProperties.find(sName); + if (iIterator != m_mapProperties.end()) { + return iIterator->second; + } + return nullptr; + } + + void CModelVolumeData::addProperty(PVolumeDataProperty pProperty) + { + if (!pProperty) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + if (hasProperty(pProperty->getName())) { + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATAPROPERTY); + } + m_mapProperties.insert(std::make_pair(pProperty->getName(), pProperty)); + } + + PVolumeDataProperty CModelVolumeData::addProperty( + std::string sName, PModelFunction pfunction) + { + if(!pfunction) throw CNMRException(NMR_ERROR_INVALIDPARAM); + + if(hasProperty(sName)) + { + throw CNMRException( + NMR_ERROR_DUPLICATEVOLUMEDATAPROPERTY); + } + + PVolumeDataProperty pVolumeDataProperty = + std::make_shared(pfunction, sName); + m_mapProperties.insert(std::make_pair(pVolumeDataProperty->getName(), pVolumeDataProperty)); + return pVolumeDataProperty; + } + + void CModelVolumeData::removeProperty(std::string sName) + { + m_mapProperties.erase(sName); + } + + bool CModelVolumeData::hasColor() const + { + return m_pColor.get() != nullptr; + } + + void CModelVolumeData::setColor(PVolumeDataColor pColor) + { + if (!pColor) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + m_pColor = pColor; + } + + PVolumeDataColor CModelVolumeData::createColor(PModelFunction pfunction) + { + if(!pfunction) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + m_pColor = std::make_shared(pfunction); + return m_pColor; + } + + PVolumeDataColor CModelVolumeData::getColor() + { + return m_pColor; + } + + void CModelVolumeData::removeColor() + { + m_pColor.reset(); + } + + bool CModelVolumeData::hasComposite() const + { + return m_pComposite.get() != nullptr; + } + + + PVolumeDataComposite CModelVolumeData::getComposite() + { + return m_pComposite; + } + PVolumeDataComposite CModelVolumeData::createComposite(/* basematerialgroupd*/) + { + m_pComposite = std::make_shared(); + return m_pComposite; + } + + void CModelVolumeData::setComposite(PVolumeDataComposite pComposite) + { + if (!pComposite) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + m_pComposite = pComposite; + } + + void CModelVolumeData::removeComposite() + { + m_pComposite.reset(); + } + + ResourceDependencies CModelVolumeData::getDependencies() + { + ResourceDependencies dependencies; + + if (m_pColor) + { + dependencies.push_back(packageResourceIDFromResourceID(m_pColor->getFunctionResourceID())); + } + + for (auto iIterator = m_mapProperties.begin(); iIterator != m_mapProperties.end(); iIterator++) + { + PVolumeDataProperty pProperty = iIterator->second; + if (pProperty) + { + dependencies.push_back(packageResourceIDFromResourceID(pProperty->getFunctionResourceID())); + } + } + + if (m_pComposite) + { + for (nfUint32 i = 0u; i < m_pComposite->materialMappingCount(); i++) + { + dependencies.push_back(packageResourceIDFromResourceID(m_pComposite->getMaterialMapping(i)->getFunctionResourceID())); + } + + } + + return dependencies; + } + + PPackageResourceID + CModelVolumeData::packageResourceIDFromResourceID( + UniqueResourceID uniqueResourceID) + { + auto* model = getModel(); + if(!model) + { + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM, + "Model must not be nullptr."); + } + + auto referendedResource = model->findResource(uniqueResourceID); + if(!referendedResource) + { + throw ELib3MFInterfaceException( + LIB3MF_ERROR_INVALIDPARAM, + "Referenced resource must not be nullptr."); + } + + return referendedResource->getPackageResourceID(); + } +} // namespace NMR diff --git a/Source/Model/Classes/NMR_PackageResourceID.cpp b/Source/Model/Classes/NMR_PackageResourceID.cpp index 1d5dc9a..b8ecf16 100644 --- a/Source/Model/Classes/NMR_PackageResourceID.cpp +++ b/Source/Model/Classes/NMR_PackageResourceID.cpp @@ -119,6 +119,13 @@ namespace NMR { PPackageModelPath CResourceHandler::findPackageModelPath(std::string sPath) { + if (!sPath.empty()) + { + if (sPath[0] != '/') + { + return nullptr; + } + } auto it = m_PathToModelPath.find(sPath); if (it != m_PathToModelPath.end()) { diff --git a/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Ball.cpp b/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Ball.cpp index 0d8d4b5..abb926f 100644 --- a/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Ball.cpp +++ b/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Ball.cpp @@ -47,7 +47,10 @@ namespace NMR { return eModelBeamLatticeBallMode::MODELBEAMLATTICEBALLMODE_MIXED; if (strcmp(ballModeStr, XML_3MF_BEAMLATTICE_BALLMODE_ALL) == 0) return eModelBeamLatticeBallMode::MODELBEAMLATTICEBALLMODE_ALL; - return eModelBeamLatticeBallMode::MODELBEAMLATTICEBALLMODE_NONE; + if (strcmp(ballModeStr, XML_3MF_BEAMLATTICE_BALLMODE_NONE) == 0) + return eModelBeamLatticeBallMode::MODELBEAMLATTICEBALLMODE_NONE; + // Invalid ballmode value + throw CNMRException(NMR_ERROR_BEAMLATTICEINVALIDATTRIBUTE); } CModelReaderNode_BeamLattice1702_Ball::CModelReaderNode_BeamLattice1702_Ball(_In_ CModel* pModel, _In_ PModelWarnings pWarnings) diff --git a/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Balls.cpp b/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Balls.cpp index 9aeb5b4..093d14f 100644 --- a/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Balls.cpp +++ b/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_Balls.cpp @@ -76,7 +76,7 @@ namespace NMR { __NMRASSERT(pXMLReader); __NMRASSERT(pNameSpace); - if (strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICESPEC) == 0) { + if ((strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICESPEC) == 0) || (strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICEBALLSSPEC) == 0)) { if (strcmp(pChildName, XML_3MF_ELEMENT_BALL) == 0) { // Parse XML PModelReaderNode_BeamLattice1702_Ball pXMLNode = std::make_shared(m_pModel, m_pWarnings); diff --git a/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_BeamLattice.cpp b/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_BeamLattice.cpp index 37c2ce3..4c0a0dc 100644 --- a/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_BeamLattice.cpp +++ b/Source/Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_BeamLattice.cpp @@ -93,7 +93,7 @@ namespace NMR { void CModelReaderNode_BeamLattice1702_BeamLattice::validateBallOptions(_In_ PModelWarnings pWarnings) { if (m_pMesh->getBeamLatticeBallMode() != eModelBeamLatticeBallMode::MODELBEAMLATTICEBALLMODE_NONE) { - if (m_pMesh->getDefaultBallRadius() <= 0 && m_pMesh->getDefaultBallRadius() >= XML_3MF_MAXIMUMCOORDINATEVALUE) { + if (m_pMesh->getDefaultBallRadius() <= 0 || m_pMesh->getDefaultBallRadius() >= XML_3MF_MAXIMUMCOORDINATEVALUE) { pWarnings->addException(CNMRException(NMR_ERROR_BEAMLATTICEINVALIDATTRIBUTE), mrwInvalidOptionalValue); } } @@ -161,8 +161,27 @@ namespace NMR { void CModelReaderNode_BeamLattice1702_BeamLattice::OnNSAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue, _In_z_ const nfChar * pNameSpace) { - + __NMRASSERT(pAttributeName); + __NMRASSERT(pAttributeValue); + __NMRASSERT(pNameSpace); + // Accept namespaced ball attributes (balls extension namespace) + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICEBALLSSPEC) == 0) { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_BEAMLATTICE_BALLMODE) == 0) { + m_pMesh->setBeamLatticeBallMode(stringToBallMode(pAttributeValue)); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_BEAMLATTICE_BALLRADIUS) == 0) { + nfDouble dValue = fnStringToDouble(pAttributeValue); + if (std::isnan(dValue) || (dValue <= 0) || (dValue > XML_3MF_MAXIMUMCOORDINATEVALUE)) + throw CNMRException(NMR_ERROR_BEAMLATTICEINVALIDATTRIBUTE); + m_dDefaultBallRadius = dValue; + m_pMesh->setDefaultBallRadius(dValue); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ATTRIBUTE), mrwInvalidOptionalValue); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ATTRIBUTE), mrwInvalidOptionalValue); } void CModelReaderNode_BeamLattice1702_BeamLattice::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) @@ -171,7 +190,7 @@ namespace NMR { __NMRASSERT(pXMLReader); __NMRASSERT(pNameSpace); - if (strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICESPEC) == 0) { + if ((strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICESPEC) == 0) || (strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICEBALLSSPEC) == 0)) { if (strcmp(pChildName, XML_3MF_ELEMENT_BEAMS) == 0) { PModelReaderNode pXMLNode = std::make_shared(m_pModel, m_pMesh, m_dDefaultRadius, m_eDefaultCapMode, m_pWarnings); diff --git a/Source/Model/Reader/NMR_KeyStoreOpcPackageReader.cpp b/Source/Model/Reader/NMR_KeyStoreOpcPackageReader.cpp index 50a3296..7963cd2 100644 --- a/Source/Model/Reader/NMR_KeyStoreOpcPackageReader.cpp +++ b/Source/Model/Reader/NMR_KeyStoreOpcPackageReader.cpp @@ -176,7 +176,7 @@ namespace NMR { ctx.m_sKekDecryptData.m_pAccessRight = accessRight; std::vector const & closedKey = accessRight->getCipherValue(); std::vector openedKey; - size_t decrypted = ctx.m_fnWrap(closedKey, openedKey, ctx.m_sKekDecryptData); + nfUint64 decrypted = ctx.m_fnWrap(closedKey, openedKey, ctx.m_sKekDecryptData); if (decrypted) { rdg->setKey(openedKey); break; diff --git a/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp b/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp index 710ac88..a421891 100644 --- a/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp +++ b/Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp @@ -85,7 +85,11 @@ namespace NMR { strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_PRODUCTIONSPEC) != 0 && strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_SLICESPEC) != 0 && strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_BEAMLATTICESPEC) != 0 && - strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_SECURECONTENTSPEC) != 0 ) + strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_BEAMLATTICEBALLSSPEC) != 0 && + strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_SECURECONTENTSPEC) != 0 && + strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_VOLUMETRICSPEC) != 0 && + strcmp(sExtensionURI.c_str(), XML_3MF_NAMESPACE_IMPLICITSPEC) != 0 + ) { m_pWarnings->addWarning(NMR_ERROR_REQUIREDEXTENSIONNOTSUPPORTED, mrwInvalidMandatoryValue); } diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp index c8d533f..70552a1 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp @@ -43,7 +43,7 @@ NMR_ModelReaderNode_KeyStoreCipherValue.h defines the Model Reader Node class th #include "Common/NMR_Exception_Windows.h" #include "Common/NMR_StringUtils.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" namespace NMR { namespace ParserUtils { @@ -107,22 +107,31 @@ namespace NMR { __NMRASSERT(pChildName); __NMRASSERT(pXMLReader); __NMRASSERT(pNameSpace); - if (strcmp(pNameSpace, XML_3MF_NAMESPACE_SECURECONTENTSPEC) == 0) { - if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_IV) == 0) { - PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); - pXMLNode->parseXML(pXMLReader); - m_iv = base64_decode(pXMLNode->getValue()); - } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_TAG) == 0) { - PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); - pXMLNode->parseXML(pXMLReader); - m_tag = base64_decode(pXMLNode->getValue()); - } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_AAD) == 0) { - PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); - pXMLNode->parseXML(pXMLReader); - m_aad = base64_decode(pXMLNode->getValue()); - } else { - m_pWarnings->addWarning(NMR_ERROR_NAMESPACE_INVALID_ELEMENT, mrwInvalidOptionalValue); + try{ + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_SECURECONTENTSPEC) == 0) { + if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_IV) == 0) { + PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + std::string result = base64_decode(pXMLNode->getValue()); + m_iv = std::vector(result.begin(), result.end()); + } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_TAG) == 0) { + PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + std::string result = base64_decode(pXMLNode->getValue()); + m_tag = std::vector(result.begin(), result.end()); + } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_AAD) == 0) { + PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + std::string result = base64_decode(pXMLNode->getValue()); + m_aad = std::vector(result.begin(), result.end()); + } else { + m_pWarnings->addWarning(NMR_ERROR_NAMESPACE_INVALID_ELEMENT, mrwInvalidOptionalValue); + } } } + catch (...) { + // base64_decode throws an exception if the input is not valid base64 + m_pWarnings->addException(CNMRException(NMR_ERROR_KEYSTOREINVALIDENCODING), mrwInvalidOptionalValue); + } } } diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp index d0a0420..5b9dcc5 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp @@ -41,7 +41,7 @@ NMR_ModelReaderNode_KeyStoreCipherValue.h defines the Model Reader Node class th #include "Common/NMR_StringUtils.h" #include "Model/Reader/NMR_ModelReaderNode_StringValue.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" namespace NMR { @@ -71,7 +71,14 @@ namespace NMR { && strcmp(pChildName, XML_3MF_ELEMENT_CIPHERVALUE) == 0) { PModelReaderNode_StringValue pNode = std::make_shared(m_pWarnings); pNode->parseXML(pXMLReader); - m_sCipherValue = base64_decode(pNode->getValue()); + try { + std::string result = base64_decode(pNode->getValue()); + m_sCipherValue = std::vector(result.begin(), result.end()); + } + catch (...) { + // base64_decode throws an exception if the input is not valid base64 + m_pWarnings->addException(CNMRException(NMR_ERROR_KEYSTOREINVALIDENCODING), NMR::eModelWarningLevel::mrwInvalidMandatoryValue); + } } } diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp index b1ac663..8c43615 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp @@ -40,7 +40,7 @@ NMR_ModelReaderNode_KeyStoreCipherValue.h defines the Model Reader Node class th #include "Common/NMR_Exception_Windows.h" #include "Common/NMR_StringUtils.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" namespace NMR { diff --git a/Source/Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.cpp b/Source/Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.cpp new file mode 100644 index 0000000..bdb3ed1 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.cpp @@ -0,0 +1,126 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Helper methods for reading implicit ports + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h" +#include "Common/NMR_Exception.h" +#include + +namespace NMR +{ + namespace implicit + { + const char * portTypeToRefName(Lib3MF::eImplicitPortType type) + { + switch (type) + { + case Lib3MF::eImplicitPortType::Scalar: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR_REF; + case Lib3MF::eImplicitPortType::Vector: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR_REF; + case Lib3MF::eImplicitPortType::Matrix: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX_REF; + case Lib3MF::eImplicitPortType::ResourceID: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_REF; + default: + return "Invalid"; + } + } + + const char * portTypeToName(Lib3MF::eImplicitPortType type) + { + switch (type) + { + case Lib3MF::eImplicitPortType::Scalar: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR; + case Lib3MF::eImplicitPortType::Vector: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR; + case Lib3MF::eImplicitPortType::Matrix: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX; + case Lib3MF::eImplicitPortType::ResourceID: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_ID; + default: + return "Invalid"; + } + } + + bool portTypeFromRefName(std::string const & name, Lib3MF::eImplicitPortType & resultType) + { + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR_REF) + { + resultType = Lib3MF::eImplicitPortType::Scalar; + return true; + } + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR_REF) + { + resultType = Lib3MF::eImplicitPortType::Vector; + return true; + } + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX_REF) + { + resultType = Lib3MF::eImplicitPortType::Matrix; + return true; + } + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_REF) + { + resultType = Lib3MF::eImplicitPortType::ResourceID; + return true; + } + + return false; + } + + bool portTypeFromName(std::string const & name, Lib3MF::eImplicitPortType & resultType) + { + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR) + { + resultType = Lib3MF::eImplicitPortType::Scalar; + return true; + } + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR) + { + resultType = Lib3MF::eImplicitPortType::Vector; + return true; + } + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX) + { + resultType = Lib3MF::eImplicitPortType::Matrix; + return true; + } + if (name == XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_ID) + { + resultType = Lib3MF::eImplicitPortType::ResourceID; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.cpp new file mode 100644 index 0000000..b0f55f8 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.cpp @@ -0,0 +1,175 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for FunctionFormImage3D + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelFunctionFromImage3D.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + NMR::CModelReaderNode_FunctionFromImage3D::CModelReaderNode_FunctionFromImage3D( + CModel * pModel, + + PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + , m_pModel(pModel) + { + __NMRASSERT(pModel); + } + + void CModelReaderNode_FunctionFromImage3D::parseXML(CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Attributes + parseAttributes(pXMLReader); + + // Create FunctionFromImage3D + m_pFunctionFromImage3D = + std::make_shared(m_nID, m_pModel); + m_pFunctionFromImage3D->setDisplayName(m_displayName); + m_pFunctionFromImage3D->setImage3DModelResourceID(m_imageModelResourceID); + m_pFunctionFromImage3D->setTileStyleU(m_tileStyleU); + m_pFunctionFromImage3D->setTileStyleV(m_tileStyleV); + m_pFunctionFromImage3D->setTileStyleW(m_tileStyleW); + m_pFunctionFromImage3D->setFilter(m_filter); + m_pFunctionFromImage3D->setOffset(m_offset); + m_pFunctionFromImage3D->setScale(m_scale); + + + // Parse Content + parseContent(pXMLReader); + + m_pModel->addResource(m_pFunctionFromImage3D); + } + + eModelTextureTileStyle fnStringToModelTextureTileStyle(const std::string & sValue) + { + if (sValue == XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLE_WRAP) + { + return eModelTextureTileStyle::MODELTEXTURETILESTYLE_WRAP; + } + else if (sValue == XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLE_MIRROR) + { + return eModelTextureTileStyle::MODELTEXTURETILESTYLE_MIRROR; + } + else if (sValue == XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLE_CLAMP) + { + return eModelTextureTileStyle::MODELTEXTURETILESTYLE_CLAMP; + } + else if (sValue == XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLE_NONE) + { + return eModelTextureTileStyle::MODELTEXTURETILESTYLE_NONE; + } + else + { + throw CNMRException(NMR_ERROR_INVALIDTILESTYLE); + } + } + + eModelTextureFilter fnStringToModelTextureFilter(const std::string & sValue) + { + if (sValue == XML_3MF_ATTRIBUTE_TEXTURE2D_FILTER_AUTO) + { + return eModelTextureFilter::MODELTEXTUREFILTER_AUTO; + } + else if (sValue == XML_3MF_ATTRIBUTE_TEXTURE2D_FILTER_LINEAR) + { + return eModelTextureFilter::MODELTEXTUREFILTER_LINEAR; + } + else if (sValue == XML_3MF_ATTRIBUTE_TEXTURE2D_FILTER_NEAREST) + { + return eModelTextureFilter::MODELTEXTUREFILTER_NEAREST; + } + else + { + throw CNMRException(NMR_ERROR_INVALIDFILTER); + } + } + + void CModelReaderNode_FunctionFromImage3D::OnAttribute(const nfChar * pAttributeName, + const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_ID) == 0) + { + m_nID = fnStringToUint32(pAttributeValue); + } + else if ((strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_IMAGE3DID_DEPRECATED) == 0) + || (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_IMAGE3DID) == 0)) + { + m_imageModelResourceID = fnStringToUint32(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_DISPLAY_NAME) == 0) + { + m_displayName = std::string{pAttributeValue}; + } + else if ((strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_OFFSET_DEPRECATED) == 0) + || (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_OFFSET) == 0)) + { + m_offset = fnStringToDouble(pAttributeValue); + } + else if ((strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_SCALE_DEPRECATED) == 0) + || (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_SCALE) == 0)) + { + m_scale = fnStringToDouble(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEU) == 0) + { + m_tileStyleU = fnStringToModelTextureTileStyle(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEV) == 0) + { + m_tileStyleV = fnStringToModelTextureTileStyle(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEW) == 0) + { + m_tileStyleW = fnStringToModelTextureTileStyle(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_FILTER) == 0) + { + m_filter = fnStringToModelTextureFilter(pAttributeValue); + } + else + { + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ATTRIBUTE), + mrwInvalidOptionalValue); + } + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.cpp new file mode 100644 index 0000000..e661028 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.cpp @@ -0,0 +1,136 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for implicit function ressources + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.h" + +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + + const implicit::NodeTypes CModelReaderNode_ImplicitFunction::m_nodeTypes; + + NMR::CModelReaderNode_ImplicitFunction::CModelReaderNode_ImplicitFunction( + CModel * pModel, + + PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + , m_pModel(pModel) + { + __NMRASSERT(pModel); + } + + void CModelReaderNode_ImplicitFunction::parseXML(CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Attributes + parseAttributes(pXMLReader); + + // Create Implicit Function + m_pImplicitFunction = std::make_shared(m_nID, m_pModel); + m_pImplicitFunction->setDisplayName(m_displayName); + + // Parse Content + parseContent(pXMLReader); + + m_pModel->addResource(m_pImplicitFunction); + } + + void CModelReaderNode_ImplicitFunction::OnAttribute(const nfChar * pAttributeName, + const nfChar * pAttributeValue) + { + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_ID) == 0) + { + m_nID = fnStringToUint32(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_DISPLAY_NAME) == 0) + { + m_displayName = pAttributeValue; + } + } + void CModelReaderNode_ImplicitFunction::OnNSChildElement(const nfChar * pChildName, + const nfChar * pNameSpace, + CXmlReader * pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + // inputs + if (strcmp(pChildName, XML_3MF_ELEMENT_IMPLICIT_FUNCTION_INPUT) == 0) + { + auto node = std::make_shared( + m_pImplicitFunction.get(), m_pWarnings); + node->parseXML(pXMLReader); + return; + } + + // output + if (strcmp(pChildName, XML_3MF_ELEMENT_IMPLICIT_FUNCTION_OUTPUT) == 0) + { + auto node = std::make_shared( + m_pImplicitFunction.get(), m_pWarnings); + node->parseXML(pXMLReader); + return; + } + + auto const & nodeTypes = m_nodeTypes.getTypes(); + + for (auto const & nodeType : nodeTypes) // maeh, no structured bindings in C++11 + { + // first is the node type, second is the node type info + if (strcmp(pChildName, nodeType.second.getName().c_str()) == 0) + { + auto implicitNode = m_pImplicitFunction->addNode(nodeType.first, Lib3MF::eImplicitNodeConfiguration::Default); + auto node = + NMR::CModelReaderNode_Implicit_Node(m_pModel, implicitNode.get(), m_pWarnings); + node.parseXML(pXMLReader); + + return; + } + } + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.cpp new file mode 100644 index 0000000..fc2c6a9 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.cpp @@ -0,0 +1,95 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for a single input of a function for implicit modelling + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + CModelReaderNode_Implicit_Function_Input::CModelReaderNode_Implicit_Function_Input( + CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings, + Lib3MF::eImplicitPortType portType) + : CModelReaderNode(pWarnings) + , m_portType(portType) + { + + __NMRASSERT(pParentFunction); + m_pParentFunction = pParentFunction; + } + + void CModelReaderNode_Implicit_Function_Input::parseXML(CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Attributes + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + + // Create Implicit Port + createInput(); + } + + void CModelReaderNode_Implicit_Function_Input::OnAttribute(const nfChar * pAttributeName, + const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID) == 0) + { + m_identifier = pAttributeValue; + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME) == 0) + { + m_displayName = pAttributeValue; + } + } + + void CModelReaderNode_Implicit_Function_Input::createInput() + { + auto input = m_pParentFunction->findInput(m_identifier); + if (!input) + { + input = m_pParentFunction->addInput(m_identifier, m_displayName, m_portType); + } + input->setDisplayName(m_displayName); + } + +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.cpp new file mode 100644 index 0000000..72c8125 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.cpp @@ -0,0 +1,77 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for ports of a function for implicit modelling + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Inputs.h" +#include "Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Input.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + CModelReaderNode_Implicit_Function_Inputs::CModelReaderNode_Implicit_Function_Inputs( + CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + __NMRASSERT(pParentFunction); + m_pImplicitFunction = pParentFunction; + } + + void CModelReaderNode_Implicit_Function_Inputs::parseXML(_In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + void CModelReaderNode_Implicit_Function_Inputs::OnNSChildElement(const nfChar * pChildName, + const nfChar * pNameSpace, + CXmlReader * pXMLReader) + { + Lib3MF::eImplicitPortType portType; + if (implicit::portTypeFromName(pChildName, portType)) + { + auto pXMLNode = std::make_shared( + m_pImplicitFunction, m_pWarnings, portType); + pXMLNode->parseXML(pXMLReader); + } + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.cpp new file mode 100644 index 0000000..34c4238 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.cpp @@ -0,0 +1,102 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for an output element + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +#include + +namespace NMR +{ + CModelReaderNode_Implicit_Function_Output::CModelReaderNode_Implicit_Function_Output( + CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings, + Lib3MF::eImplicitPortType portType) + : CModelReaderNode(pWarnings) + , m_portType(portType) + { + + __NMRASSERT(pParentFunction); + m_pParentFunction = pParentFunction; + } + + void CModelReaderNode_Implicit_Function_Output::parseXML(CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Attributes + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + + // Create Port + createOutput(); + } + + void CModelReaderNode_Implicit_Function_Output::OnAttribute(const nfChar * pAttributeName, + const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID) == 0) + { + m_identifier = pAttributeValue; + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME) == 0) + { + m_displayName = pAttributeValue; + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_REFERENCE) == 0) + { + m_reference = pAttributeValue; + } + } + + void CModelReaderNode_Implicit_Function_Output::createOutput() + { + auto output = m_pParentFunction->findOutput(m_identifier); + if (!output) + { + output = m_pParentFunction->addOutput(m_identifier, m_displayName, m_portType); + } + output->setDisplayName(m_displayName); + output->setReference(m_reference); + } + +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.cpp new file mode 100644 index 0000000..b148e16 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.cpp @@ -0,0 +1,78 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for inputs (arguments) of a function for implicit modelling + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Outputs.h" +#include "Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function_Output.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + CModelReaderNode_Implicit_Function_Outputs::CModelReaderNode_Implicit_Function_Outputs( + CModelImplicitFunction * pParentFunction, + PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + __NMRASSERT(pParentFunction); + m_pImplicitFunction = pParentFunction; + } + + void CModelReaderNode_Implicit_Function_Outputs::parseXML(_In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + void CModelReaderNode_Implicit_Function_Outputs::OnNSChildElement(const nfChar * pChildName, + const nfChar * pNameSpace, + CXmlReader * pXMLReader) + { + Lib3MF::eImplicitPortType portType; + if (implicit::portTypeFromRefName(pChildName, portType)) + { + auto XMLNode = + CModelReaderNode_Implicit_Function_Output(m_pImplicitFunction, m_pWarnings, portType); + + XMLNode.parseXML(pXMLReader); + } + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.cpp new file mode 100644 index 0000000..9be55c8 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.cpp @@ -0,0 +1,192 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for nodes of graph representing a function for implicit modelling + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +#include + +namespace NMR +{ + CModelReaderNode_Implicit_Node::CModelReaderNode_Implicit_Node( + _In_ CModel * pModel, + _In_ CModelImplicitNode * pImplicitNode, + _In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + __NMRASSERT(pModel); + __NMRASSERT(pImplicitNode); + + m_pModel = pModel; + m_pImplicitNode = pImplicitNode; + } + + void CModelReaderNode_Implicit_Node::parseXML(_In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Attributes + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + Lib3MF::sMatrix4x4 matFromString(std::string const & str) + { + Lib3MF::sMatrix4x4 mat; + std::stringstream ss(str); + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + if (!(ss >> mat.m_Field[i][j])) + { + throw CNMRException(NMR_ERROR_NOTENOUGHVALUESINMATRIXSTRING); + } + } + } + + // Check if there is any extra content in the input string + std::string extra; + if (ss >> extra && !extra.empty()) + { + throw CNMRException(NMR_ERROR_TOOMANYVALUESINMATRIXSTRING); + } + + return mat; + } + + void CModelReaderNode_Implicit_Node::OnAttribute(_In_z_ const nfChar * pAttributeName, + _In_z_ const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_ID) == 0) + { + m_pImplicitNode->setIdentifier(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_DISPLAY_NAME) == 0) + { + m_pImplicitNode->setDisplayName(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_TAG) == 0) + { + m_pImplicitNode->setTag(pAttributeValue); + } + else if (m_pImplicitNode->getNodeType() == Lib3MF::eImplicitNodeType::Constant && + strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VALUE) == 0) + { + m_pImplicitNode->setConstant(strtod(pAttributeValue, nullptr)); + } + else if (m_pImplicitNode->getNodeType() == Lib3MF::eImplicitNodeType::ConstVec) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_X) == 0) + { + m_vector.m_Coordinates[0] = strtod(pAttributeValue, nullptr); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_Y) == 0) + { + m_vector.m_Coordinates[1] = strtod(pAttributeValue, nullptr); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_Z) == 0) + { + m_vector.m_Coordinates[2] = strtod(pAttributeValue, nullptr); + } + m_pImplicitNode->setVector(m_vector); + } + else if (m_pImplicitNode->getNodeType() == Lib3MF::eImplicitNodeType::ConstMat) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_MATRIX) == 0) + { + m_pImplicitNode->setMatrix(matFromString(pAttributeValue)); + } + } + else if (m_pImplicitNode->getNodeType() == Lib3MF::eImplicitNodeType::ConstResourceID) + { + if ((strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_RESOURCE_ID_VALUE_DEPRECATED) == 0) + || (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VALUE) == 0)) + { + m_pImplicitNode->setModelResourceID(std::stoi(pAttributeValue)); + } + } + else if (m_pImplicitNode->getNodeType() == Lib3MF::eImplicitNodeType::BeamLattice) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_ACCURATERANGE) == 0) + { + m_pImplicitNode->setAccurateRange(strtod(pAttributeValue, nullptr)); + } + } + else if (m_pImplicitNode->getNodeType() == Lib3MF::eImplicitNodeType::FunctionGradient || + m_pImplicitNode->getNodeType() == Lib3MF::eImplicitNodeType::NormalizeDistance) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_SCALAROUTPUT) == 0) + { + m_pImplicitNode->setScalarOutputName(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VECTORINPUT) == 0) + { + m_pImplicitNode->setVectorInputName(pAttributeValue); + } + } + } + + void NMR::CModelReaderNode_Implicit_Node::OnNSChildElement(_In_z_ const nfChar * pChildName, + _In_z_ const nfChar * pNameSpace, + _In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if (strcmp(pChildName, XML_3MF_ELEMENT_IMPLICIT_NODE_INPUT) == 0) + { + auto pXMLNode = + std::make_shared(m_pImplicitNode, m_pWarnings); + pXMLNode->parseXML(pXMLReader); + } + else if (strcmp(pChildName, XML_3MF_ELEMENT_IMPLICIT_NODE_OUTPUT) == 0) + { + auto pXMLNode = std::make_shared( + m_pImplicitNode, m_pWarnings); + pXMLNode->parseXML(pXMLReader); + } + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.cpp new file mode 100644 index 0000000..60302c4 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.cpp @@ -0,0 +1,77 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for ports of a node of a graph representing a function for implicit modelling + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Inputs.h" +#include "Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + CModelReaderNode_Implicit_Node_Inputs::CModelReaderNode_Implicit_Node_Inputs( + _In_ CModelImplicitNode * pParentNode, + _In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + __NMRASSERT(pParentNode); + m_pImplicitNode = pParentNode; + } + + void CModelReaderNode_Implicit_Node_Inputs::parseXML(_In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + void CModelReaderNode_Implicit_Node_Inputs::OnNSChildElement(const nfChar * pChildName, + const nfChar * pNameSpace, + CXmlReader * pXMLReader) + { + Lib3MF::eImplicitPortType portType; + if (implicit::portTypeFromRefName(pChildName, portType)) + { + auto pXMLNode = CModelReaderNode_Implicit_Port( + m_pImplicitNode, m_pWarnings, portType, ImplicitPortInOut::Input); + pXMLNode.parseXML(pXMLReader); + } + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.cpp new file mode 100644 index 0000000..2c4fec2 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.cpp @@ -0,0 +1,78 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for output ports of a node + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Node_Outputs.h" +#include "Model/Reader/Volumetric2201/NMR_Implicit_PortType_Convert.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + CModelReaderNode_Implicit_Node_Outputs::CModelReaderNode_Implicit_Node_Outputs( + _In_ CModelImplicitNode * pParentNode, + _In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + __NMRASSERT(pParentNode); + m_pImplicitNode = pParentNode; + } + + void CModelReaderNode_Implicit_Node_Outputs::parseXML(_In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + void CModelReaderNode_Implicit_Node_Outputs::OnNSChildElement(const nfChar * pChildName, + const nfChar * pNameSpace, + CXmlReader * pXMLReader) + { + + Lib3MF::eImplicitPortType portType; + if (implicit::portTypeFromName(pChildName, portType)) + { + auto pXMLNode = CModelReaderNode_Implicit_Port( + m_pImplicitNode, m_pWarnings, portType, ImplicitPortInOut::Output); + pXMLNode.parseXML(pXMLReader); + } + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.cpp new file mode 100644 index 0000000..cfeba57 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.cpp @@ -0,0 +1,119 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for a single port of a node of a graph representing a function for implicit modelling + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Port.h" + +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" + +namespace NMR +{ + CModelReaderNode_Implicit_Port::CModelReaderNode_Implicit_Port(CModelImplicitNode * pParentNode, + PModelWarnings pWarnings, + Lib3MF::eImplicitPortType portType, + ImplicitPortInOut inOut) + : CModelReaderNode(pWarnings) + , m_portType(portType), + m_inOut(inOut) + { + __NMRASSERT(pParentNode); + m_pParentNode = pParentNode; + } + + void CModelReaderNode_Implicit_Port::parseXML(CXmlReader * pXMLReader) + { + __NMRASSERT(pXMLReader); + + // Parse name + parseName(pXMLReader); + + // Parse Attributes + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + + // Create Implicit Port + switch (m_inOut) + { + case ImplicitPortInOut::Input: + createInput(); + break; + case ImplicitPortInOut::Output: + createOutput(); + break; + } + } + + void CModelReaderNode_Implicit_Port::OnAttribute(const nfChar * pAttributeName, + const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID) == 0) + { + m_identifier = pAttributeValue; + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME) == 0) + { + m_displayName = pAttributeValue; + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMPLICIT_PORT_REFERENCE) == 0) + { + m_reference = pAttributeValue; + } + } + + void CModelReaderNode_Implicit_Port::createInput() + { + auto input = m_pParentNode->findInput(m_identifier); + if (!input) + { + input = m_pParentNode->addInput(m_identifier, m_displayName); + } + input->setType(m_portType); + input->setDisplayName(m_displayName); + input->setReference(m_reference); + } + + void NMR::CModelReaderNode_Implicit_Port::createOutput() + { + auto output = m_pParentNode->findOutput(m_identifier); + if (!output) + { + output = m_pParentNode->addOutput(m_identifier, m_displayName); + } + output->setType(m_portType); + output->setDisplayName(m_displayName); + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.cpp new file mode 100644 index 0000000..ee34fe4 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.cpp @@ -0,0 +1,246 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Reader for boundary shape objects + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" +#include "Model/Classes/NMR_ModelLevelSetObject.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_ModelConstants.h" + +namespace NMR +{ + + NMR::CModelReaderNode_LevelSet::CModelReaderNode_LevelSet( + CModel * pModel, PModelLevelSetObject levelSet, + PModelWarnings pWarnings, PProgressMonitor pProgressMonitor) + : CModelReaderNode(pWarnings, pProgressMonitor), m_parentModel(pModel), m_pLevelSet(std::move(levelSet)) + { + + } + + void CModelReaderNode_LevelSet::parseXML(CXmlReader* pXMLReader) + { + __NMRASSERT(pXMLReader); + // Parse name + parseName(pXMLReader); + + // Parse Attributes + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + + PPackageResourceID functionPackageId = m_parentModel->findPackageResourceID( + m_parentModel->currentPath(), m_nFunctionID); + if(!functionPackageId.get()) + { + throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE); + } + + auto pFunction = m_parentModel->findFunction(functionPackageId->getUniqueID()); + if(!pFunction) + { + throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + } + + m_pLevelSet->setFunction(pFunction); + + PPackageResourceID meshPackageId = m_parentModel->findPackageResourceID( + m_parentModel->currentPath(), m_nMeshID); + + if(!meshPackageId.get()) + { + throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE); + } + + PModelResource pMeshResource = m_parentModel->findResource(meshPackageId); + + if(!pMeshResource) + { + throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + } + + PModelMeshObject pMeshObject = std::dynamic_pointer_cast(pMeshResource); + + if(!pMeshObject) + { + throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + } + + m_pLevelSet->setMesh(pMeshObject); + + if(m_bHasTransform) + { + m_pLevelSet->setTransform(m_Transform); + } + + if(m_bHasChannel) + { + m_pLevelSet->setChannelName(m_sChannel); + } + + if(m_bHasMeshBBoxOnly) + { + m_pLevelSet->setMeshBBoxOnly(m_meshBBoxOnly); + } + + if(m_bHasMinFeatureSize) + { + m_pLevelSet->setMinFeatureSize(m_dMinFeatureSize); + } + + if(m_bHasFallBackValue) + { + m_pLevelSet->setFallBackValue(m_dFallBackValue); + } + + if(m_bHasVolumeDataID) + { + PPackageResourceID volumePackageId = + m_parentModel->findPackageResourceID(m_parentModel->currentPath(), + m_nVolumeDataID); + + if(!volumePackageId.get()) + { + throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE); + } + + auto pVolumeData = m_parentModel->findVolumeData( + volumePackageId->getUniqueID()); + + m_pLevelSet->setVolumeData(pVolumeData); + } + } + + void CModelReaderNode_LevelSet::OnAttribute( + const nfChar* pAttributeName, const nfChar* pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_ID) == 0) + { + m_resID = fnStringToUint32(pAttributeValue); + } + + if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_FUNCTION_ID) == 0) + { + if(m_bHasFunctionID) + { + throw CNMRException( + NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_FUNCTION_ID); + } + m_bHasFunctionID = true; + m_nFunctionID = fnStringToUint32(pAttributeValue); + } + else if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_CHANNEL) == 0) + { + if(m_bHasChannel) + { + throw CNMRException(NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_CHANNEL); + } + m_bHasChannel = true; + m_sChannel = pAttributeValue; + } + else if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_TRANSFORM) == 0) + { + if(m_bHasTransform) + { + throw CNMRException( + NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_TRANSFORM); + } + m_bHasTransform = true; + m_Transform = fnMATRIX3_fromString(pAttributeValue); + } + else if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MIN_FEATURE_SIZE) == 0) + { + if(m_bHasMinFeatureSize) + { + throw CNMRException( + NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_MIN_FEATURE_SIZE); + } + m_bHasMinFeatureSize = true; + m_dMinFeatureSize = fnStringToDouble(pAttributeValue); + } + else if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MESH_BBOX_ONLY) == 0) + { + m_bHasMeshBBoxOnly = true; + m_meshBBoxOnly = !(std::string(pAttributeValue) == "false"); + } + else if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_FALLBACK_VALUE) == 0) + { + if(m_bHasFallBackValue) + { + throw CNMRException( + NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_FALLBACK_VALUE); + } + m_bHasFallBackValue = true; + m_dFallBackValue = fnStringToDouble(pAttributeValue); + } + else if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MESH_ID) == 0) + { + if(m_bHasMeshID) + { + throw CNMRException( + NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_MESH_ID); + } + m_bHasMeshID = true; + m_nMeshID = fnStringToUint32(pAttributeValue); + } + else if(strcmp(pAttributeName, + XML_3MF_ATTRIBUTE_MESH_VOLUMEDATA) == 0) + { + if(m_bHasVolumeDataID) + { + throw CNMRException( + NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_VOLUME_ID); + } + m_bHasVolumeDataID = true; + m_nVolumeDataID = fnStringToUint32(pAttributeValue); + } + } + void CModelReaderNode_LevelSet::OnNSChildElement( + const nfChar* pChildName, const nfChar* pNameSpace, + CXmlReader* pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + } +} // namespace NMR diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.cpp new file mode 100644 index 0000000..e4c4eaa --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.cpp @@ -0,0 +1,156 @@ +/*++ + +Copyright (C) 2020 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +CModelReaderNode_Volumetric2201_Color.cpp covers the official 3MF volumetric extension. + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_Model.h" + +#include "Common/NMR_StringUtils.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" + +namespace NMR { + + + CModelReaderNode_Volumetric2201_Color::CModelReaderNode_Volumetric2201_Color(_In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + } + + void CModelReaderNode_Volumetric2201_Color::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + PVolumeDataColor CModelReaderNode_Volumetric2201_Color::MakeColor(_In_ CModel* pModel) + { + if (!pModel) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + if (!m_bHasFieldID) { + throw CNMRException(NMR_ERROR_MISSINGVOLUMEDATAFIELDID); + } + + PPackageResourceID pID = pModel->findPackageResourceID(pModel->currentPath(), m_nFieldID); + if (!pID.get()) { + throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE); + } + + auto pColorFunction = pModel->findFunction(pID->getUniqueID()); + if (!pColorFunction.get()) { + throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + } + + PVolumeDataColor pColor = std::make_shared(pColorFunction); + + if (m_bHasTransform) + { + pColor->setTransform(m_Transform); + } + + if (m_bHasChannel) + { + pColor->setChannelName(m_sChannel); + } + + if (m_bHasMinFeatureSize) + { + pColor->setMinFeatureSize(m_dMinFeatureSize); + } + + if (m_bHasFallBackValue) + { + pColor->setFallBackValue(m_dFallBackValue); + } + return pColor; + } + + void CModelReaderNode_Volumetric2201_Color::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_TRANSFORM) == 0) { + if (m_bHasTransform) + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATATRANSFORM); + m_bHasTransform = true; + + m_Transform = fnMATRIX3_fromString(pAttributeValue); + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID) == 0) { + if (m_bHasFieldID) + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATAFIELDID); + m_bHasFieldID = true; + + m_nFieldID = fnStringToUint32(pAttributeValue); + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_CHANNEL) == 0) { + if (m_bHasChannel) + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATACHANNEL); + + m_bHasChannel = true; + m_sChannel = pAttributeValue; + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE) == 0) { + if (m_bHasMinFeatureSize) + throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_MINFEATURESIZE); + + m_bHasMinFeatureSize = true; + m_dMinFeatureSize = fnStringToDouble(pAttributeValue); + } + + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE) == 0) { + if (m_bHasFallBackValue) + throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE); + + m_bHasFallBackValue = true; + m_dFallBackValue = fnStringToDouble(pAttributeValue); + } + } + + void CModelReaderNode_Volumetric2201_Color::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.cpp new file mode 100644 index 0000000..08eaffe --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.cpp @@ -0,0 +1,117 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_Image3D.cpp covers the official 3MF volumetric extension. + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelImage3D.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_Model.h" + +#include "Common/NMR_StringUtils.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" + +namespace NMR { + + + CModelReaderNode_Volumetric2201_Image3D::CModelReaderNode_Volumetric2201_Image3D(_In_ CModel * pModel, _In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings), + m_pModel (pModel), + m_modelResourceId (0), + m_bHasName (false) + { + if (pModel == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + } + + void CModelReaderNode_Volumetric2201_Image3D::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + //if (!m_bHasName) + // m_pWarnings->addException(CNMRException(NMR_ERROR_MISSINGIMAGE3DNAME), mrwMissingMandatoryValue); + + if (m_modelResourceId == 0) + throw CNMRException(NMR_ERROR_MISSINGMODELRESOURCEID); + + // Parse Content + parseContent(pXMLReader); + + m_pModel->addResource(m_pImage3D); + } + + + void CModelReaderNode_Volumetric2201_Image3D::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMAGE3D_ID) == 0) { + if (m_modelResourceId != 0) + throw CNMRException(NMR_ERROR_DUPLICATERESOURCEID); + + // Convert to integer and make a input and range check! + m_modelResourceId = fnStringToUint32(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMAGE3D_NAME) == 0) { + if (m_bHasName) + throw CNMRException(NMR_ERROR_DUPLICATEIMAGE3DNAME); + + m_bHasName = true; + m_sName = pAttributeName; + } + } + + void CModelReaderNode_Volumetric2201_Image3D::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_VOLUMETRICSPEC) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_IMAGESTACK) == 0) + { + PModelImageStack pImageStack = CModelImageStack::make(m_modelResourceId, m_pModel, 0, 0, 0); + + PModelReaderNode_Volumetric2201_ImageStack pXMLNode = std::make_shared(m_pModel, pImageStack.get(), m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + m_pImage3D = pImageStack; + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + } + +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.cpp new file mode 100644 index 0000000..4387707 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.cpp @@ -0,0 +1,77 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_ImageSheet.cpp covers the official 3MF volumetric extension. + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_Model.h" + +#include "Common/NMR_StringUtils.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" + +namespace NMR { + + + CModelReaderNode_Volumetric2201_ImageSheet::CModelReaderNode_Volumetric2201_ImageSheet(_In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + + { + } + + void CModelReaderNode_Volumetric2201_ImageSheet::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + + void CModelReaderNode_Volumetric2201_ImageSheet::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMAGESHEET_PATH) == 0) { + m_sPath = pAttributeValue; + } + } + + std::string CModelReaderNode_Volumetric2201_ImageSheet::getPath() + { + return m_sPath; + } + +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.cpp new file mode 100644 index 0000000..b2e453d --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.cpp @@ -0,0 +1,150 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_ImageStack.cpp covers the official 3MF volumetric extension. + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageStack.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_ImageSheet.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_Model.h" + +#include "Common/NMR_StringUtils.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" + +namespace NMR { + + + CModelReaderNode_Volumetric2201_ImageStack::CModelReaderNode_Volumetric2201_ImageStack(_In_ CModel* pModel, _In_ CModelImageStack* pImageStack, _In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings), + m_pModel(pModel), + m_pImageStack(pImageStack), + m_nRowCount(0), + m_nColumnCount(0), + m_nSheetCount(0), + m_nSheetIndex(0) + { + if (pModel == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + if (m_pImageStack == nullptr) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + } + + void CModelReaderNode_Volumetric2201_ImageStack::parseXML(_In_ CXmlReader* pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + if (m_nRowCount == 0) + throw CNMRException(NMR_ERROR_MISSINGIMAGESTACKSIZE); + if (m_nColumnCount == 0) + throw CNMRException(NMR_ERROR_MISSINGIMAGESTACKSIZE); + if (m_nSheetCount == 0) + throw CNMRException(NMR_ERROR_MISSINGIMAGESTACKSHEETCOUNT); + + m_pImageStack->setRowCount(m_nRowCount); + m_pImageStack->setColumnCount(m_nColumnCount); + m_pImageStack->setSheetCount(m_nSheetCount); + + m_nSheetIndex = 0; + + // Parse Content + parseContent(pXMLReader); + + if (m_nSheetCount != m_nSheetIndex) + m_pWarnings->addException(CNMRException(NMR_ERROR_INVALIDIMAGSHEETCOUNT), mrwMissingMandatoryValue); + } + + + void CModelReaderNode_Volumetric2201_ImageStack::OnAttribute(_In_z_ const nfChar* pAttributeName, _In_z_ const nfChar* pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMAGESTACK_ROWCOUNT) == 0) { + if (m_nRowCount != 0) + throw CNMRException(NMR_ERROR_DUPLICATEIMAGESTACKSIZE); + + // Convert to integer and make a input and range check! + m_nRowCount = fnStringToUint32(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMAGESTACK_COLUMNCOUNT) == 0) { + if (m_nColumnCount != 0) + throw CNMRException(NMR_ERROR_DUPLICATEIMAGESTACKSIZE); + + // Convert to integer and make a input and range check! + m_nColumnCount = fnStringToUint32(pAttributeValue); + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_IMAGESTACK_SHEETCOUNT) == 0) { + if (m_nSheetCount != 0) + throw CNMRException(NMR_ERROR_DUPLICATEIMAGESTACKSHEETCOUNT); + + // Convert to integer and make a input and range check! + m_nSheetCount = fnStringToUint32(pAttributeValue); + } + } + + void CModelReaderNode_Volumetric2201_ImageStack::OnNSChildElement(_In_z_ const nfChar* pChildName, _In_z_ const nfChar* pNameSpace, _In_ CXmlReader* pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_VOLUMETRICSPEC) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_IMAGESHEET) == 0) + { + PModelReaderNode_Volumetric2201_ImageSheet pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + std::string sPath = pXMLNode->getPath(); + if (sPath != "") { + + PModelAttachment pAttachment = m_pModel->findModelAttachment(sPath); + if (pAttachment.get() == nullptr) + m_pWarnings->addException(CNMRException(NMR_ERROR_IMAGESHEETNOTFOUND), mrwFatal); + + if (m_nSheetIndex >= m_nSheetCount) + m_pWarnings->addException(CNMRException(NMR_ERROR_TOOMANYIMAGESHEETS), mrwFatal); + + __NMRASSERT(m_pImageStack.get() != nullptr); + m_pImageStack->setSheet(m_nSheetIndex, pAttachment); + m_nSheetIndex++; + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_MISSINGIMAGE3DSHEETPATH), mrwMissingMandatoryValue); + + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + } + + +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.cpp new file mode 100644 index 0000000..3548eed --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.cpp @@ -0,0 +1,185 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +CModelReaderNode_Volumetric2201_Property.cpp covers the official 3MF volumetric extension. + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Classes/NMR_Model.h" + +#include "Common/NMR_StringUtils.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" + +namespace NMR { + + CModelReaderNode_Volumetric2201_Property::CModelReaderNode_Volumetric2201_Property(_In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + + } + + void CModelReaderNode_Volumetric2201_Property::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + PVolumeDataProperty CModelReaderNode_Volumetric2201_Property::MakeProperty(_In_ CModel* pModel) + { + if (!pModel) + throw CNMRException(NMR_ERROR_INVALIDPARAM); + + if (!m_bHasFieldID) { + throw CNMRException(NMR_ERROR_MISSINGVOLUMEDATAFIELDID); + } + + if (!m_bHasName) { + throw CNMRException(NMR_ERROR_MISSINGVOLUMEDATAPROPERTYNAME); + } + + PPackageResourceID pID = pModel->findPackageResourceID(pModel->currentPath(), m_nFieldID); + if (!pID.get()) { + throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE); + } + + auto pFunction = pModel->findFunction(pID->getUniqueID()); + + NMR::PVolumeDataProperty pProperty; + if (pFunction) + { + pProperty = std::make_shared(pFunction, m_sName); + } + + if (!pProperty) { + throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE); + } + pProperty->setIsRequired(m_bRequired); + + if (m_bHasTransform) + { + pProperty->setTransform(m_Transform); + } + + if (m_bHasChannel) + { + pProperty->setChannelName(m_sChannel); + } + + if (m_bHasMinFeatureSize) + { + pProperty->setMinFeatureSize(m_dMinFeatureSize); + } + + if (m_bHasFallBackValue) + { + pProperty->setFallBackValue(m_dFallBackValue); + } + + return pProperty; + } + + void CModelReaderNode_Volumetric2201_Property::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_TRANSFORM) == 0) { + if (m_bHasTransform) + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATATRANSFORM); + + m_Transform = fnMATRIX3_fromString(pAttributeValue); + + m_bHasTransform = true; + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY) == 0) { + if (m_bHasName) + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATAPROPERTY); + + m_bHasName = true; + + m_sName = pAttributeValue; + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID) == 0) { + if (m_bHasFieldID) + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATAFIELDID); + + m_bHasFieldID = true; + + m_nFieldID = fnStringToUint32(pAttributeValue); + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY_REQUIRED) == 0) { + + m_bHasRequired = true; + + m_bRequired = !(std::string(pAttributeValue) == "false"); + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_CHANNEL) == 0) { + if (m_bHasChannel) + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATACHANNEL); + + m_bHasChannel = true; + m_sChannel = pAttributeValue; + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE) == 0) { + if (m_bHasMinFeatureSize) + throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_MINFEATURESIZE); + + m_bHasMinFeatureSize = true; + m_dMinFeatureSize = strtod(pAttributeValue, nullptr); + } + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE) == 0) { + if (m_bHasFallBackValue) + throw CNMRException(NMR_ERROR_DUPLICATE_VOLUMEDATA_FALLBACKVALUE); + + m_bHasFallBackValue = true; + m_dFallBackValue = fnStringToDouble(pAttributeValue); + } + } + + void CModelReaderNode_Volumetric2201_Property::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + } +} diff --git a/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.cpp b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.cpp new file mode 100644 index 0000000..9b40c58 --- /dev/null +++ b/Source/Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.cpp @@ -0,0 +1,138 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +NMR_ModelReaderNode_Volumetric2201_VolumeData.cpp covers the official 3MF +volumetric extension. + +--*/ + +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.h" + +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "Model/Classes/NMR_ModelResource.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Color.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Property.h" + +namespace NMR +{ + + CModelReaderNode_Volumetric2201_VolumeData:: + CModelReaderNode_Volumetric2201_VolumeData(CModel* pModel, + PModelWarnings pWarnings) + : CModelReaderNode(pWarnings), + m_pModel(pModel) + + { + if(pModel == nullptr) + { + throw CNMRException(NMR_ERROR_INVALIDPARAM); + } + } + + void CModelReaderNode_Volumetric2201_VolumeData::parseXML( + CXmlReader* pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // parseContent needs m_pVolumeData to be initialized, and m_nID to be set by parseAttributes + m_pVolumeData = std::make_shared(m_nID, m_pModel); + // Parse Content + parseContent(pXMLReader); + + m_pModel->addResource(m_pVolumeData); + } + + void CModelReaderNode_Volumetric2201_VolumeData::OnAttribute( + const nfChar* pAttributeName, const nfChar* pAttributeValue) + { + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VOLUMEDATA_ID) == 0) { + if (m_nID != 0) + { + throw CNMRException(NMR_ERROR_DUPLICATERESOURCEID); + } + + // Convert to integer and make a input and range check! + m_nID = fnStringToUint32(pAttributeValue); + } + } + + void CModelReaderNode_Volumetric2201_VolumeData::OnNSChildElement( + const nfChar* pChildName, const nfChar* pNameSpace, + CXmlReader* pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if(strcmp(pNameSpace, XML_3MF_NAMESPACE_VOLUMETRICSPEC) == 0) + { + if(strcmp(pChildName, XML_3MF_ELEMENT_VOLUMETRIC_PROPERTY) == 0) + { + PModelReaderNode_Volumetric2201_Property pXMLNode = + std::make_shared( + m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + PVolumeDataProperty pProperty = + pXMLNode->MakeProperty(m_pModel); + + if(m_pVolumeData->hasProperty(pProperty->getName()) == false) + { + m_pVolumeData->addProperty(pProperty); + } + else + { + throw CNMRException(NMR_ERROR_DUPLICATEVOLUMEDATAPROPERTY); + } + } + else if(strcmp(pChildName, XML_3MF_ELEMENT_VOLUMETRIC_COLOR) == 0) + { + PModelReaderNode_Volumetric2201_Color pXMLNode = + std::make_shared( + m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + PVolumeDataColor pColor = pXMLNode->MakeColor(m_pModel); + m_pVolumeData->setColor(pColor); + } + else + m_pWarnings->addException( + CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), + mrwInvalidOptionalValue); + } + } + +} // namespace NMR diff --git a/Source/Model/Reader/v093/NMR_ModelReaderNode093_TextureVertex.cpp b/Source/Model/Reader/v093/NMR_ModelReaderNode093_TextureVertex.cpp index 3f79b97..a2184ca 100644 --- a/Source/Model/Reader/v093/NMR_ModelReaderNode093_TextureVertex.cpp +++ b/Source/Model/Reader/v093/NMR_ModelReaderNode093_TextureVertex.cpp @@ -86,7 +86,7 @@ namespace NMR { __NMRASSERT(pAttributeValue); if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TEXTURE_U) == 0) { - m_fU = strtof(pAttributeValue, nullptr); + m_fU = fnStringToFloat(pAttributeValue); if (std::isnan (m_fU)) throw CNMRException(NMR_ERROR_INVALIDMODELTEXTURECOORDINATES); if (fabs (m_fU) > XML_3MF_MAXIMUMCOORDINATEVALUE) @@ -95,8 +95,12 @@ namespace NMR { } if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TEXTURE_V) == 0) { - m_fV = strtof(pAttributeValue, nullptr); - if (std::isnan (m_fV)) + m_fV = fnStringToFloat(pAttributeValue); +#ifdef __MINGW32__ + if (isNotANumber(m_fV)) +#else + if (std::isnan(m_fV)) +#endif throw CNMRException(NMR_ERROR_INVALIDMODELTEXTURECOORDINATES); if (fabs(m_fV) > XML_3MF_MAXIMUMCOORDINATEVALUE) throw CNMRException(NMR_ERROR_INVALIDMODELTEXTURECOORDINATES); diff --git a/Source/Model/Reader/v093/NMR_ModelReaderNode093_Vertex.cpp b/Source/Model/Reader/v093/NMR_ModelReaderNode093_Vertex.cpp index a7502b5..5c8d7ae 100644 --- a/Source/Model/Reader/v093/NMR_ModelReaderNode093_Vertex.cpp +++ b/Source/Model/Reader/v093/NMR_ModelReaderNode093_Vertex.cpp @@ -82,7 +82,7 @@ namespace NMR { __NMRASSERT(pAttributeValue); if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VERTEX_X) == 0) { - m_fX = strtof(pAttributeValue, nullptr); + m_fX = fnStringToFloat(pAttributeValue); if (std::isnan (m_fX)) throw CNMRException(NMR_ERROR_INVALIDMODELCOORDINATES); if (fabs (m_fX) > XML_3MF_MAXIMUMCOORDINATEVALUE) @@ -91,7 +91,7 @@ namespace NMR { } if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VERTEX_Y) == 0) { - m_fY = strtof(pAttributeValue, nullptr); + m_fY = fnStringToFloat(pAttributeValue); if (std::isnan (m_fY)) throw CNMRException(NMR_ERROR_INVALIDMODELCOORDINATES); if (fabs(m_fY) > XML_3MF_MAXIMUMCOORDINATEVALUE) @@ -100,7 +100,7 @@ namespace NMR { } if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VERTEX_Z) == 0) { - m_fZ = strtof(pAttributeValue, nullptr); + m_fZ = fnStringToFloat(pAttributeValue); if (std::isnan (m_fZ)) throw CNMRException(NMR_ERROR_INVALIDMODELCOORDINATES); if (fabs(m_fZ) > XML_3MF_MAXIMUMCOORDINATEVALUE) diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Build.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Build.cpp index 399ef47..c7ae2de 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Build.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Build.cpp @@ -65,9 +65,9 @@ namespace NMR { { m_pWarnings->addException(CNMRException(NMR_ERROR_MISSINGUUID), mrwMissingMandatoryValue); } - // m_UUID = std::make_shared(); + m_UUID = std::make_shared(); } - m_pModel->setBuildUUID(m_UUID); + m_pModel->setBuildUUID(m_UUID); } void CModelReaderNode100_Build::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.cpp index 4fc7e25..e4eef23 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_BuildItem.cpp @@ -53,6 +53,7 @@ namespace NMR { m_hasPath = false; + m_bHasTransform = false; m_mTransform = fnMATRIX3_identity(); } @@ -110,7 +111,7 @@ namespace NMR { if (pXMLReader->NamespaceRegistered(XML_3MF_NAMESPACE_PRODUCTIONSPEC)) { m_pWarnings->addException(CNMRException(NMR_ERROR_MISSINGUUID), mrwMissingMandatoryValue); } - // m_UUID = std::make_shared(); + m_UUID = std::make_shared(); } pBuildItem->setUUID(m_UUID); pBuildItem->setPath(m_sPath); @@ -129,7 +130,11 @@ namespace NMR { m_bHasID = true; } else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_ITEM_TRANSFORM) == 0) { + if (m_bHasTransform) + throw CNMRException(NMR_ERROR_DUPLICATETRANSFORM); + m_mTransform = fnMATRIX3_fromString(pAttributeValue); + m_bHasTransform = true; } else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_ITEM_PARTNUMBER) == 0) { m_sPartNumber = std::string(pAttributeValue); diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Component.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Component.cpp index e7c479a..d19e75f 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Component.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Component.cpp @@ -50,6 +50,7 @@ namespace NMR { m_ObjectID = 0; m_bHasID = false; m_sPath = ""; + m_bHasTransform = false; m_mTransform = fnMATRIX3_identity(); m_bHasPath = false; @@ -108,7 +109,11 @@ namespace NMR { m_bHasID = true; } else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_COMPONENT_TRANSFORM) == 0) { + if (m_bHasTransform) + throw CNMRException(NMR_ERROR_DUPLICATETRANSFORM); + m_mTransform = fnMATRIX3_fromString(pAttributeValue); + m_bHasTransform = true; } else m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ATTRIBUTE), mrwInvalidOptionalValue); diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_CompositeMaterials.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_CompositeMaterials.cpp index 70f1141..8ee319c 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_CompositeMaterials.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_CompositeMaterials.cpp @@ -146,6 +146,8 @@ namespace NMR { PModelComposite pComposite = pXMLNode->getComposite(); + if (!pComposite) + throw CNMRException(NMR_ERROR_INVALIDCOMPONENTRESOURCE); m_pCompositeMaterials->addComposite(pComposite); } else diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp index 16d2fcc..13e891d 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp @@ -34,18 +34,23 @@ A mesh reader model node is a parser for the mesh node of an XML Model Stream. #include "Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h" #include "Model/Reader/v100/NMR_ModelReaderNode100_Vertices.h" #include "Model/Reader/v100/NMR_ModelReaderNode100_Triangles.h" +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h" #include "Model/Reader/BeamLattice1702/NMR_ModelReaderNode_BeamLattice1702_BeamLattice.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.h" #include "Model/Classes/NMR_ModelConstants.h" +#include "Model/Classes/NMR_ModelVolumeData.h" #include "Common/NMR_StringUtils.h" #include "Common/NMR_Exception.h" #include "Common/NMR_Exception_Windows.h" namespace NMR { - CModelReaderNode100_Mesh::CModelReaderNode100_Mesh(_In_ CModel * pModel, _In_ CMesh * pMesh, _In_ PModelWarnings pWarnings, + CModelReaderNode100_Mesh::CModelReaderNode100_Mesh(_In_ CModel * pModel, PModelMeshObject pMesh, _In_ PModelWarnings pWarnings, _In_ PProgressMonitor pProgressMonitor, _In_ PPackageResourceID pObjectLevelPropertyID, _In_ ModelResourceIndex nDefaultPropertyIndex) - : CModelReaderNode(pWarnings, pProgressMonitor) + : CModelReaderNode(pWarnings, pProgressMonitor), + m_pModel(pModel), + m_pMesh(pMesh) { __NMRASSERT(pMesh); __NMRASSERT(pModel); @@ -53,14 +58,14 @@ namespace NMR { m_pObjectLevelPropertyID = pObjectLevelPropertyID; m_nObjectLevelPropertyIndex = nDefaultPropertyIndex; - m_pMesh = pMesh; - m_pModel = pModel; - m_bHasClippingMeshID = false; m_nClippingMeshID = 0; m_eClipMode = eModelBeamLatticeClipMode::MODELBEAMLATTICECLIPMODE_NONE; m_bHasRepresentationMeshID = false; m_nRepresentationMeshID = 0; + + m_bHasVolumeDataID = false; + m_nVolumeDataID = 0; } void CModelReaderNode100_Mesh::parseXML(_In_ CXmlReader * pXMLReader) @@ -73,6 +78,23 @@ namespace NMR { // Parse Content parseContent(pXMLReader); + + if(m_bHasVolumeDataID) + { + PPackageResourceID volumePackageId = + m_pModel->findPackageResourceID(m_pModel->currentPath(), + m_nVolumeDataID); + + if(!volumePackageId.get()) + { + throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE); + } + + auto pVolumeData = m_pModel->findVolumeData( + volumePackageId->getUniqueID()); + + m_pMesh->setVolumeData(pVolumeData); + } } void CModelReaderNode100_Mesh::retrieveClippingInfo(_Out_ eModelBeamLatticeClipMode &eClipMode, _Out_ nfBool & bHasClippingMode, _Out_ ModelResourceID & nClippingMeshID) @@ -88,36 +110,59 @@ namespace NMR { nRepresentationMeshID = m_nRepresentationMeshID; } - void CModelReaderNode100_Mesh::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + void CModelReaderNode100_Mesh::OnNSAttribute( + _In_z_ const nfChar *pAttributeName, + _In_z_ const nfChar *pAttributeValue, + _In_z_ const nfChar *pNameSpace) { __NMRASSERT(pAttributeName); __NMRASSERT(pAttributeValue); + __NMRASSERT(pNameSpace); + + if(strcmp(pNameSpace, XML_3MF_NAMESPACE_VOLUMETRICSPEC) == 0) + { + if(strcmp(pAttributeName, XML_3MF_ATTRIBUTE_MESH_VOLUMEDATA) == + 0) + { + if(m_bHasVolumeDataID) + { + throw CNMRException( + NMR_ERROR_DUPLICATE_BOUNDARY_SHAPE_VOLUME_ID); + } + m_bHasVolumeDataID = true; + m_nVolumeDataID = fnStringToUint32(pAttributeValue); + } + } } - void CModelReaderNode100_Mesh::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) + void CModelReaderNode100_Mesh::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) { __NMRASSERT(pChildName); __NMRASSERT(pXMLReader); __NMRASSERT(pNameSpace); + + NMR::CMesh *mesh = m_pMesh->getMesh(); + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_CORESPEC100) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_VERTICES) == 0) { - if (m_pMesh->getNodeCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) { + if (mesh->getNodeCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) { m_pProgressMonitor->SetProgressIdentifier(ProgressIdentifier::PROGRESS_READMESH); m_pProgressMonitor->ReportProgressAndQueryCancelled(true); } - PModelReaderNode pXMLNode = std::make_shared(m_pMesh, m_pWarnings); + PModelReaderNode pXMLNode = std::make_shared(mesh, m_pWarnings); pXMLNode->parseXML(pXMLReader); } else if (strcmp(pChildName, XML_3MF_ELEMENT_TRIANGLES) == 0) { - if (m_pMesh->getFaceCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) { + if (mesh->getFaceCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) { m_pProgressMonitor->SetProgressIdentifier(ProgressIdentifier::PROGRESS_READMESH); m_pProgressMonitor->ReportProgressAndQueryCancelled(true); } - PModelReaderNode100_Triangles pXMLNode = std::make_shared(m_pModel, m_pMesh, m_pWarnings, + PModelReaderNode100_Triangles pXMLNode = std::make_shared(m_pModel, mesh, m_pWarnings, m_pObjectLevelPropertyID, m_nObjectLevelPropertyIndex); pXMLNode->parseXML(pXMLReader); if (m_pObjectLevelPropertyID && m_pObjectLevelPropertyID->getPackageModelPath() == 0) { @@ -139,7 +184,7 @@ namespace NMR { if (strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICESPEC) == 0) { if (strcmp(pChildName, XML_3MF_ELEMENT_BEAMLATTICE) == 0) { - PModelReaderNode_BeamLattice1702_BeamLattice pXMLNode = std::make_shared(m_pModel, m_pMesh, m_pWarnings); + PModelReaderNode_BeamLattice1702_BeamLattice pXMLNode = std::make_shared(m_pModel, mesh, m_pWarnings); pXMLNode->parseXML(pXMLReader); pXMLNode->retrieveClippingInfo(m_eClipMode, m_bHasClippingMeshID, m_nClippingMeshID); @@ -150,6 +195,23 @@ namespace NMR { m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); } + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_TRIANGLESETS) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_TRIANGLESETS) == 0) + { + PModelReaderNode100_TriangleSets pXMLNode = std::make_shared(m_pModel, m_pMesh->getMesh(), m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + m_pTriangleSets = pXMLNode->getTriangleSets (); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + + } + + std::vector CModelReaderNode100_Mesh::getTriangleSets() + { + return m_pTriangleSets; } } diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_MultiProperties.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_MultiProperties.cpp index 1b2fc75..4d65ec3 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_MultiProperties.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_MultiProperties.cpp @@ -143,7 +143,7 @@ namespace NMR { eModelBlendMethod method = MODELBLENDMETHOD_MIX; try { method = CModelMultiPropertyGroupResource::stringToBlendMethod(blendMethodString); - } catch (CNMRException e) { + } catch (CNMRException& e) { m_pWarnings->addException(e, mrwInvalidMandatoryValue); } m_pBlendMethods->push_back(method); diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp index c035d33..2fca11d 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp @@ -36,6 +36,7 @@ Stream. #include "Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h" #include "Model/Reader/v100/NMR_ModelReaderNode100_MetaDataGroup.h" #include "Model/Reader/v100/NMR_ModelReaderNode100_Components.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.h" #include "Model/Classes/NMR_ModelConstants.h" #include "Model/Classes/NMR_ModelMeshObject.h" @@ -122,7 +123,7 @@ namespace NMR { if (pXMLReader->NamespaceRegistered(XML_3MF_NAMESPACE_PRODUCTIONSPEC)) { m_pWarnings->addException(CNMRException(NMR_ERROR_MISSINGUUID), mrwMissingMandatoryValue); } - // m_UUID = std::make_shared(); + m_UUID = std::make_shared(); } m_pObject->setUUID(m_UUID); } @@ -236,7 +237,8 @@ namespace NMR { // Create Empty Mesh PMesh pMesh = std::make_shared(); // Create Mesh Object - m_pObject = std::make_shared(m_nID, m_pModel, pMesh); + PModelMeshObject meshObject = std::make_shared(m_nID, m_pModel, pMesh); + m_pObject = meshObject; // Set Object Type (might fail, if string is invalid) if (m_bHasType) { if (!m_pObject->setObjectTypeString(m_sType, false)) @@ -244,10 +246,15 @@ namespace NMR { } // Read Mesh - PModelReaderNode100_Mesh pXMLNode = std::make_shared(m_pModel, pMesh.get(), + PModelReaderNode100_Mesh pXMLNode = std::make_shared(m_pModel, meshObject, m_pWarnings, m_pProgressMonitor, m_pObjectLevelPropertyID, m_nObjectLevelPropertyIndex); pXMLNode->parseXML(pXMLReader); + // store triangle sets in memory model + auto triangleSets = pXMLNode->getTriangleSets(); + for (auto triangleSet : triangleSets) + meshObject->addTriangleSet(triangleSet); + // Add Object to Parent m_pModel->addResource(m_pObject); @@ -316,7 +323,28 @@ namespace NMR { } - } + if(strcmp(pNameSpace, XML_3MF_NAMESPACE_VOLUMETRICSPEC) == 0) //Seems really wiered that object types defined by extensions have to be handled here + { + if(strcmp(pChildName, XML_3MF_ELEMENT_BOUNDARY_SHAPE) == 0) + { + auto levelSet = std::make_shared(m_nID, m_pModel); + + PModelReaderNode pXMLNode = + std::make_shared( + m_pModel, levelSet, m_pWarnings, m_pProgressMonitor); + pXMLNode->parseXML(pXMLReader); + m_pObject = levelSet; + m_pModel->addResource(m_pObject); + + } + else + { + m_pWarnings->addException( + CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), + mrwInvalidOptionalValue); + } + } + } // Create the object-level property from m_nObjectLevelPropertyID, if defined void CModelReaderNode100_Object::createDefaultProperties() @@ -422,5 +450,4 @@ namespace NMR { } } } - } diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Resources.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Resources.cpp index fa23352..5df4ddd 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Resources.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Resources.cpp @@ -40,6 +40,11 @@ XML Model Stream. #include "Model/Reader/v100/NMR_ModelReaderNode100_CompositeMaterials.h" #include "Model/Reader/v100/NMR_ModelReaderNode100_MultiProperties.h" #include "Model/Reader/Slice1507/NMR_ModelReader_Slice1507_SliceStack.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_Image3D.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Implicit_Function.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_FunctionFromImage3D.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_LevelSet.h" +#include "Model/Reader/Volumetric2201/NMR_ModelReaderNode_Volumetric2201_VolumeData.h" #include "Model/Classes/NMR_ModelConstants.h" #include "Common/NMR_StringUtils.h" @@ -141,6 +146,36 @@ namespace NMR { m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); } + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_VOLUMETRICSPEC) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_IMAGE3D) == 0) { + PModelReaderNode pXMLNode = std::make_shared( + m_pModel, m_pWarnings); + pXMLNode->parseXML(pXMLReader); + } + else if (strcmp(pChildName, XML_3MF_ELEMENT_FUNCTION_FROM_IMAGE3D) == 0) + { + PModelReaderNode pXMLNode = std::make_shared( + m_pModel, m_pWarnings); + pXMLNode->parseXML(pXMLReader); + } if (strcmp(pChildName, XML_3MF_ELEMENT_VOLUMEDATA) == 0) + { + PModelReaderNode pXMLNode = std::make_shared( + m_pModel, m_pWarnings); + pXMLNode->parseXML(pXMLReader); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_IMPLICITSPEC) == 0) { + if ((strcmp(pChildName, XML_3MF_ELEMENT_IMPLICIT_FUNCTION_DEPRECATED) == 0) || (strcmp(pChildName, XML_3MF_ELEMENT_IMPLICIT_FUNCTION) == 0)) + { + PModelReaderNode_ImplicitFunction pXMLNode = std::make_shared(m_pModel, m_pWarnings); + pXMLNode->parseXML(pXMLReader); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } } diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.cpp new file mode 100644 index 0000000..171a1d3 --- /dev/null +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.cpp @@ -0,0 +1,100 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--*/ + +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h" +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + CModelReaderNode100_TriangleSet::CModelReaderNode100_TriangleSet(_In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + } + + void CModelReaderNode100_TriangleSet::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + m_pTriangleSet = std::make_shared(m_sName, m_sIdentifier); + + // Parse Content + parseContent(pXMLReader); + } + + + void CModelReaderNode100_TriangleSet::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + __NMRASSERT(pAttributeName); + __NMRASSERT(pAttributeValue); + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TRIANGLESET_NAME) == 0) { + m_sName = pAttributeValue; + } + else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TRIANGLESET_IDENTIFIER) == 0) { + m_sIdentifier = pAttributeValue; + } + } + + void CModelReaderNode100_TriangleSet::OnNSChildElement(_In_z_ const nfChar* pChildName, _In_z_ const nfChar* pNameSpace, _In_ CXmlReader* pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_TRIANGLESETS) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_REF) == 0) + { + PModelReaderNode100_TriangleSetRef pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + m_pTriangleSet->addTriangle(pXMLNode->getIndex()); + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + + } + + + PModelTriangleSet CModelReaderNode100_TriangleSet::createTriangleSet() + { + return m_pTriangleSet; + } + +} diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.cpp new file mode 100644 index 0000000..4e54687 --- /dev/null +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.cpp @@ -0,0 +1,89 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelReaderNode100_Triangle.cpp implements the Model Reader Triangle Node +Class. A triangle reader model node is a parser for the triangle node of an +XML Model Stream. + +--*/ + +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSetRef.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" +#include "Common/NMR_StringUtils.h" +#include +#include + +namespace NMR { + + CModelReaderNode100_TriangleSetRef::CModelReaderNode100_TriangleSetRef(_In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings), m_nIndex (0xffffffff) + { + } + + void CModelReaderNode100_TriangleSetRef::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + + void CModelReaderNode100_TriangleSetRef::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + __NMRASSERT(pAttributeName); + __NMRASSERT(pAttributeValue); + + + if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_TRIANGLESETREF_INDEX) == 0) { + nfInt32 nValue = fnStringToInt32(pAttributeValue); + if ((nValue >= 0) && (nValue < XML_3MF_MAXRESOURCEINDEX)) + m_nIndex = nValue; + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_TRIANGLESETINVALIDATTRIBUTE), mrwInvalidMandatoryValue); + + } + + + uint32_t CModelReaderNode100_TriangleSetRef::getIndex() + { + if (m_nIndex >= XML_3MF_MAXRESOURCEINDEX) + m_pWarnings->addException(CNMRException(NMR_ERROR_TRIANGLESETMISSINGREFERENCEINDEX), mrwInvalidMandatoryValue); + + return m_nIndex; + } + +} diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.cpp new file mode 100644 index 0000000..593608b --- /dev/null +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.cpp @@ -0,0 +1,102 @@ +/*++ + +Copyright (C) 2019 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ModelReaderNode100_Triangles.cpp implements the Model Reader Triangles Node +Class. A triangles reader model node is a parser for the triangles node of an +XML Model Stream. + +--*/ + +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSets.h" +#include "Model/Reader/v100/NMR_ModelReaderNode100_TriangleSet.h" + +#include "Model/Classes/NMR_ModelConstants.h" +#include "Common/NMR_StringUtils.h" +#include "Common/NMR_Exception.h" +#include "Common/NMR_Exception_Windows.h" + +namespace NMR { + + CModelReaderNode100_TriangleSets::CModelReaderNode100_TriangleSets(_In_ CModel * pModel, _In_ CMesh * pMesh, + _In_ PModelWarnings pWarnings) + : CModelReaderNode(pWarnings) + { + __NMRASSERT(pMesh); + __NMRASSERT(pModel); + + m_pModel = pModel; + m_pMesh = pMesh; + } + + void CModelReaderNode100_TriangleSets::parseXML(_In_ CXmlReader * pXMLReader) + { + // Parse Name + parseName(pXMLReader); + + // Parse attribute + parseAttributes(pXMLReader); + + // Parse Content + parseContent(pXMLReader); + } + + void CModelReaderNode100_TriangleSets::OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue) + { + __NMRASSERT(pAttributeName); + __NMRASSERT(pAttributeValue); + } + + + + void CModelReaderNode100_TriangleSets::OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader) + { + __NMRASSERT(pChildName); + __NMRASSERT(pXMLReader); + __NMRASSERT(pNameSpace); + + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_TRIANGLESETS) == 0) { + if (strcmp(pChildName, XML_3MF_ELEMENT_TRIANGLESET) == 0) + { + PModelReaderNode100_TriangleSet pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + + m_TriangleSets.push_back(pXMLNode->createTriangleSet ()); + + + } + else + m_pWarnings->addException(CNMRException(NMR_ERROR_NAMESPACE_INVALID_ELEMENT), mrwInvalidOptionalValue); + } + + } + + std::vector CModelReaderNode100_TriangleSets::getTriangleSets() + { + return m_TriangleSets; + } +} diff --git a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Vertex.cpp b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Vertex.cpp index 797e782..a2cc729 100644 --- a/Source/Model/Reader/v100/NMR_ModelReaderNode100_Vertex.cpp +++ b/Source/Model/Reader/v100/NMR_ModelReaderNode100_Vertex.cpp @@ -82,7 +82,7 @@ namespace NMR { __NMRASSERT(pAttributeValue); if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VERTEX_X) == 0) { - m_fX = strtof(pAttributeValue, nullptr); + m_fX = fnStringToFloat(pAttributeValue); if (std::isnan (m_fX)) throw CNMRException(NMR_ERROR_INVALIDMODELCOORDINATES); if (fabs (m_fX) > XML_3MF_MAXIMUMCOORDINATEVALUE) @@ -90,7 +90,7 @@ namespace NMR { m_bHasX = true; } else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VERTEX_Y) == 0) { - m_fY = strtof(pAttributeValue, nullptr); + m_fY = fnStringToFloat(pAttributeValue); if (std::isnan (m_fY)) throw CNMRException(NMR_ERROR_INVALIDMODELCOORDINATES); if (fabs(m_fY) > XML_3MF_MAXIMUMCOORDINATEVALUE) @@ -98,7 +98,7 @@ namespace NMR { m_bHasY = true; } else if (strcmp(pAttributeName, XML_3MF_ATTRIBUTE_VERTEX_Z) == 0) { - m_fZ = strtof(pAttributeValue, nullptr); + m_fZ = fnStringToFloat(pAttributeValue); if (std::isnan (m_fZ)) throw CNMRException(NMR_ERROR_INVALIDMODELCOORDINATES); if (fabs(m_fZ) > XML_3MF_MAXIMUMCOORDINATEVALUE) diff --git a/Source/Model/Writer/NMR_KeyStoreOpcPackageWriter.cpp b/Source/Model/Writer/NMR_KeyStoreOpcPackageWriter.cpp index a61a9d7..49632d7 100644 --- a/Source/Model/Writer/NMR_KeyStoreOpcPackageWriter.cpp +++ b/Source/Model/Writer/NMR_KeyStoreOpcPackageWriter.cpp @@ -79,12 +79,12 @@ namespace NMR { } PModel const & model = m_pContext.model(); - if (!model->hasCryptoRandCallbak()) + if (!model->hasCryptoRandCallbak() && (keyStore->getResourceDataCount()>0)) m_pContext.warnings()->addWarning(NMR_ERROR_RNGCALLBACKNOTCRYPTOSTRONG, eModelWarningLevel::mrwInvalidOptionalValue); for (nfUint64 i = 0; i < keyStore->getResourceDataCount(); ++i) { PKeyStoreResourceData rd = keyStore->getResourceData(i); if (rd->getGroup()->isOpen()) { - std::vector newIv(fnGetAlgorithmInitVectorSize(rd->getEncryptionAlgorithm()), 0); + std::vector newIv((size_t)fnGetAlgorithmInitVectorSize(rd->getEncryptionAlgorithm()), 0); model->generateRandomBytes(newIv.data(), newIv.size()); rd->setInitVector(newIv); } @@ -139,7 +139,7 @@ namespace NMR { ctx.m_sKekDecryptData.m_pAccessRight = ar; std::vector closedKey; //give consumer a chance to (re)encrypt this key - nfUint64 wrapped = ctx.m_fnWrap(key, closedKey, ctx.m_sKekDecryptData); + ctx.m_fnWrap(key, closedKey, ctx.m_sKekDecryptData); ar->setCipherValue(closedKey); } catch (CNMRException const & e) { if (ar->isNew()) { diff --git a/Source/Model/Writer/NMR_ModelWriterNode.cpp b/Source/Model/Writer/NMR_ModelWriterNode.cpp index 03ec812..82beb30 100644 --- a/Source/Model/Writer/NMR_ModelWriterNode.cpp +++ b/Source/Model/Writer/NMR_ModelWriterNode.cpp @@ -83,8 +83,18 @@ namespace NMR { writeConstStringAttribute(pAttributeName, sStream.str().c_str()); } - void CModelWriterNode::writeUintAttribute(_In_z_ const nfChar * pAttributeName, _In_ nfUint32 nAttributeValue) + void CModelWriterNode::writePrefixedIntAttribute( + const nfChar* pPrefix, const nfChar* pAttributeName, + nfInt32 nAttributeValue) { + std::stringstream sStream; + sStream << nAttributeValue; + writeConstPrefixedStringAttribute(pPrefix, pAttributeName, sStream.str().c_str()); + } + + void CModelWriterNode::writeUintAttribute( + _In_z_ const nfChar* pAttributeName, _In_ nfUint32 nAttributeValue) + { std::stringstream sStream; sStream << nAttributeValue; writeConstStringAttribute(pAttributeName, sStream.str().c_str()); @@ -97,6 +107,13 @@ namespace NMR { writeConstStringAttribute(pAttributeName, sStream.str().c_str()); } + void CModelWriterNode::writeDoubleAttribute(_In_z_ const nfChar* pAttributeName, _In_ nfDouble dAttributeValue) + { + std::stringstream sStream; + sStream << dAttributeValue; + writeConstStringAttribute(pAttributeName, sStream.str().c_str()); + } + void CModelWriterNode::writeStartElement(_In_z_ const nfChar * pElementName) { m_pXMLWriter->WriteStartElement(nullptr, pElementName, nullptr); diff --git a/Source/Model/Writer/NMR_ModelWriterNode_Implicit.cpp b/Source/Model/Writer/NMR_ModelWriterNode_Implicit.cpp new file mode 100644 index 0000000..19dd221 --- /dev/null +++ b/Source/Model/Writer/NMR_ModelWriterNode_Implicit.cpp @@ -0,0 +1,304 @@ +/*++ + +Copyright (C) 2023 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Writer node for implicit functions + +--*/ +#include "Model/Writer/NMR_ModelWriterNode_Implicit.h" +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "Common/NMR_Exception.h" +#include "lib3mf_types.hpp" + +#include + +namespace NMR +{ + const implicit::NodeTypes CModelWriterNode_Implicit::m_nodeTypes; + + CModelWriterNode_Implicit::CModelWriterNode_Implicit(CModel * pModel, + CXmlWriter * pXMLWriter, + PProgressMonitor pProgressMonitor) + : CModelWriterNode_ModelBase(pModel, pXMLWriter, pProgressMonitor) + { + } + + void CModelWriterNode_Implicit::writeImplicitFunctions() + { + nfUint32 const nCount = m_pModel->getFunctionCount(); + + for (nfUint32 nIndex = 0; nIndex < nCount; nIndex++) + { + m_pProgressMonitor->IncrementProgress(1); + CModelImplicitFunction * pFunction = m_pModel->getImplicitFunction(nIndex); + if (!pFunction) + { + continue; + } + + writeImplicitFunction(*pFunction); + } + } + + void CModelWriterNode_Implicit::writeImplicitFunction( + CModelImplicitFunction& function) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMPLICIT_FUNCTION, + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + writeIntAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_ID, + function.getPackageResourceID()->getModelResourceID()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_DISPLAY_NAME, + function.getDisplayName()); + + writeImplicitFunctionElements(function); + } + writeFullEndElement(); + } + + void CModelWriterNode_Implicit::writeToXML() + { + throw CNMRException(NMR_ERROR_NOTIMPLEMENTED); + } + + void CModelWriterNode_Implicit::writeImplicitFunctionElements(CModelImplicitFunction & function) + { + writeImplicitFunctionInputs(*function.getInputs()); + + for (auto node : *function.getNodes()) + { + writeImplicitNode(*node); + } + + writeImplicitFunctionOutputs(*function.getOutputs()); + } + + std::string mat4x4ToString(Lib3MF::sMatrix4x4 const & mat) + { + std::stringstream outStream; + outStream << mat.m_Field[0][0] << " " << mat.m_Field[0][1] << " " << mat.m_Field[0][2] << " " + << mat.m_Field[0][3] << " " << mat.m_Field[1][0] << " " << mat.m_Field[1][1] << " " + << mat.m_Field[1][2] << " " << mat.m_Field[1][3] << " " << mat.m_Field[2][0] << " " + << mat.m_Field[2][1] << " " << mat.m_Field[2][2] << " " << mat.m_Field[2][3] << " " + << mat.m_Field[3][0] << " " << mat.m_Field[3][1] << " " << mat.m_Field[3][2] << " " + << mat.m_Field[3][3]; + return outStream.str(); + } + + + + void CModelWriterNode_Implicit::writeImplicitNode(CModelImplicitNode & node) + { + + auto name = m_nodeTypes.getNodeType(node.getNodeType()).getName(); + writeStartElementWithPrefix(name.c_str(), + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_ID, node.getIdentifier()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_DISPLAY_NAME, + node.getDisplayName()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_TAG, + node.getTag()); + + if (node.getNodeType() == Lib3MF::eImplicitNodeType::Constant) + { + + writeDoubleAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VALUE, node.getConstant()); + } + else if (node.getNodeType() == Lib3MF::eImplicitNodeType::ConstVec) + { + auto vec = node.getVector(); + writeDoubleAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_X, vec.m_Coordinates[0]); + writeDoubleAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_Y, vec.m_Coordinates[1]); + writeDoubleAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_Z, vec.m_Coordinates[2]); + } + else if (node.getNodeType() == Lib3MF::eImplicitNodeType::ConstMat) + { + auto const mat = node.getMatrix(); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_MATRIX, mat4x4ToString(mat)); + } + else if(node.getNodeType() == Lib3MF::eImplicitNodeType::ConstResourceID) + { + auto resource = node.getResource(); + if (resource != nullptr) + { + writeIntAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VALUE, resource->getPackageResourceID()->getModelResourceID()); + } + + } + else if (node.getNodeType() == Lib3MF::eImplicitNodeType::BeamLattice) + { + // Only write accuraterange if non-zero (default is 0.0) + double accurateRange = node.getAccurateRange(); + if (accurateRange != 0.0) + { + writeDoubleAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_ACCURATERANGE, accurateRange); + } + } + else if (node.getNodeType() == Lib3MF::eImplicitNodeType::FunctionGradient || + node.getNodeType() == Lib3MF::eImplicitNodeType::NormalizeDistance) + { + // These attributes are required per schema + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_SCALAROUTPUT, node.getScalarOutputName()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_NODE_VECTORINPUT, node.getVectorInputName()); + } + + bool const isNodeWithoutInputs = node.getNodeType() == Lib3MF::eImplicitNodeType::Constant || + node.getNodeType() == Lib3MF::eImplicitNodeType::ConstVec || + node.getNodeType() == Lib3MF::eImplicitNodeType::ConstMat || + node.getNodeType() == Lib3MF::eImplicitNodeType::ConstResourceID; + + if (!isNodeWithoutInputs) // Certain node types are not allowed to have inputs, but may have been set by the producer + { + auto inputs = node.getInputs(); + if (!inputs->empty()) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMPLICIT_NODE_INPUT, + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + writeImplicitInputs(*inputs); + } + writeFullEndElement(); + } + } + + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMPLICIT_NODE_OUTPUT, + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + auto outputs = node.getOutputs(); + writeImplicitOutputs(*outputs); + } + writeFullEndElement(); + } + writeFullEndElement(); + } + + const char * portTypeToRefName(Lib3MF::eImplicitPortType type) + { + switch (type) + { + case Lib3MF::eImplicitPortType::Scalar: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR_REF; + case Lib3MF::eImplicitPortType::Vector: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR_REF; + case Lib3MF::eImplicitPortType::Matrix: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX_REF; + case Lib3MF::eImplicitPortType::ResourceID: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_REF; + default: + return "Invalid"; + } + } + + void NMR::CModelWriterNode_Implicit::writeImplicitInputs(NMR::Ports & ports) + { + for (auto & port : ports) + { + writeStartElementWithPrefix(portTypeToRefName(port->getType()), + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID, port->getIdentifier()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME, + port->getDisplayName()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_REFERENCE, + port->getReference()); + } + writeFullEndElement(); + } + } + + const char * portTypeToName(Lib3MF::eImplicitPortType type) + { + switch (type) + { + case Lib3MF::eImplicitPortType::Scalar: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_SCALAR; + case Lib3MF::eImplicitPortType::Vector: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_VECTOR; + case Lib3MF::eImplicitPortType::Matrix: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_MATRIX; + case Lib3MF::eImplicitPortType::ResourceID: + return XML_3MF_ELEMENT_IMPLICIT_PORT_TYPE_RESOURCE_ID; + default: + return "Invalid"; + } + } + + void CModelWriterNode_Implicit::writeImplicitFunctionInputs(NMR::Ports & ports) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMPLICIT_FUNCTION_INPUT, + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + + for (auto & port : ports) + { + writeStartElementWithPrefix(portTypeToName(port->getType()), + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID, port->getIdentifier()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME, + port->getDisplayName()); + } + writeFullEndElement(); + } + writeFullEndElement(); + } + + void CModelWriterNode_Implicit::writeImplicitFunctionOutputs(NMR::Ports & ports) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMPLICIT_FUNCTION_OUTPUT, + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + + for (auto & port : ports) + { + writeStartElementWithPrefix(portTypeToRefName(port->getType()), + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID, port->getIdentifier()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME, + port->getDisplayName()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_REFERENCE, + port->getReference()); + } + writeFullEndElement(); + } + writeFullEndElement(); + } + + void NMR::CModelWriterNode_Implicit::writeImplicitOutputs(NMR::Ports & ports) + { + for (auto & port : ports) + { + writeStartElementWithPrefix(portTypeToName(port->getType()), + XML_3MF_NAMESPACEPREFIX_IMPLICIT); + { + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_ID, port->getIdentifier()); + writeStringAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_PORT_DISPLAY_NAME, + port->getDisplayName()); + } + writeFullEndElement(); + } + } +} diff --git a/Source/Model/Writer/NMR_ModelWriterNode_LevelSet.cpp b/Source/Model/Writer/NMR_ModelWriterNode_LevelSet.cpp new file mode 100644 index 0000000..af5e573 --- /dev/null +++ b/Source/Model/Writer/NMR_ModelWriterNode_LevelSet.cpp @@ -0,0 +1,152 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Writer node for LevelSet resources + +--*/ +#include "Model/Writer/NMR_ModelWriterNode_LevelSet.h" + +#include + +#include "Common/NMR_Exception.h" +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "Model/Classes/NMR_ModelLevelSetObject.h" +#include "Model/Classes/NMR_ModelMeshObject.h" +#include "lib3mf_types.hpp" + +namespace NMR +{ + CModelWriterNode_LevelSet::CModelWriterNode_LevelSet( + CModel* pModel, + CModelLevelSetObject * pLevelSet, + CXmlWriter* pXMLWriter, + PProgressMonitor pProgressMonitor) + : CModelWriterNode_ModelBase(pModel, pXMLWriter, pProgressMonitor), m_pLevelSet(pLevelSet) + { + } + + void CModelWriterNode_LevelSet::writeLevelSetResources() + { + nfUint32 const nCount = m_pModel->getObjectCount(); + + for(nfUint32 nIndex = 0; nIndex < nCount; nIndex++) + { + m_pProgressMonitor->IncrementProgress(1); + CModelLevelSetObject* pLevelSet = + dynamic_cast( + m_pModel->getObject(nIndex)); + if(!pLevelSet) + { + continue; + } + writeLevelSetResource(*pLevelSet); + } + } + + void CModelWriterNode_LevelSet::writeLevelSetResource( + CModelLevelSetObject& levelSet) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_BOUNDARY_SHAPE, XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + + auto function = levelSet.getFunction(); + if(!function) + { + throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + } + + PPackageResourceID functionPackageID = function->getPackageResourceID(); + + + + if(!functionPackageID) throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + writeIntAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID, + functionPackageID->getModelResourceID()); + + + PModelMeshObject mesh = levelSet.getMesh(); + if(!mesh) + { + throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + } + + PPackageResourceID meshPackageID = mesh->getPackageResourceID(); + if(!meshPackageID) + { + throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + } + writeIntAttribute(XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MESH_ID, + meshPackageID->getModelResourceID()); + + if(!fnMATRIX3_isIdentity(levelSet.getTransform())) + { + writeStringAttribute(XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_TRANSFORM, + fnMATRIX3_toString(levelSet.getTransform())); + } + + if(!levelSet.getChannelName().empty()) + { + writeStringAttribute(XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_CHANNEL, + levelSet.getChannelName()); + } + else + { + writeStringAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_CHANNEL, + XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_CHANNEL_DEFAULT); + } + + writeStringAttribute(XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MESH_BBOX_ONLY, + levelSet.getMeshBBoxOnly() ? "true" : "false"); + if(levelSet.getMinFeatureSize() != 0.0) + { + writeFloatAttribute(XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_MIN_FEATURE_SIZE, + float(levelSet.getMinFeatureSize())); + } + + if(levelSet.getFallBackValue() != 0.0) + { + writeFloatAttribute(XML_3MF_ATTRIBUTE_BOUNDARY_SHAPE_FALLBACK_VALUE, + float(levelSet.getFallBackValue())); + } + + auto pVolumeData = levelSet.getVolumeData(); + if (pVolumeData) { + PPackageResourceID pID = pVolumeData->getPackageResourceID(); + if (pID->getPath() != m_pModel->currentPath()) + throw CNMRException(NMR_ERROR_MODELRESOURCE_IN_DIFFERENT_MODEL); + writeIntAttribute(XML_3MF_ATTRIBUTE_LEVELSET_VOLUMEDATA, pID->getModelResourceID()); + } + writeFullEndElement(); + } + void CModelWriterNode_LevelSet::writeToXML() + { + if (m_pLevelSet) + { + writeLevelSetResource(*m_pLevelSet); + } + } + +} // namespace NMR diff --git a/Source/Model/Writer/NMR_ModelWriterNode_VolumeData.cpp b/Source/Model/Writer/NMR_ModelWriterNode_VolumeData.cpp new file mode 100644 index 0000000..84f6fd4 --- /dev/null +++ b/Source/Model/Writer/NMR_ModelWriterNode_VolumeData.cpp @@ -0,0 +1,181 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: +Writer node for VolumeData resources + +--*/ +#include "Model/Writer/NMR_ModelWriterNode_VolumeData.h" +#include + +#include "Common/NMR_Exception.h" +#include "Model/Classes/NMR_ImplicitNodeTypes.h" +#include "lib3mf_types.hpp" + +namespace NMR +{ + CModelWriterNode_VolumeData::CModelWriterNode_VolumeData( + CModel* pModel, CXmlWriter* pXMLWriter, + PProgressMonitor pProgressMonitor) + : CModelWriterNode_ModelBase(pModel, pXMLWriter, pProgressMonitor) + { + } + + void CModelWriterNode_VolumeData::writeVolumeDataResources() + { + nfUint32 const nCount = m_pModel->getVolumeDataCount(); + + for(nfUint32 nIndex = 0; nIndex < nCount; nIndex++) + { + m_pProgressMonitor->IncrementProgress(1); + CModelVolumeData * pVolumeData = m_pModel->getVolumeData(nIndex); + if(!pVolumeData) + { + continue; + } + writeVolumeDataResource(*pVolumeData); + } + } + + void CModelWriterNode_VolumeData::writeToXML() + { + writeVolumeDataResources(); + } + + void CModelWriterNode_VolumeData::writeVolumeDataResource( + CModelVolumeData& volumeData) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_VOLUMEDATA, + XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + + writeIntAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_ID, volumeData.getPackageResourceID()->getModelResourceID()); + + if(volumeData.getPropertyCount()) + { + nfUint32 count = volumeData.getPropertyCount(); + + for(nfUint32 i = 0; i < count; i++) + { + PVolumeDataProperty pProperty = volumeData.getProperty(i); + if(pProperty) + { + writeProperty(*pProperty); + } + } + } + + if(volumeData.hasColor()) + { + PVolumeDataColor pColor = volumeData.getColor(); + if(pColor) + { + writeColor(*pColor); + } + } + + writeFullEndElement(); + } + + void CModelWriterNode_VolumeData::writeProperty( + CVolumeDataProperty& property) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_VOLUMETRIC_PROPERTY, + XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + writeStringAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY, + property.getName()); + if(!fnMATRIX3_isIdentity(property.getTransform())) + { + writeStringAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_TRANSFORM, + fnMATRIX3_toString(property.getTransform())); + } + PPackageResourceID pID = + m_pModel->findPackageResourceID(property.getFunctionResourceID()); + if(!pID) throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + writeIntAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID, + pID->getModelResourceID()); + if(!property.isRequired()) + writeStringAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_PROPERTY_REQUIRED, + "false"); + + if(!property.getChannelName().empty()) + { + writeStringAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_CHANNEL, + property.getChannelName()); + } + + if(property.getMinFeatureSize() != 0.0) + { + writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE, + float(property.getMinFeatureSize())); + } + + if(property.getFallBackValue() != 0.0) + { + writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE, + float(property.getFallBackValue())); + } + + writeEndElement(); + } + + void CModelWriterNode_VolumeData::writeColor(CVolumeDataColor& color) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_VOLUMETRIC_COLOR, + XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + + PPackageResourceID pID = + m_pModel->findPackageResourceID(color.getFunctionResourceID()); + if(!pID) throw CNMRException(NMR_ERROR_INVALIDMODELRESOURCE); + writeIntAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FUNCTIONID, + pID->getModelResourceID()); + + if(!fnMATRIX3_isIdentity(color.getTransform())) + { + writeStringAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_TRANSFORM, + fnMATRIX3_toString(color.getTransform())); + } + + if(!color.getChannelName().empty()) + { + writeStringAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_CHANNEL, + color.getChannelName()); + } + + if(color.getMinFeatureSize() != 0.0) + { + writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_MINFEATURESIZE, + float(color.getMinFeatureSize())); + } + + if(color.getFallBackValue() != 0.0) + { + writeFloatAttribute(XML_3MF_ATTRIBUTE_VOLUMEDATA_FALLBACKVALUE, + float(color.getFallBackValue())); + } + + writeEndElement(); + } +} // namespace NMR diff --git a/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp b/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp index 7bf7565..d3580fd 100644 --- a/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp +++ b/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp @@ -39,7 +39,7 @@ This is the class for exporting the 3mf keystore stream root node. #include "Common/NMR_Exception.h" #include "Common/NMR_StringUtils.h" #include "Common/NMR_UUID.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" #include #include @@ -182,7 +182,8 @@ void NMR::CModelWriterNode_KeyStore::writeAccessRight(PKeyStoreAccessRight const writeStartElement(XML_3MF_ELEMENT_CIPHERDATA); // writeStartElementWithPrefix(XML_3MF_ELEMENT_CIPHERVALUE, XML_3MF_NAMESPACEPREFIX_XENC); - std::string encodedCv = base64_encode(ar->getCipherValue()); + std::string input(ar->getCipherValue().begin(), ar->getCipherValue().end()); + std::string encodedCv = base64_encode(input); writeText(encodedCv.c_str(), (nfUint32)encodedCv.length()); // writeFullEndElement(); @@ -209,7 +210,8 @@ void NMR::CModelWriterNode_KeyStore::writeResourceData(PKeyStoreResourceData con std::vector const & iv = rd->getInitVector(); if (!iv.empty()) { writeStartElement(XML_3MF_SECURE_CONTENT_IV); - std::string encodedIv = base64_encode(iv); + std::string input(iv.begin(), iv.end()); + std::string encodedIv = base64_encode(input); writeText(encodedIv.c_str(), (nfUint32)encodedIv.length()); writeFullEndElement(); } @@ -217,7 +219,8 @@ void NMR::CModelWriterNode_KeyStore::writeResourceData(PKeyStoreResourceData con std::vector const & tag = rd->getAuthTag(); if (!tag.empty()) { writeStartElement(XML_3MF_SECURE_CONTENT_TAG); - std::string encodedTag = base64_encode(tag); + std::string input(tag.begin(), tag.end()); + std::string encodedTag = base64_encode(input); writeText(encodedTag.c_str(), (nfUint32)encodedTag.length()); writeFullEndElement(); } @@ -225,7 +228,8 @@ void NMR::CModelWriterNode_KeyStore::writeResourceData(PKeyStoreResourceData con std::vector const & aad = rd->getAddAuthData(); if (!aad.empty()) { writeStartElement(XML_3MF_SECURE_CONTENT_AAD); - std::string encodedAad = base64_encode(aad); + std::string input(aad.begin(), aad.end()); + std::string encodedAad = base64_encode(input); writeText(encodedAad.c_str(), (nfUint32)encodedAad.length()); writeFullEndElement(); } diff --git a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp index d25fb17..633cee2 100644 --- a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp +++ b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Mesh.cpp @@ -51,8 +51,8 @@ This is the class for exporting the 3mf mesh node. namespace NMR { CModelWriterNode100_Mesh::CModelWriterNode100_Mesh(_In_ CModelMeshObject * pModelMeshObject, _In_ CXmlWriter * pXMLWriter, _In_ PProgressMonitor pProgressMonitor, - _In_ PMeshInformation_PropertyIndexMapping pPropertyIndexMapping, _In_ int nPosAfterDecPoint, _In_ nfBool bWriteMaterialExtension, _In_ nfBool bWriteBeamLatticeExtension) - :CModelWriterNode_ModelBase(pModelMeshObject->getModel(), pXMLWriter, pProgressMonitor), m_nPosAfterDecPoint(nPosAfterDecPoint), m_nPutDoubleFactor((int)(pow(10, CModelWriterNode100_Mesh::m_nPosAfterDecPoint))) + _In_ PMeshInformation_PropertyIndexMapping pPropertyIndexMapping, _In_ int nPosAfterDecPoint, _In_ nfBool bWriteMaterialExtension, _In_ nfBool bWriteBeamLatticeExtension, _In_ nfBool bWriteBeamLatticeBallsExtension, _In_ nfBool bWriteVolumetricExtension, _In_ nfBool bWriteTriangleSetExtension) + :CModelWriterNode_ModelBase(pModelMeshObject->getModel(), pXMLWriter, pProgressMonitor), m_nPosAfterDecPoint(nPosAfterDecPoint), m_nPutDoubleFactor((nfInt64)(pow(10, CModelWriterNode100_Mesh::m_nPosAfterDecPoint))) { __NMRASSERT(pModelMeshObject != nullptr); if (!pPropertyIndexMapping.get()) @@ -60,6 +60,9 @@ namespace NMR { m_bWriteMaterialExtension = bWriteMaterialExtension; m_bWriteBeamLatticeExtension = bWriteBeamLatticeExtension; + m_bWriteBeamLatticeBallsExtension = bWriteBeamLatticeBallsExtension; + m_bWriteVolumetricExtension = bWriteVolumetricExtension; + m_bWriteTriangleSetExtension = bWriteTriangleSetExtension; m_pModelMeshObject = pModelMeshObject; m_pPropertyIndexMapping = pPropertyIndexMapping; @@ -71,15 +74,17 @@ namespace NMR { m_nBallBufferPos = 0; m_nBeamRefBufferPos = 0; m_nBallRefBufferPos = 0; + m_nTriangleSetRefBufferPos = 0; putVertexString(MODELWRITERMESH100_VERTEXLINESTART); putTriangleString(MODELWRITERMESH100_TRIANGLELINESTART); putBeamString(MODELWRITERMESH100_BEAMLATTICE_BEAMLINESTART); putBallString(MODELWRITERMESH100_BEAMLATTICE_BALLLINESTART); putBeamRefString(MODELWRITERMESH100_BEAMLATTICE_REFLINESTART); putBallRefString(MODELWRITERMESH100_BEAMLATTICE_BALLREFLINESTART); + putTriangleSetRefString(MODELWRITERMESH100_TRIANGLESETS_REFLINESTART); } - bool stringRepresentationsDiffer(double a, double b, double putFactor) { + bool stringRepresentationsDiffer(double a, double b, nfInt64 putFactor) { return fabs(a - b) * putFactor > 0.1; } @@ -130,6 +135,19 @@ namespace NMR { writeStartElement(XML_3MF_ELEMENT_MESH); m_pProgressMonitor->SetProgressIdentifier(ProgressIdentifier::PROGRESS_WRITENODES); + + // Write id of referenced volume data, if any + if (m_bWriteVolumetricExtension) { + auto pVolumeData = m_pModelMeshObject->getVolumeData(); + if (pVolumeData) { + PPackageResourceID pID = pVolumeData->getPackageResourceID(); + if (pID->getPath() != m_pModel->currentPath()) + throw CNMRException(NMR_ERROR_MODELRESOURCE_IN_DIFFERENT_MODEL); + writePrefixedIntAttribute(XML_3MF_NAMESPACEPREFIX_VOLUMETRIC, XML_3MF_ATTRIBUTE_MESH_VOLUMEDATA, pID->getModelResourceID()); + } + } + + // Write Vertices writeStartElement(XML_3MF_ELEMENT_VERTICES); for (nNodeIndex = 0; nNodeIndex < nNodeCount; nNodeIndex++) { @@ -248,6 +266,32 @@ namespace NMR { } writeFullEndElement(); + + if (m_bWriteTriangleSetExtension) { + uint32_t nTriangleSetCount = m_pModelMeshObject->getTriangleSetCount(); + + if (nTriangleSetCount > 0) { + writeStartElementWithPrefix(XML_3MF_ELEMENT_TRIANGLESETS, XML_3MF_NAMESPACEPREFIX_TRIANGLESETS); + + for (uint32_t nTriangleSetIndex = 0; nTriangleSetIndex < nTriangleSetCount; nTriangleSetIndex++) { + auto pTriangleSet = m_pModelMeshObject->getTriangleSet(nTriangleSetIndex); + writeStartElementWithPrefix(XML_3MF_ELEMENT_TRIANGLESET, XML_3MF_NAMESPACEPREFIX_TRIANGLESETS); + writeStringAttribute(XML_3MF_ATTRIBUTE_TRIANGLESET_IDENTIFIER, pTriangleSet->getIdentifier ()); + writeStringAttribute(XML_3MF_ATTRIBUTE_TRIANGLESET_NAME, pTriangleSet->getName()); + + auto triangleRefs = pTriangleSet->getTriangles(); + for (auto triangleRef : triangleRefs) { + writeTriangleSetRefData (triangleRef); + } + + writeFullEndElement(); + } + + writeFullEndElement(); + } + } + + if (bMeshHasAProperty && !(nObjectLevelPropertyID != 0)) { throw CNMRException(NMR_ERROR_MISSINGOBJECTLEVELPID); } @@ -323,7 +367,7 @@ namespace NMR { // write beamlattice: balls // Only if there is at least 1 ball if (bWriteBallsElement) { - writeStartElementWithPrefix(XML_3MF_ELEMENT_BALLS, XML_3MF_NAMESPACEPREFIX_BEAMLATTICE); + writeStartElementWithPrefix(XML_3MF_ELEMENT_BALLS, XML_3MF_NAMESPACEPREFIX_BEAMLATTICEBALLS); for (nBallIndex = 0; nBallIndex < nBallCount; nBallIndex++) { // write beamlattice: ball MESHBALL * pMeshBall = pMesh->getBall(nBallIndex); @@ -596,6 +640,34 @@ namespace NMR { m_nBeamRefBufferPos += nCount; } + void CModelWriterNode100_Mesh::putTriangleSetRefString(_In_ const nfChar* pszString) + { + __NMRASSERT(pszString); + const nfChar* pChar = pszString; + nfChar* pTarget = &m_TriangleSetRefLine[m_nTriangleSetRefBufferPos]; + + while (*pChar != 0) { + *pTarget = *pChar; + pTarget++; + pChar++; + m_nTriangleSetRefBufferPos++; + } + } + + void CModelWriterNode100_Mesh::putTriangleSetRefUInt32(_In_ const nfUint32 nValue) + { +#ifdef __GNUC__ + int nCount = sprintf(&m_TriangleSetRefLine[m_nTriangleSetRefBufferPos], "%d", nValue); +#else + int nCount = sprintf_s(&m_TriangleSetRefLine[m_nTriangleSetRefBufferPos], MODELWRITERMESH100_LINEBUFFERSIZE - m_nTriangleSetRefBufferPos, "%d", nValue); +#endif // __GNUC__ + + if (nCount < 1) + throw CNMRException(NMR_ERROR_COULDNOTCONVERTNUMBER); + m_nTriangleSetRefBufferPos += nCount; + } + + void CModelWriterNode100_Mesh::putBallRefString(_In_ const nfChar* pszString) { __NMRASSERT(pszString); @@ -778,4 +850,12 @@ namespace NMR { m_pXMLWriter->WriteRawLine(&m_BallRefLine[0], m_nBallRefBufferPos); } + __NMR_INLINE void CModelWriterNode100_Mesh::writeTriangleSetRefData(_In_ INT nRefID) + { + m_nTriangleSetRefBufferPos = MODELWRITERMESH100_TRIANGLESETS_REFSTARTLENGTH; + putTriangleSetRefUInt32(nRefID); + putTriangleSetRefString("\"/>"); + m_pXMLWriter->WriteRawLine(&m_TriangleSetRefLine[0], m_nTriangleSetRefBufferPos); + } + } diff --git a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp index fdf97fa..53b659e 100644 --- a/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp +++ b/Source/Model/Writer/v100/NMR_ModelWriterNode100_Model.cpp @@ -33,6 +33,7 @@ This is the class for exporting the 3mf model stream root node. #include "Model/Writer/v100/NMR_ModelWriterNode100_Mesh.h" #include "Model/Writer/v100/NMR_ModelWriterNode100_Model.h" +#include "Model/Writer/v100/NMR_ResourceDependencySorter.h" #include "Model/Classes/NMR_ModelAttachment.h" #include "Model/Classes/NMR_ModelBuildItem.h" @@ -41,6 +42,9 @@ This is the class for exporting the 3mf model stream root node. #include "Model/Classes/NMR_ModelColorGroup.h" #include "Model/Classes/NMR_ModelTexture2D.h" #include "Model/Classes/NMR_ModelTexture2DGroup.h" +#include "Model/Classes/NMR_ModelImage3D.h" +#include "Model/Classes/NMR_ModelImageStack.h" +#include "Model/Classes/NMR_ModelFunctionFromImage3D.h" #include "Model/Classes/NMR_ModelCompositeMaterials.h" #include "Model/Classes/NMR_ModelMultiPropertyGroup.h" #include "Model/Classes/NMR_ModelMeshObject.h" @@ -50,11 +54,19 @@ This is the class for exporting the 3mf model stream root node. #include "Common/NMR_Exception_Windows.h" #include "Common/NMR_StringUtils.h" #include "Common/MeshInformation/NMR_MeshInformation_Properties.h" +#include "Common/Graph/DirectedGraph.h" +#include "Common/Graph/GraphAlgorithms.h" #include "Model/Classes/NMR_ModelConstants_Slices.h" +#include "Model/Classes/NMR_ModelImplicitFunction.h" +#include "Model/Classes/NMR_ModelLevelSetObject.h" +#include "Model/Classes/NMR_ModelVolumeData.h" +#include "Model/Writer/NMR_ModelWriterNode_Implicit.h" +#include "Model/Writer/NMR_ModelWriterNode_LevelSet.h" +#include "Model/Writer/NMR_ModelWriterNode_VolumeData.h" + #include "Common/3MF_ProgressMonitor.h" - namespace NMR { CModelWriterNode100_Model::CModelWriterNode100_Model(_In_ CModel * pModel, _In_ CXmlWriter * pXMLWriter, _In_ PProgressMonitor pProgressMonitor, @@ -66,10 +78,14 @@ namespace NMR { m_bWriteMaterialExtension = true; m_bWriteProductionExtension = true; m_bWriteBeamLatticeExtension = true; + m_bWriteBeamLatticeBallsExtension = false; m_bWriteSliceExtension = true; m_bWriteSecureContentExtension = true; + m_bWriteTriangleSetExtension = true; m_bWriteBaseMaterials = true; m_bWriteObjects = true; + m_bWriteVolumetricExtension = true; + m_bWriteImplicitExtension = true; m_bWriteCustomNamespaces = true; @@ -116,6 +132,9 @@ namespace NMR { { std::string sLanguage = m_pModel->getLanguage(); + // Detect required extensions before writing namespace declarations + detectRequiredExtensions(); + writeStartElementWithNamespace(XML_3MF_ELEMENT_MODEL, PACKAGE_XMLNS_100); writeStringAttribute(XML_3MF_ATTRIBUTE_MODEL_UNIT, m_pModel->getUnitString()); @@ -143,6 +162,16 @@ namespace NMR { } } + if (m_bWriteBeamLatticeBallsExtension) { + writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_BEAMLATTICEBALLS, XML_3MF_NAMESPACE_BEAMLATTICEBALLSSPEC); + + if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_BEAMLATTICEBALLSSPEC)) { + if (sRequiredExtensions.size() > 0) + sRequiredExtensions = sRequiredExtensions + " "; + sRequiredExtensions = sRequiredExtensions + XML_3MF_NAMESPACEPREFIX_BEAMLATTICEBALLS; + } + } + if (m_bWriteSliceExtension) { writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_SLICE, XML_3MF_NAMESPACE_SLICESPEC); if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_SLICESPEC)) { @@ -152,6 +181,15 @@ namespace NMR { } } + if (m_bWriteTriangleSetExtension) { + writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_TRIANGLESETS, XML_3MF_NAMESPACE_TRIANGLESETS); + if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_TRIANGLESETS)) { + if (sRequiredExtensions.size() > 0) + sRequiredExtensions = sRequiredExtensions + " "; + sRequiredExtensions = sRequiredExtensions + XML_3MF_NAMESPACEPREFIX_TRIANGLESETS; + } + } + if (m_bWriteSecureContentExtension) { writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_SECURECONTENT, XML_3MF_NAMESPACE_SECURECONTENTSPEC); if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_SECURECONTENTSPEC)) { @@ -161,6 +199,24 @@ namespace NMR { } } + if (m_bWriteVolumetricExtension) { + writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_VOLUMETRIC, XML_3MF_NAMESPACE_VOLUMETRICSPEC); + if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_VOLUMETRICSPEC)) { + if (sRequiredExtensions.size() > 0) + sRequiredExtensions = sRequiredExtensions + " "; + sRequiredExtensions = sRequiredExtensions + XML_3MF_NAMESPACEPREFIX_VOLUMETRIC; + } + } + + if (m_bWriteImplicitExtension) { + writeConstPrefixedStringAttribute(XML_3MF_ATTRIBUTE_XMLNS, XML_3MF_NAMESPACEPREFIX_IMPLICIT, XML_3MF_NAMESPACE_IMPLICITSPEC); + if (m_pModel->RequireExtension(XML_3MF_NAMESPACE_IMPLICITSPEC)) { + if (sRequiredExtensions.size() > 0) + sRequiredExtensions = sRequiredExtensions + " "; + sRequiredExtensions = sRequiredExtensions + XML_3MF_NAMESPACEPREFIX_IMPLICIT; + } + } + if (m_bWriteCustomNamespaces) { nfUint32 nNSCount = m_pXMLWriter->GetNamespaceCount(); for (nfUint32 iNSCount = 0; iNSCount < nNSCount; iNSCount++) { @@ -190,35 +246,54 @@ namespace NMR { CModelTexture2DResource * pTexture2D = m_pModel->getTexture2D(nTextureIndex); - writeStartElementWithPrefix(XML_3MF_ELEMENT_TEXTURE2D, XML_3MF_NAMESPACEPREFIX_MATERIAL); - - assertResourceIsInCurrentPath(pTexture2D->getPackageResourceID()); - writeIntAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_ID, pTexture2D->getPackageResourceID()->getModelResourceID()); - writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_PATH, pTexture2D->getAttachment()->getPathURI()); - writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_CONTENTTYPE, pTexture2D->getContentTypeString()); - - if (pTexture2D->getTileStyleU() != MODELTEXTURETILESTYLE_WRAP) - writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLEU, CModelTexture2DResource::tileStyleToString(pTexture2D->getTileStyleU())); - if (pTexture2D->getTileStyleV() != MODELTEXTURETILESTYLE_WRAP) - writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLEV, CModelTexture2DResource::tileStyleToString(pTexture2D->getTileStyleV())); - if (pTexture2D->getFilter() != MODELTEXTUREFILTER_AUTO) - writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_FILTER, CModelTexture2DResource::filterToString(pTexture2D->getFilter())); - - if (pTexture2D->hasBox2D()) { - nfFloat fU, fV, fWidth, fHeight; - pTexture2D->getBox2D(fU, fV, fWidth, fHeight); - writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_BOX, - std::to_string(fU) + " " + std::to_string(fV) + " " + std::to_string(fWidth) + " " + std::to_string(fHeight)); - } - - writeEndElement(); - - } + writeTexture2D(pTexture2D); + } } - void CModelWriterNode100_Model::writeModelMetaData() + void CModelWriterNode100_Model::writeTexture2D( + CModelTexture2DResource *pTexture2D) { + writeStartElementWithPrefix(XML_3MF_ELEMENT_TEXTURE2D, + XML_3MF_NAMESPACEPREFIX_MATERIAL); + + assertResourceIsInCurrentPath(pTexture2D->getPackageResourceID()); + writeIntAttribute( + XML_3MF_ATTRIBUTE_TEXTURE2D_ID, + pTexture2D->getPackageResourceID()->getModelResourceID()); + writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_PATH, + pTexture2D->getAttachment()->getPathURI()); + writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_CONTENTTYPE, + pTexture2D->getContentTypeString()); + + if(pTexture2D->getTileStyleU() != MODELTEXTURETILESTYLE_WRAP) + writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLEU, + CModelTexture2DResource::tileStyleToString( + pTexture2D->getTileStyleU())); + if(pTexture2D->getTileStyleV() != MODELTEXTURETILESTYLE_WRAP) + writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_TILESTYLEV, + CModelTexture2DResource::tileStyleToString( + pTexture2D->getTileStyleV())); + if(pTexture2D->getFilter() != MODELTEXTUREFILTER_AUTO) + writeStringAttribute(XML_3MF_ATTRIBUTE_TEXTURE2D_FILTER, + CModelTexture2DResource::filterToString( + pTexture2D->getFilter())); + + if(pTexture2D->hasBox2D()) + { + nfFloat fU, fV, fWidth, fHeight; + pTexture2D->getBox2D(fU, fV, fWidth, fHeight); + writeStringAttribute( + XML_3MF_ATTRIBUTE_TEXTURE2D_BOX, + std::to_string(fU) + " " + std::to_string(fV) + " " + + std::to_string(fWidth) + " " + std::to_string(fHeight)); + } + + writeEndElement(); + } + + void CModelWriterNode100_Model::writeModelMetaData() + { if (m_bIsRootModel) { nfUint32 nMetaDataCount = m_pModel->getMetaDataCount(); @@ -240,42 +315,56 @@ namespace NMR { m_pProgressMonitor->IncrementProgress(1); CModelBaseMaterialResource * pBaseMaterial = m_pModel->getBaseMaterial(nMaterialIndex); - - pBaseMaterial->buildResourceIndexMap(); - - assertResourceIsInCurrentPath(pBaseMaterial->getPackageResourceID()); - ModelResourceID nResourceID = pBaseMaterial->getPackageResourceID()->getModelResourceID(); - - writeStartElement(XML_3MF_ELEMENT_BASEMATERIALS); - // Write Object ID (mandatory) - writeIntAttribute(XML_3MF_ATTRIBUTE_BASEMATERIALS_ID, nResourceID); - - nfUint32 nElementCount = pBaseMaterial->getCount(); - - UniqueResourceID nUniqueResourceID = pBaseMaterial->getPackageResourceID()->getUniqueID(); - - for (nfUint32 j = 0; j < nElementCount; j++) { - ModelPropertyID nPropertyID; - if (!pBaseMaterial->mapResourceIndexToPropertyID(j, nPropertyID)) { - throw CNMRException(NMR_ERROR_INVALIDPROPERTYRESOURCEID); - } - PModelBaseMaterial pElement = pBaseMaterial->getBaseMaterial(nPropertyID); - - m_pPropertyIndexMapping->registerPropertyID(nUniqueResourceID, pElement->getPropertyID(), j); - - writeStartElement(XML_3MF_ELEMENT_BASE); - writeStringAttribute(XML_3MF_ATTRIBUTE_BASEMATERIAL_NAME, pElement->getName()); - writeStringAttribute(XML_3MF_ATTRIBUTE_BASEMATERIAL_DISPLAYCOLOR, pElement->getDisplayColorString()); - writeEndElement(); - } - - writeFullEndElement(); + writeBaseMaterial(pBaseMaterial); } } + void CModelWriterNode100_Model::writeBaseMaterial( + CModelBaseMaterialResource *pBaseMaterial) + { + pBaseMaterial->buildResourceIndexMap(); - void CModelWriterNode100_Model::writeSliceStacks() { + assertResourceIsInCurrentPath( + pBaseMaterial->getPackageResourceID()); + ModelResourceID nResourceID = + pBaseMaterial->getPackageResourceID()->getModelResourceID(); + + writeStartElement(XML_3MF_ELEMENT_BASEMATERIALS); + // Write Object ID (mandatory) + writeIntAttribute(XML_3MF_ATTRIBUTE_BASEMATERIALS_ID, nResourceID); + + nfUint32 nElementCount = pBaseMaterial->getCount(); + + UniqueResourceID nUniqueResourceID = + pBaseMaterial->getPackageResourceID()->getUniqueID(); + + for(nfUint32 j = 0; j < nElementCount; j++) + { + ModelPropertyID nPropertyID; + if(!pBaseMaterial->mapResourceIndexToPropertyID(j, nPropertyID)) + { + throw CNMRException(NMR_ERROR_INVALIDPROPERTYRESOURCEID); + } + PModelBaseMaterial pElement = + pBaseMaterial->getBaseMaterial(nPropertyID); + + m_pPropertyIndexMapping->registerPropertyID( + nUniqueResourceID, pElement->getPropertyID(), j); + + writeStartElement(XML_3MF_ELEMENT_BASE); + writeStringAttribute(XML_3MF_ATTRIBUTE_BASEMATERIAL_NAME, + pElement->getName()); + writeStringAttribute( + XML_3MF_ATTRIBUTE_BASEMATERIAL_DISPLAYCOLOR, + pElement->getDisplayColorString()); + writeEndElement(); + } + + writeFullEndElement(); + } + + void CModelWriterNode100_Model::writeSliceStacks() { nfUint32 nSliceStackCount = m_pModel->getSliceStackCount(); for (nfUint32 nSliceStackIndex = 0; nSliceStackIndex < nSliceStackCount; nSliceStackIndex++) { @@ -376,116 +465,193 @@ namespace NMR { { std::list objectList = m_pModel->getSortedObjectList(); - for (auto iIterator = objectList.begin(); iIterator != objectList.end(); iIterator++) { - CModelObject * pObject = *iIterator; - - PPackageModelPath pPath = pObject->getPackageResourceID()->getPackageModelPath(); - if (m_pModel->currentModelPath()->getPath() != pPath->getPath()) + for(auto iIterator = objectList.begin(); + iIterator != objectList.end(); iIterator++) + { + CModelObject *pObject = *iIterator; + if (!pObject) { - continue; + throw CNMRException(NMR_ERROR_INVALIDMODEL); } + writeObject(*pObject); + } + } - m_pProgressMonitor->SetProgressIdentifier(ProgressIdentifier::PROGRESS_WRITEOBJECTS); - m_pProgressMonitor->IncrementProgress(1); - m_pProgressMonitor->ReportProgressAndQueryCancelled(true); + void CModelWriterNode100_Model::writeObject(CModelObject &object) + { + PPackageModelPath pPath = + object.getPackageResourceID()->getPackageModelPath(); + if(m_pModel->currentModelPath()->getPath() != pPath->getPath()) + { + return; + } - writeStartElement(XML_3MF_ELEMENT_OBJECT); - // Write Object ID (mandatory) - writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_ID, pObject->getPackageResourceID()->getModelResourceID()); + m_pProgressMonitor->SetProgressIdentifier( + ProgressIdentifier::PROGRESS_WRITEOBJECTS); + m_pProgressMonitor->IncrementProgress(1); + m_pProgressMonitor->ReportProgressAndQueryCancelled(true); - // Write Object Name (optional) - std::string sObjectName = pObject->getName(); - if (sObjectName.length() > 0) - writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_NAME, sObjectName); + writeStartElement(XML_3MF_ELEMENT_OBJECT); + // Write Object ID (mandatory) + writeIntAttribute( + XML_3MF_ATTRIBUTE_OBJECT_ID, + object.getPackageResourceID()->getModelResourceID()); - // Write Object Partnumber (optional) - std::string sObjectPartNumber = pObject->getPartNumber(); - if (sObjectPartNumber.length() > 0) - writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_PARTNUMBER, sObjectPartNumber); + // Write Object Name (optional) + std::string sObjectName = object.getName(); + if(sObjectName.length() > 0) + writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_NAME, + sObjectName); - // Write Object Type (optional) - writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_TYPE, pObject->getObjectTypeString()); + // Write Object Partnumber (optional) + std::string sObjectPartNumber = object.getPartNumber(); + if(sObjectPartNumber.length() > 0) + writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_PARTNUMBER, + sObjectPartNumber); - // Write Object Thumbnail (optional) - PModelAttachment pThumbnail = pObject->getThumbnailAttachment(); - if (pThumbnail) { - PModelAttachment pModelAttachment = m_pModel->findModelAttachment(pThumbnail->getPathURI()); - if (!pModelAttachment) - throw CNMRException(NMR_ERROR_NOTEXTURESTREAM); - if (!((pModelAttachment->getRelationShipType() == PACKAGE_TEXTURE_RELATIONSHIP_TYPE) || (pModelAttachment->getRelationShipType() == PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE))) - throw CNMRException(NMR_ERROR_NOTEXTURESTREAM); + // Write Object Type (optional) + writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_TYPE, + object.getObjectTypeString()); - writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_THUMBNAIL, pThumbnail->getPathURI()); + // Write Object Thumbnail (optional) + PModelAttachment pThumbnail = object.getThumbnailAttachment(); + if(pThumbnail) + { + PModelAttachment pModelAttachment = + m_pModel->findModelAttachment(pThumbnail->getPathURI()); + if(!pModelAttachment) + throw CNMRException(NMR_ERROR_NOTEXTURESTREAM); + if(!((pModelAttachment->getRelationShipType() == + PACKAGE_TEXTURE_RELATIONSHIP_TYPE) || + (pModelAttachment->getRelationShipType() == + PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE))) + throw CNMRException(NMR_ERROR_NOTEXTURESTREAM); + + writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_THUMBNAIL, + pThumbnail->getPathURI()); + } + + if(m_bWriteProductionExtension) + { + if(!object.uuid().get()) + throw CNMRException(NMR_ERROR_MISSINGUUID); + writePrefixedStringAttribute(XML_3MF_NAMESPACEPREFIX_PRODUCTION, + XML_3MF_PRODUCTION_UUID, + object.uuid()->toString()); + } + + // Slice extension content + if(m_bWriteSliceExtension) + { + if(object.getSliceStack().get()) + { + assertResourceIsInCurrentPath( + object.getSliceStack()->getPackageResourceID()); + writePrefixedStringAttribute( + XML_3MF_NAMESPACEPREFIX_SLICE, + XML_3MF_ATTRIBUTE_OBJECT_SLICESTACKID, + fnUint32ToString(object.getSliceStack() + ->getPackageResourceID() + ->getModelResourceID())); } - - if (m_bWriteProductionExtension) { - if (!pObject->uuid().get()) - throw CNMRException(NMR_ERROR_MISSINGUUID); - writePrefixedStringAttribute(XML_3MF_NAMESPACEPREFIX_PRODUCTION, XML_3MF_PRODUCTION_UUID, pObject->uuid()->toString()); + if(object.slicesMeshResolution() != + MODELSLICESMESHRESOLUTION_FULL) + { + writePrefixedStringAttribute( + XML_3MF_NAMESPACEPREFIX_SLICE, + XML_3MF_ATTRIBUTE_OBJECT_MESHRESOLUTION, + XML_3MF_VALUE_OBJECT_MESHRESOLUTION_LOW); } + } - // Slice extension content - if (m_bWriteSliceExtension) { - if (pObject->getSliceStack().get()) { - assertResourceIsInCurrentPath(pObject->getSliceStack()->getPackageResourceID()); - writePrefixedStringAttribute(XML_3MF_NAMESPACEPREFIX_SLICE, XML_3MF_ATTRIBUTE_OBJECT_SLICESTACKID, - fnUint32ToString(pObject->getSliceStack()->getPackageResourceID()->getModelResourceID())); - } - if (pObject->slicesMeshResolution() != MODELSLICESMESHRESOLUTION_FULL) { - writePrefixedStringAttribute(XML_3MF_NAMESPACEPREFIX_SLICE, XML_3MF_ATTRIBUTE_OBJECT_MESHRESOLUTION, - XML_3MF_VALUE_OBJECT_MESHRESOLUTION_LOW); - } - } + // Check if object is a mesh Object + CModelMeshObject *pMeshObject = + dynamic_cast(&object); + if(pMeshObject) + { + // Prepare Object Level Property ID and Index + UniqueResourceID nObjectLevelPropertyID = 0; + ModelResourceIndex nObjectLevelPropertyIndex = 0; + CMesh *pMesh = pMeshObject->getMesh(); - // Check if object is a mesh Object - CModelMeshObject * pMeshObject = dynamic_cast (pObject); - if (pMeshObject) { - // Prepare Object Level Property ID and Index - UniqueResourceID nObjectLevelPropertyID = 0; - ModelResourceIndex nObjectLevelPropertyIndex = 0; - CMesh* pMesh = pMeshObject->getMesh(); - - if (pMesh) { - CMeshInformationHandler * pMeshInformationHandler = pMesh->getMeshInformationHandler(); - if (pMeshInformationHandler) { - // Get generic property handler - CMeshInformation *pInformation = pMeshInformationHandler->getInformationByType(0, emiProperties); - if (pInformation) { - auto pProperties = dynamic_cast (pInformation); - NMR::MESHINFORMATION_PROPERTIES * pDefaultData = (NMR::MESHINFORMATION_PROPERTIES*)pProperties->getDefaultData(); - if (pDefaultData && pDefaultData->m_nUniqueResourceID != 0) { - nObjectLevelPropertyID = pDefaultData->m_nUniqueResourceID; - nObjectLevelPropertyIndex = m_pPropertyIndexMapping->mapPropertyIDToIndex(nObjectLevelPropertyID, pDefaultData->m_nPropertyIDs[0]); - } + if(pMesh) + { + CMeshInformationHandler *pMeshInformationHandler = + pMesh->getMeshInformationHandler(); + if(pMeshInformationHandler) + { + // Get generic property handler + CMeshInformation *pInformation = + pMeshInformationHandler->getInformationByType( + 0, emiProperties); + if(pInformation) + { + auto pProperties = + dynamic_cast( + pInformation); + NMR::MESHINFORMATION_PROPERTIES *pDefaultData = + (NMR::MESHINFORMATION_PROPERTIES *) + pProperties->getDefaultData(); + if(pDefaultData && + pDefaultData->m_nUniqueResourceID != 0) + { + nObjectLevelPropertyID = + pDefaultData->m_nUniqueResourceID; + nObjectLevelPropertyIndex = + m_pPropertyIndexMapping + ->mapPropertyIDToIndex( + nObjectLevelPropertyID, + pDefaultData->m_nPropertyIDs[0]); } } } - // Write Object Level Attributes (only for meshes) - if (nObjectLevelPropertyID != 0) { - ModelResourceID nPropertyModelResourceID = m_pModel->findPackageResourceID(nObjectLevelPropertyID)->getModelResourceID(); - writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_PID, nPropertyModelResourceID); - writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_PINDEX, nObjectLevelPropertyIndex); - } } - - writeMetaDataGroup(pObject->metaDataGroup()); - - if (pMeshObject) { - CModelWriterNode100_Mesh ModelWriter_Mesh(pMeshObject, m_pXMLWriter, m_pProgressMonitor, - m_pPropertyIndexMapping, m_nDecimalPrecision, m_bWriteMaterialExtension, m_bWriteBeamLatticeExtension); - - ModelWriter_Mesh.writeToXML(); + // Write Object Level Attributes (only for meshes) + if(nObjectLevelPropertyID != 0) + { + ModelResourceID nPropertyModelResourceID = + m_pModel->findPackageResourceID(nObjectLevelPropertyID) + ->getModelResourceID(); + writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_PID, + nPropertyModelResourceID); + writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_PINDEX, + nObjectLevelPropertyIndex); } - - // Check if object is a component Object - CModelComponentsObject * pComponentObject = dynamic_cast (pObject); - if (pComponentObject) { - writeComponentsObject(pComponentObject); - } - - writeFullEndElement(); } + writeMetaDataGroup(object.metaDataGroup()); + + if(pMeshObject) + { + // Beam lattice balls namespace need already determined in detectRequiredExtensions() + + CModelWriterNode100_Mesh ModelWriter_Mesh( + pMeshObject, m_pXMLWriter, m_pProgressMonitor, + m_pPropertyIndexMapping, m_nDecimalPrecision, + m_bWriteMaterialExtension, m_bWriteBeamLatticeExtension, + m_bWriteBeamLatticeBallsExtension, m_bWriteVolumetricExtension, m_bWriteTriangleSetExtension); + + ModelWriter_Mesh.writeToXML(); + } + + // Check if object is a component Object + CModelComponentsObject *pComponentObject = + dynamic_cast(&object); + if(pComponentObject) + { + writeComponentsObject(pComponentObject); + } + + CModelLevelSetObject *pLevelSet = + dynamic_cast(&object); + if(pLevelSet) + { + CModelWriterNode_LevelSet ModelWriter_LevelSet( + m_pModel, pLevelSet, m_pXMLWriter, m_pProgressMonitor); + ModelWriter_LevelSet.writeToXML(); + } + + writeFullEndElement(); } void CModelWriterNode100_Model::writeMetaData(_In_ PModelMetaData pMetaData) @@ -542,36 +708,43 @@ namespace NMR { CModelColorGroupResource * pColorGroup = m_pModel->getColorGroup(nIndex); - pColorGroup->buildResourceIndexMap(); - - assertResourceIsInCurrentPath(pColorGroup->getPackageResourceID()); - ModelResourceID nResourceID = pColorGroup->getPackageResourceID()->getModelResourceID(); - - writeStartElementWithPrefix(XML_3MF_ELEMENT_COLORGROUP, XML_3MF_NAMESPACEPREFIX_MATERIAL); - // Write Object ID (mandatory) - writeIntAttribute(XML_3MF_ATTRIBUTE_COLORS_ID, nResourceID); - - nfUint32 nElementCount = pColorGroup->getCount(); - - UniqueResourceID nUniqueResourceID = pColorGroup->getPackageResourceID()->getUniqueID(); - for (nfUint32 j = 0; j < nElementCount; j++) { - ModelPropertyID nPropertyID; - if (!pColorGroup->mapResourceIndexToPropertyID(j, nPropertyID)) { - throw CNMRException(NMR_ERROR_INVALIDPROPERTYRESOURCEID); - } - nfColor pElement = pColorGroup->getColor(nPropertyID); - - m_pPropertyIndexMapping->registerPropertyID(nUniqueResourceID, nPropertyID, j); - - writeStartElementWithPrefix(XML_3MF_ELEMENT_COLOR, XML_3MF_NAMESPACEPREFIX_MATERIAL); - writeStringAttribute(XML_3MF_ATTRIBUTE_COLORS_COLOR, fnColorToString(pElement)); - writeEndElement(); - } - - writeFullEndElement(); + writeColor(pColorGroup); } } + void CModelWriterNode100_Model::writeColor( + CModelColorGroupResource *pColorGroup) + { + pColorGroup->buildResourceIndexMap(); + + assertResourceIsInCurrentPath(pColorGroup->getPackageResourceID()); + ModelResourceID nResourceID = pColorGroup->getPackageResourceID()->getModelResourceID(); + + writeStartElementWithPrefix(XML_3MF_ELEMENT_COLORGROUP, XML_3MF_NAMESPACEPREFIX_MATERIAL); + // Write Object ID (mandatory) + writeIntAttribute(XML_3MF_ATTRIBUTE_COLORS_ID, nResourceID); + + nfUint32 nElementCount = pColorGroup->getCount(); + + UniqueResourceID nUniqueResourceID = pColorGroup->getPackageResourceID()->getUniqueID(); + for (nfUint32 j = 0; j < nElementCount; j++) { + ModelPropertyID nPropertyID; + if (!pColorGroup->mapResourceIndexToPropertyID(j, nPropertyID)) { + throw CNMRException(NMR_ERROR_INVALIDPROPERTYRESOURCEID); + } + nfColor pElement = pColorGroup->getColor(nPropertyID); + + m_pPropertyIndexMapping->registerPropertyID(nUniqueResourceID, nPropertyID, j); + + writeStartElementWithPrefix(XML_3MF_ELEMENT_COLOR, XML_3MF_NAMESPACEPREFIX_MATERIAL); + writeStringAttribute(XML_3MF_ATTRIBUTE_COLORS_COLOR, fnColorToString(pElement)); + writeEndElement(); + } + + writeFullEndElement(); + } + + void CModelWriterNode100_Model::writeTex2Coords() { nfUint32 nGroupCount = m_pModel->getTexture2DGroupCount(); @@ -735,34 +908,157 @@ namespace NMR { } } - void CModelWriterNode100_Model::writeMultiProperties() + void CModelWriterNode100_Model::writeImage3Ds() { - nfUint32 nCount = m_pModel->getMultiPropertyGroupCount(); + nfUint32 nCount = m_pModel->getImage3DCount(); for (nfUint32 nIndex = 0; nIndex < nCount; nIndex++) { + CModelImage3D * pImage3DResource = m_pModel->getImage3D(nIndex); + + if (!pImage3DResource) + { + throw CNMRException(NMR_ERROR_INVALID_RESOURCE_INDEX, "Invalid Image3D resource index."); + } + writeImage3D(*pImage3DResource); + } + + } + + void CModelWriterNode100_Model::writeImage3D(CModelImage3D &pImage3D) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMAGE3D, XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + writeIntAttribute(XML_3MF_ATTRIBUTE_IMAGE3D_ID, pImage3D.getPackageResourceID()->getModelResourceID()); + if (!pImage3D.getName().empty()) + writeStringAttribute(XML_3MF_ATTRIBUTE_IMAGE3D_NAME, pImage3D.getName()); + + if (CModelImageStack* pImageStack = dynamic_cast(&pImage3D)) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMAGESTACK, XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + + nfUint32 nSheetCount = pImageStack->getSheetCount(); + writeIntAttribute(XML_3MF_ATTRIBUTE_IMAGESTACK_ROWCOUNT, pImageStack->getRowCount()); + writeIntAttribute(XML_3MF_ATTRIBUTE_IMAGESTACK_COLUMNCOUNT, pImageStack->getColumnCount()); + writeIntAttribute(XML_3MF_ATTRIBUTE_IMAGESTACK_SHEETCOUNT, nSheetCount); + + for (nfUint32 nSheetIndex = 0; nSheetIndex < nSheetCount; nSheetIndex++) { + auto pSheet = pImageStack->getSheet(nSheetIndex); + writeStartElementWithPrefix(XML_3MF_ELEMENT_IMAGESHEET, XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + if (pSheet.get() != nullptr) { + writeStringAttribute(XML_3MF_ATTRIBUTE_IMAGESHEET_PATH, pSheet->getPathURI()); + } + writeEndElement(); + } + + writeFullEndElement(); + } + else + { + throw CNMRException(-1); // TODO NMR_ERROR_UNKNOWN_IMAGE3D_TYPE + } + + writeFullEndElement(); + } + + + void CModelWriterNode100_Model::writeFunctionsFromImage3D() + { + nfUint32 nCount = m_pModel->getFunctionCount(); + + for (nfUint32 nIndex = 0u; nIndex < nCount; nIndex++) + { + auto funcFromImg3D = m_pModel->getFunctionFromImage3D(nIndex); + if (!funcFromImg3D) + { + continue; + } + + writeFunctionFromImage3D(*funcFromImg3D); + } + } + + void CModelWriterNode100_Model::writeFunctionFromImage3D( + CModelFunctionFromImage3D & functionFromImage3D) + { + writeStartElementWithPrefix(XML_3MF_ELEMENT_FUNCTION_FROM_IMAGE3D, + XML_3MF_NAMESPACEPREFIX_VOLUMETRIC); + writeIntAttribute(XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_ID, + functionFromImage3D.getPackageResourceID() + ->getModelResourceID()); + writeStringAttribute( + XML_3MF_ATTRIBUTE_IMPLICIT_FUNCTION_DISPLAY_NAME, + functionFromImage3D.getDisplayName()); + writeIntAttribute( + XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_IMAGE3DID, + functionFromImage3D.getImage3DModelResourceID()); + writeDoubleAttribute( + XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_OFFSET, + functionFromImage3D.getOffset()); + writeDoubleAttribute(XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_SCALE, + functionFromImage3D.getScale()); + writeStringAttribute( + XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEU, + CModelTexture2DResource::tileStyleToString( + functionFromImage3D.getTileStyleU())); + writeStringAttribute( + XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEV, + CModelTexture2DResource::tileStyleToString( + functionFromImage3D.getTileStyleV())); + writeStringAttribute( + XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_TILESTYLEW, + CModelTexture2DResource::tileStyleToString( + functionFromImage3D.getTileStyleW())); + writeStringAttribute( + XML_3MF_ATTRIBUTE_FUNTCTION_FROM_IMAGE3D_FILTER, + CModelTexture2DResource::filterToString( + functionFromImage3D.getFilter())); + writeFullEndElement(); + } + + void CModelWriterNode100_Model::writeImplicitFunctions() + { + CModelWriterNode_Implicit implicitWriter(m_pModel, m_pXMLWriter, m_pProgressMonitor); + implicitWriter.writeImplicitFunctions(); + } + + void CModelWriterNode100_Model::writeVolumeData() + { + CModelWriterNode_VolumeData volumeWriter(m_pModel, m_pXMLWriter, + m_pProgressMonitor); + volumeWriter.writeToXML(); + } + + void CModelWriterNode100_Model::writeMultiProperties() + { + nfUint32 nCount = m_pModel->getMultiPropertyGroupCount(); + + for (nfUint32 nIndex = 0; nIndex < nCount; nIndex++) + { m_pProgressMonitor->IncrementProgress(1); - CModelMultiPropertyGroupResource * pMultiPropertyGroup = m_pModel->getMultiPropertyGroup(nIndex); + CModelMultiPropertyGroupResource * pMultiPropertyGroup = + m_pModel->getMultiPropertyGroup(nIndex); pMultiPropertyGroup->buildResourceIndexMap(); - writeStartElementWithPrefix(XML_3MF_ELEMENT_MULTIPROPERTIES, XML_3MF_NAMESPACEPREFIX_MATERIAL); + writeStartElementWithPrefix(XML_3MF_ELEMENT_MULTIPROPERTIES, + XML_3MF_NAMESPACEPREFIX_MATERIAL); writeMultiPropertyAttributes(pMultiPropertyGroup); - + writeMultiPropertyMultiElements(pMultiPropertyGroup); writeFullEndElement(); } } - void CModelWriterNode100_Model::writeResources() + void CModelWriterNode100_Model::writeResources() { writeStartElement(XML_3MF_ELEMENT_RESOURCES); if (m_bIsRootModel) { - if (m_bWriteBaseMaterials) + // First we write all Resources, that have no dependencies to other resources + if (m_bWriteBaseMaterials) writeBaseMaterials(); if (m_bWriteMaterialExtension) { @@ -775,9 +1071,29 @@ namespace NMR { if (m_bWriteSliceExtension) { writeSliceStacks(); } - if (m_bWriteObjects) - writeObjects(); - } + + // Create topological order of resources + CResourceDependencySorter sorter(m_pModel); + auto sortedResources = sorter.sort(); + + for(auto &resId : sortedResources) + { + if(resId->getPath() != m_pModel->currentPath()) + { + continue; + } + auto pResource = + m_pModel->findResource(resId->getUniqueID()); + + if(!pResource) + { + throw CNMRException( + NMR_ERROR_INVALID_RESOURCE_INDEX, + "Invalid Resource"); + } + writeResource(pResource.get()); + } + } else { if (m_bWriteSliceExtension) { writeSliceStacks(); @@ -790,6 +1106,51 @@ namespace NMR { writeFullEndElement(); } + void CModelWriterNode100_Model::writeResource(CModelResource *pResource) + { + if (!pResource) + { + throw CNMRException(NMR_ERROR_INVALIDPARAM, "Invalid Resource"); + } + CModelWriterNode_Implicit implicitWriter(m_pModel, m_pXMLWriter, m_pProgressMonitor); + CModelWriterNode_VolumeData volumeWriter(m_pModel, m_pXMLWriter, m_pProgressMonitor); + + CModelImage3D * pImage3DResource = dynamic_cast(pResource); + if (pImage3DResource) + { + writeImage3D(*pImage3DResource); + return; + } + + CModelFunctionFromImage3D * pFunctionFromImage3DResource = dynamic_cast(pResource); + if (pFunctionFromImage3DResource) + { + writeFunctionFromImage3D(*pFunctionFromImage3DResource); + return; + } + + CModelImplicitFunction * pImplicitFunctionResource = dynamic_cast(pResource); + if (pImplicitFunctionResource) + { + implicitWriter.writeImplicitFunction(*pImplicitFunctionResource); + return; + } + + CModelVolumeData * pVolumeDataResource = dynamic_cast(pResource); + if (pVolumeDataResource) + { + volumeWriter.writeVolumeDataResource(*pVolumeDataResource); + return; + } + + CModelObject * pObject = dynamic_cast(pResource); + if (pObject) + { + writeObject(*pObject); + return; + } + } + void CModelWriterNode100_Model::writeBuild() { writeStartElement(XML_3MF_ELEMENT_BUILD); @@ -884,4 +1245,35 @@ namespace NMR { writeFullEndElement(); } + void CModelWriterNode100_Model::detectRequiredExtensions() + { + // Scan all mesh objects to detect if balls are present + std::list objectList = m_pModel->getSortedObjectList(); + + for(auto iIterator = objectList.begin(); iIterator != objectList.end(); iIterator++) + { + CModelObject *pObject = *iIterator; + if (!pObject) + { + continue; + } + + // Check if object is a mesh Object with beam lattice + CModelMeshObject *pMeshObject = dynamic_cast(pObject); + if(pMeshObject) + { + CMesh * pMesh = pMeshObject->getMesh(); + if (pMesh) { + nfUint32 nBallCount = pMesh->getBallCount(); + eModelBeamLatticeBallMode eBallMode = pMesh->getBeamLatticeBallMode(); + + if (nBallCount > 0 || eBallMode != eModelBeamLatticeBallMode::MODELBEAMLATTICEBALLMODE_NONE) { + m_bWriteBeamLatticeBallsExtension = true; + break; // Found balls, no need to continue scanning + } + } + } + } + } + } diff --git a/Source/Model/Writer/v100/NMR_ResourceDependencySorter.cpp b/Source/Model/Writer/v100/NMR_ResourceDependencySorter.cpp new file mode 100644 index 0000000..b955979 --- /dev/null +++ b/Source/Model/Writer/v100/NMR_ResourceDependencySorter.cpp @@ -0,0 +1,127 @@ +/*++ + +Copyright (C) 2024 3MF Consortium + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Abstract: + +NMR_ResourcDependencySorter resolves the dependencies between resources by +sorting them topologically. +--*/ + +#include "Model/Writer/v100/NMR_ResourceDependencySorter.h" + +#include + +#include "Common/Graph/DirectedGraph.h" +#include "Common/Graph/GraphAlgorithms.h" +#include "Model/Classes/NMR_Model.h" +#include "Model/Classes/NMR_ModelResource.h" + +namespace NMR +{ + + CResourceDependencySorter::CResourceDependencySorter(CModel* pModel) + : m_pModel(pModel) + { + buildIndexMaps(); + } + + TopologicalSortResult CResourceDependencySorter::sort() + { + // gather list of resources that are standalone + TopologicalSortResult sortedResources; + + for(nfUint32 i = 0; i < m_pModel->getResourceCount(); i++) + { + auto pResource = m_pModel->getResource(i); + if(pResource->getDependencies().empty()) + { + sortedResources.push_back( + pResource->getPackageResourceID()); + } + } + + auto graph = buildGraph(); + if (common::graph::isCyclic(graph)) + { + throw CNMRException(NMR_ERROR_INVALIDPARAM, "Cyclic dependency between resources detected"); + } + auto sortedIndices = common::graph::topologicalSort( + buildGraph()); // only contains resources that have or are a + // dependency + + for (auto index : sortedIndices) + { + + auto modelResourceID = indexToModelResourceID(index); + if (std::find(sortedResources.begin(), sortedResources.end(), modelResourceID) == sortedResources.end()) { + sortedResources.push_back(modelResourceID); + } + } + return sortedResources; + } + + common::graph::DirectedGraph CResourceDependencySorter::buildGraph() + { + common::graph::DirectedGraph graph(m_pModel->getResourceCount()); + + for(nfUint32 i = 0; i < m_pModel->getResourceCount(); i++) + { + auto pResource = m_pModel->getResource(i); + auto dependencies = pResource->getDependencies(); + for(auto dependency : dependencies) + { + auto dependencyIndex = modelResourceIDToIndex(dependency); + graph.addDependency(i, dependencyIndex); + } + } + + return graph; + } + + void CResourceDependencySorter::buildIndexMaps() + { + for(nfUint32 i = 0; i < m_pModel->getResourceCount(); i++) + { + auto pResource = m_pModel->getResource(i); + m_indexToResourceID[i] = + pResource->getPackageResourceID(); + m_resourceIDToIndex[pResource->getPackageResourceID()] = i; + } + } + + PPackageResourceID CResourceDependencySorter::indexToModelResourceID( + size_t index) const + { + return m_indexToResourceID.at(index); + } + + size_t CResourceDependencySorter::modelResourceIDToIndex( + PPackageResourceID resourceID) const + { + return m_resourceIDToIndex.at(resourceID); + } + +} // namespace NMR diff --git a/Source/lib3mf_interfaceexception.cpp b/Source/lib3mf_interfaceexception.cpp index 0dcca72..2a9b0d9 100644 --- a/Source/lib3mf_interfaceexception.cpp +++ b/Source/lib3mf_interfaceexception.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,12 +24,12 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. Abstract: This is an autogenerated C++ Implementation file with the basic internal exception type in order to allow an easy use of the 3MF Library -Interface version: 2.2.0 +Interface version: 2.5.0 */ @@ -42,7 +42,7 @@ Interface version: 2.2.0 Class ELib3MFInterfaceException **************************************************************************************************************************/ ELib3MFInterfaceException::ELib3MFInterfaceException(Lib3MFResult errorCode) - : m_errorMessage("Lib3MF Error " + std::to_string (errorCode)) + : m_errorMessage(LIB3MF_GETERRORSTRING (errorCode)) { m_errorCode = errorCode; } diff --git a/Source/lib3mf_interfacejournal.cpp b/Source/lib3mf_interfacejournal.cpp index 1d38a8d..d793b24 100644 --- a/Source/lib3mf_interfacejournal.cpp +++ b/Source/lib3mf_interfacejournal.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,12 +24,12 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. Abstract: This is an autogenerated C++ implementation file in order to allow easy development of the 3MF Library. It provides an automatic Journaling mechanism for the library implementation. -Interface version: 2.2.0 +Interface version: 2.5.0 */ @@ -286,7 +286,7 @@ CLib3MFInterfaceJournal::CLib3MFInterfaceJournal (const std::string & sFileName) m_StartTime = std::chrono::high_resolution_clock::now(); m_Stream.open (sFileName, std::ios::out); m_Stream << "\n"; - m_Stream << "\n"; + m_Stream << "\n"; m_Stream << "\n"; } diff --git a/Source/lib3mf_interfacewrapper.cpp b/Source/lib3mf_interfacewrapper.cpp index 5f2810b..4f2e65f 100644 --- a/Source/lib3mf_interfacewrapper.cpp +++ b/Source/lib3mf_interfacewrapper.cpp @@ -1,6 +1,6 @@ /*++ -Copyright (C) 2019 3MF Consortium (Original Author) +Copyright (C) 2024 3MF Consortium (Original Author) All rights reserved. @@ -24,12 +24,12 @@ 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. +This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.1-develop. Abstract: This is an autogenerated C++ implementation file in order to allow easy development of the 3MF Library. The functions in this file need to be implemented. It needs to be generated only once. -Interface version: 2.2.0 +Interface version: 2.5.0 */ @@ -88,6 +88,40 @@ Lib3MFResult handleUnhandledException(IBase * pIBaseClass, CLib3MFInterfaceJourn /************************************************************************************************************************* Class implementation for Base **************************************************************************************************************************/ +Lib3MFResult lib3mf_base_classtypeid(Lib3MF_Base pBase, Lib3MF_uint64 * pClassTypeId) +{ + IBase* pIBaseClass = (IBase *)pBase; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pBase, "Base", "ClassTypeId"); + } + if (pClassTypeId == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pIBase = dynamic_cast(pIBaseClass); + if (!pIBase) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pClassTypeId = pIBase->ClassTypeId(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt64Result("ClassTypeId", *pClassTypeId); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + /************************************************************************************************************************* Class implementation for Writer @@ -409,8 +443,20 @@ Lib3MFResult lib3mf_writer_getwarning(Lib3MF_Writer pWriter, Lib3MF_uint32 nInde if (!pIWriter) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sWarning = pIWriter->GetWarning(nIndex, *pErrorCode); + bool isCacheCall = (pWarningBuffer == nullptr); + if (isCacheCall) { + sWarning = pIWriter->GetWarning(nIndex, *pErrorCode); + pIWriter->_setCache (new ParameterCache_2 (*pErrorCode, sWarning)); + } + else { + auto cache = dynamic_cast*> (pIWriter->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (*pErrorCode, sWarning); + pIWriter->_setCache (nullptr); + } + if (pWarningNeededChars) *pWarningNeededChars = (Lib3MF_uint32) (sWarning.size()+1); if (pWarningBuffer) { @@ -832,8 +878,20 @@ Lib3MFResult lib3mf_reader_getwarning(Lib3MF_Reader pReader, Lib3MF_uint32 nInde if (!pIReader) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sWarning = pIReader->GetWarning(nIndex, *pErrorCode); + bool isCacheCall = (pWarningBuffer == nullptr); + if (isCacheCall) { + sWarning = pIReader->GetWarning(nIndex, *pErrorCode); + pIReader->_setCache (new ParameterCache_2 (*pErrorCode, sWarning)); + } + else { + auto cache = dynamic_cast*> (pIReader->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (*pErrorCode, sWarning); + pIReader->_setCache (nullptr); + } + if (pWarningNeededChars) *pWarningNeededChars = (Lib3MF_uint32) (sWarning.size()+1); if (pWarningBuffer) { @@ -983,8 +1041,20 @@ Lib3MFResult lib3mf_packagepart_getpath(Lib3MF_PackagePart pPackagePart, const L if (!pIPackagePart) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sPath = pIPackagePart->GetPath(); + bool isCacheCall = (pPathBuffer == nullptr); + if (isCacheCall) { + sPath = pIPackagePart->GetPath(); + pIPackagePart->_setCache (new ParameterCache_1 (sPath)); + } + else { + auto cache = dynamic_cast*> (pIPackagePart->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sPath); + pIPackagePart->_setCache (nullptr); + } + if (pPathNeededChars) *pPathNeededChars = (Lib3MF_uint32) (sPath.size()+1); if (pPathBuffer) { @@ -1804,6 +1874,126 @@ Lib3MFResult lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup(Lib3 } +/************************************************************************************************************************* + Class implementation for Image3DIterator +**************************************************************************************************************************/ +Lib3MFResult lib3mf_image3diterator_getcurrentimage3d(Lib3MF_Image3DIterator pImage3DIterator, Lib3MF_Image3D * pResource) +{ + IBase* pIBaseClass = (IBase *)pImage3DIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImage3DIterator, "Image3DIterator", "GetCurrentImage3D"); + } + if (pResource == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResource(nullptr); + IImage3DIterator* pIImage3DIterator = dynamic_cast(pIBaseClass); + if (!pIImage3DIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResource = pIImage3DIterator->GetCurrentImage3D(); + + *pResource = (IBase*)(pBaseResource); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Resource", *pResource); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for FunctionIterator +**************************************************************************************************************************/ +Lib3MFResult lib3mf_functioniterator_getcurrentfunction(Lib3MF_FunctionIterator pFunctionIterator, Lib3MF_Function * pResource) +{ + IBase* pIBaseClass = (IBase *)pFunctionIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionIterator, "FunctionIterator", "GetCurrentFunction"); + } + if (pResource == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResource(nullptr); + IFunctionIterator* pIFunctionIterator = dynamic_cast(pIBaseClass); + if (!pIFunctionIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResource = pIFunctionIterator->GetCurrentFunction(); + + *pResource = (IBase*)(pBaseResource); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Resource", *pResource); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for LevelSetIterator +**************************************************************************************************************************/ +Lib3MFResult lib3mf_levelsetiterator_getcurrentlevelset(Lib3MF_LevelSetIterator pLevelSetIterator, Lib3MF_LevelSet * pResource) +{ + IBase* pIBaseClass = (IBase *)pLevelSetIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSetIterator, "LevelSetIterator", "GetCurrentLevelSet"); + } + if (pResource == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResource(nullptr); + ILevelSetIterator* pILevelSetIterator = dynamic_cast(pIBaseClass); + if (!pILevelSetIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResource = pILevelSetIterator->GetCurrentLevelSet(); + + *pResource = (IBase*)(pBaseResource); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Resource", *pResource); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + /************************************************************************************************************************* Class implementation for MetaData **************************************************************************************************************************/ @@ -1823,8 +2013,20 @@ Lib3MFResult lib3mf_metadata_getnamespace(Lib3MF_MetaData pMetaData, const Lib3M if (!pIMetaData) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sNameSpace = pIMetaData->GetNameSpace(); + bool isCacheCall = (pNameSpaceBuffer == nullptr); + if (isCacheCall) { + sNameSpace = pIMetaData->GetNameSpace(); + pIMetaData->_setCache (new ParameterCache_1 (sNameSpace)); + } + else { + auto cache = dynamic_cast*> (pIMetaData->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sNameSpace); + pIMetaData->_setCache (nullptr); + } + if (pNameSpaceNeededChars) *pNameSpaceNeededChars = (Lib3MF_uint32) (sNameSpace.size()+1); if (pNameSpaceBuffer) { @@ -1902,8 +2104,20 @@ Lib3MFResult lib3mf_metadata_getname(Lib3MF_MetaData pMetaData, const Lib3MF_uin if (!pIMetaData) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sName = pIMetaData->GetName(); + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pIMetaData->GetName(); + pIMetaData->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pIMetaData->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pIMetaData->_setCache (nullptr); + } + if (pNameNeededChars) *pNameNeededChars = (Lib3MF_uint32) (sName.size()+1); if (pNameBuffer) { @@ -1981,8 +2195,20 @@ Lib3MFResult lib3mf_metadata_getkey(Lib3MF_MetaData pMetaData, const Lib3MF_uint if (!pIMetaData) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sKey = pIMetaData->GetKey(); + bool isCacheCall = (pKeyBuffer == nullptr); + if (isCacheCall) { + sKey = pIMetaData->GetKey(); + pIMetaData->_setCache (new ParameterCache_1 (sKey)); + } + else { + auto cache = dynamic_cast*> (pIMetaData->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sKey); + pIMetaData->_setCache (nullptr); + } + if (pKeyNeededChars) *pKeyNeededChars = (Lib3MF_uint32) (sKey.size()+1); if (pKeyBuffer) { @@ -2091,8 +2317,20 @@ Lib3MFResult lib3mf_metadata_gettype(Lib3MF_MetaData pMetaData, const Lib3MF_uin if (!pIMetaData) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sType = pIMetaData->GetType(); + bool isCacheCall = (pTypeBuffer == nullptr); + if (isCacheCall) { + sType = pIMetaData->GetType(); + pIMetaData->_setCache (new ParameterCache_1 (sType)); + } + else { + auto cache = dynamic_cast*> (pIMetaData->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sType); + pIMetaData->_setCache (nullptr); + } + if (pTypeNeededChars) *pTypeNeededChars = (Lib3MF_uint32) (sType.size()+1); if (pTypeBuffer) { @@ -2170,8 +2408,20 @@ Lib3MFResult lib3mf_metadata_getvalue(Lib3MF_MetaData pMetaData, const Lib3MF_ui if (!pIMetaData) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sValue = pIMetaData->GetValue(); + bool isCacheCall = (pValueBuffer == nullptr); + if (isCacheCall) { + sValue = pIMetaData->GetValue(); + pIMetaData->_setCache (new ParameterCache_1 (sValue)); + } + else { + auto cache = dynamic_cast*> (pIMetaData->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sValue); + pIMetaData->_setCache (nullptr); + } + if (pValueNeededChars) *pValueNeededChars = (Lib3MF_uint32) (sValue.size()+1); if (pValueBuffer) { @@ -2475,6 +2725,495 @@ Lib3MFResult lib3mf_metadatagroup_addmetadata(Lib3MF_MetaDataGroup pMetaDataGrou } +/************************************************************************************************************************* + Class implementation for TriangleSet +**************************************************************************************************************************/ +Lib3MFResult lib3mf_triangleset_setname(Lib3MF_TriangleSet pTriangleSet, const char * pName) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "SetName"); + pJournalEntry->addStringParameter("Name", pName); + } + if (pName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sName(pName); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->SetName(sName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_getname(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "GetName"); + } + if ( (!pNameBuffer) && !(pNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sName(""); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pITriangleSet->GetName(); + + pITriangleSet->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pITriangleSet->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pITriangleSet->_setCache (nullptr); + } + + if (pNameNeededChars) + *pNameNeededChars = (Lib3MF_uint32) (sName.size()+1); + if (pNameBuffer) { + if (sName.size() >= nNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iName = 0; iName < sName.size(); iName++) + pNameBuffer[iName] = sName[iName]; + pNameBuffer[sName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Name", sName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_setidentifier(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "SetIdentifier"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->SetIdentifier(sIdentifier); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_getidentifier(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "GetIdentifier"); + } + if ( (!pIdentifierBuffer) && !(pIdentifierNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(""); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pIdentifierBuffer == nullptr); + if (isCacheCall) { + sIdentifier = pITriangleSet->GetIdentifier(); + + pITriangleSet->_setCache (new ParameterCache_1 (sIdentifier)); + } + else { + auto cache = dynamic_cast*> (pITriangleSet->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sIdentifier); + pITriangleSet->_setCache (nullptr); + } + + if (pIdentifierNeededChars) + *pIdentifierNeededChars = (Lib3MF_uint32) (sIdentifier.size()+1); + if (pIdentifierBuffer) { + if (sIdentifier.size() >= nIdentifierBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iIdentifier = 0; iIdentifier < sIdentifier.size(); iIdentifier++) + pIdentifierBuffer[iIdentifier] = sIdentifier[iIdentifier]; + pIdentifierBuffer[sIdentifier.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Identifier", sIdentifier.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_addtriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "AddTriangle"); + pJournalEntry->addUInt32Parameter("TriangleIndex", nTriangleIndex); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->AddTriangle(nTriangleIndex); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_removetriangle(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint32 nTriangleIndex) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "RemoveTriangle"); + pJournalEntry->addUInt32Parameter("TriangleIndex", nTriangleIndex); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->RemoveTriangle(nTriangleIndex); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_clear(Lib3MF_TriangleSet pTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "Clear"); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->Clear(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_settrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "SetTriangleList"); + } + if ( (!pTriangleIndicesBuffer) && (nTriangleIndicesBufferSize>0)) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->SetTriangleList(nTriangleIndicesBufferSize, pTriangleIndicesBuffer); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_gettrianglelist(Lib3MF_TriangleSet pTriangleSet, const Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64* pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "GetTriangleList"); + } + if ((!pTriangleIndicesBuffer) && !(pTriangleIndicesNeededCount)) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->GetTriangleList(nTriangleIndicesBufferSize, pTriangleIndicesNeededCount, pTriangleIndicesBuffer); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_addtrianglelist(Lib3MF_TriangleSet pTriangleSet, Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32 * pTriangleIndicesBuffer) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "AddTriangleList"); + } + if ( (!pTriangleIndicesBuffer) && (nTriangleIndicesBufferSize>0)) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->AddTriangleList(nTriangleIndicesBufferSize, pTriangleIndicesBuffer); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_merge(Lib3MF_TriangleSet pTriangleSet, Lib3MF_TriangleSet pOtherTriangleSet, bool bDeleteOther) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "Merge"); + pJournalEntry->addHandleParameter("OtherTriangleSet", pOtherTriangleSet); + pJournalEntry->addBooleanParameter("DeleteOther", bDeleteOther); + } + IBase* pIBaseClassOtherTriangleSet = (IBase *)pOtherTriangleSet; + ITriangleSet* pIOtherTriangleSet = dynamic_cast(pIBaseClassOtherTriangleSet); + if (!pIOtherTriangleSet) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->Merge(pIOtherTriangleSet, bDeleteOther); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_deleteset(Lib3MF_TriangleSet pTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "DeleteSet"); + } + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pITriangleSet->DeleteSet(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_triangleset_duplicate(Lib3MF_TriangleSet pTriangleSet, const char * pIdentifier, Lib3MF_TriangleSet * pNewSet) +{ + IBase* pIBaseClass = (IBase *)pTriangleSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTriangleSet, "TriangleSet", "Duplicate"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNewSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseNewSet(nullptr); + ITriangleSet* pITriangleSet = dynamic_cast(pIBaseClass); + if (!pITriangleSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNewSet = pITriangleSet->Duplicate(sIdentifier); + + *pNewSet = (IBase*)(pBaseNewSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("NewSet", *pNewSet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + /************************************************************************************************************************* Class implementation for Object **************************************************************************************************************************/ @@ -2560,8 +3299,20 @@ Lib3MFResult lib3mf_object_getname(Lib3MF_Object pObject, const Lib3MF_uint32 nN if (!pIObject) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sName = pIObject->GetName(); + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pIObject->GetName(); + pIObject->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pIObject->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pIObject->_setCache (nullptr); + } + if (pNameNeededChars) *pNameNeededChars = (Lib3MF_uint32) (sName.size()+1); if (pNameBuffer) { @@ -2639,8 +3390,20 @@ Lib3MFResult lib3mf_object_getpartnumber(Lib3MF_Object pObject, const Lib3MF_uin if (!pIObject) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sPartNumber = pIObject->GetPartNumber(); + bool isCacheCall = (pPartNumberBuffer == nullptr); + if (isCacheCall) { + sPartNumber = pIObject->GetPartNumber(); + pIObject->_setCache (new ParameterCache_1 (sPartNumber)); + } + else { + auto cache = dynamic_cast*> (pIObject->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sPartNumber); + pIObject->_setCache (nullptr); + } + if (pPartNumberNeededChars) *pPartNumberNeededChars = (Lib3MF_uint32) (sPartNumber.size()+1); if (pPartNumberBuffer) { @@ -2770,6 +3533,40 @@ Lib3MFResult lib3mf_object_iscomponentsobject(Lib3MF_Object pObject, bool * pIsC } } +Lib3MFResult lib3mf_object_islevelsetobject(Lib3MF_Object pObject, bool * pIsLevelSetObject) +{ + IBase* pIBaseClass = (IBase *)pObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pObject, "Object", "IsLevelSetObject"); + } + if (pIsLevelSetObject == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IObject* pIObject = dynamic_cast(pIBaseClass); + if (!pIObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pIsLevelSetObject = pIObject->IsLevelSetObject(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("IsLevelSetObject", *pIsLevelSetObject); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + Lib3MFResult lib3mf_object_isvalid(Lib3MF_Object pObject, bool * pIsValid) { IBase* pIBaseClass = (IBase *)pObject; @@ -2959,8 +3756,20 @@ Lib3MFResult lib3mf_object_getuuid(Lib3MF_Object pObject, bool * pHasUUID, const if (!pIObject) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sUUID = pIObject->GetUUID(*pHasUUID); + bool isCacheCall = (pUUIDBuffer == nullptr); + if (isCacheCall) { + sUUID = pIObject->GetUUID(*pHasUUID); + pIObject->_setCache (new ParameterCache_2 (*pHasUUID, sUUID)); + } + else { + auto cache = dynamic_cast*> (pIObject->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (*pHasUUID, sUUID); + pIObject->_setCache (nullptr); + } + if (pUUIDNeededChars) *pUUIDNeededChars = (Lib3MF_uint32) (sUUID.size()+1); if (pUUIDBuffer) { @@ -3943,6 +4752,848 @@ Lib3MFResult lib3mf_meshobject_beamlattice(Lib3MF_MeshObject pMeshObject, Lib3MF } } +Lib3MFResult lib3mf_meshobject_getvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData * pTheVolumeData) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "GetVolumeData"); + } + if (pTheVolumeData == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheVolumeData(nullptr); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheVolumeData = pIMeshObject->GetVolumeData(); + + *pTheVolumeData = (IBase*)(pBaseTheVolumeData); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheVolumeData", *pTheVolumeData); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshobject_setvolumedata(Lib3MF_MeshObject pMeshObject, Lib3MF_VolumeData pTheVolumeData) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "SetVolumeData"); + pJournalEntry->addHandleParameter("TheVolumeData", pTheVolumeData); + } + IBase* pIBaseClassTheVolumeData = (IBase *)pTheVolumeData; + IVolumeData* pITheVolumeData = dynamic_cast(pIBaseClassTheVolumeData); + if (!pITheVolumeData) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIMeshObject->SetVolumeData(pITheVolumeData); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshobject_addtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, const char * pName, Lib3MF_TriangleSet * pTheTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "AddTriangleSet"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("Name", pName); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTheTriangleSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sName(pName); + IBase* pBaseTheTriangleSet(nullptr); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheTriangleSet = pIMeshObject->AddTriangleSet(sIdentifier, sName); + + *pTheTriangleSet = (IBase*)(pBaseTheTriangleSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheTriangleSet", *pTheTriangleSet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshobject_hastriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, bool * pTriangleSetExists) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "HasTriangleSet"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTriangleSetExists == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pTriangleSetExists = pIMeshObject->HasTriangleSet(sIdentifier); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("TriangleSetExists", *pTriangleSetExists); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshobject_findtriangleset(Lib3MF_MeshObject pMeshObject, const char * pIdentifier, Lib3MF_TriangleSet * pTheTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "FindTriangleSet"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTheTriangleSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseTheTriangleSet(nullptr); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheTriangleSet = pIMeshObject->FindTriangleSet(sIdentifier); + + *pTheTriangleSet = (IBase*)(pBaseTheTriangleSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheTriangleSet", *pTheTriangleSet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshobject_gettrianglesetcount(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 * pCount) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "GetTriangleSetCount"); + } + if (pCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pCount = pIMeshObject->GetTriangleSetCount(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("Count", *pCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshobject_gettriangleset(Lib3MF_MeshObject pMeshObject, Lib3MF_uint32 nIndex, Lib3MF_TriangleSet * pTheTriangleSet) +{ + IBase* pIBaseClass = (IBase *)pMeshObject; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshObject, "MeshObject", "GetTriangleSet"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + } + if (pTheTriangleSet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheTriangleSet(nullptr); + IMeshObject* pIMeshObject = dynamic_cast(pIBaseClass); + if (!pIMeshObject) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheTriangleSet = pIMeshObject->GetTriangleSet(nIndex); + + *pTheTriangleSet = (IBase*)(pBaseTheTriangleSet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheTriangleSet", *pTheTriangleSet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for LevelSet +**************************************************************************************************************************/ +Lib3MFResult lib3mf_levelset_getfunction(Lib3MF_LevelSet pLevelSet, Lib3MF_Function * pTheFunction) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetFunction"); + } + if (pTheFunction == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheFunction(nullptr); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheFunction = pILevelSet->GetFunction(); + + *pTheFunction = (IBase*)(pBaseTheFunction); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheFunction", *pTheFunction); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_setfunction(Lib3MF_LevelSet pLevelSet, Lib3MF_Function pTheFunction) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetFunction"); + pJournalEntry->addHandleParameter("TheFunction", pTheFunction); + } + IBase* pIBaseClassTheFunction = (IBase *)pTheFunction; + IFunction* pITheFunction = dynamic_cast(pIBaseClassTheFunction); + if (!pITheFunction) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetFunction(pITheFunction); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_gettransform(Lib3MF_LevelSet pLevelSet, sLib3MFTransform * pTransform) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetTransform"); + } + if (pTransform == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pTransform = pILevelSet->GetTransform(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_settransform(Lib3MF_LevelSet pLevelSet, const sLib3MFTransform * pTransform) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetTransform"); + } + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetTransform(*pTransform); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_getchannelname(Lib3MF_LevelSet pLevelSet, const Lib3MF_uint32 nChannelNameBufferSize, Lib3MF_uint32* pChannelNameNeededChars, char * pChannelNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetChannelName"); + } + if ( (!pChannelNameBuffer) && !(pChannelNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sChannelName(""); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pChannelNameBuffer == nullptr); + if (isCacheCall) { + sChannelName = pILevelSet->GetChannelName(); + + pILevelSet->_setCache (new ParameterCache_1 (sChannelName)); + } + else { + auto cache = dynamic_cast*> (pILevelSet->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sChannelName); + pILevelSet->_setCache (nullptr); + } + + if (pChannelNameNeededChars) + *pChannelNameNeededChars = (Lib3MF_uint32) (sChannelName.size()+1); + if (pChannelNameBuffer) { + if (sChannelName.size() >= nChannelNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iChannelName = 0; iChannelName < sChannelName.size(); iChannelName++) + pChannelNameBuffer[iChannelName] = sChannelName[iChannelName]; + pChannelNameBuffer[sChannelName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("ChannelName", sChannelName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_setchannelname(Lib3MF_LevelSet pLevelSet, const char * pChannelName) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetChannelName"); + pJournalEntry->addStringParameter("ChannelName", pChannelName); + } + if (pChannelName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sChannelName(pChannelName); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetChannelName(sChannelName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_setminfeaturesize(Lib3MF_LevelSet pLevelSet, Lib3MF_double dMinFeatureSize) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetMinFeatureSize"); + pJournalEntry->addDoubleParameter("MinFeatureSize", dMinFeatureSize); + } + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetMinFeatureSize(dMinFeatureSize); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_getminfeaturesize(Lib3MF_LevelSet pLevelSet, Lib3MF_double * pMinFeatureSize) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetMinFeatureSize"); + } + if (pMinFeatureSize == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pMinFeatureSize = pILevelSet->GetMinFeatureSize(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("MinFeatureSize", *pMinFeatureSize); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_setfallbackvalue(Lib3MF_LevelSet pLevelSet, Lib3MF_double dFallBackValue) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetFallBackValue"); + pJournalEntry->addDoubleParameter("FallBackValue", dFallBackValue); + } + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetFallBackValue(dFallBackValue); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_getfallbackvalue(Lib3MF_LevelSet pLevelSet, Lib3MF_double * pFallBackValue) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetFallBackValue"); + } + if (pFallBackValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pFallBackValue = pILevelSet->GetFallBackValue(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("FallBackValue", *pFallBackValue); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_setmeshbboxonly(Lib3MF_LevelSet pLevelSet, bool bMeshBBoxOnly) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetMeshBBoxOnly"); + pJournalEntry->addBooleanParameter("MeshBBoxOnly", bMeshBBoxOnly); + } + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetMeshBBoxOnly(bMeshBBoxOnly); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_getmeshbboxonly(Lib3MF_LevelSet pLevelSet, bool * pMeshBBoxOnly) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetMeshBBoxOnly"); + } + if (pMeshBBoxOnly == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pMeshBBoxOnly = pILevelSet->GetMeshBBoxOnly(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("MeshBBoxOnly", *pMeshBBoxOnly); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_setmesh(Lib3MF_LevelSet pLevelSet, Lib3MF_MeshObject pTheMesh) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetMesh"); + pJournalEntry->addHandleParameter("TheMesh", pTheMesh); + } + IBase* pIBaseClassTheMesh = (IBase *)pTheMesh; + IMeshObject* pITheMesh = dynamic_cast(pIBaseClassTheMesh); + if (!pITheMesh) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetMesh(pITheMesh); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_getmesh(Lib3MF_LevelSet pLevelSet, Lib3MF_MeshObject * pTheMesh) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetMesh"); + } + if (pTheMesh == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheMesh(nullptr); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheMesh = pILevelSet->GetMesh(); + + *pTheMesh = (IBase*)(pBaseTheMesh); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheMesh", *pTheMesh); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_getvolumedata(Lib3MF_LevelSet pLevelSet, Lib3MF_VolumeData * pTheVolumeData) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "GetVolumeData"); + } + if (pTheVolumeData == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheVolumeData(nullptr); + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheVolumeData = pILevelSet->GetVolumeData(); + + *pTheVolumeData = (IBase*)(pBaseTheVolumeData); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheVolumeData", *pTheVolumeData); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_levelset_setvolumedata(Lib3MF_LevelSet pLevelSet, Lib3MF_VolumeData pTheVolumeData) +{ + IBase* pIBaseClass = (IBase *)pLevelSet; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pLevelSet, "LevelSet", "SetVolumeData"); + pJournalEntry->addHandleParameter("TheVolumeData", pTheVolumeData); + } + IBase* pIBaseClassTheVolumeData = (IBase *)pTheVolumeData; + IVolumeData* pITheVolumeData = dynamic_cast(pIBaseClassTheVolumeData); + if (!pITheVolumeData) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + ILevelSet* pILevelSet = dynamic_cast(pIBaseClass); + if (!pILevelSet) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pILevelSet->SetVolumeData(pITheVolumeData); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + /************************************************************************************************************************* Class implementation for BeamLattice @@ -4730,6 +6381,1078 @@ Lib3MFResult lib3mf_beamlattice_getbeamset(Lib3MF_BeamLattice pBeamLattice, Lib3 } +/************************************************************************************************************************* + Class implementation for FunctionReference +**************************************************************************************************************************/ +Lib3MFResult lib3mf_functionreference_getfunctionresourceid(Lib3MF_FunctionReference pFunctionReference, Lib3MF_uint32 * pUniqueResourceID) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "GetFunctionResourceID"); + } + if (pUniqueResourceID == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pUniqueResourceID = pIFunctionReference->GetFunctionResourceID(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("UniqueResourceID", *pUniqueResourceID); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_setfunctionresourceid(Lib3MF_FunctionReference pFunctionReference, Lib3MF_uint32 nUniqueResourceID) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "SetFunctionResourceID"); + pJournalEntry->addUInt32Parameter("UniqueResourceID", nUniqueResourceID); + } + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionReference->SetFunctionResourceID(nUniqueResourceID); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_gettransform(Lib3MF_FunctionReference pFunctionReference, sLib3MFTransform * pTransform) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "GetTransform"); + } + if (pTransform == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pTransform = pIFunctionReference->GetTransform(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_settransform(Lib3MF_FunctionReference pFunctionReference, const sLib3MFTransform * pTransform) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "SetTransform"); + } + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionReference->SetTransform(*pTransform); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_getchannelname(Lib3MF_FunctionReference pFunctionReference, const Lib3MF_uint32 nChannelNameBufferSize, Lib3MF_uint32* pChannelNameNeededChars, char * pChannelNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "GetChannelName"); + } + if ( (!pChannelNameBuffer) && !(pChannelNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sChannelName(""); + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pChannelNameBuffer == nullptr); + if (isCacheCall) { + sChannelName = pIFunctionReference->GetChannelName(); + + pIFunctionReference->_setCache (new ParameterCache_1 (sChannelName)); + } + else { + auto cache = dynamic_cast*> (pIFunctionReference->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sChannelName); + pIFunctionReference->_setCache (nullptr); + } + + if (pChannelNameNeededChars) + *pChannelNameNeededChars = (Lib3MF_uint32) (sChannelName.size()+1); + if (pChannelNameBuffer) { + if (sChannelName.size() >= nChannelNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iChannelName = 0; iChannelName < sChannelName.size(); iChannelName++) + pChannelNameBuffer[iChannelName] = sChannelName[iChannelName]; + pChannelNameBuffer[sChannelName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("ChannelName", sChannelName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_setchannelname(Lib3MF_FunctionReference pFunctionReference, const char * pChannelName) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "SetChannelName"); + pJournalEntry->addStringParameter("ChannelName", pChannelName); + } + if (pChannelName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sChannelName(pChannelName); + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionReference->SetChannelName(sChannelName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_setminfeaturesize(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dMinFeatureSize) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "SetMinFeatureSize"); + pJournalEntry->addDoubleParameter("MinFeatureSize", dMinFeatureSize); + } + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionReference->SetMinFeatureSize(dMinFeatureSize); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_getminfeaturesize(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pMinFeatureSize) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "GetMinFeatureSize"); + } + if (pMinFeatureSize == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pMinFeatureSize = pIFunctionReference->GetMinFeatureSize(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("MinFeatureSize", *pMinFeatureSize); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_setfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double dFallBackValue) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "SetFallBackValue"); + pJournalEntry->addDoubleParameter("FallBackValue", dFallBackValue); + } + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionReference->SetFallBackValue(dFallBackValue); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionreference_getfallbackvalue(Lib3MF_FunctionReference pFunctionReference, Lib3MF_double * pFallBackValue) +{ + IBase* pIBaseClass = (IBase *)pFunctionReference; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionReference, "FunctionReference", "GetFallBackValue"); + } + if (pFallBackValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionReference* pIFunctionReference = dynamic_cast(pIBaseClass); + if (!pIFunctionReference) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pFallBackValue = pIFunctionReference->GetFallBackValue(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("FallBackValue", *pFallBackValue); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for VolumeDataColor +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for MaterialMapping +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for VolumeDataComposite +**************************************************************************************************************************/ +Lib3MFResult lib3mf_volumedatacomposite_getbasematerialgroup(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_BaseMaterialGroup * pBaseMaterialGroupInstance) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataComposite; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataComposite, "VolumeDataComposite", "GetBaseMaterialGroup"); + } + if (pBaseMaterialGroupInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseBaseMaterialGroupInstance(nullptr); + IVolumeDataComposite* pIVolumeDataComposite = dynamic_cast(pIBaseClass); + if (!pIVolumeDataComposite) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseBaseMaterialGroupInstance = pIVolumeDataComposite->GetBaseMaterialGroup(); + + *pBaseMaterialGroupInstance = (IBase*)(pBaseBaseMaterialGroupInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("BaseMaterialGroupInstance", *pBaseMaterialGroupInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedatacomposite_setbasematerialgroup(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_BaseMaterialGroup pBaseMaterialGroupInstance) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataComposite; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataComposite, "VolumeDataComposite", "SetBaseMaterialGroup"); + pJournalEntry->addHandleParameter("BaseMaterialGroupInstance", pBaseMaterialGroupInstance); + } + IBase* pIBaseClassBaseMaterialGroupInstance = (IBase *)pBaseMaterialGroupInstance; + IBaseMaterialGroup* pIBaseMaterialGroupInstance = dynamic_cast(pIBaseClassBaseMaterialGroupInstance); + if (!pIBaseMaterialGroupInstance) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IVolumeDataComposite* pIVolumeDataComposite = dynamic_cast(pIBaseClass); + if (!pIVolumeDataComposite) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIVolumeDataComposite->SetBaseMaterialGroup(pIBaseMaterialGroupInstance); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedatacomposite_getmaterialmappingcount(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_uint32 * pCount) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataComposite; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataComposite, "VolumeDataComposite", "GetMaterialMappingCount"); + } + if (pCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IVolumeDataComposite* pIVolumeDataComposite = dynamic_cast(pIBaseClass); + if (!pIVolumeDataComposite) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pCount = pIVolumeDataComposite->GetMaterialMappingCount(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("Count", *pCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedatacomposite_getmaterialmapping(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_uint32 nIndex, Lib3MF_MaterialMapping * pTheMaterialMapping) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataComposite; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataComposite, "VolumeDataComposite", "GetMaterialMapping"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + } + if (pTheMaterialMapping == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheMaterialMapping(nullptr); + IVolumeDataComposite* pIVolumeDataComposite = dynamic_cast(pIBaseClass); + if (!pIVolumeDataComposite) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheMaterialMapping = pIVolumeDataComposite->GetMaterialMapping(nIndex); + + *pTheMaterialMapping = (IBase*)(pBaseTheMaterialMapping); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheMaterialMapping", *pTheMaterialMapping); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedatacomposite_addmaterialmapping(Lib3MF_VolumeDataComposite pVolumeDataComposite, const sLib3MFTransform * pTransform, Lib3MF_MaterialMapping * pTheMaterialMapping) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataComposite; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataComposite, "VolumeDataComposite", "AddMaterialMapping"); + } + if (pTheMaterialMapping == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheMaterialMapping(nullptr); + IVolumeDataComposite* pIVolumeDataComposite = dynamic_cast(pIBaseClass); + if (!pIVolumeDataComposite) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheMaterialMapping = pIVolumeDataComposite->AddMaterialMapping(*pTransform); + + *pTheMaterialMapping = (IBase*)(pBaseTheMaterialMapping); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheMaterialMapping", *pTheMaterialMapping); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedatacomposite_removematerialmapping(Lib3MF_VolumeDataComposite pVolumeDataComposite, Lib3MF_uint32 nIndex) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataComposite; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataComposite, "VolumeDataComposite", "RemoveMaterialMapping"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + } + IVolumeDataComposite* pIVolumeDataComposite = dynamic_cast(pIBaseClass); + if (!pIVolumeDataComposite) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIVolumeDataComposite->RemoveMaterialMapping(nIndex); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for VolumeDataProperty +**************************************************************************************************************************/ +Lib3MFResult lib3mf_volumedataproperty_getname(Lib3MF_VolumeDataProperty pVolumeDataProperty, const Lib3MF_uint32 nPropertyNameBufferSize, Lib3MF_uint32* pPropertyNameNeededChars, char * pPropertyNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataProperty; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataProperty, "VolumeDataProperty", "GetName"); + } + if ( (!pPropertyNameBuffer) && !(pPropertyNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sPropertyName(""); + IVolumeDataProperty* pIVolumeDataProperty = dynamic_cast(pIBaseClass); + if (!pIVolumeDataProperty) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pPropertyNameBuffer == nullptr); + if (isCacheCall) { + sPropertyName = pIVolumeDataProperty->GetName(); + + pIVolumeDataProperty->_setCache (new ParameterCache_1 (sPropertyName)); + } + else { + auto cache = dynamic_cast*> (pIVolumeDataProperty->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sPropertyName); + pIVolumeDataProperty->_setCache (nullptr); + } + + if (pPropertyNameNeededChars) + *pPropertyNameNeededChars = (Lib3MF_uint32) (sPropertyName.size()+1); + if (pPropertyNameBuffer) { + if (sPropertyName.size() >= nPropertyNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iPropertyName = 0; iPropertyName < sPropertyName.size(); iPropertyName++) + pPropertyNameBuffer[iPropertyName] = sPropertyName[iPropertyName]; + pPropertyNameBuffer[sPropertyName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("PropertyName", sPropertyName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedataproperty_setisrequired(Lib3MF_VolumeDataProperty pVolumeDataProperty, bool bIsRequired) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataProperty; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataProperty, "VolumeDataProperty", "SetIsRequired"); + pJournalEntry->addBooleanParameter("IsRequired", bIsRequired); + } + IVolumeDataProperty* pIVolumeDataProperty = dynamic_cast(pIBaseClass); + if (!pIVolumeDataProperty) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIVolumeDataProperty->SetIsRequired(bIsRequired); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedataproperty_isrequired(Lib3MF_VolumeDataProperty pVolumeDataProperty, bool * pIsRequired) +{ + IBase* pIBaseClass = (IBase *)pVolumeDataProperty; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeDataProperty, "VolumeDataProperty", "IsRequired"); + } + if (pIsRequired == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IVolumeDataProperty* pIVolumeDataProperty = dynamic_cast(pIBaseClass); + if (!pIVolumeDataProperty) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pIsRequired = pIVolumeDataProperty->IsRequired(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("IsRequired", *pIsRequired); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for VolumeData +**************************************************************************************************************************/ +Lib3MFResult lib3mf_volumedata_getcomposite(Lib3MF_VolumeData pVolumeData, Lib3MF_VolumeDataComposite * pTheCompositeData) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "GetComposite"); + } + if (pTheCompositeData == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheCompositeData(nullptr); + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheCompositeData = pIVolumeData->GetComposite(); + + *pTheCompositeData = (IBase*)(pBaseTheCompositeData); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheCompositeData", *pTheCompositeData); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_createnewcomposite(Lib3MF_VolumeData pVolumeData, Lib3MF_VolumeDataComposite * pTheCompositeData) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "CreateNewComposite"); + } + if (pTheCompositeData == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheCompositeData(nullptr); + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheCompositeData = pIVolumeData->CreateNewComposite(); + + *pTheCompositeData = (IBase*)(pBaseTheCompositeData); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheCompositeData", *pTheCompositeData); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_removecomposite(Lib3MF_VolumeData pVolumeData) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "RemoveComposite"); + } + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIVolumeData->RemoveComposite(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_getcolor(Lib3MF_VolumeData pVolumeData, Lib3MF_VolumeDataColor * pTheColorData) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "GetColor"); + } + if (pTheColorData == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheColorData(nullptr); + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheColorData = pIVolumeData->GetColor(); + + *pTheColorData = (IBase*)(pBaseTheColorData); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheColorData", *pTheColorData); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_createnewcolor(Lib3MF_VolumeData pVolumeData, Lib3MF_Function pTheFunction, Lib3MF_VolumeDataColor * pTheColorData) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "CreateNewColor"); + pJournalEntry->addHandleParameter("TheFunction", pTheFunction); + } + if (pTheColorData == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pIBaseClassTheFunction = (IBase *)pTheFunction; + IFunction* pITheFunction = dynamic_cast(pIBaseClassTheFunction); + if (!pITheFunction) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IBase* pBaseTheColorData(nullptr); + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheColorData = pIVolumeData->CreateNewColor(pITheFunction); + + *pTheColorData = (IBase*)(pBaseTheColorData); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheColorData", *pTheColorData); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_removecolor(Lib3MF_VolumeData pVolumeData) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "RemoveColor"); + } + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIVolumeData->RemoveColor(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_getpropertycount(Lib3MF_VolumeData pVolumeData, Lib3MF_uint32 * pCount) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "GetPropertyCount"); + } + if (pCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pCount = pIVolumeData->GetPropertyCount(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("Count", *pCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_getproperty(Lib3MF_VolumeData pVolumeData, Lib3MF_uint32 nIndex, Lib3MF_VolumeDataProperty * pTheVolumeDataProperty) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "GetProperty"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + } + if (pTheVolumeDataProperty == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheVolumeDataProperty(nullptr); + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheVolumeDataProperty = pIVolumeData->GetProperty(nIndex); + + *pTheVolumeDataProperty = (IBase*)(pBaseTheVolumeDataProperty); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheVolumeDataProperty", *pTheVolumeDataProperty); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_addpropertyfromfunction(Lib3MF_VolumeData pVolumeData, const char * pName, Lib3MF_Function pTheFunction, Lib3MF_VolumeDataProperty * pTheVolumeDataProperty) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "AddPropertyFromFunction"); + pJournalEntry->addStringParameter("Name", pName); + pJournalEntry->addHandleParameter("TheFunction", pTheFunction); + } + if (pName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTheVolumeDataProperty == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sName(pName); + IBase* pIBaseClassTheFunction = (IBase *)pTheFunction; + IFunction* pITheFunction = dynamic_cast(pIBaseClassTheFunction); + if (!pITheFunction) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IBase* pBaseTheVolumeDataProperty(nullptr); + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheVolumeDataProperty = pIVolumeData->AddPropertyFromFunction(sName, pITheFunction); + + *pTheVolumeDataProperty = (IBase*)(pBaseTheVolumeDataProperty); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheVolumeDataProperty", *pTheVolumeDataProperty); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_volumedata_removeproperty(Lib3MF_VolumeData pVolumeData, Lib3MF_uint32 nIndex) +{ + IBase* pIBaseClass = (IBase *)pVolumeData; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pVolumeData, "VolumeData", "RemoveProperty"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + } + IVolumeData* pIVolumeData = dynamic_cast(pIBaseClass); + if (!pIVolumeData) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIVolumeData->RemoveProperty(nIndex); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + /************************************************************************************************************************* Class implementation for Component **************************************************************************************************************************/ @@ -4821,8 +7544,20 @@ Lib3MFResult lib3mf_component_getuuid(Lib3MF_Component pComponent, bool * pHasUU if (!pIComponent) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sUUID = pIComponent->GetUUID(*pHasUUID); + bool isCacheCall = (pUUIDBuffer == nullptr); + if (isCacheCall) { + sUUID = pIComponent->GetUUID(*pHasUUID); + pIComponent->_setCache (new ParameterCache_2 (*pHasUUID, sUUID)); + } + else { + auto cache = dynamic_cast*> (pIComponent->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (*pHasUUID, sUUID); + pIComponent->_setCache (nullptr); + } + if (pUUIDNeededChars) *pUUIDNeededChars = (Lib3MF_uint32) (sUUID.size()+1); if (pUUIDBuffer) { @@ -5155,8 +7890,20 @@ Lib3MFResult lib3mf_beamset_getname(Lib3MF_BeamSet pBeamSet, const Lib3MF_uint32 if (!pIBeamSet) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sName = pIBeamSet->GetName(); + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pIBeamSet->GetName(); + pIBeamSet->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pIBeamSet->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pIBeamSet->_setCache (nullptr); + } + if (pNameNeededChars) *pNameNeededChars = (Lib3MF_uint32) (sName.size()+1); if (pNameBuffer) { @@ -5234,8 +7981,20 @@ Lib3MFResult lib3mf_beamset_getidentifier(Lib3MF_BeamSet pBeamSet, const Lib3MF_ if (!pIBeamSet) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sIdentifier = pIBeamSet->GetIdentifier(); + bool isCacheCall = (pIdentifierBuffer == nullptr); + if (isCacheCall) { + sIdentifier = pIBeamSet->GetIdentifier(); + pIBeamSet->_setCache (new ParameterCache_1 (sIdentifier)); + } + else { + auto cache = dynamic_cast*> (pIBeamSet->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sIdentifier); + pIBeamSet->_setCache (nullptr); + } + if (pIdentifierNeededChars) *pIdentifierNeededChars = (Lib3MF_uint32) (sIdentifier.size()+1); if (pIdentifierBuffer) { @@ -5620,8 +8379,20 @@ Lib3MFResult lib3mf_basematerialgroup_getname(Lib3MF_BaseMaterialGroup pBaseMate if (!pIBaseMaterialGroup) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sName = pIBaseMaterialGroup->GetName(nPropertyID); + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pIBaseMaterialGroup->GetName(nPropertyID); + pIBaseMaterialGroup->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pIBaseMaterialGroup->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pIBaseMaterialGroup->_setCache (nullptr); + } + if (pNameNeededChars) *pNameNeededChars = (Lib3MF_uint32) (sName.size()+1); if (pNameBuffer) { @@ -6711,6 +9482,509 @@ Lib3MFResult lib3mf_multipropertygroup_removelayer(Lib3MF_MultiPropertyGroup pMu } +/************************************************************************************************************************* + Class implementation for Image3D +**************************************************************************************************************************/ +Lib3MFResult lib3mf_image3d_getname(Lib3MF_Image3D pImage3D, const Lib3MF_uint32 nNameBufferSize, Lib3MF_uint32* pNameNeededChars, char * pNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImage3D, "Image3D", "GetName"); + } + if ( (!pNameBuffer) && !(pNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sName(""); + IImage3D* pIImage3D = dynamic_cast(pIBaseClass); + if (!pIImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pIImage3D->GetName(); + + pIImage3D->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pIImage3D->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pIImage3D->_setCache (nullptr); + } + + if (pNameNeededChars) + *pNameNeededChars = (Lib3MF_uint32) (sName.size()+1); + if (pNameBuffer) { + if (sName.size() >= nNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iName = 0; iName < sName.size(); iName++) + pNameBuffer[iName] = sName[iName]; + pNameBuffer[sName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Name", sName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_image3d_setname(Lib3MF_Image3D pImage3D, const char * pName) +{ + IBase* pIBaseClass = (IBase *)pImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImage3D, "Image3D", "SetName"); + pJournalEntry->addStringParameter("Name", pName); + } + if (pName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sName(pName); + IImage3D* pIImage3D = dynamic_cast(pIBaseClass); + if (!pIImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImage3D->SetName(sName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_image3d_isimagestack(Lib3MF_Image3D pImage3D, bool * pIsImageStack) +{ + IBase* pIBaseClass = (IBase *)pImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImage3D, "Image3D", "IsImageStack"); + } + if (pIsImageStack == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IImage3D* pIImage3D = dynamic_cast(pIBaseClass); + if (!pIImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pIsImageStack = pIImage3D->IsImageStack(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("IsImageStack", *pIsImageStack); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ImageStack +**************************************************************************************************************************/ +Lib3MFResult lib3mf_imagestack_getrowcount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 * pRowCount) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "GetRowCount"); + } + if (pRowCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pRowCount = pIImageStack->GetRowCount(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("RowCount", *pRowCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_setrowcount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nRowCount) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "SetRowCount"); + pJournalEntry->addUInt32Parameter("RowCount", nRowCount); + } + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImageStack->SetRowCount(nRowCount); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_getcolumncount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 * pColumnCount) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "GetColumnCount"); + } + if (pColumnCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pColumnCount = pIImageStack->GetColumnCount(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("ColumnCount", *pColumnCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_setcolumncount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nColumnCount) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "SetColumnCount"); + pJournalEntry->addUInt32Parameter("ColumnCount", nColumnCount); + } + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImageStack->SetColumnCount(nColumnCount); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_getsheetcount(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 * pSheetCount) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "GetSheetCount"); + } + if (pSheetCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pSheetCount = pIImageStack->GetSheetCount(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt32Result("SheetCount", *pSheetCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_getsheet(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, Lib3MF_Attachment * pSheet) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "GetSheet"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + } + if (pSheet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseSheet(nullptr); + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseSheet = pIImageStack->GetSheet(nIndex); + + *pSheet = (IBase*)(pBaseSheet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Sheet", *pSheet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_setsheet(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, Lib3MF_Attachment pSheet) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "SetSheet"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + pJournalEntry->addHandleParameter("Sheet", pSheet); + } + IBase* pIBaseClassSheet = (IBase *)pSheet; + IAttachment* pISheet = dynamic_cast(pIBaseClassSheet); + if (!pISheet) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImageStack->SetSheet(nIndex, pISheet); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_createemptysheet(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, const char * pPath, Lib3MF_Attachment * pSheet) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "CreateEmptySheet"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + pJournalEntry->addStringParameter("Path", pPath); + } + if (pPath == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pSheet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sPath(pPath); + IBase* pBaseSheet(nullptr); + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseSheet = pIImageStack->CreateEmptySheet(nIndex, sPath); + + *pSheet = (IBase*)(pBaseSheet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Sheet", *pSheet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_createsheetfrombuffer(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, const char * pPath, Lib3MF_uint64 nDataBufferSize, const Lib3MF_uint8 * pDataBuffer, Lib3MF_Attachment * pSheet) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "CreateSheetFromBuffer"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + pJournalEntry->addStringParameter("Path", pPath); + } + if (pPath == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if ( (!pDataBuffer) && (nDataBufferSize>0)) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pSheet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sPath(pPath); + IBase* pBaseSheet(nullptr); + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseSheet = pIImageStack->CreateSheetFromBuffer(nIndex, sPath, nDataBufferSize, pDataBuffer); + + *pSheet = (IBase*)(pBaseSheet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Sheet", *pSheet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_imagestack_createsheetfromfile(Lib3MF_ImageStack pImageStack, Lib3MF_uint32 nIndex, const char * pPath, const char * pFileName, Lib3MF_Attachment * pSheet) +{ + IBase* pIBaseClass = (IBase *)pImageStack; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImageStack, "ImageStack", "CreateSheetFromFile"); + pJournalEntry->addUInt32Parameter("Index", nIndex); + pJournalEntry->addStringParameter("Path", pPath); + pJournalEntry->addStringParameter("FileName", pFileName); + } + if (pPath == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pFileName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pSheet == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sPath(pPath); + std::string sFileName(pFileName); + IBase* pBaseSheet(nullptr); + IImageStack* pIImageStack = dynamic_cast(pIBaseClass); + if (!pIImageStack) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseSheet = pIImageStack->CreateSheetFromFile(nIndex, sPath, sFileName); + + *pSheet = (IBase*)(pBaseSheet); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Sheet", *pSheet); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + /************************************************************************************************************************* Class implementation for Attachment **************************************************************************************************************************/ @@ -6730,8 +10004,20 @@ Lib3MFResult lib3mf_attachment_getpath(Lib3MF_Attachment pAttachment, const Lib3 if (!pIAttachment) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sPath = pIAttachment->GetPath(); + bool isCacheCall = (pPathBuffer == nullptr); + if (isCacheCall) { + sPath = pIAttachment->GetPath(); + pIAttachment->_setCache (new ParameterCache_1 (sPath)); + } + else { + auto cache = dynamic_cast*> (pIAttachment->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sPath); + pIAttachment->_setCache (nullptr); + } + if (pPathNeededChars) *pPathNeededChars = (Lib3MF_uint32) (sPath.size()+1); if (pPathBuffer) { @@ -6845,8 +10131,20 @@ Lib3MFResult lib3mf_attachment_getrelationshiptype(Lib3MF_Attachment pAttachment if (!pIAttachment) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sPath = pIAttachment->GetRelationShipType(); + bool isCacheCall = (pPathBuffer == nullptr); + if (isCacheCall) { + sPath = pIAttachment->GetRelationShipType(); + pIAttachment->_setCache (new ParameterCache_1 (sPath)); + } + else { + auto cache = dynamic_cast*> (pIAttachment->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sPath); + pIAttachment->_setCache (nullptr); + } + if (pPathNeededChars) *pPathNeededChars = (Lib3MF_uint32) (sPath.size()+1); if (pPathBuffer) { @@ -7391,6 +10689,8102 @@ Lib3MFResult lib3mf_texture2d_setfilter(Lib3MF_Texture2D pTexture2D, eLib3MFText } +/************************************************************************************************************************* + Class implementation for ImplicitPort +**************************************************************************************************************************/ +Lib3MFResult lib3mf_implicitport_getidentifier(Lib3MF_ImplicitPort pImplicitPort, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "GetIdentifier"); + } + if ( (!pIdentifierBuffer) && !(pIdentifierNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(""); + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pIdentifierBuffer == nullptr); + if (isCacheCall) { + sIdentifier = pIImplicitPort->GetIdentifier(); + + pIImplicitPort->_setCache (new ParameterCache_1 (sIdentifier)); + } + else { + auto cache = dynamic_cast*> (pIImplicitPort->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sIdentifier); + pIImplicitPort->_setCache (nullptr); + } + + if (pIdentifierNeededChars) + *pIdentifierNeededChars = (Lib3MF_uint32) (sIdentifier.size()+1); + if (pIdentifierBuffer) { + if (sIdentifier.size() >= nIdentifierBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iIdentifier = 0; iIdentifier < sIdentifier.size(); iIdentifier++) + pIdentifierBuffer[iIdentifier] = sIdentifier[iIdentifier]; + pIdentifierBuffer[sIdentifier.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Identifier", sIdentifier.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitport_setidentifier(Lib3MF_ImplicitPort pImplicitPort, const char * pIdentifier) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "SetIdentifier"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitPort->SetIdentifier(sIdentifier); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitport_getdisplayname(Lib3MF_ImplicitPort pImplicitPort, const Lib3MF_uint32 nDisplayNameBufferSize, Lib3MF_uint32* pDisplayNameNeededChars, char * pDisplayNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "GetDisplayName"); + } + if ( (!pDisplayNameBuffer) && !(pDisplayNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sDisplayName(""); + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pDisplayNameBuffer == nullptr); + if (isCacheCall) { + sDisplayName = pIImplicitPort->GetDisplayName(); + + pIImplicitPort->_setCache (new ParameterCache_1 (sDisplayName)); + } + else { + auto cache = dynamic_cast*> (pIImplicitPort->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sDisplayName); + pIImplicitPort->_setCache (nullptr); + } + + if (pDisplayNameNeededChars) + *pDisplayNameNeededChars = (Lib3MF_uint32) (sDisplayName.size()+1); + if (pDisplayNameBuffer) { + if (sDisplayName.size() >= nDisplayNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iDisplayName = 0; iDisplayName < sDisplayName.size(); iDisplayName++) + pDisplayNameBuffer[iDisplayName] = sDisplayName[iDisplayName]; + pDisplayNameBuffer[sDisplayName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("DisplayName", sDisplayName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitport_setdisplayname(Lib3MF_ImplicitPort pImplicitPort, const char * pDisplayName) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "SetDisplayName"); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + } + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sDisplayName(pDisplayName); + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitPort->SetDisplayName(sDisplayName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitport_settype(Lib3MF_ImplicitPort pImplicitPort, eLib3MFImplicitPortType eImplicitPortType) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "SetType"); + pJournalEntry->addEnumParameter("ImplicitPortType", "ImplicitPortType", (Lib3MF_int32)(eImplicitPortType)); + } + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitPort->SetType(eImplicitPortType); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitport_gettype(Lib3MF_ImplicitPort pImplicitPort, eLib3MFImplicitPortType * pImplicitPortType) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "GetType"); + } + if (pImplicitPortType == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pImplicitPortType = pIImplicitPort->GetType(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addEnumResult("ImplicitPortType", "ImplicitPortType", (Lib3MF_int32)(*pImplicitPortType)); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitport_getreference(Lib3MF_ImplicitPort pImplicitPort, const Lib3MF_uint32 nReferenceBufferSize, Lib3MF_uint32* pReferenceNeededChars, char * pReferenceBuffer) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "GetReference"); + } + if ( (!pReferenceBuffer) && !(pReferenceNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sReference(""); + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pReferenceBuffer == nullptr); + if (isCacheCall) { + sReference = pIImplicitPort->GetReference(); + + pIImplicitPort->_setCache (new ParameterCache_1 (sReference)); + } + else { + auto cache = dynamic_cast*> (pIImplicitPort->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sReference); + pIImplicitPort->_setCache (nullptr); + } + + if (pReferenceNeededChars) + *pReferenceNeededChars = (Lib3MF_uint32) (sReference.size()+1); + if (pReferenceBuffer) { + if (sReference.size() >= nReferenceBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iReference = 0; iReference < sReference.size(); iReference++) + pReferenceBuffer[iReference] = sReference[iReference]; + pReferenceBuffer[sReference.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Reference", sReference.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitport_setreference(Lib3MF_ImplicitPort pImplicitPort, const char * pReference) +{ + IBase* pIBaseClass = (IBase *)pImplicitPort; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPort, "ImplicitPort", "SetReference"); + pJournalEntry->addStringParameter("Reference", pReference); + } + if (pReference == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sReference(pReference); + IImplicitPort* pIImplicitPort = dynamic_cast(pIBaseClass); + if (!pIImplicitPort) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitPort->SetReference(sReference); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for Iterator +**************************************************************************************************************************/ +Lib3MFResult lib3mf_iterator_movenext(Lib3MF_Iterator pIterator, bool * pHasNext) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pIterator, "Iterator", "MoveNext"); + } + if (pHasNext == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pHasNext = pIIterator->MoveNext(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("HasNext", *pHasNext); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_iterator_moveprevious(Lib3MF_Iterator pIterator, bool * pHasPrevious) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pIterator, "Iterator", "MovePrevious"); + } + if (pHasPrevious == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pHasPrevious = pIIterator->MovePrevious(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("HasPrevious", *pHasPrevious); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_iterator_count(Lib3MF_Iterator pIterator, Lib3MF_uint64 * pCount) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pIterator, "Iterator", "Count"); + } + if (pCount == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pCount = pIIterator->Count(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addUInt64Result("Count", *pCount); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ImplicitPortIterator +**************************************************************************************************************************/ +Lib3MFResult lib3mf_implicitportiterator_getcurrent(Lib3MF_ImplicitPortIterator pImplicitPortIterator, Lib3MF_ImplicitPort * pPort) +{ + IBase* pIBaseClass = (IBase *)pImplicitPortIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitPortIterator, "ImplicitPortIterator", "GetCurrent"); + } + if (pPort == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBasePort(nullptr); + IImplicitPortIterator* pIImplicitPortIterator = dynamic_cast(pIBaseClass); + if (!pIImplicitPortIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePort = pIImplicitPortIterator->GetCurrent(); + + *pPort = (IBase*)(pBasePort); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Port", *pPort); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ImplicitNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_implicitnode_getidentifier(Lib3MF_ImplicitNode pImplicitNode, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "GetIdentifier"); + } + if ( (!pIdentifierBuffer) && !(pIdentifierNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(""); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pIdentifierBuffer == nullptr); + if (isCacheCall) { + sIdentifier = pIImplicitNode->GetIdentifier(); + + pIImplicitNode->_setCache (new ParameterCache_1 (sIdentifier)); + } + else { + auto cache = dynamic_cast*> (pIImplicitNode->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sIdentifier); + pIImplicitNode->_setCache (nullptr); + } + + if (pIdentifierNeededChars) + *pIdentifierNeededChars = (Lib3MF_uint32) (sIdentifier.size()+1); + if (pIdentifierBuffer) { + if (sIdentifier.size() >= nIdentifierBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iIdentifier = 0; iIdentifier < sIdentifier.size(); iIdentifier++) + pIdentifierBuffer[iIdentifier] = sIdentifier[iIdentifier]; + pIdentifierBuffer[sIdentifier.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Identifier", sIdentifier.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_setidentifier(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "SetIdentifier"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitNode->SetIdentifier(sIdentifier); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_getdisplayname(Lib3MF_ImplicitNode pImplicitNode, const Lib3MF_uint32 nDisplayNameBufferSize, Lib3MF_uint32* pDisplayNameNeededChars, char * pDisplayNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "GetDisplayName"); + } + if ( (!pDisplayNameBuffer) && !(pDisplayNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sDisplayName(""); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pDisplayNameBuffer == nullptr); + if (isCacheCall) { + sDisplayName = pIImplicitNode->GetDisplayName(); + + pIImplicitNode->_setCache (new ParameterCache_1 (sDisplayName)); + } + else { + auto cache = dynamic_cast*> (pIImplicitNode->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sDisplayName); + pIImplicitNode->_setCache (nullptr); + } + + if (pDisplayNameNeededChars) + *pDisplayNameNeededChars = (Lib3MF_uint32) (sDisplayName.size()+1); + if (pDisplayNameBuffer) { + if (sDisplayName.size() >= nDisplayNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iDisplayName = 0; iDisplayName < sDisplayName.size(); iDisplayName++) + pDisplayNameBuffer[iDisplayName] = sDisplayName[iDisplayName]; + pDisplayNameBuffer[sDisplayName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("DisplayName", sDisplayName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_setdisplayname(Lib3MF_ImplicitNode pImplicitNode, const char * pDisplayName) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "SetDisplayName"); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + } + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sDisplayName(pDisplayName); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitNode->SetDisplayName(sDisplayName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_gettag(Lib3MF_ImplicitNode pImplicitNode, const Lib3MF_uint32 nTagBufferSize, Lib3MF_uint32* pTagNeededChars, char * pTagBuffer) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "GetTag"); + } + if ( (!pTagBuffer) && !(pTagNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sTag(""); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pTagBuffer == nullptr); + if (isCacheCall) { + sTag = pIImplicitNode->GetTag(); + + pIImplicitNode->_setCache (new ParameterCache_1 (sTag)); + } + else { + auto cache = dynamic_cast*> (pIImplicitNode->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sTag); + pIImplicitNode->_setCache (nullptr); + } + + if (pTagNeededChars) + *pTagNeededChars = (Lib3MF_uint32) (sTag.size()+1); + if (pTagBuffer) { + if (sTag.size() >= nTagBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iTag = 0; iTag < sTag.size(); iTag++) + pTagBuffer[iTag] = sTag[iTag]; + pTagBuffer[sTag.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Tag", sTag.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_settag(Lib3MF_ImplicitNode pImplicitNode, const char * pTag) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "SetTag"); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sTag(pTag); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitNode->SetTag(sTag); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_getnodetype(Lib3MF_ImplicitNode pImplicitNode, eLib3MFImplicitNodeType * pType) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "GetNodeType"); + } + if (pType == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pType = pIImplicitNode->GetNodeType(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addEnumResult("Type", "ImplicitNodeType", (Lib3MF_int32)(*pType)); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_addinput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, const char * pDisplayName, Lib3MF_ImplicitPort * pPort) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "AddInput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pPort == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + IBase* pBasePort(nullptr); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePort = pIImplicitNode->AddInput(sIdentifier, sDisplayName); + + *pPort = (IBase*)(pBasePort); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Port", *pPort); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_getinputs(Lib3MF_ImplicitNode pImplicitNode, Lib3MF_ImplicitPortIterator * pIterator) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "GetInputs"); + } + if (pIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseIterator(nullptr); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseIterator = pIImplicitNode->GetInputs(); + + *pIterator = (IBase*)(pBaseIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Iterator", *pIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_addoutput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, const char * pDisplayName, Lib3MF_ImplicitPort * pPort) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "AddOutput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pPort == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + IBase* pBasePort(nullptr); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePort = pIImplicitNode->AddOutput(sIdentifier, sDisplayName); + + *pPort = (IBase*)(pBasePort); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Port", *pPort); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_getoutputs(Lib3MF_ImplicitNode pImplicitNode, Lib3MF_ImplicitPortIterator * pIterator) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "GetOutputs"); + } + if (pIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseIterator(nullptr); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseIterator = pIImplicitNode->GetOutputs(); + + *pIterator = (IBase*)(pBaseIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Iterator", *pIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_findinput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, Lib3MF_ImplicitPort * pInput) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "FindInput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pInput == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseInput(nullptr); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseInput = pIImplicitNode->FindInput(sIdentifier); + + *pInput = (IBase*)(pBaseInput); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Input", *pInput); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_findoutput(Lib3MF_ImplicitNode pImplicitNode, const char * pIdentifier, Lib3MF_ImplicitPort * pOutput) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "FindOutput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pOutput == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseOutput(nullptr); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseOutput = pIImplicitNode->FindOutput(sIdentifier); + + *pOutput = (IBase*)(pBaseOutput); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Output", *pOutput); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitnode_aretypesvalid(Lib3MF_ImplicitNode pImplicitNode, bool * pValid) +{ + IBase* pIBaseClass = (IBase *)pImplicitNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitNode, "ImplicitNode", "AreTypesValid"); + } + if (pValid == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IImplicitNode* pIImplicitNode = dynamic_cast(pIBaseClass); + if (!pIImplicitNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pValid = pIImplicitNode->AreTypesValid(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addBooleanResult("Valid", *pValid); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for OneInputNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_oneinputnode_getinputa(Lib3MF_OneInputNode pOneInputNode, Lib3MF_ImplicitPort * pInput) +{ + IBase* pIBaseClass = (IBase *)pOneInputNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pOneInputNode, "OneInputNode", "GetInputA"); + } + if (pInput == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseInput(nullptr); + IOneInputNode* pIOneInputNode = dynamic_cast(pIBaseClass); + if (!pIOneInputNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseInput = pIOneInputNode->GetInputA(); + + *pInput = (IBase*)(pBaseInput); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Input", *pInput); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_oneinputnode_getoutputresult(Lib3MF_OneInputNode pOneInputNode, Lib3MF_ImplicitPort * pResult) +{ + IBase* pIBaseClass = (IBase *)pOneInputNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pOneInputNode, "OneInputNode", "GetOutputResult"); + } + if (pResult == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResult(nullptr); + IOneInputNode* pIOneInputNode = dynamic_cast(pIBaseClass); + if (!pIOneInputNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResult = pIOneInputNode->GetOutputResult(); + + *pResult = (IBase*)(pBaseResult); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Result", *pResult); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for SinNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for CosNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for TanNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for ArcSinNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for ArcCosNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for ArcTanNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for SinhNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for CoshNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for TanhNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for RoundNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for CeilNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for FloorNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for SignNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for FractNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for AbsNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for ExpNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for LogNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for Log2Node +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for Log10Node +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for LengthNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for TransposeNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for InverseNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for SqrtNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for ResourceIdNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_resourceidnode_setresource(Lib3MF_ResourceIdNode pResourceIdNode, Lib3MF_Resource pResource) +{ + IBase* pIBaseClass = (IBase *)pResourceIdNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pResourceIdNode, "ResourceIdNode", "SetResource"); + pJournalEntry->addHandleParameter("Resource", pResource); + } + IBase* pIBaseClassResource = (IBase *)pResource; + IResource* pIResource = dynamic_cast(pIBaseClassResource); + if (!pIResource) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IResourceIdNode* pIResourceIdNode = dynamic_cast(pIBaseClass); + if (!pIResourceIdNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIResourceIdNode->SetResource(pIResource); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_resourceidnode_getresource(Lib3MF_ResourceIdNode pResourceIdNode, Lib3MF_Resource * pResource) +{ + IBase* pIBaseClass = (IBase *)pResourceIdNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pResourceIdNode, "ResourceIdNode", "GetResource"); + } + if (pResource == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResource(nullptr); + IResourceIdNode* pIResourceIdNode = dynamic_cast(pIBaseClass); + if (!pIResourceIdNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResource = pIResourceIdNode->GetResource(); + + *pResource = (IBase*)(pBaseResource); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Resource", *pResource); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_resourceidnode_getoutputvalue(Lib3MF_ResourceIdNode pResourceIdNode, Lib3MF_ImplicitPort * pValue) +{ + IBase* pIBaseClass = (IBase *)pResourceIdNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pResourceIdNode, "ResourceIdNode", "GetOutputValue"); + } + if (pValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseValue(nullptr); + IResourceIdNode* pIResourceIdNode = dynamic_cast(pIBaseClass); + if (!pIResourceIdNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseValue = pIResourceIdNode->GetOutputValue(); + + *pValue = (IBase*)(pBaseValue); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Value", *pValue); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for TwoInputNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_twoinputnode_getinputb(Lib3MF_TwoInputNode pTwoInputNode, Lib3MF_ImplicitPort * pB) +{ + IBase* pIBaseClass = (IBase *)pTwoInputNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pTwoInputNode, "TwoInputNode", "GetInputB"); + } + if (pB == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseB(nullptr); + ITwoInputNode* pITwoInputNode = dynamic_cast(pIBaseClass); + if (!pITwoInputNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseB = pITwoInputNode->GetInputB(); + + *pB = (IBase*)(pBaseB); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("B", *pB); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for AdditionNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for SubtractionNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for MultiplicationNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for DivisionNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for DotNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for CrossNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for ArcTan2Node +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for MatVecMultiplicationNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for MinNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for MaxNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for FmodNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for ModNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for PowNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for SelectNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_selectnode_getinputb(Lib3MF_SelectNode pSelectNode, Lib3MF_ImplicitPort * pB) +{ + IBase* pIBaseClass = (IBase *)pSelectNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pSelectNode, "SelectNode", "GetInputB"); + } + if (pB == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseB(nullptr); + ISelectNode* pISelectNode = dynamic_cast(pIBaseClass); + if (!pISelectNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseB = pISelectNode->GetInputB(); + + *pB = (IBase*)(pBaseB); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("B", *pB); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_selectnode_getinputc(Lib3MF_SelectNode pSelectNode, Lib3MF_ImplicitPort * pC) +{ + IBase* pIBaseClass = (IBase *)pSelectNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pSelectNode, "SelectNode", "GetInputC"); + } + if (pC == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseC(nullptr); + ISelectNode* pISelectNode = dynamic_cast(pIBaseClass); + if (!pISelectNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseC = pISelectNode->GetInputC(); + + *pC = (IBase*)(pBaseC); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("C", *pC); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_selectnode_getinputd(Lib3MF_SelectNode pSelectNode, Lib3MF_ImplicitPort * pD) +{ + IBase* pIBaseClass = (IBase *)pSelectNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pSelectNode, "SelectNode", "GetInputD"); + } + if (pD == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseD(nullptr); + ISelectNode* pISelectNode = dynamic_cast(pIBaseClass); + if (!pISelectNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseD = pISelectNode->GetInputD(); + + *pD = (IBase*)(pBaseD); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("D", *pD); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ClampNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_clampnode_getinputmin(Lib3MF_ClampNode pClampNode, Lib3MF_ImplicitPort * pMin) +{ + IBase* pIBaseClass = (IBase *)pClampNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pClampNode, "ClampNode", "GetInputMin"); + } + if (pMin == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseMin(nullptr); + IClampNode* pIClampNode = dynamic_cast(pIBaseClass); + if (!pIClampNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseMin = pIClampNode->GetInputMin(); + + *pMin = (IBase*)(pBaseMin); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Min", *pMin); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_clampnode_getinputmax(Lib3MF_ClampNode pClampNode, Lib3MF_ImplicitPort * pMax) +{ + IBase* pIBaseClass = (IBase *)pClampNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pClampNode, "ClampNode", "GetInputMax"); + } + if (pMax == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseMax(nullptr); + IClampNode* pIClampNode = dynamic_cast(pIBaseClass); + if (!pIClampNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseMax = pIClampNode->GetInputMax(); + + *pMax = (IBase*)(pBaseMax); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Max", *pMax); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ComposeVectorNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_composevectornode_getinputx(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pX) +{ + IBase* pIBaseClass = (IBase *)pComposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeVectorNode, "ComposeVectorNode", "GetInputX"); + } + if (pX == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseX(nullptr); + IComposeVectorNode* pIComposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIComposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseX = pIComposeVectorNode->GetInputX(); + + *pX = (IBase*)(pBaseX); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("X", *pX); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composevectornode_getinputy(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pY) +{ + IBase* pIBaseClass = (IBase *)pComposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeVectorNode, "ComposeVectorNode", "GetInputY"); + } + if (pY == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseY(nullptr); + IComposeVectorNode* pIComposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIComposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseY = pIComposeVectorNode->GetInputY(); + + *pY = (IBase*)(pBaseY); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Y", *pY); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composevectornode_getinputz(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pZ) +{ + IBase* pIBaseClass = (IBase *)pComposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeVectorNode, "ComposeVectorNode", "GetInputZ"); + } + if (pZ == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseZ(nullptr); + IComposeVectorNode* pIComposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIComposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseZ = pIComposeVectorNode->GetInputZ(); + + *pZ = (IBase*)(pBaseZ); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Z", *pZ); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composevectornode_getoutputresult(Lib3MF_ComposeVectorNode pComposeVectorNode, Lib3MF_ImplicitPort * pResult) +{ + IBase* pIBaseClass = (IBase *)pComposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeVectorNode, "ComposeVectorNode", "GetOutputResult"); + } + if (pResult == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResult(nullptr); + IComposeVectorNode* pIComposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIComposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResult = pIComposeVectorNode->GetOutputResult(); + + *pResult = (IBase*)(pBaseResult); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Result", *pResult); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for VectorFromScalarNode +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for DecomposeVectorNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_decomposevectornode_getinputa(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pA) +{ + IBase* pIBaseClass = (IBase *)pDecomposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pDecomposeVectorNode, "DecomposeVectorNode", "GetInputA"); + } + if (pA == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseA(nullptr); + IDecomposeVectorNode* pIDecomposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIDecomposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseA = pIDecomposeVectorNode->GetInputA(); + + *pA = (IBase*)(pBaseA); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("A", *pA); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_decomposevectornode_getoutputx(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pX) +{ + IBase* pIBaseClass = (IBase *)pDecomposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pDecomposeVectorNode, "DecomposeVectorNode", "GetOutputX"); + } + if (pX == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseX(nullptr); + IDecomposeVectorNode* pIDecomposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIDecomposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseX = pIDecomposeVectorNode->GetOutputX(); + + *pX = (IBase*)(pBaseX); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("X", *pX); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_decomposevectornode_getoutputy(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pY) +{ + IBase* pIBaseClass = (IBase *)pDecomposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pDecomposeVectorNode, "DecomposeVectorNode", "GetOutputY"); + } + if (pY == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseY(nullptr); + IDecomposeVectorNode* pIDecomposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIDecomposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseY = pIDecomposeVectorNode->GetOutputY(); + + *pY = (IBase*)(pBaseY); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Y", *pY); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_decomposevectornode_getoutputz(Lib3MF_DecomposeVectorNode pDecomposeVectorNode, Lib3MF_ImplicitPort * pZ) +{ + IBase* pIBaseClass = (IBase *)pDecomposeVectorNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pDecomposeVectorNode, "DecomposeVectorNode", "GetOutputZ"); + } + if (pZ == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseZ(nullptr); + IDecomposeVectorNode* pIDecomposeVectorNode = dynamic_cast(pIBaseClass); + if (!pIDecomposeVectorNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseZ = pIDecomposeVectorNode->GetOutputZ(); + + *pZ = (IBase*)(pBaseZ); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Z", *pZ); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ComposeMatrixNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_composematrixnode_getinputm00(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM00) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM00"); + } + if (pM00 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM00(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM00 = pIComposeMatrixNode->GetInputM00(); + + *pM00 = (IBase*)(pBaseM00); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M00", *pM00); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm01(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM01) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM01"); + } + if (pM01 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM01(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM01 = pIComposeMatrixNode->GetInputM01(); + + *pM01 = (IBase*)(pBaseM01); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M01", *pM01); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm02(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM02) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM02"); + } + if (pM02 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM02(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM02 = pIComposeMatrixNode->GetInputM02(); + + *pM02 = (IBase*)(pBaseM02); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M02", *pM02); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm03(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM03) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM03"); + } + if (pM03 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM03(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM03 = pIComposeMatrixNode->GetInputM03(); + + *pM03 = (IBase*)(pBaseM03); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M03", *pM03); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm10(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM10) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM10"); + } + if (pM10 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM10(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM10 = pIComposeMatrixNode->GetInputM10(); + + *pM10 = (IBase*)(pBaseM10); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M10", *pM10); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm11(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM11) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM11"); + } + if (pM11 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM11(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM11 = pIComposeMatrixNode->GetInputM11(); + + *pM11 = (IBase*)(pBaseM11); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M11", *pM11); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm12(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM12) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM12"); + } + if (pM12 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM12(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM12 = pIComposeMatrixNode->GetInputM12(); + + *pM12 = (IBase*)(pBaseM12); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M12", *pM12); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm13(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM13) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM13"); + } + if (pM13 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM13(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM13 = pIComposeMatrixNode->GetInputM13(); + + *pM13 = (IBase*)(pBaseM13); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M13", *pM13); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm20(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM20) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM20"); + } + if (pM20 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM20(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM20 = pIComposeMatrixNode->GetInputM20(); + + *pM20 = (IBase*)(pBaseM20); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M20", *pM20); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm21(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM21) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM21"); + } + if (pM21 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM21(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM21 = pIComposeMatrixNode->GetInputM21(); + + *pM21 = (IBase*)(pBaseM21); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M21", *pM21); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm22(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM22) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM22"); + } + if (pM22 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM22(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM22 = pIComposeMatrixNode->GetInputM22(); + + *pM22 = (IBase*)(pBaseM22); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M22", *pM22); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm23(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM23) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM23"); + } + if (pM23 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM23(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM23 = pIComposeMatrixNode->GetInputM23(); + + *pM23 = (IBase*)(pBaseM23); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M23", *pM23); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm30(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM30) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM30"); + } + if (pM30 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM30(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM30 = pIComposeMatrixNode->GetInputM30(); + + *pM30 = (IBase*)(pBaseM30); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M30", *pM30); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm31(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM31) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM31"); + } + if (pM31 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM31(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM31 = pIComposeMatrixNode->GetInputM31(); + + *pM31 = (IBase*)(pBaseM31); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M31", *pM31); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm32(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM32) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM32"); + } + if (pM32 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM32(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM32 = pIComposeMatrixNode->GetInputM32(); + + *pM32 = (IBase*)(pBaseM32); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M32", *pM32); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getinputm33(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pM33) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetInputM33"); + } + if (pM33 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseM33(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseM33 = pIComposeMatrixNode->GetInputM33(); + + *pM33 = (IBase*)(pBaseM33); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("M33", *pM33); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_composematrixnode_getoutputresult(Lib3MF_ComposeMatrixNode pComposeMatrixNode, Lib3MF_ImplicitPort * pResult) +{ + IBase* pIBaseClass = (IBase *)pComposeMatrixNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pComposeMatrixNode, "ComposeMatrixNode", "GetOutputResult"); + } + if (pResult == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResult(nullptr); + IComposeMatrixNode* pIComposeMatrixNode = dynamic_cast(pIBaseClass); + if (!pIComposeMatrixNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResult = pIComposeMatrixNode->GetOutputResult(); + + *pResult = (IBase*)(pBaseResult); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Result", *pResult); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for MatrixFromRowsNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_matrixfromrowsnode_getinputa(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow0) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromRowsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromRowsNode, "MatrixFromRowsNode", "GetInputA"); + } + if (pRow0 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseRow0(nullptr); + IMatrixFromRowsNode* pIMatrixFromRowsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromRowsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseRow0 = pIMatrixFromRowsNode->GetInputA(); + + *pRow0 = (IBase*)(pBaseRow0); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Row0", *pRow0); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromrowsnode_getinputb(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow1) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromRowsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromRowsNode, "MatrixFromRowsNode", "GetInputB"); + } + if (pRow1 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseRow1(nullptr); + IMatrixFromRowsNode* pIMatrixFromRowsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromRowsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseRow1 = pIMatrixFromRowsNode->GetInputB(); + + *pRow1 = (IBase*)(pBaseRow1); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Row1", *pRow1); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromrowsnode_getinputc(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow2) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromRowsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromRowsNode, "MatrixFromRowsNode", "GetInputC"); + } + if (pRow2 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseRow2(nullptr); + IMatrixFromRowsNode* pIMatrixFromRowsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromRowsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseRow2 = pIMatrixFromRowsNode->GetInputC(); + + *pRow2 = (IBase*)(pBaseRow2); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Row2", *pRow2); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromrowsnode_getinputd(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pRow3) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromRowsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromRowsNode, "MatrixFromRowsNode", "GetInputD"); + } + if (pRow3 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseRow3(nullptr); + IMatrixFromRowsNode* pIMatrixFromRowsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromRowsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseRow3 = pIMatrixFromRowsNode->GetInputD(); + + *pRow3 = (IBase*)(pBaseRow3); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Row3", *pRow3); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromrowsnode_getoutputresult(Lib3MF_MatrixFromRowsNode pMatrixFromRowsNode, Lib3MF_ImplicitPort * pResult) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromRowsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromRowsNode, "MatrixFromRowsNode", "GetOutputResult"); + } + if (pResult == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResult(nullptr); + IMatrixFromRowsNode* pIMatrixFromRowsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromRowsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResult = pIMatrixFromRowsNode->GetOutputResult(); + + *pResult = (IBase*)(pBaseResult); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Result", *pResult); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for MatrixFromColumnsNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputa(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn0) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromColumnsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromColumnsNode, "MatrixFromColumnsNode", "GetInputA"); + } + if (pColumn0 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseColumn0(nullptr); + IMatrixFromColumnsNode* pIMatrixFromColumnsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromColumnsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseColumn0 = pIMatrixFromColumnsNode->GetInputA(); + + *pColumn0 = (IBase*)(pBaseColumn0); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Column0", *pColumn0); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputb(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn1) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromColumnsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromColumnsNode, "MatrixFromColumnsNode", "GetInputB"); + } + if (pColumn1 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseColumn1(nullptr); + IMatrixFromColumnsNode* pIMatrixFromColumnsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromColumnsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseColumn1 = pIMatrixFromColumnsNode->GetInputB(); + + *pColumn1 = (IBase*)(pBaseColumn1); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Column1", *pColumn1); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputc(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn2) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromColumnsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromColumnsNode, "MatrixFromColumnsNode", "GetInputC"); + } + if (pColumn2 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseColumn2(nullptr); + IMatrixFromColumnsNode* pIMatrixFromColumnsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromColumnsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseColumn2 = pIMatrixFromColumnsNode->GetInputC(); + + *pColumn2 = (IBase*)(pBaseColumn2); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Column2", *pColumn2); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromcolumnsnode_getinputd(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pColumn3) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromColumnsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromColumnsNode, "MatrixFromColumnsNode", "GetInputD"); + } + if (pColumn3 == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseColumn3(nullptr); + IMatrixFromColumnsNode* pIMatrixFromColumnsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromColumnsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseColumn3 = pIMatrixFromColumnsNode->GetInputD(); + + *pColumn3 = (IBase*)(pBaseColumn3); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Column3", *pColumn3); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_matrixfromcolumnsnode_getoutputresult(Lib3MF_MatrixFromColumnsNode pMatrixFromColumnsNode, Lib3MF_ImplicitPort * pResult) +{ + IBase* pIBaseClass = (IBase *)pMatrixFromColumnsNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMatrixFromColumnsNode, "MatrixFromColumnsNode", "GetOutputResult"); + } + if (pResult == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResult(nullptr); + IMatrixFromColumnsNode* pIMatrixFromColumnsNode = dynamic_cast(pIBaseClass); + if (!pIMatrixFromColumnsNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResult = pIMatrixFromColumnsNode->GetOutputResult(); + + *pResult = (IBase*)(pBaseResult); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Result", *pResult); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ConstantNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_constantnode_setconstant(Lib3MF_ConstantNode pConstantNode, Lib3MF_double dValue) +{ + IBase* pIBaseClass = (IBase *)pConstantNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstantNode, "ConstantNode", "SetConstant"); + pJournalEntry->addDoubleParameter("Value", dValue); + } + IConstantNode* pIConstantNode = dynamic_cast(pIBaseClass); + if (!pIConstantNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIConstantNode->SetConstant(dValue); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_constantnode_getconstant(Lib3MF_ConstantNode pConstantNode, Lib3MF_double * pValue) +{ + IBase* pIBaseClass = (IBase *)pConstantNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstantNode, "ConstantNode", "GetConstant"); + } + if (pValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IConstantNode* pIConstantNode = dynamic_cast(pIBaseClass); + if (!pIConstantNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pValue = pIConstantNode->GetConstant(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("Value", *pValue); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_constantnode_getoutputvalue(Lib3MF_ConstantNode pConstantNode, Lib3MF_ImplicitPort * pValue) +{ + IBase* pIBaseClass = (IBase *)pConstantNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstantNode, "ConstantNode", "GetOutputValue"); + } + if (pValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseValue(nullptr); + IConstantNode* pIConstantNode = dynamic_cast(pIBaseClass); + if (!pIConstantNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseValue = pIConstantNode->GetOutputValue(); + + *pValue = (IBase*)(pBaseValue); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Value", *pValue); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ConstVecNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_constvecnode_setvector(Lib3MF_ConstVecNode pConstVecNode, const sLib3MFVector * pValue) +{ + IBase* pIBaseClass = (IBase *)pConstVecNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstVecNode, "ConstVecNode", "SetVector"); + } + IConstVecNode* pIConstVecNode = dynamic_cast(pIBaseClass); + if (!pIConstVecNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIConstVecNode->SetVector(*pValue); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_constvecnode_getvector(Lib3MF_ConstVecNode pConstVecNode, sLib3MFVector * pValue) +{ + IBase* pIBaseClass = (IBase *)pConstVecNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstVecNode, "ConstVecNode", "GetVector"); + } + if (pValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IConstVecNode* pIConstVecNode = dynamic_cast(pIBaseClass); + if (!pIConstVecNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pValue = pIConstVecNode->GetVector(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_constvecnode_getoutputvector(Lib3MF_ConstVecNode pConstVecNode, Lib3MF_ImplicitPort * pVector) +{ + IBase* pIBaseClass = (IBase *)pConstVecNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstVecNode, "ConstVecNode", "GetOutputVector"); + } + if (pVector == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseVector(nullptr); + IConstVecNode* pIConstVecNode = dynamic_cast(pIBaseClass); + if (!pIConstVecNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseVector = pIConstVecNode->GetOutputVector(); + + *pVector = (IBase*)(pBaseVector); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Vector", *pVector); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ConstMatNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_constmatnode_setmatrix(Lib3MF_ConstMatNode pConstMatNode, const sLib3MFMatrix4x4 * pValue) +{ + IBase* pIBaseClass = (IBase *)pConstMatNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstMatNode, "ConstMatNode", "SetMatrix"); + } + IConstMatNode* pIConstMatNode = dynamic_cast(pIBaseClass); + if (!pIConstMatNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIConstMatNode->SetMatrix(*pValue); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_constmatnode_getmatrix(Lib3MF_ConstMatNode pConstMatNode, sLib3MFMatrix4x4 * pValue) +{ + IBase* pIBaseClass = (IBase *)pConstMatNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstMatNode, "ConstMatNode", "GetMatrix"); + } + if (pValue == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IConstMatNode* pIConstMatNode = dynamic_cast(pIBaseClass); + if (!pIConstMatNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pValue = pIConstMatNode->GetMatrix(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_constmatnode_getoutputmatrix(Lib3MF_ConstMatNode pConstMatNode, Lib3MF_ImplicitPort * pMatrix) +{ + IBase* pIBaseClass = (IBase *)pConstMatNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pConstMatNode, "ConstMatNode", "GetOutputMatrix"); + } + if (pMatrix == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseMatrix(nullptr); + IConstMatNode* pIConstMatNode = dynamic_cast(pIBaseClass); + if (!pIConstMatNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseMatrix = pIConstMatNode->GetOutputMatrix(); + + *pMatrix = (IBase*)(pBaseMatrix); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Matrix", *pMatrix); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for MeshNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_meshnode_getinputmesh(Lib3MF_MeshNode pMeshNode, Lib3MF_ImplicitPort * pMesh) +{ + IBase* pIBaseClass = (IBase *)pMeshNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshNode, "MeshNode", "GetInputMesh"); + } + if (pMesh == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseMesh(nullptr); + IMeshNode* pIMeshNode = dynamic_cast(pIBaseClass); + if (!pIMeshNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseMesh = pIMeshNode->GetInputMesh(); + + *pMesh = (IBase*)(pBaseMesh); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Mesh", *pMesh); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshnode_getinputpos(Lib3MF_MeshNode pMeshNode, Lib3MF_ImplicitPort * pPos) +{ + IBase* pIBaseClass = (IBase *)pMeshNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshNode, "MeshNode", "GetInputPos"); + } + if (pPos == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBasePos(nullptr); + IMeshNode* pIMeshNode = dynamic_cast(pIBaseClass); + if (!pIMeshNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePos = pIMeshNode->GetInputPos(); + + *pPos = (IBase*)(pBasePos); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Pos", *pPos); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_meshnode_getoutputdistance(Lib3MF_MeshNode pMeshNode, Lib3MF_ImplicitPort * pDistance) +{ + IBase* pIBaseClass = (IBase *)pMeshNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pMeshNode, "MeshNode", "GetOutputDistance"); + } + if (pDistance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseDistance(nullptr); + IMeshNode* pIMeshNode = dynamic_cast(pIBaseClass); + if (!pIMeshNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseDistance = pIMeshNode->GetOutputDistance(); + + *pDistance = (IBase*)(pBaseDistance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Distance", *pDistance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for UnsignedMeshNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_unsignedmeshnode_getinputmesh(Lib3MF_UnsignedMeshNode pUnsignedMeshNode, Lib3MF_ImplicitPort * pMesh) +{ + IBase* pIBaseClass = (IBase *)pUnsignedMeshNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pUnsignedMeshNode, "UnsignedMeshNode", "GetInputMesh"); + } + if (pMesh == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseMesh(nullptr); + IUnsignedMeshNode* pIUnsignedMeshNode = dynamic_cast(pIBaseClass); + if (!pIUnsignedMeshNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseMesh = pIUnsignedMeshNode->GetInputMesh(); + + *pMesh = (IBase*)(pBaseMesh); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Mesh", *pMesh); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_unsignedmeshnode_getinputpos(Lib3MF_UnsignedMeshNode pUnsignedMeshNode, Lib3MF_ImplicitPort * pPos) +{ + IBase* pIBaseClass = (IBase *)pUnsignedMeshNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pUnsignedMeshNode, "UnsignedMeshNode", "GetInputPos"); + } + if (pPos == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBasePos(nullptr); + IUnsignedMeshNode* pIUnsignedMeshNode = dynamic_cast(pIBaseClass); + if (!pIUnsignedMeshNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePos = pIUnsignedMeshNode->GetInputPos(); + + *pPos = (IBase*)(pBasePos); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Pos", *pPos); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_unsignedmeshnode_getoutputdistance(Lib3MF_UnsignedMeshNode pUnsignedMeshNode, Lib3MF_ImplicitPort * pDistance) +{ + IBase* pIBaseClass = (IBase *)pUnsignedMeshNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pUnsignedMeshNode, "UnsignedMeshNode", "GetOutputDistance"); + } + if (pDistance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseDistance(nullptr); + IUnsignedMeshNode* pIUnsignedMeshNode = dynamic_cast(pIBaseClass); + if (!pIUnsignedMeshNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseDistance = pIUnsignedMeshNode->GetOutputDistance(); + + *pDistance = (IBase*)(pBaseDistance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Distance", *pDistance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for BeamLatticeNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_beamlatticenode_getinputbeamlattice(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_ImplicitPort * pBeamLattice) +{ + IBase* pIBaseClass = (IBase *)pBeamLatticeNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pBeamLatticeNode, "BeamLatticeNode", "GetInputBeamLattice"); + } + if (pBeamLattice == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseBeamLattice(nullptr); + IBeamLatticeNode* pIBeamLatticeNode = dynamic_cast(pIBaseClass); + if (!pIBeamLatticeNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseBeamLattice = pIBeamLatticeNode->GetInputBeamLattice(); + + *pBeamLattice = (IBase*)(pBaseBeamLattice); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("BeamLattice", *pBeamLattice); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_beamlatticenode_getinputpos(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_ImplicitPort * pPos) +{ + IBase* pIBaseClass = (IBase *)pBeamLatticeNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pBeamLatticeNode, "BeamLatticeNode", "GetInputPos"); + } + if (pPos == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBasePos(nullptr); + IBeamLatticeNode* pIBeamLatticeNode = dynamic_cast(pIBaseClass); + if (!pIBeamLatticeNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePos = pIBeamLatticeNode->GetInputPos(); + + *pPos = (IBase*)(pBasePos); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Pos", *pPos); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_beamlatticenode_getoutputdistance(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_ImplicitPort * pDistance) +{ + IBase* pIBaseClass = (IBase *)pBeamLatticeNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pBeamLatticeNode, "BeamLatticeNode", "GetOutputDistance"); + } + if (pDistance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseDistance(nullptr); + IBeamLatticeNode* pIBeamLatticeNode = dynamic_cast(pIBaseClass); + if (!pIBeamLatticeNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseDistance = pIBeamLatticeNode->GetOutputDistance(); + + *pDistance = (IBase*)(pBaseDistance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Distance", *pDistance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_beamlatticenode_setaccuraterange(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_double dAccurateRange) +{ + IBase* pIBaseClass = (IBase *)pBeamLatticeNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pBeamLatticeNode, "BeamLatticeNode", "SetAccurateRange"); + pJournalEntry->addDoubleParameter("AccurateRange", dAccurateRange); + } + IBeamLatticeNode* pIBeamLatticeNode = dynamic_cast(pIBaseClass); + if (!pIBeamLatticeNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIBeamLatticeNode->SetAccurateRange(dAccurateRange); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_beamlatticenode_getaccuraterange(Lib3MF_BeamLatticeNode pBeamLatticeNode, Lib3MF_double * pAccurateRange) +{ + IBase* pIBaseClass = (IBase *)pBeamLatticeNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pBeamLatticeNode, "BeamLatticeNode", "GetAccurateRange"); + } + if (pAccurateRange == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBeamLatticeNode* pIBeamLatticeNode = dynamic_cast(pIBaseClass); + if (!pIBeamLatticeNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pAccurateRange = pIBeamLatticeNode->GetAccurateRange(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("AccurateRange", *pAccurateRange); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for FunctionGradientNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_functiongradientnode_getinputfunctionid(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pFunction) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetInputFunctionID"); + } + if (pFunction == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseFunction(nullptr); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseFunction = pIFunctionGradientNode->GetInputFunctionID(); + + *pFunction = (IBase*)(pBaseFunction); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Function", *pFunction); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_getinputpos(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pPos) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetInputPos"); + } + if (pPos == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBasePos(nullptr); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePos = pIFunctionGradientNode->GetInputPos(); + + *pPos = (IBase*)(pBasePos); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Pos", *pPos); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_getinputstep(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pStep) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetInputStep"); + } + if (pStep == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseStep(nullptr); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseStep = pIFunctionGradientNode->GetInputStep(); + + *pStep = (IBase*)(pBaseStep); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Step", *pStep); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_setscalaroutputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const char * pScalarOutputName) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "SetScalarOutputName"); + pJournalEntry->addStringParameter("ScalarOutputName", pScalarOutputName); + } + if (pScalarOutputName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sScalarOutputName(pScalarOutputName); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionGradientNode->SetScalarOutputName(sScalarOutputName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_getscalaroutputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const Lib3MF_uint32 nScalarOutputNameBufferSize, Lib3MF_uint32* pScalarOutputNameNeededChars, char * pScalarOutputNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetScalarOutputName"); + } + if ( (!pScalarOutputNameBuffer) && !(pScalarOutputNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sScalarOutputName(""); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pScalarOutputNameBuffer == nullptr); + if (isCacheCall) { + sScalarOutputName = pIFunctionGradientNode->GetScalarOutputName(); + + pIFunctionGradientNode->_setCache (new ParameterCache_1 (sScalarOutputName)); + } + else { + auto cache = dynamic_cast*> (pIFunctionGradientNode->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sScalarOutputName); + pIFunctionGradientNode->_setCache (nullptr); + } + + if (pScalarOutputNameNeededChars) + *pScalarOutputNameNeededChars = (Lib3MF_uint32) (sScalarOutputName.size()+1); + if (pScalarOutputNameBuffer) { + if (sScalarOutputName.size() >= nScalarOutputNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iScalarOutputName = 0; iScalarOutputName < sScalarOutputName.size(); iScalarOutputName++) + pScalarOutputNameBuffer[iScalarOutputName] = sScalarOutputName[iScalarOutputName]; + pScalarOutputNameBuffer[sScalarOutputName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("ScalarOutputName", sScalarOutputName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_setvectorinputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const char * pVectorInputName) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "SetVectorInputName"); + pJournalEntry->addStringParameter("VectorInputName", pVectorInputName); + } + if (pVectorInputName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sVectorInputName(pVectorInputName); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionGradientNode->SetVectorInputName(sVectorInputName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_getvectorinputname(Lib3MF_FunctionGradientNode pFunctionGradientNode, const Lib3MF_uint32 nVectorInputNameBufferSize, Lib3MF_uint32* pVectorInputNameNeededChars, char * pVectorInputNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetVectorInputName"); + } + if ( (!pVectorInputNameBuffer) && !(pVectorInputNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sVectorInputName(""); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pVectorInputNameBuffer == nullptr); + if (isCacheCall) { + sVectorInputName = pIFunctionGradientNode->GetVectorInputName(); + + pIFunctionGradientNode->_setCache (new ParameterCache_1 (sVectorInputName)); + } + else { + auto cache = dynamic_cast*> (pIFunctionGradientNode->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sVectorInputName); + pIFunctionGradientNode->_setCache (nullptr); + } + + if (pVectorInputNameNeededChars) + *pVectorInputNameNeededChars = (Lib3MF_uint32) (sVectorInputName.size()+1); + if (pVectorInputNameBuffer) { + if (sVectorInputName.size() >= nVectorInputNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iVectorInputName = 0; iVectorInputName < sVectorInputName.size(); iVectorInputName++) + pVectorInputNameBuffer[iVectorInputName] = sVectorInputName[iVectorInputName]; + pVectorInputNameBuffer[sVectorInputName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("VectorInputName", sVectorInputName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_getoutputnormalizedgradient(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pNormalizedGradient) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetOutputNormalizedGradient"); + } + if (pNormalizedGradient == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseNormalizedGradient(nullptr); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNormalizedGradient = pIFunctionGradientNode->GetOutputNormalizedGradient(); + + *pNormalizedGradient = (IBase*)(pBaseNormalizedGradient); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("NormalizedGradient", *pNormalizedGradient); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_getoutputgradient(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pGradient) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetOutputGradient"); + } + if (pGradient == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseGradient(nullptr); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseGradient = pIFunctionGradientNode->GetOutputGradient(); + + *pGradient = (IBase*)(pBaseGradient); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Gradient", *pGradient); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functiongradientnode_getoutputmagnitude(Lib3MF_FunctionGradientNode pFunctionGradientNode, Lib3MF_ImplicitPort * pMagnitude) +{ + IBase* pIBaseClass = (IBase *)pFunctionGradientNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionGradientNode, "FunctionGradientNode", "GetOutputMagnitude"); + } + if (pMagnitude == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseMagnitude(nullptr); + IFunctionGradientNode* pIFunctionGradientNode = dynamic_cast(pIBaseClass); + if (!pIFunctionGradientNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseMagnitude = pIFunctionGradientNode->GetOutputMagnitude(); + + *pMagnitude = (IBase*)(pBaseMagnitude); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Magnitude", *pMagnitude); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for NormalizeDistanceNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_normalizedistancenode_getinputfunctionid(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pFunction) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "GetInputFunctionID"); + } + if (pFunction == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseFunction(nullptr); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseFunction = pINormalizeDistanceNode->GetInputFunctionID(); + + *pFunction = (IBase*)(pBaseFunction); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Function", *pFunction); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_normalizedistancenode_getinputpos(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pPos) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "GetInputPos"); + } + if (pPos == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBasePos(nullptr); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePos = pINormalizeDistanceNode->GetInputPos(); + + *pPos = (IBase*)(pBasePos); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Pos", *pPos); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_normalizedistancenode_getinputstep(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pStep) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "GetInputStep"); + } + if (pStep == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseStep(nullptr); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseStep = pINormalizeDistanceNode->GetInputStep(); + + *pStep = (IBase*)(pBaseStep); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Step", *pStep); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_normalizedistancenode_setscalaroutputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const char * pScalarOutputName) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "SetScalarOutputName"); + pJournalEntry->addStringParameter("ScalarOutputName", pScalarOutputName); + } + if (pScalarOutputName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sScalarOutputName(pScalarOutputName); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pINormalizeDistanceNode->SetScalarOutputName(sScalarOutputName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_normalizedistancenode_getscalaroutputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const Lib3MF_uint32 nScalarOutputNameBufferSize, Lib3MF_uint32* pScalarOutputNameNeededChars, char * pScalarOutputNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "GetScalarOutputName"); + } + if ( (!pScalarOutputNameBuffer) && !(pScalarOutputNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sScalarOutputName(""); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pScalarOutputNameBuffer == nullptr); + if (isCacheCall) { + sScalarOutputName = pINormalizeDistanceNode->GetScalarOutputName(); + + pINormalizeDistanceNode->_setCache (new ParameterCache_1 (sScalarOutputName)); + } + else { + auto cache = dynamic_cast*> (pINormalizeDistanceNode->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sScalarOutputName); + pINormalizeDistanceNode->_setCache (nullptr); + } + + if (pScalarOutputNameNeededChars) + *pScalarOutputNameNeededChars = (Lib3MF_uint32) (sScalarOutputName.size()+1); + if (pScalarOutputNameBuffer) { + if (sScalarOutputName.size() >= nScalarOutputNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iScalarOutputName = 0; iScalarOutputName < sScalarOutputName.size(); iScalarOutputName++) + pScalarOutputNameBuffer[iScalarOutputName] = sScalarOutputName[iScalarOutputName]; + pScalarOutputNameBuffer[sScalarOutputName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("ScalarOutputName", sScalarOutputName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_normalizedistancenode_setvectorinputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const char * pVectorInputName) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "SetVectorInputName"); + pJournalEntry->addStringParameter("VectorInputName", pVectorInputName); + } + if (pVectorInputName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sVectorInputName(pVectorInputName); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pINormalizeDistanceNode->SetVectorInputName(sVectorInputName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_normalizedistancenode_getvectorinputname(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, const Lib3MF_uint32 nVectorInputNameBufferSize, Lib3MF_uint32* pVectorInputNameNeededChars, char * pVectorInputNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "GetVectorInputName"); + } + if ( (!pVectorInputNameBuffer) && !(pVectorInputNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sVectorInputName(""); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pVectorInputNameBuffer == nullptr); + if (isCacheCall) { + sVectorInputName = pINormalizeDistanceNode->GetVectorInputName(); + + pINormalizeDistanceNode->_setCache (new ParameterCache_1 (sVectorInputName)); + } + else { + auto cache = dynamic_cast*> (pINormalizeDistanceNode->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sVectorInputName); + pINormalizeDistanceNode->_setCache (nullptr); + } + + if (pVectorInputNameNeededChars) + *pVectorInputNameNeededChars = (Lib3MF_uint32) (sVectorInputName.size()+1); + if (pVectorInputNameBuffer) { + if (sVectorInputName.size() >= nVectorInputNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iVectorInputName = 0; iVectorInputName < sVectorInputName.size(); iVectorInputName++) + pVectorInputNameBuffer[iVectorInputName] = sVectorInputName[iVectorInputName]; + pVectorInputNameBuffer[sVectorInputName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("VectorInputName", sVectorInputName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_normalizedistancenode_getoutputresult(Lib3MF_NormalizeDistanceNode pNormalizeDistanceNode, Lib3MF_ImplicitPort * pResult) +{ + IBase* pIBaseClass = (IBase *)pNormalizeDistanceNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNormalizeDistanceNode, "NormalizeDistanceNode", "GetOutputResult"); + } + if (pResult == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResult(nullptr); + INormalizeDistanceNode* pINormalizeDistanceNode = dynamic_cast(pIBaseClass); + if (!pINormalizeDistanceNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResult = pINormalizeDistanceNode->GetOutputResult(); + + *pResult = (IBase*)(pBaseResult); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Result", *pResult); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for FunctionCallNode +**************************************************************************************************************************/ +Lib3MFResult lib3mf_functioncallnode_getinputfunctionid(Lib3MF_FunctionCallNode pFunctionCallNode, Lib3MF_ImplicitPort * pFunction) +{ + IBase* pIBaseClass = (IBase *)pFunctionCallNode; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionCallNode, "FunctionCallNode", "GetInputFunctionID"); + } + if (pFunction == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseFunction(nullptr); + IFunctionCallNode* pIFunctionCallNode = dynamic_cast(pIBaseClass); + if (!pIFunctionCallNode) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseFunction = pIFunctionCallNode->GetInputFunctionID(); + + *pFunction = (IBase*)(pBaseFunction); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Function", *pFunction); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for NodeIterator +**************************************************************************************************************************/ +Lib3MFResult lib3mf_nodeiterator_getcurrent(Lib3MF_NodeIterator pNodeIterator, Lib3MF_ImplicitNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pNodeIterator; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pNodeIterator, "NodeIterator", "GetCurrent"); + } + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseNode(nullptr); + INodeIterator* pINodeIterator = dynamic_cast(pIBaseClass); + if (!pINodeIterator) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pINodeIterator->GetCurrent(); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for Function +**************************************************************************************************************************/ +Lib3MFResult lib3mf_function_getdisplayname(Lib3MF_Function pFunction, const Lib3MF_uint32 nDisplayNameBufferSize, Lib3MF_uint32* pDisplayNameNeededChars, char * pDisplayNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "GetDisplayName"); + } + if ( (!pDisplayNameBuffer) && !(pDisplayNameNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sDisplayName(""); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pDisplayNameBuffer == nullptr); + if (isCacheCall) { + sDisplayName = pIFunction->GetDisplayName(); + + pIFunction->_setCache (new ParameterCache_1 (sDisplayName)); + } + else { + auto cache = dynamic_cast*> (pIFunction->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sDisplayName); + pIFunction->_setCache (nullptr); + } + + if (pDisplayNameNeededChars) + *pDisplayNameNeededChars = (Lib3MF_uint32) (sDisplayName.size()+1); + if (pDisplayNameBuffer) { + if (sDisplayName.size() >= nDisplayNameBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iDisplayName = 0; iDisplayName < sDisplayName.size(); iDisplayName++) + pDisplayNameBuffer[iDisplayName] = sDisplayName[iDisplayName]; + pDisplayNameBuffer[sDisplayName.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("DisplayName", sDisplayName.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_setdisplayname(Lib3MF_Function pFunction, const char * pDisplayName) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "SetDisplayName"); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + } + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sDisplayName(pDisplayName); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunction->SetDisplayName(sDisplayName); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_addinput(Lib3MF_Function pFunction, const char * pIdentifier, const char * pDisplayName, eLib3MFImplicitPortType eType, Lib3MF_ImplicitPort * pPort) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "AddInput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addEnumParameter("Type", "ImplicitPortType", (Lib3MF_int32)(eType)); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pPort == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + IBase* pBasePort(nullptr); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePort = pIFunction->AddInput(sIdentifier, sDisplayName, eType); + + *pPort = (IBase*)(pBasePort); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Port", *pPort); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_getinputs(Lib3MF_Function pFunction, Lib3MF_ImplicitPortIterator * pIterator) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "GetInputs"); + } + if (pIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseIterator(nullptr); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseIterator = pIFunction->GetInputs(); + + *pIterator = (IBase*)(pBaseIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Iterator", *pIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_removeinput(Lib3MF_Function pFunction, Lib3MF_ImplicitPort pInput) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "RemoveInput"); + pJournalEntry->addHandleParameter("Input", pInput); + } + IBase* pIBaseClassInput = (IBase *)pInput; + IImplicitPort* pIInput = dynamic_cast(pIBaseClassInput); + if (!pIInput) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunction->RemoveInput(pIInput); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_addoutput(Lib3MF_Function pFunction, const char * pIdentifier, const char * pDisplayName, eLib3MFImplicitPortType eType, Lib3MF_ImplicitPort * pPort) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "AddOutput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addEnumParameter("Type", "ImplicitPortType", (Lib3MF_int32)(eType)); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pPort == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + IBase* pBasePort(nullptr); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBasePort = pIFunction->AddOutput(sIdentifier, sDisplayName, eType); + + *pPort = (IBase*)(pBasePort); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Port", *pPort); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_getoutputs(Lib3MF_Function pFunction, Lib3MF_ImplicitPortIterator * pIterator) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "GetOutputs"); + } + if (pIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseIterator(nullptr); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseIterator = pIFunction->GetOutputs(); + + *pIterator = (IBase*)(pBaseIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Iterator", *pIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_removeoutput(Lib3MF_Function pFunction, Lib3MF_ImplicitPort pOutput) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "RemoveOutput"); + pJournalEntry->addHandleParameter("Output", pOutput); + } + IBase* pIBaseClassOutput = (IBase *)pOutput; + IImplicitPort* pIOutput = dynamic_cast(pIBaseClassOutput); + if (!pIOutput) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunction->RemoveOutput(pIOutput); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_findinput(Lib3MF_Function pFunction, const char * pIdentifier, Lib3MF_ImplicitPort * pInput) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "FindInput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pInput == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseInput(nullptr); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseInput = pIFunction->FindInput(sIdentifier); + + *pInput = (IBase*)(pBaseInput); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Input", *pInput); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_function_findoutput(Lib3MF_Function pFunction, const char * pIdentifier, Lib3MF_ImplicitPort * pOutput) +{ + IBase* pIBaseClass = (IBase *)pFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunction, "Function", "FindOutput"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pOutput == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IBase* pBaseOutput(nullptr); + IFunction* pIFunction = dynamic_cast(pIBaseClass); + if (!pIFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseOutput = pIFunction->FindOutput(sIdentifier); + + *pOutput = (IBase*)(pBaseOutput); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Output", *pOutput); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for ImplicitFunction +**************************************************************************************************************************/ +Lib3MFResult lib3mf_implicitfunction_getidentifier(Lib3MF_ImplicitFunction pImplicitFunction, const Lib3MF_uint32 nIdentifierBufferSize, Lib3MF_uint32* pIdentifierNeededChars, char * pIdentifierBuffer) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "GetIdentifier"); + } + if ( (!pIdentifierBuffer) && !(pIdentifierNeededChars) ) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(""); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + bool isCacheCall = (pIdentifierBuffer == nullptr); + if (isCacheCall) { + sIdentifier = pIImplicitFunction->GetIdentifier(); + + pIImplicitFunction->_setCache (new ParameterCache_1 (sIdentifier)); + } + else { + auto cache = dynamic_cast*> (pIImplicitFunction->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sIdentifier); + pIImplicitFunction->_setCache (nullptr); + } + + if (pIdentifierNeededChars) + *pIdentifierNeededChars = (Lib3MF_uint32) (sIdentifier.size()+1); + if (pIdentifierBuffer) { + if (sIdentifier.size() >= nIdentifierBufferSize) + throw ELib3MFInterfaceException (LIB3MF_ERROR_BUFFERTOOSMALL); + for (size_t iIdentifier = 0; iIdentifier < sIdentifier.size(); iIdentifier++) + pIdentifierBuffer[iIdentifier] = sIdentifier[iIdentifier]; + pIdentifierBuffer[sIdentifier.size()] = 0; + } + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addStringResult("Identifier", sIdentifier.c_str()); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_setidentifier(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "SetIdentifier"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitFunction->SetIdentifier(sIdentifier); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addnode(Lib3MF_ImplicitFunction pImplicitFunction, eLib3MFImplicitNodeType eNodeType, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ImplicitNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddNode"); + pJournalEntry->addEnumParameter("NodeType", "ImplicitNodeType", (Lib3MF_int32)(eNodeType)); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddNode(eNodeType, sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addsinnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SinNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddSinNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddSinNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addcosnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_CosNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddCosNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddCosNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addtannode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_TanNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddTanNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddTanNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addarcsinnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ArcSinNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddArcSinNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddArcSinNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addarccosnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ArcCosNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddArcCosNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddArcCosNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addarctan2node(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ArcTan2Node * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddArcTan2Node"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddArcTan2Node(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addsinhnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SinhNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddSinhNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddSinhNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addcoshnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_CoshNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddCoshNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddCoshNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addtanhnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_TanhNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddTanhNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddTanhNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addroundnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_RoundNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddRoundNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddRoundNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addceilnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_CeilNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddCeilNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddCeilNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addfloornode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_FloorNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddFloorNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddFloorNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addsignnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SignNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddSignNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddSignNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addfractnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_FractNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddFractNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddFractNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addabsnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_AbsNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddAbsNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddAbsNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addexpnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ExpNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddExpNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddExpNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addlognode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_LogNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddLogNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddLogNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addlog2node(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_Log2Node * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddLog2Node"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddLog2Node(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addlog10node(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_Log10Node * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddLog10Node"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddLog10Node(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addlengthnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_LengthNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddLengthNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddLengthNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addtransposenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_TransposeNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddTransposeNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddTransposeNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addinversenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_InverseNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddInverseNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddInverseNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addsqrtnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SqrtNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddSqrtNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddSqrtNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addresourceidnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ResourceIdNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddResourceIdNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddResourceIdNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addadditionnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_AdditionNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddAdditionNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddAdditionNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addsubtractionnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SubtractionNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddSubtractionNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddSubtractionNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addmultiplicationnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_MultiplicationNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddMultiplicationNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddMultiplicationNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_adddivisionnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_DivisionNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddDivisionNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddDivisionNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_adddotnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_DotNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddDotNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddDotNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addcrossnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_CrossNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddCrossNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddCrossNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addmatvecmultiplicationnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MatVecMultiplicationNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddMatVecMultiplicationNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddMatVecMultiplicationNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addminnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_MinNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddMinNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddMinNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addmaxnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_MaxNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddMaxNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddMaxNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addfmodnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_FmodNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddFmodNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddFmodNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addpownode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_PowNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddPowNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddPowNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addselectnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_SelectNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddSelectNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddSelectNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addclampnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, eLib3MFImplicitNodeConfiguration eConfiguration, const char * pDisplayName, const char * pTag, Lib3MF_ClampNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddClampNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addEnumParameter("Configuration", "ImplicitNodeConfiguration", (Lib3MF_int32)(eConfiguration)); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddClampNode(sIdentifier, eConfiguration, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addcomposevectornode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ComposeVectorNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddComposeVectorNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddComposeVectorNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addvectorfromscalarnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_VectorFromScalarNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddVectorFromScalarNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddVectorFromScalarNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_adddecomposevectornode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_DecomposeVectorNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddDecomposeVectorNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddDecomposeVectorNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addcomposematrixnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ComposeMatrixNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddComposeMatrixNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddComposeMatrixNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addmatrixfromrowsnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MatrixFromRowsNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddMatrixFromRowsNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddMatrixFromRowsNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addmatrixfromcolumnsnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MatrixFromColumnsNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddMatrixFromColumnsNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddMatrixFromColumnsNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addconstantnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ConstantNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddConstantNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddConstantNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addconstvecnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ConstVecNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddConstVecNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddConstVecNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addconstmatnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_ConstMatNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddConstMatNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddConstMatNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addmeshnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_MeshNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddMeshNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddMeshNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addunsignedmeshnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_UnsignedMeshNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddUnsignedMeshNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddUnsignedMeshNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addbeamlatticenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_BeamLatticeNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddBeamLatticeNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddBeamLatticeNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addfunctiongradientnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_FunctionGradientNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddFunctionGradientNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddFunctionGradientNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addnormalizedistancenode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_NormalizeDistanceNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddNormalizeDistanceNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddNormalizeDistanceNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addfunctioncallnode(Lib3MF_ImplicitFunction pImplicitFunction, const char * pIdentifier, const char * pDisplayName, const char * pTag, Lib3MF_FunctionCallNode * pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddFunctionCallNode"); + pJournalEntry->addStringParameter("Identifier", pIdentifier); + pJournalEntry->addStringParameter("DisplayName", pDisplayName); + pJournalEntry->addStringParameter("Tag", pTag); + } + if (pIdentifier == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pDisplayName == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTag == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pNode == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sIdentifier(pIdentifier); + std::string sDisplayName(pDisplayName); + std::string sTag(pTag); + IBase* pBaseNode(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseNode = pIImplicitFunction->AddFunctionCallNode(sIdentifier, sDisplayName, sTag); + + *pNode = (IBase*)(pBaseNode); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Node", *pNode); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_getnodes(Lib3MF_ImplicitFunction pImplicitFunction, Lib3MF_NodeIterator * pIterator) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "GetNodes"); + } + if (pIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseIterator(nullptr); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseIterator = pIImplicitFunction->GetNodes(); + + *pIterator = (IBase*)(pBaseIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Iterator", *pIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_removenode(Lib3MF_ImplicitFunction pImplicitFunction, Lib3MF_ImplicitNode pNode) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "RemoveNode"); + pJournalEntry->addHandleParameter("Node", pNode); + } + IBase* pIBaseClassNode = (IBase *)pNode; + IImplicitNode* pINode = dynamic_cast(pIBaseClassNode); + if (!pINode) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitFunction->RemoveNode(pINode); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addlink(Lib3MF_ImplicitFunction pImplicitFunction, Lib3MF_ImplicitPort pSource, Lib3MF_ImplicitPort pTarget) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddLink"); + pJournalEntry->addHandleParameter("Source", pSource); + pJournalEntry->addHandleParameter("Target", pTarget); + } + IBase* pIBaseClassSource = (IBase *)pSource; + IImplicitPort* pISource = dynamic_cast(pIBaseClassSource); + if (!pISource) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IBase* pIBaseClassTarget = (IBase *)pTarget; + IImplicitPort* pITarget = dynamic_cast(pIBaseClassTarget); + if (!pITarget) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitFunction->AddLink(pISource, pITarget); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_addlinkbynames(Lib3MF_ImplicitFunction pImplicitFunction, const char * pSource, const char * pTarget) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "AddLinkByNames"); + pJournalEntry->addStringParameter("Source", pSource); + pJournalEntry->addStringParameter("Target", pTarget); + } + if (pSource == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (pTarget == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + std::string sSource(pSource); + std::string sTarget(pTarget); + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitFunction->AddLinkByNames(sSource, sTarget); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_clear(Lib3MF_ImplicitFunction pImplicitFunction) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "Clear"); + } + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitFunction->Clear(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_implicitfunction_sortnodestopologically(Lib3MF_ImplicitFunction pImplicitFunction) +{ + IBase* pIBaseClass = (IBase *)pImplicitFunction; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pImplicitFunction, "ImplicitFunction", "SortNodesTopologically"); + } + IImplicitFunction* pIImplicitFunction = dynamic_cast(pIBaseClass); + if (!pIImplicitFunction) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIImplicitFunction->SortNodesTopologically(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + +/************************************************************************************************************************* + Class implementation for FunctionFromImage3D +**************************************************************************************************************************/ +Lib3MFResult lib3mf_functionfromimage3d_getimage3d(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_Image3D * pImage3D) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "GetImage3D"); + } + if (pImage3D == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseImage3D(nullptr); + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseImage3D = pIFunctionFromImage3D->GetImage3D(); + + *pImage3D = (IBase*)(pBaseImage3D); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Image3D", *pImage3D); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_setimage3d(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_Image3D pImage3D) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "SetImage3D"); + pJournalEntry->addHandleParameter("Image3D", pImage3D); + } + IBase* pIBaseClassImage3D = (IBase *)pImage3D; + IImage3D* pIImage3D = dynamic_cast(pIBaseClassImage3D); + if (!pIImage3D) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionFromImage3D->SetImage3D(pIImage3D); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_setfilter(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, eLib3MFTextureFilter eFilter) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "SetFilter"); + pJournalEntry->addEnumParameter("Filter", "TextureFilter", (Lib3MF_int32)(eFilter)); + } + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionFromImage3D->SetFilter(eFilter); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_getfilter(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, eLib3MFTextureFilter * pFilter) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "GetFilter"); + } + if (pFilter == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pFilter = pIFunctionFromImage3D->GetFilter(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addEnumResult("Filter", "TextureFilter", (Lib3MF_int32)(*pFilter)); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_settilestyles(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, eLib3MFTextureTileStyle eTileStyleU, eLib3MFTextureTileStyle eTileStyleV, eLib3MFTextureTileStyle eTileStyleW) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "SetTileStyles"); + pJournalEntry->addEnumParameter("TileStyleU", "TextureTileStyle", (Lib3MF_int32)(eTileStyleU)); + pJournalEntry->addEnumParameter("TileStyleV", "TextureTileStyle", (Lib3MF_int32)(eTileStyleV)); + pJournalEntry->addEnumParameter("TileStyleW", "TextureTileStyle", (Lib3MF_int32)(eTileStyleW)); + } + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionFromImage3D->SetTileStyles(eTileStyleU, eTileStyleV, eTileStyleW); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_gettilestyles(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, eLib3MFTextureTileStyle * pTileStyleU, eLib3MFTextureTileStyle * pTileStyleV, eLib3MFTextureTileStyle * pTileStyleW) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "GetTileStyles"); + } + if (!pTileStyleU) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (!pTileStyleV) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + if (!pTileStyleW) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionFromImage3D->GetTileStyles(*pTileStyleU, *pTileStyleV, *pTileStyleW); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addEnumResult("TileStyleU", "TextureTileStyle", (Lib3MF_int32)(*pTileStyleU)); + pJournalEntry->addEnumResult("TileStyleV", "TextureTileStyle", (Lib3MF_int32)(*pTileStyleV)); + pJournalEntry->addEnumResult("TileStyleW", "TextureTileStyle", (Lib3MF_int32)(*pTileStyleW)); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_getoffset(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double * pOffset) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "GetOffset"); + } + if (pOffset == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pOffset = pIFunctionFromImage3D->GetOffset(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("Offset", *pOffset); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_setoffset(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double dOffset) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "SetOffset"); + pJournalEntry->addDoubleParameter("Offset", dOffset); + } + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionFromImage3D->SetOffset(dOffset); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_getscale(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double * pScale) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "GetScale"); + } + if (pScale == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + *pScale = pIFunctionFromImage3D->GetScale(); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addDoubleResult("Scale", *pScale); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_functionfromimage3d_setscale(Lib3MF_FunctionFromImage3D pFunctionFromImage3D, Lib3MF_double dScale) +{ + IBase* pIBaseClass = (IBase *)pFunctionFromImage3D; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pFunctionFromImage3D, "FunctionFromImage3D", "SetScale"); + pJournalEntry->addDoubleParameter("Scale", dScale); + } + IFunctionFromImage3D* pIFunctionFromImage3D = dynamic_cast(pIBaseClass); + if (!pIFunctionFromImage3D) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIFunctionFromImage3D->SetScale(dScale); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + + /************************************************************************************************************************* Class implementation for BuildItem **************************************************************************************************************************/ @@ -7448,8 +18842,20 @@ Lib3MFResult lib3mf_builditem_getuuid(Lib3MF_BuildItem pBuildItem, bool * pHasUU if (!pIBuildItem) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sUUID = pIBuildItem->GetUUID(*pHasUUID); + bool isCacheCall = (pUUIDBuffer == nullptr); + if (isCacheCall) { + sUUID = pIBuildItem->GetUUID(*pHasUUID); + pIBuildItem->_setCache (new ParameterCache_2 (*pHasUUID, sUUID)); + } + else { + auto cache = dynamic_cast*> (pIBuildItem->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (*pHasUUID, sUUID); + pIBuildItem->_setCache (nullptr); + } + if (pUUIDNeededChars) *pUUIDNeededChars = (Lib3MF_uint32) (sUUID.size()+1); if (pUUIDBuffer) { @@ -7660,8 +19066,20 @@ Lib3MFResult lib3mf_builditem_getpartnumber(Lib3MF_BuildItem pBuildItem, const L if (!pIBuildItem) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sPartNumber = pIBuildItem->GetPartNumber(); + bool isCacheCall = (pPartNumberBuffer == nullptr); + if (isCacheCall) { + sPartNumber = pIBuildItem->GetPartNumber(); + pIBuildItem->_setCache (new ParameterCache_1 (sPartNumber)); + } + else { + auto cache = dynamic_cast*> (pIBuildItem->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sPartNumber); + pIBuildItem->_setCache (nullptr); + } + if (pPartNumberNeededChars) *pPartNumberNeededChars = (Lib3MF_uint32) (sPartNumber.size()+1); if (pPartNumberBuffer) { @@ -8617,8 +20035,20 @@ Lib3MFResult lib3mf_slicestack_getownpath(Lib3MF_SliceStack pSliceStack, const L if (!pISliceStack) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sPath = pISliceStack->GetOwnPath(); + bool isCacheCall = (pPathBuffer == nullptr); + if (isCacheCall) { + sPath = pISliceStack->GetOwnPath(); + pISliceStack->_setCache (new ParameterCache_1 (sPath)); + } + else { + auto cache = dynamic_cast*> (pISliceStack->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sPath); + pISliceStack->_setCache (nullptr); + } + if (pPathNeededChars) *pPathNeededChars = (Lib3MF_uint32) (sPath.size()+1); if (pPathBuffer) { @@ -8665,8 +20095,20 @@ Lib3MFResult lib3mf_consumer_getconsumerid(Lib3MF_Consumer pConsumer, const Lib3 if (!pIConsumer) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sConsumerID = pIConsumer->GetConsumerID(); + bool isCacheCall = (pConsumerIDBuffer == nullptr); + if (isCacheCall) { + sConsumerID = pIConsumer->GetConsumerID(); + pIConsumer->_setCache (new ParameterCache_1 (sConsumerID)); + } + else { + auto cache = dynamic_cast*> (pIConsumer->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sConsumerID); + pIConsumer->_setCache (nullptr); + } + if (pConsumerIDNeededChars) *pConsumerIDNeededChars = (Lib3MF_uint32) (sConsumerID.size()+1); if (pConsumerIDBuffer) { @@ -8709,8 +20151,20 @@ Lib3MFResult lib3mf_consumer_getkeyid(Lib3MF_Consumer pConsumer, const Lib3MF_ui if (!pIConsumer) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sKeyID = pIConsumer->GetKeyID(); + bool isCacheCall = (pKeyIDBuffer == nullptr); + if (isCacheCall) { + sKeyID = pIConsumer->GetKeyID(); + pIConsumer->_setCache (new ParameterCache_1 (sKeyID)); + } + else { + auto cache = dynamic_cast*> (pIConsumer->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sKeyID); + pIConsumer->_setCache (nullptr); + } + if (pKeyIDNeededChars) *pKeyIDNeededChars = (Lib3MF_uint32) (sKeyID.size()+1); if (pKeyIDBuffer) { @@ -8753,8 +20207,20 @@ Lib3MFResult lib3mf_consumer_getkeyvalue(Lib3MF_Consumer pConsumer, const Lib3MF if (!pIConsumer) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sKeyValue = pIConsumer->GetKeyValue(); + bool isCacheCall = (pKeyValueBuffer == nullptr); + if (isCacheCall) { + sKeyValue = pIConsumer->GetKeyValue(); + pIConsumer->_setCache (new ParameterCache_1 (sKeyValue)); + } + else { + auto cache = dynamic_cast*> (pIConsumer->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sKeyValue); + pIConsumer->_setCache (nullptr); + } + if (pKeyValueNeededChars) *pKeyValueNeededChars = (Lib3MF_uint32) (sKeyValue.size()+1); if (pKeyValueBuffer) { @@ -9176,8 +20642,20 @@ Lib3MFResult lib3mf_contentencryptionparams_getkeyuuid(Lib3MF_ContentEncryptionP if (!pIContentEncryptionParams) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sUUID = pIContentEncryptionParams->GetKeyUUID(); + bool isCacheCall = (pUUIDBuffer == nullptr); + if (isCacheCall) { + sUUID = pIContentEncryptionParams->GetKeyUUID(); + pIContentEncryptionParams->_setCache (new ParameterCache_1 (sUUID)); + } + else { + auto cache = dynamic_cast*> (pIContentEncryptionParams->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sUUID); + pIContentEncryptionParams->_setCache (nullptr); + } + if (pUUIDNeededChars) *pUUIDNeededChars = (Lib3MF_uint32) (sUUID.size()+1); if (pUUIDBuffer) { @@ -9365,8 +20843,20 @@ Lib3MFResult lib3mf_resourcedatagroup_getkeyuuid(Lib3MF_ResourceDataGroup pResou if (!pIResourceDataGroup) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sUUID = pIResourceDataGroup->GetKeyUUID(); + bool isCacheCall = (pUUIDBuffer == nullptr); + if (isCacheCall) { + sUUID = pIResourceDataGroup->GetKeyUUID(); + pIResourceDataGroup->_setCache (new ParameterCache_1 (sUUID)); + } + else { + auto cache = dynamic_cast*> (pIResourceDataGroup->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sUUID); + pIResourceDataGroup->_setCache (nullptr); + } + if (pUUIDNeededChars) *pUUIDNeededChars = (Lib3MF_uint32) (sUUID.size()+1); if (pUUIDBuffer) { @@ -10123,8 +21613,20 @@ Lib3MFResult lib3mf_keystore_getuuid(Lib3MF_KeyStore pKeyStore, bool * pHasUUID, if (!pIKeyStore) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sUUID = pIKeyStore->GetUUID(*pHasUUID); + bool isCacheCall = (pUUIDBuffer == nullptr); + if (isCacheCall) { + sUUID = pIKeyStore->GetUUID(*pHasUUID); + pIKeyStore->_setCache (new ParameterCache_2 (*pHasUUID, sUUID)); + } + else { + auto cache = dynamic_cast*> (pIKeyStore->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (*pHasUUID, sUUID); + pIKeyStore->_setCache (nullptr); + } + if (pUUIDNeededChars) *pUUIDNeededChars = (Lib3MF_uint32) (sUUID.size()+1); if (pUUIDBuffer) { @@ -10349,8 +21851,20 @@ Lib3MFResult lib3mf_model_getlanguage(Lib3MF_Model pModel, const Lib3MF_uint32 n if (!pIModel) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sLanguage = pIModel->GetLanguage(); + bool isCacheCall = (pLanguageBuffer == nullptr); + if (isCacheCall) { + sLanguage = pIModel->GetLanguage(); + pIModel->_setCache (new ParameterCache_1 (sLanguage)); + } + else { + auto cache = dynamic_cast*> (pIModel->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (sLanguage); + pIModel->_setCache (nullptr); + } + if (pLanguageNeededChars) *pLanguageNeededChars = (Lib3MF_uint32) (sLanguage.size()+1); if (pLanguageBuffer) { @@ -10492,6 +22006,43 @@ Lib3MFResult lib3mf_model_queryreader(Lib3MF_Model pModel, const char * pReaderC } } +Lib3MFResult lib3mf_model_getresourcebyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_Resource * pResource) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "GetResourceByID"); + pJournalEntry->addUInt32Parameter("UniqueResourceID", nUniqueResourceID); + } + if (pResource == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResource(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResource = pIModel->GetResourceByID(nUniqueResourceID); + + *pResource = (IBase*)(pBaseResource); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Resource", *pResource); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + Lib3MFResult lib3mf_model_gettexture2dbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_Texture2D * pTextureInstance) { IBase* pIBaseClass = (IBase *)pModel; @@ -10860,6 +22411,43 @@ Lib3MFResult lib3mf_model_getslicestackbyid(Lib3MF_Model pModel, Lib3MF_uint32 n } } +Lib3MFResult lib3mf_model_getlevelsetbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_LevelSet * pLevelSetObjectInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "GetLevelSetByID"); + pJournalEntry->addUInt32Parameter("UniqueResourceID", nUniqueResourceID); + } + if (pLevelSetObjectInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseLevelSetObjectInstance(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseLevelSetObjectInstance = pIModel->GetLevelSetByID(nUniqueResourceID); + + *pLevelSetObjectInstance = (IBase*)(pBaseLevelSetObjectInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("LevelSetObjectInstance", *pLevelSetObjectInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + Lib3MFResult lib3mf_model_getbuilduuid(Lib3MF_Model pModel, bool * pHasUUID, const Lib3MF_uint32 nUUIDBufferSize, Lib3MF_uint32* pUUIDNeededChars, char * pUUIDBuffer) { IBase* pIBaseClass = (IBase *)pModel; @@ -10878,8 +22466,20 @@ Lib3MFResult lib3mf_model_getbuilduuid(Lib3MF_Model pModel, bool * pHasUUID, con if (!pIModel) throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); - sUUID = pIModel->GetBuildUUID(*pHasUUID); + bool isCacheCall = (pUUIDBuffer == nullptr); + if (isCacheCall) { + sUUID = pIModel->GetBuildUUID(*pHasUUID); + pIModel->_setCache (new ParameterCache_2 (*pHasUUID, sUUID)); + } + else { + auto cache = dynamic_cast*> (pIModel->_getCache ()); + if (cache == nullptr) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + cache->retrieveData (*pHasUUID, sUUID); + pIModel->_setCache (nullptr); + } + if (pUUIDNeededChars) *pUUIDNeededChars = (Lib3MF_uint32) (sUUID.size()+1); if (pUUIDBuffer) { @@ -11407,6 +23007,42 @@ Lib3MFResult lib3mf_model_getslicestacks(Lib3MF_Model pModel, Lib3MF_SliceStackI } } +Lib3MFResult lib3mf_model_getimage3ds(Lib3MF_Model pModel, Lib3MF_Image3DIterator * pResourceIterator) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "GetImage3Ds"); + } + if (pResourceIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResourceIterator(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResourceIterator = pIModel->GetImage3Ds(); + + *pResourceIterator = (IBase*)(pBaseResourceIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("ResourceIterator", *pResourceIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + Lib3MFResult lib3mf_model_mergetomodel(Lib3MF_Model pModel, Lib3MF_Model * pMergedModelInstance) { IBase* pIBaseClass = (IBase *)pModel; @@ -11443,6 +23079,43 @@ Lib3MFResult lib3mf_model_mergetomodel(Lib3MF_Model pModel, Lib3MF_Model * pMerg } } +Lib3MFResult lib3mf_model_mergefrommodel(Lib3MF_Model pModel, Lib3MF_Model pModelInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "MergeFromModel"); + pJournalEntry->addHandleParameter("ModelInstance", pModelInstance); + } + IBase* pIBaseClassModelInstance = (IBase *)pModelInstance; + IModel* pIModelInstance = dynamic_cast(pIBaseClassModelInstance); + if (!pIModelInstance) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIModel->MergeFromModel(pIModelInstance); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + Lib3MFResult lib3mf_model_addmeshobject(Lib3MF_Model pModel, Lib3MF_MeshObject * pMeshObjectInstance) { IBase* pIBaseClass = (IBase *)pModel; @@ -11786,6 +23459,82 @@ Lib3MFResult lib3mf_model_addmultipropertygroup(Lib3MF_Model pModel, Lib3MF_Mult } } +Lib3MFResult lib3mf_model_addimagestack(Lib3MF_Model pModel, Lib3MF_uint32 nColumnCount, Lib3MF_uint32 nRowCount, Lib3MF_uint32 nSheetCount, Lib3MF_ImageStack * pInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "AddImageStack"); + pJournalEntry->addUInt32Parameter("ColumnCount", nColumnCount); + pJournalEntry->addUInt32Parameter("RowCount", nRowCount); + pJournalEntry->addUInt32Parameter("SheetCount", nSheetCount); + } + if (pInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseInstance(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseInstance = pIModel->AddImageStack(nColumnCount, nRowCount, nSheetCount); + + *pInstance = (IBase*)(pBaseInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("Instance", *pInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_model_getimagestackbyid(Lib3MF_Model pModel, Lib3MF_uint32 nUniqueResourceID, Lib3MF_ImageStack * pImageStackInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "GetImageStackByID"); + pJournalEntry->addUInt32Parameter("UniqueResourceID", nUniqueResourceID); + } + if (pImageStackInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseImageStackInstance(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseImageStackInstance = pIModel->GetImageStackByID(nUniqueResourceID); + + *pImageStackInstance = (IBase*)(pBaseImageStackInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("ImageStackInstance", *pImageStackInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + Lib3MFResult lib3mf_model_addbuilditem(Lib3MF_Model pModel, Lib3MF_Object pObject, const sLib3MFTransform * pTransform, Lib3MF_BuildItem * pBuildItemInstance) { IBase* pIBaseClass = (IBase *)pModel; @@ -12372,377 +24121,273 @@ Lib3MFResult lib3mf_model_getkeystore(Lib3MF_Model pModel, Lib3MF_KeyStore * pKe } } +Lib3MFResult lib3mf_model_getfunctions(Lib3MF_Model pModel, Lib3MF_FunctionIterator * pTheResourceIterator) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "GetFunctions"); + } + if (pTheResourceIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseTheResourceIterator(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseTheResourceIterator = pIModel->GetFunctions(); + + *pTheResourceIterator = (IBase*)(pBaseTheResourceIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("TheResourceIterator", *pTheResourceIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_model_addimplicitfunction(Lib3MF_Model pModel, Lib3MF_ImplicitFunction * pFunctionInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "AddImplicitFunction"); + } + if (pFunctionInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseFunctionInstance(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseFunctionInstance = pIModel->AddImplicitFunction(); + + *pFunctionInstance = (IBase*)(pBaseFunctionInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("FunctionInstance", *pFunctionInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_model_addfunctionfromimage3d(Lib3MF_Model pModel, Lib3MF_Image3D pImage3DInstance, Lib3MF_FunctionFromImage3D * pFunctionInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "AddFunctionFromImage3D"); + pJournalEntry->addHandleParameter("Image3DInstance", pImage3DInstance); + } + if (pFunctionInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pIBaseClassImage3DInstance = (IBase *)pImage3DInstance; + IImage3D* pIImage3DInstance = dynamic_cast(pIBaseClassImage3DInstance); + if (!pIImage3DInstance) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IBase* pBaseFunctionInstance(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseFunctionInstance = pIModel->AddFunctionFromImage3D(pIImage3DInstance); + + *pFunctionInstance = (IBase*)(pBaseFunctionInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("FunctionInstance", *pFunctionInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_model_addvolumedata(Lib3MF_Model pModel, Lib3MF_VolumeData * pVolumeDataInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "AddVolumeData"); + } + if (pVolumeDataInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseVolumeDataInstance(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseVolumeDataInstance = pIModel->AddVolumeData(); + + *pVolumeDataInstance = (IBase*)(pBaseVolumeDataInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("VolumeDataInstance", *pVolumeDataInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_model_addlevelset(Lib3MF_Model pModel, Lib3MF_LevelSet * pLevelSetInstance) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "AddLevelSet"); + } + if (pLevelSetInstance == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseLevelSetInstance(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseLevelSetInstance = pIModel->AddLevelSet(); + + *pLevelSetInstance = (IBase*)(pBaseLevelSetInstance); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("LevelSetInstance", *pLevelSetInstance); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_model_getlevelsets(Lib3MF_Model pModel, Lib3MF_LevelSetIterator * pResourceIterator) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "GetLevelSets"); + } + if (pResourceIterator == nullptr) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); + IBase* pBaseResourceIterator(nullptr); + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pBaseResourceIterator = pIModel->GetLevelSets(); + + *pResourceIterator = (IBase*)(pBaseResourceIterator); + if (pJournalEntry.get() != nullptr) { + pJournalEntry->addHandleResult("ResourceIterator", *pResourceIterator); + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + +Lib3MFResult lib3mf_model_removeresource(Lib3MF_Model pModel, Lib3MF_Resource pResource) +{ + IBase* pIBaseClass = (IBase *)pModel; + + PLib3MFInterfaceJournalEntry pJournalEntry; + try { + if (m_GlobalJournal.get() != nullptr) { + pJournalEntry = m_GlobalJournal->beginClassMethod(pModel, "Model", "RemoveResource"); + pJournalEntry->addHandleParameter("Resource", pResource); + } + IBase* pIBaseClassResource = (IBase *)pResource; + IResource* pIResource = dynamic_cast(pIBaseClassResource); + if (!pIResource) + throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDCAST); + + IModel* pIModel = dynamic_cast(pIBaseClass); + if (!pIModel) + throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDCAST); + + pIModel->RemoveResource(pIResource); + + if (pJournalEntry.get() != nullptr) { + pJournalEntry->writeSuccess(); + } + return LIB3MF_SUCCESS; + } + catch (ELib3MFInterfaceException & Exception) { + return handleLib3MFException(pIBaseClass, Exception, pJournalEntry.get()); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException, pJournalEntry.get()); + } + catch (...) { + return handleUnhandledException(pIBaseClass, pJournalEntry.get()); + } +} + /************************************************************************************************************************* Function table lookup implementation **************************************************************************************************************************/ -Lib3MFResult _lib3mf_getprocaddress_internal(const char * pProcName, void ** ppProcAddress) +Lib3MFResult Lib3MF::Impl::Lib3MF_GetProcAddress (const char * pProcName, void ** ppProcAddress) { - static bool sbProcAddressMapHasBeenInitialized = false; - static std::map sProcAddressMap; - if (!sbProcAddressMapHasBeenInitialized) { - sProcAddressMap["lib3mf_writer_writetofile"] = (void*)&lib3mf_writer_writetofile; - sProcAddressMap["lib3mf_writer_getstreamsize"] = (void*)&lib3mf_writer_getstreamsize; - sProcAddressMap["lib3mf_writer_writetobuffer"] = (void*)&lib3mf_writer_writetobuffer; - sProcAddressMap["lib3mf_writer_writetocallback"] = (void*)&lib3mf_writer_writetocallback; - sProcAddressMap["lib3mf_writer_setprogresscallback"] = (void*)&lib3mf_writer_setprogresscallback; - sProcAddressMap["lib3mf_writer_getdecimalprecision"] = (void*)&lib3mf_writer_getdecimalprecision; - sProcAddressMap["lib3mf_writer_setdecimalprecision"] = (void*)&lib3mf_writer_setdecimalprecision; - sProcAddressMap["lib3mf_writer_setstrictmodeactive"] = (void*)&lib3mf_writer_setstrictmodeactive; - sProcAddressMap["lib3mf_writer_getstrictmodeactive"] = (void*)&lib3mf_writer_getstrictmodeactive; - sProcAddressMap["lib3mf_writer_getwarning"] = (void*)&lib3mf_writer_getwarning; - sProcAddressMap["lib3mf_writer_getwarningcount"] = (void*)&lib3mf_writer_getwarningcount; - sProcAddressMap["lib3mf_writer_addkeywrappingcallback"] = (void*)&lib3mf_writer_addkeywrappingcallback; - sProcAddressMap["lib3mf_writer_setcontentencryptioncallback"] = (void*)&lib3mf_writer_setcontentencryptioncallback; - sProcAddressMap["lib3mf_reader_readfromfile"] = (void*)&lib3mf_reader_readfromfile; - sProcAddressMap["lib3mf_reader_readfrombuffer"] = (void*)&lib3mf_reader_readfrombuffer; - sProcAddressMap["lib3mf_reader_readfromcallback"] = (void*)&lib3mf_reader_readfromcallback; - sProcAddressMap["lib3mf_reader_setprogresscallback"] = (void*)&lib3mf_reader_setprogresscallback; - sProcAddressMap["lib3mf_reader_addrelationtoread"] = (void*)&lib3mf_reader_addrelationtoread; - sProcAddressMap["lib3mf_reader_removerelationtoread"] = (void*)&lib3mf_reader_removerelationtoread; - sProcAddressMap["lib3mf_reader_setstrictmodeactive"] = (void*)&lib3mf_reader_setstrictmodeactive; - sProcAddressMap["lib3mf_reader_getstrictmodeactive"] = (void*)&lib3mf_reader_getstrictmodeactive; - sProcAddressMap["lib3mf_reader_getwarning"] = (void*)&lib3mf_reader_getwarning; - sProcAddressMap["lib3mf_reader_getwarningcount"] = (void*)&lib3mf_reader_getwarningcount; - sProcAddressMap["lib3mf_reader_addkeywrappingcallback"] = (void*)&lib3mf_reader_addkeywrappingcallback; - sProcAddressMap["lib3mf_reader_setcontentencryptioncallback"] = (void*)&lib3mf_reader_setcontentencryptioncallback; - sProcAddressMap["lib3mf_packagepart_getpath"] = (void*)&lib3mf_packagepart_getpath; - sProcAddressMap["lib3mf_packagepart_setpath"] = (void*)&lib3mf_packagepart_setpath; - sProcAddressMap["lib3mf_resource_getresourceid"] = (void*)&lib3mf_resource_getresourceid; - sProcAddressMap["lib3mf_resource_getuniqueresourceid"] = (void*)&lib3mf_resource_getuniqueresourceid; - sProcAddressMap["lib3mf_resource_packagepart"] = (void*)&lib3mf_resource_packagepart; - sProcAddressMap["lib3mf_resource_setpackagepart"] = (void*)&lib3mf_resource_setpackagepart; - sProcAddressMap["lib3mf_resource_getmodelresourceid"] = (void*)&lib3mf_resource_getmodelresourceid; - sProcAddressMap["lib3mf_resourceiterator_movenext"] = (void*)&lib3mf_resourceiterator_movenext; - sProcAddressMap["lib3mf_resourceiterator_moveprevious"] = (void*)&lib3mf_resourceiterator_moveprevious; - sProcAddressMap["lib3mf_resourceiterator_getcurrent"] = (void*)&lib3mf_resourceiterator_getcurrent; - sProcAddressMap["lib3mf_resourceiterator_clone"] = (void*)&lib3mf_resourceiterator_clone; - sProcAddressMap["lib3mf_resourceiterator_count"] = (void*)&lib3mf_resourceiterator_count; - sProcAddressMap["lib3mf_slicestackiterator_getcurrentslicestack"] = (void*)&lib3mf_slicestackiterator_getcurrentslicestack; - sProcAddressMap["lib3mf_objectiterator_getcurrentobject"] = (void*)&lib3mf_objectiterator_getcurrentobject; - sProcAddressMap["lib3mf_meshobjectiterator_getcurrentmeshobject"] = (void*)&lib3mf_meshobjectiterator_getcurrentmeshobject; - sProcAddressMap["lib3mf_componentsobjectiterator_getcurrentcomponentsobject"] = (void*)&lib3mf_componentsobjectiterator_getcurrentcomponentsobject; - sProcAddressMap["lib3mf_texture2diterator_getcurrenttexture2d"] = (void*)&lib3mf_texture2diterator_getcurrenttexture2d; - sProcAddressMap["lib3mf_basematerialgroupiterator_getcurrentbasematerialgroup"] = (void*)&lib3mf_basematerialgroupiterator_getcurrentbasematerialgroup; - sProcAddressMap["lib3mf_colorgroupiterator_getcurrentcolorgroup"] = (void*)&lib3mf_colorgroupiterator_getcurrentcolorgroup; - sProcAddressMap["lib3mf_texture2dgroupiterator_getcurrenttexture2dgroup"] = (void*)&lib3mf_texture2dgroupiterator_getcurrenttexture2dgroup; - sProcAddressMap["lib3mf_compositematerialsiterator_getcurrentcompositematerials"] = (void*)&lib3mf_compositematerialsiterator_getcurrentcompositematerials; - sProcAddressMap["lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup"] = (void*)&lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup; - sProcAddressMap["lib3mf_metadata_getnamespace"] = (void*)&lib3mf_metadata_getnamespace; - sProcAddressMap["lib3mf_metadata_setnamespace"] = (void*)&lib3mf_metadata_setnamespace; - sProcAddressMap["lib3mf_metadata_getname"] = (void*)&lib3mf_metadata_getname; - sProcAddressMap["lib3mf_metadata_setname"] = (void*)&lib3mf_metadata_setname; - sProcAddressMap["lib3mf_metadata_getkey"] = (void*)&lib3mf_metadata_getkey; - sProcAddressMap["lib3mf_metadata_getmustpreserve"] = (void*)&lib3mf_metadata_getmustpreserve; - sProcAddressMap["lib3mf_metadata_setmustpreserve"] = (void*)&lib3mf_metadata_setmustpreserve; - sProcAddressMap["lib3mf_metadata_gettype"] = (void*)&lib3mf_metadata_gettype; - sProcAddressMap["lib3mf_metadata_settype"] = (void*)&lib3mf_metadata_settype; - sProcAddressMap["lib3mf_metadata_getvalue"] = (void*)&lib3mf_metadata_getvalue; - sProcAddressMap["lib3mf_metadata_setvalue"] = (void*)&lib3mf_metadata_setvalue; - sProcAddressMap["lib3mf_metadatagroup_getmetadatacount"] = (void*)&lib3mf_metadatagroup_getmetadatacount; - sProcAddressMap["lib3mf_metadatagroup_getmetadata"] = (void*)&lib3mf_metadatagroup_getmetadata; - sProcAddressMap["lib3mf_metadatagroup_getmetadatabykey"] = (void*)&lib3mf_metadatagroup_getmetadatabykey; - sProcAddressMap["lib3mf_metadatagroup_removemetadatabyindex"] = (void*)&lib3mf_metadatagroup_removemetadatabyindex; - sProcAddressMap["lib3mf_metadatagroup_removemetadata"] = (void*)&lib3mf_metadatagroup_removemetadata; - sProcAddressMap["lib3mf_metadatagroup_addmetadata"] = (void*)&lib3mf_metadatagroup_addmetadata; - sProcAddressMap["lib3mf_object_gettype"] = (void*)&lib3mf_object_gettype; - sProcAddressMap["lib3mf_object_settype"] = (void*)&lib3mf_object_settype; - sProcAddressMap["lib3mf_object_getname"] = (void*)&lib3mf_object_getname; - sProcAddressMap["lib3mf_object_setname"] = (void*)&lib3mf_object_setname; - sProcAddressMap["lib3mf_object_getpartnumber"] = (void*)&lib3mf_object_getpartnumber; - sProcAddressMap["lib3mf_object_setpartnumber"] = (void*)&lib3mf_object_setpartnumber; - sProcAddressMap["lib3mf_object_ismeshobject"] = (void*)&lib3mf_object_ismeshobject; - sProcAddressMap["lib3mf_object_iscomponentsobject"] = (void*)&lib3mf_object_iscomponentsobject; - sProcAddressMap["lib3mf_object_isvalid"] = (void*)&lib3mf_object_isvalid; - sProcAddressMap["lib3mf_object_setattachmentasthumbnail"] = (void*)&lib3mf_object_setattachmentasthumbnail; - sProcAddressMap["lib3mf_object_getthumbnailattachment"] = (void*)&lib3mf_object_getthumbnailattachment; - sProcAddressMap["lib3mf_object_clearthumbnailattachment"] = (void*)&lib3mf_object_clearthumbnailattachment; - sProcAddressMap["lib3mf_object_getoutbox"] = (void*)&lib3mf_object_getoutbox; - sProcAddressMap["lib3mf_object_getuuid"] = (void*)&lib3mf_object_getuuid; - sProcAddressMap["lib3mf_object_setuuid"] = (void*)&lib3mf_object_setuuid; - sProcAddressMap["lib3mf_object_getmetadatagroup"] = (void*)&lib3mf_object_getmetadatagroup; - sProcAddressMap["lib3mf_object_setslicesmeshresolution"] = (void*)&lib3mf_object_setslicesmeshresolution; - sProcAddressMap["lib3mf_object_getslicesmeshresolution"] = (void*)&lib3mf_object_getslicesmeshresolution; - sProcAddressMap["lib3mf_object_hasslices"] = (void*)&lib3mf_object_hasslices; - sProcAddressMap["lib3mf_object_clearslicestack"] = (void*)&lib3mf_object_clearslicestack; - sProcAddressMap["lib3mf_object_getslicestack"] = (void*)&lib3mf_object_getslicestack; - sProcAddressMap["lib3mf_object_assignslicestack"] = (void*)&lib3mf_object_assignslicestack; - sProcAddressMap["lib3mf_meshobject_getvertexcount"] = (void*)&lib3mf_meshobject_getvertexcount; - sProcAddressMap["lib3mf_meshobject_gettrianglecount"] = (void*)&lib3mf_meshobject_gettrianglecount; - sProcAddressMap["lib3mf_meshobject_getvertex"] = (void*)&lib3mf_meshobject_getvertex; - sProcAddressMap["lib3mf_meshobject_setvertex"] = (void*)&lib3mf_meshobject_setvertex; - sProcAddressMap["lib3mf_meshobject_addvertex"] = (void*)&lib3mf_meshobject_addvertex; - sProcAddressMap["lib3mf_meshobject_getvertices"] = (void*)&lib3mf_meshobject_getvertices; - sProcAddressMap["lib3mf_meshobject_gettriangle"] = (void*)&lib3mf_meshobject_gettriangle; - sProcAddressMap["lib3mf_meshobject_settriangle"] = (void*)&lib3mf_meshobject_settriangle; - sProcAddressMap["lib3mf_meshobject_addtriangle"] = (void*)&lib3mf_meshobject_addtriangle; - sProcAddressMap["lib3mf_meshobject_gettriangleindices"] = (void*)&lib3mf_meshobject_gettriangleindices; - sProcAddressMap["lib3mf_meshobject_setobjectlevelproperty"] = (void*)&lib3mf_meshobject_setobjectlevelproperty; - sProcAddressMap["lib3mf_meshobject_getobjectlevelproperty"] = (void*)&lib3mf_meshobject_getobjectlevelproperty; - sProcAddressMap["lib3mf_meshobject_settriangleproperties"] = (void*)&lib3mf_meshobject_settriangleproperties; - sProcAddressMap["lib3mf_meshobject_gettriangleproperties"] = (void*)&lib3mf_meshobject_gettriangleproperties; - sProcAddressMap["lib3mf_meshobject_setalltriangleproperties"] = (void*)&lib3mf_meshobject_setalltriangleproperties; - sProcAddressMap["lib3mf_meshobject_getalltriangleproperties"] = (void*)&lib3mf_meshobject_getalltriangleproperties; - sProcAddressMap["lib3mf_meshobject_clearallproperties"] = (void*)&lib3mf_meshobject_clearallproperties; - sProcAddressMap["lib3mf_meshobject_setgeometry"] = (void*)&lib3mf_meshobject_setgeometry; - sProcAddressMap["lib3mf_meshobject_ismanifoldandoriented"] = (void*)&lib3mf_meshobject_ismanifoldandoriented; - sProcAddressMap["lib3mf_meshobject_beamlattice"] = (void*)&lib3mf_meshobject_beamlattice; - sProcAddressMap["lib3mf_beamlattice_getminlength"] = (void*)&lib3mf_beamlattice_getminlength; - sProcAddressMap["lib3mf_beamlattice_setminlength"] = (void*)&lib3mf_beamlattice_setminlength; - sProcAddressMap["lib3mf_beamlattice_getclipping"] = (void*)&lib3mf_beamlattice_getclipping; - sProcAddressMap["lib3mf_beamlattice_setclipping"] = (void*)&lib3mf_beamlattice_setclipping; - sProcAddressMap["lib3mf_beamlattice_getrepresentation"] = (void*)&lib3mf_beamlattice_getrepresentation; - sProcAddressMap["lib3mf_beamlattice_setrepresentation"] = (void*)&lib3mf_beamlattice_setrepresentation; - sProcAddressMap["lib3mf_beamlattice_getballoptions"] = (void*)&lib3mf_beamlattice_getballoptions; - sProcAddressMap["lib3mf_beamlattice_setballoptions"] = (void*)&lib3mf_beamlattice_setballoptions; - sProcAddressMap["lib3mf_beamlattice_getbeamcount"] = (void*)&lib3mf_beamlattice_getbeamcount; - sProcAddressMap["lib3mf_beamlattice_getbeam"] = (void*)&lib3mf_beamlattice_getbeam; - sProcAddressMap["lib3mf_beamlattice_addbeam"] = (void*)&lib3mf_beamlattice_addbeam; - sProcAddressMap["lib3mf_beamlattice_setbeam"] = (void*)&lib3mf_beamlattice_setbeam; - sProcAddressMap["lib3mf_beamlattice_setbeams"] = (void*)&lib3mf_beamlattice_setbeams; - sProcAddressMap["lib3mf_beamlattice_getbeams"] = (void*)&lib3mf_beamlattice_getbeams; - sProcAddressMap["lib3mf_beamlattice_getballcount"] = (void*)&lib3mf_beamlattice_getballcount; - sProcAddressMap["lib3mf_beamlattice_getball"] = (void*)&lib3mf_beamlattice_getball; - sProcAddressMap["lib3mf_beamlattice_addball"] = (void*)&lib3mf_beamlattice_addball; - sProcAddressMap["lib3mf_beamlattice_setball"] = (void*)&lib3mf_beamlattice_setball; - sProcAddressMap["lib3mf_beamlattice_setballs"] = (void*)&lib3mf_beamlattice_setballs; - sProcAddressMap["lib3mf_beamlattice_getballs"] = (void*)&lib3mf_beamlattice_getballs; - sProcAddressMap["lib3mf_beamlattice_getbeamsetcount"] = (void*)&lib3mf_beamlattice_getbeamsetcount; - sProcAddressMap["lib3mf_beamlattice_addbeamset"] = (void*)&lib3mf_beamlattice_addbeamset; - sProcAddressMap["lib3mf_beamlattice_getbeamset"] = (void*)&lib3mf_beamlattice_getbeamset; - sProcAddressMap["lib3mf_component_getobjectresource"] = (void*)&lib3mf_component_getobjectresource; - sProcAddressMap["lib3mf_component_getobjectresourceid"] = (void*)&lib3mf_component_getobjectresourceid; - sProcAddressMap["lib3mf_component_getuuid"] = (void*)&lib3mf_component_getuuid; - sProcAddressMap["lib3mf_component_setuuid"] = (void*)&lib3mf_component_setuuid; - sProcAddressMap["lib3mf_component_hastransform"] = (void*)&lib3mf_component_hastransform; - sProcAddressMap["lib3mf_component_gettransform"] = (void*)&lib3mf_component_gettransform; - sProcAddressMap["lib3mf_component_settransform"] = (void*)&lib3mf_component_settransform; - sProcAddressMap["lib3mf_componentsobject_addcomponent"] = (void*)&lib3mf_componentsobject_addcomponent; - sProcAddressMap["lib3mf_componentsobject_getcomponent"] = (void*)&lib3mf_componentsobject_getcomponent; - sProcAddressMap["lib3mf_componentsobject_getcomponentcount"] = (void*)&lib3mf_componentsobject_getcomponentcount; - sProcAddressMap["lib3mf_beamset_setname"] = (void*)&lib3mf_beamset_setname; - sProcAddressMap["lib3mf_beamset_getname"] = (void*)&lib3mf_beamset_getname; - sProcAddressMap["lib3mf_beamset_setidentifier"] = (void*)&lib3mf_beamset_setidentifier; - sProcAddressMap["lib3mf_beamset_getidentifier"] = (void*)&lib3mf_beamset_getidentifier; - sProcAddressMap["lib3mf_beamset_getreferencecount"] = (void*)&lib3mf_beamset_getreferencecount; - sProcAddressMap["lib3mf_beamset_setreferences"] = (void*)&lib3mf_beamset_setreferences; - sProcAddressMap["lib3mf_beamset_getreferences"] = (void*)&lib3mf_beamset_getreferences; - sProcAddressMap["lib3mf_beamset_getballreferencecount"] = (void*)&lib3mf_beamset_getballreferencecount; - sProcAddressMap["lib3mf_beamset_setballreferences"] = (void*)&lib3mf_beamset_setballreferences; - sProcAddressMap["lib3mf_beamset_getballreferences"] = (void*)&lib3mf_beamset_getballreferences; - sProcAddressMap["lib3mf_basematerialgroup_getcount"] = (void*)&lib3mf_basematerialgroup_getcount; - sProcAddressMap["lib3mf_basematerialgroup_getallpropertyids"] = (void*)&lib3mf_basematerialgroup_getallpropertyids; - sProcAddressMap["lib3mf_basematerialgroup_addmaterial"] = (void*)&lib3mf_basematerialgroup_addmaterial; - sProcAddressMap["lib3mf_basematerialgroup_removematerial"] = (void*)&lib3mf_basematerialgroup_removematerial; - sProcAddressMap["lib3mf_basematerialgroup_getname"] = (void*)&lib3mf_basematerialgroup_getname; - sProcAddressMap["lib3mf_basematerialgroup_setname"] = (void*)&lib3mf_basematerialgroup_setname; - sProcAddressMap["lib3mf_basematerialgroup_setdisplaycolor"] = (void*)&lib3mf_basematerialgroup_setdisplaycolor; - sProcAddressMap["lib3mf_basematerialgroup_getdisplaycolor"] = (void*)&lib3mf_basematerialgroup_getdisplaycolor; - sProcAddressMap["lib3mf_colorgroup_getcount"] = (void*)&lib3mf_colorgroup_getcount; - sProcAddressMap["lib3mf_colorgroup_getallpropertyids"] = (void*)&lib3mf_colorgroup_getallpropertyids; - sProcAddressMap["lib3mf_colorgroup_addcolor"] = (void*)&lib3mf_colorgroup_addcolor; - sProcAddressMap["lib3mf_colorgroup_removecolor"] = (void*)&lib3mf_colorgroup_removecolor; - sProcAddressMap["lib3mf_colorgroup_setcolor"] = (void*)&lib3mf_colorgroup_setcolor; - sProcAddressMap["lib3mf_colorgroup_getcolor"] = (void*)&lib3mf_colorgroup_getcolor; - sProcAddressMap["lib3mf_texture2dgroup_getcount"] = (void*)&lib3mf_texture2dgroup_getcount; - sProcAddressMap["lib3mf_texture2dgroup_getallpropertyids"] = (void*)&lib3mf_texture2dgroup_getallpropertyids; - sProcAddressMap["lib3mf_texture2dgroup_addtex2coord"] = (void*)&lib3mf_texture2dgroup_addtex2coord; - sProcAddressMap["lib3mf_texture2dgroup_gettex2coord"] = (void*)&lib3mf_texture2dgroup_gettex2coord; - sProcAddressMap["lib3mf_texture2dgroup_removetex2coord"] = (void*)&lib3mf_texture2dgroup_removetex2coord; - sProcAddressMap["lib3mf_texture2dgroup_gettexture2d"] = (void*)&lib3mf_texture2dgroup_gettexture2d; - sProcAddressMap["lib3mf_compositematerials_getcount"] = (void*)&lib3mf_compositematerials_getcount; - sProcAddressMap["lib3mf_compositematerials_getallpropertyids"] = (void*)&lib3mf_compositematerials_getallpropertyids; - sProcAddressMap["lib3mf_compositematerials_getbasematerialgroup"] = (void*)&lib3mf_compositematerials_getbasematerialgroup; - sProcAddressMap["lib3mf_compositematerials_addcomposite"] = (void*)&lib3mf_compositematerials_addcomposite; - sProcAddressMap["lib3mf_compositematerials_removecomposite"] = (void*)&lib3mf_compositematerials_removecomposite; - sProcAddressMap["lib3mf_compositematerials_getcomposite"] = (void*)&lib3mf_compositematerials_getcomposite; - sProcAddressMap["lib3mf_multipropertygroup_getcount"] = (void*)&lib3mf_multipropertygroup_getcount; - sProcAddressMap["lib3mf_multipropertygroup_getallpropertyids"] = (void*)&lib3mf_multipropertygroup_getallpropertyids; - sProcAddressMap["lib3mf_multipropertygroup_addmultiproperty"] = (void*)&lib3mf_multipropertygroup_addmultiproperty; - sProcAddressMap["lib3mf_multipropertygroup_setmultiproperty"] = (void*)&lib3mf_multipropertygroup_setmultiproperty; - sProcAddressMap["lib3mf_multipropertygroup_getmultiproperty"] = (void*)&lib3mf_multipropertygroup_getmultiproperty; - sProcAddressMap["lib3mf_multipropertygroup_removemultiproperty"] = (void*)&lib3mf_multipropertygroup_removemultiproperty; - sProcAddressMap["lib3mf_multipropertygroup_getlayercount"] = (void*)&lib3mf_multipropertygroup_getlayercount; - sProcAddressMap["lib3mf_multipropertygroup_addlayer"] = (void*)&lib3mf_multipropertygroup_addlayer; - sProcAddressMap["lib3mf_multipropertygroup_getlayer"] = (void*)&lib3mf_multipropertygroup_getlayer; - sProcAddressMap["lib3mf_multipropertygroup_removelayer"] = (void*)&lib3mf_multipropertygroup_removelayer; - sProcAddressMap["lib3mf_attachment_getpath"] = (void*)&lib3mf_attachment_getpath; - sProcAddressMap["lib3mf_attachment_setpath"] = (void*)&lib3mf_attachment_setpath; - sProcAddressMap["lib3mf_attachment_packagepart"] = (void*)&lib3mf_attachment_packagepart; - sProcAddressMap["lib3mf_attachment_getrelationshiptype"] = (void*)&lib3mf_attachment_getrelationshiptype; - sProcAddressMap["lib3mf_attachment_setrelationshiptype"] = (void*)&lib3mf_attachment_setrelationshiptype; - sProcAddressMap["lib3mf_attachment_writetofile"] = (void*)&lib3mf_attachment_writetofile; - sProcAddressMap["lib3mf_attachment_readfromfile"] = (void*)&lib3mf_attachment_readfromfile; - sProcAddressMap["lib3mf_attachment_readfromcallback"] = (void*)&lib3mf_attachment_readfromcallback; - sProcAddressMap["lib3mf_attachment_getstreamsize"] = (void*)&lib3mf_attachment_getstreamsize; - sProcAddressMap["lib3mf_attachment_writetobuffer"] = (void*)&lib3mf_attachment_writetobuffer; - sProcAddressMap["lib3mf_attachment_readfrombuffer"] = (void*)&lib3mf_attachment_readfrombuffer; - sProcAddressMap["lib3mf_texture2d_getattachment"] = (void*)&lib3mf_texture2d_getattachment; - sProcAddressMap["lib3mf_texture2d_setattachment"] = (void*)&lib3mf_texture2d_setattachment; - sProcAddressMap["lib3mf_texture2d_getcontenttype"] = (void*)&lib3mf_texture2d_getcontenttype; - sProcAddressMap["lib3mf_texture2d_setcontenttype"] = (void*)&lib3mf_texture2d_setcontenttype; - sProcAddressMap["lib3mf_texture2d_gettilestyleuv"] = (void*)&lib3mf_texture2d_gettilestyleuv; - sProcAddressMap["lib3mf_texture2d_settilestyleuv"] = (void*)&lib3mf_texture2d_settilestyleuv; - sProcAddressMap["lib3mf_texture2d_getfilter"] = (void*)&lib3mf_texture2d_getfilter; - sProcAddressMap["lib3mf_texture2d_setfilter"] = (void*)&lib3mf_texture2d_setfilter; - sProcAddressMap["lib3mf_builditem_getobjectresource"] = (void*)&lib3mf_builditem_getobjectresource; - sProcAddressMap["lib3mf_builditem_getuuid"] = (void*)&lib3mf_builditem_getuuid; - sProcAddressMap["lib3mf_builditem_setuuid"] = (void*)&lib3mf_builditem_setuuid; - sProcAddressMap["lib3mf_builditem_getobjectresourceid"] = (void*)&lib3mf_builditem_getobjectresourceid; - sProcAddressMap["lib3mf_builditem_hasobjecttransform"] = (void*)&lib3mf_builditem_hasobjecttransform; - sProcAddressMap["lib3mf_builditem_getobjecttransform"] = (void*)&lib3mf_builditem_getobjecttransform; - sProcAddressMap["lib3mf_builditem_setobjecttransform"] = (void*)&lib3mf_builditem_setobjecttransform; - sProcAddressMap["lib3mf_builditem_getpartnumber"] = (void*)&lib3mf_builditem_getpartnumber; - sProcAddressMap["lib3mf_builditem_setpartnumber"] = (void*)&lib3mf_builditem_setpartnumber; - sProcAddressMap["lib3mf_builditem_getmetadatagroup"] = (void*)&lib3mf_builditem_getmetadatagroup; - sProcAddressMap["lib3mf_builditem_getoutbox"] = (void*)&lib3mf_builditem_getoutbox; - sProcAddressMap["lib3mf_builditemiterator_movenext"] = (void*)&lib3mf_builditemiterator_movenext; - sProcAddressMap["lib3mf_builditemiterator_moveprevious"] = (void*)&lib3mf_builditemiterator_moveprevious; - sProcAddressMap["lib3mf_builditemiterator_getcurrent"] = (void*)&lib3mf_builditemiterator_getcurrent; - sProcAddressMap["lib3mf_builditemiterator_clone"] = (void*)&lib3mf_builditemiterator_clone; - sProcAddressMap["lib3mf_builditemiterator_count"] = (void*)&lib3mf_builditemiterator_count; - sProcAddressMap["lib3mf_slice_setvertices"] = (void*)&lib3mf_slice_setvertices; - sProcAddressMap["lib3mf_slice_getvertices"] = (void*)&lib3mf_slice_getvertices; - sProcAddressMap["lib3mf_slice_getvertexcount"] = (void*)&lib3mf_slice_getvertexcount; - sProcAddressMap["lib3mf_slice_addpolygon"] = (void*)&lib3mf_slice_addpolygon; - sProcAddressMap["lib3mf_slice_getpolygoncount"] = (void*)&lib3mf_slice_getpolygoncount; - sProcAddressMap["lib3mf_slice_setpolygonindices"] = (void*)&lib3mf_slice_setpolygonindices; - sProcAddressMap["lib3mf_slice_getpolygonindices"] = (void*)&lib3mf_slice_getpolygonindices; - sProcAddressMap["lib3mf_slice_getpolygonindexcount"] = (void*)&lib3mf_slice_getpolygonindexcount; - sProcAddressMap["lib3mf_slice_getztop"] = (void*)&lib3mf_slice_getztop; - sProcAddressMap["lib3mf_slicestack_getbottomz"] = (void*)&lib3mf_slicestack_getbottomz; - sProcAddressMap["lib3mf_slicestack_getslicecount"] = (void*)&lib3mf_slicestack_getslicecount; - sProcAddressMap["lib3mf_slicestack_getslice"] = (void*)&lib3mf_slicestack_getslice; - sProcAddressMap["lib3mf_slicestack_addslice"] = (void*)&lib3mf_slicestack_addslice; - sProcAddressMap["lib3mf_slicestack_getslicerefcount"] = (void*)&lib3mf_slicestack_getslicerefcount; - sProcAddressMap["lib3mf_slicestack_addslicestackreference"] = (void*)&lib3mf_slicestack_addslicestackreference; - sProcAddressMap["lib3mf_slicestack_getslicestackreference"] = (void*)&lib3mf_slicestack_getslicestackreference; - sProcAddressMap["lib3mf_slicestack_collapseslicereferences"] = (void*)&lib3mf_slicestack_collapseslicereferences; - sProcAddressMap["lib3mf_slicestack_setownpath"] = (void*)&lib3mf_slicestack_setownpath; - sProcAddressMap["lib3mf_slicestack_getownpath"] = (void*)&lib3mf_slicestack_getownpath; - sProcAddressMap["lib3mf_consumer_getconsumerid"] = (void*)&lib3mf_consumer_getconsumerid; - sProcAddressMap["lib3mf_consumer_getkeyid"] = (void*)&lib3mf_consumer_getkeyid; - sProcAddressMap["lib3mf_consumer_getkeyvalue"] = (void*)&lib3mf_consumer_getkeyvalue; - sProcAddressMap["lib3mf_accessright_getconsumer"] = (void*)&lib3mf_accessright_getconsumer; - sProcAddressMap["lib3mf_accessright_getwrappingalgorithm"] = (void*)&lib3mf_accessright_getwrappingalgorithm; - sProcAddressMap["lib3mf_accessright_getmgfalgorithm"] = (void*)&lib3mf_accessright_getmgfalgorithm; - sProcAddressMap["lib3mf_accessright_getdigestmethod"] = (void*)&lib3mf_accessright_getdigestmethod; - sProcAddressMap["lib3mf_contentencryptionparams_getencryptionalgorithm"] = (void*)&lib3mf_contentencryptionparams_getencryptionalgorithm; - sProcAddressMap["lib3mf_contentencryptionparams_getkey"] = (void*)&lib3mf_contentencryptionparams_getkey; - sProcAddressMap["lib3mf_contentencryptionparams_getinitializationvector"] = (void*)&lib3mf_contentencryptionparams_getinitializationvector; - sProcAddressMap["lib3mf_contentencryptionparams_getauthenticationtag"] = (void*)&lib3mf_contentencryptionparams_getauthenticationtag; - sProcAddressMap["lib3mf_contentencryptionparams_setauthenticationtag"] = (void*)&lib3mf_contentencryptionparams_setauthenticationtag; - sProcAddressMap["lib3mf_contentencryptionparams_getadditionalauthenticationdata"] = (void*)&lib3mf_contentencryptionparams_getadditionalauthenticationdata; - sProcAddressMap["lib3mf_contentencryptionparams_getdescriptor"] = (void*)&lib3mf_contentencryptionparams_getdescriptor; - sProcAddressMap["lib3mf_contentencryptionparams_getkeyuuid"] = (void*)&lib3mf_contentencryptionparams_getkeyuuid; - sProcAddressMap["lib3mf_resourcedata_getpath"] = (void*)&lib3mf_resourcedata_getpath; - sProcAddressMap["lib3mf_resourcedata_getencryptionalgorithm"] = (void*)&lib3mf_resourcedata_getencryptionalgorithm; - sProcAddressMap["lib3mf_resourcedata_getcompression"] = (void*)&lib3mf_resourcedata_getcompression; - sProcAddressMap["lib3mf_resourcedata_getadditionalauthenticationdata"] = (void*)&lib3mf_resourcedata_getadditionalauthenticationdata; - sProcAddressMap["lib3mf_resourcedatagroup_getkeyuuid"] = (void*)&lib3mf_resourcedatagroup_getkeyuuid; - sProcAddressMap["lib3mf_resourcedatagroup_addaccessright"] = (void*)&lib3mf_resourcedatagroup_addaccessright; - sProcAddressMap["lib3mf_resourcedatagroup_findaccessrightbyconsumer"] = (void*)&lib3mf_resourcedatagroup_findaccessrightbyconsumer; - sProcAddressMap["lib3mf_resourcedatagroup_removeaccessright"] = (void*)&lib3mf_resourcedatagroup_removeaccessright; - sProcAddressMap["lib3mf_keystore_addconsumer"] = (void*)&lib3mf_keystore_addconsumer; - sProcAddressMap["lib3mf_keystore_getconsumercount"] = (void*)&lib3mf_keystore_getconsumercount; - sProcAddressMap["lib3mf_keystore_getconsumer"] = (void*)&lib3mf_keystore_getconsumer; - sProcAddressMap["lib3mf_keystore_removeconsumer"] = (void*)&lib3mf_keystore_removeconsumer; - sProcAddressMap["lib3mf_keystore_findconsumer"] = (void*)&lib3mf_keystore_findconsumer; - sProcAddressMap["lib3mf_keystore_getresourcedatagroupcount"] = (void*)&lib3mf_keystore_getresourcedatagroupcount; - sProcAddressMap["lib3mf_keystore_addresourcedatagroup"] = (void*)&lib3mf_keystore_addresourcedatagroup; - sProcAddressMap["lib3mf_keystore_getresourcedatagroup"] = (void*)&lib3mf_keystore_getresourcedatagroup; - sProcAddressMap["lib3mf_keystore_removeresourcedatagroup"] = (void*)&lib3mf_keystore_removeresourcedatagroup; - sProcAddressMap["lib3mf_keystore_findresourcedatagroup"] = (void*)&lib3mf_keystore_findresourcedatagroup; - sProcAddressMap["lib3mf_keystore_addresourcedata"] = (void*)&lib3mf_keystore_addresourcedata; - sProcAddressMap["lib3mf_keystore_removeresourcedata"] = (void*)&lib3mf_keystore_removeresourcedata; - sProcAddressMap["lib3mf_keystore_findresourcedata"] = (void*)&lib3mf_keystore_findresourcedata; - sProcAddressMap["lib3mf_keystore_getresourcedatacount"] = (void*)&lib3mf_keystore_getresourcedatacount; - sProcAddressMap["lib3mf_keystore_getresourcedata"] = (void*)&lib3mf_keystore_getresourcedata; - sProcAddressMap["lib3mf_keystore_getuuid"] = (void*)&lib3mf_keystore_getuuid; - sProcAddressMap["lib3mf_keystore_setuuid"] = (void*)&lib3mf_keystore_setuuid; - sProcAddressMap["lib3mf_model_rootmodelpart"] = (void*)&lib3mf_model_rootmodelpart; - sProcAddressMap["lib3mf_model_findorcreatepackagepart"] = (void*)&lib3mf_model_findorcreatepackagepart; - sProcAddressMap["lib3mf_model_setunit"] = (void*)&lib3mf_model_setunit; - sProcAddressMap["lib3mf_model_getunit"] = (void*)&lib3mf_model_getunit; - sProcAddressMap["lib3mf_model_getlanguage"] = (void*)&lib3mf_model_getlanguage; - sProcAddressMap["lib3mf_model_setlanguage"] = (void*)&lib3mf_model_setlanguage; - sProcAddressMap["lib3mf_model_querywriter"] = (void*)&lib3mf_model_querywriter; - sProcAddressMap["lib3mf_model_queryreader"] = (void*)&lib3mf_model_queryreader; - sProcAddressMap["lib3mf_model_gettexture2dbyid"] = (void*)&lib3mf_model_gettexture2dbyid; - sProcAddressMap["lib3mf_model_getpropertytypebyid"] = (void*)&lib3mf_model_getpropertytypebyid; - sProcAddressMap["lib3mf_model_getbasematerialgroupbyid"] = (void*)&lib3mf_model_getbasematerialgroupbyid; - sProcAddressMap["lib3mf_model_gettexture2dgroupbyid"] = (void*)&lib3mf_model_gettexture2dgroupbyid; - sProcAddressMap["lib3mf_model_getcompositematerialsbyid"] = (void*)&lib3mf_model_getcompositematerialsbyid; - sProcAddressMap["lib3mf_model_getmultipropertygroupbyid"] = (void*)&lib3mf_model_getmultipropertygroupbyid; - sProcAddressMap["lib3mf_model_getmeshobjectbyid"] = (void*)&lib3mf_model_getmeshobjectbyid; - sProcAddressMap["lib3mf_model_getcomponentsobjectbyid"] = (void*)&lib3mf_model_getcomponentsobjectbyid; - sProcAddressMap["lib3mf_model_getcolorgroupbyid"] = (void*)&lib3mf_model_getcolorgroupbyid; - sProcAddressMap["lib3mf_model_getslicestackbyid"] = (void*)&lib3mf_model_getslicestackbyid; - sProcAddressMap["lib3mf_model_getbuilduuid"] = (void*)&lib3mf_model_getbuilduuid; - sProcAddressMap["lib3mf_model_setbuilduuid"] = (void*)&lib3mf_model_setbuilduuid; - sProcAddressMap["lib3mf_model_getbuilditems"] = (void*)&lib3mf_model_getbuilditems; - sProcAddressMap["lib3mf_model_getoutbox"] = (void*)&lib3mf_model_getoutbox; - sProcAddressMap["lib3mf_model_getresources"] = (void*)&lib3mf_model_getresources; - sProcAddressMap["lib3mf_model_getobjects"] = (void*)&lib3mf_model_getobjects; - sProcAddressMap["lib3mf_model_getmeshobjects"] = (void*)&lib3mf_model_getmeshobjects; - sProcAddressMap["lib3mf_model_getcomponentsobjects"] = (void*)&lib3mf_model_getcomponentsobjects; - sProcAddressMap["lib3mf_model_gettexture2ds"] = (void*)&lib3mf_model_gettexture2ds; - sProcAddressMap["lib3mf_model_getbasematerialgroups"] = (void*)&lib3mf_model_getbasematerialgroups; - sProcAddressMap["lib3mf_model_getcolorgroups"] = (void*)&lib3mf_model_getcolorgroups; - sProcAddressMap["lib3mf_model_gettexture2dgroups"] = (void*)&lib3mf_model_gettexture2dgroups; - sProcAddressMap["lib3mf_model_getcompositematerials"] = (void*)&lib3mf_model_getcompositematerials; - sProcAddressMap["lib3mf_model_getmultipropertygroups"] = (void*)&lib3mf_model_getmultipropertygroups; - sProcAddressMap["lib3mf_model_getslicestacks"] = (void*)&lib3mf_model_getslicestacks; - sProcAddressMap["lib3mf_model_mergetomodel"] = (void*)&lib3mf_model_mergetomodel; - sProcAddressMap["lib3mf_model_addmeshobject"] = (void*)&lib3mf_model_addmeshobject; - sProcAddressMap["lib3mf_model_addcomponentsobject"] = (void*)&lib3mf_model_addcomponentsobject; - sProcAddressMap["lib3mf_model_addslicestack"] = (void*)&lib3mf_model_addslicestack; - sProcAddressMap["lib3mf_model_addtexture2dfromattachment"] = (void*)&lib3mf_model_addtexture2dfromattachment; - sProcAddressMap["lib3mf_model_addbasematerialgroup"] = (void*)&lib3mf_model_addbasematerialgroup; - sProcAddressMap["lib3mf_model_addcolorgroup"] = (void*)&lib3mf_model_addcolorgroup; - sProcAddressMap["lib3mf_model_addtexture2dgroup"] = (void*)&lib3mf_model_addtexture2dgroup; - sProcAddressMap["lib3mf_model_addcompositematerials"] = (void*)&lib3mf_model_addcompositematerials; - sProcAddressMap["lib3mf_model_addmultipropertygroup"] = (void*)&lib3mf_model_addmultipropertygroup; - sProcAddressMap["lib3mf_model_addbuilditem"] = (void*)&lib3mf_model_addbuilditem; - sProcAddressMap["lib3mf_model_removebuilditem"] = (void*)&lib3mf_model_removebuilditem; - sProcAddressMap["lib3mf_model_getmetadatagroup"] = (void*)&lib3mf_model_getmetadatagroup; - sProcAddressMap["lib3mf_model_addattachment"] = (void*)&lib3mf_model_addattachment; - sProcAddressMap["lib3mf_model_removeattachment"] = (void*)&lib3mf_model_removeattachment; - sProcAddressMap["lib3mf_model_getattachment"] = (void*)&lib3mf_model_getattachment; - sProcAddressMap["lib3mf_model_findattachment"] = (void*)&lib3mf_model_findattachment; - sProcAddressMap["lib3mf_model_getattachmentcount"] = (void*)&lib3mf_model_getattachmentcount; - sProcAddressMap["lib3mf_model_haspackagethumbnailattachment"] = (void*)&lib3mf_model_haspackagethumbnailattachment; - sProcAddressMap["lib3mf_model_createpackagethumbnailattachment"] = (void*)&lib3mf_model_createpackagethumbnailattachment; - sProcAddressMap["lib3mf_model_getpackagethumbnailattachment"] = (void*)&lib3mf_model_getpackagethumbnailattachment; - sProcAddressMap["lib3mf_model_removepackagethumbnailattachment"] = (void*)&lib3mf_model_removepackagethumbnailattachment; - sProcAddressMap["lib3mf_model_addcustomcontenttype"] = (void*)&lib3mf_model_addcustomcontenttype; - sProcAddressMap["lib3mf_model_removecustomcontenttype"] = (void*)&lib3mf_model_removecustomcontenttype; - sProcAddressMap["lib3mf_model_setrandomnumbercallback"] = (void*)&lib3mf_model_setrandomnumbercallback; - sProcAddressMap["lib3mf_model_getkeystore"] = (void*)&lib3mf_model_getkeystore; - sProcAddressMap["lib3mf_getlibraryversion"] = (void*)&lib3mf_getlibraryversion; - sProcAddressMap["lib3mf_getprereleaseinformation"] = (void*)&lib3mf_getprereleaseinformation; - sProcAddressMap["lib3mf_getbuildinformation"] = (void*)&lib3mf_getbuildinformation; - sProcAddressMap["lib3mf_getspecificationversion"] = (void*)&lib3mf_getspecificationversion; - sProcAddressMap["lib3mf_createmodel"] = (void*)&lib3mf_createmodel; - sProcAddressMap["lib3mf_release"] = (void*)&lib3mf_release; - sProcAddressMap["lib3mf_acquire"] = (void*)&lib3mf_acquire; - sProcAddressMap["lib3mf_setjournal"] = (void*)&lib3mf_setjournal; - sProcAddressMap["lib3mf_getlasterror"] = (void*)&lib3mf_getlasterror; - sProcAddressMap["lib3mf_getsymbollookupmethod"] = (void*)&lib3mf_getsymbollookupmethod; - sProcAddressMap["lib3mf_retrieveprogressmessage"] = (void*)&lib3mf_retrieveprogressmessage; - sProcAddressMap["lib3mf_rgbatocolor"] = (void*)&lib3mf_rgbatocolor; - sProcAddressMap["lib3mf_floatrgbatocolor"] = (void*)&lib3mf_floatrgbatocolor; - sProcAddressMap["lib3mf_colortorgba"] = (void*)&lib3mf_colortorgba; - sProcAddressMap["lib3mf_colortofloatrgba"] = (void*)&lib3mf_colortofloatrgba; - sProcAddressMap["lib3mf_getidentitytransform"] = (void*)&lib3mf_getidentitytransform; - sProcAddressMap["lib3mf_getuniformscaletransform"] = (void*)&lib3mf_getuniformscaletransform; - sProcAddressMap["lib3mf_getscaletransform"] = (void*)&lib3mf_getscaletransform; - sProcAddressMap["lib3mf_gettranslationtransform"] = (void*)&lib3mf_gettranslationtransform; - - sbProcAddressMapHasBeenInitialized = true; - } if (pProcName == nullptr) return LIB3MF_ERROR_INVALIDPARAM; if (ppProcAddress == nullptr) @@ -12750,15 +24395,1302 @@ Lib3MFResult _lib3mf_getprocaddress_internal(const char * pProcName, void ** ppP *ppProcAddress = nullptr; std::string sProcName (pProcName); - auto procPair = sProcAddressMap.find(sProcName); - if (procPair == sProcAddressMap.end()) { - return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; - } - else { - *ppProcAddress = procPair->second; - return LIB3MF_SUCCESS; - } + if (sProcName == "lib3mf_base_classtypeid") + *ppProcAddress = (void*) &lib3mf_base_classtypeid; + if (sProcName == "lib3mf_writer_writetofile") + *ppProcAddress = (void*) &lib3mf_writer_writetofile; + if (sProcName == "lib3mf_writer_getstreamsize") + *ppProcAddress = (void*) &lib3mf_writer_getstreamsize; + if (sProcName == "lib3mf_writer_writetobuffer") + *ppProcAddress = (void*) &lib3mf_writer_writetobuffer; + if (sProcName == "lib3mf_writer_writetocallback") + *ppProcAddress = (void*) &lib3mf_writer_writetocallback; + if (sProcName == "lib3mf_writer_setprogresscallback") + *ppProcAddress = (void*) &lib3mf_writer_setprogresscallback; + if (sProcName == "lib3mf_writer_getdecimalprecision") + *ppProcAddress = (void*) &lib3mf_writer_getdecimalprecision; + if (sProcName == "lib3mf_writer_setdecimalprecision") + *ppProcAddress = (void*) &lib3mf_writer_setdecimalprecision; + if (sProcName == "lib3mf_writer_setstrictmodeactive") + *ppProcAddress = (void*) &lib3mf_writer_setstrictmodeactive; + if (sProcName == "lib3mf_writer_getstrictmodeactive") + *ppProcAddress = (void*) &lib3mf_writer_getstrictmodeactive; + if (sProcName == "lib3mf_writer_getwarning") + *ppProcAddress = (void*) &lib3mf_writer_getwarning; + if (sProcName == "lib3mf_writer_getwarningcount") + *ppProcAddress = (void*) &lib3mf_writer_getwarningcount; + if (sProcName == "lib3mf_writer_addkeywrappingcallback") + *ppProcAddress = (void*) &lib3mf_writer_addkeywrappingcallback; + if (sProcName == "lib3mf_writer_setcontentencryptioncallback") + *ppProcAddress = (void*) &lib3mf_writer_setcontentencryptioncallback; + if (sProcName == "lib3mf_reader_readfromfile") + *ppProcAddress = (void*) &lib3mf_reader_readfromfile; + if (sProcName == "lib3mf_reader_readfrombuffer") + *ppProcAddress = (void*) &lib3mf_reader_readfrombuffer; + if (sProcName == "lib3mf_reader_readfromcallback") + *ppProcAddress = (void*) &lib3mf_reader_readfromcallback; + if (sProcName == "lib3mf_reader_setprogresscallback") + *ppProcAddress = (void*) &lib3mf_reader_setprogresscallback; + if (sProcName == "lib3mf_reader_addrelationtoread") + *ppProcAddress = (void*) &lib3mf_reader_addrelationtoread; + if (sProcName == "lib3mf_reader_removerelationtoread") + *ppProcAddress = (void*) &lib3mf_reader_removerelationtoread; + if (sProcName == "lib3mf_reader_setstrictmodeactive") + *ppProcAddress = (void*) &lib3mf_reader_setstrictmodeactive; + if (sProcName == "lib3mf_reader_getstrictmodeactive") + *ppProcAddress = (void*) &lib3mf_reader_getstrictmodeactive; + if (sProcName == "lib3mf_reader_getwarning") + *ppProcAddress = (void*) &lib3mf_reader_getwarning; + if (sProcName == "lib3mf_reader_getwarningcount") + *ppProcAddress = (void*) &lib3mf_reader_getwarningcount; + if (sProcName == "lib3mf_reader_addkeywrappingcallback") + *ppProcAddress = (void*) &lib3mf_reader_addkeywrappingcallback; + if (sProcName == "lib3mf_reader_setcontentencryptioncallback") + *ppProcAddress = (void*) &lib3mf_reader_setcontentencryptioncallback; + if (sProcName == "lib3mf_packagepart_getpath") + *ppProcAddress = (void*) &lib3mf_packagepart_getpath; + if (sProcName == "lib3mf_packagepart_setpath") + *ppProcAddress = (void*) &lib3mf_packagepart_setpath; + if (sProcName == "lib3mf_resource_getresourceid") + *ppProcAddress = (void*) &lib3mf_resource_getresourceid; + if (sProcName == "lib3mf_resource_getuniqueresourceid") + *ppProcAddress = (void*) &lib3mf_resource_getuniqueresourceid; + if (sProcName == "lib3mf_resource_packagepart") + *ppProcAddress = (void*) &lib3mf_resource_packagepart; + if (sProcName == "lib3mf_resource_setpackagepart") + *ppProcAddress = (void*) &lib3mf_resource_setpackagepart; + if (sProcName == "lib3mf_resource_getmodelresourceid") + *ppProcAddress = (void*) &lib3mf_resource_getmodelresourceid; + if (sProcName == "lib3mf_resourceiterator_movenext") + *ppProcAddress = (void*) &lib3mf_resourceiterator_movenext; + if (sProcName == "lib3mf_resourceiterator_moveprevious") + *ppProcAddress = (void*) &lib3mf_resourceiterator_moveprevious; + if (sProcName == "lib3mf_resourceiterator_getcurrent") + *ppProcAddress = (void*) &lib3mf_resourceiterator_getcurrent; + if (sProcName == "lib3mf_resourceiterator_clone") + *ppProcAddress = (void*) &lib3mf_resourceiterator_clone; + if (sProcName == "lib3mf_resourceiterator_count") + *ppProcAddress = (void*) &lib3mf_resourceiterator_count; + if (sProcName == "lib3mf_slicestackiterator_getcurrentslicestack") + *ppProcAddress = (void*) &lib3mf_slicestackiterator_getcurrentslicestack; + if (sProcName == "lib3mf_objectiterator_getcurrentobject") + *ppProcAddress = (void*) &lib3mf_objectiterator_getcurrentobject; + if (sProcName == "lib3mf_meshobjectiterator_getcurrentmeshobject") + *ppProcAddress = (void*) &lib3mf_meshobjectiterator_getcurrentmeshobject; + if (sProcName == "lib3mf_componentsobjectiterator_getcurrentcomponentsobject") + *ppProcAddress = (void*) &lib3mf_componentsobjectiterator_getcurrentcomponentsobject; + if (sProcName == "lib3mf_texture2diterator_getcurrenttexture2d") + *ppProcAddress = (void*) &lib3mf_texture2diterator_getcurrenttexture2d; + if (sProcName == "lib3mf_basematerialgroupiterator_getcurrentbasematerialgroup") + *ppProcAddress = (void*) &lib3mf_basematerialgroupiterator_getcurrentbasematerialgroup; + if (sProcName == "lib3mf_colorgroupiterator_getcurrentcolorgroup") + *ppProcAddress = (void*) &lib3mf_colorgroupiterator_getcurrentcolorgroup; + if (sProcName == "lib3mf_texture2dgroupiterator_getcurrenttexture2dgroup") + *ppProcAddress = (void*) &lib3mf_texture2dgroupiterator_getcurrenttexture2dgroup; + if (sProcName == "lib3mf_compositematerialsiterator_getcurrentcompositematerials") + *ppProcAddress = (void*) &lib3mf_compositematerialsiterator_getcurrentcompositematerials; + if (sProcName == "lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup") + *ppProcAddress = (void*) &lib3mf_multipropertygroupiterator_getcurrentmultipropertygroup; + if (sProcName == "lib3mf_image3diterator_getcurrentimage3d") + *ppProcAddress = (void*) &lib3mf_image3diterator_getcurrentimage3d; + if (sProcName == "lib3mf_functioniterator_getcurrentfunction") + *ppProcAddress = (void*) &lib3mf_functioniterator_getcurrentfunction; + if (sProcName == "lib3mf_levelsetiterator_getcurrentlevelset") + *ppProcAddress = (void*) &lib3mf_levelsetiterator_getcurrentlevelset; + if (sProcName == "lib3mf_metadata_getnamespace") + *ppProcAddress = (void*) &lib3mf_metadata_getnamespace; + if (sProcName == "lib3mf_metadata_setnamespace") + *ppProcAddress = (void*) &lib3mf_metadata_setnamespace; + if (sProcName == "lib3mf_metadata_getname") + *ppProcAddress = (void*) &lib3mf_metadata_getname; + if (sProcName == "lib3mf_metadata_setname") + *ppProcAddress = (void*) &lib3mf_metadata_setname; + if (sProcName == "lib3mf_metadata_getkey") + *ppProcAddress = (void*) &lib3mf_metadata_getkey; + if (sProcName == "lib3mf_metadata_getmustpreserve") + *ppProcAddress = (void*) &lib3mf_metadata_getmustpreserve; + if (sProcName == "lib3mf_metadata_setmustpreserve") + *ppProcAddress = (void*) &lib3mf_metadata_setmustpreserve; + if (sProcName == "lib3mf_metadata_gettype") + *ppProcAddress = (void*) &lib3mf_metadata_gettype; + if (sProcName == "lib3mf_metadata_settype") + *ppProcAddress = (void*) &lib3mf_metadata_settype; + if (sProcName == "lib3mf_metadata_getvalue") + *ppProcAddress = (void*) &lib3mf_metadata_getvalue; + if (sProcName == "lib3mf_metadata_setvalue") + *ppProcAddress = (void*) &lib3mf_metadata_setvalue; + if (sProcName == "lib3mf_metadatagroup_getmetadatacount") + *ppProcAddress = (void*) &lib3mf_metadatagroup_getmetadatacount; + if (sProcName == "lib3mf_metadatagroup_getmetadata") + *ppProcAddress = (void*) &lib3mf_metadatagroup_getmetadata; + if (sProcName == "lib3mf_metadatagroup_getmetadatabykey") + *ppProcAddress = (void*) &lib3mf_metadatagroup_getmetadatabykey; + if (sProcName == "lib3mf_metadatagroup_removemetadatabyindex") + *ppProcAddress = (void*) &lib3mf_metadatagroup_removemetadatabyindex; + if (sProcName == "lib3mf_metadatagroup_removemetadata") + *ppProcAddress = (void*) &lib3mf_metadatagroup_removemetadata; + if (sProcName == "lib3mf_metadatagroup_addmetadata") + *ppProcAddress = (void*) &lib3mf_metadatagroup_addmetadata; + if (sProcName == "lib3mf_triangleset_setname") + *ppProcAddress = (void*) &lib3mf_triangleset_setname; + if (sProcName == "lib3mf_triangleset_getname") + *ppProcAddress = (void*) &lib3mf_triangleset_getname; + if (sProcName == "lib3mf_triangleset_setidentifier") + *ppProcAddress = (void*) &lib3mf_triangleset_setidentifier; + if (sProcName == "lib3mf_triangleset_getidentifier") + *ppProcAddress = (void*) &lib3mf_triangleset_getidentifier; + if (sProcName == "lib3mf_triangleset_addtriangle") + *ppProcAddress = (void*) &lib3mf_triangleset_addtriangle; + if (sProcName == "lib3mf_triangleset_removetriangle") + *ppProcAddress = (void*) &lib3mf_triangleset_removetriangle; + if (sProcName == "lib3mf_triangleset_clear") + *ppProcAddress = (void*) &lib3mf_triangleset_clear; + if (sProcName == "lib3mf_triangleset_settrianglelist") + *ppProcAddress = (void*) &lib3mf_triangleset_settrianglelist; + if (sProcName == "lib3mf_triangleset_gettrianglelist") + *ppProcAddress = (void*) &lib3mf_triangleset_gettrianglelist; + if (sProcName == "lib3mf_triangleset_addtrianglelist") + *ppProcAddress = (void*) &lib3mf_triangleset_addtrianglelist; + if (sProcName == "lib3mf_triangleset_merge") + *ppProcAddress = (void*) &lib3mf_triangleset_merge; + if (sProcName == "lib3mf_triangleset_deleteset") + *ppProcAddress = (void*) &lib3mf_triangleset_deleteset; + if (sProcName == "lib3mf_triangleset_duplicate") + *ppProcAddress = (void*) &lib3mf_triangleset_duplicate; + if (sProcName == "lib3mf_object_gettype") + *ppProcAddress = (void*) &lib3mf_object_gettype; + if (sProcName == "lib3mf_object_settype") + *ppProcAddress = (void*) &lib3mf_object_settype; + if (sProcName == "lib3mf_object_getname") + *ppProcAddress = (void*) &lib3mf_object_getname; + if (sProcName == "lib3mf_object_setname") + *ppProcAddress = (void*) &lib3mf_object_setname; + if (sProcName == "lib3mf_object_getpartnumber") + *ppProcAddress = (void*) &lib3mf_object_getpartnumber; + if (sProcName == "lib3mf_object_setpartnumber") + *ppProcAddress = (void*) &lib3mf_object_setpartnumber; + if (sProcName == "lib3mf_object_ismeshobject") + *ppProcAddress = (void*) &lib3mf_object_ismeshobject; + if (sProcName == "lib3mf_object_iscomponentsobject") + *ppProcAddress = (void*) &lib3mf_object_iscomponentsobject; + if (sProcName == "lib3mf_object_islevelsetobject") + *ppProcAddress = (void*) &lib3mf_object_islevelsetobject; + if (sProcName == "lib3mf_object_isvalid") + *ppProcAddress = (void*) &lib3mf_object_isvalid; + if (sProcName == "lib3mf_object_setattachmentasthumbnail") + *ppProcAddress = (void*) &lib3mf_object_setattachmentasthumbnail; + if (sProcName == "lib3mf_object_getthumbnailattachment") + *ppProcAddress = (void*) &lib3mf_object_getthumbnailattachment; + if (sProcName == "lib3mf_object_clearthumbnailattachment") + *ppProcAddress = (void*) &lib3mf_object_clearthumbnailattachment; + if (sProcName == "lib3mf_object_getoutbox") + *ppProcAddress = (void*) &lib3mf_object_getoutbox; + if (sProcName == "lib3mf_object_getuuid") + *ppProcAddress = (void*) &lib3mf_object_getuuid; + if (sProcName == "lib3mf_object_setuuid") + *ppProcAddress = (void*) &lib3mf_object_setuuid; + if (sProcName == "lib3mf_object_getmetadatagroup") + *ppProcAddress = (void*) &lib3mf_object_getmetadatagroup; + if (sProcName == "lib3mf_object_setslicesmeshresolution") + *ppProcAddress = (void*) &lib3mf_object_setslicesmeshresolution; + if (sProcName == "lib3mf_object_getslicesmeshresolution") + *ppProcAddress = (void*) &lib3mf_object_getslicesmeshresolution; + if (sProcName == "lib3mf_object_hasslices") + *ppProcAddress = (void*) &lib3mf_object_hasslices; + if (sProcName == "lib3mf_object_clearslicestack") + *ppProcAddress = (void*) &lib3mf_object_clearslicestack; + if (sProcName == "lib3mf_object_getslicestack") + *ppProcAddress = (void*) &lib3mf_object_getslicestack; + if (sProcName == "lib3mf_object_assignslicestack") + *ppProcAddress = (void*) &lib3mf_object_assignslicestack; + if (sProcName == "lib3mf_meshobject_getvertexcount") + *ppProcAddress = (void*) &lib3mf_meshobject_getvertexcount; + if (sProcName == "lib3mf_meshobject_gettrianglecount") + *ppProcAddress = (void*) &lib3mf_meshobject_gettrianglecount; + if (sProcName == "lib3mf_meshobject_getvertex") + *ppProcAddress = (void*) &lib3mf_meshobject_getvertex; + if (sProcName == "lib3mf_meshobject_setvertex") + *ppProcAddress = (void*) &lib3mf_meshobject_setvertex; + if (sProcName == "lib3mf_meshobject_addvertex") + *ppProcAddress = (void*) &lib3mf_meshobject_addvertex; + if (sProcName == "lib3mf_meshobject_getvertices") + *ppProcAddress = (void*) &lib3mf_meshobject_getvertices; + if (sProcName == "lib3mf_meshobject_gettriangle") + *ppProcAddress = (void*) &lib3mf_meshobject_gettriangle; + if (sProcName == "lib3mf_meshobject_settriangle") + *ppProcAddress = (void*) &lib3mf_meshobject_settriangle; + if (sProcName == "lib3mf_meshobject_addtriangle") + *ppProcAddress = (void*) &lib3mf_meshobject_addtriangle; + if (sProcName == "lib3mf_meshobject_gettriangleindices") + *ppProcAddress = (void*) &lib3mf_meshobject_gettriangleindices; + if (sProcName == "lib3mf_meshobject_setobjectlevelproperty") + *ppProcAddress = (void*) &lib3mf_meshobject_setobjectlevelproperty; + if (sProcName == "lib3mf_meshobject_getobjectlevelproperty") + *ppProcAddress = (void*) &lib3mf_meshobject_getobjectlevelproperty; + if (sProcName == "lib3mf_meshobject_settriangleproperties") + *ppProcAddress = (void*) &lib3mf_meshobject_settriangleproperties; + if (sProcName == "lib3mf_meshobject_gettriangleproperties") + *ppProcAddress = (void*) &lib3mf_meshobject_gettriangleproperties; + if (sProcName == "lib3mf_meshobject_setalltriangleproperties") + *ppProcAddress = (void*) &lib3mf_meshobject_setalltriangleproperties; + if (sProcName == "lib3mf_meshobject_getalltriangleproperties") + *ppProcAddress = (void*) &lib3mf_meshobject_getalltriangleproperties; + if (sProcName == "lib3mf_meshobject_clearallproperties") + *ppProcAddress = (void*) &lib3mf_meshobject_clearallproperties; + if (sProcName == "lib3mf_meshobject_setgeometry") + *ppProcAddress = (void*) &lib3mf_meshobject_setgeometry; + if (sProcName == "lib3mf_meshobject_ismanifoldandoriented") + *ppProcAddress = (void*) &lib3mf_meshobject_ismanifoldandoriented; + if (sProcName == "lib3mf_meshobject_beamlattice") + *ppProcAddress = (void*) &lib3mf_meshobject_beamlattice; + if (sProcName == "lib3mf_meshobject_getvolumedata") + *ppProcAddress = (void*) &lib3mf_meshobject_getvolumedata; + if (sProcName == "lib3mf_meshobject_setvolumedata") + *ppProcAddress = (void*) &lib3mf_meshobject_setvolumedata; + if (sProcName == "lib3mf_meshobject_addtriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_addtriangleset; + if (sProcName == "lib3mf_meshobject_hastriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_hastriangleset; + if (sProcName == "lib3mf_meshobject_findtriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_findtriangleset; + if (sProcName == "lib3mf_meshobject_gettrianglesetcount") + *ppProcAddress = (void*) &lib3mf_meshobject_gettrianglesetcount; + if (sProcName == "lib3mf_meshobject_gettriangleset") + *ppProcAddress = (void*) &lib3mf_meshobject_gettriangleset; + if (sProcName == "lib3mf_levelset_getfunction") + *ppProcAddress = (void*) &lib3mf_levelset_getfunction; + if (sProcName == "lib3mf_levelset_setfunction") + *ppProcAddress = (void*) &lib3mf_levelset_setfunction; + if (sProcName == "lib3mf_levelset_gettransform") + *ppProcAddress = (void*) &lib3mf_levelset_gettransform; + if (sProcName == "lib3mf_levelset_settransform") + *ppProcAddress = (void*) &lib3mf_levelset_settransform; + if (sProcName == "lib3mf_levelset_getchannelname") + *ppProcAddress = (void*) &lib3mf_levelset_getchannelname; + if (sProcName == "lib3mf_levelset_setchannelname") + *ppProcAddress = (void*) &lib3mf_levelset_setchannelname; + if (sProcName == "lib3mf_levelset_setminfeaturesize") + *ppProcAddress = (void*) &lib3mf_levelset_setminfeaturesize; + if (sProcName == "lib3mf_levelset_getminfeaturesize") + *ppProcAddress = (void*) &lib3mf_levelset_getminfeaturesize; + if (sProcName == "lib3mf_levelset_setfallbackvalue") + *ppProcAddress = (void*) &lib3mf_levelset_setfallbackvalue; + if (sProcName == "lib3mf_levelset_getfallbackvalue") + *ppProcAddress = (void*) &lib3mf_levelset_getfallbackvalue; + if (sProcName == "lib3mf_levelset_setmeshbboxonly") + *ppProcAddress = (void*) &lib3mf_levelset_setmeshbboxonly; + if (sProcName == "lib3mf_levelset_getmeshbboxonly") + *ppProcAddress = (void*) &lib3mf_levelset_getmeshbboxonly; + if (sProcName == "lib3mf_levelset_setmesh") + *ppProcAddress = (void*) &lib3mf_levelset_setmesh; + if (sProcName == "lib3mf_levelset_getmesh") + *ppProcAddress = (void*) &lib3mf_levelset_getmesh; + if (sProcName == "lib3mf_levelset_getvolumedata") + *ppProcAddress = (void*) &lib3mf_levelset_getvolumedata; + if (sProcName == "lib3mf_levelset_setvolumedata") + *ppProcAddress = (void*) &lib3mf_levelset_setvolumedata; + if (sProcName == "lib3mf_beamlattice_getminlength") + *ppProcAddress = (void*) &lib3mf_beamlattice_getminlength; + if (sProcName == "lib3mf_beamlattice_setminlength") + *ppProcAddress = (void*) &lib3mf_beamlattice_setminlength; + if (sProcName == "lib3mf_beamlattice_getclipping") + *ppProcAddress = (void*) &lib3mf_beamlattice_getclipping; + if (sProcName == "lib3mf_beamlattice_setclipping") + *ppProcAddress = (void*) &lib3mf_beamlattice_setclipping; + if (sProcName == "lib3mf_beamlattice_getrepresentation") + *ppProcAddress = (void*) &lib3mf_beamlattice_getrepresentation; + if (sProcName == "lib3mf_beamlattice_setrepresentation") + *ppProcAddress = (void*) &lib3mf_beamlattice_setrepresentation; + if (sProcName == "lib3mf_beamlattice_getballoptions") + *ppProcAddress = (void*) &lib3mf_beamlattice_getballoptions; + if (sProcName == "lib3mf_beamlattice_setballoptions") + *ppProcAddress = (void*) &lib3mf_beamlattice_setballoptions; + if (sProcName == "lib3mf_beamlattice_getbeamcount") + *ppProcAddress = (void*) &lib3mf_beamlattice_getbeamcount; + if (sProcName == "lib3mf_beamlattice_getbeam") + *ppProcAddress = (void*) &lib3mf_beamlattice_getbeam; + if (sProcName == "lib3mf_beamlattice_addbeam") + *ppProcAddress = (void*) &lib3mf_beamlattice_addbeam; + if (sProcName == "lib3mf_beamlattice_setbeam") + *ppProcAddress = (void*) &lib3mf_beamlattice_setbeam; + if (sProcName == "lib3mf_beamlattice_setbeams") + *ppProcAddress = (void*) &lib3mf_beamlattice_setbeams; + if (sProcName == "lib3mf_beamlattice_getbeams") + *ppProcAddress = (void*) &lib3mf_beamlattice_getbeams; + if (sProcName == "lib3mf_beamlattice_getballcount") + *ppProcAddress = (void*) &lib3mf_beamlattice_getballcount; + if (sProcName == "lib3mf_beamlattice_getball") + *ppProcAddress = (void*) &lib3mf_beamlattice_getball; + if (sProcName == "lib3mf_beamlattice_addball") + *ppProcAddress = (void*) &lib3mf_beamlattice_addball; + if (sProcName == "lib3mf_beamlattice_setball") + *ppProcAddress = (void*) &lib3mf_beamlattice_setball; + if (sProcName == "lib3mf_beamlattice_setballs") + *ppProcAddress = (void*) &lib3mf_beamlattice_setballs; + if (sProcName == "lib3mf_beamlattice_getballs") + *ppProcAddress = (void*) &lib3mf_beamlattice_getballs; + if (sProcName == "lib3mf_beamlattice_getbeamsetcount") + *ppProcAddress = (void*) &lib3mf_beamlattice_getbeamsetcount; + if (sProcName == "lib3mf_beamlattice_addbeamset") + *ppProcAddress = (void*) &lib3mf_beamlattice_addbeamset; + if (sProcName == "lib3mf_beamlattice_getbeamset") + *ppProcAddress = (void*) &lib3mf_beamlattice_getbeamset; + if (sProcName == "lib3mf_functionreference_getfunctionresourceid") + *ppProcAddress = (void*) &lib3mf_functionreference_getfunctionresourceid; + if (sProcName == "lib3mf_functionreference_setfunctionresourceid") + *ppProcAddress = (void*) &lib3mf_functionreference_setfunctionresourceid; + if (sProcName == "lib3mf_functionreference_gettransform") + *ppProcAddress = (void*) &lib3mf_functionreference_gettransform; + if (sProcName == "lib3mf_functionreference_settransform") + *ppProcAddress = (void*) &lib3mf_functionreference_settransform; + if (sProcName == "lib3mf_functionreference_getchannelname") + *ppProcAddress = (void*) &lib3mf_functionreference_getchannelname; + if (sProcName == "lib3mf_functionreference_setchannelname") + *ppProcAddress = (void*) &lib3mf_functionreference_setchannelname; + if (sProcName == "lib3mf_functionreference_setminfeaturesize") + *ppProcAddress = (void*) &lib3mf_functionreference_setminfeaturesize; + if (sProcName == "lib3mf_functionreference_getminfeaturesize") + *ppProcAddress = (void*) &lib3mf_functionreference_getminfeaturesize; + if (sProcName == "lib3mf_functionreference_setfallbackvalue") + *ppProcAddress = (void*) &lib3mf_functionreference_setfallbackvalue; + if (sProcName == "lib3mf_functionreference_getfallbackvalue") + *ppProcAddress = (void*) &lib3mf_functionreference_getfallbackvalue; + if (sProcName == "lib3mf_volumedatacomposite_getbasematerialgroup") + *ppProcAddress = (void*) &lib3mf_volumedatacomposite_getbasematerialgroup; + if (sProcName == "lib3mf_volumedatacomposite_setbasematerialgroup") + *ppProcAddress = (void*) &lib3mf_volumedatacomposite_setbasematerialgroup; + if (sProcName == "lib3mf_volumedatacomposite_getmaterialmappingcount") + *ppProcAddress = (void*) &lib3mf_volumedatacomposite_getmaterialmappingcount; + if (sProcName == "lib3mf_volumedatacomposite_getmaterialmapping") + *ppProcAddress = (void*) &lib3mf_volumedatacomposite_getmaterialmapping; + if (sProcName == "lib3mf_volumedatacomposite_addmaterialmapping") + *ppProcAddress = (void*) &lib3mf_volumedatacomposite_addmaterialmapping; + if (sProcName == "lib3mf_volumedatacomposite_removematerialmapping") + *ppProcAddress = (void*) &lib3mf_volumedatacomposite_removematerialmapping; + if (sProcName == "lib3mf_volumedataproperty_getname") + *ppProcAddress = (void*) &lib3mf_volumedataproperty_getname; + if (sProcName == "lib3mf_volumedataproperty_setisrequired") + *ppProcAddress = (void*) &lib3mf_volumedataproperty_setisrequired; + if (sProcName == "lib3mf_volumedataproperty_isrequired") + *ppProcAddress = (void*) &lib3mf_volumedataproperty_isrequired; + if (sProcName == "lib3mf_volumedata_getcomposite") + *ppProcAddress = (void*) &lib3mf_volumedata_getcomposite; + if (sProcName == "lib3mf_volumedata_createnewcomposite") + *ppProcAddress = (void*) &lib3mf_volumedata_createnewcomposite; + if (sProcName == "lib3mf_volumedata_removecomposite") + *ppProcAddress = (void*) &lib3mf_volumedata_removecomposite; + if (sProcName == "lib3mf_volumedata_getcolor") + *ppProcAddress = (void*) &lib3mf_volumedata_getcolor; + if (sProcName == "lib3mf_volumedata_createnewcolor") + *ppProcAddress = (void*) &lib3mf_volumedata_createnewcolor; + if (sProcName == "lib3mf_volumedata_removecolor") + *ppProcAddress = (void*) &lib3mf_volumedata_removecolor; + if (sProcName == "lib3mf_volumedata_getpropertycount") + *ppProcAddress = (void*) &lib3mf_volumedata_getpropertycount; + if (sProcName == "lib3mf_volumedata_getproperty") + *ppProcAddress = (void*) &lib3mf_volumedata_getproperty; + if (sProcName == "lib3mf_volumedata_addpropertyfromfunction") + *ppProcAddress = (void*) &lib3mf_volumedata_addpropertyfromfunction; + if (sProcName == "lib3mf_volumedata_removeproperty") + *ppProcAddress = (void*) &lib3mf_volumedata_removeproperty; + if (sProcName == "lib3mf_component_getobjectresource") + *ppProcAddress = (void*) &lib3mf_component_getobjectresource; + if (sProcName == "lib3mf_component_getobjectresourceid") + *ppProcAddress = (void*) &lib3mf_component_getobjectresourceid; + if (sProcName == "lib3mf_component_getuuid") + *ppProcAddress = (void*) &lib3mf_component_getuuid; + if (sProcName == "lib3mf_component_setuuid") + *ppProcAddress = (void*) &lib3mf_component_setuuid; + if (sProcName == "lib3mf_component_hastransform") + *ppProcAddress = (void*) &lib3mf_component_hastransform; + if (sProcName == "lib3mf_component_gettransform") + *ppProcAddress = (void*) &lib3mf_component_gettransform; + if (sProcName == "lib3mf_component_settransform") + *ppProcAddress = (void*) &lib3mf_component_settransform; + if (sProcName == "lib3mf_componentsobject_addcomponent") + *ppProcAddress = (void*) &lib3mf_componentsobject_addcomponent; + if (sProcName == "lib3mf_componentsobject_getcomponent") + *ppProcAddress = (void*) &lib3mf_componentsobject_getcomponent; + if (sProcName == "lib3mf_componentsobject_getcomponentcount") + *ppProcAddress = (void*) &lib3mf_componentsobject_getcomponentcount; + if (sProcName == "lib3mf_beamset_setname") + *ppProcAddress = (void*) &lib3mf_beamset_setname; + if (sProcName == "lib3mf_beamset_getname") + *ppProcAddress = (void*) &lib3mf_beamset_getname; + if (sProcName == "lib3mf_beamset_setidentifier") + *ppProcAddress = (void*) &lib3mf_beamset_setidentifier; + if (sProcName == "lib3mf_beamset_getidentifier") + *ppProcAddress = (void*) &lib3mf_beamset_getidentifier; + if (sProcName == "lib3mf_beamset_getreferencecount") + *ppProcAddress = (void*) &lib3mf_beamset_getreferencecount; + if (sProcName == "lib3mf_beamset_setreferences") + *ppProcAddress = (void*) &lib3mf_beamset_setreferences; + if (sProcName == "lib3mf_beamset_getreferences") + *ppProcAddress = (void*) &lib3mf_beamset_getreferences; + if (sProcName == "lib3mf_beamset_getballreferencecount") + *ppProcAddress = (void*) &lib3mf_beamset_getballreferencecount; + if (sProcName == "lib3mf_beamset_setballreferences") + *ppProcAddress = (void*) &lib3mf_beamset_setballreferences; + if (sProcName == "lib3mf_beamset_getballreferences") + *ppProcAddress = (void*) &lib3mf_beamset_getballreferences; + if (sProcName == "lib3mf_basematerialgroup_getcount") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_getcount; + if (sProcName == "lib3mf_basematerialgroup_getallpropertyids") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_getallpropertyids; + if (sProcName == "lib3mf_basematerialgroup_addmaterial") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_addmaterial; + if (sProcName == "lib3mf_basematerialgroup_removematerial") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_removematerial; + if (sProcName == "lib3mf_basematerialgroup_getname") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_getname; + if (sProcName == "lib3mf_basematerialgroup_setname") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_setname; + if (sProcName == "lib3mf_basematerialgroup_setdisplaycolor") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_setdisplaycolor; + if (sProcName == "lib3mf_basematerialgroup_getdisplaycolor") + *ppProcAddress = (void*) &lib3mf_basematerialgroup_getdisplaycolor; + if (sProcName == "lib3mf_colorgroup_getcount") + *ppProcAddress = (void*) &lib3mf_colorgroup_getcount; + if (sProcName == "lib3mf_colorgroup_getallpropertyids") + *ppProcAddress = (void*) &lib3mf_colorgroup_getallpropertyids; + if (sProcName == "lib3mf_colorgroup_addcolor") + *ppProcAddress = (void*) &lib3mf_colorgroup_addcolor; + if (sProcName == "lib3mf_colorgroup_removecolor") + *ppProcAddress = (void*) &lib3mf_colorgroup_removecolor; + if (sProcName == "lib3mf_colorgroup_setcolor") + *ppProcAddress = (void*) &lib3mf_colorgroup_setcolor; + if (sProcName == "lib3mf_colorgroup_getcolor") + *ppProcAddress = (void*) &lib3mf_colorgroup_getcolor; + if (sProcName == "lib3mf_texture2dgroup_getcount") + *ppProcAddress = (void*) &lib3mf_texture2dgroup_getcount; + if (sProcName == "lib3mf_texture2dgroup_getallpropertyids") + *ppProcAddress = (void*) &lib3mf_texture2dgroup_getallpropertyids; + if (sProcName == "lib3mf_texture2dgroup_addtex2coord") + *ppProcAddress = (void*) &lib3mf_texture2dgroup_addtex2coord; + if (sProcName == "lib3mf_texture2dgroup_gettex2coord") + *ppProcAddress = (void*) &lib3mf_texture2dgroup_gettex2coord; + if (sProcName == "lib3mf_texture2dgroup_removetex2coord") + *ppProcAddress = (void*) &lib3mf_texture2dgroup_removetex2coord; + if (sProcName == "lib3mf_texture2dgroup_gettexture2d") + *ppProcAddress = (void*) &lib3mf_texture2dgroup_gettexture2d; + if (sProcName == "lib3mf_compositematerials_getcount") + *ppProcAddress = (void*) &lib3mf_compositematerials_getcount; + if (sProcName == "lib3mf_compositematerials_getallpropertyids") + *ppProcAddress = (void*) &lib3mf_compositematerials_getallpropertyids; + if (sProcName == "lib3mf_compositematerials_getbasematerialgroup") + *ppProcAddress = (void*) &lib3mf_compositematerials_getbasematerialgroup; + if (sProcName == "lib3mf_compositematerials_addcomposite") + *ppProcAddress = (void*) &lib3mf_compositematerials_addcomposite; + if (sProcName == "lib3mf_compositematerials_removecomposite") + *ppProcAddress = (void*) &lib3mf_compositematerials_removecomposite; + if (sProcName == "lib3mf_compositematerials_getcomposite") + *ppProcAddress = (void*) &lib3mf_compositematerials_getcomposite; + if (sProcName == "lib3mf_multipropertygroup_getcount") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_getcount; + if (sProcName == "lib3mf_multipropertygroup_getallpropertyids") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_getallpropertyids; + if (sProcName == "lib3mf_multipropertygroup_addmultiproperty") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_addmultiproperty; + if (sProcName == "lib3mf_multipropertygroup_setmultiproperty") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_setmultiproperty; + if (sProcName == "lib3mf_multipropertygroup_getmultiproperty") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_getmultiproperty; + if (sProcName == "lib3mf_multipropertygroup_removemultiproperty") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_removemultiproperty; + if (sProcName == "lib3mf_multipropertygroup_getlayercount") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_getlayercount; + if (sProcName == "lib3mf_multipropertygroup_addlayer") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_addlayer; + if (sProcName == "lib3mf_multipropertygroup_getlayer") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_getlayer; + if (sProcName == "lib3mf_multipropertygroup_removelayer") + *ppProcAddress = (void*) &lib3mf_multipropertygroup_removelayer; + if (sProcName == "lib3mf_image3d_getname") + *ppProcAddress = (void*) &lib3mf_image3d_getname; + if (sProcName == "lib3mf_image3d_setname") + *ppProcAddress = (void*) &lib3mf_image3d_setname; + if (sProcName == "lib3mf_image3d_isimagestack") + *ppProcAddress = (void*) &lib3mf_image3d_isimagestack; + if (sProcName == "lib3mf_imagestack_getrowcount") + *ppProcAddress = (void*) &lib3mf_imagestack_getrowcount; + if (sProcName == "lib3mf_imagestack_setrowcount") + *ppProcAddress = (void*) &lib3mf_imagestack_setrowcount; + if (sProcName == "lib3mf_imagestack_getcolumncount") + *ppProcAddress = (void*) &lib3mf_imagestack_getcolumncount; + if (sProcName == "lib3mf_imagestack_setcolumncount") + *ppProcAddress = (void*) &lib3mf_imagestack_setcolumncount; + if (sProcName == "lib3mf_imagestack_getsheetcount") + *ppProcAddress = (void*) &lib3mf_imagestack_getsheetcount; + if (sProcName == "lib3mf_imagestack_getsheet") + *ppProcAddress = (void*) &lib3mf_imagestack_getsheet; + if (sProcName == "lib3mf_imagestack_setsheet") + *ppProcAddress = (void*) &lib3mf_imagestack_setsheet; + if (sProcName == "lib3mf_imagestack_createemptysheet") + *ppProcAddress = (void*) &lib3mf_imagestack_createemptysheet; + if (sProcName == "lib3mf_imagestack_createsheetfrombuffer") + *ppProcAddress = (void*) &lib3mf_imagestack_createsheetfrombuffer; + if (sProcName == "lib3mf_imagestack_createsheetfromfile") + *ppProcAddress = (void*) &lib3mf_imagestack_createsheetfromfile; + if (sProcName == "lib3mf_attachment_getpath") + *ppProcAddress = (void*) &lib3mf_attachment_getpath; + if (sProcName == "lib3mf_attachment_setpath") + *ppProcAddress = (void*) &lib3mf_attachment_setpath; + if (sProcName == "lib3mf_attachment_packagepart") + *ppProcAddress = (void*) &lib3mf_attachment_packagepart; + if (sProcName == "lib3mf_attachment_getrelationshiptype") + *ppProcAddress = (void*) &lib3mf_attachment_getrelationshiptype; + if (sProcName == "lib3mf_attachment_setrelationshiptype") + *ppProcAddress = (void*) &lib3mf_attachment_setrelationshiptype; + if (sProcName == "lib3mf_attachment_writetofile") + *ppProcAddress = (void*) &lib3mf_attachment_writetofile; + if (sProcName == "lib3mf_attachment_readfromfile") + *ppProcAddress = (void*) &lib3mf_attachment_readfromfile; + if (sProcName == "lib3mf_attachment_readfromcallback") + *ppProcAddress = (void*) &lib3mf_attachment_readfromcallback; + if (sProcName == "lib3mf_attachment_getstreamsize") + *ppProcAddress = (void*) &lib3mf_attachment_getstreamsize; + if (sProcName == "lib3mf_attachment_writetobuffer") + *ppProcAddress = (void*) &lib3mf_attachment_writetobuffer; + if (sProcName == "lib3mf_attachment_readfrombuffer") + *ppProcAddress = (void*) &lib3mf_attachment_readfrombuffer; + if (sProcName == "lib3mf_texture2d_getattachment") + *ppProcAddress = (void*) &lib3mf_texture2d_getattachment; + if (sProcName == "lib3mf_texture2d_setattachment") + *ppProcAddress = (void*) &lib3mf_texture2d_setattachment; + if (sProcName == "lib3mf_texture2d_getcontenttype") + *ppProcAddress = (void*) &lib3mf_texture2d_getcontenttype; + if (sProcName == "lib3mf_texture2d_setcontenttype") + *ppProcAddress = (void*) &lib3mf_texture2d_setcontenttype; + if (sProcName == "lib3mf_texture2d_gettilestyleuv") + *ppProcAddress = (void*) &lib3mf_texture2d_gettilestyleuv; + if (sProcName == "lib3mf_texture2d_settilestyleuv") + *ppProcAddress = (void*) &lib3mf_texture2d_settilestyleuv; + if (sProcName == "lib3mf_texture2d_getfilter") + *ppProcAddress = (void*) &lib3mf_texture2d_getfilter; + if (sProcName == "lib3mf_texture2d_setfilter") + *ppProcAddress = (void*) &lib3mf_texture2d_setfilter; + if (sProcName == "lib3mf_implicitport_getidentifier") + *ppProcAddress = (void*) &lib3mf_implicitport_getidentifier; + if (sProcName == "lib3mf_implicitport_setidentifier") + *ppProcAddress = (void*) &lib3mf_implicitport_setidentifier; + if (sProcName == "lib3mf_implicitport_getdisplayname") + *ppProcAddress = (void*) &lib3mf_implicitport_getdisplayname; + if (sProcName == "lib3mf_implicitport_setdisplayname") + *ppProcAddress = (void*) &lib3mf_implicitport_setdisplayname; + if (sProcName == "lib3mf_implicitport_settype") + *ppProcAddress = (void*) &lib3mf_implicitport_settype; + if (sProcName == "lib3mf_implicitport_gettype") + *ppProcAddress = (void*) &lib3mf_implicitport_gettype; + if (sProcName == "lib3mf_implicitport_getreference") + *ppProcAddress = (void*) &lib3mf_implicitport_getreference; + if (sProcName == "lib3mf_implicitport_setreference") + *ppProcAddress = (void*) &lib3mf_implicitport_setreference; + if (sProcName == "lib3mf_iterator_movenext") + *ppProcAddress = (void*) &lib3mf_iterator_movenext; + if (sProcName == "lib3mf_iterator_moveprevious") + *ppProcAddress = (void*) &lib3mf_iterator_moveprevious; + if (sProcName == "lib3mf_iterator_count") + *ppProcAddress = (void*) &lib3mf_iterator_count; + if (sProcName == "lib3mf_implicitportiterator_getcurrent") + *ppProcAddress = (void*) &lib3mf_implicitportiterator_getcurrent; + if (sProcName == "lib3mf_implicitnode_getidentifier") + *ppProcAddress = (void*) &lib3mf_implicitnode_getidentifier; + if (sProcName == "lib3mf_implicitnode_setidentifier") + *ppProcAddress = (void*) &lib3mf_implicitnode_setidentifier; + if (sProcName == "lib3mf_implicitnode_getdisplayname") + *ppProcAddress = (void*) &lib3mf_implicitnode_getdisplayname; + if (sProcName == "lib3mf_implicitnode_setdisplayname") + *ppProcAddress = (void*) &lib3mf_implicitnode_setdisplayname; + if (sProcName == "lib3mf_implicitnode_gettag") + *ppProcAddress = (void*) &lib3mf_implicitnode_gettag; + if (sProcName == "lib3mf_implicitnode_settag") + *ppProcAddress = (void*) &lib3mf_implicitnode_settag; + if (sProcName == "lib3mf_implicitnode_getnodetype") + *ppProcAddress = (void*) &lib3mf_implicitnode_getnodetype; + if (sProcName == "lib3mf_implicitnode_addinput") + *ppProcAddress = (void*) &lib3mf_implicitnode_addinput; + if (sProcName == "lib3mf_implicitnode_getinputs") + *ppProcAddress = (void*) &lib3mf_implicitnode_getinputs; + if (sProcName == "lib3mf_implicitnode_addoutput") + *ppProcAddress = (void*) &lib3mf_implicitnode_addoutput; + if (sProcName == "lib3mf_implicitnode_getoutputs") + *ppProcAddress = (void*) &lib3mf_implicitnode_getoutputs; + if (sProcName == "lib3mf_implicitnode_findinput") + *ppProcAddress = (void*) &lib3mf_implicitnode_findinput; + if (sProcName == "lib3mf_implicitnode_findoutput") + *ppProcAddress = (void*) &lib3mf_implicitnode_findoutput; + if (sProcName == "lib3mf_implicitnode_aretypesvalid") + *ppProcAddress = (void*) &lib3mf_implicitnode_aretypesvalid; + if (sProcName == "lib3mf_oneinputnode_getinputa") + *ppProcAddress = (void*) &lib3mf_oneinputnode_getinputa; + if (sProcName == "lib3mf_oneinputnode_getoutputresult") + *ppProcAddress = (void*) &lib3mf_oneinputnode_getoutputresult; + if (sProcName == "lib3mf_resourceidnode_setresource") + *ppProcAddress = (void*) &lib3mf_resourceidnode_setresource; + if (sProcName == "lib3mf_resourceidnode_getresource") + *ppProcAddress = (void*) &lib3mf_resourceidnode_getresource; + if (sProcName == "lib3mf_resourceidnode_getoutputvalue") + *ppProcAddress = (void*) &lib3mf_resourceidnode_getoutputvalue; + if (sProcName == "lib3mf_twoinputnode_getinputb") + *ppProcAddress = (void*) &lib3mf_twoinputnode_getinputb; + if (sProcName == "lib3mf_selectnode_getinputb") + *ppProcAddress = (void*) &lib3mf_selectnode_getinputb; + if (sProcName == "lib3mf_selectnode_getinputc") + *ppProcAddress = (void*) &lib3mf_selectnode_getinputc; + if (sProcName == "lib3mf_selectnode_getinputd") + *ppProcAddress = (void*) &lib3mf_selectnode_getinputd; + if (sProcName == "lib3mf_clampnode_getinputmin") + *ppProcAddress = (void*) &lib3mf_clampnode_getinputmin; + if (sProcName == "lib3mf_clampnode_getinputmax") + *ppProcAddress = (void*) &lib3mf_clampnode_getinputmax; + if (sProcName == "lib3mf_composevectornode_getinputx") + *ppProcAddress = (void*) &lib3mf_composevectornode_getinputx; + if (sProcName == "lib3mf_composevectornode_getinputy") + *ppProcAddress = (void*) &lib3mf_composevectornode_getinputy; + if (sProcName == "lib3mf_composevectornode_getinputz") + *ppProcAddress = (void*) &lib3mf_composevectornode_getinputz; + if (sProcName == "lib3mf_composevectornode_getoutputresult") + *ppProcAddress = (void*) &lib3mf_composevectornode_getoutputresult; + if (sProcName == "lib3mf_decomposevectornode_getinputa") + *ppProcAddress = (void*) &lib3mf_decomposevectornode_getinputa; + if (sProcName == "lib3mf_decomposevectornode_getoutputx") + *ppProcAddress = (void*) &lib3mf_decomposevectornode_getoutputx; + if (sProcName == "lib3mf_decomposevectornode_getoutputy") + *ppProcAddress = (void*) &lib3mf_decomposevectornode_getoutputy; + if (sProcName == "lib3mf_decomposevectornode_getoutputz") + *ppProcAddress = (void*) &lib3mf_decomposevectornode_getoutputz; + if (sProcName == "lib3mf_composematrixnode_getinputm00") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm00; + if (sProcName == "lib3mf_composematrixnode_getinputm01") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm01; + if (sProcName == "lib3mf_composematrixnode_getinputm02") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm02; + if (sProcName == "lib3mf_composematrixnode_getinputm03") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm03; + if (sProcName == "lib3mf_composematrixnode_getinputm10") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm10; + if (sProcName == "lib3mf_composematrixnode_getinputm11") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm11; + if (sProcName == "lib3mf_composematrixnode_getinputm12") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm12; + if (sProcName == "lib3mf_composematrixnode_getinputm13") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm13; + if (sProcName == "lib3mf_composematrixnode_getinputm20") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm20; + if (sProcName == "lib3mf_composematrixnode_getinputm21") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm21; + if (sProcName == "lib3mf_composematrixnode_getinputm22") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm22; + if (sProcName == "lib3mf_composematrixnode_getinputm23") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm23; + if (sProcName == "lib3mf_composematrixnode_getinputm30") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm30; + if (sProcName == "lib3mf_composematrixnode_getinputm31") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm31; + if (sProcName == "lib3mf_composematrixnode_getinputm32") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm32; + if (sProcName == "lib3mf_composematrixnode_getinputm33") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getinputm33; + if (sProcName == "lib3mf_composematrixnode_getoutputresult") + *ppProcAddress = (void*) &lib3mf_composematrixnode_getoutputresult; + if (sProcName == "lib3mf_matrixfromrowsnode_getinputa") + *ppProcAddress = (void*) &lib3mf_matrixfromrowsnode_getinputa; + if (sProcName == "lib3mf_matrixfromrowsnode_getinputb") + *ppProcAddress = (void*) &lib3mf_matrixfromrowsnode_getinputb; + if (sProcName == "lib3mf_matrixfromrowsnode_getinputc") + *ppProcAddress = (void*) &lib3mf_matrixfromrowsnode_getinputc; + if (sProcName == "lib3mf_matrixfromrowsnode_getinputd") + *ppProcAddress = (void*) &lib3mf_matrixfromrowsnode_getinputd; + if (sProcName == "lib3mf_matrixfromrowsnode_getoutputresult") + *ppProcAddress = (void*) &lib3mf_matrixfromrowsnode_getoutputresult; + if (sProcName == "lib3mf_matrixfromcolumnsnode_getinputa") + *ppProcAddress = (void*) &lib3mf_matrixfromcolumnsnode_getinputa; + if (sProcName == "lib3mf_matrixfromcolumnsnode_getinputb") + *ppProcAddress = (void*) &lib3mf_matrixfromcolumnsnode_getinputb; + if (sProcName == "lib3mf_matrixfromcolumnsnode_getinputc") + *ppProcAddress = (void*) &lib3mf_matrixfromcolumnsnode_getinputc; + if (sProcName == "lib3mf_matrixfromcolumnsnode_getinputd") + *ppProcAddress = (void*) &lib3mf_matrixfromcolumnsnode_getinputd; + if (sProcName == "lib3mf_matrixfromcolumnsnode_getoutputresult") + *ppProcAddress = (void*) &lib3mf_matrixfromcolumnsnode_getoutputresult; + if (sProcName == "lib3mf_constantnode_setconstant") + *ppProcAddress = (void*) &lib3mf_constantnode_setconstant; + if (sProcName == "lib3mf_constantnode_getconstant") + *ppProcAddress = (void*) &lib3mf_constantnode_getconstant; + if (sProcName == "lib3mf_constantnode_getoutputvalue") + *ppProcAddress = (void*) &lib3mf_constantnode_getoutputvalue; + if (sProcName == "lib3mf_constvecnode_setvector") + *ppProcAddress = (void*) &lib3mf_constvecnode_setvector; + if (sProcName == "lib3mf_constvecnode_getvector") + *ppProcAddress = (void*) &lib3mf_constvecnode_getvector; + if (sProcName == "lib3mf_constvecnode_getoutputvector") + *ppProcAddress = (void*) &lib3mf_constvecnode_getoutputvector; + if (sProcName == "lib3mf_constmatnode_setmatrix") + *ppProcAddress = (void*) &lib3mf_constmatnode_setmatrix; + if (sProcName == "lib3mf_constmatnode_getmatrix") + *ppProcAddress = (void*) &lib3mf_constmatnode_getmatrix; + if (sProcName == "lib3mf_constmatnode_getoutputmatrix") + *ppProcAddress = (void*) &lib3mf_constmatnode_getoutputmatrix; + if (sProcName == "lib3mf_meshnode_getinputmesh") + *ppProcAddress = (void*) &lib3mf_meshnode_getinputmesh; + if (sProcName == "lib3mf_meshnode_getinputpos") + *ppProcAddress = (void*) &lib3mf_meshnode_getinputpos; + if (sProcName == "lib3mf_meshnode_getoutputdistance") + *ppProcAddress = (void*) &lib3mf_meshnode_getoutputdistance; + if (sProcName == "lib3mf_unsignedmeshnode_getinputmesh") + *ppProcAddress = (void*) &lib3mf_unsignedmeshnode_getinputmesh; + if (sProcName == "lib3mf_unsignedmeshnode_getinputpos") + *ppProcAddress = (void*) &lib3mf_unsignedmeshnode_getinputpos; + if (sProcName == "lib3mf_unsignedmeshnode_getoutputdistance") + *ppProcAddress = (void*) &lib3mf_unsignedmeshnode_getoutputdistance; + if (sProcName == "lib3mf_beamlatticenode_getinputbeamlattice") + *ppProcAddress = (void*) &lib3mf_beamlatticenode_getinputbeamlattice; + if (sProcName == "lib3mf_beamlatticenode_getinputpos") + *ppProcAddress = (void*) &lib3mf_beamlatticenode_getinputpos; + if (sProcName == "lib3mf_beamlatticenode_getoutputdistance") + *ppProcAddress = (void*) &lib3mf_beamlatticenode_getoutputdistance; + if (sProcName == "lib3mf_beamlatticenode_setaccuraterange") + *ppProcAddress = (void*) &lib3mf_beamlatticenode_setaccuraterange; + if (sProcName == "lib3mf_beamlatticenode_getaccuraterange") + *ppProcAddress = (void*) &lib3mf_beamlatticenode_getaccuraterange; + if (sProcName == "lib3mf_functiongradientnode_getinputfunctionid") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getinputfunctionid; + if (sProcName == "lib3mf_functiongradientnode_getinputpos") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getinputpos; + if (sProcName == "lib3mf_functiongradientnode_getinputstep") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getinputstep; + if (sProcName == "lib3mf_functiongradientnode_setscalaroutputname") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_setscalaroutputname; + if (sProcName == "lib3mf_functiongradientnode_getscalaroutputname") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getscalaroutputname; + if (sProcName == "lib3mf_functiongradientnode_setvectorinputname") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_setvectorinputname; + if (sProcName == "lib3mf_functiongradientnode_getvectorinputname") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getvectorinputname; + if (sProcName == "lib3mf_functiongradientnode_getoutputnormalizedgradient") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getoutputnormalizedgradient; + if (sProcName == "lib3mf_functiongradientnode_getoutputgradient") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getoutputgradient; + if (sProcName == "lib3mf_functiongradientnode_getoutputmagnitude") + *ppProcAddress = (void*) &lib3mf_functiongradientnode_getoutputmagnitude; + if (sProcName == "lib3mf_normalizedistancenode_getinputfunctionid") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_getinputfunctionid; + if (sProcName == "lib3mf_normalizedistancenode_getinputpos") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_getinputpos; + if (sProcName == "lib3mf_normalizedistancenode_getinputstep") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_getinputstep; + if (sProcName == "lib3mf_normalizedistancenode_setscalaroutputname") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_setscalaroutputname; + if (sProcName == "lib3mf_normalizedistancenode_getscalaroutputname") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_getscalaroutputname; + if (sProcName == "lib3mf_normalizedistancenode_setvectorinputname") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_setvectorinputname; + if (sProcName == "lib3mf_normalizedistancenode_getvectorinputname") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_getvectorinputname; + if (sProcName == "lib3mf_normalizedistancenode_getoutputresult") + *ppProcAddress = (void*) &lib3mf_normalizedistancenode_getoutputresult; + if (sProcName == "lib3mf_functioncallnode_getinputfunctionid") + *ppProcAddress = (void*) &lib3mf_functioncallnode_getinputfunctionid; + if (sProcName == "lib3mf_nodeiterator_getcurrent") + *ppProcAddress = (void*) &lib3mf_nodeiterator_getcurrent; + if (sProcName == "lib3mf_function_getdisplayname") + *ppProcAddress = (void*) &lib3mf_function_getdisplayname; + if (sProcName == "lib3mf_function_setdisplayname") + *ppProcAddress = (void*) &lib3mf_function_setdisplayname; + if (sProcName == "lib3mf_function_addinput") + *ppProcAddress = (void*) &lib3mf_function_addinput; + if (sProcName == "lib3mf_function_getinputs") + *ppProcAddress = (void*) &lib3mf_function_getinputs; + if (sProcName == "lib3mf_function_removeinput") + *ppProcAddress = (void*) &lib3mf_function_removeinput; + if (sProcName == "lib3mf_function_addoutput") + *ppProcAddress = (void*) &lib3mf_function_addoutput; + if (sProcName == "lib3mf_function_getoutputs") + *ppProcAddress = (void*) &lib3mf_function_getoutputs; + if (sProcName == "lib3mf_function_removeoutput") + *ppProcAddress = (void*) &lib3mf_function_removeoutput; + if (sProcName == "lib3mf_function_findinput") + *ppProcAddress = (void*) &lib3mf_function_findinput; + if (sProcName == "lib3mf_function_findoutput") + *ppProcAddress = (void*) &lib3mf_function_findoutput; + if (sProcName == "lib3mf_implicitfunction_getidentifier") + *ppProcAddress = (void*) &lib3mf_implicitfunction_getidentifier; + if (sProcName == "lib3mf_implicitfunction_setidentifier") + *ppProcAddress = (void*) &lib3mf_implicitfunction_setidentifier; + if (sProcName == "lib3mf_implicitfunction_addnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addnode; + if (sProcName == "lib3mf_implicitfunction_addsinnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addsinnode; + if (sProcName == "lib3mf_implicitfunction_addcosnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addcosnode; + if (sProcName == "lib3mf_implicitfunction_addtannode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addtannode; + if (sProcName == "lib3mf_implicitfunction_addarcsinnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addarcsinnode; + if (sProcName == "lib3mf_implicitfunction_addarccosnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addarccosnode; + if (sProcName == "lib3mf_implicitfunction_addarctan2node") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addarctan2node; + if (sProcName == "lib3mf_implicitfunction_addsinhnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addsinhnode; + if (sProcName == "lib3mf_implicitfunction_addcoshnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addcoshnode; + if (sProcName == "lib3mf_implicitfunction_addtanhnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addtanhnode; + if (sProcName == "lib3mf_implicitfunction_addroundnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addroundnode; + if (sProcName == "lib3mf_implicitfunction_addceilnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addceilnode; + if (sProcName == "lib3mf_implicitfunction_addfloornode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addfloornode; + if (sProcName == "lib3mf_implicitfunction_addsignnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addsignnode; + if (sProcName == "lib3mf_implicitfunction_addfractnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addfractnode; + if (sProcName == "lib3mf_implicitfunction_addabsnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addabsnode; + if (sProcName == "lib3mf_implicitfunction_addexpnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addexpnode; + if (sProcName == "lib3mf_implicitfunction_addlognode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addlognode; + if (sProcName == "lib3mf_implicitfunction_addlog2node") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addlog2node; + if (sProcName == "lib3mf_implicitfunction_addlog10node") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addlog10node; + if (sProcName == "lib3mf_implicitfunction_addlengthnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addlengthnode; + if (sProcName == "lib3mf_implicitfunction_addtransposenode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addtransposenode; + if (sProcName == "lib3mf_implicitfunction_addinversenode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addinversenode; + if (sProcName == "lib3mf_implicitfunction_addsqrtnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addsqrtnode; + if (sProcName == "lib3mf_implicitfunction_addresourceidnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addresourceidnode; + if (sProcName == "lib3mf_implicitfunction_addadditionnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addadditionnode; + if (sProcName == "lib3mf_implicitfunction_addsubtractionnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addsubtractionnode; + if (sProcName == "lib3mf_implicitfunction_addmultiplicationnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addmultiplicationnode; + if (sProcName == "lib3mf_implicitfunction_adddivisionnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_adddivisionnode; + if (sProcName == "lib3mf_implicitfunction_adddotnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_adddotnode; + if (sProcName == "lib3mf_implicitfunction_addcrossnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addcrossnode; + if (sProcName == "lib3mf_implicitfunction_addmatvecmultiplicationnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addmatvecmultiplicationnode; + if (sProcName == "lib3mf_implicitfunction_addminnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addminnode; + if (sProcName == "lib3mf_implicitfunction_addmaxnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addmaxnode; + if (sProcName == "lib3mf_implicitfunction_addfmodnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addfmodnode; + if (sProcName == "lib3mf_implicitfunction_addpownode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addpownode; + if (sProcName == "lib3mf_implicitfunction_addselectnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addselectnode; + if (sProcName == "lib3mf_implicitfunction_addclampnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addclampnode; + if (sProcName == "lib3mf_implicitfunction_addcomposevectornode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addcomposevectornode; + if (sProcName == "lib3mf_implicitfunction_addvectorfromscalarnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addvectorfromscalarnode; + if (sProcName == "lib3mf_implicitfunction_adddecomposevectornode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_adddecomposevectornode; + if (sProcName == "lib3mf_implicitfunction_addcomposematrixnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addcomposematrixnode; + if (sProcName == "lib3mf_implicitfunction_addmatrixfromrowsnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addmatrixfromrowsnode; + if (sProcName == "lib3mf_implicitfunction_addmatrixfromcolumnsnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addmatrixfromcolumnsnode; + if (sProcName == "lib3mf_implicitfunction_addconstantnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addconstantnode; + if (sProcName == "lib3mf_implicitfunction_addconstvecnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addconstvecnode; + if (sProcName == "lib3mf_implicitfunction_addconstmatnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addconstmatnode; + if (sProcName == "lib3mf_implicitfunction_addmeshnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addmeshnode; + if (sProcName == "lib3mf_implicitfunction_addunsignedmeshnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addunsignedmeshnode; + if (sProcName == "lib3mf_implicitfunction_addbeamlatticenode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addbeamlatticenode; + if (sProcName == "lib3mf_implicitfunction_addfunctiongradientnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addfunctiongradientnode; + if (sProcName == "lib3mf_implicitfunction_addnormalizedistancenode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addnormalizedistancenode; + if (sProcName == "lib3mf_implicitfunction_addfunctioncallnode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addfunctioncallnode; + if (sProcName == "lib3mf_implicitfunction_getnodes") + *ppProcAddress = (void*) &lib3mf_implicitfunction_getnodes; + if (sProcName == "lib3mf_implicitfunction_removenode") + *ppProcAddress = (void*) &lib3mf_implicitfunction_removenode; + if (sProcName == "lib3mf_implicitfunction_addlink") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addlink; + if (sProcName == "lib3mf_implicitfunction_addlinkbynames") + *ppProcAddress = (void*) &lib3mf_implicitfunction_addlinkbynames; + if (sProcName == "lib3mf_implicitfunction_clear") + *ppProcAddress = (void*) &lib3mf_implicitfunction_clear; + if (sProcName == "lib3mf_implicitfunction_sortnodestopologically") + *ppProcAddress = (void*) &lib3mf_implicitfunction_sortnodestopologically; + if (sProcName == "lib3mf_functionfromimage3d_getimage3d") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_getimage3d; + if (sProcName == "lib3mf_functionfromimage3d_setimage3d") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_setimage3d; + if (sProcName == "lib3mf_functionfromimage3d_setfilter") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_setfilter; + if (sProcName == "lib3mf_functionfromimage3d_getfilter") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_getfilter; + if (sProcName == "lib3mf_functionfromimage3d_settilestyles") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_settilestyles; + if (sProcName == "lib3mf_functionfromimage3d_gettilestyles") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_gettilestyles; + if (sProcName == "lib3mf_functionfromimage3d_getoffset") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_getoffset; + if (sProcName == "lib3mf_functionfromimage3d_setoffset") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_setoffset; + if (sProcName == "lib3mf_functionfromimage3d_getscale") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_getscale; + if (sProcName == "lib3mf_functionfromimage3d_setscale") + *ppProcAddress = (void*) &lib3mf_functionfromimage3d_setscale; + if (sProcName == "lib3mf_builditem_getobjectresource") + *ppProcAddress = (void*) &lib3mf_builditem_getobjectresource; + if (sProcName == "lib3mf_builditem_getuuid") + *ppProcAddress = (void*) &lib3mf_builditem_getuuid; + if (sProcName == "lib3mf_builditem_setuuid") + *ppProcAddress = (void*) &lib3mf_builditem_setuuid; + if (sProcName == "lib3mf_builditem_getobjectresourceid") + *ppProcAddress = (void*) &lib3mf_builditem_getobjectresourceid; + if (sProcName == "lib3mf_builditem_hasobjecttransform") + *ppProcAddress = (void*) &lib3mf_builditem_hasobjecttransform; + if (sProcName == "lib3mf_builditem_getobjecttransform") + *ppProcAddress = (void*) &lib3mf_builditem_getobjecttransform; + if (sProcName == "lib3mf_builditem_setobjecttransform") + *ppProcAddress = (void*) &lib3mf_builditem_setobjecttransform; + if (sProcName == "lib3mf_builditem_getpartnumber") + *ppProcAddress = (void*) &lib3mf_builditem_getpartnumber; + if (sProcName == "lib3mf_builditem_setpartnumber") + *ppProcAddress = (void*) &lib3mf_builditem_setpartnumber; + if (sProcName == "lib3mf_builditem_getmetadatagroup") + *ppProcAddress = (void*) &lib3mf_builditem_getmetadatagroup; + if (sProcName == "lib3mf_builditem_getoutbox") + *ppProcAddress = (void*) &lib3mf_builditem_getoutbox; + if (sProcName == "lib3mf_builditemiterator_movenext") + *ppProcAddress = (void*) &lib3mf_builditemiterator_movenext; + if (sProcName == "lib3mf_builditemiterator_moveprevious") + *ppProcAddress = (void*) &lib3mf_builditemiterator_moveprevious; + if (sProcName == "lib3mf_builditemiterator_getcurrent") + *ppProcAddress = (void*) &lib3mf_builditemiterator_getcurrent; + if (sProcName == "lib3mf_builditemiterator_clone") + *ppProcAddress = (void*) &lib3mf_builditemiterator_clone; + if (sProcName == "lib3mf_builditemiterator_count") + *ppProcAddress = (void*) &lib3mf_builditemiterator_count; + if (sProcName == "lib3mf_slice_setvertices") + *ppProcAddress = (void*) &lib3mf_slice_setvertices; + if (sProcName == "lib3mf_slice_getvertices") + *ppProcAddress = (void*) &lib3mf_slice_getvertices; + if (sProcName == "lib3mf_slice_getvertexcount") + *ppProcAddress = (void*) &lib3mf_slice_getvertexcount; + if (sProcName == "lib3mf_slice_addpolygon") + *ppProcAddress = (void*) &lib3mf_slice_addpolygon; + if (sProcName == "lib3mf_slice_getpolygoncount") + *ppProcAddress = (void*) &lib3mf_slice_getpolygoncount; + if (sProcName == "lib3mf_slice_setpolygonindices") + *ppProcAddress = (void*) &lib3mf_slice_setpolygonindices; + if (sProcName == "lib3mf_slice_getpolygonindices") + *ppProcAddress = (void*) &lib3mf_slice_getpolygonindices; + if (sProcName == "lib3mf_slice_getpolygonindexcount") + *ppProcAddress = (void*) &lib3mf_slice_getpolygonindexcount; + if (sProcName == "lib3mf_slice_getztop") + *ppProcAddress = (void*) &lib3mf_slice_getztop; + if (sProcName == "lib3mf_slicestack_getbottomz") + *ppProcAddress = (void*) &lib3mf_slicestack_getbottomz; + if (sProcName == "lib3mf_slicestack_getslicecount") + *ppProcAddress = (void*) &lib3mf_slicestack_getslicecount; + if (sProcName == "lib3mf_slicestack_getslice") + *ppProcAddress = (void*) &lib3mf_slicestack_getslice; + if (sProcName == "lib3mf_slicestack_addslice") + *ppProcAddress = (void*) &lib3mf_slicestack_addslice; + if (sProcName == "lib3mf_slicestack_getslicerefcount") + *ppProcAddress = (void*) &lib3mf_slicestack_getslicerefcount; + if (sProcName == "lib3mf_slicestack_addslicestackreference") + *ppProcAddress = (void*) &lib3mf_slicestack_addslicestackreference; + if (sProcName == "lib3mf_slicestack_getslicestackreference") + *ppProcAddress = (void*) &lib3mf_slicestack_getslicestackreference; + if (sProcName == "lib3mf_slicestack_collapseslicereferences") + *ppProcAddress = (void*) &lib3mf_slicestack_collapseslicereferences; + if (sProcName == "lib3mf_slicestack_setownpath") + *ppProcAddress = (void*) &lib3mf_slicestack_setownpath; + if (sProcName == "lib3mf_slicestack_getownpath") + *ppProcAddress = (void*) &lib3mf_slicestack_getownpath; + if (sProcName == "lib3mf_consumer_getconsumerid") + *ppProcAddress = (void*) &lib3mf_consumer_getconsumerid; + if (sProcName == "lib3mf_consumer_getkeyid") + *ppProcAddress = (void*) &lib3mf_consumer_getkeyid; + if (sProcName == "lib3mf_consumer_getkeyvalue") + *ppProcAddress = (void*) &lib3mf_consumer_getkeyvalue; + if (sProcName == "lib3mf_accessright_getconsumer") + *ppProcAddress = (void*) &lib3mf_accessright_getconsumer; + if (sProcName == "lib3mf_accessright_getwrappingalgorithm") + *ppProcAddress = (void*) &lib3mf_accessright_getwrappingalgorithm; + if (sProcName == "lib3mf_accessright_getmgfalgorithm") + *ppProcAddress = (void*) &lib3mf_accessright_getmgfalgorithm; + if (sProcName == "lib3mf_accessright_getdigestmethod") + *ppProcAddress = (void*) &lib3mf_accessright_getdigestmethod; + if (sProcName == "lib3mf_contentencryptionparams_getencryptionalgorithm") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_getencryptionalgorithm; + if (sProcName == "lib3mf_contentencryptionparams_getkey") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_getkey; + if (sProcName == "lib3mf_contentencryptionparams_getinitializationvector") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_getinitializationvector; + if (sProcName == "lib3mf_contentencryptionparams_getauthenticationtag") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_getauthenticationtag; + if (sProcName == "lib3mf_contentencryptionparams_setauthenticationtag") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_setauthenticationtag; + if (sProcName == "lib3mf_contentencryptionparams_getadditionalauthenticationdata") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_getadditionalauthenticationdata; + if (sProcName == "lib3mf_contentencryptionparams_getdescriptor") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_getdescriptor; + if (sProcName == "lib3mf_contentencryptionparams_getkeyuuid") + *ppProcAddress = (void*) &lib3mf_contentencryptionparams_getkeyuuid; + if (sProcName == "lib3mf_resourcedata_getpath") + *ppProcAddress = (void*) &lib3mf_resourcedata_getpath; + if (sProcName == "lib3mf_resourcedata_getencryptionalgorithm") + *ppProcAddress = (void*) &lib3mf_resourcedata_getencryptionalgorithm; + if (sProcName == "lib3mf_resourcedata_getcompression") + *ppProcAddress = (void*) &lib3mf_resourcedata_getcompression; + if (sProcName == "lib3mf_resourcedata_getadditionalauthenticationdata") + *ppProcAddress = (void*) &lib3mf_resourcedata_getadditionalauthenticationdata; + if (sProcName == "lib3mf_resourcedatagroup_getkeyuuid") + *ppProcAddress = (void*) &lib3mf_resourcedatagroup_getkeyuuid; + if (sProcName == "lib3mf_resourcedatagroup_addaccessright") + *ppProcAddress = (void*) &lib3mf_resourcedatagroup_addaccessright; + if (sProcName == "lib3mf_resourcedatagroup_findaccessrightbyconsumer") + *ppProcAddress = (void*) &lib3mf_resourcedatagroup_findaccessrightbyconsumer; + if (sProcName == "lib3mf_resourcedatagroup_removeaccessright") + *ppProcAddress = (void*) &lib3mf_resourcedatagroup_removeaccessright; + if (sProcName == "lib3mf_keystore_addconsumer") + *ppProcAddress = (void*) &lib3mf_keystore_addconsumer; + if (sProcName == "lib3mf_keystore_getconsumercount") + *ppProcAddress = (void*) &lib3mf_keystore_getconsumercount; + if (sProcName == "lib3mf_keystore_getconsumer") + *ppProcAddress = (void*) &lib3mf_keystore_getconsumer; + if (sProcName == "lib3mf_keystore_removeconsumer") + *ppProcAddress = (void*) &lib3mf_keystore_removeconsumer; + if (sProcName == "lib3mf_keystore_findconsumer") + *ppProcAddress = (void*) &lib3mf_keystore_findconsumer; + if (sProcName == "lib3mf_keystore_getresourcedatagroupcount") + *ppProcAddress = (void*) &lib3mf_keystore_getresourcedatagroupcount; + if (sProcName == "lib3mf_keystore_addresourcedatagroup") + *ppProcAddress = (void*) &lib3mf_keystore_addresourcedatagroup; + if (sProcName == "lib3mf_keystore_getresourcedatagroup") + *ppProcAddress = (void*) &lib3mf_keystore_getresourcedatagroup; + if (sProcName == "lib3mf_keystore_removeresourcedatagroup") + *ppProcAddress = (void*) &lib3mf_keystore_removeresourcedatagroup; + if (sProcName == "lib3mf_keystore_findresourcedatagroup") + *ppProcAddress = (void*) &lib3mf_keystore_findresourcedatagroup; + if (sProcName == "lib3mf_keystore_addresourcedata") + *ppProcAddress = (void*) &lib3mf_keystore_addresourcedata; + if (sProcName == "lib3mf_keystore_removeresourcedata") + *ppProcAddress = (void*) &lib3mf_keystore_removeresourcedata; + if (sProcName == "lib3mf_keystore_findresourcedata") + *ppProcAddress = (void*) &lib3mf_keystore_findresourcedata; + if (sProcName == "lib3mf_keystore_getresourcedatacount") + *ppProcAddress = (void*) &lib3mf_keystore_getresourcedatacount; + if (sProcName == "lib3mf_keystore_getresourcedata") + *ppProcAddress = (void*) &lib3mf_keystore_getresourcedata; + if (sProcName == "lib3mf_keystore_getuuid") + *ppProcAddress = (void*) &lib3mf_keystore_getuuid; + if (sProcName == "lib3mf_keystore_setuuid") + *ppProcAddress = (void*) &lib3mf_keystore_setuuid; + if (sProcName == "lib3mf_model_rootmodelpart") + *ppProcAddress = (void*) &lib3mf_model_rootmodelpart; + if (sProcName == "lib3mf_model_findorcreatepackagepart") + *ppProcAddress = (void*) &lib3mf_model_findorcreatepackagepart; + if (sProcName == "lib3mf_model_setunit") + *ppProcAddress = (void*) &lib3mf_model_setunit; + if (sProcName == "lib3mf_model_getunit") + *ppProcAddress = (void*) &lib3mf_model_getunit; + if (sProcName == "lib3mf_model_getlanguage") + *ppProcAddress = (void*) &lib3mf_model_getlanguage; + if (sProcName == "lib3mf_model_setlanguage") + *ppProcAddress = (void*) &lib3mf_model_setlanguage; + if (sProcName == "lib3mf_model_querywriter") + *ppProcAddress = (void*) &lib3mf_model_querywriter; + if (sProcName == "lib3mf_model_queryreader") + *ppProcAddress = (void*) &lib3mf_model_queryreader; + if (sProcName == "lib3mf_model_getresourcebyid") + *ppProcAddress = (void*) &lib3mf_model_getresourcebyid; + if (sProcName == "lib3mf_model_gettexture2dbyid") + *ppProcAddress = (void*) &lib3mf_model_gettexture2dbyid; + if (sProcName == "lib3mf_model_getpropertytypebyid") + *ppProcAddress = (void*) &lib3mf_model_getpropertytypebyid; + if (sProcName == "lib3mf_model_getbasematerialgroupbyid") + *ppProcAddress = (void*) &lib3mf_model_getbasematerialgroupbyid; + if (sProcName == "lib3mf_model_gettexture2dgroupbyid") + *ppProcAddress = (void*) &lib3mf_model_gettexture2dgroupbyid; + if (sProcName == "lib3mf_model_getcompositematerialsbyid") + *ppProcAddress = (void*) &lib3mf_model_getcompositematerialsbyid; + if (sProcName == "lib3mf_model_getmultipropertygroupbyid") + *ppProcAddress = (void*) &lib3mf_model_getmultipropertygroupbyid; + if (sProcName == "lib3mf_model_getmeshobjectbyid") + *ppProcAddress = (void*) &lib3mf_model_getmeshobjectbyid; + if (sProcName == "lib3mf_model_getcomponentsobjectbyid") + *ppProcAddress = (void*) &lib3mf_model_getcomponentsobjectbyid; + if (sProcName == "lib3mf_model_getcolorgroupbyid") + *ppProcAddress = (void*) &lib3mf_model_getcolorgroupbyid; + if (sProcName == "lib3mf_model_getslicestackbyid") + *ppProcAddress = (void*) &lib3mf_model_getslicestackbyid; + if (sProcName == "lib3mf_model_getlevelsetbyid") + *ppProcAddress = (void*) &lib3mf_model_getlevelsetbyid; + if (sProcName == "lib3mf_model_getbuilduuid") + *ppProcAddress = (void*) &lib3mf_model_getbuilduuid; + if (sProcName == "lib3mf_model_setbuilduuid") + *ppProcAddress = (void*) &lib3mf_model_setbuilduuid; + if (sProcName == "lib3mf_model_getbuilditems") + *ppProcAddress = (void*) &lib3mf_model_getbuilditems; + if (sProcName == "lib3mf_model_getoutbox") + *ppProcAddress = (void*) &lib3mf_model_getoutbox; + if (sProcName == "lib3mf_model_getresources") + *ppProcAddress = (void*) &lib3mf_model_getresources; + if (sProcName == "lib3mf_model_getobjects") + *ppProcAddress = (void*) &lib3mf_model_getobjects; + if (sProcName == "lib3mf_model_getmeshobjects") + *ppProcAddress = (void*) &lib3mf_model_getmeshobjects; + if (sProcName == "lib3mf_model_getcomponentsobjects") + *ppProcAddress = (void*) &lib3mf_model_getcomponentsobjects; + if (sProcName == "lib3mf_model_gettexture2ds") + *ppProcAddress = (void*) &lib3mf_model_gettexture2ds; + if (sProcName == "lib3mf_model_getbasematerialgroups") + *ppProcAddress = (void*) &lib3mf_model_getbasematerialgroups; + if (sProcName == "lib3mf_model_getcolorgroups") + *ppProcAddress = (void*) &lib3mf_model_getcolorgroups; + if (sProcName == "lib3mf_model_gettexture2dgroups") + *ppProcAddress = (void*) &lib3mf_model_gettexture2dgroups; + if (sProcName == "lib3mf_model_getcompositematerials") + *ppProcAddress = (void*) &lib3mf_model_getcompositematerials; + if (sProcName == "lib3mf_model_getmultipropertygroups") + *ppProcAddress = (void*) &lib3mf_model_getmultipropertygroups; + if (sProcName == "lib3mf_model_getslicestacks") + *ppProcAddress = (void*) &lib3mf_model_getslicestacks; + if (sProcName == "lib3mf_model_getimage3ds") + *ppProcAddress = (void*) &lib3mf_model_getimage3ds; + if (sProcName == "lib3mf_model_mergetomodel") + *ppProcAddress = (void*) &lib3mf_model_mergetomodel; + if (sProcName == "lib3mf_model_mergefrommodel") + *ppProcAddress = (void*) &lib3mf_model_mergefrommodel; + if (sProcName == "lib3mf_model_addmeshobject") + *ppProcAddress = (void*) &lib3mf_model_addmeshobject; + if (sProcName == "lib3mf_model_addcomponentsobject") + *ppProcAddress = (void*) &lib3mf_model_addcomponentsobject; + if (sProcName == "lib3mf_model_addslicestack") + *ppProcAddress = (void*) &lib3mf_model_addslicestack; + if (sProcName == "lib3mf_model_addtexture2dfromattachment") + *ppProcAddress = (void*) &lib3mf_model_addtexture2dfromattachment; + if (sProcName == "lib3mf_model_addbasematerialgroup") + *ppProcAddress = (void*) &lib3mf_model_addbasematerialgroup; + if (sProcName == "lib3mf_model_addcolorgroup") + *ppProcAddress = (void*) &lib3mf_model_addcolorgroup; + if (sProcName == "lib3mf_model_addtexture2dgroup") + *ppProcAddress = (void*) &lib3mf_model_addtexture2dgroup; + if (sProcName == "lib3mf_model_addcompositematerials") + *ppProcAddress = (void*) &lib3mf_model_addcompositematerials; + if (sProcName == "lib3mf_model_addmultipropertygroup") + *ppProcAddress = (void*) &lib3mf_model_addmultipropertygroup; + if (sProcName == "lib3mf_model_addimagestack") + *ppProcAddress = (void*) &lib3mf_model_addimagestack; + if (sProcName == "lib3mf_model_getimagestackbyid") + *ppProcAddress = (void*) &lib3mf_model_getimagestackbyid; + if (sProcName == "lib3mf_model_addbuilditem") + *ppProcAddress = (void*) &lib3mf_model_addbuilditem; + if (sProcName == "lib3mf_model_removebuilditem") + *ppProcAddress = (void*) &lib3mf_model_removebuilditem; + if (sProcName == "lib3mf_model_getmetadatagroup") + *ppProcAddress = (void*) &lib3mf_model_getmetadatagroup; + if (sProcName == "lib3mf_model_addattachment") + *ppProcAddress = (void*) &lib3mf_model_addattachment; + if (sProcName == "lib3mf_model_removeattachment") + *ppProcAddress = (void*) &lib3mf_model_removeattachment; + if (sProcName == "lib3mf_model_getattachment") + *ppProcAddress = (void*) &lib3mf_model_getattachment; + if (sProcName == "lib3mf_model_findattachment") + *ppProcAddress = (void*) &lib3mf_model_findattachment; + if (sProcName == "lib3mf_model_getattachmentcount") + *ppProcAddress = (void*) &lib3mf_model_getattachmentcount; + if (sProcName == "lib3mf_model_haspackagethumbnailattachment") + *ppProcAddress = (void*) &lib3mf_model_haspackagethumbnailattachment; + if (sProcName == "lib3mf_model_createpackagethumbnailattachment") + *ppProcAddress = (void*) &lib3mf_model_createpackagethumbnailattachment; + if (sProcName == "lib3mf_model_getpackagethumbnailattachment") + *ppProcAddress = (void*) &lib3mf_model_getpackagethumbnailattachment; + if (sProcName == "lib3mf_model_removepackagethumbnailattachment") + *ppProcAddress = (void*) &lib3mf_model_removepackagethumbnailattachment; + if (sProcName == "lib3mf_model_addcustomcontenttype") + *ppProcAddress = (void*) &lib3mf_model_addcustomcontenttype; + if (sProcName == "lib3mf_model_removecustomcontenttype") + *ppProcAddress = (void*) &lib3mf_model_removecustomcontenttype; + if (sProcName == "lib3mf_model_setrandomnumbercallback") + *ppProcAddress = (void*) &lib3mf_model_setrandomnumbercallback; + if (sProcName == "lib3mf_model_getkeystore") + *ppProcAddress = (void*) &lib3mf_model_getkeystore; + if (sProcName == "lib3mf_model_getfunctions") + *ppProcAddress = (void*) &lib3mf_model_getfunctions; + if (sProcName == "lib3mf_model_addimplicitfunction") + *ppProcAddress = (void*) &lib3mf_model_addimplicitfunction; + if (sProcName == "lib3mf_model_addfunctionfromimage3d") + *ppProcAddress = (void*) &lib3mf_model_addfunctionfromimage3d; + if (sProcName == "lib3mf_model_addvolumedata") + *ppProcAddress = (void*) &lib3mf_model_addvolumedata; + if (sProcName == "lib3mf_model_addlevelset") + *ppProcAddress = (void*) &lib3mf_model_addlevelset; + if (sProcName == "lib3mf_model_getlevelsets") + *ppProcAddress = (void*) &lib3mf_model_getlevelsets; + if (sProcName == "lib3mf_model_removeresource") + *ppProcAddress = (void*) &lib3mf_model_removeresource; + if (sProcName == "lib3mf_getlibraryversion") + *ppProcAddress = (void*) &lib3mf_getlibraryversion; + if (sProcName == "lib3mf_getprereleaseinformation") + *ppProcAddress = (void*) &lib3mf_getprereleaseinformation; + if (sProcName == "lib3mf_getbuildinformation") + *ppProcAddress = (void*) &lib3mf_getbuildinformation; + if (sProcName == "lib3mf_getspecificationversion") + *ppProcAddress = (void*) &lib3mf_getspecificationversion; + if (sProcName == "lib3mf_createmodel") + *ppProcAddress = (void*) &lib3mf_createmodel; + if (sProcName == "lib3mf_release") + *ppProcAddress = (void*) &lib3mf_release; + if (sProcName == "lib3mf_acquire") + *ppProcAddress = (void*) &lib3mf_acquire; + if (sProcName == "lib3mf_setjournal") + *ppProcAddress = (void*) &lib3mf_setjournal; + if (sProcName == "lib3mf_getlasterror") + *ppProcAddress = (void*) &lib3mf_getlasterror; + if (sProcName == "lib3mf_getsymbollookupmethod") + *ppProcAddress = (void*) &lib3mf_getsymbollookupmethod; + if (sProcName == "lib3mf_retrieveprogressmessage") + *ppProcAddress = (void*) &lib3mf_retrieveprogressmessage; + if (sProcName == "lib3mf_rgbatocolor") + *ppProcAddress = (void*) &lib3mf_rgbatocolor; + if (sProcName == "lib3mf_floatrgbatocolor") + *ppProcAddress = (void*) &lib3mf_floatrgbatocolor; + if (sProcName == "lib3mf_colortorgba") + *ppProcAddress = (void*) &lib3mf_colortorgba; + if (sProcName == "lib3mf_colortofloatrgba") + *ppProcAddress = (void*) &lib3mf_colortofloatrgba; + if (sProcName == "lib3mf_getidentitytransform") + *ppProcAddress = (void*) &lib3mf_getidentitytransform; + if (sProcName == "lib3mf_getuniformscaletransform") + *ppProcAddress = (void*) &lib3mf_getuniformscaletransform; + if (sProcName == "lib3mf_getscaletransform") + *ppProcAddress = (void*) &lib3mf_getscaletransform; + if (sProcName == "lib3mf_gettranslationtransform") + *ppProcAddress = (void*) &lib3mf_gettranslationtransform; + if (*ppProcAddress == nullptr) + return LIB3MF_ERROR_COULDNOTFINDLIBRARYEXPORT; + return LIB3MF_SUCCESS; } /************************************************************************************************************************* @@ -13112,7 +26044,7 @@ Lib3MFResult lib3mf_getsymbollookupmethod(Lib3MF_pvoid * pSymbolLookupMethod) } if (pSymbolLookupMethod == nullptr) throw ELib3MFInterfaceException (LIB3MF_ERROR_INVALIDPARAM); - *pSymbolLookupMethod = (void*)&_lib3mf_getprocaddress_internal; + *pSymbolLookupMethod = (void*)&Lib3MF::Impl::Lib3MF_GetProcAddress; if (pJournalEntry.get() != nullptr) { pJournalEntry->addPointerResult("SymbolLookupMethod", *pSymbolLookupMethod); pJournalEntry->writeSuccess();