diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..dd84ea782 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..bbcbbe7d6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore index e975976bf..fe59f9a70 100644 --- a/.gitignore +++ b/.gitignore @@ -79,6 +79,12 @@ test/gtest/src/gtest-stamp/Debug/ tools/assimp_view/assimp_viewer.vcxproj.user *.pyc +### Rust ### +# Generated by Cargo; will have compiled files and executables +port/assimp_rs/target/ +# Backup files generated by rustfmt +port/assimp_rs/**/*.rs.bk + # Unix editor backups *~ test/gtest/src/gtest-stamp/gtest-gitinfo.txt diff --git a/INSTALL b/INSTALL index 350a5f109..ecec2585b 100644 --- a/INSTALL +++ b/INSTALL @@ -1,50 +1,50 @@ - -======================================================================== -Open Asset Import Library (assimp) INSTALL -======================================================================== - ------------------------------- -Getting the documentation ------------------------------- - -A regularly-updated copy is available at -http://assimp.sourceforge.net/lib_html/index.html - -A CHM file is included in the SVN repos: ./doc/AssimpDoc_Html/AssimpDoc.chm. -To build the doxygen documentation on your own, follow these steps: - -a) download & install latest doxygen -b) make sure doxygen is in the executable search path -c) navigate to ./doc -d) and run 'doxygen' - -Open the generated HTML (AssimpDoc_Html/index.html) in the browser of your choice. -Windows only: To generate the CHM doc, install 'Microsoft HTML Workshop' -and configure the path to it in the DOXYFILE first. - ------------------------------- -Building Assimp ------------------------------- - -More detailed build instructions can be found in the documentation, -this section is just for the inpatient among you. - -CMake is the preferred build system for Assimp. The minimum required version -is 2.6. If you don't have it yet, downloads for CMake can be found on -http://www.cmake.org/. - -For Unix: - -1. mkdir build && cd build -2. cmake .. -G 'Unix Makefiles' -3. make -j4 - -For Windows: -1. Open a command prompt -2. mkdir build -3. cd build -4. cmake .. -5. cmake --build . - -For iOS: -Just check the following project, which deploys a compiler toolchain for different iOS-versions: https://github.com/assimp/assimp/tree/master/port/iOS + +======================================================================== +Open Asset Import Library (assimp) INSTALL +======================================================================== + +------------------------------ +Getting the documentation +------------------------------ + +A regularly-updated copy is available at +http://assimp.sourceforge.net/lib_html/index.html + +A CHM file is included in the SVN repos: ./doc/AssimpDoc_Html/AssimpDoc.chm. +To build the doxygen documentation on your own, follow these steps: + +a) download & install latest doxygen +b) make sure doxygen is in the executable search path +c) navigate to ./doc +d) and run 'doxygen' + +Open the generated HTML (AssimpDoc_Html/index.html) in the browser of your choice. +Windows only: To generate the CHM doc, install 'Microsoft HTML Workshop' +and configure the path to it in the DOXYFILE first. + +------------------------------ +Building Assimp +------------------------------ + +More detailed build instructions can be found in the documentation, +this section is just for the inpatient among you. + +CMake is the preferred build system for Assimp. The minimum required version +is 2.6. If you don't have it yet, downloads for CMake can be found on +http://www.cmake.org/. + +For Unix: + +1. mkdir build && cd build +2. cmake .. -G 'Unix Makefiles' +3. make -j4 + +For Windows: +1. Open a command prompt +2. mkdir build +3. cd build +4. cmake .. +5. cmake --build . + +For iOS: +Just check the following project, which deploys a compiler toolchain for different iOS-versions: https://github.com/assimp/assimp/tree/master/port/iOS diff --git a/Readme.md b/Readme.md index 15e76b9d2..dc54870a0 100644 --- a/Readme.md +++ b/Readme.md @@ -25,107 +25,12 @@ Additionally, assimp features various __mesh post processing tools__: normals an This is the development repo containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [Github Assimp Releases](https://github.com/assimp/assimp/releases). -Monthly donations via Patreon: -
[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/assimp) - -
- -One-off donations via PayPal: -
[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4) - -
- Please check our Wiki as well: https://github.com/assimp/assimp/wiki If you want to check our Model-Database, use the following repo: https://github.com/assimp/assimp-mdb #### Supported file formats #### - -__Importers__: - -- 3D -- [3DS](https://en.wikipedia.org/wiki/.3ds) -- [3MF](https://en.wikipedia.org/wiki/3D_Manufacturing_Format) -- AC -- [AC3D](https://en.wikipedia.org/wiki/AC3D) -- ACC -- AMJ -- ASE -- ASK -- B3D -- [BLEND](https://en.wikipedia.org/wiki/.blend_(file_format)) -- [BVH](https://en.wikipedia.org/wiki/Biovision_Hierarchy) -- CMS -- COB -- [DAE/Collada](https://en.wikipedia.org/wiki/COLLADA) -- [DXF](https://en.wikipedia.org/wiki/AutoCAD_DXF) -- ENFF -- [FBX](https://en.wikipedia.org/wiki/FBX) -- [glTF 1.0](https://en.wikipedia.org/wiki/GlTF#glTF_1.0) + GLB -- [glTF 2.0](https://en.wikipedia.org/wiki/GlTF#glTF_2.0): - At the moment for glTF2.0 the following extensions are supported: - + KHR_lights_punctual ( 5.0 ) - + KHR_materials_pbrSpecularGlossiness ( 5.0 ) - + KHR_materials_unlit ( 5.0 ) - + KHR_texture_transform ( 5.1 under test ) -- HMB -- IFC-STEP -- IRR / IRRMESH -- [LWO](https://en.wikipedia.org/wiki/LightWave_3D) -- LWS -- LXO -- [M3D](https://bztsrc.gitlab.io/model3d) -- MD2 -- MD3 -- MD5 -- MDC -- MDL -- MESH / MESH.XML -- MOT -- MS3D -- NDO -- NFF -- [OBJ](https://en.wikipedia.org/wiki/Wavefront_.obj_file) -- [OFF](https://en.wikipedia.org/wiki/OFF_(file_format)) -- [OGEX](https://en.wikipedia.org/wiki/Open_Game_Engine_Exchange) -- [PLY](https://en.wikipedia.org/wiki/PLY_(file_format)) -- PMX -- PRJ -- Q3O -- Q3S -- RAW -- SCN -- SIB -- SMD -- [STP](https://en.wikipedia.org/wiki/ISO_10303-21) -- [STL](https://en.wikipedia.org/wiki/STL_(file_format)) -- TER -- UC -- VTA -- X -- [X3D](https://en.wikipedia.org/wiki/X3D) -- XGL -- ZGL - -Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default): - -- [C4D](https://en.wikipedia.org/wiki/Cinema_4D) (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange) IMporting geometry + node hierarchy are currently supported - -__Exporters__: - -- DAE (Collada) -- STL -- OBJ -- PLY -- X -- 3DS -- JSON (for WebGl, via https://github.com/acgessler/assimp2json) -- ASSBIN -- STEP -- glTF 1.0 (partial) -- glTF 2.0 (partial) -- 3MF ( experimental ) -- FBX ( experimental ) +You can find the complete list of supported file-formats [here](https://github.com/assimp/assimp/blob/master/doc/Fileformats.md) ### Building ### Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file. We are available in vcpkg, and our build system is CMake; if you used CMake before there is a good chance you know what to do. @@ -196,6 +101,16 @@ Become a financial contributor and help us sustain our community. [[Contribute]( +Monthly donations via Patreon: +
[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/assimp) + +
+ +One-off donations via PayPal: +
[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4) + +
+ #### Organizations Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/assimp/contribute)] diff --git a/assimpTargets-debug.cmake.in b/assimpTargets-debug.cmake.in index de6459eaf..b7efe71f9 100644 --- a/assimpTargets-debug.cmake.in +++ b/assimpTargets-debug.cmake.in @@ -73,6 +73,9 @@ else() else() set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@") endif() + + # Import target "assimp::assimp" for configuration "Debug" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(assimp::assimp PROPERTIES IMPORTED_SONAME_DEBUG "${sharedLibraryName}" IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" @@ -81,6 +84,9 @@ else() list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" ) else() set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@") + + # Import target "assimp::assimp" for configuration "Debug" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(assimp::assimp PROPERTIES IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" ) diff --git a/assimpTargets-release.cmake.in b/assimpTargets-release.cmake.in index 6a5bafcf7..c716006dd 100644 --- a/assimpTargets-release.cmake.in +++ b/assimpTargets-release.cmake.in @@ -73,6 +73,9 @@ else() else() set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@") endif() + + # Import target "assimp::assimp" for configuration "Release" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(assimp::assimp PROPERTIES IMPORTED_SONAME_RELEASE "${sharedLibraryName}" IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" @@ -81,6 +84,9 @@ else() list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" ) else() set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@") + + # Import target "assimp::assimp" for configuration "Release" + set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(assimp::assimp PROPERTIES IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" ) diff --git a/code/AMF/AMFImporter.cpp b/code/AMF/AMFImporter.cpp new file mode 100644 index 000000000..d93ca54cf --- /dev/null +++ b/code/AMF/AMFImporter.cpp @@ -0,0 +1,707 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +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 +OWNER 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. +--------------------------------------------------------------------------- +*/ + +/// \file AMFImporter.cpp +/// \brief AMF-format files importer for Assimp: main algorithm implementation. +/// \date 2016 +/// \author smal.root@gmail.com + +#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER + +// Header files, Assimp. +#include "AMFImporter.hpp" +#include "AMFImporter_Macro.hpp" + +#include +#include + +// Header files, stdlib. +#include + +namespace Assimp +{ + +/// \var aiImporterDesc AMFImporter::Description +/// Conastant which hold importer description +const aiImporterDesc AMFImporter::Description = { + "Additive manufacturing file format(AMF) Importer", + "smalcom", + "", + "See documentation in source code. Chapter: Limitations.", + aiImporterFlags_SupportTextFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental, + 0, + 0, + 0, + 0, + "amf" +}; + +void AMFImporter::Clear() +{ + mNodeElement_Cur = nullptr; + mUnit.clear(); + mMaterial_Converted.clear(); + mTexture_Converted.clear(); + // Delete all elements + if(!mNodeElement_List.empty()) + { + for(CAMFImporter_NodeElement* ne: mNodeElement_List) { delete ne; } + + mNodeElement_List.clear(); + } +} + +AMFImporter::~AMFImporter() +{ + if(mReader != nullptr) delete mReader; + // Clear() is accounting if data already is deleted. So, just check again if all data is deleted. + Clear(); +} + +/*********************************************************************************************************************************************/ +/************************************************************ Functions: find set ************************************************************/ +/*********************************************************************************************************************************************/ + +bool AMFImporter::Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const +{ + for(CAMFImporter_NodeElement* ne: mNodeElement_List) + { + if((ne->ID == pID) && (ne->Type == pType)) + { + if(pNodeElement != nullptr) *pNodeElement = ne; + + return true; + } + }// for(CAMFImporter_NodeElement* ne: mNodeElement_List) + + return false; +} + +bool AMFImporter::Find_ConvertedNode(const std::string& pID, std::list& pNodeList, aiNode** pNode) const +{ +aiString node_name(pID.c_str()); + + for(aiNode* node: pNodeList) + { + if(node->mName == node_name) + { + if(pNode != nullptr) *pNode = node; + + return true; + } + }// for(aiNode* node: pNodeList) + + return false; +} + +bool AMFImporter::Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const +{ + for(const SPP_Material& mat: mMaterial_Converted) + { + if(mat.ID == pID) + { + if(pConvertedMaterial != nullptr) *pConvertedMaterial = &mat; + + return true; + } + }// for(const SPP_Material& mat: mMaterial_Converted) + + return false; +} + +/*********************************************************************************************************************************************/ +/************************************************************ Functions: throw set ***********************************************************/ +/*********************************************************************************************************************************************/ + +void AMFImporter::Throw_CloseNotFound(const std::string& pNode) +{ + throw DeadlyImportError("Close tag for node <" + pNode + "> not found. Seems file is corrupt."); +} + +void AMFImporter::Throw_IncorrectAttr(const std::string& pAttrName) +{ + throw DeadlyImportError("Node <" + std::string(mReader->getNodeName()) + "> has incorrect attribute \"" + pAttrName + "\"."); +} + +void AMFImporter::Throw_IncorrectAttrValue(const std::string& pAttrName) +{ + throw DeadlyImportError("Attribute \"" + pAttrName + "\" in node <" + std::string(mReader->getNodeName()) + "> has incorrect value."); +} + +void AMFImporter::Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription) +{ + throw DeadlyImportError("\"" + pNodeType + "\" node can be used only once in " + mReader->getNodeName() + ". Description: " + pDescription); +} + +void AMFImporter::Throw_ID_NotFound(const std::string& pID) const +{ + throw DeadlyImportError("Not found node with name \"" + pID + "\"."); +} + +/*********************************************************************************************************************************************/ +/************************************************************* Functions: XML set ************************************************************/ +/*********************************************************************************************************************************************/ + +void AMFImporter::XML_CheckNode_MustHaveChildren() +{ + if(mReader->isEmptyElement()) throw DeadlyImportError(std::string("Node <") + mReader->getNodeName() + "> must have children."); +} + +void AMFImporter::XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName) +{ + static const size_t Uns_Skip_Len = 3; + const char* Uns_Skip[Uns_Skip_Len] = { "composite", "edge", "normal" }; + + static bool skipped_before[Uns_Skip_Len] = { false, false, false }; + + std::string nn(mReader->getNodeName()); + bool found = false; + bool close_found = false; + size_t sk_idx; + + for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++) + { + if(nn != Uns_Skip[sk_idx]) continue; + + found = true; + if(mReader->isEmptyElement()) + { + close_found = true; + + goto casu_cres; + } + + while(mReader->read()) + { + if((mReader->getNodeType() == irr::io::EXN_ELEMENT_END) && (nn == mReader->getNodeName())) + { + close_found = true; + + goto casu_cres; + } + } + }// for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++) + +casu_cres: + + if(!found) throw DeadlyImportError("Unknown node \"" + nn + "\" in " + pParentNodeName + "."); + if(!close_found) Throw_CloseNotFound(nn); + + if(!skipped_before[sk_idx]) + { + skipped_before[sk_idx] = true; + ASSIMP_LOG_WARN_F("Skipping node \"", nn, "\" in ", pParentNodeName, "."); + } +} + +bool AMFImporter::XML_SearchNode(const std::string& pNodeName) +{ + while(mReader->read()) + { + if((mReader->getNodeType() == irr::io::EXN_ELEMENT) && XML_CheckNode_NameEqual(pNodeName)) return true; + } + + return false; +} + +bool AMFImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) +{ + std::string val(mReader->getAttributeValue(pAttrIdx)); + + if((val == "false") || (val == "0")) + return false; + else if((val == "true") || (val == "1")) + return true; + else + throw DeadlyImportError("Bool attribute value can contain \"false\"/\"0\" or \"true\"/\"1\" not the \"" + val + "\""); +} + +float AMFImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) +{ + std::string val; + float tvalf; + + ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), val); + fast_atoreal_move(val.c_str(), tvalf, false); + + return tvalf; +} + +uint32_t AMFImporter::XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx) +{ + return strtoul10(mReader->getAttributeValue(pAttrIdx)); +} + +float AMFImporter::XML_ReadNode_GetVal_AsFloat() +{ + std::string val; + float tvalf; + + if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. No data, seems file is corrupt."); + if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. Invalid type of XML element, seems file is corrupt."); + + ParseHelper_FixTruncatedFloatString(mReader->getNodeData(), val); + fast_atoreal_move(val.c_str(), tvalf, false); + + return tvalf; +} + +uint32_t AMFImporter::XML_ReadNode_GetVal_AsU32() +{ + if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. No data, seems file is corrupt."); + if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. Invalid type of XML element, seems file is corrupt."); + + return strtoul10(mReader->getNodeData()); +} + +void AMFImporter::XML_ReadNode_GetVal_AsString(std::string& pValue) +{ + if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsString. No data, seems file is corrupt."); + if(mReader->getNodeType() != irr::io::EXN_TEXT) + throw DeadlyImportError("XML_ReadNode_GetVal_AsString. Invalid type of XML element, seems file is corrupt."); + + pValue = mReader->getNodeData(); +} + +/*********************************************************************************************************************************************/ +/************************************************************ Functions: parse set ***********************************************************/ +/*********************************************************************************************************************************************/ + +void AMFImporter::ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode) +{ + mNodeElement_Cur->Child.push_back(pNode);// add new element to current element child list. + mNodeElement_Cur = pNode;// switch current element to new one. +} + +void AMFImporter::ParseHelper_Node_Exit() +{ + // check if we can walk up. + if(mNodeElement_Cur != nullptr) mNodeElement_Cur = mNodeElement_Cur->Parent; +} + +void AMFImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString) +{ + size_t instr_len; + + pOutString.clear(); + instr_len = strlen(pInStr); + if(!instr_len) return; + + pOutString.reserve(instr_len * 3 / 2); + // check and correct floats in format ".x". Must be "x.y". + if(pInStr[0] == '.') pOutString.push_back('0'); + + pOutString.push_back(pInStr[0]); + for(size_t ci = 1; ci < instr_len; ci++) + { + if((pInStr[ci] == '.') && ((pInStr[ci - 1] == ' ') || (pInStr[ci - 1] == '-') || (pInStr[ci - 1] == '+') || (pInStr[ci - 1] == '\t'))) + { + pOutString.push_back('0'); + pOutString.push_back('.'); + } + else + { + pOutString.push_back(pInStr[ci]); + } + } +} + +static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) +{ + return (isalnum(pChar) || (pChar == '+') || (pChar == '/')); +} + +void AMFImporter::ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector& pOutputData) const +{ + // With help from + // René Nyffenegger http://www.adp-gmbh.ch/cpp/common/base64.html + const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + uint8_t tidx = 0; + uint8_t arr4[4], arr3[3]; + + // check input data + if(pInputBase64.size() % 4) throw DeadlyImportError("Base64-encoded data must have size multiply of four."); + // prepare output place + pOutputData.clear(); + pOutputData.reserve(pInputBase64.size() / 4 * 3); + + for(size_t in_len = pInputBase64.size(), in_idx = 0; (in_len > 0) && (pInputBase64[in_idx] != '='); in_len--) + { + if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx])) + { + arr4[tidx++] = pInputBase64[in_idx++]; + if(tidx == 4) + { + for(tidx = 0; tidx < 4; tidx++) arr4[tidx] = (uint8_t)base64_chars.find(arr4[tidx]); + + arr3[0] = (arr4[0] << 2) + ((arr4[1] & 0x30) >> 4); + arr3[1] = ((arr4[1] & 0x0F) << 4) + ((arr4[2] & 0x3C) >> 2); + arr3[2] = ((arr4[2] & 0x03) << 6) + arr4[3]; + for(tidx = 0; tidx < 3; tidx++) pOutputData.push_back(arr3[tidx]); + + tidx = 0; + }// if(tidx == 4) + }// if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx])) + else + { + in_idx++; + }// if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx])) else + } + + if(tidx) + { + for(uint8_t i = tidx; i < 4; i++) arr4[i] = 0; + for(uint8_t i = 0; i < 4; i++) arr4[i] = (uint8_t)(base64_chars.find(arr4[i])); + + arr3[0] = (arr4[0] << 2) + ((arr4[1] & 0x30) >> 4); + arr3[1] = ((arr4[1] & 0x0F) << 4) + ((arr4[2] & 0x3C) >> 2); + arr3[2] = ((arr4[2] & 0x03) << 6) + arr4[3]; + for(uint8_t i = 0; i < (tidx - 1); i++) pOutputData.push_back(arr3[i]); + } +} + +void AMFImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler) +{ + irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader. + std::unique_ptr file(pIOHandler->Open(pFile, "rb")); + + // Check whether we can read from the file + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open AMF file " + pFile + "."); + } + + // generate a XML reader for it + std::unique_ptr mIOWrapper(new CIrrXML_IOStreamReader(file.get())); + mReader = irr::io::createIrrXMLReader(mIOWrapper.get()); + if(!mReader) throw DeadlyImportError("Failed to create XML reader for file" + pFile + "."); + // + // start reading + // search for root tag + if(XML_SearchNode("amf")) + ParseNode_Root(); + else + throw DeadlyImportError("Root node \"amf\" not found."); + + delete mReader; + // restore old XMLreader + mReader = OldReader; +} + +// +// +// Root XML element. +// Multi elements - No. +void AMFImporter::ParseNode_Root() +{ + std::string unit, version; + CAMFImporter_NodeElement *ne( nullptr ); + + // Read attributes for node . + MACRO_ATTRREAD_LOOPBEG; + MACRO_ATTRREAD_CHECK_RET("unit", unit, mReader->getAttributeValue); + MACRO_ATTRREAD_CHECK_RET("version", version, mReader->getAttributeValue); + MACRO_ATTRREAD_LOOPEND_WSKIP; + + // Check attributes + if(!mUnit.empty()) + { + if((mUnit != "inch") && (mUnit != "millimeter") && (mUnit != "meter") && (mUnit != "feet") && (mUnit != "micron")) Throw_IncorrectAttrValue("unit"); + } + + // create root node element. + ne = new CAMFImporter_NodeElement_Root(nullptr); + mNodeElement_Cur = ne;// set first "current" element + // and assign attribute's values + ((CAMFImporter_NodeElement_Root*)ne)->Unit = unit; + ((CAMFImporter_NodeElement_Root*)ne)->Version = version; + + // Check for child nodes + if(!mReader->isEmptyElement()) + { + MACRO_NODECHECK_LOOPBEGIN("amf"); + if(XML_CheckNode_NameEqual("object")) { ParseNode_Object(); continue; } + if(XML_CheckNode_NameEqual("material")) { ParseNode_Material(); continue; } + if(XML_CheckNode_NameEqual("texture")) { ParseNode_Texture(); continue; } + if(XML_CheckNode_NameEqual("constellation")) { ParseNode_Constellation(); continue; } + if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } + MACRO_NODECHECK_LOOPEND("amf"); + mNodeElement_Cur = ne;// force restore "current" element + }// if(!mReader->isEmptyElement()) + + mNodeElement_List.push_back(ne);// add to node element list because its a new object in graph. +} + +// +// +// A collection of objects or constellations with specific relative locations. +// Multi elements - Yes. +// Parent element - . +void AMFImporter::ParseNode_Constellation() +{ + std::string id; + CAMFImporter_NodeElement* ne( nullptr ); + + // Read attributes for node . + MACRO_ATTRREAD_LOOPBEG; + MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue); + MACRO_ATTRREAD_LOOPEND; + + // create and if needed - define new grouping object. + ne = new CAMFImporter_NodeElement_Constellation(mNodeElement_Cur); + + CAMFImporter_NodeElement_Constellation& als = *((CAMFImporter_NodeElement_Constellation*)ne);// alias for convenience + + if(!id.empty()) als.ID = id; + // Check for child nodes + if(!mReader->isEmptyElement()) + { + ParseHelper_Node_Enter(ne); + MACRO_NODECHECK_LOOPBEGIN("constellation"); + if(XML_CheckNode_NameEqual("instance")) { ParseNode_Instance(); continue; } + if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } + MACRO_NODECHECK_LOOPEND("constellation"); + ParseHelper_Node_Exit(); + }// if(!mReader->isEmptyElement()) + else + { + mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element + }// if(!mReader->isEmptyElement()) else + + mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. +} + +// +// +// A collection of objects or constellations with specific relative locations. +// Multi elements - Yes. +// Parent element - . +void AMFImporter::ParseNode_Instance() +{ + std::string objectid; + CAMFImporter_NodeElement* ne( nullptr ); + + // Read attributes for node . + MACRO_ATTRREAD_LOOPBEG; + MACRO_ATTRREAD_CHECK_RET("objectid", objectid, mReader->getAttributeValue); + MACRO_ATTRREAD_LOOPEND; + + // used object id must be defined, check that. + if(objectid.empty()) throw DeadlyImportError("\"objectid\" in must be defined."); + // create and define new grouping object. + ne = new CAMFImporter_NodeElement_Instance(mNodeElement_Cur); + + CAMFImporter_NodeElement_Instance& als = *((CAMFImporter_NodeElement_Instance*)ne);// alias for convenience + + als.ObjectID = objectid; + // Check for child nodes + if(!mReader->isEmptyElement()) + { + bool read_flag[6] = { false, false, false, false, false, false }; + + als.Delta.Set(0, 0, 0); + als.Rotation.Set(0, 0, 0); + ParseHelper_Node_Enter(ne); + MACRO_NODECHECK_LOOPBEGIN("instance"); + MACRO_NODECHECK_READCOMP_F("deltax", read_flag[0], als.Delta.x); + MACRO_NODECHECK_READCOMP_F("deltay", read_flag[1], als.Delta.y); + MACRO_NODECHECK_READCOMP_F("deltaz", read_flag[2], als.Delta.z); + MACRO_NODECHECK_READCOMP_F("rx", read_flag[3], als.Rotation.x); + MACRO_NODECHECK_READCOMP_F("ry", read_flag[4], als.Rotation.y); + MACRO_NODECHECK_READCOMP_F("rz", read_flag[5], als.Rotation.z); + MACRO_NODECHECK_LOOPEND("instance"); + ParseHelper_Node_Exit(); + // also convert degrees to radians. + als.Rotation.x = AI_MATH_PI_F * als.Rotation.x / 180.0f; + als.Rotation.y = AI_MATH_PI_F * als.Rotation.y / 180.0f; + als.Rotation.z = AI_MATH_PI_F * als.Rotation.z / 180.0f; + }// if(!mReader->isEmptyElement()) + else + { + mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element + }// if(!mReader->isEmptyElement()) else + + mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. +} + +// +// +// An object definition. +// Multi elements - Yes. +// Parent element - . +void AMFImporter::ParseNode_Object() +{ + std::string id; + CAMFImporter_NodeElement* ne( nullptr ); + + // Read attributes for node . + MACRO_ATTRREAD_LOOPBEG; + MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue); + MACRO_ATTRREAD_LOOPEND; + + // create and if needed - define new geometry object. + ne = new CAMFImporter_NodeElement_Object(mNodeElement_Cur); + + CAMFImporter_NodeElement_Object& als = *((CAMFImporter_NodeElement_Object*)ne);// alias for convenience + + if(!id.empty()) als.ID = id; + // Check for child nodes + if(!mReader->isEmptyElement()) + { + bool col_read = false; + + ParseHelper_Node_Enter(ne); + MACRO_NODECHECK_LOOPBEGIN("object"); + if(XML_CheckNode_NameEqual("color")) + { + // Check if color already defined for object. + if(col_read) Throw_MoreThanOnceDefined("color", "Only one color can be defined for ."); + // read data and set flag about it + ParseNode_Color(); + col_read = true; + + continue; + } + + if(XML_CheckNode_NameEqual("mesh")) { ParseNode_Mesh(); continue; } + if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } + MACRO_NODECHECK_LOOPEND("object"); + ParseHelper_Node_Exit(); + }// if(!mReader->isEmptyElement()) + else + { + mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element + }// if(!mReader->isEmptyElement()) else + + mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. +} + +// +// +// Specify additional information about an entity. +// Multi elements - Yes. +// Parent element - , , , , . +// +// Reserved types are: +// "Name" - The alphanumeric label of the entity, to be used by the interpreter if interacting with the user. +// "Description" - A description of the content of the entity +// "URL" - A link to an external resource relating to the entity +// "Author" - Specifies the name(s) of the author(s) of the entity +// "Company" - Specifying the company generating the entity +// "CAD" - specifies the name of the originating CAD software and version +// "Revision" - specifies the revision of the entity +// "Tolerance" - specifies the desired manufacturing tolerance of the entity in entity's unit system +// "Volume" - specifies the total volume of the entity, in the entity's unit system, to be used for verification (object and volume only) +void AMFImporter::ParseNode_Metadata() +{ + std::string type, value; + CAMFImporter_NodeElement* ne( nullptr ); + + // read attribute + MACRO_ATTRREAD_LOOPBEG; + MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue); + MACRO_ATTRREAD_LOOPEND; + // and value of node. + value = mReader->getNodeData(); + // Create node element and assign read data. + ne = new CAMFImporter_NodeElement_Metadata(mNodeElement_Cur); + ((CAMFImporter_NodeElement_Metadata*)ne)->Type = type; + ((CAMFImporter_NodeElement_Metadata*)ne)->Value = value; + mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element + mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. +} + +/*********************************************************************************************************************************************/ +/******************************************************** Functions: BaseImporter set ********************************************************/ +/*********************************************************************************************************************************************/ + +bool AMFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const +{ + const std::string extension = GetExtension(pFile); + + if ( extension == "amf" ) { + return true; + } + + if(!extension.length() || pCheckSig) + { + const char* tokens[] = { "& pExtensionList) +{ + pExtensionList.insert("amf"); +} + +const aiImporterDesc* AMFImporter::GetInfo () const +{ + return &Description; +} + +void AMFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) +{ + Clear();// delete old graph. + ParseFile(pFile, pIOHandler); + Postprocess_BuildScene(pScene); + // scene graph is ready, exit. +} + +}// namespace Assimp + +#endif // !ASSIMP_BUILD_NO_AMF_IMPORTER diff --git a/code/AssetLib/3DS/3DSConverter.cpp b/code/AssetLib/3DS/3DSConverter.cpp index 1004c74a5..ef37e03de 100644 --- a/code/AssetLib/3DS/3DSConverter.cpp +++ b/code/AssetLib/3DS/3DSConverter.cpp @@ -539,7 +539,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene *pcSOut, aiNode *pcOut, ai_assert(nullptr != anim); if (pcIn->aCameraRollKeys.size() > 1) { - ASSIMP_LOG_DEBUG("3DS: Converting camera roll track ..."); + ASSIMP_LOG_VERBOSE_DEBUG("3DS: Converting camera roll track ..."); // Camera roll keys - in fact they're just rotations // around the camera's z axis. The angles are given @@ -558,7 +558,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene *pcSOut, aiNode *pcOut, #if 0 if (pcIn->aTargetPositionKeys.size() > 1) { - ASSIMP_LOG_DEBUG("3DS: Converting target track ..."); + ASSIMP_LOG_VERBOSE_DEBUG("3DS: Converting target track ..."); // Camera or spot light - need to convert the separate // target position channel to our representation diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp index 5f3d955da..fed96a51f 100644 --- a/code/AssetLib/3DS/3DSExporter.cpp +++ b/code/AssetLib/3DS/3DSExporter.cpp @@ -367,7 +367,7 @@ void Discreet3DSExporter::WriteTexture(const aiMaterial &mat, aiTextureType type aiTextureMapMode_Wrap, aiTextureMapMode_Wrap }; ai_real blend = 1.0; - if (mat.GetTexture(type, 0, &path, NULL, NULL, &blend, NULL, map_mode) != AI_SUCCESS || !path.length) { + if (mat.GetTexture(type, 0, &path, nullptr, nullptr, &blend, nullptr, map_mode) != AI_SUCCESS || !path.length) { return; } diff --git a/code/AssetLib/3DS/3DSHelper.h b/code/AssetLib/3DS/3DSHelper.h index e348c090d..89c15f5f2 100644 --- a/code/AssetLib/3DS/3DSHelper.h +++ b/code/AssetLib/3DS/3DSHelper.h @@ -462,30 +462,28 @@ struct Material { sTexAmbient(other.sTexAmbient), mTwoSided(other.mTwoSided) { // empty - } //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it - Material(Material &&other) AI_NO_EXCEPT : - mName(std::move(other.mName)), - mDiffuse(std::move(other.mDiffuse)), - mSpecularExponent(std::move(other.mSpecularExponent)), - mShininessStrength(std::move(other.mShininessStrength)), - mSpecular(std::move(other.mSpecular)), - mAmbient(std::move(other.mAmbient)), - mShading(std::move(other.mShading)), - mTransparency(std::move(other.mTransparency)), - sTexDiffuse(std::move(other.sTexDiffuse)), - sTexOpacity(std::move(other.sTexOpacity)), - sTexSpecular(std::move(other.sTexSpecular)), - sTexReflective(std::move(other.sTexReflective)), - sTexBump(std::move(other.sTexBump)), - sTexEmissive(std::move(other.sTexEmissive)), - sTexShininess(std::move(other.sTexShininess)), - mBumpHeight(std::move(other.mBumpHeight)), - mEmissive(std::move(other.mEmissive)), - sTexAmbient(std::move(other.sTexAmbient)), - mTwoSided(std::move(other.mTwoSided)) { + Material(Material &&other) AI_NO_EXCEPT : mName(std::move(other.mName)), + mDiffuse(std::move(other.mDiffuse)), + mSpecularExponent(std::move(other.mSpecularExponent)), + mShininessStrength(std::move(other.mShininessStrength)), + mSpecular(std::move(other.mSpecular)), + mAmbient(std::move(other.mAmbient)), + mShading(std::move(other.mShading)), + mTransparency(std::move(other.mTransparency)), + sTexDiffuse(std::move(other.sTexDiffuse)), + sTexOpacity(std::move(other.sTexOpacity)), + sTexSpecular(std::move(other.sTexSpecular)), + sTexReflective(std::move(other.sTexReflective)), + sTexBump(std::move(other.sTexBump)), + sTexEmissive(std::move(other.sTexEmissive)), + sTexShininess(std::move(other.sTexShininess)), + mBumpHeight(std::move(other.mBumpHeight)), + mEmissive(std::move(other.mEmissive)), + sTexAmbient(std::move(other.sTexAmbient)), + mTwoSided(std::move(other.mTwoSided)) { // empty } @@ -615,7 +613,12 @@ struct Node { Node() = delete; explicit Node(const std::string &name) : - mParent(NULL), mName(name), mInstanceNumber(0), mHierarchyPos(0), mHierarchyIndex(0), mInstanceCount(1) { + mParent(nullptr), + mName(name), + mInstanceNumber(0), + mHierarchyPos(0), + mHierarchyIndex(0), + mInstanceCount(1) { aRotationKeys.reserve(20); aPositionKeys.reserve(20); aScalingKeys.reserve(20); diff --git a/code/AssetLib/3MF/D3MFImporter.cpp b/code/AssetLib/3MF/D3MFImporter.cpp index 9fc9a653d..2093e5e9a 100644 --- a/code/AssetLib/3MF/D3MFImporter.cpp +++ b/code/AssetLib/3MF/D3MFImporter.cpp @@ -314,19 +314,19 @@ private: ++buf; comp[1] = *buf; ++buf; - diffuse.r = static_cast(strtol(comp, NULL, 16)) / ai_real(255.0); + diffuse.r = static_cast(strtol(comp, nullptr, 16)) / ai_real(255.0); comp[0] = *buf; ++buf; comp[1] = *buf; ++buf; - diffuse.g = static_cast(strtol(comp, NULL, 16)) / ai_real(255.0); + diffuse.g = static_cast(strtol(comp, nullptr, 16)) / ai_real(255.0); comp[0] = *buf; ++buf; comp[1] = *buf; ++buf; - diffuse.b = static_cast(strtol(comp, NULL, 16)) / ai_real(255.0); + diffuse.b = static_cast(strtol(comp, nullptr, 16)) / ai_real(255.0); if (7 == len) return true; @@ -334,7 +334,7 @@ private: ++buf; comp[1] = *buf; ++buf; - diffuse.a = static_cast(strtol(comp, NULL, 16)) / ai_real(255.0); + diffuse.a = static_cast(strtol(comp, nullptr, 16)) / ai_real(255.0); return true; } diff --git a/code/AssetLib/3MF/D3MFOpcPackage.cpp b/code/AssetLib/3MF/D3MFOpcPackage.cpp index 565790656..e8e1e2f5e 100644 --- a/code/AssetLib/3MF/D3MFOpcPackage.cpp +++ b/code/AssetLib/3MF/D3MFOpcPackage.cpp @@ -45,19 +45,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "D3MFOpcPackage.h" #include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "3MFXmlTags.h" #include #include -#include "3MFXmlTags.h" +#include +#include +#include +#include namespace Assimp { @@ -68,49 +68,45 @@ typedef std::shared_ptr OpcPackageRelationshipPtr; class OpcPackageRelationshipReader { public: - OpcPackageRelationshipReader(XmlReader* xmlReader) { - while(xmlReader->read()) { - if(xmlReader->getNodeType() == irr::io::EXN_ELEMENT && - xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_CONTAINER) - { + OpcPackageRelationshipReader(XmlReader *xmlReader) { + while (xmlReader->read()) { + if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT && + xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_CONTAINER) { ParseRootNode(xmlReader); } } } - void ParseRootNode(XmlReader* xmlReader) - { + void ParseRootNode(XmlReader *xmlReader) { ParseAttributes(xmlReader); - while(xmlReader->read()) - { - if(xmlReader->getNodeType() == irr::io::EXN_ELEMENT && - xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_NODE) - { + while (xmlReader->read()) { + if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT && + xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_NODE) { ParseChildNode(xmlReader); } } } - void ParseAttributes(XmlReader*) { + void ParseAttributes(XmlReader *) { // empty } - bool validateRels( OpcPackageRelationshipPtr &relPtr ) { - if ( relPtr->id.empty() || relPtr->type.empty() || relPtr->target.empty() ) { + bool validateRels(OpcPackageRelationshipPtr &relPtr) { + if (relPtr->id.empty() || relPtr->type.empty() || relPtr->target.empty()) { return false; } return true; } - void ParseChildNode(XmlReader* xmlReader) { + void ParseChildNode(XmlReader *xmlReader) { OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship()); relPtr->id = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_ID.c_str()); relPtr->type = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_TYPE.c_str()); relPtr->target = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_TARGET.c_str()); - if ( validateRels( relPtr ) ) { - m_relationShips.push_back( relPtr ); + if (validateRels(relPtr)) { + m_relationShips.push_back(relPtr); } } @@ -118,51 +114,52 @@ public: }; // ------------------------------------------------------------------------------------------------ -D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile) -: mRootStream(nullptr) -, mZipArchive() { - mZipArchive.reset( new ZipArchiveIOSystem( pIOHandler, rFile ) ); - if(!mZipArchive->isOpen()) { - throw DeadlyImportError("Failed to open file " + rFile+ "."); +D3MFOpcPackage::D3MFOpcPackage(IOSystem *pIOHandler, const std::string &rFile) : + mRootStream(nullptr), mZipArchive() { + mZipArchive.reset(new ZipArchiveIOSystem(pIOHandler, rFile)); + if (!mZipArchive->isOpen()) { + throw DeadlyImportError("Failed to open file " + rFile + "."); } std::vector fileList; mZipArchive->getFileList(fileList); - for (auto& file: fileList) { - if(file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) { - //PkgRelationshipReader pkgRelReader(file, archive); - ai_assert(mZipArchive->Exists(file.c_str())); + for (auto &file : fileList) { + if (file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) { + if (!mZipArchive->Exists(file.c_str())) { + continue; + } IOStream *fileStream = mZipArchive->Open(file.c_str()); - - ai_assert(fileStream != nullptr); + if (nullptr == fileStream) { + ai_assert(fileStream != nullptr); + continue; + } std::string rootFile = ReadPackageRootRelationship(fileStream); - if ( rootFile.size() > 0 && rootFile[ 0 ] == '/' ) { - rootFile = rootFile.substr( 1 ); - if ( rootFile[ 0 ] == '/' ) { + if (rootFile.size() > 0 && rootFile[0] == '/') { + rootFile = rootFile.substr(1); + if (rootFile[0] == '/') { // deal with zip-bug - rootFile = rootFile.substr( 1 ); + rootFile = rootFile.substr(1); } } - ASSIMP_LOG_DEBUG(rootFile); + ASSIMP_LOG_VERBOSE_DEBUG(rootFile); mZipArchive->Close(fileStream); mRootStream = mZipArchive->Open(rootFile.c_str()); - ai_assert( mRootStream != nullptr ); - if ( nullptr == mRootStream ) { - throw DeadlyExportError( "Cannot open root-file in archive : " + rootFile ); + ai_assert(mRootStream != nullptr); + if (nullptr == mRootStream) { + throw DeadlyExportError("Cannot open root-file in archive : " + rootFile); } - } else if( file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) { - ASSIMP_LOG_WARN_F("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES",file); + } else if (file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) { + ASSIMP_LOG_WARN_F("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES", file); } else { - ASSIMP_LOG_WARN_F("Ignored file of unknown type: ",file); + ASSIMP_LOG_WARN_F("Ignored file of unknown type: ", file); } - } } @@ -170,32 +167,32 @@ D3MFOpcPackage::~D3MFOpcPackage() { mZipArchive->Close(mRootStream); } -IOStream* D3MFOpcPackage::RootStream() const { +IOStream *D3MFOpcPackage::RootStream() const { return mRootStream; } static const std::string ModelRef = "3D/3dmodel.model"; bool D3MFOpcPackage::validate() { - if ( nullptr == mRootStream || nullptr == mZipArchive ) { + if (nullptr == mRootStream || nullptr == mZipArchive) { return false; } - return mZipArchive->Exists( ModelRef.c_str() ); + return mZipArchive->Exists(ModelRef.c_str()); } -std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream* stream) { +std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) { std::unique_ptr xmlStream(new CIrrXML_IOStreamReader(stream)); std::unique_ptr xml(irr::io::createIrrXMLReader(xmlStream.get())); OpcPackageRelationshipReader reader(xml.get()); - auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr& rel){ + auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr &rel) { return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE; }); - if ( itr == reader.m_relationShips.end() ) { - throw DeadlyImportError( "Cannot find " + XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE ); + if (itr == reader.m_relationShips.end()) { + throw DeadlyImportError("Cannot find " + XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE); } return (*itr)->target; diff --git a/code/AssetLib/AC/ACLoader.cpp b/code/AssetLib/AC/ACLoader.cpp index 40ff8dc86..ac1631a9b 100644 --- a/code/AssetLib/AC/ACLoader.cpp +++ b/code/AssetLib/AC/ACLoader.cpp @@ -207,7 +207,7 @@ void AC3DImporter::LoadObjectSection(std::vector &objects) { light->mName.length = ::ai_snprintf(light->mName.data, MAXLEN, "ACLight_%i", static_cast(mLights->size()) - 1); obj.name = std::string(light->mName.data); - ASSIMP_LOG_DEBUG("AC3D: Light source encountered"); + ASSIMP_LOG_VERBOSE_DEBUG("AC3D: Light source encountered"); obj.type = Object::Light; } else if (!ASSIMP_strincmp(buffer, "group", 5)) { obj.type = Object::Group; @@ -294,7 +294,7 @@ void AC3DImporter::LoadObjectSection(std::vector &objects) { // example writes no surf chunks if (!Q3DWorkAround) { ASSIMP_LOG_WARN("AC3D: SURF token was expected"); - ASSIMP_LOG_DEBUG("Continuing with Quick3D Workaround enabled"); + ASSIMP_LOG_VERBOSE_DEBUG("Continuing with Quick3D Workaround enabled"); } --buffer; // make sure the line is processed a second time // break; --- see fix notes above @@ -627,7 +627,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object, std::unique_ptr div(Subdivider::Create(Subdivider::CATMULL_CLARKE)); ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: " + object.name); - std::vector cpy(meshes.size() - oldm, NULL); + std::vector cpy(meshes.size() - oldm, nullptr); div->Subdivide(&meshes[oldm], cpy.size(), &cpy.front(), object.subDiv, true); std::copy(cpy.begin(), cpy.end(), meshes.begin() + oldm); diff --git a/code/AssetLib/AMF/AMFImporter.cpp b/code/AssetLib/AMF/AMFImporter.cpp index 3bb18b0ab..0b76b2652 100644 --- a/code/AssetLib/AMF/AMFImporter.cpp +++ b/code/AssetLib/AMF/AMFImporter.cpp @@ -366,7 +366,9 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) { std::unique_ptr file(pIOHandler->Open(pFile, "rb")); // Check whether we can read from the file - if (file.get() == NULL) throw DeadlyImportError("Failed to open AMF file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open AMF file " + pFile + "."); + } // generate a XML reader for it std::unique_ptr mIOWrapper(new CIrrXML_IOStreamReader(file.get())); diff --git a/code/AssetLib/AMF/AMFImporter_Geometry.cpp b/code/AssetLib/AMF/AMFImporter_Geometry.cpp index e9a50b656..45be05df1 100644 --- a/code/AssetLib/AMF/AMFImporter_Geometry.cpp +++ b/code/AssetLib/AMF/AMFImporter_Geometry.cpp @@ -1,4 +1,4 @@ -/* +/* --------------------------------------------------------------------------- Open Asset Import Library (assimp) --------------------------------------------------------------------------- diff --git a/code/AssetLib/AMF/AMFImporter_Macro.hpp b/code/AssetLib/AMF/AMFImporter_Macro.hpp index ec06cb999..5877a62d2 100644 --- a/code/AssetLib/AMF/AMFImporter_Macro.hpp +++ b/code/AssetLib/AMF/AMFImporter_Macro.hpp @@ -1,4 +1,4 @@ -/* +/* --------------------------------------------------------------------------- Open Asset Import Library (assimp) --------------------------------------------------------------------------- diff --git a/code/AssetLib/AMF/AMFImporter_Material.cpp b/code/AssetLib/AMF/AMFImporter_Material.cpp index 64da12dda..7ab5710da 100644 --- a/code/AssetLib/AMF/AMFImporter_Material.cpp +++ b/code/AssetLib/AMF/AMFImporter_Material.cpp @@ -1,4 +1,4 @@ -/* +/* --------------------------------------------------------------------------- Open Asset Import Library (assimp) --------------------------------------------------------------------------- diff --git a/code/AssetLib/AMF/AMFImporter_Node.hpp b/code/AssetLib/AMF/AMFImporter_Node.hpp index b7b7836f3..ea65e106b 100644 --- a/code/AssetLib/AMF/AMFImporter_Node.hpp +++ b/code/AssetLib/AMF/AMFImporter_Node.hpp @@ -1,4 +1,4 @@ -/* +/* --------------------------------------------------------------------------- Open Asset Import Library (assimp) --------------------------------------------------------------------------- diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp index 47b357248..a27767229 100644 --- a/code/AssetLib/ASE/ASELoader.cpp +++ b/code/AssetLib/ASE/ASELoader.cpp @@ -614,7 +614,7 @@ void ASEImporter::AddNodes(const std::vector &nodes, node->mNumChildren++; // What we did is so great, it is at least worth a debug message - ASSIMP_LOG_DEBUG("ASE: Generating separate target node (" + snode->mName + ")"); + ASSIMP_LOG_VERBOSE_DEBUG("ASE: Generating separate target node (" + snode->mName + ")"); } } diff --git a/code/AssetLib/ASE/ASEParser.cpp b/code/AssetLib/ASE/ASEParser.cpp index 09ad2ab1d..c801f53a1 100644 --- a/code/AssetLib/ASE/ASEParser.cpp +++ b/code/AssetLib/ASE/ASEParser.cpp @@ -925,7 +925,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode &mesh) { ASSIMP_LOG_ERROR("ASE: Found target animation channel " "but the node is neither a camera nor a spot light"); - anim = NULL; + anim = nullptr; } else anim = &mesh.mTargetAnim; } @@ -1797,14 +1797,14 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) { } // ------------------------------------------------------------------------------------------------ void Parser::ParseLV4MeshLongTriple(unsigned int *apOut) { - ai_assert(NULL != apOut); + ai_assert(nullptr != apOut); for (unsigned int i = 0; i < 3; ++i) ParseLV4MeshLong(apOut[i]); } // ------------------------------------------------------------------------------------------------ void Parser::ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut) { - ai_assert(NULL != apOut); + ai_assert(nullptr != apOut); // parse the index ParseLV4MeshLong(rIndexOut); @@ -1814,7 +1814,7 @@ void Parser::ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut } // ------------------------------------------------------------------------------------------------ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) { - ai_assert(NULL != apOut); + ai_assert(nullptr != apOut); // parse the index ParseLV4MeshLong(rIndexOut); @@ -1824,7 +1824,7 @@ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) { } // ------------------------------------------------------------------------------------------------ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut) { - ai_assert(NULL != apOut); + ai_assert(nullptr != apOut); for (unsigned int i = 0; i < 3; ++i) ParseLV4MeshFloat(apOut[i]); diff --git a/code/AssetLib/ASE/ASEParser.h b/code/AssetLib/ASE/ASEParser.h index c94c8e3aa..8df75c2dc 100644 --- a/code/AssetLib/ASE/ASEParser.h +++ b/code/AssetLib/ASE/ASEParser.h @@ -40,15 +40,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ - /** @file Defines the helper data structures for importing ASE files */ #ifndef AI_ASEFILEHELPER_H_INC #define AI_ASEFILEHELPER_H_INC // public ASSIMP headers -#include -#include #include +#include +#include #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER @@ -59,27 +58,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ASE is quite similar to 3ds. We can reuse some structures #include "AssetLib/3DS/3DSLoader.h" -namespace Assimp { -namespace ASE { +namespace Assimp { +namespace ASE { using namespace D3DS; // --------------------------------------------------------------------------- /** Helper structure representing an ASE material */ -struct Material : public D3DS::Material -{ +struct Material : public D3DS::Material { //! Default constructor has been deleted Material() = delete; //! Constructor with explicit name - explicit Material(const std::string &name) - : D3DS::Material(name) - , pcInstance(NULL) - , bNeed (false) { + explicit Material(const std::string &name) : + D3DS::Material(name), + pcInstance(nullptr), + bNeed(false) { // empty } - Material(const Material &other) = default; + Material(const Material &other) = default; Material &operator=(const Material &other) { if (this == &other) { @@ -93,19 +91,16 @@ struct Material : public D3DS::Material return *this; } - //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it Material(Material &&other) AI_NO_EXCEPT - : D3DS::Material(std::move(other)) - , avSubMaterials(std::move(other.avSubMaterials)) - , pcInstance(std::move(other.pcInstance)) - , bNeed(std::move(other.bNeed)) - { + : D3DS::Material(std::move(other)), + avSubMaterials(std::move(other.avSubMaterials)), + pcInstance(std::move(other.pcInstance)), + bNeed(std::move(other.bNeed)) { other.pcInstance = nullptr; } - - Material &operator=( Material &&other) AI_NO_EXCEPT { + Material &operator=(Material &&other) AI_NO_EXCEPT { if (this == &other) { return *this; } @@ -121,15 +116,13 @@ struct Material : public D3DS::Material return *this; } - ~Material() {} - //! Contains all sub materials of this material std::vector avSubMaterials; //! aiMaterial object - aiMaterial* pcInstance; + aiMaterial *pcInstance; //! Can we remove this material? bool bNeed; @@ -140,8 +133,8 @@ struct Material : public D3DS::Material struct Face : public FaceWithSmoothingGroup { //! Default constructor. Initializes everything with 0 Face() AI_NO_EXCEPT - : iMaterial(DEFAULT_MATINDEX) - , iFace(0) { + : iMaterial(DEFAULT_MATINDEX), + iFace(0) { // empty } @@ -172,8 +165,8 @@ struct Bone { Bone() = delete; //! Construction from an existing name - explicit Bone( const std::string& name) - : mName(name) { + explicit Bone(const std::string &name) : + mName(name) { // empty } @@ -186,33 +179,34 @@ struct Bone { struct BoneVertex { //! Bone and corresponding vertex weight. //! -1 for unrequired bones .... - std::vector > mBoneWeights; + std::vector> mBoneWeights; }; // --------------------------------------------------------------------------- /** Helper structure to represent an ASE file animation */ struct Animation { enum Type { - TRACK = 0x0, - BEZIER = 0x1, - TCB = 0x2 - } mRotationType, mScalingType, mPositionType; + TRACK = 0x0, + BEZIER = 0x1, + TCB = 0x2 + } mRotationType, + mScalingType, mPositionType; Animation() AI_NO_EXCEPT - : mRotationType (TRACK) - , mScalingType (TRACK) - , mPositionType (TRACK) { + : mRotationType(TRACK), + mScalingType(TRACK), + mPositionType(TRACK) { // empty } //! List of track rotation keyframes - std::vector< aiQuatKey > akeyRotations; + std::vector akeyRotations; //! List of track position keyframes - std::vector< aiVectorKey > akeyPositions; + std::vector akeyPositions; //! List of track scaling keyframes - std::vector< aiVectorKey > akeyScaling; + std::vector akeyScaling; }; // --------------------------------------------------------------------------- @@ -220,7 +214,7 @@ struct Animation { struct InheritanceInfo { //! Default constructor InheritanceInfo() AI_NO_EXCEPT { - for ( size_t i=0; i<3; ++i ) { + for (size_t i = 0; i < 3; ++i) { abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true; } } @@ -239,17 +233,15 @@ struct InheritanceInfo { /** Represents an ASE file node. Base class for mesh, light and cameras */ struct BaseNode { enum Type { - Light, - Camera, - Mesh, + Light, + Camera, + Mesh, Dummy } mType; //! Construction from an existing name - BaseNode(Type _mType, const std::string &name) - : mType (_mType) - , mName (name) - , mProcessed (false) { + BaseNode(Type _mType, const std::string &name) : + mType(_mType), mName(name), mProcessed(false) { // Set mTargetPosition to qnan const ai_real qnan = get_qnan(); mTargetPosition.x = qnan; @@ -289,14 +281,9 @@ struct Mesh : public MeshWithSmoothingGroups, public BaseNode { Mesh() = delete; //! Construction from an existing name - explicit Mesh(const std::string &name) - : BaseNode( BaseNode::Mesh, name ) - , mVertexColors() - , mBoneVertices() - , mBones() - , iMaterialIndex(Face::DEFAULT_MATINDEX) - , bSkip (false) { - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) { + explicit Mesh(const std::string &name) : + BaseNode(BaseNode::Mesh, name), mVertexColors(), mBoneVertices(), mBones(), iMaterialIndex(Face::DEFAULT_MATINDEX), bSkip(false) { + for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c) { this->mNumUVComponents[c] = 2; } } @@ -325,10 +312,8 @@ struct Mesh : public MeshWithSmoothingGroups, public BaseNode { // --------------------------------------------------------------------------- /** Helper structure to represent an ASE light source */ -struct Light : public BaseNode -{ - enum LightType - { +struct Light : public BaseNode { + enum LightType { OMNI, TARGET, FREE, @@ -339,17 +324,13 @@ struct Light : public BaseNode Light() = delete; //! Construction from an existing name - explicit Light(const std::string &name) - : BaseNode (BaseNode::Light, name) - , mLightType (OMNI) - , mColor (1.f,1.f,1.f) - , mIntensity (1.f) // light is white by default - , mAngle (45.f) - , mFalloff (0.f) - { + explicit Light(const std::string &name) : + BaseNode(BaseNode::Light, name), mLightType(OMNI), mColor(1.f, 1.f, 1.f), mIntensity(1.f) // light is white by default + , + mAngle(45.f), + mFalloff(0.f) { } - LightType mLightType; aiColor3D mColor; ai_real mIntensity; @@ -359,10 +340,8 @@ struct Light : public BaseNode // --------------------------------------------------------------------------- /** Helper structure to represent an ASE camera */ -struct Camera : public BaseNode -{ - enum CameraType - { +struct Camera : public BaseNode { + enum CameraType { FREE, TARGET }; @@ -370,18 +349,16 @@ struct Camera : public BaseNode //! Default constructor has been deleted Camera() = delete; - //! Construction from an existing name - explicit Camera(const std::string &name) - : BaseNode (BaseNode::Camera, name) - , mFOV (0.75f) // in radians - , mNear (0.1f) - , mFar (1000.f) // could be zero - , mCameraType (FREE) - { + explicit Camera(const std::string &name) : + BaseNode(BaseNode::Camera, name), mFOV(0.75f) // in radians + , + mNear(0.1f), + mFar(1000.f) // could be zero + , + mCameraType(FREE) { } - ai_real mFOV, mNear, mFar; CameraType mCameraType; }; @@ -391,7 +368,7 @@ struct Camera : public BaseNode struct Dummy : public BaseNode { //! Constructor Dummy() AI_NO_EXCEPT - : BaseNode (BaseNode::Dummy, "DUMMY") { + : BaseNode(BaseNode::Dummy, "DUMMY") { // empty } }; @@ -414,7 +391,6 @@ private: } public: - // ------------------------------------------------------------------- //! Construct a parser from a given input file which is //! guaranteed to be terminated with zero. @@ -422,15 +398,13 @@ public: //! @param fileFormatDefault Assumed file format version. If the //! file format is specified in the file the new value replaces //! the default value. - Parser (const char* szFile, unsigned int fileFormatDefault); + Parser(const char *szFile, unsigned int fileFormatDefault); // ------------------------------------------------------------------- //! Parses the file into the parsers internal representation void Parse(); - private: - // ------------------------------------------------------------------- //! Parse the *SCENE block in a file void ParseLV1SceneBlock(); @@ -446,45 +420,45 @@ private: // ------------------------------------------------------------------- //! Parse a *OBJECT block in a file //! \param mesh Node to be filled - void ParseLV1ObjectBlock(BaseNode& mesh); + void ParseLV1ObjectBlock(BaseNode &mesh); // ------------------------------------------------------------------- //! Parse a *MATERIAL blocks in a material list //! \param mat Material structure to be filled - void ParseLV2MaterialBlock(Material& mat); + void ParseLV2MaterialBlock(Material &mat); // ------------------------------------------------------------------- //! Parse a *NODE_TM block in a file //! \param mesh Node (!) object to be filled - void ParseLV2NodeTransformBlock(BaseNode& mesh); + void ParseLV2NodeTransformBlock(BaseNode &mesh); // ------------------------------------------------------------------- //! Parse a *TM_ANIMATION block in a file //! \param mesh Mesh object to be filled - void ParseLV2AnimationBlock(BaseNode& mesh); - void ParseLV3PosAnimationBlock(ASE::Animation& anim); - void ParseLV3ScaleAnimationBlock(ASE::Animation& anim); - void ParseLV3RotAnimationBlock(ASE::Animation& anim); + void ParseLV2AnimationBlock(BaseNode &mesh); + void ParseLV3PosAnimationBlock(ASE::Animation &anim); + void ParseLV3ScaleAnimationBlock(ASE::Animation &anim); + void ParseLV3RotAnimationBlock(ASE::Animation &anim); // ------------------------------------------------------------------- //! Parse a *MESH block in a file //! \param mesh Mesh object to be filled - void ParseLV2MeshBlock(Mesh& mesh); + void ParseLV2MeshBlock(Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *LIGHT_SETTINGS block in a file //! \param light Light object to be filled - void ParseLV2LightSettingsBlock(Light& light); + void ParseLV2LightSettingsBlock(Light &light); // ------------------------------------------------------------------- //! Parse a *CAMERA_SETTINGS block in a file //! \param cam Camera object to be filled - void ParseLV2CameraSettingsBlock(Camera& cam); + void ParseLV2CameraSettingsBlock(Camera &cam); // ------------------------------------------------------------------- //! Parse the *MAP_XXXXXX blocks in a material //! \param map Texture structure to be filled - void ParseLV3MapBlock(Texture& map); + void ParseLV3MapBlock(Texture &map); // ------------------------------------------------------------------- //! Parse a *MESH_VERTEX_LIST block in a file @@ -493,7 +467,7 @@ private: //! A warning is sent to the logger if the validations fails. //! \param mesh Mesh object to be filled void ParseLV3MeshVertexListBlock( - unsigned int iNumVertices,Mesh& mesh); + unsigned int iNumVertices, Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *MESH_FACE_LIST block in a file @@ -502,7 +476,7 @@ private: //! A warning is sent to the logger if the validations fails. //! \param mesh Mesh object to be filled void ParseLV3MeshFaceListBlock( - unsigned int iNumFaces,Mesh& mesh); + unsigned int iNumFaces, Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *MESH_TVERT_LIST block in a file @@ -512,7 +486,7 @@ private: //! \param mesh Mesh object to be filled //! \param iChannel Output UVW channel void ParseLV3MeshTListBlock( - unsigned int iNumVertices,Mesh& mesh, unsigned int iChannel = 0); + unsigned int iNumVertices, Mesh &mesh, unsigned int iChannel = 0); // ------------------------------------------------------------------- //! Parse a *MESH_TFACELIST block in a file @@ -522,7 +496,7 @@ private: //! \param mesh Mesh object to be filled //! \param iChannel Output UVW channel void ParseLV3MeshTFaceListBlock( - unsigned int iNumFaces,Mesh& mesh, unsigned int iChannel = 0); + unsigned int iNumFaces, Mesh &mesh, unsigned int iChannel = 0); // ------------------------------------------------------------------- //! Parse an additional mapping channel @@ -530,7 +504,7 @@ private: //! \param iChannel Channel index to be filled //! \param mesh Mesh object to be filled void ParseLV3MappingChannel( - unsigned int iChannel, Mesh& mesh); + unsigned int iChannel, Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *MESH_CVERTLIST block in a file @@ -539,7 +513,7 @@ private: //! A warning is sent to the logger if the validations fails. //! \param mesh Mesh object to be filled void ParseLV3MeshCListBlock( - unsigned int iNumVertices, Mesh& mesh); + unsigned int iNumVertices, Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *MESH_CFACELIST block in a file @@ -548,70 +522,70 @@ private: //! A warning is sent to the logger if the validations fails. //! \param mesh Mesh object to be filled void ParseLV3MeshCFaceListBlock( - unsigned int iNumFaces, Mesh& mesh); + unsigned int iNumFaces, Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *MESH_NORMALS block in a file //! \param mesh Mesh object to be filled - void ParseLV3MeshNormalListBlock(Mesh& mesh); + void ParseLV3MeshNormalListBlock(Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *MESH_WEIGHTSblock in a file //! \param mesh Mesh object to be filled - void ParseLV3MeshWeightsBlock(Mesh& mesh); + void ParseLV3MeshWeightsBlock(Mesh &mesh); // ------------------------------------------------------------------- //! Parse the bone list of a file //! \param mesh Mesh object to be filled //! \param iNumBones Number of bones in the mesh - void ParseLV4MeshBones(unsigned int iNumBones,Mesh& mesh); + void ParseLV4MeshBones(unsigned int iNumBones, Mesh &mesh); // ------------------------------------------------------------------- //! Parse the bone vertices list of a file //! \param mesh Mesh object to be filled //! \param iNumVertices Number of vertices to be parsed - void ParseLV4MeshBonesVertices(unsigned int iNumVertices,Mesh& mesh); + void ParseLV4MeshBonesVertices(unsigned int iNumVertices, Mesh &mesh); // ------------------------------------------------------------------- //! Parse a *MESH_FACE block in a file //! \param out receive the face data - void ParseLV4MeshFace(ASE::Face& out); + void ParseLV4MeshFace(ASE::Face &out); // ------------------------------------------------------------------- //! Parse a *MESH_VERT block in a file //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...) //! \param apOut Output buffer (3 floats) //! \param rIndexOut Output index - void ParseLV4MeshFloatTriple(ai_real* apOut, unsigned int& rIndexOut); + void ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut); // ------------------------------------------------------------------- //! Parse a *MESH_VERT block in a file //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...) //! \param apOut Output buffer (3 floats) - void ParseLV4MeshFloatTriple(ai_real* apOut); + void ParseLV4MeshFloatTriple(ai_real *apOut); // ------------------------------------------------------------------- //! Parse a *MESH_TFACE block in a file //! (also works for MESH_CFACE) //! \param apOut Output buffer (3 ints) //! \param rIndexOut Output index - void ParseLV4MeshLongTriple(unsigned int* apOut, unsigned int& rIndexOut); + void ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut); // ------------------------------------------------------------------- //! Parse a *MESH_TFACE block in a file //! (also works for MESH_CFACE) //! \param apOut Output buffer (3 ints) - void ParseLV4MeshLongTriple(unsigned int* apOut); + void ParseLV4MeshLongTriple(unsigned int *apOut); // ------------------------------------------------------------------- //! Parse a single float element //! \param fOut Output float - void ParseLV4MeshFloat(ai_real& fOut); + void ParseLV4MeshFloat(ai_real &fOut); // ------------------------------------------------------------------- //! Parse a single int element //! \param iOut Output integer - void ParseLV4MeshLong(unsigned int& iOut); + void ParseLV4MeshLong(unsigned int &iOut); // ------------------------------------------------------------------- //! Skip everything to the next: '*' or '\0' @@ -625,17 +599,17 @@ private: // ------------------------------------------------------------------- //! Output a warning to the logger //! \param szWarn Warn message - void LogWarning(const char* szWarn); + void LogWarning(const char *szWarn); // ------------------------------------------------------------------- //! Output a message to the logger //! \param szWarn Message - void LogInfo(const char* szWarn); + void LogInfo(const char *szWarn); // ------------------------------------------------------------------- //! Output an error to the logger //! \param szWarn Error message - AI_WONT_RETURN void LogError(const char* szWarn) AI_WONT_RETURN_SUFFIX; + AI_WONT_RETURN void LogError(const char *szWarn) AI_WONT_RETURN_SUFFIX; // ------------------------------------------------------------------- //! Parse a string, enclosed in double quotation marks @@ -643,12 +617,11 @@ private: //! \param szName Name of the enclosing element -> used in error //! messages. //! \return false if an error occurred - bool ParseString(std::string& out,const char* szName); + bool ParseString(std::string &out, const char *szName); public: - //! Pointer to current data - const char* filePtr; + const char *filePtr; //! background color to be passed to the viewer //! QNAN if none was found @@ -695,9 +668,8 @@ public: unsigned int iFileFormat; }; - } // Namespace ASE -} // Namespace ASSIMP +} // namespace Assimp #endif // ASSIMP_BUILD_NO_3DS_IMPORTER diff --git a/code/AssetLib/Assbin/AssbinFileWriter.cpp b/code/AssetLib/Assbin/AssbinFileWriter.cpp index 431be4d3a..a879e637c 100644 --- a/code/AssetLib/Assbin/AssbinFileWriter.cpp +++ b/code/AssetLib/Assbin/AssbinFileWriter.cpp @@ -336,7 +336,7 @@ protected: void WriteBinaryNode(IOStream *container, const aiNode *node) { AssbinChunkWriter chunk(container, ASSBIN_CHUNK_AINODE); - unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0); + unsigned int nb_metadata = (node->mMetaData != nullptr ? node->mMetaData->mNumProperties : 0); Write(&chunk, node->mName); Write(&chunk, node->mTransformation); @@ -744,7 +744,7 @@ public: }; try { - time_t tt = time(NULL); + time_t tt = time(nullptr); #if _WIN32 tm *p = gmtime(&tt); #else @@ -790,7 +790,7 @@ public: // Up to here the data is uncompressed. For compressed files, the rest // is compressed using standard DEFLATE from zlib. if (compressed) { - AssbinChunkWriter uncompressedStream(NULL, 0); + AssbinChunkWriter uncompressedStream(nullptr, 0); WriteBinaryScene(&uncompressedStream, pScene); uLongf uncompressedSize = static_cast(uncompressedStream.Tell()); diff --git a/code/AssetLib/Assbin/AssbinLoader.cpp b/code/AssetLib/Assbin/AssbinLoader.cpp index 5ee87e952..34021575c 100644 --- a/code/AssetLib/Assbin/AssbinLoader.cpp +++ b/code/AssetLib/Assbin/AssbinLoader.cpp @@ -604,7 +604,7 @@ void AssbinImporter::ReadBinaryScene(IOStream *stream, aiScene *scene) { // Read node graph //scene->mRootNode = new aiNode[1]; - ReadBinaryNode(stream, &scene->mRootNode, (aiNode *)NULL); + ReadBinaryNode(stream, &scene->mRootNode, (aiNode *)nullptr); // Read all meshes if (scene->mNumMeshes) { diff --git a/code/AssetLib/Assxml/AssxmlFileWriter.cpp b/code/AssetLib/Assxml/AssxmlFileWriter.cpp index b175265b5..05661d3fc 100644 --- a/code/AssetLib/Assxml/AssxmlFileWriter.cpp +++ b/code/AssetLib/Assxml/AssxmlFileWriter.cpp @@ -189,7 +189,7 @@ static std::string encodeXML(const std::string &data) { // ----------------------------------------------------------------------------------- // Write a text model dump static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene, IOStream *io, bool shortened) { - time_t tt = ::time(NULL); + time_t tt = ::time(nullptr); #if _WIN32 tm *p = gmtime(&tt); #else diff --git a/code/AssetLib/BVH/BVHLoader.cpp b/code/AssetLib/BVH/BVHLoader.cpp index 9c22879d2..46afc5e64 100644 --- a/code/AssetLib/BVH/BVHLoader.cpp +++ b/code/AssetLib/BVH/BVHLoader.cpp @@ -422,9 +422,9 @@ void BVHLoader::CreateAnimation(aiScene *pScene) { anim->mNumChannels = static_cast(mNodes.size()); anim->mChannels = new aiNodeAnim *[anim->mNumChannels]; - // FIX: set the array elements to NULL to ensure proper deletion if an exception is thrown + // FIX: set the array elements to nullptr to ensure proper deletion if an exception is thrown for (unsigned int i = 0; i < anim->mNumChannels; ++i) - anim->mChannels[i] = NULL; + anim->mChannels[i] = nullptr; for (unsigned int a = 0; a < anim->mNumChannels; a++) { const Node &node = mNodes[a]; @@ -493,37 +493,30 @@ void BVHLoader::CreateAnimation(aiScene *pScene) { for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) { aiMatrix4x4 temp; aiMatrix3x3 rotMatrix; - for (BVHLoader::ChannelType channel = Channel_RotationX; channel <= Channel_RotationZ; channel = (BVHLoader::ChannelType)(channel + 1)) { - //Find channel in node - std::map::iterator mapIter = channelMap.find(channel); - - if (mapIter == channelMap.end()) - throw DeadlyImportError("Missing rotation channel in node " + nodeName); - else { - int channelIdx = mapIter->second; - // translate ZXY euler angels into a quaternion + for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++ channelIdx) { + switch (node.mChannels[channelIdx]) { + case Channel_RotationX: + { const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; - - // Compute rotation transformations in the right order - switch (channel) { - case Channel_RotationX: - aiMatrix4x4::RotationX(angle, temp); - rotMatrix *= aiMatrix3x3(temp); - break; - case Channel_RotationY: - aiMatrix4x4::RotationY(angle, temp); - rotMatrix *= aiMatrix3x3(temp); - break; - case Channel_RotationZ: - aiMatrix4x4::RotationZ(angle, temp); - rotMatrix *= aiMatrix3x3(temp); - break; - default: - break; + aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp); } - } - } - + break; + case Channel_RotationY: + { + const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; + aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp); + } + break; + case Channel_RotationZ: + { + const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; + aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp); + } + break; + default: + break; + } + } rotkey->mTime = double(fr); rotkey->mValue = aiQuaternion(rotMatrix); ++rotkey; diff --git a/code/AssetLib/Blender/BlenderDNA.cpp b/code/AssetLib/Blender/BlenderDNA.cpp index 69f139ec5..920362f24 100644 --- a/code/AssetLib/Blender/BlenderDNA.cpp +++ b/code/AssetLib/Blender/BlenderDNA.cpp @@ -353,7 +353,7 @@ void SectionParser ::Next() { } #ifdef ASSIMP_BUILD_BLENDER_DEBUG - ASSIMP_LOG_DEBUG(current.id); + ASSIMP_LOG_VERBOSE_DEBUG(current.id); #endif } diff --git a/code/AssetLib/Blender/BlenderDNA.h b/code/AssetLib/Blender/BlenderDNA.h index 7e04bad19..c89b21434 100644 --- a/code/AssetLib/Blender/BlenderDNA.h +++ b/code/AssetLib/Blender/BlenderDNA.h @@ -230,7 +230,7 @@ public: // -------------------------------------------------------- /** Access a field of the structure by its canonical name. The pointer version - * returns NULL on failure while the reference version raises an import error. */ + * returns nullptr on failure while the reference version raises an import error. */ inline const Field &operator[](const std::string &ss) const; inline const Field *Get(const std::string &ss) const; @@ -359,7 +359,7 @@ private: template T *_allocate(vector &out, size_t &s) const { out.resize(s); - return s ? &out.front() : NULL; + return s ? &out.front() : nullptr; } // -------------------------------------------------------- @@ -367,14 +367,14 @@ private: struct _defaultInitializer { template - void operator()(T (&out)[N], const char * = NULL) { + void operator()(T (&out)[N], const char * = nullptr) { for (unsigned int i = 0; i < N; ++i) { out[i] = T(); } } template - void operator()(T (&out)[N][M], const char * = NULL) { + void operator()(T (&out)[N][M], const char * = nullptr) { for (unsigned int i = 0; i < N; ++i) { for (unsigned int j = 0; j < M; ++j) { out[i][j] = T(); @@ -383,7 +383,7 @@ private: } template - void operator()(T &out, const char * = NULL) { + void operator()(T &out, const char * = nullptr) { out = T(); } }; @@ -448,7 +448,7 @@ public: public: // -------------------------------------------------------- - /** Access a structure by its canonical name, the pointer version returns NULL on failure + /** Access a structure by its canonical name, the pointer version returns nullptr on failure * while the reference version raises an error. */ inline const Structure &operator[](const std::string &ss) const; inline const Structure *Get(const std::string &ss) const; diff --git a/code/AssetLib/Blender/BlenderDNA.inl b/code/AssetLib/Blender/BlenderDNA.inl index a41ceab7f..7bb9d586a 100644 --- a/code/AssetLib/Blender/BlenderDNA.inl +++ b/code/AssetLib/Blender/BlenderDNA.inl @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -70,7 +69,7 @@ const Field& Structure :: operator [] (const std::string& ss) const const Field* Structure :: Get (const std::string& ss) const { std::map::const_iterator it = indices.find(ss); - return it == indices.end() ? NULL : &fields[(*it).second]; + return it == indices.end() ? nullptr : &fields[(*it).second]; } //-------------------------------------------------------------------------------- @@ -239,11 +238,13 @@ bool Structure :: ReadFieldPtr(TOUT (&out)[N], const char* name, try { f = &(*this)[name]; +#ifdef _DEBUG // sanity check, should never happen if the genblenddna script is right if ((FieldFlag_Pointer|FieldFlag_Pointer) != (f->flags & (FieldFlag_Pointer|FieldFlag_Pointer))) { throw Error((Formatter::format(),"Field `",name,"` of structure `", this->name,"` ought to be a pointer AND an array")); } +#endif // _DEBUG db.reader->IncPtr(f->offset); diff --git a/code/AssetLib/Blender/BlenderLoader.cpp b/code/AssetLib/Blender/BlenderLoader.cpp index 06ae79cd2..508db8422 100644 --- a/code/AssetLib/Blender/BlenderLoader.cpp +++ b/code/AssetLib/Blender/BlenderLoader.cpp @@ -45,43 +45,41 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of the Blender3D importer class. */ - //#define ASSIMP_BUILD_NO_COMPRESSED_BLEND // Uncomment this to disable support for (gzip)compressed .BLEND files #ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER -#include "BlenderIntermediate.h" -#include "BlenderModifier.h" #include "BlenderBMesh.h" #include "BlenderCustomData.h" +#include "BlenderIntermediate.h" +#include "BlenderModifier.h" #include -#include #include +#include -#include -#include #include +#include +#include #include - // zlib is needed for compressed blend files #ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND -# ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -# else -# include "../contrib/zlib/zlib.h" -# endif +#ifdef ASSIMP_BUILD_NO_OWN_ZLIB +#include +#else +#include "../contrib/zlib/zlib.h" +#endif #endif namespace Assimp { - template<> const char* LogFunctions::Prefix() - { - static auto prefix = "BLEND: "; - return prefix; - } +template <> +const char *LogFunctions::Prefix() { + static auto prefix = "BLEND: "; + return prefix; } +} // namespace Assimp using namespace Assimp; using namespace Assimp::Blender; @@ -100,81 +98,72 @@ static const aiImporterDesc blenderDesc = { "blend" }; - // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -BlenderImporter::BlenderImporter() -: modifier_cache(new BlenderModifierShowcase()) { +BlenderImporter::BlenderImporter() : + modifier_cache(new BlenderModifierShowcase()) { // empty } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -BlenderImporter::~BlenderImporter() -{ +BlenderImporter::~BlenderImporter() { delete modifier_cache; } -static const char* Tokens[] = { "BLENDER" }; -static const char* TokensForSearch[] = { "blender" }; +static const char *Tokens[] = { "BLENDER" }; +static const char *TokensForSearch[] = { "blender" }; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool BlenderImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ - const std::string& extension = GetExtension(pFile); +bool BlenderImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { + const std::string &extension = GetExtension(pFile); if (extension == "blend") { return true; } - else if ((!extension.length() || checkSig) && pIOHandler) { + else if ((!extension.length() || checkSig) && pIOHandler) { // note: this won't catch compressed files - return SearchFileHeaderForToken(pIOHandler,pFile, TokensForSearch,1); + return SearchFileHeaderForToken(pIOHandler, pFile, TokensForSearch, 1); } return false; } // ------------------------------------------------------------------------------------------------ // List all extensions handled by this loader -void BlenderImporter::GetExtensionList(std::set& app) -{ +void BlenderImporter::GetExtensionList(std::set &app) { app.insert("blend"); } // ------------------------------------------------------------------------------------------------ // Loader registry entry -const aiImporterDesc* BlenderImporter::GetInfo () const -{ +const aiImporterDesc *BlenderImporter::GetInfo() const { return &blenderDesc; } // ------------------------------------------------------------------------------------------------ // Setup configuration properties for the loader -void BlenderImporter::SetupProperties(const Importer* /*pImp*/) -{ +void BlenderImporter::SetupProperties(const Importer * /*pImp*/) { // nothing to be done for the moment } - // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void BlenderImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ +void BlenderImporter::InternReadFile(const std::string &pFile, + aiScene *pScene, IOSystem *pIOHandler) { #ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND std::vector uncompressed; #endif - FileDatabase file; - std::shared_ptr stream(pIOHandler->Open(pFile,"rb")); + std::shared_ptr stream(pIOHandler->Open(pFile, "rb")); if (!stream) { ThrowException("Could not open file for reading"); } - char magic[8] = {0}; - stream->Read(magic,7,1); - if (strcmp(magic, Tokens[0] )) { + char magic[8] = { 0 }; + stream->Read(magic, 7, 1); + if (strcmp(magic, Tokens[0])) { // Check for presence of the gzip header. If yes, assume it is a // compressed blend file and try uncompressing it, else fail. This is to // avoid uncompressing random files which our loader might end up with. @@ -192,21 +181,21 @@ void BlenderImporter::InternReadFile( const std::string& pFile, } // http://www.gzip.org/zlib/rfc-gzip.html#header-trailer - stream->Seek(0L,aiOrigin_SET); + stream->Seek(0L, aiOrigin_SET); std::shared_ptr reader = std::shared_ptr(new StreamReaderLE(stream)); // build a zlib stream z_stream zstream; zstream.opaque = Z_NULL; zstream.zalloc = Z_NULL; - zstream.zfree = Z_NULL; + zstream.zfree = Z_NULL; zstream.data_type = Z_BINARY; // http://hewgill.com/journal/entries/349-how-to-decompress-gzip-stream-with-zlib - inflateInit2(&zstream, 16+MAX_WBITS); + inflateInit2(&zstream, 16 + MAX_WBITS); - zstream.next_in = reinterpret_cast( reader->GetPtr() ); - zstream.avail_in = (uInt) reader->GetRemainingSize(); + zstream.next_in = reinterpret_cast(reader->GetPtr()); + zstream.avail_in = (uInt)reader->GetRemainingSize(); size_t total = 0l; @@ -226,62 +215,59 @@ void BlenderImporter::InternReadFile( const std::string& pFile, const size_t have = MYBLOCK - zstream.avail_out; total += have; uncompressed.resize(total); - memcpy(uncompressed.data() + total - have,block,have); - } - while (ret != Z_STREAM_END); + memcpy(uncompressed.data() + total - have, block, have); + } while (ret != Z_STREAM_END); // terminate zlib inflateEnd(&zstream); // replace the input stream with a memory stream - stream.reset(new MemoryIOStream(reinterpret_cast(uncompressed.data()),total)); + stream.reset(new MemoryIOStream(reinterpret_cast(uncompressed.data()), total)); // .. and retry - stream->Read(magic,7,1); - if (strcmp(magic,"BLENDER")) { + stream->Read(magic, 7, 1); + if (strcmp(magic, "BLENDER")) { ThrowException("Found no BLENDER magic word in decompressed GZIP file"); } #endif } - file.i64bit = (stream->Read(magic,1,1),magic[0]=='-'); - file.little = (stream->Read(magic,1,1),magic[0]=='v'); + file.i64bit = (stream->Read(magic, 1, 1), magic[0] == '-'); + file.little = (stream->Read(magic, 1, 1), magic[0] == 'v'); - stream->Read(magic,3,1); + stream->Read(magic, 3, 1); magic[3] = '\0'; - LogInfo((format(),"Blender version is ",magic[0],".",magic+1, - " (64bit: ",file.i64bit?"true":"false", - ", little endian: ",file.little?"true":"false",")" - )); + LogInfo((format(), "Blender version is ", magic[0], ".", magic + 1, + " (64bit: ", file.i64bit ? "true" : "false", + ", little endian: ", file.little ? "true" : "false", ")")); - ParseBlendFile(file,stream); + ParseBlendFile(file, stream); Scene scene; - ExtractScene(scene,file); + ExtractScene(scene, file); - ConvertBlendFile(pScene,scene,file); + ConvertBlendFile(pScene, scene, file); } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::ParseBlendFile(FileDatabase& out, std::shared_ptr stream) -{ - out.reader = std::shared_ptr(new StreamReaderAny(stream,out.little)); +void BlenderImporter::ParseBlendFile(FileDatabase &out, std::shared_ptr stream) { + out.reader = std::shared_ptr(new StreamReaderAny(stream, out.little)); DNAParser dna_reader(out); - const DNA* dna = NULL; + const DNA *dna = nullptr; - out.entries.reserve(128); { // even small BLEND files tend to consist of many file blocks - SectionParser parser(*out.reader.get(),out.i64bit); + out.entries.reserve(128); + { // even small BLEND files tend to consist of many file blocks + SectionParser parser(*out.reader.get(), out.i64bit); // first parse the file in search for the DNA and insert all other sections into the database - while ((parser.Next(),1)) { - const FileBlockHead& head = parser.GetCurrent(); + while ((parser.Next(), 1)) { + const FileBlockHead &head = parser.GetCurrent(); if (head.id == "ENDB") { break; // only valid end of the file - } - else if (head.id == "DNA1") { + } else if (head.id == "DNA1") { dna_reader.Parse(); dna = &dna_reader.GetDNA(); continue; @@ -294,22 +280,21 @@ void BlenderImporter::ParseBlendFile(FileDatabase& out, std::shared_ptr::const_iterator it = file.dna.indices.find("Scene"); +void BlenderImporter::ExtractScene(Scene &out, const FileDatabase &file) { + const FileBlockHead *block = nullptr; + std::map::const_iterator it = file.dna.indices.find("Scene"); if (it == file.dna.indices.end()) { ThrowException("There is no `Scene` structure record"); } - const Structure& ss = file.dna.structures[(*it).second]; + const Structure &ss = file.dna.structures[(*it).second]; // we need a scene somewhere to start with. - for(const FileBlockHead& bl :file.entries) { + for (const FileBlockHead &bl : file.entries) { // Fix: using the DNA index is more reliable to locate scenes //if (bl.id == "SC") { @@ -325,39 +310,37 @@ void BlenderImporter::ExtractScene(Scene& out, const FileDatabase& file) } file.reader->SetCurrentPos(block->start); - ss.Convert(out,file); + ss.Convert(out, file); #ifndef ASSIMP_BUILD_BLENDER_NO_STATS ASSIMP_LOG_INFO_F( - "(Stats) Fields read: " ,file.stats().fields_read, - ", pointers resolved: " ,file.stats().pointers_resolved, - ", cache hits: " ,file.stats().cache_hits, - ", cached objects: " ,file.stats().cached_objects - ); + "(Stats) Fields read: ", file.stats().fields_read, + ", pointers resolved: ", file.stats().pointers_resolved, + ", cache hits: ", file.stats().cache_hits, + ", cached objects: ", file.stats().cached_objects); #endif } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::ConvertBlendFile(aiScene* out, const Scene& in,const FileDatabase& file) -{ +void BlenderImporter::ConvertBlendFile(aiScene *out, const Scene &in, const FileDatabase &file) { ConversionData conv(file); // FIXME it must be possible to take the hierarchy directly from // the file. This is terrible. Here, we're first looking for // all objects which don't have parent objects at all - - std::deque no_parents; - for (std::shared_ptr cur = std::static_pointer_cast ( in.base.first ); cur; cur = cur->next) { + std::deque no_parents; + for (std::shared_ptr cur = std::static_pointer_cast(in.base.first); cur; cur = cur->next) { if (cur->object) { - if(!cur->object->parent) { + if (!cur->object->parent) { no_parents.push_back(cur->object.get()); } else { - conv.objects.insert( cur->object.get() ); + conv.objects.insert(cur->object.get()); } } } for (std::shared_ptr cur = in.basact; cur; cur = cur->next) { if (cur->object) { - if(cur->object->parent) { + if (cur->object->parent) { conv.objects.insert(cur->object.get()); } } @@ -367,10 +350,10 @@ void BlenderImporter::ConvertBlendFile(aiScene* out, const Scene& in,const FileD ThrowException("Expected at least one object with no parent"); } - aiNode* root = out->mRootNode = new aiNode(""); + aiNode *root = out->mRootNode = new aiNode(""); root->mNumChildren = static_cast(no_parents.size()); - root->mChildren = new aiNode*[root->mNumChildren](); + root->mChildren = new aiNode *[root->mNumChildren](); for (unsigned int i = 0; i < root->mNumChildren; ++i) { root->mChildren[i] = ConvertNode(in, no_parents[i], conv, aiMatrix4x4()); root->mChildren[i]->mParent = root; @@ -379,32 +362,32 @@ void BlenderImporter::ConvertBlendFile(aiScene* out, const Scene& in,const FileD BuildMaterials(conv); if (conv.meshes->size()) { - out->mMeshes = new aiMesh*[out->mNumMeshes = static_cast( conv.meshes->size() )]; - std::copy(conv.meshes->begin(),conv.meshes->end(),out->mMeshes); + out->mMeshes = new aiMesh *[out->mNumMeshes = static_cast(conv.meshes->size())]; + std::copy(conv.meshes->begin(), conv.meshes->end(), out->mMeshes); conv.meshes.dismiss(); } if (conv.lights->size()) { - out->mLights = new aiLight*[out->mNumLights = static_cast( conv.lights->size() )]; - std::copy(conv.lights->begin(),conv.lights->end(),out->mLights); + out->mLights = new aiLight *[out->mNumLights = static_cast(conv.lights->size())]; + std::copy(conv.lights->begin(), conv.lights->end(), out->mLights); conv.lights.dismiss(); } if (conv.cameras->size()) { - out->mCameras = new aiCamera*[out->mNumCameras = static_cast( conv.cameras->size() )]; - std::copy(conv.cameras->begin(),conv.cameras->end(),out->mCameras); + out->mCameras = new aiCamera *[out->mNumCameras = static_cast(conv.cameras->size())]; + std::copy(conv.cameras->begin(), conv.cameras->end(), out->mCameras); conv.cameras.dismiss(); } if (conv.materials->size()) { - out->mMaterials = new aiMaterial*[out->mNumMaterials = static_cast( conv.materials->size() )]; - std::copy(conv.materials->begin(),conv.materials->end(),out->mMaterials); + out->mMaterials = new aiMaterial *[out->mNumMaterials = static_cast(conv.materials->size())]; + std::copy(conv.materials->begin(), conv.materials->end(), out->mMaterials); conv.materials.dismiss(); } if (conv.textures->size()) { - out->mTextures = new aiTexture*[out->mNumTextures = static_cast( conv.textures->size() )]; - std::copy(conv.textures->begin(),conv.textures->end(),out->mTextures); + out->mTextures = new aiTexture *[out->mNumTextures = static_cast(conv.textures->size())]; + std::copy(conv.textures->begin(), conv.textures->end(), out->mTextures); conv.textures.dismiss(); } @@ -418,24 +401,25 @@ void BlenderImporter::ConvertBlendFile(aiScene* out, const Scene& in,const FileD } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::ResolveImage(aiMaterial* out, const Material* mat, const MTex* tex, const Image* img, ConversionData& conv_data) -{ - (void)mat; (void)tex; (void)conv_data; +void BlenderImporter::ResolveImage(aiMaterial *out, const Material *mat, const MTex *tex, const Image *img, ConversionData &conv_data) { + (void)mat; + (void)tex; + (void)conv_data; aiString name; // check if the file contents are bundled with the BLEND file if (img->packedfile) { name.data[0] = '*'; - name.length = 1+ ASSIMP_itoa10(name.data+1,static_cast(MAXLEN-1), static_cast(conv_data.textures->size())); + name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast(MAXLEN - 1), static_cast(conv_data.textures->size())); conv_data.textures->push_back(new aiTexture()); - aiTexture* curTex = conv_data.textures->back(); + aiTexture *curTex = conv_data.textures->back(); // usually 'img->name' will be the original file name of the embedded textures, // so we can extract the file extension from it. - const size_t nlen = strlen( img->name ); - const char* s = img->name+nlen, *e = s; - while ( s >= img->name && *s != '.' ) { + const size_t nlen = strlen(img->name); + const char *s = img->name + nlen, *e = s; + while (s >= img->name && *s != '.') { --s; } @@ -448,14 +432,14 @@ void BlenderImporter::ResolveImage(aiMaterial* out, const Material* mat, const M curTex->mWidth = img->packedfile->size; uint8_t *ch = new uint8_t[curTex->mWidth]; - conv_data.db.reader->SetCurrentPos(static_cast( img->packedfile->data->val)); + conv_data.db.reader->SetCurrentPos(static_cast(img->packedfile->data->val)); conv_data.db.reader->CopyAndAdvance(ch, curTex->mWidth); curTex->pcData = reinterpret_cast(ch); - LogInfo("Reading embedded texture, original file was "+std::string(img->name)); + LogInfo("Reading embedded texture, original file was " + std::string(img->name)); } else { - name = aiString( img->name ); + name = aiString(img->name); } aiTextureType texture_type = aiTextureType_UNKNOWN; @@ -466,13 +450,11 @@ void BlenderImporter::ResolveImage(aiMaterial* out, const Material* mat, const M else if (map_type & MTex::MapType_NORM) { if (tex->tex->imaflag & Tex::ImageFlags_NORMALMAP) { texture_type = aiTextureType_NORMALS; - } - else { + } else { texture_type = aiTextureType_HEIGHT; } - out->AddProperty(&tex->norfac,1,AI_MATKEY_BUMPSCALING); - } - else if (map_type & MTex::MapType_COLSPEC) + out->AddProperty(&tex->norfac, 1, AI_MATKEY_BUMPSCALING); + } else if (map_type & MTex::MapType_COLSPEC) texture_type = aiTextureType_SPECULAR; else if (map_type & MTex::MapType_COLMIR) texture_type = aiTextureType_REFLECTION; @@ -491,86 +473,81 @@ void BlenderImporter::ResolveImage(aiMaterial* out, const Material* mat, const M texture_type = aiTextureType_DISPLACEMENT; //else if (map_type & MTex::MapType_WARP) - out->AddProperty(&name,AI_MATKEY_TEXTURE(texture_type, - conv_data.next_texture[texture_type]++)); - + out->AddProperty(&name, AI_MATKEY_TEXTURE(texture_type, + conv_data.next_texture[texture_type]++)); } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::AddSentinelTexture(aiMaterial* out, const Material* mat, const MTex* tex, ConversionData& conv_data) -{ - (void)mat; (void)tex; (void)conv_data; +void BlenderImporter::AddSentinelTexture(aiMaterial *out, const Material *mat, const MTex *tex, ConversionData &conv_data) { + (void)mat; + (void)tex; + (void)conv_data; aiString name; - name.length = ai_snprintf(name.data, MAXLEN, "Procedural,num=%i,type=%s",conv_data.sentinel_cnt++, - GetTextureTypeDisplayString(tex->tex->type) - ); - out->AddProperty(&name,AI_MATKEY_TEXTURE_DIFFUSE( - conv_data.next_texture[aiTextureType_DIFFUSE]++) - ); + name.length = ai_snprintf(name.data, MAXLEN, "Procedural,num=%i,type=%s", conv_data.sentinel_cnt++, + GetTextureTypeDisplayString(tex->tex->type)); + out->AddProperty(&name, AI_MATKEY_TEXTURE_DIFFUSE( + conv_data.next_texture[aiTextureType_DIFFUSE]++)); } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::ResolveTexture(aiMaterial* out, const Material* mat, const MTex* tex, ConversionData& conv_data) -{ - const Tex* rtex = tex->tex.get(); - if(!rtex || !rtex->type) { +void BlenderImporter::ResolveTexture(aiMaterial *out, const Material *mat, const MTex *tex, ConversionData &conv_data) { + const Tex *rtex = tex->tex.get(); + if (!rtex || !rtex->type) { return; } // We can't support most of the texture types because they're mostly procedural. // These are substituted by a dummy texture. - const char* dispnam = ""; - switch( rtex->type ) - { - // these are listed in blender's UI - case Tex::Type_CLOUDS : - case Tex::Type_WOOD : - case Tex::Type_MARBLE : - case Tex::Type_MAGIC : - case Tex::Type_BLEND : - case Tex::Type_STUCCI : - case Tex::Type_NOISE : - case Tex::Type_PLUGIN : - case Tex::Type_MUSGRAVE : - case Tex::Type_VORONOI : - case Tex::Type_DISTNOISE : - case Tex::Type_ENVMAP : + const char *dispnam = ""; + switch (rtex->type) { + // these are listed in blender's UI + case Tex::Type_CLOUDS: + case Tex::Type_WOOD: + case Tex::Type_MARBLE: + case Tex::Type_MAGIC: + case Tex::Type_BLEND: + case Tex::Type_STUCCI: + case Tex::Type_NOISE: + case Tex::Type_PLUGIN: + case Tex::Type_MUSGRAVE: + case Tex::Type_VORONOI: + case Tex::Type_DISTNOISE: + case Tex::Type_ENVMAP: - // these do no appear in the UI, why? - case Tex::Type_POINTDENSITY : - case Tex::Type_VOXELDATA : + // these do no appear in the UI, why? + case Tex::Type_POINTDENSITY: + case Tex::Type_VOXELDATA: - LogWarn(std::string("Encountered a texture with an unsupported type: ")+dispnam); - AddSentinelTexture(out, mat, tex, conv_data); + LogWarn(std::string("Encountered a texture with an unsupported type: ") + dispnam); + AddSentinelTexture(out, mat, tex, conv_data); + break; + + case Tex::Type_IMAGE: + if (!rtex->ima) { + LogError("A texture claims to be an Image, but no image reference is given"); break; + } + ResolveImage(out, mat, tex, rtex->ima.get(), conv_data); + break; - case Tex::Type_IMAGE : - if (!rtex->ima) { - LogError("A texture claims to be an Image, but no image reference is given"); - break; - } - ResolveImage(out, mat, tex, rtex->ima.get(),conv_data); - break; - - default: - ai_assert(false); + default: + ai_assert(false); }; } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::BuildDefaultMaterial(Blender::ConversionData& conv_data) -{ +void BlenderImporter::BuildDefaultMaterial(Blender::ConversionData &conv_data) { // add a default material if necessary - unsigned int index = static_cast( -1 ); - for( aiMesh* mesh : conv_data.meshes.get() ) { - if (mesh->mMaterialIndex == static_cast( -1 )) { + unsigned int index = static_cast(-1); + for (aiMesh *mesh : conv_data.meshes.get()) { + if (mesh->mMaterialIndex == static_cast(-1)) { - if (index == static_cast( -1 )) { + if (index == static_cast(-1)) { // Setup a default material. std::shared_ptr p(new Material()); - ai_assert(::strlen(AI_DEFAULT_MATERIAL_NAME) < sizeof(p->id.name)-2); - strcpy( p->id.name+2, AI_DEFAULT_MATERIAL_NAME ); + ai_assert(::strlen(AI_DEFAULT_MATERIAL_NAME) < sizeof(p->id.name) - 2); + strcpy(p->id.name + 2, AI_DEFAULT_MATERIAL_NAME); // Note: MSVC11 does not zero-initialize Material here, although it should. // Thus all relevant fields should be explicitly initialized. We cannot add @@ -584,7 +561,7 @@ void BlenderImporter::BuildDefaultMaterial(Blender::ConversionData& conv_data) p->alpha = 0.f; p->har = 0; - index = static_cast( conv_data.materials_raw.size() ); + index = static_cast(conv_data.materials_raw.size()); conv_data.materials_raw.push_back(p); LogInfo("Adding default material"); } @@ -593,8 +570,7 @@ void BlenderImporter::BuildDefaultMaterial(Blender::ConversionData& conv_data) } } -void BlenderImporter::AddBlendParams(aiMaterial* result, const Material* source) -{ +void BlenderImporter::AddBlendParams(aiMaterial *result, const Material *source) { aiColor3D diffuseColor(source->r, source->g, source->b); result->AddProperty(&diffuseColor, 1, "$mat.blend.diffuse.color", 0, 0); @@ -607,7 +583,6 @@ void BlenderImporter::AddBlendParams(aiMaterial* result, const Material* source) int diffuseRamp = 0; result->AddProperty(&diffuseRamp, 1, "$mat.blend.diffuse.ramp", 0, 0); - aiColor3D specularColor(source->specr, source->specg, source->specb); result->AddProperty(&specularColor, 1, "$mat.blend.specular.color", 0, 0); @@ -623,7 +598,6 @@ void BlenderImporter::AddBlendParams(aiMaterial* result, const Material* source) int specularHardness = source->har; result->AddProperty(&specularHardness, 1, "$mat.blend.specular.hardness", 0, 0); - int transparencyUse = source->mode & MA_TRANSPARENCY ? 1 : 0; result->AddProperty(&transparencyUse, 1, "$mat.blend.transparency.use", 0, 0); @@ -666,7 +640,6 @@ void BlenderImporter::AddBlendParams(aiMaterial* result, const Material* source) int transparencyGlossSamples = source->samp_gloss_tra; result->AddProperty(&transparencyGlossSamples, 1, "$mat.blend.transparency.glossSamples", 0, 0); - int mirrorUse = source->mode & MA_RAYMIRROR ? 1 : 0; result->AddProperty(&mirrorUse, 1, "$mat.blend.mirror.use", 0, 0); @@ -704,68 +677,67 @@ void BlenderImporter::AddBlendParams(aiMaterial* result, const Material* source) result->AddProperty(&mirrorGlossAnisotropic, 1, "$mat.blend.mirror.glossAnisotropic", 0, 0); } -void BlenderImporter::BuildMaterials(ConversionData& conv_data) -{ +void BlenderImporter::BuildMaterials(ConversionData &conv_data) { conv_data.materials->reserve(conv_data.materials_raw.size()); BuildDefaultMaterial(conv_data); - for(std::shared_ptr mat : conv_data.materials_raw) { + for (std::shared_ptr mat : conv_data.materials_raw) { // reset per material global counters - for (size_t i = 0; i < sizeof(conv_data.next_texture)/sizeof(conv_data.next_texture[0]);++i) { - conv_data.next_texture[i] = 0 ; + for (size_t i = 0; i < sizeof(conv_data.next_texture) / sizeof(conv_data.next_texture[0]); ++i) { + conv_data.next_texture[i] = 0; } - aiMaterial* mout = new aiMaterial(); + aiMaterial *mout = new aiMaterial(); conv_data.materials->push_back(mout); // For any new material field handled here, the default material above must be updated with an appropriate default value. // set material name - aiString name = aiString(mat->id.name+2); // skip over the name prefix 'MA' - mout->AddProperty(&name,AI_MATKEY_NAME); + aiString name = aiString(mat->id.name + 2); // skip over the name prefix 'MA' + mout->AddProperty(&name, AI_MATKEY_NAME); // basic material colors - aiColor3D col(mat->r,mat->g,mat->b); - if (mat->r || mat->g || mat->b ) { + aiColor3D col(mat->r, mat->g, mat->b); + if (mat->r || mat->g || mat->b) { // Usually, zero diffuse color means no diffuse color at all in the equation. // So we omit this member to express this intent. - mout->AddProperty(&col,1,AI_MATKEY_COLOR_DIFFUSE); + mout->AddProperty(&col, 1, AI_MATKEY_COLOR_DIFFUSE); if (mat->emit) { - aiColor3D emit_col(mat->emit * mat->r, mat->emit * mat->g, mat->emit * mat->b) ; - mout->AddProperty(&emit_col, 1, AI_MATKEY_COLOR_EMISSIVE) ; + aiColor3D emit_col(mat->emit * mat->r, mat->emit * mat->g, mat->emit * mat->b); + mout->AddProperty(&emit_col, 1, AI_MATKEY_COLOR_EMISSIVE); } } - col = aiColor3D(mat->specr,mat->specg,mat->specb); - mout->AddProperty(&col,1,AI_MATKEY_COLOR_SPECULAR); + col = aiColor3D(mat->specr, mat->specg, mat->specb); + mout->AddProperty(&col, 1, AI_MATKEY_COLOR_SPECULAR); // is hardness/shininess set? - if( mat->har ) { + if (mat->har) { const float har = mat->har; - mout->AddProperty(&har,1,AI_MATKEY_SHININESS); + mout->AddProperty(&har, 1, AI_MATKEY_SHININESS); } - col = aiColor3D(mat->ambr,mat->ambg,mat->ambb); - mout->AddProperty(&col,1,AI_MATKEY_COLOR_AMBIENT); + col = aiColor3D(mat->ambr, mat->ambg, mat->ambb); + mout->AddProperty(&col, 1, AI_MATKEY_COLOR_AMBIENT); // is mirror enabled? - if( mat->mode & MA_RAYMIRROR ) { + if (mat->mode & MA_RAYMIRROR) { const float ray_mirror = mat->ray_mirror; - mout->AddProperty(&ray_mirror,1,AI_MATKEY_REFLECTIVITY); + mout->AddProperty(&ray_mirror, 1, AI_MATKEY_REFLECTIVITY); } - col = aiColor3D(mat->mirr,mat->mirg,mat->mirb); - mout->AddProperty(&col,1,AI_MATKEY_COLOR_REFLECTIVE); + col = aiColor3D(mat->mirr, mat->mirg, mat->mirb); + mout->AddProperty(&col, 1, AI_MATKEY_COLOR_REFLECTIVE); - for(size_t i = 0; i < sizeof(mat->mtex) / sizeof(mat->mtex[0]); ++i) { + for (size_t i = 0; i < sizeof(mat->mtex) / sizeof(mat->mtex[0]); ++i) { if (!mat->mtex[i]) { continue; } - ResolveTexture(mout,mat.get(),mat->mtex[i].get(),conv_data); + ResolveTexture(mout, mat.get(), mat->mtex[i].get(), conv_data); } AddBlendParams(mout, mat.get()); @@ -773,85 +745,79 @@ void BlenderImporter::BuildMaterials(ConversionData& conv_data) } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::CheckActualType(const ElemBase* dt, const char* check) -{ +void BlenderImporter::CheckActualType(const ElemBase *dt, const char *check) { ai_assert(dt); - if (strcmp(dt->dna_type,check)) { + if (strcmp(dt->dna_type, check)) { ThrowException((format(), - "Expected object at ",std::hex,dt," to be of type `",check, - "`, but it claims to be a `",dt->dna_type,"`instead" - )); + "Expected object at ", std::hex, dt, " to be of type `", check, + "`, but it claims to be a `", dt->dna_type, "`instead")); } } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::NotSupportedObjectType(const Object* obj, const char* type) -{ - LogWarn((format(), "Object `",obj->id.name,"` - type is unsupported: `",type, "`, skipping" )); +void BlenderImporter::NotSupportedObjectType(const Object *obj, const char *type) { + LogWarn((format(), "Object `", obj->id.name, "` - type is unsupported: `", type, "`, skipping")); } // ------------------------------------------------------------------------------------------------ -void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, const Mesh* mesh, - ConversionData& conv_data, TempArray& temp - ) -{ +void BlenderImporter::ConvertMesh(const Scene & /*in*/, const Object * /*obj*/, const Mesh *mesh, + ConversionData &conv_data, TempArray &temp) { // TODO: Resolve various problems with BMesh triangulation before re-enabling. // See issues #400, #373, #318 #315 and #132. #if defined(TODO_FIX_BMESH_CONVERSION) - BlenderBMeshConverter BMeshConverter( mesh ); - if ( BMeshConverter.ContainsBMesh( ) ) - { - mesh = BMeshConverter.TriangulateBMesh( ); + BlenderBMeshConverter BMeshConverter(mesh); + if (BMeshConverter.ContainsBMesh()) { + mesh = BMeshConverter.TriangulateBMesh(); } #endif - typedef std::pair MyPair; + typedef std::pair MyPair; if ((!mesh->totface && !mesh->totloop) || !mesh->totvert) { return; } // some sanity checks - if (static_cast ( mesh->totface ) > mesh->mface.size() ){ + if (static_cast(mesh->totface) > mesh->mface.size()) { ThrowException("Number of faces is larger than the corresponding array"); } - if (static_cast ( mesh->totvert ) > mesh->mvert.size()) { + if (static_cast(mesh->totvert) > mesh->mvert.size()) { ThrowException("Number of vertices is larger than the corresponding array"); } - if (static_cast ( mesh->totloop ) > mesh->mloop.size()) { + if (static_cast(mesh->totloop) > mesh->mloop.size()) { ThrowException("Number of vertices is larger than the corresponding array"); } // collect per-submesh numbers - std::map per_mat; - std::map per_mat_verts; + std::map per_mat; + std::map per_mat_verts; for (int i = 0; i < mesh->totface; ++i) { - const MFace& mf = mesh->mface[i]; - per_mat[ mf.mat_nr ]++; - per_mat_verts[ mf.mat_nr ] += mf.v4?4:3; + const MFace &mf = mesh->mface[i]; + per_mat[mf.mat_nr]++; + per_mat_verts[mf.mat_nr] += mf.v4 ? 4 : 3; } for (int i = 0; i < mesh->totpoly; ++i) { - const MPoly& mp = mesh->mpoly[i]; - per_mat[ mp.mat_nr ]++; - per_mat_verts[ mp.mat_nr ] += mp.totloop; + const MPoly &mp = mesh->mpoly[i]; + per_mat[mp.mat_nr]++; + per_mat_verts[mp.mat_nr] += mp.totloop; } // ... and allocate the corresponding meshes const size_t old = temp->size(); temp->reserve(temp->size() + per_mat.size()); - std::map mat_num_to_mesh_idx; - for(MyPair& it : per_mat) { + std::map mat_num_to_mesh_idx; + for (MyPair &it : per_mat) { mat_num_to_mesh_idx[it.first] = temp->size(); temp->push_back(new aiMesh()); - aiMesh* out = temp->back(); + aiMesh *out = temp->back(); out->mVertices = new aiVector3D[per_mat_verts[it.first]]; - out->mNormals = new aiVector3D[per_mat_verts[it.first]]; + out->mNormals = new aiVector3D[per_mat_verts[it.first]]; //out->mNumFaces = 0 //out->mNumVertices = 0 @@ -859,45 +825,43 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co // all sub-meshes created from this mesh are named equally. this allows // curious users to recover the original adjacency. - out->mName = aiString(mesh->id.name+2); - // skip over the name prefix 'ME' + out->mName = aiString(mesh->id.name + 2); + // skip over the name prefix 'ME' // resolve the material reference and add this material to the set of // output materials. The (temporary) material index is the index // of the material entry within the list of resolved materials. if (mesh->mat) { - if (static_cast ( it.first ) >= mesh->mat.size() ) { + if (static_cast(it.first) >= mesh->mat.size()) { ThrowException("Material index is out of range"); } std::shared_ptr mat = mesh->mat[it.first]; - const std::deque< std::shared_ptr >::iterator has = std::find( + const std::deque>::iterator has = std::find( conv_data.materials_raw.begin(), - conv_data.materials_raw.end(),mat - ); + conv_data.materials_raw.end(), mat); if (has != conv_data.materials_raw.end()) { - out->mMaterialIndex = static_cast( std::distance(conv_data.materials_raw.begin(),has)); - } - else { - out->mMaterialIndex = static_cast( conv_data.materials_raw.size() ); + out->mMaterialIndex = static_cast(std::distance(conv_data.materials_raw.begin(), has)); + } else { + out->mMaterialIndex = static_cast(conv_data.materials_raw.size()); conv_data.materials_raw.push_back(mat); } - } - else out->mMaterialIndex = static_cast( -1 ); + } else + out->mMaterialIndex = static_cast(-1); } for (int i = 0; i < mesh->totface; ++i) { - const MFace& mf = mesh->mface[i]; + const MFace &mf = mesh->mface[i]; - aiMesh* const out = temp[ mat_num_to_mesh_idx[ mf.mat_nr ] ]; - aiFace& f = out->mFaces[out->mNumFaces++]; + aiMesh *const out = temp[mat_num_to_mesh_idx[mf.mat_nr]]; + aiFace &f = out->mFaces[out->mNumFaces++]; - f.mIndices = new unsigned int[ f.mNumIndices = mf.v4?4:3 ]; - aiVector3D* vo = out->mVertices + out->mNumVertices; - aiVector3D* vn = out->mNormals + out->mNumVertices; + f.mIndices = new unsigned int[f.mNumIndices = mf.v4 ? 4 : 3]; + aiVector3D *vo = out->mVertices + out->mNumVertices; + aiVector3D *vn = out->mNormals + out->mNumVertices; // XXX we can't fold this easily, because we are restricted // to the member names from the BLEND file (v1,v2,v3,v4) @@ -908,7 +872,7 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co if (mf.v1 >= mesh->totvert) { ThrowException("Vertex index v1 out of range"); } - const MVert* v = &mesh->mvert[mf.v1]; + const MVert *v = &mesh->mvert[mf.v1]; vo->x = v->co[0]; vo->y = v->co[1]; vo->z = v->co[2]; @@ -966,8 +930,8 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co ++vn; out->mPrimitiveTypes |= aiPrimitiveType_POLYGON; - } - else out->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE; + } else + out->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE; // } // } @@ -976,29 +940,28 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co for (int i = 0; i < mesh->totpoly; ++i) { - const MPoly& mf = mesh->mpoly[i]; + const MPoly &mf = mesh->mpoly[i]; - aiMesh* const out = temp[ mat_num_to_mesh_idx[ mf.mat_nr ] ]; - aiFace& f = out->mFaces[out->mNumFaces++]; + aiMesh *const out = temp[mat_num_to_mesh_idx[mf.mat_nr]]; + aiFace &f = out->mFaces[out->mNumFaces++]; - f.mIndices = new unsigned int[ f.mNumIndices = mf.totloop ]; - aiVector3D* vo = out->mVertices + out->mNumVertices; - aiVector3D* vn = out->mNormals + out->mNumVertices; + f.mIndices = new unsigned int[f.mNumIndices = mf.totloop]; + aiVector3D *vo = out->mVertices + out->mNumVertices; + aiVector3D *vn = out->mNormals + out->mNumVertices; // XXX we can't fold this easily, because we are restricted // to the member names from the BLEND file (v1,v2,v3,v4) // which are assigned by the genblenddna.py script and // cannot be changed without breaking the entire // import process. - for (int j = 0;j < mf.totloop; ++j) - { - const MLoop& loop = mesh->mloop[mf.loopstart + j]; + for (int j = 0; j < mf.totloop; ++j) { + const MLoop &loop = mesh->mloop[mf.loopstart + j]; if (loop.v >= mesh->totvert) { ThrowException("Vertex index out of range"); } - const MVert& v = mesh->mvert[loop.v]; + const MVert &v = mesh->mvert[loop.v]; vo->x = v.co[0]; vo->y = v.co[1]; @@ -1010,14 +973,10 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co ++vo; ++vn; - } - if (mf.totloop == 3) - { + if (mf.totloop == 3) { out->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE; - } - else - { + } else { out->mPrimitiveTypes |= aiPrimitiveType_POLYGON; } } @@ -1052,17 +1011,17 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co // collect texture coordinates, they're stored in a separate per-face buffer if (mesh->mtface || mesh->mloopuv) { - if (mesh->totface > static_cast ( mesh->mtface.size())) { + if (mesh->totface > static_cast(mesh->mtface.size())) { ThrowException("Number of UV faces is larger than the corresponding UV face array (#1)"); } - for (std::vector::iterator it = temp->begin()+old; it != temp->end(); ++it) { - ai_assert((*it)->mNumVertices && (*it)->mNumFaces); + for (std::vector::iterator it = temp->begin() + old; it != temp->end(); ++it) { + ai_assert(0 != (*it)->mNumVertices); + ai_assert(0 != (*it)->mNumFaces); const auto itMatTexUvMapping = matTexUvMappings.find((*it)->mMaterialIndex); if (itMatTexUvMapping == matTexUvMappings.end()) { // default behaviour like before (*it)->mTextureCoords[0] = new aiVector3D[(*it)->mNumVertices]; - } - else { + } else { // create texture coords for every mapped tex for (uint32_t i = 0; i < itMatTexUvMapping->second.size(); ++i) { (*it)->mTextureCoords[i] = new aiVector3D[(*it)->mNumVertices]; @@ -1072,29 +1031,29 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co } for (int i = 0; i < mesh->totface; ++i) { - const MTFace* v = &mesh->mtface[i]; + const MTFace *v = &mesh->mtface[i]; - aiMesh* const out = temp[ mat_num_to_mesh_idx[ mesh->mface[i].mat_nr ] ]; - const aiFace& f = out->mFaces[out->mNumFaces++]; + aiMesh *const out = temp[mat_num_to_mesh_idx[mesh->mface[i].mat_nr]]; + const aiFace &f = out->mFaces[out->mNumFaces++]; - aiVector3D* vo = &out->mTextureCoords[0][out->mNumVertices]; - for (unsigned int j = 0; j < f.mNumIndices; ++j,++vo,++out->mNumVertices) { + aiVector3D *vo = &out->mTextureCoords[0][out->mNumVertices]; + for (unsigned int j = 0; j < f.mNumIndices; ++j, ++vo, ++out->mNumVertices) { vo->x = v->uv[j][0]; vo->y = v->uv[j][1]; } } for (int i = 0; i < mesh->totpoly; ++i) { - const MPoly& v = mesh->mpoly[i]; - aiMesh* const out = temp[ mat_num_to_mesh_idx[ v.mat_nr ] ]; - const aiFace& f = out->mFaces[out->mNumFaces++]; + const MPoly &v = mesh->mpoly[i]; + aiMesh *const out = temp[mat_num_to_mesh_idx[v.mat_nr]]; + const aiFace &f = out->mFaces[out->mNumFaces++]; const auto itMatTexUvMapping = matTexUvMappings.find(v.mat_nr); if (itMatTexUvMapping == matTexUvMappings.end()) { // old behavior - aiVector3D* vo = &out->mTextureCoords[0][out->mNumVertices]; + aiVector3D *vo = &out->mTextureCoords[0][out->mNumVertices]; for (unsigned int j = 0; j < f.mNumIndices; ++j, ++vo, ++out->mNumVertices) { - const MLoopUV& uv = mesh->mloopuv[v.loopstart + j]; + const MLoopUV &uv = mesh->mloopuv[v.loopstart + j]; vo->x = uv.uv[0]; vo->y = uv.uv[1]; } @@ -1102,10 +1061,10 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co // create textureCoords for every mapped tex for (uint32_t m = 0; m < itMatTexUvMapping->second.size(); ++m) { const MLoopUV *tm = itMatTexUvMapping->second[m]; - aiVector3D* vo = &out->mTextureCoords[m][out->mNumVertices]; + aiVector3D *vo = &out->mTextureCoords[m][out->mNumVertices]; uint32_t j = 0; for (; j < f.mNumIndices; ++j, ++vo) { - const MLoopUV& uv = tm[v.loopstart + j]; + const MLoopUV &uv = tm[v.loopstart + j]; vo->x = uv.uv[0]; vo->y = uv.uv[1]; } @@ -1121,24 +1080,25 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co // collect texture coordinates, old-style (marked as deprecated in current blender sources) if (mesh->tface) { - if (mesh->totface > static_cast ( mesh->tface.size())) { + if (mesh->totface > static_cast(mesh->tface.size())) { ThrowException("Number of faces is larger than the corresponding UV face array (#2)"); } - for (std::vector::iterator it = temp->begin()+old; it != temp->end(); ++it) { - ai_assert((*it)->mNumVertices && (*it)->mNumFaces); + for (std::vector::iterator it = temp->begin() + old; it != temp->end(); ++it) { + ai_assert(0 != (*it)->mNumVertices); + ai_assert(0 != (*it)->mNumFaces); (*it)->mTextureCoords[0] = new aiVector3D[(*it)->mNumVertices]; (*it)->mNumFaces = (*it)->mNumVertices = 0; } for (int i = 0; i < mesh->totface; ++i) { - const TFace* v = &mesh->tface[i]; + const TFace *v = &mesh->tface[i]; - aiMesh* const out = temp[ mat_num_to_mesh_idx[ mesh->mface[i].mat_nr ] ]; - const aiFace& f = out->mFaces[out->mNumFaces++]; + aiMesh *const out = temp[mat_num_to_mesh_idx[mesh->mface[i].mat_nr]]; + const aiFace &f = out->mFaces[out->mNumFaces++]; - aiVector3D* vo = &out->mTextureCoords[0][out->mNumVertices]; - for (unsigned int j = 0; j < f.mNumIndices; ++j,++vo,++out->mNumVertices) { + aiVector3D *vo = &out->mTextureCoords[0][out->mNumVertices]; + for (unsigned int j = 0; j < f.mNumIndices; ++j, ++vo, ++out->mNumVertices) { vo->x = v->uv[j][0]; vo->y = v->uv[j][1]; } @@ -1147,11 +1107,12 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co // collect vertex colors, stored separately as well if (mesh->mcol || mesh->mloopcol) { - if (mesh->totface > static_cast ( (mesh->mcol.size()/4)) ) { + if (mesh->totface > static_cast((mesh->mcol.size() / 4))) { ThrowException("Number of faces is larger than the corresponding color face array"); } - for (std::vector::iterator it = temp->begin()+old; it != temp->end(); ++it) { - ai_assert((*it)->mNumVertices && (*it)->mNumFaces); + for (std::vector::iterator it = temp->begin() + old; it != temp->end(); ++it) { + ai_assert(0 != (*it)->mNumVertices); + ai_assert(0 != (*it)->mNumFaces); (*it)->mColors[0] = new aiColor4D[(*it)->mNumVertices]; (*it)->mNumFaces = (*it)->mNumVertices = 0; @@ -1159,53 +1120,51 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co for (int i = 0; i < mesh->totface; ++i) { - aiMesh* const out = temp[ mat_num_to_mesh_idx[ mesh->mface[i].mat_nr ] ]; - const aiFace& f = out->mFaces[out->mNumFaces++]; + aiMesh *const out = temp[mat_num_to_mesh_idx[mesh->mface[i].mat_nr]]; + const aiFace &f = out->mFaces[out->mNumFaces++]; - aiColor4D* vo = &out->mColors[0][out->mNumVertices]; - for (unsigned int n = 0; n < f.mNumIndices; ++n, ++vo,++out->mNumVertices) { - const MCol* col = &mesh->mcol[(i<<2)+n]; + aiColor4D *vo = &out->mColors[0][out->mNumVertices]; + for (unsigned int n = 0; n < f.mNumIndices; ++n, ++vo, ++out->mNumVertices) { + const MCol *col = &mesh->mcol[(i << 2) + n]; vo->r = col->r; vo->g = col->g; vo->b = col->b; vo->a = col->a; } - for (unsigned int n = f.mNumIndices; n < 4; ++n); + for (unsigned int n = f.mNumIndices; n < 4; ++n) + ; } for (int i = 0; i < mesh->totpoly; ++i) { - const MPoly& v = mesh->mpoly[i]; - aiMesh* const out = temp[ mat_num_to_mesh_idx[ v.mat_nr ] ]; - const aiFace& f = out->mFaces[out->mNumFaces++]; + const MPoly &v = mesh->mpoly[i]; + aiMesh *const out = temp[mat_num_to_mesh_idx[v.mat_nr]]; + const aiFace &f = out->mFaces[out->mNumFaces++]; - aiColor4D* vo = &out->mColors[0][out->mNumVertices]; - const ai_real scaleZeroToOne = 1.f/255.f; - for (unsigned int j = 0; j < f.mNumIndices; ++j,++vo,++out->mNumVertices) { - const MLoopCol& col = mesh->mloopcol[v.loopstart + j]; + aiColor4D *vo = &out->mColors[0][out->mNumVertices]; + const ai_real scaleZeroToOne = 1.f / 255.f; + for (unsigned int j = 0; j < f.mNumIndices; ++j, ++vo, ++out->mNumVertices) { + const MLoopCol &col = mesh->mloopcol[v.loopstart + j]; vo->r = ai_real(col.r) * scaleZeroToOne; vo->g = ai_real(col.g) * scaleZeroToOne; vo->b = ai_real(col.b) * scaleZeroToOne; vo->a = ai_real(col.a) * scaleZeroToOne; } - } - } return; } // ------------------------------------------------------------------------------------------------ -aiCamera* BlenderImporter::ConvertCamera(const Scene& /*in*/, const Object* obj, const Camera* cam, ConversionData& /*conv_data*/) -{ +aiCamera *BlenderImporter::ConvertCamera(const Scene & /*in*/, const Object *obj, const Camera *cam, ConversionData & /*conv_data*/) { std::unique_ptr out(new aiCamera()); - out->mName = obj->id.name+2; + out->mName = obj->id.name + 2; out->mPosition = aiVector3D(0.f, 0.f, 0.f); out->mUp = aiVector3D(0.f, 1.f, 0.f); out->mLookAt = aiVector3D(0.f, 0.f, -1.f); if (cam->sensor_x && cam->lens) { - out->mHorizontalFOV = 2.f * std::atan2(cam->sensor_x, 2.f * cam->lens); + out->mHorizontalFOV = 2.f * std::atan2(cam->sensor_x, 2.f * cam->lens); } out->mClipPlaneNear = cam->clipsta; out->mClipPlaneFar = cam->clipend; @@ -1214,51 +1173,48 @@ aiCamera* BlenderImporter::ConvertCamera(const Scene& /*in*/, const Object* obj, } // ------------------------------------------------------------------------------------------------ -aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, const Lamp* lamp, ConversionData& /*conv_data*/) -{ +aiLight *BlenderImporter::ConvertLight(const Scene & /*in*/, const Object *obj, const Lamp *lamp, ConversionData & /*conv_data*/) { std::unique_ptr out(new aiLight()); - out->mName = obj->id.name+2; + out->mName = obj->id.name + 2; - switch (lamp->type) - { - case Lamp::Type_Local: - out->mType = aiLightSource_POINT; - break; - case Lamp::Type_Spot: - out->mType = aiLightSource_SPOT; + switch (lamp->type) { + case Lamp::Type_Local: + out->mType = aiLightSource_POINT; + break; + case Lamp::Type_Spot: + out->mType = aiLightSource_SPOT; - // blender orients directional lights as facing toward -z - out->mDirection = aiVector3D(0.f, 0.f, -1.f); - out->mUp = aiVector3D(0.f, 1.f, 0.f); + // blender orients directional lights as facing toward -z + out->mDirection = aiVector3D(0.f, 0.f, -1.f); + out->mUp = aiVector3D(0.f, 1.f, 0.f); - out->mAngleInnerCone = lamp->spotsize * (1.0f - lamp->spotblend); - out->mAngleOuterCone = lamp->spotsize; - break; - case Lamp::Type_Sun: - out->mType = aiLightSource_DIRECTIONAL; + out->mAngleInnerCone = lamp->spotsize * (1.0f - lamp->spotblend); + out->mAngleOuterCone = lamp->spotsize; + break; + case Lamp::Type_Sun: + out->mType = aiLightSource_DIRECTIONAL; - // blender orients directional lights as facing toward -z - out->mDirection = aiVector3D(0.f, 0.f, -1.f); - out->mUp = aiVector3D(0.f, 1.f, 0.f); - break; + // blender orients directional lights as facing toward -z + out->mDirection = aiVector3D(0.f, 0.f, -1.f); + out->mUp = aiVector3D(0.f, 1.f, 0.f); + break; - case Lamp::Type_Area: - out->mType = aiLightSource_AREA; + case Lamp::Type_Area: + out->mType = aiLightSource_AREA; - if (lamp->area_shape == 0) { - out->mSize = aiVector2D(lamp->area_size, lamp->area_size); - } - else { - out->mSize = aiVector2D(lamp->area_size, lamp->area_sizey); - } + if (lamp->area_shape == 0) { + out->mSize = aiVector2D(lamp->area_size, lamp->area_size); + } else { + out->mSize = aiVector2D(lamp->area_size, lamp->area_sizey); + } - // blender orients directional lights as facing toward -z - out->mDirection = aiVector3D(0.f, 0.f, -1.f); - out->mUp = aiVector3D(0.f, 1.f, 0.f); - break; + // blender orients directional lights as facing toward -z + out->mDirection = aiVector3D(0.f, 0.f, -1.f); + out->mUp = aiVector3D(0.f, 1.f, 0.f); + break; - default: - break; + default: + break; } out->mColorAmbient = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy; @@ -1268,14 +1224,11 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c // If default values are supplied, compute the coefficients from light's max distance // Read this: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/ // - if (lamp->constant_coefficient == 1.0f && lamp->linear_coefficient == 0.0f && lamp->quadratic_coefficient == 0.0f && lamp->dist > 0.0f) - { + if (lamp->constant_coefficient == 1.0f && lamp->linear_coefficient == 0.0f && lamp->quadratic_coefficient == 0.0f && lamp->dist > 0.0f) { out->mAttenuationConstant = 1.0f; out->mAttenuationLinear = 2.0f / lamp->dist; out->mAttenuationQuadratic = 1.0f / (lamp->dist * lamp->dist); - } - else - { + } else { out->mAttenuationConstant = lamp->constant_coefficient; out->mAttenuationLinear = lamp->linear_coefficient; out->mAttenuationQuadratic = lamp->quadratic_coefficient; @@ -1285,11 +1238,10 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c } // ------------------------------------------------------------------------------------------------ -aiNode* BlenderImporter::ConvertNode(const Scene& in, const Object* obj, ConversionData& conv_data, const aiMatrix4x4& parentTransform) -{ - std::deque children; - for(ObjectSet::iterator it = conv_data.objects.begin(); it != conv_data.objects.end() ;) { - const Object* object = *it; +aiNode *BlenderImporter::ConvertNode(const Scene &in, const Object *obj, ConversionData &conv_data, const aiMatrix4x4 &parentTransform) { + std::deque children; + for (ObjectSet::iterator it = conv_data.objects.begin(); it != conv_data.objects.end();) { + const Object *object = *it; if (object->parent == obj) { children.push_back(object); @@ -1299,66 +1251,61 @@ aiNode* BlenderImporter::ConvertNode(const Scene& in, const Object* obj, Convers ++it; } - std::unique_ptr node(new aiNode(obj->id.name+2)); // skip over the name prefix 'OB' + std::unique_ptr node(new aiNode(obj->id.name + 2)); // skip over the name prefix 'OB' if (obj->data) { - switch (obj->type) - { - case Object :: Type_EMPTY: + switch (obj->type) { + case Object ::Type_EMPTY: break; // do nothing - // supported object types - case Object :: Type_MESH: { + case Object ::Type_MESH: { const size_t old = conv_data.meshes->size(); - CheckActualType(obj->data.get(),"Mesh"); - ConvertMesh(in,obj,static_cast(obj->data.get()),conv_data,conv_data.meshes); + CheckActualType(obj->data.get(), "Mesh"); + ConvertMesh(in, obj, static_cast(obj->data.get()), conv_data, conv_data.meshes); if (conv_data.meshes->size() > old) { - node->mMeshes = new unsigned int[node->mNumMeshes = static_cast(conv_data.meshes->size()-old)]; + node->mMeshes = new unsigned int[node->mNumMeshes = static_cast(conv_data.meshes->size() - old)]; for (unsigned int i = 0; i < node->mNumMeshes; ++i) { node->mMeshes[i] = static_cast(i + old); } - }} - break; - case Object :: Type_LAMP: { - CheckActualType(obj->data.get(),"Lamp"); - aiLight* mesh = ConvertLight(in,obj,static_cast( - obj->data.get()),conv_data); + } + } break; + case Object ::Type_LAMP: { + CheckActualType(obj->data.get(), "Lamp"); + aiLight *mesh = ConvertLight(in, obj, static_cast(obj->data.get()), conv_data); if (mesh) { conv_data.lights->push_back(mesh); - }} - break; - case Object :: Type_CAMERA: { - CheckActualType(obj->data.get(),"Camera"); - aiCamera* mesh = ConvertCamera(in,obj,static_cast( - obj->data.get()),conv_data); + } + } break; + case Object ::Type_CAMERA: { + CheckActualType(obj->data.get(), "Camera"); + aiCamera *mesh = ConvertCamera(in, obj, static_cast(obj->data.get()), conv_data); if (mesh) { conv_data.cameras->push_back(mesh); - }} - break; - + } + } break; // unsupported object types / log, but do not break - case Object :: Type_CURVE: - NotSupportedObjectType(obj,"Curve"); + case Object ::Type_CURVE: + NotSupportedObjectType(obj, "Curve"); break; - case Object :: Type_SURF: - NotSupportedObjectType(obj,"Surface"); + case Object ::Type_SURF: + NotSupportedObjectType(obj, "Surface"); break; - case Object :: Type_FONT: - NotSupportedObjectType(obj,"Font"); + case Object ::Type_FONT: + NotSupportedObjectType(obj, "Font"); break; - case Object :: Type_MBALL: - NotSupportedObjectType(obj,"MetaBall"); + case Object ::Type_MBALL: + NotSupportedObjectType(obj, "MetaBall"); break; - case Object :: Type_WAVE: - NotSupportedObjectType(obj,"Wave"); + case Object ::Type_WAVE: + NotSupportedObjectType(obj, "Wave"); break; - case Object :: Type_LATTICE: - NotSupportedObjectType(obj,"Lattice"); + case Object ::Type_LATTICE: + NotSupportedObjectType(obj, "Lattice"); break; // invalid or unknown type @@ -1367,8 +1314,8 @@ aiNode* BlenderImporter::ConvertNode(const Scene& in, const Object* obj, Convers } } - for(unsigned int x = 0; x < 4; ++x) { - for(unsigned int y = 0; y < 4; ++y) { + for (unsigned int x = 0; x < 4; ++x) { + for (unsigned int y = 0; y < 4; ++y) { node->mTransformation[y][x] = obj->obmat[x][y]; } } @@ -1376,19 +1323,19 @@ aiNode* BlenderImporter::ConvertNode(const Scene& in, const Object* obj, Convers aiMatrix4x4 m = parentTransform; m = m.Inverse(); - node->mTransformation = m*node->mTransformation; + node->mTransformation = m * node->mTransformation; if (children.size()) { node->mNumChildren = static_cast(children.size()); - aiNode** nd = node->mChildren = new aiNode*[node->mNumChildren](); - for (const Object* nobj :children) { - *nd = ConvertNode(in,nobj,conv_data,node->mTransformation * parentTransform); + aiNode **nd = node->mChildren = new aiNode *[node->mNumChildren](); + for (const Object *nobj : children) { + *nd = ConvertNode(in, nobj, conv_data, node->mTransformation * parentTransform); (*nd++)->mParent = node.get(); } } // apply modifiers - modifier_cache->ApplyModifiers(*node,conv_data,in,*obj); + modifier_cache->ApplyModifiers(*node, conv_data, in, *obj); return node.release(); } diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp index d66fb4f4c..86550e776 100644 --- a/code/AssetLib/COB/COBLoader.cpp +++ b/code/AssetLib/COB/COBLoader.cpp @@ -290,7 +290,7 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi } std::unique_ptr defmat; if (!min) { - ASSIMP_LOG_DEBUG(format() << "Could not resolve material index " + ASSIMP_LOG_VERBOSE_DEBUG(format() << "Could not resolve material index " << reflist.first << " - creating default material for this slot"); defmat.reset(min = new Material()); @@ -322,7 +322,9 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi break; default: + ASSIMP_LOG_ERROR("Unknown option."); ai_assert(false); // shouldn't be here + break; } mat->AddProperty(&shader, 1, AI_MATKEY_SHADING_MODEL); if (shader != aiShadingMode_Gouraud) { diff --git a/code/AssetLib/CSM/CSMLoader.cpp b/code/AssetLib/CSM/CSMLoader.cpp index 914ca4e33..c455bb3a4 100644 --- a/code/AssetLib/CSM/CSMLoader.cpp +++ b/code/AssetLib/CSM/CSMLoader.cpp @@ -127,7 +127,7 @@ void CSMImporter::InternReadFile( const std::string& pFile, std::unique_ptr file( pIOHandler->Open( pFile, "rb")); // Check whether we can read from the file - if( file.get() == NULL) { + if( file.get() == nullptr) { throw DeadlyImportError( "Failed to open CSM file " + pFile + "."); } diff --git a/code/AssetLib/Collada/ColladaExporter.cpp b/code/AssetLib/Collada/ColladaExporter.cpp index c2b71d00c..567f7c8e7 100644 --- a/code/AssetLib/Collada/ColladaExporter.cpp +++ b/code/AssetLib/Collada/ColladaExporter.cpp @@ -44,8 +44,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER #include "ColladaExporter.h" + #include +#include #include +#include #include #include #include @@ -56,15 +59,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include - #include -#include #include -#include -#include - -using namespace Assimp; namespace Assimp { @@ -91,8 +87,6 @@ void ExportSceneCollada(const char *pFile, IOSystem *pIOSystem, const aiScene *p outfile->Write(iDoTheExportThing.mOutput.str().c_str(), static_cast(iDoTheExportThing.mOutput.tellp()), 1); } -} // end of namespace Assimp - // ------------------------------------------------------------------------------------------------ // Encodes a string into a valid XML ID using the xsd:ID schema qualifications. static const std::string XMLIDEncode(const std::string &name) { @@ -115,7 +109,7 @@ static const std::string XMLIDEncode(const std::string &name) { if (strchr(XML_ID_CHARS, *it) != nullptr) { idEncoded << *it; } else { - // Select placeholder character based on invalid character to prevent name collisions + // Select placeholder character based on invalid character to reduce ID collisions idEncoded << XML_ID_CHARS[(*it) % XML_ID_CHARS_COUNT]; } } @@ -123,20 +117,37 @@ static const std::string XMLIDEncode(const std::string &name) { return idEncoded.str(); } +// ------------------------------------------------------------------------------------------------ +// Helper functions to create unique ids +inline bool IsUniqueId(const std::unordered_set &idSet, const std::string &idStr) { + return (idSet.find(idStr) == idSet.end()); +} + +inline std::string MakeUniqueId(const std::unordered_set &idSet, const std::string &idPrefix, const std::string &postfix) { + std::string result(idPrefix + postfix); + if (!IsUniqueId(idSet, result)) { + // Select a number to append + size_t idnum = 1; + do { + result = idPrefix + '_' + to_string(idnum) + postfix; + ++idnum; + } while (!IsUniqueId(idSet, result)); + } + return result; +} + // ------------------------------------------------------------------------------------------------ // Constructor for a specific scene to export ColladaExporter::ColladaExporter(const aiScene *pScene, IOSystem *pIOSystem, const std::string &path, const std::string &file) : - mIOSystem(pIOSystem), mPath(path), mFile(file) { + mIOSystem(pIOSystem), + mPath(path), + mFile(file), + mScene(pScene), + endstr("\n") { // make sure that all formatting happens using the standard, C locale and not the user's current locale mOutput.imbue(std::locale("C")); mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION); - mScene = pScene; - mSceneOwned = false; - - // set up strings - endstr = "\n"; - // start writing the file WriteFile(); } @@ -144,9 +155,6 @@ ColladaExporter::ColladaExporter(const aiScene *pScene, IOSystem *pIOSystem, con // ------------------------------------------------------------------------------------------------ // Destructor ColladaExporter::~ColladaExporter() { - if (mSceneOwned) { - delete mScene; - } } // ------------------------------------------------------------------------------------------------ @@ -161,6 +169,9 @@ void ColladaExporter::WriteFile() { WriteTextures(); WriteHeader(); + // Add node names to the unique id database first so they are most likely to use their names as unique ids + CreateNodeIds(mScene->mRootNode); + WriteCamerasLibrary(); WriteLightsLibrary(); WriteMaterials(); @@ -172,10 +183,11 @@ void ColladaExporter::WriteFile() { // customized, Writes the animation library WriteAnimationsLibrary(); - // useless Collada fu at the end, just in case we haven't had enough indirections, yet. + // instantiate the scene(s) + // For Assimp there will only ever be one mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "mRootNode->mName.C_Str()) + "\" />" << endstr; + mOutput << startstr << "" << endstr; PopTag(); mOutput << startstr << "" << endstr; PopTag(); @@ -201,7 +213,7 @@ void ColladaExporter::WriteHeader() { static const unsigned int date_nb_chars = 20; char date_str[date_nb_chars]; - std::time_t date = std::time(NULL); + std::time_t date = std::time(nullptr); std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date)); aiVector3D scaling; @@ -210,13 +222,13 @@ void ColladaExporter::WriteHeader() { mScene->mRootNode->mTransformation.Decompose(scaling, rotation, position); rotation.Normalize(); - bool add_root_node = false; + mAdd_root_node = false; ai_real scale = 1.0; if (std::abs(scaling.x - scaling.y) <= epsilon && std::abs(scaling.x - scaling.z) <= epsilon && std::abs(scaling.y - scaling.z) <= epsilon) { scale = (ai_real)((((double)scaling.x) + ((double)scaling.y) + ((double)scaling.z)) / 3.0); } else { - add_root_node = true; + mAdd_root_node = true; } std::string up_axis = "Y_UP"; @@ -227,33 +239,19 @@ void ColladaExporter::WriteHeader() { } else if (rotation.Equal(z_rot, epsilon)) { up_axis = "Z_UP"; } else { - add_root_node = true; + mAdd_root_node = true; } if (!position.Equal(aiVector3D(0, 0, 0))) { - add_root_node = true; + mAdd_root_node = true; } - if (mScene->mRootNode->mNumChildren == 0) { - add_root_node = true; + // Assimp root nodes can have meshes, Collada Scenes cannot + if (mScene->mRootNode->mNumChildren == 0 || mScene->mRootNode->mMeshes != 0) { + mAdd_root_node = true; } - if (add_root_node) { - aiScene *scene; - SceneCombiner::CopyScene(&scene, mScene); - - aiNode *root = new aiNode("Scene"); - - root->mNumChildren = 1; - root->mChildren = new aiNode *[root->mNumChildren]; - - root->mChildren[0] = scene->mRootNode; - scene->mRootNode->mParent = root; - scene->mRootNode = root; - - mScene = scene; - mSceneOwned = true; - + if (mAdd_root_node) { up_axis = "Y_UP"; scale = 1.0; } @@ -352,7 +350,7 @@ void ColladaExporter::WriteTextures() { std::string name = mFile + "_texture_" + (i < 1000 ? "0" : "") + (i < 100 ? "0" : "") + (i < 10 ? "0" : "") + str + "." + ((const char *)texture->achFormatHint); std::unique_ptr outfile(mIOSystem->Open(mPath + mIOSystem->getOsSeparator() + name, "wb")); - if (outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output texture file: " + mPath + name); } @@ -388,10 +386,10 @@ void ColladaExporter::WriteCamerasLibrary() { void ColladaExporter::WriteCamera(size_t pIndex) { const aiCamera *cam = mScene->mCameras[pIndex]; - const std::string cameraName = XMLEscape(cam->mName.C_Str()); - const std::string cameraId = XMLIDEncode(cam->mName.C_Str()); + const std::string cameraId = GetObjectUniqueId(AiObjectType::Camera, pIndex); + const std::string cameraName = GetObjectName(AiObjectType::Camera, pIndex); - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; PushTag(); @@ -441,10 +439,10 @@ void ColladaExporter::WriteLightsLibrary() { void ColladaExporter::WriteLight(size_t pIndex) { const aiLight *light = mScene->mLights[pIndex]; - const std::string lightName = XMLEscape(light->mName.C_Str()); - const std::string lightId = XMLIDEncode(light->mName.C_Str()); + const std::string lightId = GetObjectUniqueId(AiObjectType::Light, pIndex); + const std::string lightName = GetObjectName(AiObjectType::Light, pIndex); - mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; @@ -561,12 +559,11 @@ void ColladaExporter::WriteAmbienttLight(const aiLight *const light) { // ------------------------------------------------------------------------------------------------ // Reads a single surface entry from the given material keys -void ColladaExporter::ReadMaterialSurface(Surface &poSurface, const aiMaterial *pSrcMat, - aiTextureType pTexture, const char *pKey, size_t pType, size_t pIndex) { - if (pSrcMat->GetTextureCount(pTexture) > 0) { +bool ColladaExporter::ReadMaterialSurface(Surface &poSurface, const aiMaterial &pSrcMat, aiTextureType pTexture, const char *pKey, size_t pType, size_t pIndex) { + if (pSrcMat.GetTextureCount(pTexture) > 0) { aiString texfile; unsigned int uvChannel = 0; - pSrcMat->GetTexture(pTexture, 0, &texfile, NULL, &uvChannel); + pSrcMat.GetTexture(pTexture, 0, &texfile, nullptr, &uvChannel); std::string index_str(texfile.C_Str()); @@ -596,8 +593,9 @@ void ColladaExporter::ReadMaterialSurface(Surface &poSurface, const aiMaterial * poSurface.exist = true; } else { if (pKey) - poSurface.exist = pSrcMat->Get(pKey, static_cast(pType), static_cast(pIndex), poSurface.color) == aiReturn_SUCCESS; + poSurface.exist = pSrcMat.Get(pKey, static_cast(pType), static_cast(pIndex), poSurface.color) == aiReturn_SUCCESS; } + return poSurface.exist; } // ------------------------------------------------------------------------------------------------ @@ -608,9 +606,9 @@ static bool isalnum_C(char c) { // ------------------------------------------------------------------------------------------------ // Writes an image entry for the given surface -void ColladaExporter::WriteImageEntry(const Surface &pSurface, const std::string &pNameAdd) { +void ColladaExporter::WriteImageEntry(const Surface &pSurface, const std::string &imageId) { if (!pSurface.texture.empty()) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << ""; @@ -631,14 +629,14 @@ void ColladaExporter::WriteImageEntry(const Surface &pSurface, const std::string // ------------------------------------------------------------------------------------------------ // Writes a color-or-texture entry into an effect definition -void ColladaExporter::WriteTextureColorEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &pImageName) { +void ColladaExporter::WriteTextureColorEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &imageId) { if (pSurface.exist) { mOutput << startstr << "<" << pTypeName << ">" << endstr; PushTag(); if (pSurface.texture.empty()) { mOutput << startstr << "" << pSurface.color.r << " " << pSurface.color.g << " " << pSurface.color.b << " " << pSurface.color.a << "" << endstr; } else { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; } PopTag(); mOutput << startstr << "" << endstr; @@ -647,24 +645,24 @@ void ColladaExporter::WriteTextureColorEntry(const Surface &pSurface, const std: // ------------------------------------------------------------------------------------------------ // Writes the two parameters necessary for referencing a texture in an effect entry -void ColladaExporter::WriteTextureParamEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &pMatName) { +void ColladaExporter::WriteTextureParamEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &materialId) { // if surface is a texture, write out the sampler and the surface parameters necessary to reference the texture if (!pSurface.texture.empty()) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "" << XMLIDEncode(pMatName) << "-" << pTypeName << "-image" << endstr; + mOutput << startstr << "" << materialId << "-" << pTypeName << "-image" << endstr; PopTag(); mOutput << startstr << "" << endstr; PopTag(); mOutput << startstr << "" << endstr; - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "" << XMLIDEncode(pMatName) << "-" << pTypeName << "-surface" << endstr; + mOutput << startstr << "" << materialId << "-" << pTypeName << "-surface" << endstr; PopTag(); mOutput << startstr << "" << endstr; PopTag(); @@ -687,80 +685,63 @@ void ColladaExporter::WriteFloatEntry(const Property &pProperty, const std::stri // ------------------------------------------------------------------------------------------------ // Writes the material setup void ColladaExporter::WriteMaterials() { + std::vector materials; materials.resize(mScene->mNumMaterials); /// collect all materials from the scene size_t numTextures = 0; for (size_t a = 0; a < mScene->mNumMaterials; ++a) { - const aiMaterial *mat = mScene->mMaterials[a]; - - aiString name; - if (mat->Get(AI_MATKEY_NAME, name) != aiReturn_SUCCESS) { - name = "mat"; - materials[a].name = std::string("m") + to_string(a) + name.C_Str(); - } else { - // try to use the material's name if no other material has already taken it, else append # - std::string testName = name.C_Str(); - size_t materialCountWithThisName = 0; - for (size_t i = 0; i < a; i++) { - if (materials[i].name == testName) { - materialCountWithThisName++; - } - } - if (materialCountWithThisName == 0) { - materials[a].name = name.C_Str(); - } else { - materials[a].name = std::string(name.C_Str()) + to_string(materialCountWithThisName); - } - } + Material &material = materials[a]; + material.id = GetObjectUniqueId(AiObjectType::Material, a); + material.name = GetObjectName(AiObjectType::Material, a); + const aiMaterial &mat = *(mScene->mMaterials[a]); aiShadingMode shading = aiShadingMode_Flat; - materials[a].shading_model = "phong"; - if (mat->Get(AI_MATKEY_SHADING_MODEL, shading) == aiReturn_SUCCESS) { + material.shading_model = "phong"; + if (mat.Get(AI_MATKEY_SHADING_MODEL, shading) == aiReturn_SUCCESS) { if (shading == aiShadingMode_Phong) { - materials[a].shading_model = "phong"; + material.shading_model = "phong"; } else if (shading == aiShadingMode_Blinn) { - materials[a].shading_model = "blinn"; + material.shading_model = "blinn"; } else if (shading == aiShadingMode_NoShading) { - materials[a].shading_model = "constant"; + material.shading_model = "constant"; } else if (shading == aiShadingMode_Gouraud) { - materials[a].shading_model = "lambert"; + material.shading_model = "lambert"; } } - ReadMaterialSurface(materials[a].ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT); - if (!materials[a].ambient.texture.empty()) numTextures++; - ReadMaterialSurface(materials[a].diffuse, mat, aiTextureType_DIFFUSE, AI_MATKEY_COLOR_DIFFUSE); - if (!materials[a].diffuse.texture.empty()) numTextures++; - ReadMaterialSurface(materials[a].specular, mat, aiTextureType_SPECULAR, AI_MATKEY_COLOR_SPECULAR); - if (!materials[a].specular.texture.empty()) numTextures++; - ReadMaterialSurface(materials[a].emissive, mat, aiTextureType_EMISSIVE, AI_MATKEY_COLOR_EMISSIVE); - if (!materials[a].emissive.texture.empty()) numTextures++; - ReadMaterialSurface(materials[a].reflective, mat, aiTextureType_REFLECTION, AI_MATKEY_COLOR_REFLECTIVE); - if (!materials[a].reflective.texture.empty()) numTextures++; - ReadMaterialSurface(materials[a].transparent, mat, aiTextureType_OPACITY, AI_MATKEY_COLOR_TRANSPARENT); - if (!materials[a].transparent.texture.empty()) numTextures++; - ReadMaterialSurface(materials[a].normal, mat, aiTextureType_NORMALS, NULL, 0, 0); - if (!materials[a].normal.texture.empty()) numTextures++; + if (ReadMaterialSurface(material.ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT)) + ++numTextures; + if (ReadMaterialSurface(material.diffuse, mat, aiTextureType_DIFFUSE, AI_MATKEY_COLOR_DIFFUSE)) + ++numTextures; + if (ReadMaterialSurface(material.specular, mat, aiTextureType_SPECULAR, AI_MATKEY_COLOR_SPECULAR)) + ++numTextures; + if (ReadMaterialSurface(material.emissive, mat, aiTextureType_EMISSIVE, AI_MATKEY_COLOR_EMISSIVE)) + ++numTextures; + if (ReadMaterialSurface(material.reflective, mat, aiTextureType_REFLECTION, AI_MATKEY_COLOR_REFLECTIVE)) + ++numTextures; + if (ReadMaterialSurface(material.transparent, mat, aiTextureType_OPACITY, AI_MATKEY_COLOR_TRANSPARENT)) + ++numTextures; + if (ReadMaterialSurface(material.normal, mat, aiTextureType_NORMALS, nullptr, 0, 0)) + ++numTextures; - materials[a].shininess.exist = mat->Get(AI_MATKEY_SHININESS, materials[a].shininess.value) == aiReturn_SUCCESS; - materials[a].transparency.exist = mat->Get(AI_MATKEY_OPACITY, materials[a].transparency.value) == aiReturn_SUCCESS; - materials[a].index_refraction.exist = mat->Get(AI_MATKEY_REFRACTI, materials[a].index_refraction.value) == aiReturn_SUCCESS; + material.shininess.exist = mat.Get(AI_MATKEY_SHININESS, material.shininess.value) == aiReturn_SUCCESS; + material.transparency.exist = mat.Get(AI_MATKEY_OPACITY, material.transparency.value) == aiReturn_SUCCESS; + material.index_refraction.exist = mat.Get(AI_MATKEY_REFRACTI, material.index_refraction.value) == aiReturn_SUCCESS; } // output textures if present if (numTextures > 0) { mOutput << startstr << "" << endstr; PushTag(); - for (std::vector::const_iterator it = materials.begin(); it != materials.end(); ++it) { - const Material &mat = *it; - WriteImageEntry(mat.ambient, mat.name + "-ambient-image"); - WriteImageEntry(mat.diffuse, mat.name + "-diffuse-image"); - WriteImageEntry(mat.specular, mat.name + "-specular-image"); - WriteImageEntry(mat.emissive, mat.name + "-emission-image"); - WriteImageEntry(mat.reflective, mat.name + "-reflective-image"); - WriteImageEntry(mat.transparent, mat.name + "-transparent-image"); - WriteImageEntry(mat.normal, mat.name + "-normal-image"); + for (const Material &mat : materials) { + WriteImageEntry(mat.ambient, mat.id + "-ambient-image"); + WriteImageEntry(mat.diffuse, mat.id + "-diffuse-image"); + WriteImageEntry(mat.specular, mat.id + "-specular-image"); + WriteImageEntry(mat.emissive, mat.id + "-emission-image"); + WriteImageEntry(mat.reflective, mat.id + "-reflective-image"); + WriteImageEntry(mat.transparent, mat.id + "-transparent-image"); + WriteImageEntry(mat.normal, mat.id + "-normal-image"); } PopTag(); mOutput << startstr << "" << endstr; @@ -770,40 +751,39 @@ void ColladaExporter::WriteMaterials() { if (!materials.empty()) { mOutput << startstr << "" << endstr; PushTag(); - for (std::vector::const_iterator it = materials.begin(); it != materials.end(); ++it) { - const Material &mat = *it; + for (const Material &mat : materials) { // this is so ridiculous it must be right - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; PushTag(); // write sampler- and surface params for the texture entries - WriteTextureParamEntry(mat.emissive, "emission", mat.name); - WriteTextureParamEntry(mat.ambient, "ambient", mat.name); - WriteTextureParamEntry(mat.diffuse, "diffuse", mat.name); - WriteTextureParamEntry(mat.specular, "specular", mat.name); - WriteTextureParamEntry(mat.reflective, "reflective", mat.name); - WriteTextureParamEntry(mat.transparent, "transparent", mat.name); - WriteTextureParamEntry(mat.normal, "normal", mat.name); + WriteTextureParamEntry(mat.emissive, "emission", mat.id); + WriteTextureParamEntry(mat.ambient, "ambient", mat.id); + WriteTextureParamEntry(mat.diffuse, "diffuse", mat.id); + WriteTextureParamEntry(mat.specular, "specular", mat.id); + WriteTextureParamEntry(mat.reflective, "reflective", mat.id); + WriteTextureParamEntry(mat.transparent, "transparent", mat.id); + WriteTextureParamEntry(mat.normal, "normal", mat.id); mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "<" << mat.shading_model << ">" << endstr; PushTag(); - WriteTextureColorEntry(mat.emissive, "emission", mat.name + "-emission-sampler"); - WriteTextureColorEntry(mat.ambient, "ambient", mat.name + "-ambient-sampler"); - WriteTextureColorEntry(mat.diffuse, "diffuse", mat.name + "-diffuse-sampler"); - WriteTextureColorEntry(mat.specular, "specular", mat.name + "-specular-sampler"); + WriteTextureColorEntry(mat.emissive, "emission", mat.id + "-emission-sampler"); + WriteTextureColorEntry(mat.ambient, "ambient", mat.id + "-ambient-sampler"); + WriteTextureColorEntry(mat.diffuse, "diffuse", mat.id + "-diffuse-sampler"); + WriteTextureColorEntry(mat.specular, "specular", mat.id + "-specular-sampler"); WriteFloatEntry(mat.shininess, "shininess"); - WriteTextureColorEntry(mat.reflective, "reflective", mat.name + "-reflective-sampler"); - WriteTextureColorEntry(mat.transparent, "transparent", mat.name + "-transparent-sampler"); + WriteTextureColorEntry(mat.reflective, "reflective", mat.id + "-reflective-sampler"); + WriteTextureColorEntry(mat.transparent, "transparent", mat.id + "-transparent-sampler"); WriteFloatEntry(mat.transparency, "transparency"); WriteFloatEntry(mat.index_refraction, "index_of_refraction"); if (!mat.normal.texture.empty()) { - WriteTextureColorEntry(mat.normal, "bump", mat.name + "-normal-sampler"); + WriteTextureColorEntry(mat.normal, "bump", mat.id + "-normal-sampler"); } PopTag(); @@ -823,9 +803,9 @@ void ColladaExporter::WriteMaterials() { PushTag(); for (std::vector::const_iterator it = materials.begin(); it != materials.end(); ++it) { const Material &mat = *it; - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PopTag(); mOutput << startstr << "" << endstr; } @@ -852,20 +832,18 @@ void ColladaExporter::WriteControllerLibrary() { // Writes a skin controller of the given mesh void ColladaExporter::WriteController(size_t pIndex) { const aiMesh *mesh = mScene->mMeshes[pIndex]; - const std::string idstr = mesh->mName.length == 0 ? GetMeshId(pIndex) : mesh->mName.C_Str(); - const std::string idstrEscaped = XMLIDEncode(idstr); - - if (mesh->mNumFaces == 0 || mesh->mNumVertices == 0) + // Is there a skin controller? + if (mesh->mNumBones == 0 || mesh->mNumFaces == 0 || mesh->mNumVertices == 0) return; - if (mesh->mNumBones == 0) - return; + const std::string idstr = GetObjectUniqueId(AiObjectType::Mesh, pIndex); + const std::string namestr = GetObjectName(AiObjectType::Mesh, pIndex); - mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); // bind pose matrix @@ -882,20 +860,20 @@ void ColladaExporter::WriteController(size_t pIndex) { PopTag(); mOutput << startstr << "" << endstr; - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "mNumBones << "\">"; + mOutput << startstr << "mNumBones << "\">"; for (size_t i = 0; i < mesh->mNumBones; ++i) - mOutput << XMLIDEncode(mesh->mBones[i]->mName.C_Str()) << " "; + mOutput << GetBoneUniqueId(mesh->mBones[i]) << ' '; mOutput << "" << endstr; mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "mNumBones << "\" stride=\"" << 1 << "\">" << endstr; + mOutput << startstr << "mNumBones << "\" stride=\"" << 1 << "\">" << endstr; PushTag(); mOutput << startstr << "" << endstr; @@ -932,8 +910,8 @@ void ColladaExporter::WriteController(size_t pIndex) { mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "" << endstr; - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PopTag(); mOutput << startstr << "" << endstr; @@ -941,8 +919,8 @@ void ColladaExporter::WriteController(size_t pIndex) { mOutput << startstr << "mNumVertices << "\">" << endstr; PushTag(); - mOutput << startstr << "" << endstr; - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; mOutput << startstr << ""; @@ -1017,9 +995,8 @@ void ColladaExporter::WriteGeometryLibrary() { // Writes the given mesh void ColladaExporter::WriteGeometry(size_t pIndex) { const aiMesh *mesh = mScene->mMeshes[pIndex]; - const std::string idstr = mesh->mName.length == 0 ? GetMeshId(pIndex) : mesh->mName.C_Str(); - const std::string geometryName = XMLEscape(idstr); - const std::string geometryId = XMLIDEncode(idstr); + const std::string geometryId = GetObjectUniqueId(AiObjectType::Mesh, pIndex); + const std::string geometryName = GetObjectName(AiObjectType::Mesh, pIndex); if (mesh->mNumFaces == 0 || mesh->mNumVertices == 0) return; @@ -1032,15 +1009,15 @@ void ColladaExporter::WriteGeometry(size_t pIndex) { PushTag(); // Positions - WriteFloatArray(idstr + "-positions", FloatType_Vector, (ai_real *)mesh->mVertices, mesh->mNumVertices); + WriteFloatArray(geometryId + "-positions", FloatType_Vector, (ai_real *)mesh->mVertices, mesh->mNumVertices); // Normals, if any if (mesh->HasNormals()) - WriteFloatArray(idstr + "-normals", FloatType_Vector, (ai_real *)mesh->mNormals, mesh->mNumVertices); + WriteFloatArray(geometryId + "-normals", FloatType_Vector, (ai_real *)mesh->mNormals, mesh->mNumVertices); // texture coords for (size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { if (mesh->HasTextureCoords(static_cast(a))) { - WriteFloatArray(idstr + "-tex" + to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2, + WriteFloatArray(geometryId + "-tex" + to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2, (ai_real *)mesh->mTextureCoords[a], mesh->mNumVertices); } } @@ -1048,7 +1025,7 @@ void ColladaExporter::WriteGeometry(size_t pIndex) { // vertex colors for (size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { if (mesh->HasVertexColors(static_cast(a))) - WriteFloatArray(idstr + "-color" + to_string(a), FloatType_Color, (ai_real *)mesh->mColors[a], mesh->mNumVertices); + WriteFloatArray(geometryId + "-color" + to_string(a), FloatType_Color, (ai_real *)mesh->mColors[a], mesh->mNumVertices); } // assemble vertex structure @@ -1248,17 +1225,29 @@ void ColladaExporter::WriteFloatArray(const std::string &pIdString, FloatDataTyp // ------------------------------------------------------------------------------------------------ // Writes the scene library void ColladaExporter::WriteSceneLibrary() { - const std::string sceneName = XMLEscape(mScene->mRootNode->mName.C_Str()); - const std::string sceneId = XMLIDEncode(mScene->mRootNode->mName.C_Str()); + // Determine if we are using the aiScene root or our own + std::string sceneName("Scene"); + if (mAdd_root_node) { + mSceneId = MakeUniqueId(mUniqueIds, sceneName, std::string()); + mUniqueIds.insert(mSceneId); + } else { + mSceneId = GetNodeUniqueId(mScene->mRootNode); + sceneName = GetNodeName(mScene->mRootNode); + } mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); - // start recursive write at the root node - for (size_t a = 0; a < mScene->mRootNode->mNumChildren; ++a) - WriteNode(mScene, mScene->mRootNode->mChildren[a]); + if (mAdd_root_node) { + // Export the root node + WriteNode(mScene->mRootNode); + } else { + // Have already exported the root node + for (size_t a = 0; a < mScene->mRootNode->mNumChildren; ++a) + WriteNode(mScene->mRootNode->mChildren[a]); + } PopTag(); mOutput << startstr << "" << endstr; @@ -1272,20 +1261,10 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex) { if (anim->mNumChannels == 0 && anim->mNumMeshChannels == 0 && anim->mNumMorphMeshChannels == 0) return; - const std::string animation_name_escaped = XMLEscape(anim->mName.C_Str()); - std::string idstr = anim->mName.C_Str(); - std::string ending = std::string("AnimId") + to_string(pIndex); - if (idstr.length() >= ending.length()) { - if (0 != idstr.compare(idstr.length() - ending.length(), ending.length(), ending)) { - idstr = idstr + ending; - } - } else { - idstr = idstr + ending; - } + const std::string animationNameEscaped = GetObjectName(AiObjectType::Animation, pIndex); + const std::string idstrEscaped = GetObjectUniqueId(AiObjectType::Animation, pIndex); - const std::string idstrEscaped = XMLIDEncode(idstr); - - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); std::string cur_node_idstr; @@ -1435,20 +1414,21 @@ void ColladaExporter::WriteAnimationsLibrary() { } // ------------------------------------------------------------------------------------------------ // Helper to find a bone by name in the scene -aiBone *findBone(const aiScene *scene, const char *name) { +aiBone *findBone(const aiScene *scene, const aiString &name) { for (size_t m = 0; m < scene->mNumMeshes; m++) { aiMesh *mesh = scene->mMeshes[m]; for (size_t b = 0; b < mesh->mNumBones; b++) { aiBone *bone = mesh->mBones[b]; - if (0 == strcmp(name, bone->mName.C_Str())) { + if (name == bone->mName) { return bone; } } } - return NULL; + return nullptr; } // ------------------------------------------------------------------------------------------------ +// Helper to find the node associated with a bone in the scene const aiNode *findBoneNode(const aiNode *aNode, const aiBone *bone) { if (aNode && bone && aNode->mName == bone->mName) { return aNode; @@ -1457,15 +1437,17 @@ const aiNode *findBoneNode(const aiNode *aNode, const aiBone *bone) { if (aNode && bone) { for (unsigned int i = 0; i < aNode->mNumChildren; ++i) { aiNode *aChild = aNode->mChildren[i]; - const aiNode *foundFromChild = 0; + const aiNode *foundFromChild = nullptr; if (aChild) { foundFromChild = findBoneNode(aChild, bone); - if (foundFromChild) return foundFromChild; + if (foundFromChild) { + return foundFromChild; + } } } } - return NULL; + return nullptr; } const aiNode *findSkeletonRootNode(const aiScene *scene, const aiMesh *mesh) { @@ -1476,7 +1458,7 @@ const aiNode *findSkeletonRootNode(const aiScene *scene, const aiMesh *mesh) { const aiNode *node = findBoneNode(scene->mRootNode, bone); if (node) { - while (node->mParent && findBone(scene, node->mParent->mName.C_Str()) != 0) { + while (node->mParent && findBone(scene, node->mParent->mName) != nullptr) { node = node->mParent; } topParentBoneNodes.insert(node); @@ -1496,45 +1478,36 @@ const aiNode *findSkeletonRootNode(const aiScene *scene, const aiMesh *mesh) { } } - return NULL; + return nullptr; } // ------------------------------------------------------------------------------------------------ // Recursively writes the given node -void ColladaExporter::WriteNode(const aiScene *pScene, aiNode *pNode) { - // the node must have a name - if (pNode->mName.length == 0) { - std::stringstream ss; - ss << "Node_" << pNode; - pNode->mName.Set(ss.str()); - } - +void ColladaExporter::WriteNode(const aiNode *pNode) { // If the node is associated with a bone, it is a joint node (JOINT) // otherwise it is a normal node (NODE) + // Assimp-specific: nodes with no name cannot be associated with bones const char *node_type; bool is_joint, is_skeleton_root = false; - if (nullptr == findBone(pScene, pNode->mName.C_Str())) { + if (pNode->mName.length == 0 || nullptr == findBone(mScene, pNode->mName)) { node_type = "NODE"; is_joint = false; } else { node_type = "JOINT"; is_joint = true; - if (!pNode->mParent || nullptr == findBone(pScene, pNode->mParent->mName.C_Str())) { + if (!pNode->mParent || nullptr == findBone(mScene, pNode->mParent->mName)) { is_skeleton_root = true; } } - const std::string node_id = XMLIDEncode(pNode->mName.data); - const std::string node_name = XMLEscape(pNode->mName.data); + const std::string node_id = GetNodeUniqueId(pNode); + const std::string node_name = GetNodeName(pNode); mOutput << startstr << "" << endstr; PushTag(); @@ -1573,14 +1546,14 @@ void ColladaExporter::WriteNode(const aiScene *pScene, aiNode *pNode) { //check if it is a camera node for (size_t i = 0; i < mScene->mNumCameras; i++) { if (mScene->mCameras[i]->mName == pNode->mName) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; break; } } //check if it is a light node for (size_t i = 0; i < mScene->mNumLights; i++) { if (mScene->mLights[i]->mName == pNode->mName) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; break; } } @@ -1593,22 +1566,22 @@ void ColladaExporter::WriteNode(const aiScene *pScene, aiNode *pNode) { if (mesh->mNumFaces == 0 || mesh->mNumVertices == 0) continue; - const std::string meshName = mesh->mName.length == 0 ? GetMeshId(pNode->mMeshes[a]) : mesh->mName.C_Str(); + const std::string meshId = GetObjectUniqueId(AiObjectType::Mesh, pNode->mMeshes[a]); if (mesh->mNumBones == 0) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); } else { mOutput << startstr - << "" + << "" << endstr; PushTag(); // note! this mFoundSkeletonRootNodeID some how affects animation, it makes the mesh attaches to armature skeleton root node. // use the first bone to find skeleton root - const aiNode *skeletonRootBoneNode = findSkeletonRootNode(pScene, mesh); + const aiNode *skeletonRootBoneNode = findSkeletonRootNode(mScene, mesh); if (skeletonRootBoneNode) { - mFoundSkeletonRootNodeID = XMLIDEncode(skeletonRootBoneNode->mName.C_Str()); + mFoundSkeletonRootNodeID = GetNodeUniqueId(skeletonRootBoneNode); } mOutput << startstr << "#" << mFoundSkeletonRootNodeID << "" << endstr; } @@ -1616,7 +1589,7 @@ void ColladaExporter::WriteNode(const aiScene *pScene, aiNode *pNode) { PushTag(); mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "mMaterialIndex].name) << "\">" << endstr; + mOutput << startstr << "mMaterialIndex) << "\">" << endstr; PushTag(); for (size_t aa = 0; aa < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++aa) { if (mesh->HasTextureCoords(static_cast(aa))) @@ -1641,11 +1614,135 @@ void ColladaExporter::WriteNode(const aiScene *pScene, aiNode *pNode) { // recurse into subnodes for (size_t a = 0; a < pNode->mNumChildren; ++a) - WriteNode(pScene, pNode->mChildren[a]); + WriteNode(pNode->mChildren[a]); PopTag(); mOutput << startstr << "" << endstr; } +void ColladaExporter::CreateNodeIds(const aiNode *node) { + GetNodeUniqueId(node); + for (size_t a = 0; a < node->mNumChildren; ++a) + CreateNodeIds(node->mChildren[a]); +} + +std::string ColladaExporter::GetNodeUniqueId(const aiNode *node) { + // Use the pointer as the key. This is safe because the scene is immutable. + auto idIt = mNodeIdMap.find(node); + if (idIt != mNodeIdMap.cend()) + return idIt->second; + + // Prefer the requested Collada Id if extant + std::string idStr; + aiString origId; + if (node->mMetaData && node->mMetaData->Get(AI_METADATA_COLLADA_ID, origId)) { + idStr = origId.C_Str(); + } else { + idStr = node->mName.C_Str(); + } + // Make sure the requested id is valid + if (idStr.empty()) + idStr = "node"; + else + idStr = XMLIDEncode(idStr); + + // Ensure it's unique + idStr = MakeUniqueId(mUniqueIds, idStr, std::string()); + mUniqueIds.insert(idStr); + mNodeIdMap.insert(std::make_pair(node, idStr)); + return idStr; +} + +std::string ColladaExporter::GetNodeName(const aiNode *node) { + + return XMLEscape(node->mName.C_Str()); +} + +std::string ColladaExporter::GetBoneUniqueId(const aiBone *bone) { + // Find the Node that is this Bone + const aiNode *boneNode = findBoneNode(mScene->mRootNode, bone); + if (boneNode == nullptr) + return std::string(); + + return GetNodeUniqueId(boneNode); +} + +std::string ColladaExporter::GetObjectUniqueId(AiObjectType type, size_t pIndex) { + auto idIt = GetObjectIdMap(type).find(pIndex); + if (idIt != GetObjectIdMap(type).cend()) + return idIt->second; + + // Not seen this object before, create and add + NameIdPair result = AddObjectIndexToMaps(type, pIndex); + return result.second; +} + +std::string ColladaExporter::GetObjectName(AiObjectType type, size_t pIndex) { + auto objectName = GetObjectNameMap(type).find(pIndex); + if (objectName != GetObjectNameMap(type).cend()) + return objectName->second; + + // Not seen this object before, create and add + NameIdPair result = AddObjectIndexToMaps(type, pIndex); + return result.first; +} + +// Determine unique id and add the name and id to the maps +// @param type object type +// @param index object index +// @param name in/out. Caller to set the original name if known. +// @param idStr in/out. Caller to set the preferred id if known. +ColladaExporter::NameIdPair ColladaExporter::AddObjectIndexToMaps(AiObjectType type, size_t index) { + + std::string name; + std::string idStr; + std::string idPostfix; + + // Get the name and id postfix + switch (type) { + case AiObjectType::Mesh: name = mScene->mMeshes[index]->mName.C_Str(); break; + case AiObjectType::Material: name = mScene->mMaterials[index]->GetName().C_Str(); break; + case AiObjectType::Animation: name = mScene->mAnimations[index]->mName.C_Str(); break; + case AiObjectType::Light: + name = mScene->mLights[index]->mName.C_Str(); + idPostfix = "-light"; + break; + case AiObjectType::Camera: + name = mScene->mCameras[index]->mName.C_Str(); + idPostfix = "-camera"; + break; + case AiObjectType::Count: throw std::logic_error("ColladaExporter::AiObjectType::Count is not an object type"); + } + + if (name.empty()) { + // Default ids if empty name + switch (type) { + case AiObjectType::Mesh: idStr = std::string("mesh_"); break; + case AiObjectType::Material: idStr = std::string("material_"); break; // This one should never happen + case AiObjectType::Animation: idStr = std::string("animation_"); break; + case AiObjectType::Light: idStr = std::string("light_"); break; + case AiObjectType::Camera: idStr = std::string("camera_"); break; + case AiObjectType::Count: throw std::logic_error("ColladaExporter::AiObjectType::Count is not an object type"); + } + idStr.append(to_string(index)); + } else { + idStr = XMLIDEncode(name); + } + + if (!name.empty()) + name = XMLEscape(name); + + idStr = MakeUniqueId(mUniqueIds, idStr, idPostfix); + + // Add to maps + mUniqueIds.insert(idStr); + GetObjectIdMap(type).insert(std::make_pair(index, idStr)); + GetObjectNameMap(type).insert(std::make_pair(index, name)); + + return std::make_pair(name, idStr); +} + +} // end of namespace Assimp + #endif #endif diff --git a/code/AssetLib/Collada/ColladaExporter.h b/code/AssetLib/Collada/ColladaExporter.h index f6c66e279..e9a3530ae 100644 --- a/code/AssetLib/Collada/ColladaExporter.h +++ b/code/AssetLib/Collada/ColladaExporter.h @@ -48,28 +48,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include struct aiScene; struct aiNode; +struct aiLight; +struct aiBone; -namespace Assimp -{ +namespace Assimp { + +class IOSystem; /// Helper class to export a given scene to a Collada file. Just for my personal /// comfort when implementing it. -class ColladaExporter -{ +class ColladaExporter { public: /// Constructor for a specific scene to export - ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file); + ColladaExporter(const aiScene *pScene, IOSystem *pIOSystem, const std::string &path, const std::string &file); /// Destructor virtual ~ColladaExporter(); @@ -107,51 +107,87 @@ protected: void WriteControllerLibrary(); /// Writes a skin controller of the given mesh - void WriteController( size_t pIndex); + void WriteController(size_t pIndex); /// Writes the geometry library void WriteGeometryLibrary(); /// Writes the given mesh - void WriteGeometry( size_t pIndex); + void WriteGeometry(size_t pIndex); //enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight }; // customized to add animation related type - enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight, FloatType_Time }; + enum FloatDataType { FloatType_Vector, + FloatType_TexCoord2, + FloatType_TexCoord3, + FloatType_Color, + FloatType_Mat4x4, + FloatType_Weight, + FloatType_Time }; /// Writes a float array of the given type - void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount); + void WriteFloatArray(const std::string &pIdString, FloatDataType pType, const ai_real *pData, size_t pElementCount); /// Writes the scene library void WriteSceneLibrary(); - // customized, Writes the animation library - void WriteAnimationsLibrary(); - void WriteAnimationLibrary( size_t pIndex); - std::string mFoundSkeletonRootNodeID = "skeleton_root"; // will be replaced by found node id in the WriteNode call. - + // customized, Writes the animation library + void WriteAnimationsLibrary(); + void WriteAnimationLibrary(size_t pIndex); + std::string mFoundSkeletonRootNodeID = "skeleton_root"; // will be replaced by found node id in the WriteNode call. + /// Recursively writes the given node - void WriteNode( const aiScene* scene, aiNode* pNode); + void WriteNode(const aiNode *pNode); /// Enters a new xml element, which increases the indentation - void PushTag() { startstr.append( " "); } + void PushTag() { startstr.append(" "); } /// Leaves an element, decreasing the indentation - void PopTag() { - ai_assert( startstr.length() > 1); - startstr.erase( startstr.length() - 2); + void PopTag() { + ai_assert(startstr.length() > 1); + startstr.erase(startstr.length() - 2); } - /// Creates a mesh ID for the given mesh - std::string GetMeshId( size_t pIndex) const { - return std::string( "meshId" ) + to_string(pIndex); - } + void CreateNodeIds(const aiNode *node); + + /// Get or Create a unique Node ID string for the given Node + std::string GetNodeUniqueId(const aiNode *node); + std::string GetNodeName(const aiNode *node); + + std::string GetBoneUniqueId(const aiBone *bone); + + enum class AiObjectType { + Mesh, + Material, + Animation, + Light, + Camera, + Count, + }; + /// Get or Create a unique ID string for the given scene object index + std::string GetObjectUniqueId(AiObjectType type, size_t pIndex); + /// Get or Create a name string for the given scene object index + std::string GetObjectName(AiObjectType type, size_t pIndex); + + typedef std::map IndexIdMap; + typedef std::pair NameIdPair; + NameIdPair AddObjectIndexToMaps(AiObjectType type, size_t pIndex); + + // Helpers + inline IndexIdMap &GetObjectIdMap(AiObjectType type) { return mObjectIdMap[static_cast(type)]; } + inline IndexIdMap &GetObjectNameMap(AiObjectType type) { return mObjectNameMap[static_cast(type)]; } + +private: + std::unordered_set mUniqueIds; // Cache of used unique ids + std::map mNodeIdMap; // Cache of encoded node and bone ids + std::array(AiObjectType::Count)> mObjectIdMap; // Cache of encoded unique IDs + std::array(AiObjectType::Count)> mObjectNameMap; // Cache of encoded names public: /// Stringstream to write all output into std::stringstream mOutput; /// The IOSystem for output - IOSystem* mIOSystem; + IOSystem *mIOSystem; /// Path of the directory where the scene will be exported const std::string mPath; @@ -160,63 +196,62 @@ public: const std::string mFile; /// The scene to be written - const aiScene* mScene; - bool mSceneOwned; + const aiScene *const mScene; + std::string mSceneId; + bool mAdd_root_node = false; /// current line start string, contains the current indentation for simple stream insertion std::string startstr; /// current line end string for simple stream insertion - std::string endstr; + const std::string endstr; - // pair of color and texture - texture precedences color - struct Surface - { - bool exist; - aiColor4D color; - std::string texture; - size_t channel; - Surface() { exist = false; channel = 0; } - }; + // pair of color and texture - texture precedences color + struct Surface { + bool exist; + aiColor4D color; + std::string texture; + size_t channel; + Surface() { + exist = false; + channel = 0; + } + }; - struct Property - { - bool exist; - ai_real value; - Property() - : exist(false) - , value(0.0) - {} - }; + struct Property { + bool exist; + ai_real value; + Property() : + exist(false), + value(0.0) {} + }; - // summarize a material in an convenient way. - struct Material - { - std::string name; - std::string shading_model; - Surface ambient, diffuse, specular, emissive, reflective, transparent, normal; - Property shininess, transparency, index_refraction; + // summarize a material in an convenient way. + struct Material { + std::string id; + std::string name; + std::string shading_model; + Surface ambient, diffuse, specular, emissive, reflective, transparent, normal; + Property shininess, transparency, index_refraction; - Material() {} - }; + Material() {} + }; - std::vector materials; - - std::map textures; + std::map textures; public: - /// Dammit C++ - y u no compile two-pass? No I have to add all methods below the struct definitions - /// Reads a single surface entry from the given material keys - void ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex); - /// Writes an image entry for the given surface - void WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd); - /// Writes the two parameters necessary for referencing a texture in an effect entry - void WriteTextureParamEntry( const Surface& pSurface, const std::string& pTypeName, const std::string& pMatName); - /// Writes a color-or-texture entry into an effect definition - void WriteTextureColorEntry( const Surface& pSurface, const std::string& pTypeName, const std::string& pImageName); - /// Writes a scalar property - void WriteFloatEntry( const Property& pProperty, const std::string& pTypeName); + /// Dammit C++ - y u no compile two-pass? No I have to add all methods below the struct definitions + /// Reads a single surface entry from the given material keys + bool ReadMaterialSurface(Surface &poSurface, const aiMaterial &pSrcMat, aiTextureType pTexture, const char *pKey, size_t pType, size_t pIndex); + /// Writes an image entry for the given surface + void WriteImageEntry(const Surface &pSurface, const std::string &imageId); + /// Writes the two parameters necessary for referencing a texture in an effect entry + void WriteTextureParamEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &materialId); + /// Writes a color-or-texture entry into an effect definition + void WriteTextureColorEntry(const Surface &pSurface, const std::string &pTypeName, const std::string &imageId); + /// Writes a scalar property + void WriteFloatEntry(const Property &pProperty, const std::string &pTypeName); }; -} +} // namespace Assimp #endif // !! AI_COLLADAEXPORTER_H_INC diff --git a/code/AssetLib/Collada/ColladaHelper.cpp b/code/AssetLib/Collada/ColladaHelper.cpp index 6f1fed366..50d70e640 100644 --- a/code/AssetLib/Collada/ColladaHelper.cpp +++ b/code/AssetLib/Collada/ColladaHelper.cpp @@ -43,8 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "ColladaHelper.h" -#include #include +#include namespace Assimp { namespace Collada { @@ -63,42 +63,35 @@ const MetaKeyPairVector &GetColladaAssimpMetaKeys() { const MetaKeyPairVector MakeColladaAssimpMetaKeysCamelCase() { MetaKeyPairVector result = MakeColladaAssimpMetaKeys(); - for (auto &val : result) - { + for (auto &val : result) { ToCamelCase(val.first); } return result; }; -const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase() -{ +const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase() { static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase(); return result; } // ------------------------------------------------------------------------------------------------ // Convert underscore_separated to CamelCase: "authoring_tool" becomes "AuthoringTool" -void ToCamelCase(std::string &text) -{ +void ToCamelCase(std::string &text) { if (text.empty()) return; // Capitalise first character auto it = text.begin(); (*it) = ToUpper(*it); ++it; - for (/*started above*/ ; it != text.end(); /*iterated below*/) - { - if ((*it) == '_') - { + for (/*started above*/; it != text.end(); /*iterated below*/) { + if ((*it) == '_') { it = text.erase(it); if (it != text.end()) (*it) = ToUpper(*it); - } - else - { + } else { // Make lower case (*it) = ToLower(*it); - ++it; + ++it; } } } diff --git a/code/AssetLib/Collada/ColladaHelper.h b/code/AssetLib/Collada/ColladaHelper.h index c6e2e7ddd..bc93203aa 100644 --- a/code/AssetLib/Collada/ColladaHelper.h +++ b/code/AssetLib/Collada/ColladaHelper.h @@ -45,31 +45,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_COLLADAHELPER_H_INC #define AI_COLLADAHELPER_H_INC -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include +#include struct aiMaterial; -namespace Assimp { -namespace Collada { +namespace Assimp { +namespace Collada { /** Collada file versions which evolved during the years ... */ -enum FormatVersion -{ +enum FormatVersion { FV_1_5_n, FV_1_4_n, FV_1_3_n }; - /** Transformation types that can be applied to a node */ -enum TransformType -{ +enum TransformType { TF_LOOKAT, TF_ROTATE, TF_TRANSLATE, @@ -79,10 +76,9 @@ enum TransformType }; /** Different types of input data to a vertex or face */ -enum InputType -{ +enum InputType { IT_Invalid, - IT_Vertex, // special type for per-index data referring to the element carrying the per-vertex data. + IT_Vertex, // special type for per-index data referring to the element carrying the per-vertex data. IT_Position, IT_Normal, IT_Texcoord, @@ -92,15 +88,13 @@ enum InputType }; /** Supported controller types */ -enum ControllerType -{ +enum ControllerType { Skin, Morph }; /** Supported morph methods */ -enum MorphMethod -{ +enum MorphMethod { Normalized, Relative }; @@ -118,24 +112,21 @@ const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase(); void ToCamelCase(std::string &text); /** Contains all data for one of the different transformation types */ -struct Transform -{ - std::string mID; ///< SID of the transform step, by which anim channels address their target node +struct Transform { + std::string mID; ///< SID of the transform step, by which anim channels address their target node TransformType mType; ai_real f[16]; ///< Interpretation of data depends on the type of the transformation }; /** A collada camera. */ -struct Camera -{ - Camera() - : mOrtho (false) - , mHorFov (10e10f) - , mVerFov (10e10f) - , mAspect (10e10f) - , mZNear (0.1f) - , mZFar (1000.f) - {} +struct Camera { + Camera() : + mOrtho(false), + mHorFov(10e10f), + mVerFov(10e10f), + mAspect(10e10f), + mZNear(0.1f), + mZFar(1000.f) {} // Name of camera std::string mName; @@ -159,19 +150,17 @@ struct Camera #define ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET 1e9f /** A collada light source. */ -struct Light -{ - Light() - : mType (aiLightSource_UNDEFINED) - , mAttConstant (1.f) - , mAttLinear (0.f) - , mAttQuadratic (0.f) - , mFalloffAngle (180.f) - , mFalloffExponent (0.f) - , mPenumbraAngle (ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET) - , mOuterAngle (ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET) - , mIntensity (1.f) - {} +struct Light { + Light() : + mType(aiLightSource_UNDEFINED), + mAttConstant(1.f), + mAttLinear(0.f), + mAttQuadratic(0.f), + mFalloffAngle(180.f), + mFalloffExponent(0.f), + mPenumbraAngle(ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET), + mOuterAngle(ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET), + mIntensity(1.f) {} //! Type of the light source aiLightSourceType + ambient unsigned int mType; @@ -180,7 +169,7 @@ struct Light aiColor3D mColor; //! Light attenuation - ai_real mAttConstant,mAttLinear,mAttQuadratic; + ai_real mAttConstant, mAttLinear, mAttQuadratic; //! Spot light falloff ai_real mFalloffAngle; @@ -198,12 +187,10 @@ struct Light }; /** Short vertex index description */ -struct InputSemanticMapEntry -{ - InputSemanticMapEntry() - : mSet(0) - , mType(IT_Invalid) - {} +struct InputSemanticMapEntry { + InputSemanticMapEntry() : + mSet(0), + mType(IT_Invalid) {} //! Index of set, optional unsigned int mSet; @@ -213,8 +200,7 @@ struct InputSemanticMapEntry }; /** Table to map from effect to vertex input semantics */ -struct SemanticMappingTable -{ +struct SemanticMappingTable { //! Name of material std::string mMatName; @@ -222,7 +208,7 @@ struct SemanticMappingTable std::map mMap; //! For std::find - bool operator == (const std::string& s) const { + bool operator==(const std::string &s) const { return s == mMatName; } }; @@ -230,8 +216,7 @@ struct SemanticMappingTable /** A reference to a mesh inside a node, including materials assigned to the various subgroups. * The ID refers to either a mesh or a controller which specifies the mesh */ -struct MeshInstance -{ +struct MeshInstance { ///< ID of the mesh or controller to be instanced std::string mMeshOrController; @@ -240,34 +225,30 @@ struct MeshInstance }; /** A reference to a camera inside a node*/ -struct CameraInstance -{ - ///< ID of the camera +struct CameraInstance { + ///< ID of the camera std::string mCamera; }; /** A reference to a light inside a node*/ -struct LightInstance -{ - ///< ID of the camera +struct LightInstance { + ///< ID of the camera std::string mLight; }; /** A reference to a node inside a node*/ -struct NodeInstance -{ - ///< ID of the node +struct NodeInstance { + ///< ID of the node std::string mNode; }; /** A node in a scene hierarchy */ -struct Node -{ +struct Node { std::string mName; std::string mID; std::string mSID; - Node* mParent; - std::vector mChildren; + Node *mParent; + std::vector mChildren; /** Operations in order to calculate the resulting transformation to parent. */ std::vector mTransforms; @@ -288,80 +269,83 @@ struct Node std::string mPrimaryCamera; //! Constructor. Begin with a zero parent - Node() - : mParent( nullptr ){ + Node() : + mParent(nullptr) { // empty } //! Destructor: delete all children subsequently ~Node() { - for( std::vector::iterator it = mChildren.begin(); it != mChildren.end(); ++it) + for (std::vector::iterator it = mChildren.begin(); it != mChildren.end(); ++it) delete *it; } }; /** Data source array: either floats or strings */ -struct Data -{ +struct Data { bool mIsStringArray; std::vector mValues; std::vector mStrings; }; /** Accessor to a data array */ -struct Accessor -{ - size_t mCount; // in number of objects - size_t mSize; // size of an object, in elements (floats or strings, mostly 1) - size_t mOffset; // in number of values - size_t mStride; // Stride in number of values +struct Accessor { + size_t mCount; // in number of objects + size_t mSize; // size of an object, in elements (floats or strings, mostly 1) + size_t mOffset; // in number of values + size_t mStride; // Stride in number of values std::vector mParams; // names of the data streams in the accessors. Empty string tells to ignore. size_t mSubOffset[4]; // Suboffset inside the object for the common 4 elements. For a vector, that's XYZ, for a color RGBA and so on. - // For example, SubOffset[0] denotes which of the values inside the object is the vector X component. - std::string mSource; // URL of the source array - mutable const Data* mData; // Pointer to the source array, if resolved. NULL else + // For example, SubOffset[0] denotes which of the values inside the object is the vector X component. + std::string mSource; // URL of the source array + mutable const Data *mData; // Pointer to the source array, if resolved. nullptr else - Accessor() - { - mCount = 0; mSize = 0; mOffset = 0; mStride = 0; mData = NULL; + Accessor() { + mCount = 0; + mSize = 0; + mOffset = 0; + mStride = 0; + mData = nullptr; mSubOffset[0] = mSubOffset[1] = mSubOffset[2] = mSubOffset[3] = 0; } }; /** A single face in a mesh */ -struct Face -{ +struct Face { std::vector mIndices; }; /** An input channel for mesh data, referring to a single accessor */ -struct InputChannel -{ - InputType mType; // Type of the data - size_t mIndex; // Optional index, if multiple sets of the same data type are given - size_t mOffset; // Index offset in the indices array of per-face indices. Don't ask, can't explain that any better. +struct InputChannel { + InputType mType; // Type of the data + size_t mIndex; // Optional index, if multiple sets of the same data type are given + size_t mOffset; // Index offset in the indices array of per-face indices. Don't ask, can't explain that any better. std::string mAccessor; // ID of the accessor where to read the actual values from. - mutable const Accessor* mResolved; // Pointer to the accessor, if resolved. NULL else + mutable const Accessor *mResolved; // Pointer to the accessor, if resolved. nullptr else - InputChannel() { mType = IT_Invalid; mIndex = 0; mOffset = 0; mResolved = NULL; } + InputChannel() { + mType = IT_Invalid; + mIndex = 0; + mOffset = 0; + mResolved = nullptr; + } }; /** Subset of a mesh with a certain material */ -struct SubMesh -{ +struct SubMesh { std::string mMaterial; ///< subgroup identifier size_t mNumFaces; ///< number of faces in this submesh }; /** Contains data for a single mesh */ -struct Mesh -{ - Mesh() - { - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) +struct Mesh { + Mesh(const std::string &id) : + mId(id) { + for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) mNumUVComponents[i] = 2; } + const std::string mId; std::string mName; // just to check if there's some sophisticated addressing involved... @@ -377,7 +361,7 @@ struct Mesh std::vector mTangents; std::vector mBitangents; std::vector mTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; - std::vector mColors[AI_MAX_NUMBER_OF_COLOR_SETS]; + std::vector mColors[AI_MAX_NUMBER_OF_COLOR_SETS]; unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS]; @@ -394,8 +378,7 @@ struct Mesh }; /** Which type of primitives the ReadPrimitives() function is going to read */ -enum PrimitiveType -{ +enum PrimitiveType { Prim_Invalid, Prim_Lines, Prim_LineStrip, @@ -407,8 +390,7 @@ enum PrimitiveType }; /** A skeleton controller to deform a mesh with the use of joints */ -struct Controller -{ +struct Controller { // controller type ControllerType mType; @@ -436,36 +418,32 @@ struct Controller std::vector mWeightCounts; // JointIndex-WeightIndex pairs for all vertices - std::vector< std::pair > mWeights; + std::vector> mWeights; std::string mMorphTarget; std::string mMorphWeight; }; /** A collada material. Pretty much the only member is a reference to an effect. */ -struct Material -{ +struct Material { std::string mName; std::string mEffect; }; /** Type of the effect param */ -enum ParamType -{ +enum ParamType { Param_Sampler, Param_Surface }; /** A param for an effect. Might be of several types, but they all just refer to each other, so I summarize them */ -struct EffectParam -{ +struct EffectParam { ParamType mType; std::string mReference; // to which other thing the param is referring to. }; /** Shading type supported by the standard effect spec of Collada */ -enum ShadeType -{ +enum ShadeType { Shade_Invalid, Shade_Constant, Shade_Lambert, @@ -474,18 +452,16 @@ enum ShadeType }; /** Represents a texture sampler in collada */ -struct Sampler -{ - Sampler() - : mWrapU (true) - , mWrapV (true) - , mMirrorU () - , mMirrorV () - , mOp (aiTextureOp_Multiply) - , mUVId (UINT_MAX) - , mWeighting (1.f) - , mMixWithPrevious (1.f) - {} +struct Sampler { + Sampler() : + mWrapU(true), + mWrapV(true), + mMirrorU(), + mMirrorV(), + mOp(aiTextureOp_Multiply), + mUVId(UINT_MAX), + mWeighting(1.f), + mMixWithPrevious(1.f) {} /** Name of image reference */ @@ -537,18 +513,17 @@ struct Sampler /** A collada effect. Can contain about anything according to the Collada spec, but we limit our version to a reasonable subset. */ -struct Effect -{ +struct Effect { // Shading mode ShadeType mShadeType; // Colors aiColor4D mEmissive, mAmbient, mDiffuse, mSpecular, - mTransparent, mReflective; + mTransparent, mReflective; // Textures Sampler mTexEmissive, mTexAmbient, mTexDiffuse, mTexSpecular, - mTexTransparent, mTexBump, mTexReflective; + mTexTransparent, mTexBump, mTexReflective; // Scalar factory ai_real mShininess, mRefractIndex, mReflectivity; @@ -566,30 +541,28 @@ struct Effect // Double-sided? bool mDoubleSided, mWireframe, mFaceted; - Effect() - : mShadeType (Shade_Phong) - , mEmissive ( 0, 0, 0, 1) - , mAmbient ( 0.1f, 0.1f, 0.1f, 1) - , mDiffuse ( 0.6f, 0.6f, 0.6f, 1) - , mSpecular ( 0.4f, 0.4f, 0.4f, 1) - , mTransparent ( 0, 0, 0, 1) - , mShininess (10.0f) - , mRefractIndex (1.f) - , mReflectivity (0.f) - , mTransparency (1.f) - , mHasTransparency (false) - , mRGBTransparency(false) - , mInvertTransparency(false) - , mDoubleSided (false) - , mWireframe (false) - , mFaceted (false) - { + Effect() : + mShadeType(Shade_Phong), + mEmissive(0, 0, 0, 1), + mAmbient(0.1f, 0.1f, 0.1f, 1), + mDiffuse(0.6f, 0.6f, 0.6f, 1), + mSpecular(0.4f, 0.4f, 0.4f, 1), + mTransparent(0, 0, 0, 1), + mShininess(10.0f), + mRefractIndex(1.f), + mReflectivity(0.f), + mTransparency(1.f), + mHasTransparency(false), + mRGBTransparency(false), + mInvertTransparency(false), + mDoubleSided(false), + mWireframe(false), + mFaceted(false) { } }; /** An image, meaning texture */ -struct Image -{ +struct Image { std::string mFileName; /** Embedded image data */ @@ -600,8 +573,7 @@ struct Image }; /** An animation channel. */ -struct AnimationChannel -{ +struct AnimationChannel { /** URL of the data to animate. Could be about anything, but we support only the * "NodeID/TransformID.SubElement" notation */ @@ -620,8 +592,7 @@ struct AnimationChannel }; /** An animation. Container for 0-x animation channels or 0-x animations */ -struct Animation -{ +struct Animation { /** Anim name */ std::string mName; @@ -629,96 +600,86 @@ struct Animation std::vector mChannels; /** the sub-animations, if any */ - std::vector mSubAnims; + std::vector mSubAnims; /** Destructor */ - ~Animation() - { - for( std::vector::iterator it = mSubAnims.begin(); it != mSubAnims.end(); ++it) + ~Animation() { + for (std::vector::iterator it = mSubAnims.begin(); it != mSubAnims.end(); ++it) delete *it; } - /** Collect all channels in the animation hierarchy into a single channel list. */ - void CollectChannelsRecursively(std::vector &channels) - { - channels.insert(channels.end(), mChannels.begin(), mChannels.end()); + /** Collect all channels in the animation hierarchy into a single channel list. */ + void CollectChannelsRecursively(std::vector &channels) { + channels.insert(channels.end(), mChannels.begin(), mChannels.end()); - for (std::vector::iterator it = mSubAnims.begin(); it != mSubAnims.end(); ++it) - { - Animation *pAnim = (*it); + for (std::vector::iterator it = mSubAnims.begin(); it != mSubAnims.end(); ++it) { + Animation *pAnim = (*it); - pAnim->CollectChannelsRecursively(channels); - } - } + pAnim->CollectChannelsRecursively(channels); + } + } - /** Combine all single-channel animations' channel into the same (parent) animation channel list. */ - void CombineSingleChannelAnimations() - { - CombineSingleChannelAnimationsRecursively(this); - } + /** Combine all single-channel animations' channel into the same (parent) animation channel list. */ + void CombineSingleChannelAnimations() { + CombineSingleChannelAnimationsRecursively(this); + } - void CombineSingleChannelAnimationsRecursively(Animation *pParent) - { - std::set childrenTargets; - bool childrenAnimationsHaveDifferentChannels = true; + void CombineSingleChannelAnimationsRecursively(Animation *pParent) { + std::set childrenTargets; + bool childrenAnimationsHaveDifferentChannels = true; - for (std::vector::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();) - { - Animation *anim = *it; - CombineSingleChannelAnimationsRecursively(anim); + for (std::vector::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();) { + Animation *anim = *it; + CombineSingleChannelAnimationsRecursively(anim); - if (childrenAnimationsHaveDifferentChannels && anim->mChannels.size() == 1 && - childrenTargets.find(anim->mChannels[0].mTarget) == childrenTargets.end()) { - childrenTargets.insert(anim->mChannels[0].mTarget); - } else { - childrenAnimationsHaveDifferentChannels = false; - } + if (childrenAnimationsHaveDifferentChannels && anim->mChannels.size() == 1 && + childrenTargets.find(anim->mChannels[0].mTarget) == childrenTargets.end()) { + childrenTargets.insert(anim->mChannels[0].mTarget); + } else { + childrenAnimationsHaveDifferentChannels = false; + } - ++it; - } + ++it; + } - // We only want to combine animations if they have different channels - if (childrenAnimationsHaveDifferentChannels) - { - for (std::vector::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();) - { - Animation *anim = *it; + // We only want to combine animations if they have different channels + if (childrenAnimationsHaveDifferentChannels) { + for (std::vector::iterator it = pParent->mSubAnims.begin(); it != pParent->mSubAnims.end();) { + Animation *anim = *it; - pParent->mChannels.push_back(anim->mChannels[0]); + pParent->mChannels.push_back(anim->mChannels[0]); - it = pParent->mSubAnims.erase(it); + it = pParent->mSubAnims.erase(it); - delete anim; - continue; - } - } - } + delete anim; + continue; + } + } + } }; /** Description of a collada animation channel which has been determined to affect the current node */ -struct ChannelEntry -{ - const Collada::AnimationChannel* mChannel; ///> the source channel +struct ChannelEntry { + const Collada::AnimationChannel *mChannel; ///> the source channel std::string mTargetId; - std::string mTransformId; // the ID of the transformation step of the node which is influenced + std::string mTransformId; // the ID of the transformation step of the node which is influenced size_t mTransformIndex; // Index into the node's transform chain to apply the channel to size_t mSubElement; // starting index inside the transform data // resolved data references - const Collada::Accessor* mTimeAccessor; ///> Collada accessor to the time values - const Collada::Data* mTimeData; ///> Source data array for the time values - const Collada::Accessor* mValueAccessor; ///> Collada accessor to the key value values - const Collada::Data* mValueData; ///> Source datat array for the key value values + const Collada::Accessor *mTimeAccessor; ///> Collada accessor to the time values + const Collada::Data *mTimeData; ///> Source data array for the time values + const Collada::Accessor *mValueAccessor; ///> Collada accessor to the key value values + const Collada::Data *mValueData; ///> Source datat array for the key value values - ChannelEntry() - : mChannel() - , mTransformIndex() - , mSubElement() - , mTimeAccessor() - , mTimeData() - , mValueAccessor() - , mValueData() - {} + ChannelEntry() : + mChannel(), + mTransformIndex(), + mSubElement(), + mTimeAccessor(), + mTimeData(), + mValueAccessor(), + mValueData() {} }; } // end of namespace Collada diff --git a/code/AssetLib/Collada/ColladaLoader.cpp b/code/AssetLib/Collada/ColladaLoader.cpp index b78fc0e3b..7b0fdd8e0 100644 --- a/code/AssetLib/Collada/ColladaLoader.cpp +++ b/code/AssetLib/Collada/ColladaLoader.cpp @@ -46,27 +46,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "ColladaLoader.h" #include "ColladaParser.h" +#include +#include #include +#include #include #include #include -#include -#include -#include +#include #include #include -#include #include +#include -#include "time.h" #include "math.h" +#include "time.h" #include -#include #include +#include namespace Assimp { - + using namespace Assimp::Formatter; static const aiImporterDesc desc = { @@ -82,22 +83,34 @@ static const aiImporterDesc desc = { "dae zae" }; +static const float kMillisecondsFromSeconds = 1000.f; + +// Add an item of metadata to a node +// Assumes the key is not already in the list +template +inline void AddNodeMetaData(aiNode *node, const std::string &key, const T &value) { + if (nullptr == node->mMetaData) { + node->mMetaData = new aiMetadata(); + } + node->mMetaData->Add(key, value); +} + // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -ColladaLoader::ColladaLoader() - : mFileName() - , mMeshIndexByID() - , mMaterialIndexByName() - , mMeshes() - , newMats() - , mCameras() - , mLights() - , mTextures() - , mAnims() - , noSkeletonMesh(false) - , ignoreUpDirection(false) - , useColladaName(false) - , mNodeNameCounter(0) { +ColladaLoader::ColladaLoader() : + mFileName(), + mMeshIndexByID(), + mMaterialIndexByName(), + mMeshes(), + newMats(), + mCameras(), + mLights(), + mTextures(), + mAnims(), + noSkeletonMesh(false), + ignoreUpDirection(false), + useColladaName(false), + mNodeNameCounter(0) { // empty } @@ -109,7 +122,7 @@ ColladaLoader::~ColladaLoader() { // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool ColladaLoader::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const { +bool ColladaLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { // check file extension const std::string extension = GetExtension(pFile); @@ -132,12 +145,12 @@ bool ColladaLoader::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool if (extension == "xml" || !extension.length() || checkSig) { /* If CanRead() is called in order to check whether we * support a specific file extension in general pIOHandler - * might be NULL and it's our duty to return true here. + * might be nullptr and it's our duty to return true here. */ if (!pIOHandler) { return true; } - static const char* tokens[] = { "GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES, 0) != 0; ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION, 0) != 0; useColladaName = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES, 0) != 0; @@ -153,13 +166,13 @@ void ColladaLoader::SetupProperties(const Importer* pImp) { // ------------------------------------------------------------------------------------------------ // Get file extension list -const aiImporterDesc* ColladaLoader::GetInfo() const { +const aiImporterDesc *ColladaLoader::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void ColladaLoader::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { +void ColladaLoader::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { mFileName = pFile; // clean all member arrays - just for safety, it should work even if we did not @@ -176,14 +189,13 @@ void ColladaLoader::InternReadFile(const std::string& pFile, aiScene* pScene, IO // parse the input file ColladaParser parser(pIOHandler, pFile); - - if( !parser.mRootNode) { - throw DeadlyImportError( "Collada: File came out empty. Something is wrong here."); + if (!parser.mRootNode) { + throw DeadlyImportError("Collada: File came out empty. Something is wrong here."); } // reserve some storage to avoid unnecessary reallocs - newMats.reserve(parser.mMaterialLibrary.size()*2u); - mMeshes.reserve(parser.mMeshLibrary.size()*2u); + newMats.reserve(parser.mMaterialLibrary.size() * 2u); + mMeshes.reserve(parser.mMeshLibrary.size() * 2u); mCameras.reserve(parser.mCameraLibrary.size()); mLights.reserve(parser.mLightLibrary.size()); @@ -199,24 +211,24 @@ void ColladaLoader::InternReadFile(const std::string& pFile, aiScene* pScene, IO // Apply unit-size scale calculation - pScene->mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0, - 0, parser.mUnitSize, 0, 0, - 0, 0, parser.mUnitSize, 0, - 0, 0, 0, 1); - if( !ignoreUpDirection ) { + pScene->mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0, + 0, parser.mUnitSize, 0, 0, + 0, 0, parser.mUnitSize, 0, + 0, 0, 0, 1); + if (!ignoreUpDirection) { // Convert to Y_UP, if different orientation - if( parser.mUpDirection == ColladaParser::UP_X) { + if (parser.mUpDirection == ColladaParser::UP_X) { pScene->mRootNode->mTransformation *= aiMatrix4x4( - 0, -1, 0, 0, - 1, 0, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - } else if( parser.mUpDirection == ColladaParser::UP_Z) { + 0, -1, 0, 0, + 1, 0, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1); + } else if (parser.mUpDirection == ColladaParser::UP_Z) { pScene->mRootNode->mTransformation *= aiMatrix4x4( - 1, 0, 0, 0, - 0, 0, 1, 0, - 0, -1, 0, 0, - 0, 0, 0, 1); + 1, 0, 0, 0, + 0, 0, 1, 0, + 0, -1, 0, 0, + 0, 0, 0, 1); } } @@ -230,27 +242,15 @@ void ColladaLoader::InternReadFile(const std::string& pFile, aiScene* pScene, IO } } - // store all meshes StoreSceneMeshes(pScene); - - // store all materials StoreSceneMaterials(pScene); - - // store all textures StoreSceneTextures(pScene); - - // store all lights StoreSceneLights(pScene); - - // store all cameras StoreSceneCameras(pScene); - - // store all animations StoreAnimations(pScene, parser); // If no meshes have been loaded, it's probably just an animated skeleton. - if ( 0u == pScene->mNumMeshes) { - + if (0u == pScene->mNumMeshes) { if (!noSkeletonMesh) { SkeletonMeshBuilder hero(pScene); } @@ -260,23 +260,32 @@ void ColladaLoader::InternReadFile(const std::string& pFile, aiScene* pScene, IO // ------------------------------------------------------------------------------------------------ // Recursively constructs a scene node for the given parser node and returns it. -aiNode* ColladaLoader::BuildHierarchy(const ColladaParser& pParser, const Collada::Node* pNode) { +aiNode *ColladaLoader::BuildHierarchy(const ColladaParser &pParser, const Collada::Node *pNode) { // create a node for it - aiNode* node = new aiNode(); + aiNode *node = new aiNode(); // find a name for the new node. It's more complicated than you might think node->mName.Set(FindNameForNode(pNode)); + // if we're not using the unique IDs, hold onto them for reference and export + if (useColladaName) { + if (!pNode->mID.empty()) { + AddNodeMetaData(node, AI_METADATA_COLLADA_ID, aiString(pNode->mID)); + } + if (!pNode->mSID.empty()) { + AddNodeMetaData(node, AI_METADATA_COLLADA_SID, aiString(pNode->mSID)); + } + } // calculate the transformation matrix for it node->mTransformation = pParser.CalculateResultTransform(pNode->mTransforms); // now resolve node instances - std::vector instances; + std::vector instances; ResolveNodeInstances(pParser, pNode, instances); // add children. first the *real* ones node->mNumChildren = static_cast(pNode->mChildren.size() + instances.size()); - node->mChildren = new aiNode*[node->mNumChildren]; + node->mChildren = new aiNode *[node->mNumChildren]; for (size_t a = 0; a < pNode->mChildren.size(); ++a) { node->mChildren[a] = BuildHierarchy(pParser, pNode->mChildren[a]); @@ -289,13 +298,8 @@ aiNode* ColladaLoader::BuildHierarchy(const ColladaParser& pParser, const Collad node->mChildren[pNode->mChildren.size() + a]->mParent = node; } - // construct meshes BuildMeshesForNode(pParser, pNode, node); - - // construct cameras BuildCamerasForNode(pParser, pNode, node); - - // construct lights BuildLightsForNode(pParser, pNode, node); return node; @@ -303,8 +307,8 @@ aiNode* ColladaLoader::BuildHierarchy(const ColladaParser& pParser, const Collad // ------------------------------------------------------------------------------------------------ // Resolve node instances -void ColladaLoader::ResolveNodeInstances(const ColladaParser& pParser, const Collada::Node* pNode, - std::vector& resolved) { +void ColladaLoader::ResolveNodeInstances(const ColladaParser &pParser, const Collada::Node *pNode, + std::vector &resolved) { // reserve enough storage resolved.reserve(pNode->mNodeInstances.size()); @@ -312,7 +316,7 @@ void ColladaLoader::ResolveNodeInstances(const ColladaParser& pParser, const Col for (const auto &nodeInst : pNode->mNodeInstances) { // find the corresponding node in the library const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find(nodeInst.mNode); - const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second; + const Collada::Node *nd = itt == pParser.mNodeLibrary.end() ? nullptr : (*itt).second; // FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632 // need to check for both name and ID to catch all. To avoid breaking valid files, @@ -331,9 +335,7 @@ void ColladaLoader::ResolveNodeInstances(const ColladaParser& pParser, const Col // ------------------------------------------------------------------------------------------------ // Resolve UV channels -void ColladaLoader::ApplyVertexToEffectSemanticMapping(Collada::Sampler& sampler, - - const Collada::SemanticMappingTable& table) { +void ColladaLoader::ApplyVertexToEffectSemanticMapping(Collada::Sampler &sampler, const Collada::SemanticMappingTable &table) { std::map::const_iterator it = table.mMap.find(sampler.mUVChannel); if (it != table.mMap.end()) { if (it->second.mType != Collada::IT_Texcoord) { @@ -346,18 +348,18 @@ void ColladaLoader::ApplyVertexToEffectSemanticMapping(Collada::Sampler& sampler // ------------------------------------------------------------------------------------------------ // Builds lights for the given node and references them -void ColladaLoader::BuildLightsForNode(const ColladaParser& pParser, const Collada::Node* pNode, aiNode* pTarget) { - for (const Collada::LightInstance& lid : pNode->mLights) { +void ColladaLoader::BuildLightsForNode(const ColladaParser &pParser, const Collada::Node *pNode, aiNode *pTarget) { + for (const Collada::LightInstance &lid : pNode->mLights) { // find the referred light ColladaParser::LightLibrary::const_iterator srcLightIt = pParser.mLightLibrary.find(lid.mLight); if (srcLightIt == pParser.mLightLibrary.end()) { ASSIMP_LOG_WARN_F("Collada: Unable to find light for ID \"", lid.mLight, "\". Skipping."); continue; } - const Collada::Light* srcLight = &srcLightIt->second; + const Collada::Light *srcLight = &srcLightIt->second; // now fill our ai data structure - aiLight* out = new aiLight(); + aiLight *out = new aiLight(); out->mName = pTarget->mName; out->mType = (aiLightSourceType)srcLight->mType; @@ -368,14 +370,13 @@ void ColladaLoader::BuildLightsForNode(const ColladaParser& pParser, const Colla out->mAttenuationLinear = srcLight->mAttLinear; out->mAttenuationQuadratic = srcLight->mAttQuadratic; - out->mColorDiffuse = out->mColorSpecular = out->mColorAmbient = srcLight->mColor*srcLight->mIntensity; + out->mColorDiffuse = out->mColorSpecular = out->mColorAmbient = srcLight->mColor * srcLight->mIntensity; if (out->mType == aiLightSource_AMBIENT) { out->mColorDiffuse = out->mColorSpecular = aiColor3D(0, 0, 0); - out->mColorAmbient = srcLight->mColor*srcLight->mIntensity; - } - else { + out->mColorAmbient = srcLight->mColor * srcLight->mIntensity; + } else { // collada doesn't differentiate between these color types - out->mColorDiffuse = out->mColorSpecular = srcLight->mColor*srcLight->mIntensity; + out->mColorDiffuse = out->mColorSpecular = srcLight->mColor * srcLight->mIntensity; out->mColorAmbient = aiColor3D(0, 0, 0); } @@ -390,15 +391,13 @@ void ColladaLoader::BuildLightsForNode(const ColladaParser& pParser, const Colla // Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess .... // epsilon chosen to be 0.1 out->mAngleOuterCone = std::acos(std::pow(0.1f, 1.f / srcLight->mFalloffExponent)) + - out->mAngleInnerCone; - } - else { + out->mAngleInnerCone; + } else { out->mAngleOuterCone = out->mAngleInnerCone + AI_DEG_TO_RAD(srcLight->mPenumbraAngle); if (out->mAngleOuterCone < out->mAngleInnerCone) std::swap(out->mAngleInnerCone, out->mAngleOuterCone); } - } - else { + } else { out->mAngleOuterCone = AI_DEG_TO_RAD(srcLight->mOuterAngle); } } @@ -410,15 +409,15 @@ void ColladaLoader::BuildLightsForNode(const ColladaParser& pParser, const Colla // ------------------------------------------------------------------------------------------------ // Builds cameras for the given node and references them -void ColladaLoader::BuildCamerasForNode(const ColladaParser& pParser, const Collada::Node* pNode, aiNode* pTarget) { - for (const Collada::CameraInstance& cid : pNode->mCameras) { +void ColladaLoader::BuildCamerasForNode(const ColladaParser &pParser, const Collada::Node *pNode, aiNode *pTarget) { + for (const Collada::CameraInstance &cid : pNode->mCameras) { // find the referred light ColladaParser::CameraLibrary::const_iterator srcCameraIt = pParser.mCameraLibrary.find(cid.mCamera); if (srcCameraIt == pParser.mCameraLibrary.end()) { ASSIMP_LOG_WARN_F("Collada: Unable to find camera for ID \"", cid.mCamera, "\". Skipping."); continue; } - const Collada::Camera* srcCamera = &srcCameraIt->second; + const Collada::Camera *srcCamera = &srcCameraIt->second; // orthographic cameras not yet supported in Assimp if (srcCamera->mOrtho) { @@ -426,7 +425,7 @@ void ColladaLoader::BuildCamerasForNode(const ColladaParser& pParser, const Coll } // now fill our ai data structure - aiCamera* out = new aiCamera(); + aiCamera *out = new aiCamera(); out->mName = pTarget->mName; // collada cameras point in -Z by default, rest is specified in node transform @@ -447,12 +446,12 @@ void ColladaLoader::BuildCamerasForNode(const ColladaParser& pParser, const Coll if (srcCamera->mVerFov != 10e10f && srcCamera->mAspect == 10e10f) { out->mAspect = std::tan(AI_DEG_TO_RAD(srcCamera->mHorFov)) / - std::tan(AI_DEG_TO_RAD(srcCamera->mVerFov)); + std::tan(AI_DEG_TO_RAD(srcCamera->mVerFov)); } - } else if (srcCamera->mAspect != 10e10f && srcCamera->mVerFov != 10e10f) { + } else if (srcCamera->mAspect != 10e10f && srcCamera->mVerFov != 10e10f) { out->mHorizontalFOV = 2.0f * AI_RAD_TO_DEG(std::atan(srcCamera->mAspect * - std::tan(AI_DEG_TO_RAD(srcCamera->mVerFov) * 0.5f))); + std::tan(AI_DEG_TO_RAD(srcCamera->mVerFov) * 0.5f))); } // Collada uses degrees, we use radians @@ -465,15 +464,15 @@ void ColladaLoader::BuildCamerasForNode(const ColladaParser& pParser, const Coll // ------------------------------------------------------------------------------------------------ // Builds meshes for the given node and references them -void ColladaLoader::BuildMeshesForNode(const ColladaParser& pParser, const Collada::Node* pNode, aiNode* pTarget) { +void ColladaLoader::BuildMeshesForNode(const ColladaParser &pParser, const Collada::Node *pNode, aiNode *pTarget) { // accumulated mesh references by this node std::vector newMeshRefs; newMeshRefs.reserve(pNode->mMeshes.size()); // add a mesh for each subgroup in each collada mesh - for (const Collada::MeshInstance& mid : pNode->mMeshes) { - const Collada::Mesh* srcMesh = nullptr; - const Collada::Controller* srcController = nullptr; + for (const Collada::MeshInstance &mid : pNode->mMeshes) { + const Collada::Mesh *srcMesh = nullptr; + const Collada::Controller *srcController = nullptr; // find the referred mesh ColladaParser::MeshLibrary::const_iterator srcMeshIt = pParser.mMeshLibrary.find(mid.mMeshOrController); @@ -488,13 +487,11 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser& pParser, const Colla } } - - if( nullptr == srcMesh) { - ASSIMP_LOG_WARN_F( "Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping." ); + if (nullptr == srcMesh) { + ASSIMP_LOG_WARN_F("Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping."); continue; } - } - else { + } else { // ID found in the mesh library -> direct reference to an unskinned mesh srcMesh = srcMeshIt->second; } @@ -502,23 +499,22 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser& pParser, const Colla // build a mesh for each of its subgroups size_t vertexStart = 0, faceStart = 0; for (size_t sm = 0; sm < srcMesh->mSubMeshes.size(); ++sm) { - const Collada::SubMesh& submesh = srcMesh->mSubMeshes[sm]; + const Collada::SubMesh &submesh = srcMesh->mSubMeshes[sm]; if (submesh.mNumFaces == 0) { continue; } // find material assigned to this submesh std::string meshMaterial; - std::map::const_iterator meshMatIt = mid.mMaterials.find(submesh.mMaterial); + std::map::const_iterator meshMatIt = mid.mMaterials.find(submesh.mMaterial); - const Collada::SemanticMappingTable* table = nullptr; + const Collada::SemanticMappingTable *table = nullptr; if (meshMatIt != mid.mMaterials.end()) { table = &meshMatIt->second; meshMaterial = table->mMatName; - } - else { + } else { ASSIMP_LOG_WARN_F("Collada: No material specified for subgroup <", submesh.mMaterial, "> in geometry <", - mid.mMeshOrController, ">."); + mid.mMeshOrController, ">."); if (!mid.mMaterials.empty()) { meshMaterial = mid.mMaterials.begin()->second.mMatName; } @@ -533,7 +529,7 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser& pParser, const Colla } if (table && !table->mMap.empty()) { - std::pair& mat = newMats[matIdx]; + std::pair &mat = newMats[matIdx]; // Iterate through all texture channels assigned to the effect and // check whether we have mapping information for it. @@ -552,16 +548,16 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser& pParser, const Colla std::map::const_iterator dstMeshIt = mMeshIndexByID.find(index); if (dstMeshIt != mMeshIndexByID.end()) { newMeshRefs.push_back(dstMeshIt->second); - } - else { + } else { // else we have to add the mesh to the collection and store its newly assigned index at the node - aiMesh* dstMesh = CreateMesh(pParser, srcMesh, submesh, srcController, vertexStart, faceStart); + aiMesh *dstMesh = CreateMesh(pParser, srcMesh, submesh, srcController, vertexStart, faceStart); // store the mesh, and store its new index in the node newMeshRefs.push_back(mMeshes.size()); mMeshIndexByID[index] = mMeshes.size(); mMeshes.push_back(dstMesh); - vertexStart += dstMesh->mNumVertices; faceStart += submesh.mNumFaces; + vertexStart += dstMesh->mNumVertices; + faceStart += submesh.mNumFaces; // assign the material index dstMesh->mMaterialIndex = matIdx; @@ -576,7 +572,7 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser& pParser, const Colla pTarget->mNumMeshes = static_cast(newMeshRefs.size()); if (newMeshRefs.size()) { struct UIntTypeConverter { - unsigned int operator()(const size_t& v) const { + unsigned int operator()(const size_t &v) const { return static_cast(v); } }; @@ -588,7 +584,11 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser& pParser, const Colla // ------------------------------------------------------------------------------------------------ // Find mesh from either meshes or morph target meshes -aiMesh *ColladaLoader::findMesh(const std::string& meshid) { +aiMesh *ColladaLoader::findMesh(const std::string &meshid) { + if ( meshid.empty()) { + return nullptr; + } + for (unsigned int i = 0; i < mMeshes.size(); ++i) { if (std::string(mMeshes[i]->mName.data) == meshid) { return mMeshes[i]; @@ -606,43 +606,43 @@ aiMesh *ColladaLoader::findMesh(const std::string& meshid) { // ------------------------------------------------------------------------------------------------ // Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh -aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::Mesh* pSrcMesh, const Collada::SubMesh& pSubMesh, - const Collada::Controller* pSrcController, size_t pStartVertex, size_t pStartFace) { +aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Collada::Mesh *pSrcMesh, const Collada::SubMesh &pSubMesh, + const Collada::Controller *pSrcController, size_t pStartVertex, size_t pStartFace) { std::unique_ptr dstMesh(new aiMesh); - dstMesh->mName = pSrcMesh->mName; + if (useColladaName) { + dstMesh->mName = pSrcMesh->mName; + } else { + dstMesh->mName = pSrcMesh->mId; + } // count the vertices addressed by its faces const size_t numVertices = std::accumulate(pSrcMesh->mFaceSize.begin() + pStartFace, - pSrcMesh->mFaceSize.begin() + pStartFace + pSubMesh.mNumFaces, size_t(0)); + pSrcMesh->mFaceSize.begin() + pStartFace + pSubMesh.mNumFaces, size_t(0)); // copy positions dstMesh->mNumVertices = static_cast(numVertices); dstMesh->mVertices = new aiVector3D[numVertices]; - std::copy(pSrcMesh->mPositions.begin() + pStartVertex, pSrcMesh->mPositions.begin() + - pStartVertex + numVertices, dstMesh->mVertices); + std::copy(pSrcMesh->mPositions.begin() + pStartVertex, pSrcMesh->mPositions.begin() + pStartVertex + numVertices, dstMesh->mVertices); // normals, if given. HACK: (thom) Due to the glorious Collada spec we never // know if we have the same number of normals as there are positions. So we // also ignore any vertex attribute if it has a different count if (pSrcMesh->mNormals.size() >= pStartVertex + numVertices) { dstMesh->mNormals = new aiVector3D[numVertices]; - std::copy(pSrcMesh->mNormals.begin() + pStartVertex, pSrcMesh->mNormals.begin() + - pStartVertex + numVertices, dstMesh->mNormals); + std::copy(pSrcMesh->mNormals.begin() + pStartVertex, pSrcMesh->mNormals.begin() + pStartVertex + numVertices, dstMesh->mNormals); } // tangents, if given. if (pSrcMesh->mTangents.size() >= pStartVertex + numVertices) { dstMesh->mTangents = new aiVector3D[numVertices]; - std::copy(pSrcMesh->mTangents.begin() + pStartVertex, pSrcMesh->mTangents.begin() + - pStartVertex + numVertices, dstMesh->mTangents); + std::copy(pSrcMesh->mTangents.begin() + pStartVertex, pSrcMesh->mTangents.begin() + pStartVertex + numVertices, dstMesh->mTangents); } // bitangents, if given. if (pSrcMesh->mBitangents.size() >= pStartVertex + numVertices) { dstMesh->mBitangents = new aiVector3D[numVertices]; - std::copy(pSrcMesh->mBitangents.begin() + pStartVertex, pSrcMesh->mBitangents.begin() + - pStartVertex + numVertices, dstMesh->mBitangents); + std::copy(pSrcMesh->mBitangents.begin() + pStartVertex, pSrcMesh->mBitangents.begin() + pStartVertex + numVertices, dstMesh->mBitangents); } // same for texturecoords, as many as we have @@ -674,7 +674,7 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M dstMesh->mFaces = new aiFace[dstMesh->mNumFaces]; for (size_t a = 0; a < dstMesh->mNumFaces; ++a) { size_t s = pSrcMesh->mFaceSize[pStartFace + a]; - aiFace& face = dstMesh->mFaces[a]; + aiFace &face = dstMesh->mFaces[a]; face.mNumIndices = static_cast(s); face.mIndices = new unsigned int[s]; for (size_t b = 0; b < s; ++b) { @@ -683,20 +683,20 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M } // create morph target meshes if any - std::vector targetMeshes; + std::vector targetMeshes; std::vector targetWeights; Collada::MorphMethod method = Collada::Normalized; for (std::map::const_iterator it = pParser.mControllerLibrary.begin(); - it != pParser.mControllerLibrary.end(); ++it) { + it != pParser.mControllerLibrary.end(); ++it) { const Collada::Controller &c = it->second; - const Collada::Mesh* baseMesh = pParser.ResolveLibraryReference(pParser.mMeshLibrary, c.mMeshId); + const Collada::Mesh *baseMesh = pParser.ResolveLibraryReference(pParser.mMeshLibrary, c.mMeshId); if (c.mType == Collada::Morph && baseMesh->mName == pSrcMesh->mName) { - const Collada::Accessor& targetAccessor = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, c.mMorphTarget); - const Collada::Accessor& weightAccessor = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, c.mMorphWeight); - const Collada::Data& targetData = pParser.ResolveLibraryReference(pParser.mDataLibrary, targetAccessor.mSource); - const Collada::Data& weightData = pParser.ResolveLibraryReference(pParser.mDataLibrary, weightAccessor.mSource); + const Collada::Accessor &targetAccessor = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, c.mMorphTarget); + const Collada::Accessor &weightAccessor = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, c.mMorphWeight); + const Collada::Data &targetData = pParser.ResolveLibraryReference(pParser.mDataLibrary, targetAccessor.mSource); + const Collada::Data &weightData = pParser.ResolveLibraryReference(pParser.mDataLibrary, weightAccessor.mSource); // take method method = c.mMethod; @@ -709,14 +709,14 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M } for (unsigned int i = 0; i < targetData.mStrings.size(); ++i) { - const Collada::Mesh* targetMesh = pParser.ResolveLibraryReference(pParser.mMeshLibrary, targetData.mStrings.at(i)); + const Collada::Mesh *targetMesh = pParser.ResolveLibraryReference(pParser.mMeshLibrary, targetData.mStrings.at(i)); - aiMesh *aimesh = findMesh(targetMesh->mName); + aiMesh *aimesh = findMesh(useColladaName ? targetMesh->mName : targetMesh->mId); if (!aimesh) { if (targetMesh->mSubMeshes.size() > 1) { - throw DeadlyImportError("Morhing target mesh must be a single"); + throw DeadlyImportError("Morphing target mesh must be a single"); } - aimesh = CreateMesh(pParser, targetMesh, targetMesh->mSubMeshes.at(0), NULL, 0, 0); + aimesh = CreateMesh(pParser, targetMesh, targetMesh->mSubMeshes.at(0), nullptr, 0, 0); mTargetMeshes.push_back(aimesh); } targetMeshes.push_back(aimesh); @@ -727,19 +727,17 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M } } if (targetMeshes.size() > 0 && targetWeights.size() == targetMeshes.size()) { - std::vector animMeshes; + std::vector animMeshes; for (unsigned int i = 0; i < targetMeshes.size(); ++i) { - aiMesh* targetMesh = targetMeshes.at(i); + aiMesh *targetMesh = targetMeshes.at(i); aiAnimMesh *animMesh = aiCreateAnimMesh(targetMesh); float weight = targetWeights[i]; animMesh->mWeight = weight == 0 ? 1.0f : weight; animMesh->mName = targetMesh->mName; animMeshes.push_back(animMesh); } - dstMesh->mMethod = (method == Collada::Relative) - ? aiMorphingMethod_MORPH_RELATIVE - : aiMorphingMethod_MORPH_NORMALIZED; - dstMesh->mAnimMeshes = new aiAnimMesh*[animMeshes.size()]; + dstMesh->mMethod = (method == Collada::Relative) ? aiMorphingMethod_MORPH_RELATIVE : aiMorphingMethod_MORPH_NORMALIZED; + dstMesh->mAnimMeshes = new aiAnimMesh *[animMeshes.size()]; dstMesh->mNumAnimMeshes = static_cast(animMeshes.size()); for (unsigned int i = 0; i < animMeshes.size(); ++i) { dstMesh->mAnimMeshes[i] = animMeshes.at(i); @@ -749,18 +747,18 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M // create bones if given if (pSrcController && pSrcController->mType == Collada::Skin) { // resolve references - joint names - const Collada::Accessor& jointNamesAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mJointNameSource); - const Collada::Data& jointNames = pParser.ResolveLibraryReference(pParser.mDataLibrary, jointNamesAcc.mSource); + const Collada::Accessor &jointNamesAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mJointNameSource); + const Collada::Data &jointNames = pParser.ResolveLibraryReference(pParser.mDataLibrary, jointNamesAcc.mSource); // joint offset matrices - const Collada::Accessor& jointMatrixAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mJointOffsetMatrixSource); - const Collada::Data& jointMatrices = pParser.ResolveLibraryReference(pParser.mDataLibrary, jointMatrixAcc.mSource); + const Collada::Accessor &jointMatrixAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mJointOffsetMatrixSource); + const Collada::Data &jointMatrices = pParser.ResolveLibraryReference(pParser.mDataLibrary, jointMatrixAcc.mSource); // joint vertex_weight name list - should refer to the same list as the joint names above. If not, report and reconsider - const Collada::Accessor& weightNamesAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mWeightInputJoints.mAccessor); + const Collada::Accessor &weightNamesAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mWeightInputJoints.mAccessor); if (&weightNamesAcc != &jointNamesAcc) throw DeadlyImportError("Temporary implementational laziness. If you read this, please report to the author."); // vertex weights - const Collada::Accessor& weightsAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mWeightInputWeights.mAccessor); - const Collada::Data& weights = pParser.ResolveLibraryReference(pParser.mDataLibrary, weightsAcc.mSource); + const Collada::Accessor &weightsAcc = pParser.ResolveLibraryReference(pParser.mAccessorLibrary, pSrcController->mWeightInputWeights.mAccessor); + const Collada::Data &weights = pParser.ResolveLibraryReference(pParser.mDataLibrary, weightsAcc.mSource); if (!jointNames.mIsStringArray || jointMatrices.mIsStringArray || weights.mIsStringArray) throw DeadlyImportError("Data type mismatch while resolving mesh joints"); @@ -770,10 +768,10 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M // create containers to collect the weights for each bone size_t numBones = jointNames.mStrings.size(); - std::vector > dstBones(numBones); + std::vector> dstBones(numBones); // build a temporary array of pointers to the start of each vertex's weights - typedef std::vector< std::pair > IndexPairVector; + typedef std::vector> IndexPairVector; std::vector weightStartPerVertex; weightStartPerVertex.resize(pSrcController->mWeightCounts.size(), pSrcController->mWeights.end()); @@ -792,18 +790,16 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M IndexPairVector::const_iterator iit = weightStartPerVertex[orgIndex]; size_t pairCount = pSrcController->mWeightCounts[orgIndex]; - - for( size_t b = 0; b < pairCount; ++b, ++iit) { + for (size_t b = 0; b < pairCount; ++b, ++iit) { const size_t jointIndex = iit->first; - const size_t vertexIndex = iit->second; + const size_t vertexIndex = iit->second; ai_real weight = 1.0f; if (!weights.mValues.empty()) { weight = ReadFloat(weightsAcc, weights, vertexIndex, 0); } // one day I gonna kill that XSI Collada exporter - if (weight > 0.0f) - { + if (weight > 0.0f) { aiVertexWeight w; w.mVertexId = static_cast(a - pStartVertex); w.mWeight = weight; @@ -814,24 +810,24 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M // count the number of bones which influence vertices of the current submesh size_t numRemainingBones = 0; - for( std::vector >::const_iterator it = dstBones.begin(); it != dstBones.end(); ++it) { - if( it->size() > 0) { + for (std::vector>::const_iterator it = dstBones.begin(); it != dstBones.end(); ++it) { + if (it->size() > 0) { ++numRemainingBones; } } // create bone array and copy bone weights one by one dstMesh->mNumBones = static_cast(numRemainingBones); - dstMesh->mBones = new aiBone*[numRemainingBones]; + dstMesh->mBones = new aiBone *[numRemainingBones]; size_t boneCount = 0; - for( size_t a = 0; a < numBones; ++a) { + for (size_t a = 0; a < numBones; ++a) { // omit bones without weights - if( dstBones[a].empty() ) { + if (dstBones[a].empty()) { continue; } // create bone with its weights - aiBone* bone = new aiBone; + aiBone *bone = new aiBone; bone->mName = ReadString(jointNamesAcc, jointNames, a); bone->mOffsetMatrix.a1 = ReadFloat(jointMatrixAcc, jointMatrices, a, 0); bone->mOffsetMatrix.a2 = ReadFloat(jointMatrixAcc, jointMatrices, a, 1); @@ -873,16 +869,16 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M // Therefore I added a little name replacement here: I search for the bone's node by either name, ID or SID, // and replace the bone's name by the node's name so that the user can use the standard // find-by-name method to associate nodes with bones. - const Collada::Node* bnode = FindNode( pParser.mRootNode, bone->mName.data); - if( !bnode) { - bnode = FindNodeBySID( pParser.mRootNode, bone->mName.data); + const Collada::Node *bnode = FindNode(pParser.mRootNode, bone->mName.data); + if (!bnode) { + bnode = FindNodeBySID(pParser.mRootNode, bone->mName.data); } // assign the name that we would have assigned for the source node - if( bnode) { - bone->mName.Set( FindNameForNode( bnode)); + if (bnode) { + bone->mName.Set(FindNameForNode(bnode)); } else { - ASSIMP_LOG_WARN_F( "ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\"." ); + ASSIMP_LOG_WARN_F("ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\"."); } // and insert bone @@ -895,61 +891,61 @@ aiMesh* ColladaLoader::CreateMesh(const ColladaParser& pParser, const Collada::M // ------------------------------------------------------------------------------------------------ // Stores all meshes in the given scene -void ColladaLoader::StoreSceneMeshes( aiScene* pScene) { +void ColladaLoader::StoreSceneMeshes(aiScene *pScene) { pScene->mNumMeshes = static_cast(mMeshes.size()); - if( mMeshes.empty() ) { + if (mMeshes.empty()) { return; } - pScene->mMeshes = new aiMesh*[mMeshes.size()]; - std::copy( mMeshes.begin(), mMeshes.end(), pScene->mMeshes); + pScene->mMeshes = new aiMesh *[mMeshes.size()]; + std::copy(mMeshes.begin(), mMeshes.end(), pScene->mMeshes); mMeshes.clear(); } // ------------------------------------------------------------------------------------------------ // Stores all cameras in the given scene -void ColladaLoader::StoreSceneCameras( aiScene* pScene) { +void ColladaLoader::StoreSceneCameras(aiScene *pScene) { pScene->mNumCameras = static_cast(mCameras.size()); - if( mCameras.empty() ) { + if (mCameras.empty()) { return; } - pScene->mCameras = new aiCamera*[mCameras.size()]; - std::copy( mCameras.begin(), mCameras.end(), pScene->mCameras); + pScene->mCameras = new aiCamera *[mCameras.size()]; + std::copy(mCameras.begin(), mCameras.end(), pScene->mCameras); mCameras.clear(); } // ------------------------------------------------------------------------------------------------ // Stores all lights in the given scene -void ColladaLoader::StoreSceneLights( aiScene* pScene) { +void ColladaLoader::StoreSceneLights(aiScene *pScene) { pScene->mNumLights = static_cast(mLights.size()); - if( mLights.empty() ) { + if (mLights.empty()) { return; } - pScene->mLights = new aiLight*[mLights.size()]; - std::copy( mLights.begin(), mLights.end(), pScene->mLights); + pScene->mLights = new aiLight *[mLights.size()]; + std::copy(mLights.begin(), mLights.end(), pScene->mLights); mLights.clear(); } // ------------------------------------------------------------------------------------------------ // Stores all textures in the given scene -void ColladaLoader::StoreSceneTextures( aiScene* pScene) { +void ColladaLoader::StoreSceneTextures(aiScene *pScene) { pScene->mNumTextures = static_cast(mTextures.size()); - if( mTextures.empty() ) { + if (mTextures.empty()) { return; } - pScene->mTextures = new aiTexture*[mTextures.size()]; - std::copy( mTextures.begin(), mTextures.end(), pScene->mTextures); + pScene->mTextures = new aiTexture *[mTextures.size()]; + std::copy(mTextures.begin(), mTextures.end(), pScene->mTextures); mTextures.clear(); } // ------------------------------------------------------------------------------------------------ // Stores all materials in the given scene -void ColladaLoader::StoreSceneMaterials( aiScene* pScene) { +void ColladaLoader::StoreSceneMaterials(aiScene *pScene) { pScene->mNumMaterials = static_cast(newMats.size()); - if (newMats.empty() ) { + if (newMats.empty()) { return; } - pScene->mMaterials = new aiMaterial*[newMats.size()]; - for (unsigned int i = 0; i < newMats.size();++i) { + pScene->mMaterials = new aiMaterial *[newMats.size()]; + for (unsigned int i = 0; i < newMats.size(); ++i) { pScene->mMaterials[i] = newMats[i].second; } newMats.clear(); @@ -957,73 +953,69 @@ void ColladaLoader::StoreSceneMaterials( aiScene* pScene) { // ------------------------------------------------------------------------------------------------ // Stores all animations -void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser) { +void ColladaLoader::StoreAnimations(aiScene *pScene, const ColladaParser &pParser) { // recursively collect all animations from the collada scene StoreAnimations(pScene, pParser, &pParser.mAnims, ""); // catch special case: many animations with the same length, each affecting only a single node. // we need to unite all those single-node-anims to a proper combined animation - for(size_t a = 0; a < mAnims.size(); ++a) { - aiAnimation* templateAnim = mAnims[a]; + for (size_t a = 0; a < mAnims.size(); ++a) { + aiAnimation *templateAnim = mAnims[a]; if (templateAnim->mNumChannels == 1) { // search for other single-channel-anims with the same duration std::vector collectedAnimIndices; - for( size_t b = a+1; b < mAnims.size(); ++b) { - aiAnimation* other = mAnims[b]; + for (size_t b = a + 1; b < mAnims.size(); ++b) { + aiAnimation *other = mAnims[b]; if (other->mNumChannels == 1 && other->mDuration == templateAnim->mDuration && - other->mTicksPerSecond == templateAnim->mTicksPerSecond) - collectedAnimIndices.push_back(b); + other->mTicksPerSecond == templateAnim->mTicksPerSecond) + collectedAnimIndices.push_back(b); } - // We only want to combine the animations if they have different channels - std::set animTargets; - animTargets.insert(templateAnim->mChannels[0]->mNodeName.C_Str()); - bool collectedAnimationsHaveDifferentChannels = true; - for (size_t b = 0; b < collectedAnimIndices.size(); ++b) - { - aiAnimation* srcAnimation = mAnims[collectedAnimIndices[b]]; - std::string channelName = std::string(srcAnimation->mChannels[0]->mNodeName.C_Str()); - if (animTargets.find(channelName) == animTargets.end()) { - animTargets.insert(channelName); - } else { - collectedAnimationsHaveDifferentChannels = false; - break; - } - } + // We only want to combine the animations if they have different channels + std::set animTargets; + animTargets.insert(templateAnim->mChannels[0]->mNodeName.C_Str()); + bool collectedAnimationsHaveDifferentChannels = true; + for (size_t b = 0; b < collectedAnimIndices.size(); ++b) { + aiAnimation *srcAnimation = mAnims[collectedAnimIndices[b]]; + std::string channelName = std::string(srcAnimation->mChannels[0]->mNodeName.C_Str()); + if (animTargets.find(channelName) == animTargets.end()) { + animTargets.insert(channelName); + } else { + collectedAnimationsHaveDifferentChannels = false; + break; + } + } - if (!collectedAnimationsHaveDifferentChannels) - continue; + if (!collectedAnimationsHaveDifferentChannels) + continue; // if there are other animations which fit the template anim, combine all channels into a single anim - if (!collectedAnimIndices.empty()) - { - aiAnimation* combinedAnim = new aiAnimation(); + if (!collectedAnimIndices.empty()) { + aiAnimation *combinedAnim = new aiAnimation(); combinedAnim->mName = aiString(std::string("combinedAnim_") + char('0' + a)); combinedAnim->mDuration = templateAnim->mDuration; combinedAnim->mTicksPerSecond = templateAnim->mTicksPerSecond; combinedAnim->mNumChannels = static_cast(collectedAnimIndices.size() + 1); - combinedAnim->mChannels = new aiNodeAnim*[combinedAnim->mNumChannels]; + combinedAnim->mChannels = new aiNodeAnim *[combinedAnim->mNumChannels]; // add the template anim as first channel by moving its aiNodeAnim to the combined animation combinedAnim->mChannels[0] = templateAnim->mChannels[0]; - templateAnim->mChannels[0] = NULL; + templateAnim->mChannels[0] = nullptr; delete templateAnim; // combined animation replaces template animation in the anim array mAnims[a] = combinedAnim; // move the memory of all other anims to the combined anim and erase them from the source anims - for (size_t b = 0; b < collectedAnimIndices.size(); ++b) - { - aiAnimation* srcAnimation = mAnims[collectedAnimIndices[b]]; + for (size_t b = 0; b < collectedAnimIndices.size(); ++b) { + aiAnimation *srcAnimation = mAnims[collectedAnimIndices[b]]; combinedAnim->mChannels[1 + b] = srcAnimation->mChannels[0]; - srcAnimation->mChannels[0] = NULL; + srcAnimation->mChannels[0] = nullptr; delete srcAnimation; } // in a second go, delete all the single-channel-anims that we've stripped from their channels // back to front to preserve indices - you know, removing an element from a vector moves all elements behind the removed one - while (!collectedAnimIndices.empty()) - { + while (!collectedAnimIndices.empty()) { mAnims.erase(mAnims.begin() + collectedAnimIndices.back()); collectedAnimIndices.pop_back(); } @@ -1032,10 +1024,9 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars } // now store all anims in the scene - if (!mAnims.empty()) - { + if (!mAnims.empty()) { pScene->mNumAnimations = static_cast(mAnims.size()); - pScene->mAnimations = new aiAnimation*[mAnims.size()]; + pScene->mAnimations = new aiAnimation *[mAnims.size()]; std::copy(mAnims.begin(), mAnims.end(), pScene->mAnimations); } @@ -1044,12 +1035,11 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars // ------------------------------------------------------------------------------------------------ // Constructs the animations for the given source anim -void ColladaLoader::StoreAnimations(aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string &pPrefix) -{ +void ColladaLoader::StoreAnimations(aiScene *pScene, const ColladaParser &pParser, const Collada::Animation *pSrcAnim, const std::string &pPrefix) { std::string animName = pPrefix.empty() ? pSrcAnim->mName : pPrefix + "_" + pSrcAnim->mName; // create nested animations, if given - for (std::vector::const_iterator it = pSrcAnim->mSubAnims.begin(); it != pSrcAnim->mSubAnims.end(); ++it) + for (std::vector::const_iterator it = pSrcAnim->mSubAnims.begin(); it != pSrcAnim->mSubAnims.end(); ++it) StoreAnimations(pScene, pParser, *it, animName); // create animation channels, if any @@ -1057,47 +1047,38 @@ void ColladaLoader::StoreAnimations(aiScene* pScene, const ColladaParser& pParse CreateAnimation(pScene, pParser, pSrcAnim, animName); } -struct MorphTimeValues -{ +struct MorphTimeValues { float mTime; - struct key - { + struct key { float mWeight; unsigned int mValue; }; std::vector mKeys; }; -void insertMorphTimeValue(std::vector &values, float time, float weight, unsigned int value) -{ +void insertMorphTimeValue(std::vector &values, float time, float weight, unsigned int value) { MorphTimeValues::key k; k.mValue = value; k.mWeight = weight; - if (values.size() == 0 || time < values[0].mTime) - { + if (values.size() == 0 || time < values[0].mTime) { MorphTimeValues val; val.mTime = time; val.mKeys.push_back(k); values.insert(values.begin(), val); return; } - if (time > values.back().mTime) - { + if (time > values.back().mTime) { MorphTimeValues val; val.mTime = time; val.mKeys.push_back(k); values.insert(values.end(), val); return; } - for (unsigned int i = 0; i < values.size(); i++) - { - if (std::abs(time - values[i].mTime) < 1e-6f) - { + for (unsigned int i = 0; i < values.size(); i++) { + if (std::abs(time - values[i].mTime) < 1e-6f) { values[i].mKeys.push_back(k); return; - } - else if (time > values[i].mTime && time < values[i + 1].mTime) - { + } else if (time > values[i].mTime && time < values[i + 1].mTime) { MorphTimeValues val; val.mTime = time; val.mKeys.push_back(k); @@ -1108,10 +1089,8 @@ void insertMorphTimeValue(std::vector &values, float time, floa // should not get here } -float getWeightAtKey(const std::vector &values, int key, unsigned int value) -{ - for (unsigned int i = 0; i < values[key].mKeys.size(); i++) - { +float getWeightAtKey(const std::vector &values, int key, unsigned int value) { + for (unsigned int i = 0; i < values[key].mKeys.size(); i++) { if (values[key].mKeys[i].mValue == value) return values[key].mKeys[i].mWeight; } @@ -1122,48 +1101,45 @@ float getWeightAtKey(const std::vector &values, int key, unsign // ------------------------------------------------------------------------------------------------ // Constructs the animation for the given source anim -void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName) -{ +void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParser, const Collada::Animation *pSrcAnim, const std::string &pName) { // collect a list of animatable nodes - std::vector nodes; + std::vector nodes; CollectNodes(pScene->mRootNode, nodes); - std::vector anims; - std::vector morphAnims; + std::vector anims; + std::vector morphAnims; - for (std::vector::const_iterator nit = nodes.begin(); nit != nodes.end(); ++nit) - { + for (std::vector::const_iterator nit = nodes.begin(); nit != nodes.end(); ++nit) { // find all the collada anim channels which refer to the current node std::vector entries; std::string nodeName = (*nit)->mName.data; // find the collada node corresponding to the aiNode - const Collada::Node* srcNode = FindNode(pParser.mRootNode, nodeName); - // ai_assert( srcNode != NULL); - if (!srcNode) + const Collada::Node *srcNode = FindNode(pParser.mRootNode, nodeName); + if (!srcNode) { continue; + } // now check all channels if they affect the current node std::string targetID, subElement; for (std::vector::const_iterator cit = pSrcAnim->mChannels.begin(); - cit != pSrcAnim->mChannels.end(); ++cit) - { - const Collada::AnimationChannel& srcChannel = *cit; + cit != pSrcAnim->mChannels.end(); ++cit) { + const Collada::AnimationChannel &srcChannel = *cit; Collada::ChannelEntry entry; // we expect the animation target to be of type "nodeName/transformID.subElement". Ignore all others // find the slash that separates the node name - there should be only one std::string::size_type slashPos = srcChannel.mTarget.find('/'); - if (slashPos == std::string::npos) - { + if (slashPos == std::string::npos) { std::string::size_type targetPos = srcChannel.mTarget.find(srcNode->mID); - if (targetPos == std::string::npos) + if (targetPos == std::string::npos) { continue; + } // not node transform, but something else. store as unknown animation channel for now entry.mChannel = &(*cit); entry.mTargetId = srcChannel.mTarget.substr(targetPos + pSrcAnim->mName.length(), - srcChannel.mTarget.length() - targetPos - pSrcAnim->mName.length()); + srcChannel.mTarget.length() - targetPos - pSrcAnim->mName.length()); if (entry.mTargetId.front() == '-') entry.mTargetId = entry.mTargetId.substr(1); entries.push_back(entry); @@ -1179,8 +1155,7 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse // find the dot that separates the transformID - there should be only one or zero std::string::size_type dotPos = srcChannel.mTarget.find('.'); - if (dotPos != std::string::npos) - { + if (dotPos != std::string::npos) { if (srcChannel.mTarget.find('.', dotPos + 1) != std::string::npos) continue; @@ -1198,15 +1173,13 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse entry.mSubElement = 2; else ASSIMP_LOG_WARN_F("Unknown anim subelement <", subElement, ">. Ignoring"); - } - else { + } else { // no subelement following, transformId is remaining string entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1); } std::string::size_type bracketPos = srcChannel.mTarget.find('('); - if (bracketPos != std::string::npos) - { + if (bracketPos != std::string::npos) { entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1, bracketPos - slashPos - 1); subElement.clear(); subElement = srcChannel.mTarget.substr(bracketPos); @@ -1251,14 +1224,11 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse if (srcNode->mTransforms[a].mID == entry.mTransformId) entry.mTransformIndex = a; - if (entry.mTransformIndex == SIZE_MAX) - { - if (entry.mTransformId.find("morph-weights") != std::string::npos) - { + if (entry.mTransformIndex == SIZE_MAX) { + if (entry.mTransformId.find("morph-weights") != std::string::npos) { entry.mTargetId = entry.mTransformId; entry.mTransformId = ""; - } - else + } else continue; } @@ -1272,9 +1242,8 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse // resolve the data pointers for all anim channels. Find the minimum time while we're at it ai_real startTime = ai_real(1e20), endTime = ai_real(-1e20); - for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) - { - Collada::ChannelEntry& e = *it; + for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { + Collada::ChannelEntry &e = *it; e.mTimeAccessor = &pParser.ResolveLibraryReference(pParser.mAccessorLibrary, e.mChannel->mSourceTimes); e.mTimeData = &pParser.ResolveLibraryReference(pParser.mDataLibrary, e.mTimeAccessor->mSource); e.mValueAccessor = &pParser.ResolveLibraryReference(pParser.mAccessorLibrary, e.mChannel->mSourceValues); @@ -1284,8 +1253,7 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse if (e.mTimeAccessor->mCount != e.mValueAccessor->mCount) throw DeadlyImportError(format() << "Time count / value count mismatch in animation channel \"" << e.mChannel->mTarget << "\"."); - if (e.mTimeAccessor->mCount > 0) - { + if (e.mTimeAccessor->mCount > 0) { // find bounding times startTime = std::min(startTime, ReadFloat(*e.mTimeAccessor, *e.mTimeData, 0, 0)); endTime = std::max(endTime, ReadFloat(*e.mTimeAccessor, *e.mTimeData, e.mTimeAccessor->mCount - 1, 0)); @@ -1293,25 +1261,21 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse } std::vector resultTrafos; - if (!entries.empty() && entries.front().mTimeAccessor->mCount > 0) - { + if (!entries.empty() && entries.front().mTimeAccessor->mCount > 0) { // create a local transformation chain of the node's transforms std::vector transforms = srcNode->mTransforms; // now for every unique point in time, find or interpolate the key values for that time // and apply them to the transform chain. Then the node's present transformation can be calculated. ai_real time = startTime; - while (1) - { - for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) - { - Collada::ChannelEntry& e = *it; + while (1) { + for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { + Collada::ChannelEntry &e = *it; // find the keyframe behind the current point in time size_t pos = 0; ai_real postTime = 0.0; - while (1) - { + while (1) { if (pos >= e.mTimeAccessor->mCount) break; postTime = ReadFloat(*e.mTimeAccessor, *e.mTimeData, pos, 0); @@ -1328,13 +1292,11 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse temp[c] = ReadFloat(*e.mValueAccessor, *e.mValueData, pos, c); // if not exactly at the key time, interpolate with previous value set - if (postTime > time && pos > 0) - { + if (postTime > time && pos > 0) { ai_real preTime = ReadFloat(*e.mTimeAccessor, *e.mTimeData, pos - 1, 0); ai_real factor = (time - postTime) / (preTime - postTime); - for (size_t c = 0; c < e.mValueAccessor->mSize; ++c) - { + for (size_t c = 0; c < e.mValueAccessor->mSize; ++c) { ai_real v = ReadFloat(*e.mValueAccessor, *e.mValueData, pos - 1, c); temp[c] += (v - temp[c]) * factor; } @@ -1353,17 +1315,14 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse // find next point in time to evaluate. That's the closest frame larger than the current in any channel ai_real nextTime = ai_real(1e20); - for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) - { - Collada::ChannelEntry& channelElement = *it; + for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { + Collada::ChannelEntry &channelElement = *it; // find the next time value larger than the current size_t pos = 0; - while (pos < channelElement.mTimeAccessor->mCount) - { + while (pos < channelElement.mTimeAccessor->mCount) { const ai_real t = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0); - if (t > time) - { + if (t > time) { nextTime = std::min(nextTime, t); break; } @@ -1400,12 +1359,11 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse } // there should be some keyframes, but we aren't that fixated on valid input data -// ai_assert( resultTrafos.size() > 0); + // ai_assert( resultTrafos.size() > 0); // build an animation channel for the given node out of these trafo keys - if (!resultTrafos.empty()) - { - aiNodeAnim* dstAnim = new aiNodeAnim; + if (!resultTrafos.empty()) { + aiNodeAnim *dstAnim = new aiNodeAnim; dstAnim->mNodeName = nodeName; dstAnim->mNumPositionKeys = static_cast(resultTrafos.size()); dstAnim->mNumRotationKeys = static_cast(resultTrafos.size()); @@ -1414,31 +1372,26 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse dstAnim->mRotationKeys = new aiQuatKey[resultTrafos.size()]; dstAnim->mScalingKeys = new aiVectorKey[resultTrafos.size()]; - for (size_t a = 0; a < resultTrafos.size(); ++a) - { + for (size_t a = 0; a < resultTrafos.size(); ++a) { aiMatrix4x4 mat = resultTrafos[a]; double time = double(mat.d4); // remember? time is stored in mat.d4 mat.d4 = 1.0f; - dstAnim->mPositionKeys[a].mTime = time; - dstAnim->mRotationKeys[a].mTime = time; - dstAnim->mScalingKeys[a].mTime = time; + dstAnim->mPositionKeys[a].mTime = time * kMillisecondsFromSeconds ; + dstAnim->mRotationKeys[a].mTime = time * kMillisecondsFromSeconds ; + dstAnim->mScalingKeys[a].mTime = time * kMillisecondsFromSeconds ; mat.Decompose(dstAnim->mScalingKeys[a].mValue, dstAnim->mRotationKeys[a].mValue, dstAnim->mPositionKeys[a].mValue); } anims.push_back(dstAnim); - } - else - { + } else { ASSIMP_LOG_WARN("Collada loader: found empty animation channel, ignored. Please check your exporter."); } - if (!entries.empty() && entries.front().mTimeAccessor->mCount > 0) - { + if (!entries.empty() && entries.front().mTimeAccessor->mCount > 0) { std::vector morphChannels; - for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) - { - Collada::ChannelEntry& e = *it; + for (std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { + Collada::ChannelEntry &e = *it; // skip non-transform types if (e.mTargetId.empty()) @@ -1447,8 +1400,7 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse if (e.mTargetId.find("morph-weights") != std::string::npos) morphChannels.push_back(e); } - if (morphChannels.size() > 0) - { + if (!morphChannels.empty() ) { // either 1) morph weight animation count should contain morph target count channels // or 2) one channel with morph target count arrays // assume first @@ -1457,11 +1409,9 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse morphAnim->mName.Set(nodeName); std::vector morphTimeValues; - int morphAnimChannelIndex = 0; - for (std::vector::iterator it = morphChannels.begin(); it != morphChannels.end(); ++it) - { - Collada::ChannelEntry& e = *it; + for (std::vector::iterator it = morphChannels.begin(); it != morphChannels.end(); ++it) { + Collada::ChannelEntry &e = *it; std::string::size_type apos = e.mTargetId.find('('); std::string::size_type bpos = e.mTargetId.find(')'); if (apos == std::string::npos || bpos == std::string::npos) @@ -1470,23 +1420,22 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse // weight target can be in format Weight_M_N, Weight_N, WeightN, or some other way // we ignore the name and just assume the channels are in the right order - for (unsigned int i = 0; i < e.mTimeData->mValues.size(); i++) - insertMorphTimeValue(morphTimeValues, e.mTimeData->mValues.at(i), e.mValueData->mValues.at(i), morphAnimChannelIndex); + for (unsigned int i = 0; i < e.mTimeData->mValues.size(); i++) { + insertMorphTimeValue(morphTimeValues, e.mTimeData->mValues[i], e.mValueData->mValues[i], morphAnimChannelIndex); + } ++morphAnimChannelIndex; } morphAnim->mNumKeys = static_cast(morphTimeValues.size()); morphAnim->mKeys = new aiMeshMorphKey[morphAnim->mNumKeys]; - for (unsigned int key = 0; key < morphAnim->mNumKeys; key++) - { + for (unsigned int key = 0; key < morphAnim->mNumKeys; key++) { morphAnim->mKeys[key].mNumValuesAndWeights = static_cast(morphChannels.size()); morphAnim->mKeys[key].mValues = new unsigned int[morphChannels.size()]; morphAnim->mKeys[key].mWeights = new double[morphChannels.size()]; - morphAnim->mKeys[key].mTime = morphTimeValues[key].mTime; - for (unsigned int valueIndex = 0; valueIndex < morphChannels.size(); valueIndex++) - { + morphAnim->mKeys[key].mTime = morphTimeValues[key].mTime * kMillisecondsFromSeconds ; + for (unsigned int valueIndex = 0; valueIndex < morphChannels.size(); ++valueIndex ) { morphAnim->mKeys[key].mValues[valueIndex] = valueIndex; morphAnim->mKeys[key].mWeights[valueIndex] = getWeightAtKey(morphTimeValues, key, valueIndex); } @@ -1497,31 +1446,26 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse } } - if (!anims.empty() || !morphAnims.empty()) - { - aiAnimation* anim = new aiAnimation; + if (!anims.empty() || !morphAnims.empty()) { + aiAnimation *anim = new aiAnimation; anim->mName.Set(pName); anim->mNumChannels = static_cast(anims.size()); - if (anim->mNumChannels > 0) - { - anim->mChannels = new aiNodeAnim*[anims.size()]; + if (anim->mNumChannels > 0) { + anim->mChannels = new aiNodeAnim *[anims.size()]; std::copy(anims.begin(), anims.end(), anim->mChannels); } anim->mNumMorphMeshChannels = static_cast(morphAnims.size()); - if (anim->mNumMorphMeshChannels > 0) - { - anim->mMorphMeshChannels = new aiMeshMorphAnim*[anim->mNumMorphMeshChannels]; + if (anim->mNumMorphMeshChannels > 0) { + anim->mMorphMeshChannels = new aiMeshMorphAnim *[anim->mNumMorphMeshChannels]; std::copy(morphAnims.begin(), morphAnims.end(), anim->mMorphMeshChannels); } anim->mDuration = 0.0f; - for (size_t a = 0; a < anims.size(); ++a) - { + for (size_t a = 0; a < anims.size(); ++a) { anim->mDuration = std::max(anim->mDuration, anims[a]->mPositionKeys[anims[a]->mNumPositionKeys - 1].mTime); anim->mDuration = std::max(anim->mDuration, anims[a]->mRotationKeys[anims[a]->mNumRotationKeys - 1].mTime); anim->mDuration = std::max(anim->mDuration, anims[a]->mScalingKeys[anims[a]->mNumScalingKeys - 1].mTime); } - for (size_t a = 0; a < morphAnims.size(); ++a) - { + for (size_t a = 0; a < morphAnims.size(); ++a) { anim->mDuration = std::max(anim->mDuration, morphAnims[a]->mKeys[morphAnims[a]->mNumKeys - 1].mTime); } anim->mTicksPerSecond = 1; @@ -1531,52 +1475,55 @@ void ColladaLoader::CreateAnimation(aiScene* pScene, const ColladaParser& pParse // ------------------------------------------------------------------------------------------------ // Add a texture to a material structure -void ColladaLoader::AddTexture(aiMaterial& mat, const ColladaParser& pParser, - const Collada::Effect& effect, - const Collada::Sampler& sampler, - aiTextureType type, unsigned int idx) -{ +void ColladaLoader::AddTexture(aiMaterial &mat, const ColladaParser &pParser, + const Collada::Effect &effect, + const Collada::Sampler &sampler, + aiTextureType type, unsigned int idx) { // first of all, basic file name const aiString name = FindFilenameForEffectTexture(pParser, effect, sampler.mName); mat.AddProperty(&name, _AI_MATKEY_TEXTURE_BASE, type, idx); // mapping mode int map = aiTextureMapMode_Clamp; - if (sampler.mWrapU) + if (sampler.mWrapU) { map = aiTextureMapMode_Wrap; - if (sampler.mWrapU && sampler.mMirrorU) + } + if (sampler.mWrapU && sampler.mMirrorU) { map = aiTextureMapMode_Mirror; + } mat.AddProperty(&map, 1, _AI_MATKEY_MAPPINGMODE_U_BASE, type, idx); map = aiTextureMapMode_Clamp; - if (sampler.mWrapV) + if (sampler.mWrapV) { map = aiTextureMapMode_Wrap; - if (sampler.mWrapV && sampler.mMirrorV) + } + if (sampler.mWrapV && sampler.mMirrorV) { map = aiTextureMapMode_Mirror; + } mat.AddProperty(&map, 1, _AI_MATKEY_MAPPINGMODE_V_BASE, type, idx); // UV transformation mat.AddProperty(&sampler.mTransform, 1, - _AI_MATKEY_UVTRANSFORM_BASE, type, idx); + _AI_MATKEY_UVTRANSFORM_BASE, type, idx); // Blend mode - mat.AddProperty((int*)&sampler.mOp, 1, - _AI_MATKEY_TEXBLEND_BASE, type, idx); + mat.AddProperty((int *)&sampler.mOp, 1, + _AI_MATKEY_TEXBLEND_BASE, type, idx); // Blend factor - mat.AddProperty((ai_real*)&sampler.mWeighting, 1, - _AI_MATKEY_TEXBLEND_BASE, type, idx); + mat.AddProperty((ai_real *)&sampler.mWeighting, 1, + _AI_MATKEY_TEXBLEND_BASE, type, idx); // UV source index ... if we didn't resolve the mapping, it is actually just // a guess but it works in most cases. We search for the frst occurrence of a // number in the channel name. We assume it is the zero-based index into the // UV channel array of all corresponding meshes. It could also be one-based // for some exporters, but we won't care of it unless someone complains about. - if (sampler.mUVId != UINT_MAX) + if (sampler.mUVId != UINT_MAX) { map = sampler.mUVId; - else { + } else { map = -1; for (std::string::const_iterator it = sampler.mUVChannel.begin(); it != sampler.mUVChannel.end(); ++it) { if (IsNumeric(*it)) { @@ -1594,37 +1541,34 @@ void ColladaLoader::AddTexture(aiMaterial& mat, const ColladaParser& pParser, // ------------------------------------------------------------------------------------------------ // Fills materials from the collada material definitions -void ColladaLoader::FillMaterials(const ColladaParser& pParser, aiScene* /*pScene*/) -{ - for (auto &elem : newMats) - { - aiMaterial& mat = (aiMaterial&)*elem.second; - Collada::Effect& effect = *elem.first; +void ColladaLoader::FillMaterials(const ColladaParser &pParser, aiScene * /*pScene*/) { + for (auto &elem : newMats) { + aiMaterial &mat = (aiMaterial &)*elem.second; + Collada::Effect &effect = *elem.first; // resolve shading mode int shadeMode; - if (effect.mFaceted) /* fixme */ + if (effect.mFaceted) { shadeMode = aiShadingMode_Flat; - else { - switch (effect.mShadeType) - { - case Collada::Shade_Constant: - shadeMode = aiShadingMode_NoShading; - break; - case Collada::Shade_Lambert: - shadeMode = aiShadingMode_Gouraud; - break; - case Collada::Shade_Blinn: - shadeMode = aiShadingMode_Blinn; - break; - case Collada::Shade_Phong: - shadeMode = aiShadingMode_Phong; - break; + } else { + switch (effect.mShadeType) { + case Collada::Shade_Constant: + shadeMode = aiShadingMode_NoShading; + break; + case Collada::Shade_Lambert: + shadeMode = aiShadingMode_Gouraud; + break; + case Collada::Shade_Blinn: + shadeMode = aiShadingMode_Blinn; + break; + case Collada::Shade_Phong: + shadeMode = aiShadingMode_Phong; + break; - default: - ASSIMP_LOG_WARN("Collada: Unrecognized shading mode, using gouraud shading"); - shadeMode = aiShadingMode_Gouraud; - break; + default: + ASSIMP_LOG_WARN("Collada: Unrecognized shading mode, using gouraud shading"); + shadeMode = aiShadingMode_Gouraud; + break; } } mat.AddProperty(&shadeMode, 1, AI_MATKEY_SHADING_MODEL); @@ -1657,17 +1601,14 @@ void ColladaLoader::FillMaterials(const ColladaParser& pParser, aiScene* /*pScen // handle RGB transparency completely, cf Collada specs 1.5.0 pages 249 and 304 if (effect.mRGBTransparency) { // use luminance as defined by ISO/CIE color standards (see ITU-R Recommendation BT.709-4) - effect.mTransparency *= ( - 0.212671f * effect.mTransparent.r + - 0.715160f * effect.mTransparent.g + - 0.072169f * effect.mTransparent.b - ); + effect.mTransparency *= (0.212671f * effect.mTransparent.r + + 0.715160f * effect.mTransparent.g + + 0.072169f * effect.mTransparent.b); effect.mTransparent.a = 1.f; mat.AddProperty(&effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT); - } - else { + } else { effect.mTransparency *= effect.mTransparent.a; } @@ -1709,62 +1650,42 @@ void ColladaLoader::FillMaterials(const ColladaParser& pParser, aiScene* /*pScen // ------------------------------------------------------------------------------------------------ // Constructs materials from the collada material definitions -void ColladaLoader::BuildMaterials(ColladaParser& pParser, aiScene* /*pScene*/) -{ +void ColladaLoader::BuildMaterials(ColladaParser &pParser, aiScene * /*pScene*/) { newMats.reserve(pParser.mMaterialLibrary.size()); for (ColladaParser::MaterialLibrary::const_iterator matIt = pParser.mMaterialLibrary.begin(); - matIt != pParser.mMaterialLibrary.end(); ++matIt) { - const Collada::Material& material = matIt->second; + matIt != pParser.mMaterialLibrary.end(); ++matIt) { + const Collada::Material &material = matIt->second; // a material is only a reference to an effect ColladaParser::EffectLibrary::iterator effIt = pParser.mEffectLibrary.find(material.mEffect); if (effIt == pParser.mEffectLibrary.end()) continue; - Collada::Effect& effect = effIt->second; + Collada::Effect &effect = effIt->second; // create material - aiMaterial* mat = new aiMaterial; + aiMaterial *mat = new aiMaterial; aiString name(material.mName.empty() ? matIt->first : material.mName); mat->AddProperty(&name, AI_MATKEY_NAME); // store the material mMaterialIndexByName[matIt->first] = newMats.size(); - newMats.push_back(std::pair(&effect, mat)); + newMats.push_back(std::pair(&effect, mat)); } // ScenePreprocessor generates a default material automatically if none is there. // All further code here in this loader works well without a valid material so // we can safely let it to ScenePreprocessor. -#if 0 - if (newMats.size() == 0) - { - aiMaterial* mat = new aiMaterial; - aiString name(AI_DEFAULT_MATERIAL_NAME); - mat->AddProperty(&name, AI_MATKEY_NAME); - - const int shadeMode = aiShadingMode_Phong; - mat->AddProperty(&shadeMode, 1, AI_MATKEY_SHADING_MODEL); - aiColor4D colAmbient(0.2, 0.2, 0.2, 1.0), colDiffuse(0.8, 0.8, 0.8, 1.0), colSpecular(0.5, 0.5, 0.5, 0.5); - mat->AddProperty(&colAmbient, 1, AI_MATKEY_COLOR_AMBIENT); - mat->AddProperty(&colDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE); - mat->AddProperty(&colSpecular, 1, AI_MATKEY_COLOR_SPECULAR); - const ai_real specExp = 5.0; - mat->AddProperty(&specExp, 1, AI_MATKEY_SHININESS); -} -#endif } // ------------------------------------------------------------------------------------------------ // Resolves the texture name for the given effect texture entry -// and loads the texture data -aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParser, - const Collada::Effect& pEffect, const std::string& pName) -{ +// and loads the texture data +aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser &pParser, + const Collada::Effect &pEffect, const std::string &pName) { aiString result; // recurse through the param references until we end up at an image std::string name = pName; - while (1) - { + while (1) { // the given string is a param entry. Find it Collada::Effect::ParamLibrary::const_iterator it = pEffect.mParams.find(name); // if not found, we're at the end of the recursion. The resulting string should be the image ID @@ -1777,8 +1698,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParse // find the image referred by this name in the image library of the scene ColladaParser::ImageLibrary::const_iterator imIt = pParser.mImageLibrary.find(name); - if (imIt == pParser.mImageLibrary.end()) - { + if (imIt == pParser.mImageLibrary.end()) { ASSIMP_LOG_WARN_F("Collada: Unable to resolve effect texture entry \"", pName, "\", ended up at ID \"", name, "\"."); //set default texture file name @@ -1788,18 +1708,16 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParse } // if this is an embedded texture image setup an aiTexture for it - if (!imIt->second.mImageData.empty()) - { - aiTexture* tex = new aiTexture(); + if (!imIt->second.mImageData.empty()) { + aiTexture *tex = new aiTexture(); // Store embedded texture name reference tex->mFilename.Set(imIt->second.mFileName.c_str()); result.Set(imIt->second.mFileName); // TODO: check the possibility of using the flag "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING" -// result.data[0] = '*'; -// result.length = 1 + ASSIMP_itoa10(result.data + 1, static_cast(MAXLEN - 1), static_cast(mTextures.size())); - + // result.data[0] = '*'; + // result.length = 1 + ASSIMP_itoa10(result.data + 1, static_cast(MAXLEN - 1), static_cast(mTextures.size())); // setup format hint if (imIt->second.mEmbeddedFormat.length() >= HINTMAXTEXTURELEN) { @@ -1810,28 +1728,26 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser& pParse // and copy texture data tex->mHeight = 0; tex->mWidth = static_cast(imIt->second.mImageData.size()); - tex->pcData = (aiTexel*)new char[tex->mWidth]; + tex->pcData = (aiTexel *)new char[tex->mWidth]; memcpy(tex->pcData, &imIt->second.mImageData[0], tex->mWidth); // and add this texture to the list mTextures.push_back(tex); - } - else - { - if (imIt->second.mFileName.empty()) { - throw DeadlyImportError("Collada: Invalid texture, no data or file reference given"); - } + return result; + } - result.Set(imIt->second.mFileName); + if (imIt->second.mFileName.empty()) { + throw DeadlyImportError("Collada: Invalid texture, no data or file reference given"); } + + result.Set(imIt->second.mFileName); + return result; } // ------------------------------------------------------------------------------------------------ // Reads a float value from an accessor and its data array. -ai_real ColladaLoader::ReadFloat(const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const -{ - // FIXME: (thom) Test for data type here in every access? For the moment, I leave this to the caller +ai_real ColladaLoader::ReadFloat(const Collada::Accessor &pAccessor, const Collada::Data &pData, size_t pIndex, size_t pOffset) const { size_t pos = pAccessor.mStride * pIndex + pAccessor.mOffset + pOffset; ai_assert(pos < pData.mValues.size()); return pData.mValues[pos]; @@ -1839,8 +1755,7 @@ ai_real ColladaLoader::ReadFloat(const Collada::Accessor& pAccessor, const Colla // ------------------------------------------------------------------------------------------------ // Reads a string value from an accessor and its data array. -const std::string& ColladaLoader::ReadString(const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex) const -{ +const std::string &ColladaLoader::ReadString(const Collada::Accessor &pAccessor, const Collada::Data &pData, size_t pIndex) const { size_t pos = pAccessor.mStride * pIndex + pAccessor.mOffset; ai_assert(pos < pData.mStrings.size()); return pData.mStrings[pos]; @@ -1848,8 +1763,7 @@ const std::string& ColladaLoader::ReadString(const Collada::Accessor& pAccessor, // ------------------------------------------------------------------------------------------------ // Collects all nodes into the given array -void ColladaLoader::CollectNodes(const aiNode* pNode, std::vector& poNodes) const -{ +void ColladaLoader::CollectNodes(const aiNode *pNode, std::vector &poNodes) const { poNodes.push_back(pNode); for (size_t a = 0; a < pNode->mNumChildren; ++a) { CollectNodes(pNode->mChildren[a], poNodes); @@ -1858,24 +1772,23 @@ void ColladaLoader::CollectNodes(const aiNode* pNode, std::vector // ------------------------------------------------------------------------------------------------ // Finds a node in the collada scene by the given name -const Collada::Node* ColladaLoader::FindNode(const Collada::Node* pNode, const std::string& pName) const -{ +const Collada::Node *ColladaLoader::FindNode(const Collada::Node *pNode, const std::string &pName) const { if (pNode->mName == pName || pNode->mID == pName) return pNode; - for (size_t a = 0; a < pNode->mChildren.size(); ++a) - { - const Collada::Node* node = FindNode(pNode->mChildren[a], pName); - if (node) + for (size_t a = 0; a < pNode->mChildren.size(); ++a) { + const Collada::Node *node = FindNode(pNode->mChildren[a], pName); + if (node) { return node; + } } - return NULL; + return nullptr; } // ------------------------------------------------------------------------------------------------ // Finds a node in the collada scene by the given SID -const Collada::Node* ColladaLoader::FindNodeBySID( const Collada::Node* pNode, const std::string& pSID) const { +const Collada::Node *ColladaLoader::FindNodeBySID(const Collada::Node *pNode, const std::string &pSID) const { if (nullptr == pNode) { return nullptr; } @@ -1884,8 +1797,8 @@ const Collada::Node* ColladaLoader::FindNodeBySID( const Collada::Node* pNode, c return pNode; } - for( size_t a = 0; a < pNode->mChildren.size(); ++a) { - const Collada::Node* node = FindNodeBySID( pNode->mChildren[a], pSID); + for (size_t a = 0; a < pNode->mChildren.size(); ++a) { + const Collada::Node *node = FindNodeBySID(pNode->mChildren[a], pSID); if (node) { return node; } @@ -1897,28 +1810,22 @@ const Collada::Node* ColladaLoader::FindNodeBySID( const Collada::Node* pNode, c // ------------------------------------------------------------------------------------------------ // Finds a proper unique name for a node derived from the collada-node's properties. // The name must be unique for proper node-bone association. -std::string ColladaLoader::FindNameForNode(const Collada::Node* pNode) -{ +std::string ColladaLoader::FindNameForNode(const Collada::Node *pNode) { // If explicitly requested, just use the collada name. - if (useColladaName) - { + if (useColladaName) { if (!pNode->mName.empty()) { return pNode->mName; - } - else { + } else { return format() << "$ColladaAutoName$_" << mNodeNameCounter++; } - } - else - { + } else { // Now setup the name of the assimp node. The collada name might not be // unique, so we use the collada ID. if (!pNode->mID.empty()) return pNode->mID; else if (!pNode->mSID.empty()) return pNode->mSID; - else - { + else { // No need to worry. Unnamed nodes are no problem at all, except // if cameras or lights need to be assigned to them. return format() << "$ColladaAutoName$_" << mNodeNameCounter++; diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 25ee2bc3c..964851d60 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -47,18 +47,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER -#include -#include #include "ColladaParser.h" -#include -#include #include #include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include #include @@ -68,28 +68,28 @@ using namespace Assimp::Formatter; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -ColladaParser::ColladaParser(IOSystem* pIOHandler, const std::string& pFile) - : mFileName(pFile) - , mReader(nullptr) - , mDataLibrary() - , mAccessorLibrary() - , mMeshLibrary() - , mNodeLibrary() - , mImageLibrary() - , mEffectLibrary() - , mMaterialLibrary() - , mLightLibrary() - , mCameraLibrary() - , mControllerLibrary() - , mRootNode(nullptr) - , mAnims() - , mUnitSize(1.0f) - , mUpDirection(UP_Y) - , mFormat(FV_1_5_n) // We assume the newest file format by default +ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) : + mFileName(pFile), + mReader(nullptr), + mDataLibrary(), + mAccessorLibrary(), + mMeshLibrary(), + mNodeLibrary(), + mImageLibrary(), + mEffectLibrary(), + mMaterialLibrary(), + mLightLibrary(), + mCameraLibrary(), + mControllerLibrary(), + mRootNode(nullptr), + mAnims(), + mUnitSize(1.0f), + mUpDirection(UP_Y), + mFormat(FV_1_5_n) // We assume the newest file format by default { // validate io-handler instance if (nullptr == pIOHandler) { - throw DeadlyImportError("IOSystem is NULL."); + throw DeadlyImportError("IOSystem is nullptr."); } std::unique_ptr daefile; @@ -112,8 +112,7 @@ ColladaParser::ColladaParser(IOSystem* pIOHandler, const std::string& pFile) if (daefile == nullptr) { ThrowException(std::string("Invalid ZAE manifest: '") + std::string(dae_filename) + std::string("' is missing")); } - } - else { + } else { // attempt to open the file directly daefile.reset(pIOHandler->Open(pFile)); if (daefile.get() == nullptr) { @@ -139,8 +138,7 @@ ColladaParser::ColladaParser(IOSystem* pIOHandler, const std::string& pFile) // ------------------------------------------------------------------------------------------------ // Destructor, private as well -ColladaParser::~ColladaParser() -{ +ColladaParser::~ColladaParser() { delete mReader; for (NodeLibrary::iterator it = mNodeLibrary.begin(); it != mNodeLibrary.end(); ++it) delete it->second; @@ -153,8 +151,7 @@ ColladaParser::~ColladaParser() std::string ColladaParser::ReadZaeManifest(ZipArchiveIOSystem &zip_archive) { // Open the manifest std::unique_ptr manifestfile(zip_archive.Open("manifest.xml")); - if (manifestfile == nullptr) - { + if (manifestfile == nullptr) { // No manifest, hope there is only one .DAE inside std::vector file_list; zip_archive.getFileListExtension(file_list, "dae"); @@ -168,19 +165,16 @@ std::string ColladaParser::ReadZaeManifest(ZipArchiveIOSystem &zip_archive) { std::unique_ptr mIOWrapper(new CIrrXML_IOStreamReader(manifestfile.get())); std::unique_ptr manifest_reader(irr::io::createIrrXMLReader(mIOWrapper.get())); - while (manifest_reader->read()) - { + while (manifest_reader->read()) { // find the manifest "dae_root" element - if (manifest_reader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (::strcmp(manifest_reader->getNodeName(), "dae_root") == 0) - { + if (manifest_reader->getNodeType() == irr::io::EXN_ELEMENT) { + if (::strcmp(manifest_reader->getNodeName(), "dae_root") == 0) { if (!manifest_reader->read()) return std::string(); if (manifest_reader->getNodeType() != irr::io::EXN_TEXT && manifest_reader->getNodeType() != irr::io::EXN_CDATA) return std::string(); - const char* filepath = manifest_reader->getNodeData(); + const char *filepath = manifest_reader->getNodeData(); if (filepath == nullptr) return std::string(); @@ -196,14 +190,12 @@ std::string ColladaParser::ReadZaeManifest(ZipArchiveIOSystem &zip_archive) { // ------------------------------------------------------------------------------------------------ // Convert a path read from a collada file to the usual representation -void ColladaParser::UriDecodePath(aiString& ss) -{ +void ColladaParser::UriDecodePath(aiString &ss) { // TODO: collada spec, p 22. Handle URI correctly. // For the moment we're just stripping the file:// away to make it work. // Windows doesn't seem to be able to find stuff like // 'file://..\LWO\LWO2\MappingModes\earthSpherical.jpg' - if (0 == strncmp(ss.data, "file://", 7)) - { + if (0 == strncmp(ss.data, "file://", 7)) { ss.length -= 7; memmove(ss.data, ss.data + 7, ss.length); ss.data[ss.length] = '\0'; @@ -211,7 +203,7 @@ void ColladaParser::UriDecodePath(aiString& ss) // Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes... // I need to filter it without destroying linux paths starting with "/somewhere" -#if defined( _MSC_VER ) +#if defined(_MSC_VER) if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') { #else if (ss.data[0] == '/' && isalpha(ss.data[1]) && ss.data[2] == ':') { @@ -222,19 +214,15 @@ void ColladaParser::UriDecodePath(aiString& ss) } // find and convert all %xy special chars - char* out = ss.data; - for (const char* it = ss.data; it != ss.data + ss.length; /**/) - { - if (*it == '%' && (it + 3) < ss.data + ss.length) - { + char *out = ss.data; + for (const char *it = ss.data; it != ss.data + ss.length; /**/) { + if (*it == '%' && (it + 3) < ss.data + ss.length) { // separate the number to avoid dragging in chars from behind into the parsing char mychar[3] = { it[1], it[2], 0 }; size_t nbr = strtoul16(mychar); it += 3; *out++ = (char)(nbr & 0xFF); - } - else - { + } else { *out++ = *it++; } } @@ -247,10 +235,9 @@ void ColladaParser::UriDecodePath(aiString& ss) // ------------------------------------------------------------------------------------------------ // Read bool from text contents of current element -bool ColladaParser::ReadBoolFromTextContent() -{ - const char* cur = GetTextContent(); - if ( nullptr == cur) { +bool ColladaParser::ReadBoolFromTextContent() { + const char *cur = GetTextContent(); + if (nullptr == cur) { return false; } return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur); @@ -258,10 +245,9 @@ bool ColladaParser::ReadBoolFromTextContent() // ------------------------------------------------------------------------------------------------ // Read float from text contents of current element -ai_real ColladaParser::ReadFloatFromTextContent() -{ - const char* cur = GetTextContent(); - if ( nullptr == cur ) { +ai_real ColladaParser::ReadFloatFromTextContent() { + const char *cur = GetTextContent(); + if (nullptr == cur) { return 0.0; } return fast_atof(cur); @@ -269,49 +255,39 @@ ai_real ColladaParser::ReadFloatFromTextContent() // ------------------------------------------------------------------------------------------------ // Reads the contents of the file -void ColladaParser::ReadContents() -{ - while (mReader->read()) - { +void ColladaParser::ReadContents() { + while (mReader->read()) { // handle the root element "COLLADA" - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("COLLADA")) - { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("COLLADA")) { // check for 'version' attribute const int attrib = TestAttribute("version"); if (attrib != -1) { - const char* version = mReader->getAttributeValue(attrib); + const char *version = mReader->getAttributeValue(attrib); // Store declared format version string aiString v; v.Set(version); - mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, v ); + mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, v); if (!::strncmp(version, "1.5", 3)) { mFormat = FV_1_5_n; ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n"); - } - else if (!::strncmp(version, "1.4", 3)) { + } else if (!::strncmp(version, "1.4", 3)) { mFormat = FV_1_4_n; ASSIMP_LOG_DEBUG("Collada schema version is 1.4.n"); - } - else if (!::strncmp(version, "1.3", 3)) { + } else if (!::strncmp(version, "1.3", 3)) { mFormat = FV_1_3_n; ASSIMP_LOG_DEBUG("Collada schema version is 1.3.n"); } } ReadStructure(); - } - else - { - ASSIMP_LOG_DEBUG_F("Ignoring global element <", mReader->getNodeName(), ">."); + } else { + ASSIMP_LOG_VERBOSE_DEBUG_F("Ignoring global element <", mReader->getNodeName(), ">."); SkipElement(); } - } - else - { + } else { // skip everything else silently } } @@ -319,13 +295,10 @@ void ColladaParser::ReadContents() // ------------------------------------------------------------------------------------------------ // Reads the structure of the file -void ColladaParser::ReadStructure() -{ - while (mReader->read()) - { +void ColladaParser::ReadStructure() { + while (mReader->read()) { // beginning of elements - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { if (IsElement("asset")) ReadAssetInfo(); else if (IsElement("library_animations")) @@ -349,14 +322,12 @@ void ColladaParser::ReadStructure() else if (IsElement("library_cameras")) ReadCameraLibrary(); else if (IsElement("library_nodes")) - ReadSceneNode(NULL); /* some hacking to reuse this piece of code */ + ReadSceneNode(nullptr); /* some hacking to reuse this piece of code */ else if (IsElement("scene")) ReadScene(); else SkipElement(); - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { break; } } @@ -367,34 +338,27 @@ void ColladaParser::ReadStructure() // ------------------------------------------------------------------------------------------------ // Reads asset information such as coordinate system information and legal blah -void ColladaParser::ReadAssetInfo() -{ +void ColladaParser::ReadAssetInfo() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("unit")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("unit")) { // read unit data from the element's attributes const int attrIndex = TestAttribute("meter"); if (attrIndex == -1) { mUnitSize = 1.f; - } - else { + } else { mUnitSize = mReader->getAttributeValueAsFloat(attrIndex); } // consume the trailing stuff if (!mReader->isEmptyElement()) SkipElement(); - } - else if (IsElement("up_axis")) - { + } else if (IsElement("up_axis")) { // read content, strip whitespace, compare - const char* content = GetTextContent(); + const char *content = GetTextContent(); if (strncmp(content, "X_UP", 4) == 0) mUpDirection = UP_X; else if (strncmp(content, "Z_UP", 4) == 0) @@ -404,18 +368,12 @@ void ColladaParser::ReadAssetInfo() // check element end TestClosing("up_axis"); - } - else if (IsElement("contributor")) - { + } else if (IsElement("contributor")) { ReadContributorInfo(); - } - else - { + } else { ReadMetaDataItem(mAssetMetaData); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "asset") != 0) ThrowException("Expected end of element."); @@ -426,19 +384,14 @@ void ColladaParser::ReadAssetInfo() // ------------------------------------------------------------------------------------------------ // Reads the contributor info -void ColladaParser::ReadContributorInfo() -{ +void ColladaParser::ReadContributorInfo() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { ReadMetaDataItem(mAssetMetaData); - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "contributor") != 0) ThrowException("Expected end of element."); break; @@ -448,11 +401,11 @@ void ColladaParser::ReadContributorInfo() static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) { for (size_t i = 0; i < key_renaming.size(); ++i) { - if (key_renaming[i].first == collada_key) { + if (key_renaming[i].first == collada_key) { found_index = i; return true; - } - } + } + } found_index = std::numeric_limits::max(); return false; } @@ -461,44 +414,39 @@ static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVecto // Reads a single string metadata item void ColladaParser::ReadMetaDataItem(StringMetaData &metadata) { const Collada::MetaKeyPairVector &key_renaming = GetColladaAssimpMetaKeysCamelCase(); - // Metadata such as created, keywords, subject etc - const char *key_char = mReader->getNodeName(); - if (key_char != nullptr) { + // Metadata such as created, keywords, subject etc + const char *key_char = mReader->getNodeName(); + if (key_char != nullptr) { const std::string key_str(key_char); - const char *value_char = TestTextContent(); - if (value_char != nullptr) { + const char *value_char = TestTextContent(); + if (value_char != nullptr) { aiString aistr; - aistr.Set(value_char); + aistr.Set(value_char); std::string camel_key_str(key_str); - ToCamelCase(camel_key_str); + ToCamelCase(camel_key_str); - size_t found_index; - if (FindCommonKey(camel_key_str, key_renaming, found_index)) { + size_t found_index; + if (FindCommonKey(camel_key_str, key_renaming, found_index)) { metadata.emplace(key_renaming[found_index].second, aistr); } else { - metadata.emplace(camel_key_str, aistr); - } + metadata.emplace(camel_key_str, aistr); + } } TestClosing(key_str.c_str()); - } - else + } else SkipElement(); } // ------------------------------------------------------------------------------------------------ // Reads the animation clips -void ColladaParser::ReadAnimationClipLibrary() -{ +void ColladaParser::ReadAnimationClipLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("animation_clip")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("animation_clip")) { // optional name given as an attribute std::string animName; int indexName = TestAttribute("name"); @@ -510,20 +458,16 @@ void ColladaParser::ReadAnimationClipLibrary() else animName = std::string("animation_") + to_string(mAnimationClipLibrary.size()); - std::pair > clip; + std::pair> clip; clip.first = animName; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("instance_animation")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("instance_animation")) { int indexUrl = TestAttribute("url"); - if (indexUrl >= 0) - { - const char* url = mReader->getAttributeValue(indexUrl); + if (indexUrl >= 0) { + const char *url = mReader->getAttributeValue(indexUrl); if (url[0] != '#') ThrowException("Unknown reference format"); @@ -531,15 +475,11 @@ void ColladaParser::ReadAnimationClipLibrary() clip.second.push_back(url); } - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "animation_clip") != 0) ThrowException("Expected end of element."); @@ -547,19 +487,14 @@ void ColladaParser::ReadAnimationClipLibrary() } } - if (clip.second.size() > 0) - { + if (clip.second.size() > 0) { mAnimationClipLibrary.push_back(clip); } - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_animation_clips") != 0) ThrowException("Expected end of element."); @@ -568,8 +503,7 @@ void ColladaParser::ReadAnimationClipLibrary() } } -void ColladaParser::PostProcessControllers() -{ +void ColladaParser::PostProcessControllers() { std::string meshId; for (ControllerLibrary::iterator it = mControllerLibrary.begin(); it != mControllerLibrary.end(); ++it) { meshId = it->second.mMeshId; @@ -585,14 +519,11 @@ void ColladaParser::PostProcessControllers() // ------------------------------------------------------------------------------------------------ // Re-build animations from animation clip library, if present, otherwise combine single-channel animations -void ColladaParser::PostProcessRootAnimations() -{ - if (mAnimationClipLibrary.size() > 0) - { +void ColladaParser::PostProcessRootAnimations() { + if (mAnimationClipLibrary.size() > 0) { Animation temp; - for (AnimationClipLibrary::iterator it = mAnimationClipLibrary.begin(); it != mAnimationClipLibrary.end(); ++it) - { + for (AnimationClipLibrary::iterator it = mAnimationClipLibrary.begin(); it != mAnimationClipLibrary.end(); ++it) { std::string clipName = it->first; Animation *clip = new Animation(); @@ -600,14 +531,12 @@ void ColladaParser::PostProcessRootAnimations() temp.mSubAnims.push_back(clip); - for (std::vector::iterator a = it->second.begin(); a != it->second.end(); ++a) - { + for (std::vector::iterator a = it->second.begin(); a != it->second.end(); ++a) { std::string animationID = *a; AnimationLibrary::iterator animation = mAnimationLibrary.find(animationID); - if (animation != mAnimationLibrary.end()) - { + if (animation != mAnimationLibrary.end()) { Animation *pSourceAnimation = animation->second; pSourceAnimation->CollectChannelsRecursively(clip->mChannels); @@ -619,37 +548,27 @@ void ColladaParser::PostProcessRootAnimations() // Ensure no double deletes. temp.mSubAnims.clear(); - } - else - { + } else { mAnims.CombineSingleChannelAnimations(); } } // ------------------------------------------------------------------------------------------------ // Reads the animation library -void ColladaParser::ReadAnimationLibrary() -{ +void ColladaParser::ReadAnimationLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("animation")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("animation")) { // delegate the reading. Depending on the inner elements it will be a container or a anim channel ReadAnimation(&mAnims); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_animations") != 0) ThrowException("Expected end of element."); @@ -660,8 +579,7 @@ void ColladaParser::ReadAnimationLibrary() // ------------------------------------------------------------------------------------------------ // Reads an animation into the given parent structure -void ColladaParser::ReadAnimation(Collada::Animation* pParent) -{ +void ColladaParser::ReadAnimation(Collada::Animation *pParent) { if (mReader->isEmptyElement()) return; @@ -670,7 +588,7 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) typedef std::map ChannelMap; ChannelMap channels; // this is the anim container in case we're a container - Animation* anim = NULL; + Animation *anim = nullptr; // optional name given as an attribute std::string animName; @@ -688,16 +606,12 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) else animName = "animation"; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { // we have subanimations - if (IsElement("animation")) - { + if (IsElement("animation")) { // create container from our element - if (!anim) - { + if (!anim) { anim = new Animation; anim->mName = animName; pParent->mSubAnims.push_back(anim); @@ -705,14 +619,10 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) // recurse into the subelement ReadAnimation(anim); - } - else if (IsElement("source")) - { + } else if (IsElement("source")) { // possible animation data - we'll never know. Better store it ReadSource(); - } - else if (IsElement("sampler")) - { + } else if (IsElement("sampler")) { // read the ID to assign the corresponding collada channel afterwards. int indexId = GetAttribute("id"); std::string id = mReader->getAttributeValue(indexId); @@ -720,15 +630,13 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) // have it read into a channel ReadAnimationSampler(newChannel->second); - } - else if (IsElement("channel")) - { + } else if (IsElement("channel")) { // the binding element whose whole purpose is to provide the target to animate // Thanks, Collada! A directly posted information would have been too simple, I guess. // Better add another indirection to that! Can't have enough of those. int indexTarget = GetAttribute("target"); int indexSource = GetAttribute("source"); - const char* sourceId = mReader->getAttributeValue(indexSource); + const char *sourceId = mReader->getAttributeValue(indexSource); if (sourceId[0] == '#') sourceId++; ChannelMap::iterator cit = channels.find(sourceId); @@ -737,15 +645,11 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) if (!mReader->isEmptyElement()) SkipElement(); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "animation") != 0) ThrowException("Expected end of element."); @@ -754,15 +658,14 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) } // it turned out to have channels - add them - if (!channels.empty()) - { + if (!channels.empty()) { // FIXME: Is this essentially doing the same as "single-anim-node" codepath in // ColladaLoader::StoreAnimations? For now, this has been deferred to after // all animations and all clips have been read. Due to handling of // this cannot be done here, as the channel owner // is lost, and some exporters make up animations by referring to multiple // single-channel animations from an . -/* + /* // special filtering for stupid exporters packing each channel into a separate animation if( channels.size() == 1) { @@ -771,8 +674,7 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) */ { // else create the animation, if not done yet, and store the channels - if (!anim) - { + if (!anim) { anim = new Animation; anim->mName = animName; pParent->mSubAnims.push_back(anim); @@ -780,8 +682,7 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) for (ChannelMap::const_iterator it = channels.begin(); it != channels.end(); ++it) anim->mChannels.push_back(it->second); - if (indexID >= 0) - { + if (indexID >= 0) { mAnimationLibrary[animID] = anim; } } @@ -790,18 +691,14 @@ void ColladaParser::ReadAnimation(Collada::Animation* pParent) // ------------------------------------------------------------------------------------------------ // Reads an animation sampler into the given anim channel -void ColladaParser::ReadAnimationSampler(Collada::AnimationChannel& pChannel) -{ - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("input")) - { +void ColladaParser::ReadAnimationSampler(Collada::AnimationChannel &pChannel) { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("input")) { int indexSemantic = GetAttribute("semantic"); - const char* semantic = mReader->getAttributeValue(indexSemantic); + const char *semantic = mReader->getAttributeValue(indexSemantic); int indexSource = GetAttribute("source"); - const char* source = mReader->getAttributeValue(indexSource); + const char *source = mReader->getAttributeValue(indexSource); if (source[0] != '#') ThrowException("Unsupported URL format"); source++; @@ -819,15 +716,11 @@ void ColladaParser::ReadAnimationSampler(Collada::AnimationChannel& pChannel) if (!mReader->isEmptyElement()) SkipElement(); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "sampler") != 0) ThrowException("Expected end of element."); @@ -838,17 +731,13 @@ void ColladaParser::ReadAnimationSampler(Collada::AnimationChannel& pChannel) // ------------------------------------------------------------------------------------------------ // Reads the skeleton controller library -void ColladaParser::ReadControllerLibrary() -{ +void ColladaParser::ReadControllerLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("controller")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("controller")) { // read ID. Ask the spec if it's necessary or optional... you might be surprised. int attrID = GetAttribute("id"); std::string id = mReader->getAttributeValue(attrID); @@ -858,15 +747,11 @@ void ColladaParser::ReadControllerLibrary() // read on from there ReadController(mControllerLibrary[id]); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_controllers") != 0) ThrowException("Expected end of element."); @@ -877,18 +762,14 @@ void ColladaParser::ReadControllerLibrary() // ------------------------------------------------------------------------------------------------ // Reads a controller into the given mesh structure -void ColladaParser::ReadController(Collada::Controller& pController) -{ +void ColladaParser::ReadController(Collada::Controller &pController) { // initial values pController.mType = Skin; pController.mMethod = Normalized; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { // two types of controllers: "skin" and "morph". Only the first one is relevant, we skip the other - if (IsElement("morph")) - { + if (IsElement("morph")) { pController.mType = Morph; int baseIndex = GetAttribute("source"); pController.mMeshId = mReader->getAttributeValue(baseIndex) + 1; @@ -898,22 +779,17 @@ void ColladaParser::ReadController(Collada::Controller& pController) if (strcmp(method, "RELATIVE") == 0) pController.mMethod = Relative; } - } - else if (IsElement("skin")) - { + } else if (IsElement("skin")) { // read the mesh it refers to. According to the spec this could also be another // controller, but I refuse to implement every single idea they've come up with int sourceIndex = GetAttribute("source"); pController.mMeshId = mReader->getAttributeValue(sourceIndex) + 1; - } - else if (IsElement("bind_shape_matrix")) - { + } else if (IsElement("bind_shape_matrix")) { // content is 16 floats to define a matrix... it seems to be important for some models - const char* content = GetTextContent(); + const char *content = GetTextContent(); // read the 16 floats - for (unsigned int a = 0; a < 16; a++) - { + for (unsigned int a = 0; a < 16; a++) { // read a number content = fast_atoreal_move(content, pController.mBindShapeMatrix[a]); // skip whitespace after it @@ -921,22 +797,14 @@ void ColladaParser::ReadController(Collada::Controller& pController) } TestClosing("bind_shape_matrix"); - } - else if (IsElement("source")) - { + } else if (IsElement("source")) { // data array - we have specialists to handle this ReadSource(); - } - else if (IsElement("joints")) - { + } else if (IsElement("joints")) { ReadControllerJoints(pController); - } - else if (IsElement("vertex_weights")) - { + } else if (IsElement("vertex_weights")) { ReadControllerWeights(pController); - } - else if (IsElement("targets")) - { + } else if (IsElement("targets")) { while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { if (IsElement("input")) { @@ -947,29 +815,22 @@ void ColladaParser::ReadController(Collada::Controller& pController) const char *source = mReader->getAttributeValue(sourceIndex); if (strcmp(semantics, "MORPH_TARGET") == 0) { pController.mMorphTarget = source + 1; - } - else if (strcmp(semantics, "MORPH_WEIGHT") == 0) - { + } else if (strcmp(semantics, "MORPH_WEIGHT") == 0) { pController.mMorphWeight = source + 1; } } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "targets") == 0) break; else ThrowException("Expected end of element."); } } - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "controller") == 0) break; else if (strcmp(mReader->getNodeName(), "skin") != 0 && strcmp(mReader->getNodeName(), "morph") != 0) @@ -980,19 +841,15 @@ void ColladaParser::ReadController(Collada::Controller& pController) // ------------------------------------------------------------------------------------------------ // Reads the joint definitions for the given controller -void ColladaParser::ReadControllerJoints(Collada::Controller& pController) -{ - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { +void ColladaParser::ReadControllerJoints(Collada::Controller &pController) { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { // Input channels for joint data. Two possible semantics: "JOINT" and "INV_BIND_MATRIX" - if (IsElement("input")) - { + if (IsElement("input")) { int indexSemantic = GetAttribute("semantic"); - const char* attrSemantic = mReader->getAttributeValue(indexSemantic); + const char *attrSemantic = mReader->getAttributeValue(indexSemantic); int indexSource = GetAttribute("source"); - const char* attrSource = mReader->getAttributeValue(indexSource); + const char *attrSource = mReader->getAttributeValue(indexSource); // local URLS always start with a '#'. We don't support global URLs if (attrSource[0] != '#') @@ -1010,15 +867,11 @@ void ColladaParser::ReadControllerJoints(Collada::Controller& pController) // skip inner data, if present if (!mReader->isEmptyElement()) SkipElement(); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "joints") != 0) ThrowException("Expected end of element."); @@ -1029,26 +882,22 @@ void ColladaParser::ReadControllerJoints(Collada::Controller& pController) // ------------------------------------------------------------------------------------------------ // Reads the joint weights for the given controller -void ColladaParser::ReadControllerWeights(Collada::Controller& pController) -{ +void ColladaParser::ReadControllerWeights(Collada::Controller &pController) { // read vertex count from attributes and resize the array accordingly int indexCount = GetAttribute("count"); size_t vertexCount = (size_t)mReader->getAttributeValueAsInt(indexCount); pController.mWeightCounts.resize(vertexCount); - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { // Input channels for weight data. Two possible semantics: "JOINT" and "WEIGHT" - if (IsElement("input") && vertexCount > 0) - { + if (IsElement("input") && vertexCount > 0) { InputChannel channel; int indexSemantic = GetAttribute("semantic"); - const char* attrSemantic = mReader->getAttributeValue(indexSemantic); + const char *attrSemantic = mReader->getAttributeValue(indexSemantic); int indexSource = GetAttribute("source"); - const char* attrSource = mReader->getAttributeValue(indexSource); + const char *attrSource = mReader->getAttributeValue(indexSource); int indexOffset = TestAttribute("offset"); if (indexOffset >= 0) channel.mOffset = mReader->getAttributeValueAsInt(indexOffset); @@ -1069,14 +918,11 @@ void ColladaParser::ReadControllerWeights(Collada::Controller& pController) // skip inner data, if present if (!mReader->isEmptyElement()) SkipElement(); - } - else if (IsElement("vcount") && vertexCount > 0) - { + } else if (IsElement("vcount") && vertexCount > 0) { // read weight count per vertex - const char* text = GetTextContent(); + const char *text = GetTextContent(); size_t numWeights = 0; - for (std::vector::iterator it = pController.mWeightCounts.begin(); it != pController.mWeightCounts.end(); ++it) - { + for (std::vector::iterator it = pController.mWeightCounts.begin(); it != pController.mWeightCounts.end(); ++it) { if (*text == 0) ThrowException("Out of data while reading "); @@ -1089,14 +935,11 @@ void ColladaParser::ReadControllerWeights(Collada::Controller& pController) // reserve weight count pController.mWeights.resize(numWeights); - } - else if (IsElement("v") && vertexCount > 0) - { + } else if (IsElement("v") && vertexCount > 0) { // read JointIndex - WeightIndex pairs - const char* text = GetTextContent(); + const char *text = GetTextContent(); - for (std::vector< std::pair >::iterator it = pController.mWeights.begin(); it != pController.mWeights.end(); ++it) - { + for (std::vector>::iterator it = pController.mWeights.begin(); it != pController.mWeights.end(); ++it) { if (*text == 0) ThrowException("Out of data while reading "); it->first = strtoul10(text, &text); @@ -1108,15 +951,11 @@ void ColladaParser::ReadControllerWeights(Collada::Controller& pController) } TestClosing("v"); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "vertex_weights") != 0) ThrowException("Expected end of element."); @@ -1127,16 +966,13 @@ void ColladaParser::ReadControllerWeights(Collada::Controller& pController) // ------------------------------------------------------------------------------------------------ // Reads the image library contents -void ColladaParser::ReadImageLibrary() -{ +void ColladaParser::ReadImageLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("image")) - { + if (IsElement("image")) { // read ID. Another entry which is "optional" by design but obligatory in reality int attrID = GetAttribute("id"); std::string id = mReader->getAttributeValue(attrID); @@ -1146,14 +982,11 @@ void ColladaParser::ReadImageLibrary() // read on from there ReadImage(mImageLibrary[id]); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_images") != 0) ThrowException("Expected end of element."); @@ -1164,25 +997,19 @@ void ColladaParser::ReadImageLibrary() // ------------------------------------------------------------------------------------------------ // Reads an image entry into the given image -void ColladaParser::ReadImage(Collada::Image& pImage) -{ - while (mReader->read()) - { +void ColladaParser::ReadImage(Collada::Image &pImage) { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { // Need to run different code paths here, depending on the Collada XSD version if (IsElement("image")) { SkipElement(); - } - else if (IsElement("init_from")) - { - if (mFormat == FV_1_4_n) - { + } else if (IsElement("init_from")) { + if (mFormat == FV_1_4_n) { // FIX: C4D exporter writes empty tags if (!mReader->isEmptyElement()) { // element content is filename - hopefully - const char* sz = TestTextContent(); - if (sz) - { + const char *sz = TestTextContent(); + if (sz) { aiString filepath(sz); UriDecodePath(filepath); pImage.mFileName = filepath.C_Str(); @@ -1192,9 +1019,7 @@ void ColladaParser::ReadImage(Collada::Image& pImage) if (!pImage.mFileName.length()) { pImage.mFileName = "unknown_texture"; } - } - else if (mFormat == FV_1_5_n) - { + } else if (mFormat == FV_1_5_n) { // make sure we skip over mip and array initializations, which // we don't support, but which could confuse the loader if // they're not skipped. @@ -1212,35 +1037,31 @@ void ColladaParser::ReadImage(Collada::Image& pImage) // TODO: correctly jump over cube and volume maps? } - } - else if (mFormat == FV_1_5_n) - { - if (IsElement("ref")) - { + } else if (mFormat == FV_1_5_n) { + if (IsElement("ref")) { // element content is filename - hopefully - const char* sz = TestTextContent(); - if (sz) - { + const char *sz = TestTextContent(); + if (sz) { aiString filepath(sz); UriDecodePath(filepath); pImage.mFileName = filepath.C_Str(); } TestClosing("ref"); - } - else if (IsElement("hex") && !pImage.mFileName.length()) - { + } else if (IsElement("hex") && !pImage.mFileName.length()) { // embedded image. get format const int attrib = TestAttribute("format"); if (-1 == attrib) ASSIMP_LOG_WARN("Collada: Unknown image file format"); - else pImage.mEmbeddedFormat = mReader->getAttributeValue(attrib); + else + pImage.mEmbeddedFormat = mReader->getAttributeValue(attrib); - const char* data = GetTextContent(); + const char *data = GetTextContent(); // hexadecimal-encoded binary octets. First of all, find the // required buffer size to reserve enough storage. - const char* cur = data; - while (!IsSpaceOrNewLine(*cur)) cur++; + const char *cur = data; + while (!IsSpaceOrNewLine(*cur)) + cur++; const unsigned int size = (unsigned int)(cur - data) * 2; pImage.mImageData.resize(size); @@ -1249,14 +1070,11 @@ void ColladaParser::ReadImage(Collada::Image& pImage) TestClosing("hex"); } - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "image") == 0) break; } @@ -1265,18 +1083,14 @@ void ColladaParser::ReadImage(Collada::Image& pImage) // ------------------------------------------------------------------------------------------------ // Reads the material library -void ColladaParser::ReadMaterialLibrary() -{ +void ColladaParser::ReadMaterialLibrary() { if (mReader->isEmptyElement()) return; std::map names; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("material")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("material")) { // read ID. By now you probably know my opinion about this "specification" int attrID = GetAttribute("id"); std::string id = mReader->getAttributeValue(attrID); @@ -1289,17 +1103,13 @@ void ColladaParser::ReadMaterialLibrary() // create an entry and store it in the library under its ID mMaterialLibrary[id] = Material(); - if (!name.empty()) - { + if (!name.empty()) { std::map::iterator it = names.find(name); - if (it != names.end()) - { + if (it != names.end()) { std::ostringstream strStream; strStream << ++it->second; name.append(" " + strStream.str()); - } - else - { + } else { names[name] = 0; } @@ -1307,15 +1117,11 @@ void ColladaParser::ReadMaterialLibrary() } ReadMaterial(mMaterialLibrary[id]); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_materials") != 0) ThrowException("Expected end of element."); @@ -1326,16 +1132,13 @@ void ColladaParser::ReadMaterialLibrary() // ------------------------------------------------------------------------------------------------ // Reads the light library -void ColladaParser::ReadLightLibrary() -{ +void ColladaParser::ReadLightLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("light")) - { + if (IsElement("light")) { // read ID. By now you probably know my opinion about this "specification" int attrID = GetAttribute("id"); std::string id = mReader->getAttributeValue(attrID); @@ -1343,14 +1146,11 @@ void ColladaParser::ReadLightLibrary() // create an entry and store it in the library under its ID ReadLight(mLightLibrary[id] = Light()); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_lights") != 0) ThrowException("Expected end of element."); @@ -1361,36 +1161,30 @@ void ColladaParser::ReadLightLibrary() // ------------------------------------------------------------------------------------------------ // Reads the camera library -void ColladaParser::ReadCameraLibrary() -{ +void ColladaParser::ReadCameraLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("camera")) - { + if (IsElement("camera")) { // read ID. By now you probably know my opinion about this "specification" int attrID = GetAttribute("id"); std::string id = mReader->getAttributeValue(attrID); // create an entry and store it in the library under its ID - Camera& cam = mCameraLibrary[id]; + Camera &cam = mCameraLibrary[id]; attrID = TestAttribute("name"); if (attrID != -1) cam.mName = mReader->getAttributeValue(attrID); ReadCamera(cam); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_cameras") != 0) ThrowException("Expected end of element."); @@ -1401,33 +1195,26 @@ void ColladaParser::ReadCameraLibrary() // ------------------------------------------------------------------------------------------------ // Reads a material entry into the given material -void ColladaParser::ReadMaterial(Collada::Material& pMaterial) -{ - while (mReader->read()) - { +void ColladaParser::ReadMaterial(Collada::Material &pMaterial) { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { if (IsElement("material")) { SkipElement(); - } - else if (IsElement("instance_effect")) - { + } else if (IsElement("instance_effect")) { // referred effect by URL int attrUrl = GetAttribute("url"); - const char* url = mReader->getAttributeValue(attrUrl); + const char *url = mReader->getAttributeValue(attrUrl); if (url[0] != '#') ThrowException("Unknown reference format"); pMaterial.mEffect = url + 1; SkipElement(); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "material") != 0) ThrowException("Expected end of element."); @@ -1438,58 +1225,46 @@ void ColladaParser::ReadMaterial(Collada::Material& pMaterial) // ------------------------------------------------------------------------------------------------ // Reads a light entry into the given light -void ColladaParser::ReadLight(Collada::Light& pLight) -{ - while (mReader->read()) - { +void ColladaParser::ReadLight(Collada::Light &pLight) { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { if (IsElement("light")) { SkipElement(); - } - else if (IsElement("spot")) { + } else if (IsElement("spot")) { pLight.mType = aiLightSource_SPOT; - } - else if (IsElement("ambient")) { + } else if (IsElement("ambient")) { pLight.mType = aiLightSource_AMBIENT; - } - else if (IsElement("directional")) { + } else if (IsElement("directional")) { pLight.mType = aiLightSource_DIRECTIONAL; - } - else if (IsElement("point")) { + } else if (IsElement("point")) { pLight.mType = aiLightSource_POINT; - } - else if (IsElement("color")) { + } else if (IsElement("color")) { // text content contains 3 floats - const char* content = GetTextContent(); + const char *content = GetTextContent(); - content = fast_atoreal_move(content, (ai_real&)pLight.mColor.r); + content = fast_atoreal_move(content, (ai_real &)pLight.mColor.r); SkipSpacesAndLineEnd(&content); - content = fast_atoreal_move(content, (ai_real&)pLight.mColor.g); + content = fast_atoreal_move(content, (ai_real &)pLight.mColor.g); SkipSpacesAndLineEnd(&content); - content = fast_atoreal_move(content, (ai_real&)pLight.mColor.b); + content = fast_atoreal_move(content, (ai_real &)pLight.mColor.b); SkipSpacesAndLineEnd(&content); TestClosing("color"); - } - else if (IsElement("constant_attenuation")) { + } else if (IsElement("constant_attenuation")) { pLight.mAttConstant = ReadFloatFromTextContent(); TestClosing("constant_attenuation"); - } - else if (IsElement("linear_attenuation")) { + } else if (IsElement("linear_attenuation")) { pLight.mAttLinear = ReadFloatFromTextContent(); TestClosing("linear_attenuation"); - } - else if (IsElement("quadratic_attenuation")) { + } else if (IsElement("quadratic_attenuation")) { pLight.mAttQuadratic = ReadFloatFromTextContent(); TestClosing("quadratic_attenuation"); - } - else if (IsElement("falloff_angle")) { + } else if (IsElement("falloff_angle")) { pLight.mFalloffAngle = ReadFloatFromTextContent(); TestClosing("falloff_angle"); - } - else if (IsElement("falloff_exponent")) { + } else if (IsElement("falloff_exponent")) { pLight.mFalloffExponent = ReadFloatFromTextContent(); TestClosing("falloff_exponent"); } @@ -1503,16 +1278,13 @@ void ColladaParser::ReadLight(Collada::Light& pLight) else if (IsElement("penumbra_angle")) { pLight.mPenumbraAngle = ReadFloatFromTextContent(); TestClosing("penumbra_angle"); - } - else if (IsElement("intensity")) { + } else if (IsElement("intensity")) { pLight.mIntensity = ReadFloatFromTextContent(); TestClosing("intensity"); - } - else if (IsElement("falloff")) { + } else if (IsElement("falloff")) { pLight.mOuterAngle = ReadFloatFromTextContent(); TestClosing("falloff"); - } - else if (IsElement("hotspot_beam")) { + } else if (IsElement("hotspot_beam")) { pLight.mFalloffAngle = ReadFloatFromTextContent(); TestClosing("hotspot_beam"); } @@ -1522,8 +1294,7 @@ void ColladaParser::ReadLight(Collada::Light& pLight) pLight.mOuterAngle = ReadFloatFromTextContent(); TestClosing("decay_falloff"); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "light") == 0) break; } @@ -1532,39 +1303,30 @@ void ColladaParser::ReadLight(Collada::Light& pLight) // ------------------------------------------------------------------------------------------------ // Reads a camera entry into the given light -void ColladaParser::ReadCamera(Collada::Camera& pCamera) -{ - while (mReader->read()) - { +void ColladaParser::ReadCamera(Collada::Camera &pCamera) { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { if (IsElement("camera")) { SkipElement(); - } - else if (IsElement("orthographic")) { + } else if (IsElement("orthographic")) { pCamera.mOrtho = true; - } - else if (IsElement("xfov") || IsElement("xmag")) { + } else if (IsElement("xfov") || IsElement("xmag")) { pCamera.mHorFov = ReadFloatFromTextContent(); TestClosing((pCamera.mOrtho ? "xmag" : "xfov")); - } - else if (IsElement("yfov") || IsElement("ymag")) { + } else if (IsElement("yfov") || IsElement("ymag")) { pCamera.mVerFov = ReadFloatFromTextContent(); TestClosing((pCamera.mOrtho ? "ymag" : "yfov")); - } - else if (IsElement("aspect_ratio")) { + } else if (IsElement("aspect_ratio")) { pCamera.mAspect = ReadFloatFromTextContent(); TestClosing("aspect_ratio"); - } - else if (IsElement("znear")) { + } else if (IsElement("znear")) { pCamera.mZNear = ReadFloatFromTextContent(); TestClosing("znear"); - } - else if (IsElement("zfar")) { + } else if (IsElement("zfar")) { pCamera.mZFar = ReadFloatFromTextContent(); TestClosing("zfar"); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "camera") == 0) break; } @@ -1573,17 +1335,14 @@ void ColladaParser::ReadCamera(Collada::Camera& pCamera) // ------------------------------------------------------------------------------------------------ // Reads the effect library -void ColladaParser::ReadEffectLibrary() -{ +void ColladaParser::ReadEffectLibrary() { if (mReader->isEmptyElement()) { return; } - while (mReader->read()) - { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("effect")) - { + if (IsElement("effect")) { // read ID. Do I have to repeat my ranting about "optional" attributes? int attrID = GetAttribute("id"); std::string id = mReader->getAttributeValue(attrID); @@ -1592,14 +1351,11 @@ void ColladaParser::ReadEffectLibrary() mEffectLibrary[id] = Effect(); // read on from there ReadEffect(mEffectLibrary[id]); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_effects") != 0) ThrowException("Expected end of element."); @@ -1610,20 +1366,15 @@ void ColladaParser::ReadEffectLibrary() // ------------------------------------------------------------------------------------------------ // Reads an effect entry into the given effect -void ColladaParser::ReadEffect(Collada::Effect& pEffect) -{ +void ColladaParser::ReadEffect(Collada::Effect &pEffect) { // for the moment we don't support any other type of effect. - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { if (IsElement("profile_COMMON")) ReadEffectProfileCommon(pEffect); else SkipElement(); - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "effect") != 0) ThrowException("Expected end of element."); @@ -1634,26 +1385,20 @@ void ColladaParser::ReadEffect(Collada::Effect& pEffect) // ------------------------------------------------------------------------------------------------ // Reads an COMMON effect profile -void ColladaParser::ReadEffectProfileCommon(Collada::Effect& pEffect) -{ - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { +void ColladaParser::ReadEffectProfileCommon(Collada::Effect &pEffect) { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { if (IsElement("newparam")) { // save ID int attrSID = GetAttribute("sid"); std::string sid = mReader->getAttributeValue(attrSID); pEffect.mParams[sid] = EffectParam(); ReadEffectParam(pEffect.mParams[sid]); - } - else if (IsElement("technique") || IsElement("extra")) - { + } else if (IsElement("technique") || IsElement("extra")) { // just syntactic sugar } - else if (mFormat == FV_1_4_n && IsElement("image")) - { + else if (mFormat == FV_1_4_n && IsElement("image")) { // read ID. Another entry which is "optional" by design but obligatory in reality int attrID = GetAttribute("id"); std::string id = mReader->getAttributeValue(attrID); @@ -1686,11 +1431,10 @@ void ColladaParser::ReadEffectProfileCommon(Collada::Effect& pEffect) ReadEffectColor(pEffect.mSpecular, pEffect.mTexSpecular); else if (IsElement("reflective")) { ReadEffectColor(pEffect.mReflective, pEffect.mTexReflective); - } - else if (IsElement("transparent")) { + } else if (IsElement("transparent")) { pEffect.mHasTransparency = true; - const char* opaque = mReader->getAttributeValueSafe("opaque"); + const char *opaque = mReader->getAttributeValueSafe("opaque"); if (::strcmp(opaque, "RGB_ZERO") == 0 || ::strcmp(opaque, "RGB_ONE") == 0) { pEffect.mRGBTransparency = true; @@ -1702,8 +1446,7 @@ void ColladaParser::ReadEffectProfileCommon(Collada::Effect& pEffect) } ReadEffectColor(pEffect.mTransparent, pEffect.mTexTransparent); - } - else if (IsElement("shininess")) + } else if (IsElement("shininess")) ReadEffectFloat(pEffect.mShininess); else if (IsElement("reflectivity")) ReadEffectFloat(pEffect.mReflectivity); @@ -1731,20 +1474,15 @@ void ColladaParser::ReadEffectProfileCommon(Collada::Effect& pEffect) else if (IsElement("wireframe")) { pEffect.mWireframe = ReadBoolFromTextContent(); TestClosing("wireframe"); - } - else if (IsElement("faceted")) { + } else if (IsElement("faceted")) { pEffect.mFaceted = ReadBoolFromTextContent(); TestClosing("faceted"); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { - if (strcmp(mReader->getNodeName(), "profile_COMMON") == 0) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + if (strcmp(mReader->getNodeName(), "profile_COMMON") == 0) { break; } } @@ -1753,14 +1491,12 @@ void ColladaParser::ReadEffectProfileCommon(Collada::Effect& pEffect) // ------------------------------------------------------------------------------------------------ // Read texture wrapping + UV transform settings from a profile==Maya chunk -void ColladaParser::ReadSamplerProperties(Sampler& out) -{ +void ColladaParser::ReadSamplerProperties(Sampler &out) { if (mReader->isEmptyElement()) { return; } - while (mReader->read()) - { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { // MAYA extensions @@ -1768,42 +1504,33 @@ void ColladaParser::ReadSamplerProperties(Sampler& out) if (IsElement("wrapU")) { out.mWrapU = ReadBoolFromTextContent(); TestClosing("wrapU"); - } - else if (IsElement("wrapV")) { + } else if (IsElement("wrapV")) { out.mWrapV = ReadBoolFromTextContent(); TestClosing("wrapV"); - } - else if (IsElement("mirrorU")) { + } else if (IsElement("mirrorU")) { out.mMirrorU = ReadBoolFromTextContent(); TestClosing("mirrorU"); - } - else if (IsElement("mirrorV")) { + } else if (IsElement("mirrorV")) { out.mMirrorV = ReadBoolFromTextContent(); TestClosing("mirrorV"); - } - else if (IsElement("repeatU")) { + } else if (IsElement("repeatU")) { out.mTransform.mScaling.x = ReadFloatFromTextContent(); TestClosing("repeatU"); - } - else if (IsElement("repeatV")) { + } else if (IsElement("repeatV")) { out.mTransform.mScaling.y = ReadFloatFromTextContent(); TestClosing("repeatV"); - } - else if (IsElement("offsetU")) { + } else if (IsElement("offsetU")) { out.mTransform.mTranslation.x = ReadFloatFromTextContent(); TestClosing("offsetU"); - } - else if (IsElement("offsetV")) { + } else if (IsElement("offsetV")) { out.mTransform.mTranslation.y = ReadFloatFromTextContent(); TestClosing("offsetV"); - } - else if (IsElement("rotateUV")) { + } else if (IsElement("rotateUV")) { out.mTransform.mRotation = ReadFloatFromTextContent(); TestClosing("rotateUV"); - } - else if (IsElement("blend_mode")) { + } else if (IsElement("blend_mode")) { - const char* sz = GetTextContent(); + const char *sz = GetTextContent(); // http://www.feelingsoftware.com/content/view/55/72/lang,en/ // NONE, OVER, IN, OUT, ADD, SUBTRACT, MULTIPLY, DIFFERENCE, LIGHTEN, DARKEN, SATURATE, DESATURATE and ILLUMINATE if (0 == ASSIMP_strincmp(sz, "ADD", 3)) @@ -1825,8 +1552,7 @@ void ColladaParser::ReadSamplerProperties(Sampler& out) else if (IsElement("weighting")) { out.mWeighting = ReadFloatFromTextContent(); TestClosing("weighting"); - } - else if (IsElement("mix_with_previous_layer")) { + } else if (IsElement("mix_with_previous_layer")) { out.mMixWithPrevious = ReadFloatFromTextContent(); TestClosing("mix_with_previous_layer"); } @@ -1836,8 +1562,7 @@ void ColladaParser::ReadSamplerProperties(Sampler& out) out.mWeighting = ReadFloatFromTextContent(); TestClosing("amount"); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "technique") == 0) break; } @@ -1846,37 +1571,32 @@ void ColladaParser::ReadSamplerProperties(Sampler& out) // ------------------------------------------------------------------------------------------------ // Reads an effect entry containing a color or a texture defining that color -void ColladaParser::ReadEffectColor(aiColor4D& pColor, Sampler& pSampler) -{ +void ColladaParser::ReadEffectColor(aiColor4D &pColor, Sampler &pSampler) { if (mReader->isEmptyElement()) return; // Save current element name const std::string curElem = mReader->getNodeName(); - while (mReader->read()) - { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("color")) - { + if (IsElement("color")) { // text content contains 4 floats - const char* content = GetTextContent(); + const char *content = GetTextContent(); - content = fast_atoreal_move(content, (ai_real&)pColor.r); + content = fast_atoreal_move(content, (ai_real &)pColor.r); SkipSpacesAndLineEnd(&content); - content = fast_atoreal_move(content, (ai_real&)pColor.g); + content = fast_atoreal_move(content, (ai_real &)pColor.g); SkipSpacesAndLineEnd(&content); - content = fast_atoreal_move(content, (ai_real&)pColor.b); + content = fast_atoreal_move(content, (ai_real &)pColor.b); SkipSpacesAndLineEnd(&content); - content = fast_atoreal_move(content, (ai_real&)pColor.a); + content = fast_atoreal_move(content, (ai_real &)pColor.a); SkipSpacesAndLineEnd(&content); TestClosing("color"); - } - else if (IsElement("texture")) - { + } else if (IsElement("texture")) { // get name of source texture/sampler int attrTex = GetAttribute("texture"); pSampler.mName = mReader->getAttributeValue(attrTex); @@ -1890,28 +1610,22 @@ void ColladaParser::ReadEffectColor(aiColor4D& pColor, Sampler& pSampler) // as we've read texture, the color needs to be 1,1,1,1 pColor = aiColor4D(1.f, 1.f, 1.f, 1.f); - } - else if (IsElement("technique")) - { + } else if (IsElement("technique")) { const int _profile = GetAttribute("profile"); - const char* profile = mReader->getAttributeValue(_profile); + const char *profile = mReader->getAttributeValue(_profile); // Some extensions are quite useful ... ReadSamplerProperties processes // several extensions in MAYA, OKINO and MAX3D profiles. - if (!::strcmp(profile, "MAYA") || !::strcmp(profile, "MAX3D") || !::strcmp(profile, "OKINO")) - { + if (!::strcmp(profile, "MAYA") || !::strcmp(profile, "MAX3D") || !::strcmp(profile, "OKINO")) { // get more information on this sampler ReadSamplerProperties(pSampler); - } - else SkipElement(); - } - else if (!IsElement("extra")) - { + } else + SkipElement(); + } else if (!IsElement("extra")) { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (mReader->getNodeName() == curElem) break; } @@ -1920,27 +1634,21 @@ void ColladaParser::ReadEffectColor(aiColor4D& pColor, Sampler& pSampler) // ------------------------------------------------------------------------------------------------ // Reads an effect entry containing a float -void ColladaParser::ReadEffectFloat(ai_real& pFloat) -{ - while (mReader->read()) - { +void ColladaParser::ReadEffectFloat(ai_real &pFloat) { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("float")) - { + if (IsElement("float")) { // text content contains a single floats - const char* content = GetTextContent(); + const char *content = GetTextContent(); content = fast_atoreal_move(content, pFloat); SkipSpacesAndLineEnd(&content); TestClosing("float"); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { break; } } @@ -1948,55 +1656,45 @@ void ColladaParser::ReadEffectFloat(ai_real& pFloat) // ------------------------------------------------------------------------------------------------ // Reads an effect parameter specification of any kind -void ColladaParser::ReadEffectParam(Collada::EffectParam& pParam) -{ - while (mReader->read()) - { +void ColladaParser::ReadEffectParam(Collada::EffectParam &pParam) { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("surface")) - { + if (IsElement("surface")) { // image ID given inside tags TestOpening("init_from"); - const char* content = GetTextContent(); + const char *content = GetTextContent(); pParam.mType = Param_Surface; pParam.mReference = content; TestClosing("init_from"); // don't care for remaining stuff SkipElement("surface"); - } - else if (IsElement("sampler2D") && (FV_1_4_n == mFormat || FV_1_3_n == mFormat)) - { + } else if (IsElement("sampler2D") && (FV_1_4_n == mFormat || FV_1_3_n == mFormat)) { // surface ID is given inside tags TestOpening("source"); - const char* content = GetTextContent(); + const char *content = GetTextContent(); pParam.mType = Param_Sampler; pParam.mReference = content; TestClosing("source"); // don't care for remaining stuff SkipElement("sampler2D"); - } - else if (IsElement("sampler2D")) - { + } else if (IsElement("sampler2D")) { // surface ID is given inside tags TestOpening("instance_image"); int attrURL = GetAttribute("url"); - const char* url = mReader->getAttributeValue(attrURL); + const char *url = mReader->getAttributeValue(attrURL); if (url[0] != '#') ThrowException("Unsupported URL format in instance_image"); url++; pParam.mType = Param_Sampler; pParam.mReference = url; SkipElement("sampler2D"); - } - else - { + } else { // ignore unknown element SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { break; } } @@ -2004,46 +1702,41 @@ void ColladaParser::ReadEffectParam(Collada::EffectParam& pParam) // ------------------------------------------------------------------------------------------------ // Reads the geometry library contents -void ColladaParser::ReadGeometryLibrary() -{ +void ColladaParser::ReadGeometryLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("geometry")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("geometry")) { // read ID. Another entry which is "optional" by design but obligatory in reality int indexID = GetAttribute("id"); std::string id = mReader->getAttributeValue(indexID); - // TODO: (thom) support SIDs - // ai_assert( TestAttribute( "sid") == -1); + // create a mesh and store it in the library under its (resolved) ID + // Skip and warn if ID is not unique + if (mMeshLibrary.find(id) == mMeshLibrary.cend()) { + std::unique_ptr mesh(new Mesh(id)); - // create a mesh and store it in the library under its ID - Mesh* mesh = new Mesh; - mMeshLibrary[id] = mesh; + // read the mesh name if it exists + const int nameIndex = TestAttribute("name"); + if (nameIndex != -1) { + mesh->mName = mReader->getAttributeValue(nameIndex); + } - // read the mesh name if it exists - const int nameIndex = TestAttribute("name"); - if (nameIndex != -1) - { - mesh->mName = mReader->getAttributeValue(nameIndex); + // read on from there + ReadGeometry(*mesh); + // Read successfully, add to library + mMeshLibrary.insert({ id, mesh.release() }); + } else { + ASSIMP_LOG_ERROR_F("Collada: Skipped duplicate geometry id: \"", id, "\""); + SkipElement(); } - - // read on from there - ReadGeometry(mesh); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_geometries") != 0) ThrowException("Expected end of element."); @@ -2054,28 +1747,20 @@ void ColladaParser::ReadGeometryLibrary() // ------------------------------------------------------------------------------------------------ // Reads a geometry from the geometry library. -void ColladaParser::ReadGeometry(Collada::Mesh* pMesh) -{ +void ColladaParser::ReadGeometry(Collada::Mesh &pMesh) { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("mesh")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("mesh")) { // read on from there ReadMesh(pMesh); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "geometry") != 0) ThrowException("Expected end of element."); @@ -2086,50 +1771,32 @@ void ColladaParser::ReadGeometry(Collada::Mesh* pMesh) // ------------------------------------------------------------------------------------------------ // Reads a mesh from the geometry library -void ColladaParser::ReadMesh(Mesh* pMesh) -{ +void ColladaParser::ReadMesh(Mesh &pMesh) { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("source")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("source")) { // we have professionals dealing with this ReadSource(); - } - else if (IsElement("vertices")) - { + } else if (IsElement("vertices")) { // read per-vertex mesh data ReadVertexData(pMesh); - } - else if (IsElement("triangles") || IsElement("lines") || IsElement("linestrips") - || IsElement("polygons") || IsElement("polylist") || IsElement("trifans") || IsElement("tristrips")) - { + } else if (IsElement("triangles") || IsElement("lines") || IsElement("linestrips") || IsElement("polygons") || IsElement("polylist") || IsElement("trifans") || IsElement("tristrips")) { // read per-index mesh data and faces setup ReadIndexData(pMesh); - } - else - { + } else { // ignore the restf SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { - if (strcmp(mReader->getNodeName(), "technique_common") == 0) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + if (strcmp(mReader->getNodeName(), "technique_common") == 0) { // end of another meaningless element - read over it - } - else if (strcmp(mReader->getNodeName(), "mesh") == 0) - { + } else if (strcmp(mReader->getNodeName(), "mesh") == 0) { // end of element - we're done here break; - } - else - { + } else { // everything else should be punished ThrowException("Expected end of element."); } @@ -2139,46 +1806,29 @@ void ColladaParser::ReadMesh(Mesh* pMesh) // ------------------------------------------------------------------------------------------------ // Reads a source element -void ColladaParser::ReadSource() -{ +void ColladaParser::ReadSource() { int indexID = GetAttribute("id"); std::string sourceID = mReader->getAttributeValue(indexID); - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("float_array") || IsElement("IDREF_array") || IsElement("Name_array")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("float_array") || IsElement("IDREF_array") || IsElement("Name_array")) { ReadDataArray(); - } - else if (IsElement("technique_common")) - { + } else if (IsElement("technique_common")) { // I don't care for your profiles - } - else if (IsElement("accessor")) - { + } else if (IsElement("accessor")) { ReadAccessor(sourceID); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { - if (strcmp(mReader->getNodeName(), "source") == 0) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + if (strcmp(mReader->getNodeName(), "source") == 0) { // end of - we're done break; - } - else if (strcmp(mReader->getNodeName(), "technique_common") == 0) - { + } else if (strcmp(mReader->getNodeName(), "technique_common") == 0) { // end of another meaningless element - read over it - } - else - { + } else { // everything else should be punished ThrowException("Expected end of element."); } @@ -2188,8 +1838,7 @@ void ColladaParser::ReadSource() // ------------------------------------------------------------------------------------------------ // Reads a data array holding a number of floats, and stores it in the global library -void ColladaParser::ReadDataArray() -{ +void ColladaParser::ReadDataArray() { std::string elmName = mReader->getNodeName(); bool isStringArray = (elmName == "IDREF_array" || elmName == "Name_array"); bool isEmptyElement = mReader->isEmptyElement(); @@ -2199,23 +1848,20 @@ void ColladaParser::ReadDataArray() std::string id = mReader->getAttributeValue(indexID); int indexCount = GetAttribute("count"); unsigned int count = (unsigned int)mReader->getAttributeValueAsInt(indexCount); - const char* content = TestTextContent(); + const char *content = TestTextContent(); // read values and store inside an array in the data library mDataLibrary[id] = Data(); - Data& data = mDataLibrary[id]; + Data &data = mDataLibrary[id]; data.mIsStringArray = isStringArray; // some exporters write empty data arrays, but we need to conserve them anyways because others might reference them - if (content) - { - if (isStringArray) - { + if (content) { + if (isStringArray) { data.mStrings.reserve(count); std::string s; - for (unsigned int a = 0; a < count; a++) - { + for (unsigned int a = 0; a < count; a++) { if (*content == 0) ThrowException("Expected more values while reading IDREF_array contents."); @@ -2226,13 +1872,10 @@ void ColladaParser::ReadDataArray() SkipSpacesAndLineEnd(&content); } - } - else - { + } else { data.mValues.reserve(count); - for (unsigned int a = 0; a < count; a++) - { + for (unsigned int a = 0; a < count; a++) { if (*content == 0) ThrowException("Expected more values while reading float_array contents."); @@ -2253,11 +1896,10 @@ void ColladaParser::ReadDataArray() // ------------------------------------------------------------------------------------------------ // Reads an accessor and stores it in the global library -void ColladaParser::ReadAccessor(const std::string& pID) -{ +void ColladaParser::ReadAccessor(const std::string &pID) { // read accessor attributes int attrSource = GetAttribute("source"); - const char* source = mReader->getAttributeValue(attrSource); + const char *source = mReader->getAttributeValue(attrSource); if (source[0] != '#') ThrowException(format() << "Unknown reference format in url \"" << source << "\" in source attribute of element."); int attrCount = GetAttribute("count"); @@ -2273,7 +1915,7 @@ void ColladaParser::ReadAccessor(const std::string& pID) // store in the library under the given ID mAccessorLibrary[pID] = Accessor(); - Accessor& acc = mAccessorLibrary[pID]; + Accessor &acc = mAccessorLibrary[pID]; acc.mCount = count; acc.mOffset = offset; acc.mStride = stride; @@ -2281,50 +1923,57 @@ void ColladaParser::ReadAccessor(const std::string& pID) acc.mSize = 0; // gets incremented with every param // and read the components - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("param")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("param")) { // read data param int attrName = TestAttribute("name"); std::string name; - if (attrName > -1) - { + if (attrName > -1) { name = mReader->getAttributeValue(attrName); // analyse for common type components and store it's sub-offset in the corresponding field /* Cartesian coordinates */ - if (name == "X") acc.mSubOffset[0] = acc.mParams.size(); - else if (name == "Y") acc.mSubOffset[1] = acc.mParams.size(); - else if (name == "Z") acc.mSubOffset[2] = acc.mParams.size(); + if (name == "X") + acc.mSubOffset[0] = acc.mParams.size(); + else if (name == "Y") + acc.mSubOffset[1] = acc.mParams.size(); + else if (name == "Z") + acc.mSubOffset[2] = acc.mParams.size(); /* RGBA colors */ - else if (name == "R") acc.mSubOffset[0] = acc.mParams.size(); - else if (name == "G") acc.mSubOffset[1] = acc.mParams.size(); - else if (name == "B") acc.mSubOffset[2] = acc.mParams.size(); - else if (name == "A") acc.mSubOffset[3] = acc.mParams.size(); + else if (name == "R") + acc.mSubOffset[0] = acc.mParams.size(); + else if (name == "G") + acc.mSubOffset[1] = acc.mParams.size(); + else if (name == "B") + acc.mSubOffset[2] = acc.mParams.size(); + else if (name == "A") + acc.mSubOffset[3] = acc.mParams.size(); /* UVWQ (STPQ) texture coordinates */ - else if (name == "S") acc.mSubOffset[0] = acc.mParams.size(); - else if (name == "T") acc.mSubOffset[1] = acc.mParams.size(); - else if (name == "P") acc.mSubOffset[2] = acc.mParams.size(); + else if (name == "S") + acc.mSubOffset[0] = acc.mParams.size(); + else if (name == "T") + acc.mSubOffset[1] = acc.mParams.size(); + else if (name == "P") + acc.mSubOffset[2] = acc.mParams.size(); // else if( name == "Q") acc.mSubOffset[3] = acc.mParams.size(); - /* 4D uv coordinates are not supported in Assimp */ + /* 4D uv coordinates are not supported in Assimp */ - /* Generic extra data, interpreted as UV data, too*/ - else if (name == "U") acc.mSubOffset[0] = acc.mParams.size(); - else if (name == "V") acc.mSubOffset[1] = acc.mParams.size(); + /* Generic extra data, interpreted as UV data, too*/ + else if (name == "U") + acc.mSubOffset[0] = acc.mParams.size(); + else if (name == "V") + acc.mSubOffset[1] = acc.mParams.size(); //else // DefaultLogger::get()->warn( format() << "Unknown accessor parameter \"" << name << "\". Ignoring data channel." ); } // read data type int attrType = TestAttribute("type"); - if (attrType > -1) - { + if (attrType > -1) { // for the moment we only distinguish between a 4x4 matrix and anything else. // TODO: (thom) I don't have a spec here at work. Check if there are other multi-value types // which should be tested for here. @@ -2339,14 +1988,10 @@ void ColladaParser::ReadAccessor(const std::string& pID) // skip remaining stuff of this element, if any SkipElement(); - } - else - { + } else { ThrowException(format() << "Unexpected sub element <" << mReader->getNodeName() << "> in tag "); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "accessor") != 0) ThrowException("Expected end of element."); break; @@ -2356,28 +2001,20 @@ void ColladaParser::ReadAccessor(const std::string& pID) // ------------------------------------------------------------------------------------------------ // Reads input declarations of per-vertex mesh data into the given mesh -void ColladaParser::ReadVertexData(Mesh* pMesh) -{ +void ColladaParser::ReadVertexData(Mesh &pMesh) { // extract the ID of the element. Not that we care, but to catch strange referencing schemes we should warn about int attrID = GetAttribute("id"); - pMesh->mVertexID = mReader->getAttributeValue(attrID); + pMesh.mVertexID = mReader->getAttributeValue(attrID); // a number of elements - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("input")) - { - ReadInputChannel(pMesh->mPerVertexData); - } - else - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("input")) { + ReadInputChannel(pMesh.mPerVertexData); + } else { ThrowException(format() << "Unexpected sub element <" << mReader->getNodeName() << "> in tag "); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "vertices") != 0) ThrowException("Expected end of element."); @@ -2388,8 +2025,7 @@ void ColladaParser::ReadVertexData(Mesh* pMesh) // ------------------------------------------------------------------------------------------------ // Reads input declarations of per-index mesh data into the given mesh -void ColladaParser::ReadIndexData(Mesh* pMesh) -{ +void ColladaParser::ReadIndexData(Mesh &pMesh) { std::vector vcount; std::vector perIndexData; @@ -2427,25 +2063,18 @@ void ColladaParser::ReadIndexData(Mesh* pMesh) ai_assert(primType != Prim_Invalid); // also a number of elements, but in addition a

primitive collection and probably index counts for all primitives - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("input")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("input")) { ReadInputChannel(perIndexData); - } - else if (IsElement("vcount")) - { - if (!mReader->isEmptyElement()) - { - if (numPrimitives) // It is possible to define a mesh without any primitives + } else if (IsElement("vcount")) { + if (!mReader->isEmptyElement()) { + if (numPrimitives) // It is possible to define a mesh without any primitives { // case - specifies the number of indices for each polygon - const char* content = GetTextContent(); + const char *content = GetTextContent(); vcount.reserve(numPrimitives); - for (unsigned int a = 0; a < numPrimitives; a++) - { + for (unsigned int a = 0; a < numPrimitives; a++) { if (*content == 0) ThrowException("Expected more values while reading contents."); // read a number @@ -2457,28 +2086,19 @@ void ColladaParser::ReadIndexData(Mesh* pMesh) TestClosing("vcount"); } - } - else if (IsElement("p")) - { - if (!mReader->isEmptyElement()) - { + } else if (IsElement("p")) { + if (!mReader->isEmptyElement()) { // now here the actual fun starts - these are the indices to construct the mesh data from actualPrimitives += ReadPrimitives(pMesh, perIndexData, numPrimitives, vcount, primType); } - } - else if (IsElement("extra")) - { + } else if (IsElement("extra")) { SkipElement("extra"); - } - else if (IsElement("ph")) { + } else if (IsElement("ph")) { SkipElement("ph"); - } - else { + } else { ThrowException(format() << "Unexpected sub element <" << mReader->getNodeName() << "> in tag <" << elementName << ">"); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (mReader->getNodeName() != elementName) ThrowException(format() << "Expected end of <" << elementName << "> element."); @@ -2488,20 +2108,19 @@ void ColladaParser::ReadIndexData(Mesh* pMesh) #ifdef ASSIMP_BUILD_DEBUG if (primType != Prim_TriFans && primType != Prim_TriStrips && primType != Prim_LineStrip && - primType != Prim_Lines) { // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'. + primType != Prim_Lines) { // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'. ai_assert(actualPrimitives == numPrimitives); } #endif // only when we're done reading all

tags (and thus know the final vertex count) can we commit the submesh subgroup.mNumFaces = actualPrimitives; - pMesh->mSubMeshes.push_back(subgroup); + pMesh.mSubMeshes.push_back(subgroup); } // ------------------------------------------------------------------------------------------------ // Reads a single input channel element and stores it in the given array, if valid -void ColladaParser::ReadInputChannel(std::vector& poChannels) -{ +void ColladaParser::ReadInputChannel(std::vector &poChannels) { InputChannel channel; // read semantic @@ -2511,7 +2130,7 @@ void ColladaParser::ReadInputChannel(std::vector& poChannels) // read source int attrSource = GetAttribute("source"); - const char* source = mReader->getAttributeValue(attrSource); + const char *source = mReader->getAttributeValue(attrSource); if (source[0] != '#') ThrowException(format() << "Unknown reference format in url \"" << source << "\" in source attribute of element."); channel.mAccessor = source + 1; // skipping the leading #, hopefully the remaining text is the accessor ID only @@ -2543,15 +2162,13 @@ void ColladaParser::ReadInputChannel(std::vector& poChannels) // ------------------------------------------------------------------------------------------------ // Reads a

primitive index list and assembles the mesh data into the given mesh -size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPerIndexChannels, - size_t pNumPrimitives, const std::vector& pVCount, PrimitiveType pPrimType) -{ +size_t ColladaParser::ReadPrimitives(Mesh &pMesh, std::vector &pPerIndexChannels, + size_t pNumPrimitives, const std::vector &pVCount, PrimitiveType pPrimType) { // determine number of indices coming per vertex // find the offset index for all per-vertex channels size_t numOffsets = 1; size_t perVertexOffset = SIZE_MAX; // invalid value - for (const InputChannel& channel : pPerIndexChannels) - { + for (const InputChannel &channel : pPerIndexChannels) { numOffsets = std::max(numOffsets, channel.mOffset + 1); if (channel.mType == IT_Vertex) perVertexOffset = channel.mOffset; @@ -2559,10 +2176,8 @@ size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPe // determine the expected number of indices size_t expectedPointCount = 0; - switch (pPrimType) - { - case Prim_Polylist: - { + switch (pPrimType) { + case Prim_Polylist: { for (size_t i : pVCount) expectedPointCount += i; break; @@ -2585,9 +2200,8 @@ size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPe if (pNumPrimitives > 0) // It is possible to not contain any indices { - const char* content = GetTextContent(); - while (*content != 0) - { + const char *content = GetTextContent(); + while (*content != 0) { // read a value. // Hack: (thom) Some exporters put negative indices sometimes. We just try to carry on anyways. int value = std::max(0, strtol10(content, &content)); @@ -2603,40 +2217,35 @@ size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPe // HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines' ReportWarning("Expected different index count in

element, %zu instead of %zu.", indices.size(), expectedPointCount * numOffsets); pNumPrimitives = (indices.size() / numOffsets) / 2; - } - else + } else ThrowException("Expected different index count in

element."); - } - else if (expectedPointCount == 0 && (indices.size() % numOffsets) != 0) + } else if (expectedPointCount == 0 && (indices.size() % numOffsets) != 0) ThrowException("Expected different index count in

element."); // find the data for all sources - for (std::vector::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it) - { - InputChannel& input = *it; + for (std::vector::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it) { + InputChannel &input = *it; if (input.mResolved) continue; // find accessor input.mResolved = &ResolveLibraryReference(mAccessorLibrary, input.mAccessor); // resolve accessor's data pointer as well, if necessary - const Accessor* acc = input.mResolved; + const Accessor *acc = input.mResolved; if (!acc->mData) acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource); } // and the same for the per-index channels - for (std::vector::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) - { - InputChannel& input = *it; + for (std::vector::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) { + InputChannel &input = *it; if (input.mResolved) continue; // ignore vertex pointer, it doesn't refer to an accessor - if (input.mType == IT_Vertex) - { + if (input.mType == IT_Vertex) { // warn if the vertex channel does not refer to the element in the same mesh - if (input.mAccessor != pMesh->mVertexID) + if (input.mAccessor != pMesh.mVertexID) ThrowException("Unsupported vertex referencing scheme."); continue; } @@ -2644,7 +2253,7 @@ size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPe // find accessor input.mResolved = &ResolveLibraryReference(mAccessorLibrary, input.mAccessor); // resolve accessor's data pointer as well, if necessary - const Accessor* acc = input.mResolved; + const Accessor *acc = input.mResolved; if (!acc->mData) acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource); } @@ -2663,16 +2272,14 @@ size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPe numPrimitives = numberOfVertices - 1; } - pMesh->mFaceSize.reserve(numPrimitives); - pMesh->mFacePosIndices.reserve(indices.size() / numOffsets); + pMesh.mFaceSize.reserve(numPrimitives); + pMesh.mFacePosIndices.reserve(indices.size() / numOffsets); size_t polylistStartVertex = 0; - for (size_t currentPrimitive = 0; currentPrimitive < numPrimitives; currentPrimitive++) - { + for (size_t currentPrimitive = 0; currentPrimitive < numPrimitives; currentPrimitive++) { // determine number of points for this primitive size_t numPoints = 0; - switch (pPrimType) - { + switch (pPrimType) { case Prim_Lines: numPoints = 2; for (size_t currentVertex = 0; currentVertex < numPoints; currentVertex++) @@ -2711,7 +2318,7 @@ size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPe } // store the face size to later reconstruct the face from - pMesh->mFaceSize.push_back(numPoints); + pMesh.mFaceSize.push_back(numPoints); } // if I ever get my hands on that guy who invented this steaming pile of indirection... @@ -2719,10 +2326,10 @@ size_t ColladaParser::ReadPrimitives(Mesh* pMesh, std::vector& pPe return numPrimitives; } -///@note This function willn't work correctly if both PerIndex and PerVertex channels have same channels. +///@note This function won't work correctly if both PerIndex and PerVertex channels have same channels. ///For example if TEXCOORD present in both and tags this function will create wrong uv coordinates. ///It's not clear from COLLADA documentation is this allowed or not. For now only exporter fixed to avoid such behavior -void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, Mesh* pMesh, std::vector& pPerIndexChannels, size_t currentPrimitive, const std::vector& indices) { +void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, Mesh &pMesh, std::vector &pPerIndexChannels, size_t currentPrimitive, const std::vector &indices) { // calculate the base offset of the vertex whose attributes we ant to copy size_t baseOffset = currentPrimitive * numOffsets * numPoints + currentVertex * numOffsets; @@ -2730,24 +2337,23 @@ void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t n ai_assert((baseOffset + numOffsets - 1) < indices.size()); // extract per-vertex channels using the global per-vertex offset - for (std::vector::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it) + for (std::vector::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it) ExtractDataObjectFromChannel(*it, indices[baseOffset + perVertexOffset], pMesh); // and extract per-index channels using there specified offset for (std::vector::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) ExtractDataObjectFromChannel(*it, indices[baseOffset + it->mOffset], pMesh); // store the vertex-data index for later assignment of bone vertex weights - pMesh->mFacePosIndices.push_back(indices[baseOffset + perVertexOffset]); + pMesh.mFacePosIndices.push_back(indices[baseOffset + perVertexOffset]); } -void ColladaParser::ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Mesh* pMesh, std::vector& pPerIndexChannels, size_t currentPrimitive, const std::vector& indices) { +void ColladaParser::ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Mesh &pMesh, std::vector &pPerIndexChannels, size_t currentPrimitive, const std::vector &indices) { if (currentPrimitive % 2 != 0) { //odd tristrip triangles need their indices mangled, to preserve winding direction CopyVertex(1, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices); CopyVertex(0, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices); CopyVertex(2, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices); - } - else {//for non tristrips or even tristrip triangles + } else { //for non tristrips or even tristrip triangles CopyVertex(0, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices); CopyVertex(1, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices); CopyVertex(2, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices); @@ -2756,18 +2362,17 @@ void ColladaParser::ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, // ------------------------------------------------------------------------------------------------ // Extracts a single object from an input channel and stores it in the appropriate mesh data array -void ColladaParser::ExtractDataObjectFromChannel(const InputChannel& pInput, size_t pLocalIndex, Mesh* pMesh) -{ +void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, size_t pLocalIndex, Mesh &pMesh) { // ignore vertex referrer - we handle them that separate if (pInput.mType == IT_Vertex) return; - const Accessor& acc = *pInput.mResolved; + const Accessor &acc = *pInput.mResolved; if (pLocalIndex >= acc.mCount) ThrowException(format() << "Invalid data index (" << pLocalIndex << "/" << acc.mCount << ") in primitive specification"); // get a pointer to the start of the data object referred to by the accessor and the local index - const ai_real* dataObject = &(acc.mData->mValues[0]) + acc.mOffset + pLocalIndex * acc.mStride; + const ai_real *dataObject = &(acc.mData->mValues[0]) + acc.mOffset + pLocalIndex * acc.mStride; // assemble according to the accessors component sub-offset list. We don't care, yet, // what kind of object exactly we're extracting here @@ -2776,83 +2381,75 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel& pInput, siz obj[c] = dataObject[acc.mSubOffset[c]]; // now we reinterpret it according to the type we're reading here - switch (pInput.mType) - { + switch (pInput.mType) { case IT_Position: // ignore all position streams except 0 - there can be only one position if (pInput.mIndex == 0) - pMesh->mPositions.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mPositions.push_back(aiVector3D(obj[0], obj[1], obj[2])); else ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported"); break; case IT_Normal: // pad to current vertex count if necessary - if (pMesh->mNormals.size() < pMesh->mPositions.size() - 1) - pMesh->mNormals.insert(pMesh->mNormals.end(), pMesh->mPositions.size() - pMesh->mNormals.size() - 1, aiVector3D(0, 1, 0)); + if (pMesh.mNormals.size() < pMesh.mPositions.size() - 1) + pMesh.mNormals.insert(pMesh.mNormals.end(), pMesh.mPositions.size() - pMesh.mNormals.size() - 1, aiVector3D(0, 1, 0)); // ignore all normal streams except 0 - there can be only one normal if (pInput.mIndex == 0) - pMesh->mNormals.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mNormals.push_back(aiVector3D(obj[0], obj[1], obj[2])); else ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported"); break; case IT_Tangent: // pad to current vertex count if necessary - if (pMesh->mTangents.size() < pMesh->mPositions.size() - 1) - pMesh->mTangents.insert(pMesh->mTangents.end(), pMesh->mPositions.size() - pMesh->mTangents.size() - 1, aiVector3D(1, 0, 0)); + if (pMesh.mTangents.size() < pMesh.mPositions.size() - 1) + pMesh.mTangents.insert(pMesh.mTangents.end(), pMesh.mPositions.size() - pMesh.mTangents.size() - 1, aiVector3D(1, 0, 0)); // ignore all tangent streams except 0 - there can be only one tangent if (pInput.mIndex == 0) - pMesh->mTangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mTangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); else ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported"); break; case IT_Bitangent: // pad to current vertex count if necessary - if (pMesh->mBitangents.size() < pMesh->mPositions.size() - 1) - pMesh->mBitangents.insert(pMesh->mBitangents.end(), pMesh->mPositions.size() - pMesh->mBitangents.size() - 1, aiVector3D(0, 0, 1)); + if (pMesh.mBitangents.size() < pMesh.mPositions.size() - 1) + pMesh.mBitangents.insert(pMesh.mBitangents.end(), pMesh.mPositions.size() - pMesh.mBitangents.size() - 1, aiVector3D(0, 0, 1)); // ignore all bitangent streams except 0 - there can be only one bitangent if (pInput.mIndex == 0) - pMesh->mBitangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mBitangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); else ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported"); break; case IT_Texcoord: // up to 4 texture coord sets are fine, ignore the others - if (pInput.mIndex < AI_MAX_NUMBER_OF_TEXTURECOORDS) - { + if (pInput.mIndex < AI_MAX_NUMBER_OF_TEXTURECOORDS) { // pad to current vertex count if necessary - if (pMesh->mTexCoords[pInput.mIndex].size() < pMesh->mPositions.size() - 1) - pMesh->mTexCoords[pInput.mIndex].insert(pMesh->mTexCoords[pInput.mIndex].end(), - pMesh->mPositions.size() - pMesh->mTexCoords[pInput.mIndex].size() - 1, aiVector3D(0, 0, 0)); + if (pMesh.mTexCoords[pInput.mIndex].size() < pMesh.mPositions.size() - 1) + pMesh.mTexCoords[pInput.mIndex].insert(pMesh.mTexCoords[pInput.mIndex].end(), + pMesh.mPositions.size() - pMesh.mTexCoords[pInput.mIndex].size() - 1, aiVector3D(0, 0, 0)); - pMesh->mTexCoords[pInput.mIndex].push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mTexCoords[pInput.mIndex].push_back(aiVector3D(obj[0], obj[1], obj[2])); if (0 != acc.mSubOffset[2] || 0 != acc.mSubOffset[3]) /* hack ... consider cleaner solution */ - pMesh->mNumUVComponents[pInput.mIndex] = 3; - } - else - { + pMesh.mNumUVComponents[pInput.mIndex] = 3; + } else { ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping."); } break; case IT_Color: // up to 4 color sets are fine, ignore the others - if (pInput.mIndex < AI_MAX_NUMBER_OF_COLOR_SETS) - { + if (pInput.mIndex < AI_MAX_NUMBER_OF_COLOR_SETS) { // pad to current vertex count if necessary - if (pMesh->mColors[pInput.mIndex].size() < pMesh->mPositions.size() - 1) - pMesh->mColors[pInput.mIndex].insert(pMesh->mColors[pInput.mIndex].end(), - pMesh->mPositions.size() - pMesh->mColors[pInput.mIndex].size() - 1, aiColor4D(0, 0, 0, 1)); + if (pMesh.mColors[pInput.mIndex].size() < pMesh.mPositions.size() - 1) + pMesh.mColors[pInput.mIndex].insert(pMesh.mColors[pInput.mIndex].end(), + pMesh.mPositions.size() - pMesh.mColors[pInput.mIndex].size() - 1, aiColor4D(0, 0, 0, 1)); aiColor4D result(0, 0, 0, 1); - for (size_t i = 0; i < pInput.mResolved->mSize; ++i) - { + for (size_t i = 0; i < pInput.mResolved->mSize; ++i) { result[static_cast(i)] = obj[pInput.mResolved->mSubOffset[i]]; } - pMesh->mColors[pInput.mIndex].push_back(result); - } - else - { + pMesh.mColors[pInput.mIndex].push_back(result); + } else { ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping."); } @@ -2865,44 +2462,36 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel& pInput, siz // ------------------------------------------------------------------------------------------------ // Reads the library of node hierarchies and scene parts -void ColladaParser::ReadSceneLibrary() -{ +void ColladaParser::ReadSceneLibrary() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { // a visual scene - generate root node under its ID and let ReadNode() do the recursive work - if (IsElement("visual_scene")) - { + if (IsElement("visual_scene")) { // read ID. Is optional according to the spec, but how on earth should a scene_instance refer to it then? int indexID = GetAttribute("id"); - const char* attrID = mReader->getAttributeValue(indexID); + const char *attrID = mReader->getAttributeValue(indexID); // read name if given. int indexName = TestAttribute("name"); - const char* attrName = "unnamed"; + const char *attrName = "Scene"; if (indexName > -1) attrName = mReader->getAttributeValue(indexName); // create a node and store it in the library under its ID - Node* node = new Node; + Node *node = new Node; node->mID = attrID; node->mName = attrName; mNodeLibrary[node->mID] = node; ReadSceneNode(node); - } - else - { + } else { // ignore the rest SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "library_visual_scenes") == 0) //ThrowException( "Expected end of \"library_visual_scenes\" element."); @@ -2913,19 +2502,15 @@ void ColladaParser::ReadSceneLibrary() // ------------------------------------------------------------------------------------------------ // Reads a scene node's contents including children and stores it in the given node -void ColladaParser::ReadSceneNode(Node* pNode) -{ +void ColladaParser::ReadSceneNode(Node *pNode) { // quit immediately on elements if (mReader->isEmptyElement()) return; - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("node")) - { - Node* child = new Node; + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("node")) { + Node *child = new Node; int attrID = TestAttribute("id"); if (attrID > -1) child->mID = mReader->getAttributeValue(attrID); @@ -2937,16 +2522,11 @@ void ColladaParser::ReadSceneNode(Node* pNode) if (attrName > -1) child->mName = mReader->getAttributeValue(attrName); - // TODO: (thom) support SIDs - // ai_assert( TestAttribute( "sid") == -1); - if (pNode) - { + if (pNode) { pNode->mChildren.push_back(child); child->mParent = pNode; - } - else - { + } else { // no parent node given, probably called from element. // create new node in node library mNodeLibrary[child->mID] = child; @@ -2972,82 +2552,65 @@ void ColladaParser::ReadSceneNode(Node* pNode) ReadNodeTransformation(pNode, TF_SKEW); else if (IsElement("translate")) ReadNodeTransformation(pNode, TF_TRANSLATE); - else if (IsElement("render") && pNode->mParent == NULL && 0 == pNode->mPrimaryCamera.length()) - { + else if (IsElement("render") && pNode->mParent == nullptr && 0 == pNode->mPrimaryCamera.length()) { // ... scene evaluation or, in other words, postprocessing pipeline, // or, again in other words, a turing-complete description how to // render a Collada scene. The only thing that is interesting for // us is the primary camera. int attrId = TestAttribute("camera_node"); - if (-1 != attrId) - { - const char* s = mReader->getAttributeValue(attrId); + if (-1 != attrId) { + const char *s = mReader->getAttributeValue(attrId); if (s[0] != '#') ASSIMP_LOG_ERROR("Collada: Unresolved reference format of camera"); else pNode->mPrimaryCamera = s + 1; } - } - else if (IsElement("instance_node")) - { + } else if (IsElement("instance_node")) { // find the node in the library int attrID = TestAttribute("url"); - if (attrID != -1) - { - const char* s = mReader->getAttributeValue(attrID); + if (attrID != -1) { + const char *s = mReader->getAttributeValue(attrID); if (s[0] != '#') ASSIMP_LOG_ERROR("Collada: Unresolved reference format of node"); - else - { + else { pNode->mNodeInstances.push_back(NodeInstance()); pNode->mNodeInstances.back().mNode = s + 1; } } - } - else if (IsElement("instance_geometry") || IsElement("instance_controller")) - { + } else if (IsElement("instance_geometry") || IsElement("instance_controller")) { // Reference to a mesh or controller, with possible material associations ReadNodeGeometry(pNode); - } - else if (IsElement("instance_light")) - { + } else if (IsElement("instance_light")) { // Reference to a light, name given in 'url' attribute int attrID = TestAttribute("url"); if (-1 == attrID) ASSIMP_LOG_WARN("Collada: Expected url attribute in element"); - else - { - const char* url = mReader->getAttributeValue(attrID); + else { + const char *url = mReader->getAttributeValue(attrID); if (url[0] != '#') ThrowException("Unknown reference format in element"); pNode->mLights.push_back(LightInstance()); pNode->mLights.back().mLight = url + 1; } - } - else if (IsElement("instance_camera")) - { + } else if (IsElement("instance_camera")) { // Reference to a camera, name given in 'url' attribute int attrID = TestAttribute("url"); if (-1 == attrID) ASSIMP_LOG_WARN("Collada: Expected url attribute in element"); - else - { - const char* url = mReader->getAttributeValue(attrID); + else { + const char *url = mReader->getAttributeValue(attrID); if (url[0] != '#') ThrowException("Unknown reference format in element"); pNode->mCameras.push_back(CameraInstance()); pNode->mCameras.back().mCamera = url + 1; } - } - else - { + } else { // skip everything else for the moment SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { break; } } @@ -3055,8 +2618,7 @@ void ColladaParser::ReadSceneNode(Node* pNode) // ------------------------------------------------------------------------------------------------ // Reads a node transformation entry of the given type and adds it to the given node's transformation list. -void ColladaParser::ReadNodeTransformation(Node* pNode, TransformType pType) -{ +void ColladaParser::ReadNodeTransformation(Node *pNode, TransformType pType) { if (mReader->isEmptyElement()) return; @@ -3072,11 +2634,10 @@ void ColladaParser::ReadNodeTransformation(Node* pNode, TransformType pType) // how many parameters to read per transformation type static const unsigned int sNumParameters[] = { 9, 4, 3, 3, 7, 16 }; - const char* content = GetTextContent(); + const char *content = GetTextContent(); // read as many parameters and store in the transformation - for (unsigned int a = 0; a < sNumParameters[pType]; a++) - { + for (unsigned int a = 0; a < sNumParameters[pType]; a++) { // read a number content = fast_atoreal_move(content, tf.f[a]); // skip whitespace after it @@ -3092,13 +2653,10 @@ void ColladaParser::ReadNodeTransformation(Node* pNode, TransformType pType) // ------------------------------------------------------------------------------------------------ // Processes bind_vertex_input and bind elements -void ColladaParser::ReadMaterialVertexInputBinding(Collada::SemanticMappingTable& tbl) -{ - while (mReader->read()) - { +void ColladaParser::ReadMaterialVertexInputBinding(Collada::SemanticMappingTable &tbl) { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("bind_vertex_input")) - { + if (IsElement("bind_vertex_input")) { Collada::InputSemanticMapEntry vn; // effect semantic @@ -3115,20 +2673,17 @@ void ColladaParser::ReadMaterialVertexInputBinding(Collada::SemanticMappingTable vn.mSet = mReader->getAttributeValueAsInt(n); tbl.mMap[s] = vn; - } - else if (IsElement("bind")) { + } else if (IsElement("bind")) { ASSIMP_LOG_WARN("Collada: Found unsupported element"); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { if (strcmp(mReader->getNodeName(), "instance_material") == 0) break; } } } -void ColladaParser::ReadEmbeddedTextures(ZipArchiveIOSystem& zip_archive) -{ +void ColladaParser::ReadEmbeddedTextures(ZipArchiveIOSystem &zip_archive) { // Attempt to load any undefined Collada::Image in ImageLibrary for (ImageLibrary::iterator it = mImageLibrary.begin(); it != mImageLibrary.end(); ++it) { Collada::Image &image = (*it).second; @@ -3149,31 +2704,26 @@ void ColladaParser::ReadEmbeddedTextures(ZipArchiveIOSystem& zip_archive) // ------------------------------------------------------------------------------------------------ // Reads a mesh reference in a node and adds it to the node's mesh list -void ColladaParser::ReadNodeGeometry(Node* pNode) -{ +void ColladaParser::ReadNodeGeometry(Node *pNode) { // referred mesh is given as an attribute of the element int attrUrl = GetAttribute("url"); - const char* url = mReader->getAttributeValue(attrUrl); + const char *url = mReader->getAttributeValue(attrUrl); if (url[0] != '#') ThrowException("Unknown reference format"); Collada::MeshInstance instance; instance.mMeshOrController = url + 1; // skipping the leading # - if (!mReader->isEmptyElement()) - { + if (!mReader->isEmptyElement()) { // read material associations. Ignore additional elements in between - while (mReader->read()) - { - if (mReader->getNodeType() == irr::io::EXN_ELEMENT) - { - if (IsElement("instance_material")) - { + while (mReader->read()) { + if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { + if (IsElement("instance_material")) { // read ID of the geometry subgroup and the target material int attrGroup = GetAttribute("symbol"); std::string group = mReader->getAttributeValue(attrGroup); int attrMaterial = GetAttribute("target"); - const char* urlMat = mReader->getAttributeValue(attrMaterial); + const char *urlMat = mReader->getAttributeValue(attrMaterial); Collada::SemanticMappingTable s; if (urlMat[0] == '#') urlMat++; @@ -3187,11 +2737,8 @@ void ColladaParser::ReadNodeGeometry(Node* pNode) // store the association instance.mMaterials[group] = s; } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) - { - if (strcmp(mReader->getNodeName(), "instance_geometry") == 0 - || strcmp(mReader->getNodeName(), "instance_controller") == 0) + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + if (strcmp(mReader->getNodeName(), "instance_geometry") == 0 || strcmp(mReader->getNodeName(), "instance_controller") == 0) break; } } @@ -3203,23 +2750,20 @@ void ColladaParser::ReadNodeGeometry(Node* pNode) // ------------------------------------------------------------------------------------------------ // Reads the collada scene -void ColladaParser::ReadScene() -{ +void ColladaParser::ReadScene() { if (mReader->isEmptyElement()) return; - while (mReader->read()) - { + while (mReader->read()) { if (mReader->getNodeType() == irr::io::EXN_ELEMENT) { - if (IsElement("instance_visual_scene")) - { + if (IsElement("instance_visual_scene")) { // should be the first and only occurrence if (mRootNode) ThrowException("Invalid scene containing multiple root nodes in element"); // read the url of the scene to instance. Should be of format "#some_name" int urlIndex = GetAttribute("url"); - const char* url = mReader->getAttributeValue(urlIndex); + const char *url = mReader->getAttributeValue(urlIndex); if (url[0] != '#') ThrowException("Unknown reference format in element"); @@ -3228,12 +2772,10 @@ void ColladaParser::ReadScene() if (sit == mNodeLibrary.end()) ThrowException("Unable to resolve visual_scene reference \"" + std::string(url) + "\" in element."); mRootNode = sit->second; - } - else { + } else { SkipElement(); } - } - else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { + } else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { break; } } @@ -3241,11 +2783,11 @@ void ColladaParser::ReadScene() // ------------------------------------------------------------------------------------------------ // Aborts the file reading with an exception -AI_WONT_RETURN void ColladaParser::ThrowException(const std::string& pError) const { +AI_WONT_RETURN void ColladaParser::ThrowException(const std::string &pError) const { throw DeadlyImportError(format() << "Collada: " << mFileName << " - " << pError); } -void ColladaParser::ReportWarning(const char* msg, ...) { +void ColladaParser::ReportWarning(const char *msg, ...) { ai_assert(nullptr != msg); va_list args; @@ -3273,7 +2815,7 @@ void ColladaParser::SkipElement() { // ------------------------------------------------------------------------------------------------ // Skips all data until the end node of the given element -void ColladaParser::SkipElement(const char* pElement) { +void ColladaParser::SkipElement(const char *pElement) { // copy the current node's name because it'a pointer to the reader's internal buffer, // which is going to change with the upcoming parsing std::string element = pElement; @@ -3288,7 +2830,7 @@ void ColladaParser::SkipElement(const char* pElement) { // ------------------------------------------------------------------------------------------------ // Tests for an opening element of the given name, throws an exception if not found -void ColladaParser::TestOpening(const char* pName) { +void ColladaParser::TestOpening(const char *pName) { // read element start if (!mReader->read()) { ThrowException(format() << "Unexpected end of file while beginning of <" << pName << "> element."); @@ -3307,7 +2849,7 @@ void ColladaParser::TestOpening(const char* pName) { // ------------------------------------------------------------------------------------------------ // Tests for the closing tag of the given element, throws an exception if not found -void ColladaParser::TestClosing(const char* pName) { +void ColladaParser::TestClosing(const char *pName) { // check if we have an empty (self-closing) element if (mReader->isEmptyElement()) { return; @@ -3337,7 +2879,7 @@ void ColladaParser::TestClosing(const char* pName) { // ------------------------------------------------------------------------------------------------ // Returns the index of the named attribute or -1 if not found. Does not throw, therefore useful for optional attributes -int ColladaParser::GetAttribute(const char* pAttr) const { +int ColladaParser::GetAttribute(const char *pAttr) const { int index = TestAttribute(pAttr); if (index == -1) { ThrowException(format() << "Expected attribute \"" << pAttr << "\" for element <" << mReader->getNodeName() << ">."); @@ -3349,8 +2891,7 @@ int ColladaParser::GetAttribute(const char* pAttr) const { // ------------------------------------------------------------------------------------------------ // Tests the present element for the presence of one attribute, returns its index or throws an exception if not found -int ColladaParser::TestAttribute(const char* pAttr) const -{ +int ColladaParser::TestAttribute(const char *pAttr) const { for (int a = 0; a < mReader->getAttributeCount(); a++) if (strcmp(mReader->getAttributeName(a), pAttr) == 0) return a; @@ -3360,9 +2901,8 @@ int ColladaParser::TestAttribute(const char* pAttr) const // ------------------------------------------------------------------------------------------------ // Reads the text contents of an element, throws an exception if not given. Skips leading whitespace. -const char* ColladaParser::GetTextContent() -{ - const char* sz = TestTextContent(); +const char *ColladaParser::GetTextContent() { + const char *sz = TestTextContent(); if (!sz) { ThrowException("Invalid contents in element \"n\"."); } @@ -3370,21 +2910,22 @@ const char* ColladaParser::GetTextContent() } // ------------------------------------------------------------------------------------------------ -// Reads the text contents of an element, returns NULL if not given. Skips leading whitespace. -const char* ColladaParser::TestTextContent() -{ +// Reads the text contents of an element, returns nullptr if not given. Skips leading whitespace. +const char *ColladaParser::TestTextContent() { // present node should be the beginning of an element if (mReader->getNodeType() != irr::io::EXN_ELEMENT || mReader->isEmptyElement()) - return NULL; + return nullptr; // read contents of the element - if (!mReader->read()) - return NULL; - if (mReader->getNodeType() != irr::io::EXN_TEXT && mReader->getNodeType() != irr::io::EXN_CDATA) - return NULL; + if (!mReader->read()) { + return nullptr; + } + if (mReader->getNodeType() != irr::io::EXN_TEXT && mReader->getNodeType() != irr::io::EXN_CDATA) { + return nullptr; + } // skip leading whitespace - const char* text = mReader->getNodeData(); + const char *text = mReader->getNodeData(); SkipSpacesAndLineEnd(&text); return text; @@ -3392,17 +2933,13 @@ const char* ColladaParser::TestTextContent() // ------------------------------------------------------------------------------------------------ // Calculates the resulting transformation fromm all the given transform steps -aiMatrix4x4 ColladaParser::CalculateResultTransform(const std::vector& pTransforms) const -{ +aiMatrix4x4 ColladaParser::CalculateResultTransform(const std::vector &pTransforms) const { aiMatrix4x4 res; - for (std::vector::const_iterator it = pTransforms.begin(); it != pTransforms.end(); ++it) - { - const Transform& tf = *it; - switch (tf.mType) - { - case TF_LOOKAT: - { + for (std::vector::const_iterator it = pTransforms.begin(); it != pTransforms.end(); ++it) { + const Transform &tf = *it; + switch (tf.mType) { + case TF_LOOKAT: { aiVector3D pos(tf.f[0], tf.f[1], tf.f[2]); aiVector3D dstPos(tf.f[3], tf.f[4], tf.f[5]); aiVector3D up = aiVector3D(tf.f[6], tf.f[7], tf.f[8]).Normalize(); @@ -3410,14 +2947,13 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform(const std::vector aiVector3D right = (dir ^ up).Normalize(); res *= aiMatrix4x4( - right.x, up.x, -dir.x, pos.x, - right.y, up.y, -dir.y, pos.y, - right.z, up.z, -dir.z, pos.z, - 0, 0, 0, 1); + right.x, up.x, -dir.x, pos.x, + right.y, up.y, -dir.y, pos.y, + right.z, up.z, -dir.z, pos.z, + 0, 0, 0, 1); break; } - case TF_ROTATE: - { + case TF_ROTATE: { aiMatrix4x4 rot; ai_real angle = tf.f[3] * ai_real(AI_MATH_PI) / ai_real(180.0); aiVector3D axis(tf.f[0], tf.f[1], tf.f[2]); @@ -3425,17 +2961,15 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform(const std::vector res *= rot; break; } - case TF_TRANSLATE: - { + case TF_TRANSLATE: { aiMatrix4x4 trans; aiMatrix4x4::Translation(aiVector3D(tf.f[0], tf.f[1], tf.f[2]), trans); res *= trans; break; } - case TF_SCALE: - { + case TF_SCALE: { aiMatrix4x4 scale(tf.f[0], 0.0f, 0.0f, 0.0f, 0.0f, tf.f[1], 0.0f, 0.0f, 0.0f, 0.0f, tf.f[2], 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f); + 0.0f, 0.0f, 0.0f, 1.0f); res *= scale; break; } @@ -3443,10 +2977,9 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform(const std::vector // TODO: (thom) ai_assert(false); break; - case TF_MATRIX: - { + case TF_MATRIX: { aiMatrix4x4 mat(tf.f[0], tf.f[1], tf.f[2], tf.f[3], tf.f[4], tf.f[5], tf.f[6], tf.f[7], - tf.f[8], tf.f[9], tf.f[10], tf.f[11], tf.f[12], tf.f[13], tf.f[14], tf.f[15]); + tf.f[8], tf.f[9], tf.f[10], tf.f[11], tf.f[12], tf.f[13], tf.f[14], tf.f[15]); res *= mat; break; } @@ -3461,8 +2994,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform(const std::vector // ------------------------------------------------------------------------------------------------ // Determines the input data type for the given semantic string -Collada::InputType ColladaParser::GetTypeForSemantic(const std::string& semantic) -{ +Collada::InputType ColladaParser::GetTypeForSemantic(const std::string &semantic) { if (semantic.empty()) { ASSIMP_LOG_WARN("Vertex input type is empty."); return IT_Invalid; diff --git a/code/AssetLib/Collada/ColladaParser.h b/code/AssetLib/Collada/ColladaParser.h index d1e812bd2..f6056abcc 100644 --- a/code/AssetLib/Collada/ColladaParser.h +++ b/code/AssetLib/Collada/ColladaParser.h @@ -47,346 +47,345 @@ #ifndef AI_COLLADAPARSER_H_INC #define AI_COLLADAPARSER_H_INC -#include #include "ColladaHelper.h" -#include #include +#include +#include -namespace Assimp -{ - class ZipArchiveIOSystem; +namespace Assimp { +class ZipArchiveIOSystem; - // ------------------------------------------------------------------------------------------ - /** Parser helper class for the Collada loader. +// ------------------------------------------------------------------------------------------ +/** Parser helper class for the Collada loader. * * Does all the XML reading and builds internal data structures from it, * but leaves the resolving of all the references to the loader. */ - class ColladaParser - { - friend class ColladaLoader; +class ColladaParser { + friend class ColladaLoader; - /** Converts a path read from a collada file to the usual representation */ - static void UriDecodePath(aiString& ss); + /** Converts a path read from a collada file to the usual representation */ + static void UriDecodePath(aiString &ss); - protected: - /** Map for generic metadata as aiString */ - typedef std::map StringMetaData; +protected: + /** Map for generic metadata as aiString */ + typedef std::map StringMetaData; - /** Constructor from XML file */ - ColladaParser(IOSystem* pIOHandler, const std::string& pFile); + /** Constructor from XML file */ + ColladaParser(IOSystem *pIOHandler, const std::string &pFile); - /** Destructor */ - ~ColladaParser(); + /** Destructor */ + ~ColladaParser(); - /** Attempts to read the ZAE manifest and returns the DAE to open */ - static std::string ReadZaeManifest(ZipArchiveIOSystem &zip_archive); + /** Attempts to read the ZAE manifest and returns the DAE to open */ + static std::string ReadZaeManifest(ZipArchiveIOSystem &zip_archive); - /** Reads the contents of the file */ - void ReadContents(); + /** Reads the contents of the file */ + void ReadContents(); - /** Reads the structure of the file */ - void ReadStructure(); + /** Reads the structure of the file */ + void ReadStructure(); - /** Reads asset information such as coordinate system information and legal blah */ - void ReadAssetInfo(); + /** Reads asset information such as coordinate system information and legal blah */ + void ReadAssetInfo(); - /** Reads contributor information such as author and legal blah */ - void ReadContributorInfo(); + /** Reads contributor information such as author and legal blah */ + void ReadContributorInfo(); - /** Reads generic metadata into provided map and renames keys for Assimp */ - void ReadMetaDataItem(StringMetaData &metadata); + /** Reads generic metadata into provided map and renames keys for Assimp */ + void ReadMetaDataItem(StringMetaData &metadata); - /** Reads the animation library */ - void ReadAnimationLibrary(); + /** Reads the animation library */ + void ReadAnimationLibrary(); - /** Reads the animation clip library */ - void ReadAnimationClipLibrary(); + /** Reads the animation clip library */ + void ReadAnimationClipLibrary(); - /** Unwrap controllers dependency hierarchy */ - void PostProcessControllers(); - - /** Re-build animations from animation clip library, if present, otherwise combine single-channel animations */ - void PostProcessRootAnimations(); + /** Unwrap controllers dependency hierarchy */ + void PostProcessControllers(); - /** Reads an animation into the given parent structure */ - void ReadAnimation( Collada::Animation* pParent); + /** Re-build animations from animation clip library, if present, otherwise combine single-channel animations */ + void PostProcessRootAnimations(); - /** Reads an animation sampler into the given anim channel */ - void ReadAnimationSampler( Collada::AnimationChannel& pChannel); + /** Reads an animation into the given parent structure */ + void ReadAnimation(Collada::Animation *pParent); - /** Reads the skeleton controller library */ - void ReadControllerLibrary(); + /** Reads an animation sampler into the given anim channel */ + void ReadAnimationSampler(Collada::AnimationChannel &pChannel); - /** Reads a controller into the given mesh structure */ - void ReadController( Collada::Controller& pController); + /** Reads the skeleton controller library */ + void ReadControllerLibrary(); - /** Reads the joint definitions for the given controller */ - void ReadControllerJoints( Collada::Controller& pController); + /** Reads a controller into the given mesh structure */ + void ReadController(Collada::Controller &pController); - /** Reads the joint weights for the given controller */ - void ReadControllerWeights( Collada::Controller& pController); + /** Reads the joint definitions for the given controller */ + void ReadControllerJoints(Collada::Controller &pController); - /** Reads the image library contents */ - void ReadImageLibrary(); + /** Reads the joint weights for the given controller */ + void ReadControllerWeights(Collada::Controller &pController); - /** Reads an image entry into the given image */ - void ReadImage( Collada::Image& pImage); + /** Reads the image library contents */ + void ReadImageLibrary(); - /** Reads the material library */ - void ReadMaterialLibrary(); + /** Reads an image entry into the given image */ + void ReadImage(Collada::Image &pImage); - /** Reads a material entry into the given material */ - void ReadMaterial( Collada::Material& pMaterial); + /** Reads the material library */ + void ReadMaterialLibrary(); - /** Reads the camera library */ - void ReadCameraLibrary(); + /** Reads a material entry into the given material */ + void ReadMaterial(Collada::Material &pMaterial); - /** Reads a camera entry into the given camera */ - void ReadCamera( Collada::Camera& pCamera); + /** Reads the camera library */ + void ReadCameraLibrary(); - /** Reads the light library */ - void ReadLightLibrary(); + /** Reads a camera entry into the given camera */ + void ReadCamera(Collada::Camera &pCamera); - /** Reads a light entry into the given light */ - void ReadLight( Collada::Light& pLight); + /** Reads the light library */ + void ReadLightLibrary(); - /** Reads the effect library */ - void ReadEffectLibrary(); + /** Reads a light entry into the given light */ + void ReadLight(Collada::Light &pLight); - /** Reads an effect entry into the given effect*/ - void ReadEffect( Collada::Effect& pEffect); + /** Reads the effect library */ + void ReadEffectLibrary(); - /** Reads an COMMON effect profile */ - void ReadEffectProfileCommon( Collada::Effect& pEffect); + /** Reads an effect entry into the given effect*/ + void ReadEffect(Collada::Effect &pEffect); - /** Read sampler properties */ - void ReadSamplerProperties( Collada::Sampler& pSampler); + /** Reads an COMMON effect profile */ + void ReadEffectProfileCommon(Collada::Effect &pEffect); - /** Reads an effect entry containing a color or a texture defining that color */ - void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler); + /** Read sampler properties */ + void ReadSamplerProperties(Collada::Sampler &pSampler); - /** Reads an effect entry containing a float */ - void ReadEffectFloat( ai_real& pFloat); + /** Reads an effect entry containing a color or a texture defining that color */ + void ReadEffectColor(aiColor4D &pColor, Collada::Sampler &pSampler); - /** Reads an effect parameter specification of any kind */ - void ReadEffectParam( Collada::EffectParam& pParam); + /** Reads an effect entry containing a float */ + void ReadEffectFloat(ai_real &pFloat); - /** Reads the geometry library contents */ - void ReadGeometryLibrary(); + /** Reads an effect parameter specification of any kind */ + void ReadEffectParam(Collada::EffectParam &pParam); - /** Reads a geometry from the geometry library. */ - void ReadGeometry( Collada::Mesh* pMesh); + /** Reads the geometry library contents */ + void ReadGeometryLibrary(); - /** Reads a mesh from the geometry library */ - void ReadMesh( Collada::Mesh* pMesh); + /** Reads a geometry from the geometry library. */ + void ReadGeometry(Collada::Mesh &pMesh); - /** Reads a source element - a combination of raw data and an accessor defining + /** Reads a mesh from the geometry library */ + void ReadMesh(Collada::Mesh &pMesh); + + /** Reads a source element - a combination of raw data and an accessor defining * things that should not be redefinable. Yes, that's another rant. */ - void ReadSource(); + void ReadSource(); - /** Reads a data array holding a number of elements, and stores it in the global library. + /** Reads a data array holding a number of elements, and stores it in the global library. * Currently supported are array of floats and arrays of strings. */ - void ReadDataArray(); + void ReadDataArray(); - /** Reads an accessor and stores it in the global library under the given ID - + /** Reads an accessor and stores it in the global library under the given ID - * accessors use the ID of the parent element */ - void ReadAccessor( const std::string& pID); + void ReadAccessor(const std::string &pID); - /** Reads input declarations of per-vertex mesh data into the given mesh */ - void ReadVertexData( Collada::Mesh* pMesh); + /** Reads input declarations of per-vertex mesh data into the given mesh */ + void ReadVertexData(Collada::Mesh &pMesh); - /** Reads input declarations of per-index mesh data into the given mesh */ - void ReadIndexData( Collada::Mesh* pMesh); + /** Reads input declarations of per-index mesh data into the given mesh */ + void ReadIndexData(Collada::Mesh &pMesh); - /** Reads a single input channel element and stores it in the given array, if valid */ - void ReadInputChannel( std::vector& poChannels); + /** Reads a single input channel element and stores it in the given array, if valid */ + void ReadInputChannel(std::vector &poChannels); - /** Reads a

primitive index list and assembles the mesh data into the given mesh */ - size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector& pPerIndexChannels, - size_t pNumPrimitives, const std::vector& pVCount, Collada::PrimitiveType pPrimType); + /** Reads a

primitive index list and assembles the mesh data into the given mesh */ + size_t ReadPrimitives(Collada::Mesh &pMesh, std::vector &pPerIndexChannels, + size_t pNumPrimitives, const std::vector &pVCount, Collada::PrimitiveType pPrimType); - /** Copies the data for a single primitive into the mesh, based on the InputChannels */ - void CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, - Collada::Mesh* pMesh, std::vector& pPerIndexChannels, - size_t currentPrimitive, const std::vector& indices); + /** Copies the data for a single primitive into the mesh, based on the InputChannels */ + void CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, + Collada::Mesh &pMesh, std::vector &pPerIndexChannels, + size_t currentPrimitive, const std::vector &indices); - /** Reads one triangle of a tristrip into the mesh */ - void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh* pMesh, - std::vector& pPerIndexChannels, size_t currentPrimitive, const std::vector& indices); + /** Reads one triangle of a tristrip into the mesh */ + void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh &pMesh, + std::vector &pPerIndexChannels, size_t currentPrimitive, const std::vector &indices); - /** Extracts a single object from an input channel and stores it in the appropriate mesh data array */ - void ExtractDataObjectFromChannel( const Collada::InputChannel& pInput, size_t pLocalIndex, Collada::Mesh* pMesh); + /** Extracts a single object from an input channel and stores it in the appropriate mesh data array */ + void ExtractDataObjectFromChannel(const Collada::InputChannel &pInput, size_t pLocalIndex, Collada::Mesh &pMesh); - /** Reads the library of node hierarchies and scene parts */ - void ReadSceneLibrary(); + /** Reads the library of node hierarchies and scene parts */ + void ReadSceneLibrary(); - /** Reads a scene node's contents including children and stores it in the given node */ - void ReadSceneNode( Collada::Node* pNode); + /** Reads a scene node's contents including children and stores it in the given node */ + void ReadSceneNode(Collada::Node *pNode); - /** Reads a node transformation entry of the given type and adds it to the given node's transformation list. */ - void ReadNodeTransformation( Collada::Node* pNode, Collada::TransformType pType); + /** Reads a node transformation entry of the given type and adds it to the given node's transformation list. */ + void ReadNodeTransformation(Collada::Node *pNode, Collada::TransformType pType); - /** Reads a mesh reference in a node and adds it to the node's mesh list */ - void ReadNodeGeometry( Collada::Node* pNode); + /** Reads a mesh reference in a node and adds it to the node's mesh list */ + void ReadNodeGeometry(Collada::Node *pNode); - /** Reads the collada scene */ - void ReadScene(); + /** Reads the collada scene */ + void ReadScene(); - // Processes bind_vertex_input and bind elements - void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl); + // Processes bind_vertex_input and bind elements + void ReadMaterialVertexInputBinding(Collada::SemanticMappingTable &tbl); - /** Reads embedded textures from a ZAE archive*/ - void ReadEmbeddedTextures(ZipArchiveIOSystem &zip_archive); + /** Reads embedded textures from a ZAE archive*/ + void ReadEmbeddedTextures(ZipArchiveIOSystem &zip_archive); - protected: - /** Aborts the file reading with an exception */ - AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX; - void ReportWarning(const char* msg,...); +protected: + /** Aborts the file reading with an exception */ + AI_WONT_RETURN void ThrowException(const std::string &pError) const AI_WONT_RETURN_SUFFIX; + void ReportWarning(const char *msg, ...); - /** Skips all data until the end node of the current element */ - void SkipElement(); + /** Skips all data until the end node of the current element */ + void SkipElement(); - /** Skips all data until the end node of the given element */ - void SkipElement( const char* pElement); + /** Skips all data until the end node of the given element */ + void SkipElement(const char *pElement); - /** Compares the current xml element name to the given string and returns true if equal */ - bool IsElement( const char* pName) const; + /** Compares the current xml element name to the given string and returns true if equal */ + bool IsElement(const char *pName) const; - /** Tests for the opening tag of the given element, throws an exception if not found */ - void TestOpening( const char* pName); + /** Tests for the opening tag of the given element, throws an exception if not found */ + void TestOpening(const char *pName); - /** Tests for the closing tag of the given element, throws an exception if not found */ - void TestClosing( const char* pName); + /** Tests for the closing tag of the given element, throws an exception if not found */ + void TestClosing(const char *pName); - /** Checks the present element for the presence of the attribute, returns its index + /** Checks the present element for the presence of the attribute, returns its index or throws an exception if not found */ - int GetAttribute( const char* pAttr) const; + int GetAttribute(const char *pAttr) const; - /** Returns the index of the named attribute or -1 if not found. Does not throw, + /** Returns the index of the named attribute or -1 if not found. Does not throw, therefore useful for optional attributes */ - int TestAttribute( const char* pAttr) const; + int TestAttribute(const char *pAttr) const; - /** Reads the text contents of an element, throws an exception if not given. + /** Reads the text contents of an element, throws an exception if not given. Skips leading whitespace. */ - const char* GetTextContent(); + const char *GetTextContent(); - /** Reads the text contents of an element, returns NULL if not given. + /** Reads the text contents of an element, returns nullptr if not given. Skips leading whitespace. */ - const char* TestTextContent(); + const char *TestTextContent(); - /** Reads a single bool from current text content */ - bool ReadBoolFromTextContent(); + /** Reads a single bool from current text content */ + bool ReadBoolFromTextContent(); - /** Reads a single float from current text content */ - ai_real ReadFloatFromTextContent(); + /** Reads a single float from current text content */ + ai_real ReadFloatFromTextContent(); - /** Calculates the resulting transformation from all the given transform steps */ - aiMatrix4x4 CalculateResultTransform( const std::vector& pTransforms) const; + /** Calculates the resulting transformation from all the given transform steps */ + aiMatrix4x4 CalculateResultTransform(const std::vector &pTransforms) const; - /** Determines the input data type for the given semantic string */ - Collada::InputType GetTypeForSemantic( const std::string& pSemantic); + /** Determines the input data type for the given semantic string */ + Collada::InputType GetTypeForSemantic(const std::string &pSemantic); - /** Finds the item in the given library by its reference, throws if not found */ - template const Type& ResolveLibraryReference( const std::map& pLibrary, const std::string& pURL) const; - - protected: - /** Filename, for a verbose error message */ - std::string mFileName; - - /** XML reader, member for everyday use */ - irr::io::IrrXMLReader* mReader; - - /** All data arrays found in the file by ID. Might be referred to by actually - everyone. Collada, you are a steaming pile of indirection. */ - typedef std::map DataLibrary; - DataLibrary mDataLibrary; - - /** Same for accessors which define how the data in a data array is accessed. */ - typedef std::map AccessorLibrary; - AccessorLibrary mAccessorLibrary; - - /** Mesh library: mesh by ID */ - typedef std::map MeshLibrary; - MeshLibrary mMeshLibrary; - - /** node library: root node of the hierarchy part by ID */ - typedef std::map NodeLibrary; - NodeLibrary mNodeLibrary; - - /** Image library: stores texture properties by ID */ - typedef std::map ImageLibrary; - ImageLibrary mImageLibrary; - - /** Effect library: surface attributes by ID */ - typedef std::map EffectLibrary; - EffectLibrary mEffectLibrary; - - /** Material library: surface material by ID */ - typedef std::map MaterialLibrary; - MaterialLibrary mMaterialLibrary; - - /** Light library: surface light by ID */ - typedef std::map LightLibrary; - LightLibrary mLightLibrary; - - /** Camera library: surface material by ID */ - typedef std::map CameraLibrary; - CameraLibrary mCameraLibrary; - - /** Controller library: joint controllers by ID */ - typedef std::map ControllerLibrary; - ControllerLibrary mControllerLibrary; - - /** Animation library: animation references by ID */ - typedef std::map AnimationLibrary; - AnimationLibrary mAnimationLibrary; - - /** Animation clip library: clip animation references by ID */ - typedef std::vector > > AnimationClipLibrary; - AnimationClipLibrary mAnimationClipLibrary; - - /** Pointer to the root node. Don't delete, it just points to one of - the nodes in the node library. */ - Collada::Node* mRootNode; - - /** Root animation container */ - Collada::Animation mAnims; - - /** Size unit: how large compared to a meter */ - ai_real mUnitSize; - - /** Which is the up vector */ - enum { UP_X, UP_Y, UP_Z } mUpDirection; - - /** Asset metadata (global for scene) */ - StringMetaData mAssetMetaData; - - /** Collada file format version */ - Collada::FormatVersion mFormat; - }; - - // ------------------------------------------------------------------------------------------------ - // Check for element match - inline bool ColladaParser::IsElement( const char* pName) const - { - ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT); - return ::strcmp( mReader->getNodeName(), pName) == 0; - } - - // ------------------------------------------------------------------------------------------------ - // Finds the item in the given library by its reference, throws if not found + /** Finds the item in the given library by its reference, throws if not found */ template - const Type& ColladaParser::ResolveLibraryReference( const std::map& pLibrary, const std::string& pURL) const - { - typename std::map::const_iterator it = pLibrary.find( pURL); - if( it == pLibrary.end()) - ThrowException( Formatter::format() << "Unable to resolve library reference \"" << pURL << "\"." ); - return it->second; - } + const Type &ResolveLibraryReference(const std::map &pLibrary, const std::string &pURL) const; + +protected: + /** Filename, for a verbose error message */ + std::string mFileName; + + /** XML reader, member for everyday use */ + irr::io::IrrXMLReader *mReader; + + /** All data arrays found in the file by ID. Might be referred to by actually + everyone. Collada, you are a steaming pile of indirection. */ + typedef std::map DataLibrary; + DataLibrary mDataLibrary; + + /** Same for accessors which define how the data in a data array is accessed. */ + typedef std::map AccessorLibrary; + AccessorLibrary mAccessorLibrary; + + /** Mesh library: mesh by ID */ + typedef std::map MeshLibrary; + MeshLibrary mMeshLibrary; + + /** node library: root node of the hierarchy part by ID */ + typedef std::map NodeLibrary; + NodeLibrary mNodeLibrary; + + /** Image library: stores texture properties by ID */ + typedef std::map ImageLibrary; + ImageLibrary mImageLibrary; + + /** Effect library: surface attributes by ID */ + typedef std::map EffectLibrary; + EffectLibrary mEffectLibrary; + + /** Material library: surface material by ID */ + typedef std::map MaterialLibrary; + MaterialLibrary mMaterialLibrary; + + /** Light library: surface light by ID */ + typedef std::map LightLibrary; + LightLibrary mLightLibrary; + + /** Camera library: surface material by ID */ + typedef std::map CameraLibrary; + CameraLibrary mCameraLibrary; + + /** Controller library: joint controllers by ID */ + typedef std::map ControllerLibrary; + ControllerLibrary mControllerLibrary; + + /** Animation library: animation references by ID */ + typedef std::map AnimationLibrary; + AnimationLibrary mAnimationLibrary; + + /** Animation clip library: clip animation references by ID */ + typedef std::vector>> AnimationClipLibrary; + AnimationClipLibrary mAnimationClipLibrary; + + /** Pointer to the root node. Don't delete, it just points to one of + the nodes in the node library. */ + Collada::Node *mRootNode; + + /** Root animation container */ + Collada::Animation mAnims; + + /** Size unit: how large compared to a meter */ + ai_real mUnitSize; + + /** Which is the up vector */ + enum { UP_X, + UP_Y, + UP_Z } mUpDirection; + + /** Asset metadata (global for scene) */ + StringMetaData mAssetMetaData; + + /** Collada file format version */ + Collada::FormatVersion mFormat; +}; + +// ------------------------------------------------------------------------------------------------ +// Check for element match +inline bool ColladaParser::IsElement(const char *pName) const { + ai_assert(mReader->getNodeType() == irr::io::EXN_ELEMENT); + return ::strcmp(mReader->getNodeName(), pName) == 0; +} + +// ------------------------------------------------------------------------------------------------ +// Finds the item in the given library by its reference, throws if not found +template +const Type &ColladaParser::ResolveLibraryReference(const std::map &pLibrary, const std::string &pURL) const { + typename std::map::const_iterator it = pLibrary.find(pURL); + if (it == pLibrary.end()) + ThrowException(Formatter::format() << "Unable to resolve library reference \"" << pURL << "\"."); + return it->second; +} } // end of namespace Assimp diff --git a/code/AssetLib/DXF/DXFHelper.h b/code/AssetLib/DXF/DXFHelper.h index 8140d00c6..d11addc0a 100644 --- a/code/AssetLib/DXF/DXFHelper.h +++ b/code/AssetLib/DXF/DXFHelper.h @@ -135,7 +135,7 @@ public: for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++); splitter++; - ASSIMP_LOG_DEBUG((Formatter::format("DXF: skipped over control group ("),cnt," lines)")); + ASSIMP_LOG_VERBOSE_DEBUG((Formatter::format("DXF: skipped over control group ("),cnt," lines)")); } } catch(std::logic_error&) { ai_assert(!splitter); diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp index bd5c23c7b..97b0d19dd 100644 --- a/code/AssetLib/DXF/DXFLoader.cpp +++ b/code/AssetLib/DXF/DXFLoader.cpp @@ -241,7 +241,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) { } } - ASSIMP_LOG_DEBUG_F("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount); + ASSIMP_LOG_VERBOSE_DEBUG_F("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount); } if (! output.blocks.size() ) { @@ -473,7 +473,7 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) { ++reader; } - ASSIMP_LOG_DEBUG_F("DXF: got ", output.blocks.size()," entries in BLOCKS" ); + ASSIMP_LOG_VERBOSE_DEBUG_F("DXF: got ", output.blocks.size()," entries in BLOCKS" ); } // ------------------------------------------------------------------------------------------------ @@ -549,7 +549,7 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) ++reader; } - ASSIMP_LOG_DEBUG_F( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(), + ASSIMP_LOG_VERBOSE_DEBUG_F( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(), " inserted blocks in ENTITIES" ); } diff --git a/code/AssetLib/FBX/FBXAnimation.cpp b/code/AssetLib/FBX/FBXAnimation.cpp index 9a54f61a0..d7596131d 100644 --- a/code/AssetLib/FBX/FBXAnimation.cpp +++ b/code/AssetLib/FBX/FBXAnimation.cpp @@ -47,10 +47,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER -#include "FBXParser.h" #include "FBXDocument.h" -#include "FBXImporter.h" #include "FBXDocumentUtil.h" +#include "FBXImporter.h" +#include "FBXParser.h" namespace Assimp { namespace FBX { @@ -58,65 +58,60 @@ namespace FBX { using namespace Util; // ------------------------------------------------------------------------------------------------ -AnimationCurve::AnimationCurve(uint64_t id, const Element& element, const std::string& name, const Document& /*doc*/) -: Object(id, element, name) -{ - const Scope& sc = GetRequiredScope(element); - const Element& KeyTime = GetRequiredElement(sc,"KeyTime"); - const Element& KeyValueFloat = GetRequiredElement(sc,"KeyValueFloat"); +AnimationCurve::AnimationCurve(uint64_t id, const Element &element, const std::string &name, const Document & /*doc*/) : + Object(id, element, name) { + const Scope &sc = GetRequiredScope(element); + const Element &KeyTime = GetRequiredElement(sc, "KeyTime"); + const Element &KeyValueFloat = GetRequiredElement(sc, "KeyValueFloat"); ParseVectorDataArray(keys, KeyTime); ParseVectorDataArray(values, KeyValueFloat); - if(keys.size() != values.size()) { - DOMError("the number of key times does not match the number of keyframe values",&KeyTime); + if (keys.size() != values.size()) { + DOMError("the number of key times does not match the number of keyframe values", &KeyTime); } // check if the key times are well-ordered - if(!std::equal(keys.begin(), keys.end() - 1, keys.begin() + 1, std::less())) { - DOMError("the keyframes are not in ascending order",&KeyTime); + if (!std::equal(keys.begin(), keys.end() - 1, keys.begin() + 1, std::less())) { + DOMError("the keyframes are not in ascending order", &KeyTime); } - const Element* KeyAttrDataFloat = sc["KeyAttrDataFloat"]; - if(KeyAttrDataFloat) { + const Element *KeyAttrDataFloat = sc["KeyAttrDataFloat"]; + if (KeyAttrDataFloat) { ParseVectorDataArray(attributes, *KeyAttrDataFloat); } - const Element* KeyAttrFlags = sc["KeyAttrFlags"]; - if(KeyAttrFlags) { + const Element *KeyAttrFlags = sc["KeyAttrFlags"]; + if (KeyAttrFlags) { ParseVectorDataArray(flags, *KeyAttrFlags); } } // ------------------------------------------------------------------------------------------------ -AnimationCurve::~AnimationCurve() -{ +AnimationCurve::~AnimationCurve() { // empty } // ------------------------------------------------------------------------------------------------ -AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, const std::string& name, - const Document& doc, const char* const * target_prop_whitelist /*= NULL*/, - size_t whitelist_size /*= 0*/) -: Object(id, element, name) -, target() -, doc(doc) -{ - const Scope& sc = GetRequiredScope(element); +AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element &element, const std::string &name, + const Document &doc, const char *const *target_prop_whitelist /*= nullptr*/, + size_t whitelist_size /*= 0*/) : + Object(id, element, name), target(), doc(doc) { + const Scope &sc = GetRequiredScope(element); // find target node - const char* whitelist[] = {"Model","NodeAttribute","Deformer"}; - const std::vector& conns = doc.GetConnectionsBySourceSequenced(ID(),whitelist,3); + const char *whitelist[] = { "Model", "NodeAttribute", "Deformer" }; + const std::vector &conns = doc.GetConnectionsBySourceSequenced(ID(), whitelist, 3); - for(const Connection* con : conns) { + for (const Connection *con : conns) { // link should go for a property if (!con->PropertyName().length()) { continue; } - if(target_prop_whitelist) { - const char* const s = con->PropertyName().c_str(); + if (target_prop_whitelist) { + const char *const s = con->PropertyName().c_str(); bool ok = false; for (size_t i = 0; i < whitelist_size; ++i) { if (!strcmp(s, target_prop_whitelist[i])) { @@ -130,16 +125,14 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons } } - const Object* const ob = con->DestinationObject(); - if(!ob) { - DOMWarning("failed to read destination object for AnimationCurveNode->Model link, ignoring",&element); + const Object *const ob = con->DestinationObject(); + if (!ob) { + DOMWarning("failed to read destination object for AnimationCurveNode->Model link, ignoring", &element); continue; } - // XXX support constraints as DOM class - //ai_assert(dynamic_cast(ob) || dynamic_cast(ob)); target = ob; - if(!target) { + if (!target) { continue; } @@ -147,42 +140,40 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons break; } - if(!target) { - DOMWarning("failed to resolve target Model/NodeAttribute/Constraint for AnimationCurveNode",&element); + if (!target) { + DOMWarning("failed to resolve target Model/NodeAttribute/Constraint for AnimationCurveNode", &element); } - props = GetPropertyTable(doc,"AnimationCurveNode.FbxAnimCurveNode",element,sc,false); + props = GetPropertyTable(doc, "AnimationCurveNode.FbxAnimCurveNode", element, sc, false); } // ------------------------------------------------------------------------------------------------ -AnimationCurveNode::~AnimationCurveNode() -{ +AnimationCurveNode::~AnimationCurveNode() { // empty } // ------------------------------------------------------------------------------------------------ -const AnimationCurveMap& AnimationCurveNode::Curves() const -{ - if ( curves.empty() ) { +const AnimationCurveMap &AnimationCurveNode::Curves() const { + if (curves.empty()) { // resolve attached animation curves - const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationCurve"); + const std::vector &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationCurve"); - for(const Connection* con : conns) { + for (const Connection *con : conns) { // link should go for a property if (!con->PropertyName().length()) { continue; } - const Object* const ob = con->SourceObject(); - if(!ob) { - DOMWarning("failed to read source object for AnimationCurve->AnimationCurveNode link, ignoring",&element); + const Object *const ob = con->SourceObject(); + if (nullptr == ob) { + DOMWarning("failed to read source object for AnimationCurve->AnimationCurveNode link, ignoring", &element); continue; } - const AnimationCurve* const anim = dynamic_cast(ob); - if(!anim) { - DOMWarning("source object for ->AnimationCurveNode link is not an AnimationCurve",&element); + const AnimationCurve *const anim = dynamic_cast(ob); + if (nullptr == anim) { + DOMWarning("source object for ->AnimationCurveNode link is not an AnimationCurve", &element); continue; } @@ -194,53 +185,49 @@ const AnimationCurveMap& AnimationCurveNode::Curves() const } // ------------------------------------------------------------------------------------------------ -AnimationLayer::AnimationLayer(uint64_t id, const Element& element, const std::string& name, const Document& doc) -: Object(id, element, name) -, doc(doc) -{ - const Scope& sc = GetRequiredScope(element); +AnimationLayer::AnimationLayer(uint64_t id, const Element &element, const std::string &name, const Document &doc) : + Object(id, element, name), doc(doc) { + const Scope &sc = GetRequiredScope(element); // note: the props table here bears little importance and is usually absent - props = GetPropertyTable(doc,"AnimationLayer.FbxAnimLayer",element,sc, true); + props = GetPropertyTable(doc, "AnimationLayer.FbxAnimLayer", element, sc, true); } // ------------------------------------------------------------------------------------------------ -AnimationLayer::~AnimationLayer() -{ +AnimationLayer::~AnimationLayer() { // empty } // ------------------------------------------------------------------------------------------------ -AnimationCurveNodeList AnimationLayer::Nodes(const char* const * target_prop_whitelist /*= NULL*/, - size_t whitelist_size /*= 0*/) const -{ +AnimationCurveNodeList AnimationLayer::Nodes(const char *const *target_prop_whitelist /*= nullptr*/, + size_t whitelist_size /*= 0*/) const { AnimationCurveNodeList nodes; // resolve attached animation nodes - const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationCurveNode"); + const std::vector &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationCurveNode"); nodes.reserve(conns.size()); - for(const Connection* con : conns) { + for (const Connection *con : conns) { // link should not go to a property if (con->PropertyName().length()) { continue; } - const Object* const ob = con->SourceObject(); - if(!ob) { - DOMWarning("failed to read source object for AnimationCurveNode->AnimationLayer link, ignoring",&element); + const Object *const ob = con->SourceObject(); + if (!ob) { + DOMWarning("failed to read source object for AnimationCurveNode->AnimationLayer link, ignoring", &element); continue; } - const AnimationCurveNode* const anim = dynamic_cast(ob); - if(!anim) { - DOMWarning("source object for ->AnimationLayer link is not an AnimationCurveNode",&element); + const AnimationCurveNode *const anim = dynamic_cast(ob); + if (!anim) { + DOMWarning("source object for ->AnimationLayer link is not an AnimationCurveNode", &element); continue; } - if(target_prop_whitelist) { - const char* s = anim->TargetProperty().c_str(); + if (target_prop_whitelist) { + const char *s = anim->TargetProperty().c_str(); bool ok = false; for (size_t i = 0; i < whitelist_size; ++i) { if (!strcmp(s, target_prop_whitelist[i])) { @@ -248,7 +235,7 @@ AnimationCurveNodeList AnimationLayer::Nodes(const char* const * target_prop_whi break; } } - if(!ok) { + if (!ok) { continue; } } @@ -259,34 +246,33 @@ AnimationCurveNodeList AnimationLayer::Nodes(const char* const * target_prop_whi } // ------------------------------------------------------------------------------------------------ -AnimationStack::AnimationStack(uint64_t id, const Element& element, const std::string& name, const Document& doc) -: Object(id, element, name) -{ - const Scope& sc = GetRequiredScope(element); +AnimationStack::AnimationStack(uint64_t id, const Element &element, const std::string &name, const Document &doc) : + Object(id, element, name) { + const Scope &sc = GetRequiredScope(element); // note: we don't currently use any of these properties so we shouldn't bother if it is missing - props = GetPropertyTable(doc,"AnimationStack.FbxAnimStack",element,sc, true); + props = GetPropertyTable(doc, "AnimationStack.FbxAnimStack", element, sc, true); // resolve attached animation layers - const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationLayer"); + const std::vector &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationLayer"); layers.reserve(conns.size()); - for(const Connection* con : conns) { + for (const Connection *con : conns) { // link should not go to a property if (con->PropertyName().length()) { continue; } - const Object* const ob = con->SourceObject(); - if(!ob) { - DOMWarning("failed to read source object for AnimationLayer->AnimationStack link, ignoring",&element); + const Object *const ob = con->SourceObject(); + if (!ob) { + DOMWarning("failed to read source object for AnimationLayer->AnimationStack link, ignoring", &element); continue; } - const AnimationLayer* const anim = dynamic_cast(ob); - if(!anim) { - DOMWarning("source object for ->AnimationStack link is not an AnimationLayer",&element); + const AnimationLayer *const anim = dynamic_cast(ob); + if (!anim) { + DOMWarning("source object for ->AnimationStack link is not an AnimationLayer", &element); continue; } layers.push_back(anim); @@ -294,12 +280,11 @@ AnimationStack::AnimationStack(uint64_t id, const Element& element, const std::s } // ------------------------------------------------------------------------------------------------ -AnimationStack::~AnimationStack() -{ +AnimationStack::~AnimationStack() { // empty } -} //!FBX -} //!Assimp +} // namespace FBX +} // namespace Assimp #endif // ASSIMP_BUILD_NO_FBX_IMPORTER diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp index 7faa0518b..719b928bc 100644 --- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp +++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp @@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include namespace Assimp { namespace FBX { @@ -426,7 +427,8 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, // TODO: Test FBX Binary files newer than the 7500 version to check if the 64 bits address behaviour is consistent void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length) { - ai_assert(input); + ai_assert(input); + ASSIMP_LOG_DEBUG("Tokenizing binary FBX file"); if(length < 0x1b) { TokenizeError("file is too short",0); @@ -451,6 +453,7 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length) /*Result ignored*/ ReadByte(input, cursor, input + length); /*Result ignored*/ ReadByte(input, cursor, input + length); const uint32_t version = ReadWord(input, cursor, input + length); + ASSIMP_LOG_DEBUG_F("FBX version: ", version); const bool is64bits = version >= 7500; const char *end = input + length; while (cursor < end ) { diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 1bf977189..041153080 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -105,7 +105,7 @@ FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBo // The idea here is to traverse all objects to find these Textures and convert them, // so later during material conversion it will find converted texture in the textures_converted array. if (doc.Settings().readTextures) { - ConvertOrphantEmbeddedTextures(); + ConvertOrphanedEmbeddedTextures(); } ConvertRootNode(); @@ -804,11 +804,6 @@ bool FBXConverter::GenerateTransformationNodeChain(const Model &model, const std aiMatrix4x4::Translation(-GeometricTranslation, chain[TransformationComp_GeometricTranslationInverse]); } - // is_complex needs to be consistent with NeedsComplexTransformationChain() - // or the interplay between this code and the animation converter would - // not be guaranteed. - //ai_assert(NeedsComplexTransformationChain(model) == ((chainBits & chainMaskComplex) != 0)); - // now, if we have more than just Translation, Scaling and Rotation, // we need to generate a full node chain to accommodate for assimp's // lack to express pivots and offsets. @@ -1163,7 +1158,8 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c const std::vector &curVertices = shapeGeometry->GetVertices(); const std::vector &curNormals = shapeGeometry->GetNormals(); const std::vector &curIndices = shapeGeometry->GetIndices(); - animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name())); + //losing channel name if using shapeGeometry->Name() + animMesh->mName.Set(FixAnimMeshName(blendShapeChannel->Name())); for (size_t j = 0; j < curIndices.size(); j++) { const unsigned int curIndex = curIndices.at(j); aiVector3D vertex = curVertices.at(j); @@ -1289,7 +1285,8 @@ unsigned int FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry &mesh, co } if (binormals) { - ai_assert(tangents.size() == vertices.size() && binormals->size() == vertices.size()); + ai_assert(tangents.size() == vertices.size()); + ai_assert(binormals->size() == vertices.size()); out_mesh->mTangents = new aiVector3D[vertices.size()]; out_mesh->mBitangents = new aiVector3D[vertices.size()]; @@ -1542,10 +1539,10 @@ void FBXConverter::ConvertCluster(std::vector &local_mesh_bones, const aiBone *bone = nullptr; if (bone_map.count(deformer_name)) { - ASSIMP_LOG_DEBUG_F("retrieved bone from lookup ", bone_name.C_Str(), ". Deformer:", deformer_name); + ASSIMP_LOG_VERBOSE_DEBUG_F("retrieved bone from lookup ", bone_name.C_Str(), ". Deformer:", deformer_name); bone = bone_map[deformer_name]; } else { - ASSIMP_LOG_DEBUG_F("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name); + ASSIMP_LOG_VERBOSE_DEBUG_F("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name); bone = new aiBone(); bone->mName = bone_name; @@ -1999,19 +1996,19 @@ void FBXConverter::SetTextureProperties(aiMaterial *out_mat, const TextureMap &_ TrySetTextureProperties(out_mat, _textures, "Maya|ReflectionMapTexture", aiTextureType_REFLECTION, mesh); // Maya PBR - TrySetTextureProperties(out_mat, _textures, "Maya|baseColor|file", aiTextureType_BASE_COLOR, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|normalCamera|file", aiTextureType_NORMAL_CAMERA, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|emissionColor|file", aiTextureType_EMISSION_COLOR, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|metalness|file", aiTextureType_METALNESS, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|diffuseRoughness|file", aiTextureType_DIFFUSE_ROUGHNESS, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|baseColor", aiTextureType_BASE_COLOR, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|normalCamera", aiTextureType_NORMAL_CAMERA, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|emissionColor", aiTextureType_EMISSION_COLOR, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|metalness", aiTextureType_METALNESS, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|diffuseRoughness", aiTextureType_DIFFUSE_ROUGHNESS, mesh); // Maya stingray - TrySetTextureProperties(out_mat, _textures, "Maya|TEX_color_map|file", aiTextureType_BASE_COLOR, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|TEX_normal_map|file", aiTextureType_NORMAL_CAMERA, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|TEX_emissive_map|file", aiTextureType_EMISSION_COLOR, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|TEX_metallic_map|file", aiTextureType_METALNESS, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|TEX_roughness_map|file", aiTextureType_DIFFUSE_ROUGHNESS, mesh); - TrySetTextureProperties(out_mat, _textures, "Maya|TEX_ao_map|file", aiTextureType_AMBIENT_OCCLUSION, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|TEX_color_map", aiTextureType_BASE_COLOR, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|TEX_normal_map", aiTextureType_NORMAL_CAMERA, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|TEX_emissive_map", aiTextureType_EMISSION_COLOR, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|TEX_metallic_map", aiTextureType_METALNESS, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|TEX_roughness_map", aiTextureType_DIFFUSE_ROUGHNESS, mesh); + TrySetTextureProperties(out_mat, _textures, "Maya|TEX_ao_map", aiTextureType_AMBIENT_OCCLUSION, mesh); // 3DSMax PBR TrySetTextureProperties(out_mat, _textures, "3dsMax|Parameters|base_color_map", aiTextureType_BASE_COLOR, mesh); @@ -2719,7 +2716,7 @@ void FBXConverter::GenerateNodeAnimations(std::vector &node_anims, if (doc.Settings().optimizeEmptyAnimationCurves && IsRedundantAnimationData(target, comp, (chain[i]->second))) { - FBXImporter::LogDebug("dropping redundant animation channel for node " + target.Name()); + FBXImporter::LogVerboseDebug("dropping redundant animation channel for node " + target.Name()); continue; } @@ -3164,7 +3161,8 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList(const std::vectorGetKeys().size() == curve->GetValues().size() && curve->GetKeys().size()); + ai_assert(curve->GetKeys().size() == curve->GetValues().size()); + ai_assert(curve->GetKeys().size()); //get values within the start/stop time window std::shared_ptr Keys(new KeyTimeList()); @@ -3315,6 +3313,7 @@ void FBXConverter::InterpolateKeys(aiQuatKey *valOut, const KeyTimeList &keys, c // http://www.3dkingdoms.com/weekly/weekly.php?a=36 if (quat.x * lastq.x + quat.y * lastq.y + quat.z * lastq.z + quat.w * lastq.w < 0) { quat.Conjugate(); + quat.w = -quat.w; } lastq = quat; @@ -3466,7 +3465,7 @@ void FBXConverter::TransferDataToScene() { } } -void FBXConverter::ConvertOrphantEmbeddedTextures() { +void FBXConverter::ConvertOrphanedEmbeddedTextures() { // in C++14 it could be: // for (auto&& [id, object] : objects) for (auto &&id_and_object : doc.Objects()) { diff --git a/code/AssetLib/FBX/FBXConverter.h b/code/AssetLib/FBX/FBXConverter.h index d4f75820f..7db4b795b 100644 --- a/code/AssetLib/FBX/FBXConverter.h +++ b/code/AssetLib/FBX/FBXConverter.h @@ -220,8 +220,8 @@ private: * each output vertex the DOM index it maps to. */ void ConvertWeights(aiMesh *out, const MeshGeometry &geo, const aiMatrix4x4 &absolute_transform, - aiNode *parent = NULL, unsigned int materialIndex = NO_MATERIAL_SEPARATION, - std::vector *outputVertStartIndices = NULL); + aiNode *parent = nullptr, unsigned int materialIndex = NO_MATERIAL_SEPARATION, + std::vector *outputVertStartIndices = nullptr); // ------------------------------------------------------------------------------------------------ void ConvertCluster(std::vector &local_mesh_bones, const Cluster *cl, @@ -412,7 +412,7 @@ private: // ------------------------------------------------------------------------------------------------ // FBX file could have embedded textures not connected to anything - void ConvertOrphantEmbeddedTextures(); + void ConvertOrphanedEmbeddedTextures(); private: // 0: not assigned yet, others: index is value - 1 diff --git a/code/AssetLib/FBX/FBXDocument.cpp b/code/AssetLib/FBX/FBXDocument.cpp index 5940f3cfa..88e5c4eb4 100644 --- a/code/AssetLib/FBX/FBXDocument.cpp +++ b/code/AssetLib/FBX/FBXDocument.cpp @@ -55,6 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "FBXDocumentUtil.h" #include "FBXProperties.h" +#include + #include #include #include @@ -219,7 +221,7 @@ const Object* LazyObject::Get(bool dieOnError) if(!DefaultLogger::isNullLogger()) { ASSIMP_LOG_ERROR(ex.what()); } - return NULL; + return nullptr; } if (!object.get()) { @@ -264,6 +266,8 @@ Document::Document(const Parser& parser, const ImportSettings& settings) : settings(settings) , parser(parser) { + ASSIMP_LOG_DEBUG("Creating FBX Document"); + // Cannot use array default initialization syntax because vc8 fails on it for (auto &timeStamp : creationTimeStamp) { timeStamp = 0; @@ -308,6 +312,7 @@ void Document::ReadHeader() { const Scope& shead = *ehead->Compound(); fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0)); + ASSIMP_LOG_DEBUG_F("FBX Version: ", fbxVersion); // While we may have some success with newer files, we don't support // the older 6.n fbx format @@ -462,7 +467,7 @@ void Document::ReadPropertyTemplates() const Element *Properties70 = (*innerSc)["Properties70"]; if(Properties70) { std::shared_ptr props = std::make_shared( - *Properties70,std::shared_ptr(static_cast(NULL)) + *Properties70, std::shared_ptr(static_cast(nullptr)) ); templates[oname+"."+pname] = props; diff --git a/code/AssetLib/FBX/FBXDocument.h b/code/AssetLib/FBX/FBXDocument.h index 8984b3df7..165bb900e 100644 --- a/code/AssetLib/FBX/FBXDocument.h +++ b/code/AssetLib/FBX/FBXDocument.h @@ -96,7 +96,7 @@ public: template const T* Get(bool dieOnError = false) { const Object* const ob = Get(dieOnError); - return ob ? dynamic_cast(ob) : NULL; + return ob ? dynamic_cast(ob) : nullptr; } uint64_t ID() const { @@ -213,7 +213,8 @@ private: type name() const { \ const int ival = PropertyGet(Props(), fbx_stringize(name), static_cast(default_value)); \ if (ival < 0 || ival >= AI_CONCAT(type, _MAX)) { \ - ai_assert(static_cast(default_value) >= 0 && static_cast(default_value) < AI_CONCAT(type, _MAX)); \ + ai_assert(static_cast(default_value) >= 0); \ + ai_assert(static_cast(default_value) < AI_CONCAT(type, _MAX)); \ return static_cast(default_value); \ } \ return static_cast(ival); \ @@ -744,7 +745,7 @@ public: wants animations for. If the curve node does not match one of these, std::range_error will be thrown. */ AnimationCurveNode(uint64_t id, const Element& element, const std::string& name, const Document& doc, - const char* const * target_prop_whitelist = NULL, size_t whitelist_size = 0); + const char *const *target_prop_whitelist = nullptr, size_t whitelist_size = 0); virtual ~AnimationCurveNode(); @@ -756,7 +757,7 @@ public: const AnimationCurveMap& Curves() const; - /** Object the curve is assigned to, this can be NULL if the + /** Object the curve is assigned to, this can be nullptr if the * target object has no DOM representation or could not * be read for other reasons.*/ const Object* Target() const { @@ -968,7 +969,7 @@ public: // note: a connection ensures that the source and dest objects exist, but // not that they have DOM representations, so the return value of one of - // these functions can still be NULL. + // these functions can still be nullptr. const Object* SourceObject() const; const Object* DestinationObject() const; diff --git a/code/AssetLib/FBX/FBXDocumentUtil.cpp b/code/AssetLib/FBX/FBXDocumentUtil.cpp index 7178e9f26..16235645c 100644 --- a/code/AssetLib/FBX/FBXDocumentUtil.cpp +++ b/code/AssetLib/FBX/FBXDocumentUtil.cpp @@ -65,7 +65,7 @@ void DOMError(const std::string& message, const Token& token) } // ------------------------------------------------------------------------------------------------ -void DOMError(const std::string& message, const Element* element /*= NULL*/) +void DOMError(const std::string& message, const Element* element /*= nullptr*/) { if(element) { DOMError(message,element->KeyToken()); @@ -84,7 +84,7 @@ void DOMWarning(const std::string& message, const Token& token) } // ------------------------------------------------------------------------------------------------ -void DOMWarning(const std::string& message, const Element* element /*= NULL*/) +void DOMWarning(const std::string& message, const Element* element /*= nullptr*/) { if(element) { DOMWarning(message,element->KeyToken()); @@ -106,7 +106,7 @@ std::shared_ptr GetPropertyTable(const Document& doc, { const Element* const Properties70 = sc["Properties70"]; std::shared_ptr templateProps = std::shared_ptr( - static_cast(NULL)); + static_cast(nullptr)); if(templateName.length()) { PropertyTemplateMap::const_iterator it = doc.Templates().find(templateName); diff --git a/code/AssetLib/FBX/FBXImporter.cpp b/code/AssetLib/FBX/FBXImporter.cpp index 11c1503d8..8c908be40 100644 --- a/code/AssetLib/FBX/FBXImporter.cpp +++ b/code/AssetLib/FBX/FBXImporter.cpp @@ -146,6 +146,8 @@ void FBXImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy ThrowException("Could not open file for reading"); } + ASSIMP_LOG_DEBUG("Reading FBX file"); + // read entire file into memory - no streaming for this, fbx // files can grow large, but the assimp output data structure // then becomes very large, too. Assimp doesn't support diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp index 6de44bd23..9679e62a5 100644 --- a/code/AssetLib/FBX/FBXMaterial.cpp +++ b/code/AssetLib/FBX/FBXMaterial.cpp @@ -383,7 +383,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std } catch (const runtime_error& runtimeError) { //we don't need the content data for contents that has already been loaded - ASSIMP_LOG_DEBUG_F("Caught exception in FBXMaterial (likely because content was already loaded): ", + ASSIMP_LOG_VERBOSE_DEBUG_F("Caught exception in FBXMaterial (likely because content was already loaded): ", runtimeError.what()); } } diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp index 4a3de9f99..da96934d6 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.cpp +++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp @@ -241,7 +241,7 @@ const MatIndexArray& MeshGeometry::GetMaterialIndices() const { // ------------------------------------------------------------------------------------------------ const unsigned int* MeshGeometry::ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const { if ( in_index >= m_mapping_counts.size() ) { - return NULL; + return nullptr; } ai_assert( m_mapping_counts.size() == m_mapping_offsets.size() ); diff --git a/code/AssetLib/FBX/FBXMeshGeometry.h b/code/AssetLib/FBX/FBXMeshGeometry.h index 97265e4b2..f30f527d6 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.h +++ b/code/AssetLib/FBX/FBXMeshGeometry.h @@ -61,10 +61,10 @@ public: Geometry( uint64_t id, const Element& element, const std::string& name, const Document& doc ); virtual ~Geometry(); - /** Get the Skin attached to this geometry or NULL */ + /** Get the Skin attached to this geometry or nullptr */ const Skin* DeformerSkin() const; - /** Get the BlendShape attached to this geometry or NULL */ + /** Get the BlendShape attached to this geometry or nullptr */ const std::vector& GetBlendShapes() const; private: @@ -123,7 +123,7 @@ public: /** Get per-face-vertex material assignments */ const MatIndexArray& GetMaterialIndices() const; - /** Convert from a fbx file vertex index (for example from a #Cluster weight) or NULL + /** Convert from a fbx file vertex index (for example from a #Cluster weight) or nullptr * if the vertex index is not valid. */ const unsigned int* ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const; diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp index aef59d60c..3c9137ccc 100644 --- a/code/AssetLib/FBX/FBXParser.cpp +++ b/code/AssetLib/FBX/FBXParser.cpp @@ -59,6 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include @@ -76,7 +77,7 @@ namespace { } // ------------------------------------------------------------------------------------------------ - AI_WONT_RETURN void ParseError(const std::string& message, const Element* element = NULL) AI_WONT_RETURN_SUFFIX; + AI_WONT_RETURN void ParseError(const std::string &message, const Element *element = nullptr) AI_WONT_RETURN_SUFFIX; AI_WONT_RETURN void ParseError(const std::string& message, const Element* element) { if(element) { @@ -180,7 +181,7 @@ Scope::Scope(Parser& parser,bool topLevel) } TokenPtr n = parser.AdvanceToNextToken(); - if(n == NULL) { + if (n == nullptr) { ParseError("unexpected end of file"); } @@ -195,7 +196,7 @@ Scope::Scope(Parser& parser,bool topLevel) // Element() should stop at the next Key token (or right after a Close token) n = parser.CurrentToken(); - if(n == NULL) { + if (n == nullptr) { if (topLevel) { return; } @@ -220,6 +221,7 @@ Parser::Parser (const TokenList& tokens, bool is_binary) , cursor(tokens.begin()) , is_binary(is_binary) { + ASSIMP_LOG_DEBUG("Parsing FBX tokens"); root.reset(new Scope(*this,true)); } @@ -234,7 +236,7 @@ TokenPtr Parser::AdvanceToNextToken() { last = current; if (cursor == tokens.end()) { - current = NULL; + current = nullptr; } else { current = *cursor++; } @@ -256,7 +258,7 @@ TokenPtr Parser::LastToken() const // ------------------------------------------------------------------------------------------------ uint64_t ParseTokenAsID(const Token& t, const char*& err_out) { - err_out = NULL; + err_out = nullptr; if (t.Type() != TokenType_DATA) { err_out = "expected TOK_DATA token"; @@ -294,7 +296,7 @@ uint64_t ParseTokenAsID(const Token& t, const char*& err_out) size_t ParseTokenAsDim(const Token& t, const char*& err_out) { // same as ID parsing, except there is a trailing asterisk - err_out = NULL; + err_out = nullptr; if (t.Type() != TokenType_DATA) { err_out = "expected TOK_DATA token"; @@ -340,7 +342,7 @@ size_t ParseTokenAsDim(const Token& t, const char*& err_out) // ------------------------------------------------------------------------------------------------ float ParseTokenAsFloat(const Token& t, const char*& err_out) { - err_out = NULL; + err_out = nullptr; if (t.Type() != TokenType_DATA) { err_out = "expected TOK_DATA token"; @@ -383,7 +385,7 @@ float ParseTokenAsFloat(const Token& t, const char*& err_out) // ------------------------------------------------------------------------------------------------ int ParseTokenAsInt(const Token& t, const char*& err_out) { - err_out = NULL; + err_out = nullptr; if (t.Type() != TokenType_DATA) { err_out = "expected TOK_DATA token"; @@ -419,7 +421,7 @@ int ParseTokenAsInt(const Token& t, const char*& err_out) // ------------------------------------------------------------------------------------------------ int64_t ParseTokenAsInt64(const Token& t, const char*& err_out) { - err_out = NULL; + err_out = nullptr; if (t.Type() != TokenType_DATA) { err_out = "expected TOK_DATA token"; @@ -456,7 +458,7 @@ int64_t ParseTokenAsInt64(const Token& t, const char*& err_out) // ------------------------------------------------------------------------------------------------ std::string ParseTokenAsString(const Token& t, const char*& err_out) { - err_out = NULL; + err_out = nullptr; if (t.Type() != TokenType_DATA) { err_out = "expected TOK_DATA token"; @@ -1209,7 +1211,7 @@ bool HasElement( const Scope& sc, const std::string& index ) { // ------------------------------------------------------------------------------------------------ // extract a required element from a scope, abort if the element cannot be found -const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element /*= NULL*/) +const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element /*= nullptr*/) { const Element* el = sc[index]; if(!el) { diff --git a/code/AssetLib/FBX/FBXParser.h b/code/AssetLib/FBX/FBXParser.h index 7617f96ad..3ee3d5033 100644 --- a/code/AssetLib/FBX/FBXParser.h +++ b/code/AssetLib/FBX/FBXParser.h @@ -137,7 +137,7 @@ public: return element->second; } } - return NULL; + return nullptr; } ElementCollection GetCollection(const std::string& index) const { @@ -219,7 +219,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el); bool HasElement( const Scope& sc, const std::string& index ); // extract a required element from a scope, abort if the element cannot be found -const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element = NULL); +const Element &GetRequiredElement(const Scope &sc, const std::string &index, const Element *element = nullptr); // extract required compound scope const Scope& GetRequiredScope(const Element& el); diff --git a/code/AssetLib/FBX/FBXProperties.cpp b/code/AssetLib/FBX/FBXProperties.cpp index afc20e7fb..25282b637 100644 --- a/code/AssetLib/FBX/FBXProperties.cpp +++ b/code/AssetLib/FBX/FBXProperties.cpp @@ -70,7 +70,7 @@ Property::~Property() namespace { // ------------------------------------------------------------------------------------------------ -// read a typed property out of a FBX element. The return value is NULL if the property cannot be read. +// read a typed property out of a FBX element. The return value is nullptr if the property cannot be read. Property* ReadTypedProperty(const Element& element) { ai_assert(element.KeyToken().StringContents() == "P"); @@ -112,7 +112,7 @@ Property* ReadTypedProperty(const Element& element) else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) { return new TypedProperty(ParseTokenAsFloat(*tok[4])); } - return NULL; + return nullptr; } @@ -197,7 +197,7 @@ const Property* PropertyTable::Get(const std::string& name) const return templateProps->Get(name); } - return NULL; + return nullptr; } } diff --git a/code/AssetLib/FBX/FBXProperties.h b/code/AssetLib/FBX/FBXProperties.h index 209d5e940..58793d7ae 100644 --- a/code/AssetLib/FBX/FBXProperties.h +++ b/code/AssetLib/FBX/FBXProperties.h @@ -110,7 +110,7 @@ public: const Property* Get(const std::string& name) const; - // PropertyTable's need not be coupled with FBX elements so this can be NULL + // PropertyTable's need not be coupled with FBX elements so this can be nullptr const Element* GetElement() const { return element; } diff --git a/code/AssetLib/FBX/FBXTokenizer.cpp b/code/AssetLib/FBX/FBXTokenizer.cpp index 831c40061..bd3ee7ad1 100644 --- a/code/AssetLib/FBX/FBXTokenizer.cpp +++ b/code/AssetLib/FBX/FBXTokenizer.cpp @@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "FBXTokenizer.h" #include "FBXUtil.h" #include +#include namespace Assimp { namespace FBX { @@ -126,7 +127,7 @@ void ProcessDataToken( TokenList& output_tokens, const char*& start, const char* TokenizeError("unexpected character, expected data token", line, column); } - start = end = NULL; + start = end = nullptr; } } @@ -134,7 +135,8 @@ void ProcessDataToken( TokenList& output_tokens, const char*& start, const char* // ------------------------------------------------------------------------------------------------ void Tokenize(TokenList& output_tokens, const char* input) { - ai_assert(input); + ai_assert(input); + ASSIMP_LOG_DEBUG("Tokenizing ASCII FBX file"); // line and column numbers numbers are one-based unsigned int line = 1; @@ -144,7 +146,7 @@ void Tokenize(TokenList& output_tokens, const char* input) bool in_double_quotes = false; bool pending_data_token = false; - const char* token_begin = NULL, *token_end = NULL; + const char *token_begin = nullptr, *token_end = nullptr; for (const char* cur = input;*cur;column += (*cur == '\t' ? ASSIMP_FBX_TAB_WIDTH : 1), ++cur) { const char c = *cur; diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp index 54eb395bd..33460cc73 100644 --- a/code/AssetLib/HMP/HMPLoader.cpp +++ b/code/AssetLib/HMP/HMPLoader.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,17 +41,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Implementation of the MDL importer class */ - #ifndef ASSIMP_BUILD_NO_HMP_IMPORTER // internal headers #include "AssetLib/HMP/HMPLoader.h" #include "AssetLib/MD2/MD2FileData.h" -#include -#include -#include #include +#include +#include +#include #include @@ -74,24 +71,21 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -HMPImporter::HMPImporter() -{ +HMPImporter::HMPImporter() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -HMPImporter::~HMPImporter() -{ +HMPImporter::~HMPImporter() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool HMPImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const -{ +bool HMPImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool cs) const { const std::string extension = GetExtension(pFile); - if (extension == "hmp" ) + if (extension == "hmp") return true; // if check for extension is not enough, check for the magic tokens @@ -100,167 +94,155 @@ bool HMPImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool tokens[0] = AI_HMP_MAGIC_NUMBER_LE_4; tokens[1] = AI_HMP_MAGIC_NUMBER_LE_5; tokens[2] = AI_HMP_MAGIC_NUMBER_LE_7; - return CheckMagicToken(pIOHandler,pFile,tokens,3,0); + return CheckMagicToken(pIOHandler, pFile, tokens, 3, 0); } return false; } // ------------------------------------------------------------------------------------------------ // Get list of all file extensions that are handled by this loader -const aiImporterDesc* HMPImporter::GetInfo () const -{ +const aiImporterDesc *HMPImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void HMPImporter::InternReadFile( const std::string& pFile, - aiScene* _pScene, IOSystem* _pIOHandler) -{ - pScene = _pScene; +void HMPImporter::InternReadFile(const std::string &pFile, + aiScene *_pScene, IOSystem *_pIOHandler) { + pScene = _pScene; mIOHandler = _pIOHandler; std::unique_ptr file(mIOHandler->Open(pFile)); // Check whether we can read from the file - if( file.get() == nullptr) - throw DeadlyImportError( "Failed to open HMP file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open HMP file " + pFile + "."); + } // Check whether the HMP file is large enough to contain // at least the file header const size_t fileSize = file->FileSize(); - if( fileSize < 50) - throw DeadlyImportError( "HMP File is too small."); + if (fileSize < 50) + throw DeadlyImportError("HMP File is too small."); // Allocate storage and copy the contents of the file to a memory buffer mBuffer = new uint8_t[fileSize]; - file->Read( (void*)mBuffer, 1, fileSize); + file->Read((void *)mBuffer, 1, fileSize); iFileSize = (unsigned int)fileSize; // Determine the file subtype and call the appropriate member function - const uint32_t iMagic = *((uint32_t*)this->mBuffer); + const uint32_t iMagic = *((uint32_t *)this->mBuffer); // HMP4 format if (AI_HMP_MAGIC_NUMBER_LE_4 == iMagic || - AI_HMP_MAGIC_NUMBER_BE_4 == iMagic) - { + AI_HMP_MAGIC_NUMBER_BE_4 == iMagic) { ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A4, magic word is HMP4"); InternReadFile_HMP4(); } // HMP5 format else if (AI_HMP_MAGIC_NUMBER_LE_5 == iMagic || - AI_HMP_MAGIC_NUMBER_BE_5 == iMagic) - { + AI_HMP_MAGIC_NUMBER_BE_5 == iMagic) { ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A5, magic word is HMP5"); InternReadFile_HMP5(); } // HMP7 format else if (AI_HMP_MAGIC_NUMBER_LE_7 == iMagic || - AI_HMP_MAGIC_NUMBER_BE_7 == iMagic) - { + AI_HMP_MAGIC_NUMBER_BE_7 == iMagic) { ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A7, magic word is HMP7"); InternReadFile_HMP7(); - } - else - { + } else { // Print the magic word to the logger char szBuffer[5]; - szBuffer[0] = ((char*)&iMagic)[0]; - szBuffer[1] = ((char*)&iMagic)[1]; - szBuffer[2] = ((char*)&iMagic)[2]; - szBuffer[3] = ((char*)&iMagic)[3]; + szBuffer[0] = ((char *)&iMagic)[0]; + szBuffer[1] = ((char *)&iMagic)[1]; + szBuffer[2] = ((char *)&iMagic)[2]; + szBuffer[3] = ((char *)&iMagic)[3]; szBuffer[4] = '\0'; // We're definitely unable to load this file - throw DeadlyImportError( "Unknown HMP subformat " + pFile + - ". Magic word (" + szBuffer + ") is not known"); + throw DeadlyImportError("Unknown HMP subformat " + pFile + + ". Magic word (" + szBuffer + ") is not known"); } // Set the AI_SCENE_FLAGS_TERRAIN bit pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN; delete[] mBuffer; - mBuffer= nullptr; - + mBuffer = nullptr; } // ------------------------------------------------------------------------------------------------ -void HMPImporter::ValidateHeader_HMP457( ) -{ - const HMP::Header_HMP5* const pcHeader = (const HMP::Header_HMP5*)mBuffer; +void HMPImporter::ValidateHeader_HMP457() { + const HMP::Header_HMP5 *const pcHeader = (const HMP::Header_HMP5 *)mBuffer; - if (120 > iFileSize) - { + if (120 > iFileSize) { throw DeadlyImportError("HMP file is too small (header size is " - "120 bytes, this file is smaller)"); + "120 bytes, this file is smaller)"); } if (!pcHeader->ftrisize_x || !pcHeader->ftrisize_y) throw DeadlyImportError("Size of triangles in either x or y direction is zero"); - if(pcHeader->fnumverts_x < 1.0f || (pcHeader->numverts/pcHeader->fnumverts_x) < 1.0f) + if (pcHeader->fnumverts_x < 1.0f || (pcHeader->numverts / pcHeader->fnumverts_x) < 1.0f) throw DeadlyImportError("Number of triangles in either x or y direction is zero"); - if(!pcHeader->numframes) + if (!pcHeader->numframes) throw DeadlyImportError("There are no frames. At least one should be there"); - } // ------------------------------------------------------------------------------------------------ -void HMPImporter::InternReadFile_HMP4( ) -{ +void HMPImporter::InternReadFile_HMP4() { throw DeadlyImportError("HMP4 is currently not supported"); } // ------------------------------------------------------------------------------------------------ -void HMPImporter::InternReadFile_HMP5( ) -{ +void HMPImporter::InternReadFile_HMP5() { // read the file header and skip everything to byte 84 - const HMP::Header_HMP5* pcHeader = (const HMP::Header_HMP5*)mBuffer; - const unsigned char* szCurrent = (const unsigned char*)(mBuffer+84); + const HMP::Header_HMP5 *pcHeader = (const HMP::Header_HMP5 *)mBuffer; + const unsigned char *szCurrent = (const unsigned char *)(mBuffer + 84); ValidateHeader_HMP457(); // generate an output mesh pScene->mNumMeshes = 1; - pScene->mMeshes = new aiMesh*[1]; - aiMesh* pcMesh = pScene->mMeshes[0] = new aiMesh(); + pScene->mMeshes = new aiMesh *[1]; + aiMesh *pcMesh = pScene->mMeshes[0] = new aiMesh(); pcMesh->mMaterialIndex = 0; pcMesh->mVertices = new aiVector3D[pcHeader->numverts]; pcMesh->mNormals = new aiVector3D[pcHeader->numverts]; const unsigned int height = (unsigned int)(pcHeader->numverts / pcHeader->fnumverts_x); - const unsigned int width = (unsigned int)pcHeader->fnumverts_x; + const unsigned int width = (unsigned int)pcHeader->fnumverts_x; // generate/load a material for the terrain - CreateMaterial(szCurrent,&szCurrent); + CreateMaterial(szCurrent, &szCurrent); // goto offset 120, I don't know why ... // (fixme) is this the frame header? I assume yes since it starts with 2. szCurrent += 36; - SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7)*height*width); + SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7) * height * width); // now load all vertices from the file - aiVector3D* pcVertOut = pcMesh->mVertices; - aiVector3D* pcNorOut = pcMesh->mNormals; - const HMP::Vertex_HMP5* src = (const HMP::Vertex_HMP5*) szCurrent; - for (unsigned int y = 0; y < height;++y) - { - for (unsigned int x = 0; x < width;++x) - { + aiVector3D *pcVertOut = pcMesh->mVertices; + aiVector3D *pcNorOut = pcMesh->mNormals; + const HMP::Vertex_HMP5 *src = (const HMP::Vertex_HMP5 *)szCurrent; + for (unsigned int y = 0; y < height; ++y) { + for (unsigned int x = 0; x < width; ++x) { pcVertOut->x = x * pcHeader->ftrisize_x; pcVertOut->y = y * pcHeader->ftrisize_y; - pcVertOut->z = (((float)src->z / 0xffff)-0.5f) * pcHeader->ftrisize_x * 8.0f; - MD2::LookupNormalIndex(src->normals162index, *pcNorOut ); - ++pcVertOut;++pcNorOut;++src; + pcVertOut->z = (((float)src->z / 0xffff) - 0.5f) * pcHeader->ftrisize_x * 8.0f; + MD2::LookupNormalIndex(src->normals162index, *pcNorOut); + ++pcVertOut; + ++pcNorOut; + ++src; } } // generate texture coordinates if necessary if (pcHeader->numskins) - GenerateTextureCoords(width,height); + GenerateTextureCoords(width, height); // now build a list of faces - CreateOutputFaceList(width,height); + CreateOutputFaceList(width, height); // there is no nodegraph in HMP files. Simply assign the one mesh // (no, not the one ring) to the root node @@ -272,17 +254,16 @@ void HMPImporter::InternReadFile_HMP5( ) } // ------------------------------------------------------------------------------------------------ -void HMPImporter::InternReadFile_HMP7( ) -{ +void HMPImporter::InternReadFile_HMP7() { // read the file header and skip everything to byte 84 - const HMP::Header_HMP5* const pcHeader = (const HMP::Header_HMP5*)mBuffer; - const unsigned char* szCurrent = (const unsigned char*)(mBuffer+84); + const HMP::Header_HMP5 *const pcHeader = (const HMP::Header_HMP5 *)mBuffer; + const unsigned char *szCurrent = (const unsigned char *)(mBuffer + 84); ValidateHeader_HMP457(); // generate an output mesh pScene->mNumMeshes = 1; - pScene->mMeshes = new aiMesh*[1]; - aiMesh* pcMesh = pScene->mMeshes[0] = new aiMesh(); + pScene->mMeshes = new aiMesh *[1]; + aiMesh *pcMesh = pScene->mMeshes[0] = new aiMesh(); pcMesh->mMaterialIndex = 0; pcMesh->mVertices = new aiVector3D[pcHeader->numverts]; @@ -292,44 +273,44 @@ void HMPImporter::InternReadFile_HMP7( ) const unsigned int width = (unsigned int)pcHeader->fnumverts_x; // generate/load a material for the terrain - CreateMaterial(szCurrent,&szCurrent); + CreateMaterial(szCurrent, &szCurrent); // goto offset 120, I don't know why ... // (fixme) is this the frame header? I assume yes since it starts with 2. szCurrent += 36; - SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7)*height*width); + SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7) * height * width); // now load all vertices from the file - aiVector3D* pcVertOut = pcMesh->mVertices; - aiVector3D* pcNorOut = pcMesh->mNormals; - const HMP::Vertex_HMP7* src = (const HMP::Vertex_HMP7*) szCurrent; - for (unsigned int y = 0; y < height;++y) - { - for (unsigned int x = 0; x < width;++x) - { + aiVector3D *pcVertOut = pcMesh->mVertices; + aiVector3D *pcNorOut = pcMesh->mNormals; + const HMP::Vertex_HMP7 *src = (const HMP::Vertex_HMP7 *)szCurrent; + for (unsigned int y = 0; y < height; ++y) { + for (unsigned int x = 0; x < width; ++x) { pcVertOut->x = x * pcHeader->ftrisize_x; pcVertOut->y = y * pcHeader->ftrisize_y; // FIXME: What exctly is the correct scaling factor to use? // possibly pcHeader->scale_origin[2] in combination with a // signed interpretation of src->z? - pcVertOut->z = (((float)src->z / 0xffff)-0.5f) * pcHeader->ftrisize_x * 8.0f; + pcVertOut->z = (((float)src->z / 0xffff) - 0.5f) * pcHeader->ftrisize_x * 8.0f; - pcNorOut->x = ((float)src->normal_x / 0x80 ); // * pcHeader->scale_origin[0]; - pcNorOut->y = ((float)src->normal_y / 0x80 ); // * pcHeader->scale_origin[1]; + pcNorOut->x = ((float)src->normal_x / 0x80); // * pcHeader->scale_origin[0]; + pcNorOut->y = ((float)src->normal_y / 0x80); // * pcHeader->scale_origin[1]; pcNorOut->z = 1.0f; pcNorOut->Normalize(); - ++pcVertOut;++pcNorOut;++src; + ++pcVertOut; + ++pcNorOut; + ++src; } } // generate texture coordinates if necessary - if (pcHeader->numskins)GenerateTextureCoords(width,height); + if (pcHeader->numskins) GenerateTextureCoords(width, height); // now build a list of faces - CreateOutputFaceList(width,height); + CreateOutputFaceList(width, height); // there is no nodegraph in HMP files. Simply assign the one mesh // (no, not the One Ring) to the root node @@ -341,96 +322,89 @@ void HMPImporter::InternReadFile_HMP7( ) } // ------------------------------------------------------------------------------------------------ -void HMPImporter::CreateMaterial(const unsigned char* szCurrent, - const unsigned char** szCurrentOut) -{ - aiMesh* const pcMesh = pScene->mMeshes[0]; - const HMP::Header_HMP5* const pcHeader = (const HMP::Header_HMP5*)mBuffer; +void HMPImporter::CreateMaterial(const unsigned char *szCurrent, + const unsigned char **szCurrentOut) { + aiMesh *const pcMesh = pScene->mMeshes[0]; + const HMP::Header_HMP5 *const pcHeader = (const HMP::Header_HMP5 *)mBuffer; // we don't need to generate texture coordinates if // we have no textures in the file ... - if (pcHeader->numskins) - { + if (pcHeader->numskins) { pcMesh->mTextureCoords[0] = new aiVector3D[pcHeader->numverts]; pcMesh->mNumUVComponents[0] = 2; // now read the first skin and skip all others - ReadFirstSkin(pcHeader->numskins,szCurrent,&szCurrent); - } - else - { + ReadFirstSkin(pcHeader->numskins, szCurrent, &szCurrent); + } else { // generate a default material const int iMode = (int)aiShadingMode_Gouraud; - aiMaterial* pcHelper = new aiMaterial(); + aiMaterial *pcHelper = new aiMaterial(); pcHelper->AddProperty(&iMode, 1, AI_MATKEY_SHADING_MODEL); aiColor3D clr; clr.b = clr.g = clr.r = 0.6f; - pcHelper->AddProperty(&clr, 1,AI_MATKEY_COLOR_DIFFUSE); - pcHelper->AddProperty(&clr, 1,AI_MATKEY_COLOR_SPECULAR); + pcHelper->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE); + pcHelper->AddProperty(&clr, 1, AI_MATKEY_COLOR_SPECULAR); clr.b = clr.g = clr.r = 0.05f; - pcHelper->AddProperty(&clr, 1,AI_MATKEY_COLOR_AMBIENT); + pcHelper->AddProperty(&clr, 1, AI_MATKEY_COLOR_AMBIENT); aiString szName; szName.Set(AI_DEFAULT_MATERIAL_NAME); - pcHelper->AddProperty(&szName,AI_MATKEY_NAME); + pcHelper->AddProperty(&szName, AI_MATKEY_NAME); // add the material to the scene pScene->mNumMaterials = 1; - pScene->mMaterials = new aiMaterial*[1]; + pScene->mMaterials = new aiMaterial *[1]; pScene->mMaterials[0] = pcHelper; } *szCurrentOut = szCurrent; } // ------------------------------------------------------------------------------------------------ -void HMPImporter::CreateOutputFaceList(unsigned int width,unsigned int height) -{ - aiMesh* const pcMesh = this->pScene->mMeshes[0]; +void HMPImporter::CreateOutputFaceList(unsigned int width, unsigned int height) { + aiMesh *const pcMesh = this->pScene->mMeshes[0]; // Allocate enough storage - pcMesh->mNumFaces = (width-1) * (height-1); + pcMesh->mNumFaces = (width - 1) * (height - 1); pcMesh->mFaces = new aiFace[pcMesh->mNumFaces]; - pcMesh->mNumVertices = pcMesh->mNumFaces*4; - aiVector3D* pcVertices = new aiVector3D[pcMesh->mNumVertices]; - aiVector3D* pcNormals = new aiVector3D[pcMesh->mNumVertices]; + pcMesh->mNumVertices = pcMesh->mNumFaces * 4; + aiVector3D *pcVertices = new aiVector3D[pcMesh->mNumVertices]; + aiVector3D *pcNormals = new aiVector3D[pcMesh->mNumVertices]; - aiFace* pcFaceOut(pcMesh->mFaces); - aiVector3D* pcVertOut = pcVertices; - aiVector3D* pcNorOut = pcNormals; + aiFace *pcFaceOut(pcMesh->mFaces); + aiVector3D *pcVertOut = pcVertices; + aiVector3D *pcNorOut = pcNormals; - aiVector3D* pcUVs = pcMesh->mTextureCoords[0] ? new aiVector3D[pcMesh->mNumVertices] : NULL; - aiVector3D* pcUVOut(pcUVs); + aiVector3D *pcUVs = pcMesh->mTextureCoords[0] ? new aiVector3D[pcMesh->mNumVertices] : nullptr; + aiVector3D *pcUVOut(pcUVs); // Build the terrain square unsigned int iCurrent = 0; - for (unsigned int y = 0; y < height-1;++y) { - for (unsigned int x = 0; x < width-1;++x,++pcFaceOut) { + for (unsigned int y = 0; y < height - 1; ++y) { + for (unsigned int x = 0; x < width - 1; ++x, ++pcFaceOut) { pcFaceOut->mNumIndices = 4; pcFaceOut->mIndices = new unsigned int[4]; - *pcVertOut++ = pcMesh->mVertices[y*width+x]; - *pcVertOut++ = pcMesh->mVertices[(y+1)*width+x]; - *pcVertOut++ = pcMesh->mVertices[(y+1)*width+x+1]; - *pcVertOut++ = pcMesh->mVertices[y*width+x+1]; + *pcVertOut++ = pcMesh->mVertices[y * width + x]; + *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x]; + *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x + 1]; + *pcVertOut++ = pcMesh->mVertices[y * width + x + 1]; + *pcNorOut++ = pcMesh->mNormals[y * width + x]; + *pcNorOut++ = pcMesh->mNormals[(y + 1) * width + x]; + *pcNorOut++ = pcMesh->mNormals[(y + 1) * width + x + 1]; + *pcNorOut++ = pcMesh->mNormals[y * width + x + 1]; - *pcNorOut++ = pcMesh->mNormals[y*width+x]; - *pcNorOut++ = pcMesh->mNormals[(y+1)*width+x]; - *pcNorOut++ = pcMesh->mNormals[(y+1)*width+x+1]; - *pcNorOut++ = pcMesh->mNormals[y*width+x+1]; - - if (pcMesh->mTextureCoords[0]) - { - *pcUVOut++ = pcMesh->mTextureCoords[0][y*width+x]; - *pcUVOut++ = pcMesh->mTextureCoords[0][(y+1)*width+x]; - *pcUVOut++ = pcMesh->mTextureCoords[0][(y+1)*width+x+1]; - *pcUVOut++ = pcMesh->mTextureCoords[0][y*width+x+1]; + if (pcMesh->mTextureCoords[0]) { + *pcUVOut++ = pcMesh->mTextureCoords[0][y * width + x]; + *pcUVOut++ = pcMesh->mTextureCoords[0][(y + 1) * width + x]; + *pcUVOut++ = pcMesh->mTextureCoords[0][(y + 1) * width + x + 1]; + *pcUVOut++ = pcMesh->mTextureCoords[0][y * width + x + 1]; } - for (unsigned int i = 0; i < 4;++i) + for (unsigned int i = 0; i < 4; ++i) pcFaceOut->mIndices[i] = iCurrent++; } } @@ -440,58 +414,58 @@ void HMPImporter::CreateOutputFaceList(unsigned int width,unsigned int height) delete[] pcMesh->mNormals; pcMesh->mNormals = pcNormals; - if (pcMesh->mTextureCoords[0]) - { + if (pcMesh->mTextureCoords[0]) { delete[] pcMesh->mTextureCoords[0]; pcMesh->mTextureCoords[0] = pcUVs; } } // ------------------------------------------------------------------------------------------------ -void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szCursor, - const unsigned char** szCursorOut) -{ - ai_assert( 0 != iNumSkins ); - ai_assert( nullptr != szCursor); +void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char *szCursor, + const unsigned char **szCursorOut) { + ai_assert(0 != iNumSkins); + ai_assert(nullptr != szCursor); // read the type of the skin ... // sometimes we need to skip 12 bytes here, I don't know why ... - uint32_t iType = *((uint32_t*)szCursor); + uint32_t iType = *((uint32_t *)szCursor); szCursor += sizeof(uint32_t); - if (0 == iType) - { + if (0 == iType) { szCursor += sizeof(uint32_t) * 2; - iType = *((uint32_t*)szCursor); + iType = *((uint32_t *)szCursor); szCursor += sizeof(uint32_t); if (!iType) throw DeadlyImportError("Unable to read HMP7 skin chunk"); - } // read width and height - uint32_t iWidth = *((uint32_t*)szCursor); szCursor += sizeof(uint32_t); - uint32_t iHeight = *((uint32_t*)szCursor); szCursor += sizeof(uint32_t); + uint32_t iWidth = *((uint32_t *)szCursor); + szCursor += sizeof(uint32_t); + uint32_t iHeight = *((uint32_t *)szCursor); + szCursor += sizeof(uint32_t); // allocate an output material - aiMaterial* pcMat = new aiMaterial(); + aiMaterial *pcMat = new aiMaterial(); // read the skin, this works exactly as for MDL7 - ParseSkinLump_3DGS_MDL7(szCursor,&szCursor, - pcMat,iType,iWidth,iHeight); + ParseSkinLump_3DGS_MDL7(szCursor, &szCursor, + pcMat, iType, iWidth, iHeight); // now we need to skip any other skins ... - for (unsigned int i = 1; i< iNumSkins;++i) - { - iType = *((uint32_t*)szCursor); szCursor += sizeof(uint32_t); - iWidth = *((uint32_t*)szCursor); szCursor += sizeof(uint32_t); - iHeight = *((uint32_t*)szCursor); szCursor += sizeof(uint32_t); + for (unsigned int i = 1; i < iNumSkins; ++i) { + iType = *((uint32_t *)szCursor); + szCursor += sizeof(uint32_t); + iWidth = *((uint32_t *)szCursor); + szCursor += sizeof(uint32_t); + iHeight = *((uint32_t *)szCursor); + szCursor += sizeof(uint32_t); - SkipSkinLump_3DGS_MDL7(szCursor,&szCursor,iType,iWidth,iHeight); + SkipSkinLump_3DGS_MDL7(szCursor, &szCursor, iType, iWidth, iHeight); SizeCheck(szCursor); } // setup the material ... pScene->mNumMaterials = 1; - pScene->mMaterials = new aiMaterial*[1]; + pScene->mMaterials = new aiMaterial *[1]; pScene->mMaterials[0] = pcMat; *szCursorOut = szCursor; @@ -500,20 +474,20 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szC // ------------------------------------------------------------------------------------------------ // Generate proepr texture coords void HMPImporter::GenerateTextureCoords( - const unsigned int width, const unsigned int height) -{ - ai_assert(NULL != pScene->mMeshes && NULL != pScene->mMeshes[0] && - NULL != pScene->mMeshes[0]->mTextureCoords[0]); + const unsigned int width, const unsigned int height) { + ai_assert(nullptr != pScene->mMeshes); + ai_assert(nullptr != pScene->mMeshes[0]); + ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]); - aiVector3D* uv = pScene->mMeshes[0]->mTextureCoords[0]; + aiVector3D *uv = pScene->mMeshes[0]->mTextureCoords[0]; - const float fY = (1.0f / height) + (1.0f / height) / (height-1); - const float fX = (1.0f / width) + (1.0f / width) / (width-1); + const float fY = (1.0f / height) + (1.0f / height) / (height - 1); + const float fX = (1.0f / width) + (1.0f / width) / (width - 1); - for (unsigned int y = 0; y < height;++y) { - for (unsigned int x = 0; x < width;++x,++uv) { - uv->y = fY*y; - uv->x = fX*x; + for (unsigned int y = 0; y < height; ++y) { + for (unsigned int x = 0; x < width; ++x, ++uv) { + uv->y = fY * y; + uv->x = fX * x; uv->z = 0.0f; } } diff --git a/code/AssetLib/IFC/IFCBoolean.cpp b/code/AssetLib/IFC/IFCBoolean.cpp index 2c9f6cf8f..1e3a0c61f 100644 --- a/code/AssetLib/IFC/IFCBoolean.cpp +++ b/code/AssetLib/IFC/IFCBoolean.cpp @@ -131,7 +131,7 @@ void WritePolygon(std::vector &resultpoly, TempMesh &result) { void ProcessBooleanHalfSpaceDifference(const Schema_2x3::IfcHalfSpaceSolid *hs, TempMesh &result, const TempMesh &first_operand, ConversionData & /*conv*/) { - ai_assert(hs != NULL); + ai_assert(hs != nullptr); const Schema_2x3::IfcPlane *const plane = hs->BaseSurface->ToPtr(); if (!plane) { @@ -221,7 +221,7 @@ void ProcessBooleanHalfSpaceDifference(const Schema_2x3::IfcHalfSpaceSolid *hs, result.mVerts.pop_back(); } } - IFCImporter::LogDebug("generating CSG geometry by plane clipping (IfcBooleanClippingResult)"); + IFCImporter::LogVerboseDebug("generating CSG geometry by plane clipping (IfcBooleanClippingResult)"); } // ------------------------------------------------------------------------------------------------ @@ -366,7 +366,7 @@ bool PointInPoly(const IfcVector3 &p, const std::vector &boundary) { void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPolygonalBoundedHalfSpace *hs, TempMesh &result, const TempMesh &first_operand, ConversionData &conv) { - ai_assert(hs != NULL); + ai_assert(hs != nullptr); const Schema_2x3::IfcPlane *const plane = hs->BaseSurface->ToPtr(); if (!plane) { @@ -658,14 +658,14 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPoly } } } - IFCImporter::LogDebug("generating CSG geometry by plane clipping with polygonal bounding (IfcBooleanClippingResult)"); + IFCImporter::LogVerboseDebug("generating CSG geometry by plane clipping with polygonal bounding (IfcBooleanClippingResult)"); } // ------------------------------------------------------------------------------------------------ void ProcessBooleanExtrudedAreaSolidDifference(const Schema_2x3::IfcExtrudedAreaSolid *as, TempMesh &result, const TempMesh &first_operand, ConversionData &conv) { - ai_assert(as != NULL); + ai_assert(as != nullptr); // This case is handled by reduction to an instance of the quadrify() algorithm. // Obviously, this won't work for arbitrarily complex cases. In fact, the first @@ -706,7 +706,7 @@ void ProcessBooleanExtrudedAreaSolidDifference(const Schema_2x3::IfcExtrudedArea vit += pcount; } - IFCImporter::LogDebug("generating CSG geometry by geometric difference to a solid (IfcExtrudedAreaSolid)"); + IFCImporter::LogVerboseDebug("generating CSG geometry by geometric difference to a solid (IfcExtrudedAreaSolid)"); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/IFC/IFCCurve.cpp b/code/AssetLib/IFC/IFCCurve.cpp index ba2b1eaf1..c9d33961d 100644 --- a/code/AssetLib/IFC/IFCCurve.cpp +++ b/code/AssetLib/IFC/IFCCurve.cpp @@ -223,7 +223,7 @@ public: } if ( (std::string)curveSegment.Transition != "CONTINUOUS" ) { - IFCImporter::LogDebug("ignoring transition code on composite curve segment, only continuous transitions are supported"); + IFCImporter::LogVerboseDebug("ignoring transition code on composite curve segment, only continuous transitions are supported"); } curves.push_back( CurveEntry(bc,IsTrue(curveSegment.SameSense)) ); @@ -389,7 +389,8 @@ public: // -------------------------------------------------- void SampleDiscrete(TempMesh& out,IfcFloat a,IfcFloat b) const { - ai_assert(InRange(a) && InRange(b)); + ai_assert(InRange(a)); + ai_assert(InRange(b)); return base->SampleDiscrete(out,TrimParam(a),TrimParam(b)); } @@ -446,7 +447,8 @@ public: // -------------------------------------------------- size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const { - ai_assert(InRange(a) && InRange(b)); + ai_assert(InRange(a)); + ai_assert(InRange(b)); return static_cast( std::ceil(b) - std::floor(a) ); } @@ -489,7 +491,7 @@ Curve* Curve::Convert(const IFC::Schema_2x3::IfcCurve& curve,ConversionData& con } // XXX OffsetCurve2D, OffsetCurve3D not currently supported - return NULL; + return nullptr; } #ifdef ASSIMP_BUILD_DEBUG diff --git a/code/AssetLib/IFC/IFCGeometry.cpp b/code/AssetLib/IFC/IFCGeometry.cpp index 781f01964..7e8a06bbb 100644 --- a/code/AssetLib/IFC/IFCGeometry.cpp +++ b/code/AssetLib/IFC/IFCGeometry.cpp @@ -174,7 +174,7 @@ void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t m TempOpening& opening = fake_openings.back(); opening.extrusionDir = master_normal; - opening.solid = NULL; + opening.solid = nullptr; opening.profileMesh = std::make_shared(); opening.profileMesh->mVerts.reserve(*iit); @@ -319,7 +319,7 @@ void ProcessRevolvedAreaSolid(const Schema_2x3::IfcRevolvedAreaSolid& solid, Tem ConvertAxisPlacement(trafo, solid.Position); result.Transform(trafo); - IFCImporter::LogDebug("generate mesh procedurally by radial extrusion (IfcRevolvedAreaSolid)"); + IFCImporter::LogVerboseDebug("generate mesh procedurally by radial extrusion (IfcRevolvedAreaSolid)"); } // ------------------------------------------------------------------------------------------------ @@ -457,7 +457,7 @@ void ProcessSweptDiskSolid(const Schema_2x3::IfcSweptDiskSolid &solid, TempMesh& } } - IFCImporter::LogDebug("generate mesh procedurally by sweeping a disk along a curve (IfcSweptDiskSolid)"); + IFCImporter::LogVerboseDebug("generate mesh procedurally by sweeping a disk along a curve (IfcSweptDiskSolid)"); } // ------------------------------------------------------------------------------------------------ @@ -660,7 +660,7 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te IFCImporter::LogWarn("failed to resolve all openings, presumably their topology is not supported by Assimp"); } - IFCImporter::LogDebug("generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)"); + IFCImporter::LogVerboseDebug("generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)"); // If this is an opening element, store both the extruded mesh and the 2D profile mesh // it was created from. Return an empty mesh to the caller. diff --git a/code/AssetLib/IFC/IFCLoader.cpp b/code/AssetLib/IFC/IFCLoader.cpp index b96733c68..5201f87b9 100644 --- a/code/AssetLib/IFC/IFCLoader.cpp +++ b/code/AssetLib/IFC/IFCLoader.cpp @@ -172,7 +172,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy if (GetExtension(pFile) == "ifczip") { #ifndef ASSIMP_BUILD_NO_COMPRESSED_IFC unzFile zip = unzOpen(pFile.c_str()); - if (zip == NULL) { + if (zip == nullptr) { ThrowException("Could not open ifczip file for reading, unzip failed"); } @@ -373,7 +373,7 @@ void SetUnits(ConversionData &conv) { // ------------------------------------------------------------------------------------------------ void SetCoordinateSpace(ConversionData &conv) { - const Schema_2x3::IfcRepresentationContext *fav = NULL; + const Schema_2x3::IfcRepresentationContext *fav = nullptr; for (const Schema_2x3::IfcRepresentationContext &v : conv.proj.RepresentationContexts) { fav = &v; // Model should be the most suitable type of context, hence ignore the others @@ -641,14 +641,14 @@ aiNode *ProcessSpatialStructure(aiNode *parent, const Schema_2x3::IfcProduct &el bool skipGeometry = false; if (conv.settings.skipSpaceRepresentations) { if (el.ToPtr()) { - IFCImporter::LogDebug("skipping IfcSpace entity due to importer settings"); + IFCImporter::LogVerboseDebug("skipping IfcSpace entity due to importer settings"); skipGeometry = true; } } if (conv.settings.skipAnnotations) { if (el.ToPtr()) { - IFCImporter::LogDebug("skipping IfcAnnotation entity due to importer settings"); + IFCImporter::LogVerboseDebug("skipping IfcAnnotation entity due to importer settings"); return nullptr; } } @@ -790,7 +790,7 @@ aiNode *ProcessSpatialStructure(aiNode *parent, const Schema_2x3::IfcProduct &el for (const Schema_2x3::IfcObjectDefinition &def : aggr->RelatedObjects) { if (const Schema_2x3::IfcProduct *const prod = def.ToPtr()) { - aiNode *const ndnew = ProcessSpatialStructure(nd_aggr.get(), *prod, conv, NULL); + aiNode *const ndnew = ProcessSpatialStructure(nd_aggr.get(), *prod, conv, nullptr); if (ndnew) { nd_aggr->mChildren[nd_aggr->mNumChildren++] = ndnew; } @@ -856,7 +856,7 @@ void ProcessSpatialStructures(ConversionData &conv) { if (!prod) { continue; } - IFCImporter::LogDebug("looking at spatial structure `" + (prod->Name ? prod->Name.Get() : "unnamed") + "`" + (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : "")); + IFCImporter::LogVerboseDebug("looking at spatial structure `" + (prod->Name ? prod->Name.Get() : "unnamed") + "`" + (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : "")); // the primary sites are referenced by an IFCRELAGGREGATES element which assigns them to the IFCPRODUCT const STEP::DB::RefMap &refs = conv.db.GetRefs(); @@ -868,9 +868,9 @@ void ProcessSpatialStructures(ConversionData &conv) { // comparing pointer values is not sufficient, we would need to cast them to the same type first // as there is multiple inheritance in the game. if (def.GetID() == prod->GetID()) { - IFCImporter::LogDebug("selecting this spatial structure as root structure"); + IFCImporter::LogVerboseDebug("selecting this spatial structure as root structure"); // got it, this is one primary site. - nodes.push_back(ProcessSpatialStructure(NULL, *prod, conv, NULL)); + nodes.push_back(ProcessSpatialStructure(nullptr, *prod, conv, nullptr)); } } } @@ -887,7 +887,7 @@ void ProcessSpatialStructures(ConversionData &conv) { continue; } - nodes.push_back(ProcessSpatialStructure(NULL, *prod, conv, NULL)); + nodes.push_back(ProcessSpatialStructure(nullptr, *prod, conv, nullptr)); } nb_nodes = nodes.size(); @@ -897,7 +897,7 @@ void ProcessSpatialStructures(ConversionData &conv) { conv.out->mRootNode = nodes[0]; } else if (nb_nodes > 1) { conv.out->mRootNode = new aiNode("Root"); - conv.out->mRootNode->mParent = NULL; + conv.out->mRootNode->mParent = nullptr; conv.out->mRootNode->mNumChildren = static_cast(nb_nodes); conv.out->mRootNode->mChildren = new aiNode *[conv.out->mRootNode->mNumChildren]; diff --git a/code/AssetLib/IFC/IFCOpenings.cpp b/code/AssetLib/IFC/IFCOpenings.cpp index f77f33faf..e15691957 100644 --- a/code/AssetLib/IFC/IFCOpenings.cpp +++ b/code/AssetLib/IFC/IFCOpenings.cpp @@ -1359,7 +1359,7 @@ bool GenerateOpenings(std::vector& openings, break; } else { - IFCImporter::LogDebug("merging overlapping openings"); + IFCImporter::LogVerboseDebug("merging overlapping openings"); ExtractVerticesFromClipper(poly[0].outer, temp_contour, false); // Generate the union of the bounding boxes diff --git a/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp b/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp index 58ff47113..3376f4d9e 100644 --- a/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp +++ b/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp @@ -54,333 +54,333 @@ namespace { typedef EXPRESS::ConversionSchema::SchemaEntry SchemaEntry; static const SchemaEntry schema_raw_2x3[] = { - SchemaEntry("ifcstairtypeenum",NULL ) -, SchemaEntry("ifcspacetypeenum",NULL ) -, SchemaEntry("ifcwalltypeenum",NULL ) -, SchemaEntry("ifcmonthinyearnumber",NULL ) -, SchemaEntry("ifcheatfluxdensitymeasure",NULL ) -, SchemaEntry("ifckinematicviscositymeasure",NULL ) -, SchemaEntry("ifcsequenceenum",NULL ) -, SchemaEntry("ifcairtoairheatrecoverytypeenum",NULL ) -, SchemaEntry("ifcactorselect",NULL ) -, SchemaEntry("ifctransformertypeenum",NULL ) -, SchemaEntry("ifcunitaryequipmenttypeenum",NULL ) -, SchemaEntry("ifcelectricflowstoragedevicetypeenum",NULL ) -, SchemaEntry("ifcenergysequenceenum",NULL ) -, SchemaEntry("ifcworkcontroltypeenum",NULL ) -, SchemaEntry("ifccurvaturemeasure",NULL ) -, SchemaEntry("ifcparametervalue",NULL ) -, SchemaEntry("ifcappliedvalueselect",NULL ) -, SchemaEntry("ifcwarpingconstantmeasure",NULL ) -, SchemaEntry("ifcarithmeticoperatorenum",NULL ) -, SchemaEntry("ifclinearforcemeasure",NULL ) -, SchemaEntry("ifcwindowpanelpositionenum",NULL ) -, SchemaEntry("ifcflowmetertypeenum",NULL ) -, SchemaEntry("ifcrampflighttypeenum",NULL ) -, SchemaEntry("ifcspecularhighlightselect",NULL ) -, SchemaEntry("ifcactiontypeenum",NULL ) -, SchemaEntry("ifcgeometricprojectionenum",NULL ) -, SchemaEntry("ifctimeseriesdatatypeenum",NULL ) -, SchemaEntry("ifcmagneticfluxmeasure",NULL ) -, SchemaEntry("ifcobjecttypeenum",NULL ) -, SchemaEntry("ifcdataoriginenum",NULL ) -, SchemaEntry("ifcmassdensitymeasure",NULL ) -, SchemaEntry("ifclightfixturetypeenum",NULL ) -, SchemaEntry("ifcservicelifetypeenum",NULL ) -, SchemaEntry("ifcelectricvoltagemeasure",NULL ) -, SchemaEntry("ifcheatingvaluemeasure",NULL ) -, SchemaEntry("ifcpresentabletext",NULL ) -, SchemaEntry("ifcaheadorbehind",NULL ) -, SchemaEntry("ifcsimplevalue",NULL ) -, SchemaEntry("ifcsensortypeenum",NULL ) -, SchemaEntry("ifcderivedunitenum",NULL ) -, SchemaEntry("ifcsizeselect",NULL ) -, SchemaEntry("ifctransportelementtypeenum",NULL ) -, SchemaEntry("ifcinventorytypeenum",NULL ) -, SchemaEntry("ifctextdecoration",NULL ) -, SchemaEntry("ifcdirectionsenseenum",NULL ) -, SchemaEntry("ifcductfittingtypeenum",NULL ) -, SchemaEntry("ifcdocumentstatusenum",NULL ) -, SchemaEntry("ifcslabtypeenum",NULL ) -, SchemaEntry("ifcdoorstyleconstructionenum",NULL ) -, SchemaEntry("ifcvolumemeasure",NULL ) -, SchemaEntry("ifcinductancemeasure",NULL ) -, SchemaEntry("ifccurtainwalltypeenum",NULL ) -, SchemaEntry("ifcsiunitname",NULL ) -, SchemaEntry("ifcspecularexponent",NULL ) -, SchemaEntry("ifcsoundpressuremeasure",NULL ) -, SchemaEntry("ifcanalysistheorytypeenum",NULL ) -, SchemaEntry("ifcgasterminaltypeenum",NULL ) -, SchemaEntry("ifcyearnumber",NULL ) -, SchemaEntry("ifcmodulusofelasticitymeasure",NULL ) -, SchemaEntry("ifcchangeactionenum",NULL ) -, SchemaEntry("ifcdampertypeenum",NULL ) -, SchemaEntry("ifcevaporatortypeenum",NULL ) -, SchemaEntry("ifcionconcentrationmeasure",NULL ) -, SchemaEntry("ifcductsegmenttypeenum",NULL ) -, SchemaEntry("ifcprotectivedevicetypeenum",NULL ) -, SchemaEntry("ifcabsorbeddosemeasure",NULL ) -, SchemaEntry("ifcmassperlengthmeasure",NULL ) -, SchemaEntry("ifctextfontname",NULL ) -, SchemaEntry("ifcorientationselect",NULL ) -, SchemaEntry("ifcilluminancemeasure",NULL ) -, SchemaEntry("ifcfiresuppressionterminaltypeenum",NULL ) -, SchemaEntry("ifcfontstyle",NULL ) -, SchemaEntry("ifcmomentofinertiameasure",NULL ) -, SchemaEntry("ifcmodulusofsubgradereactionmeasure",NULL ) -, SchemaEntry("ifccomplexnumber",NULL ) -, SchemaEntry("ifchumidifiertypeenum",NULL ) -, SchemaEntry("ifcpresentationstyleselect",NULL ) -, SchemaEntry("ifcthermaltransmittancemeasure",NULL ) -, SchemaEntry("ifcribplatedirectionenum",NULL ) -, SchemaEntry("ifcclassificationnotationselect",NULL ) -, SchemaEntry("ifcminuteinhour",NULL ) -, SchemaEntry("ifcinternalorexternalenum",NULL ) -, SchemaEntry("ifcrotationalfrequencymeasure",NULL ) -, SchemaEntry("ifcsanitaryterminaltypeenum",NULL ) -, SchemaEntry("ifcsymbolstyleselect",NULL ) -, SchemaEntry("ifcelementcompositionenum",NULL ) -, SchemaEntry("ifctextpath",NULL ) -, SchemaEntry("ifcpowermeasure",NULL ) -, SchemaEntry("ifcsurfacestyleelementselect",NULL ) -, SchemaEntry("ifcresourceconsumptionenum",NULL ) -, SchemaEntry("ifcelectriccapacitancemeasure",NULL ) -, SchemaEntry("ifclayersetdirectionenum",NULL ) -, SchemaEntry("ifcrailingtypeenum",NULL ) -, SchemaEntry("ifcobjectiveenum",NULL ) -, SchemaEntry("ifcdocumentselect",NULL ) -, SchemaEntry("ifcmodulusoflinearsubgradereactionmeasure",NULL ) -, SchemaEntry("ifcthermaladmittancemeasure",NULL ) -, SchemaEntry("ifctransitioncode",NULL ) -, SchemaEntry("ifcconnectiontypeenum",NULL ) -, SchemaEntry("ifcmonetarymeasure",NULL ) -, SchemaEntry("ifcstackterminaltypeenum",NULL ) -, SchemaEntry("ifccolour",NULL ) -, SchemaEntry("ifctext",NULL ) -, SchemaEntry("ifccontextdependentmeasure",NULL ) -, SchemaEntry("ifcthermalconductivitymeasure",NULL ) -, SchemaEntry("ifcprojectedortruelengthenum",NULL ) -, SchemaEntry("ifcpressuremeasure",NULL ) -, SchemaEntry("ifcmoisturediffusivitymeasure",NULL ) -, SchemaEntry("ifcbooleanoperator",NULL ) -, SchemaEntry("ifcpropertysourceenum",NULL ) -, SchemaEntry("ifctimestamp",NULL ) -, SchemaEntry("ifcmaterialselect",NULL ) -, SchemaEntry("ifcgloballyuniqueid",NULL ) -, SchemaEntry("ifcreflectancemethodenum",NULL ) -, SchemaEntry("ifcvaporpermeabilitymeasure",NULL ) -, SchemaEntry("ifctimeseriesscheduletypeenum",NULL ) -, SchemaEntry("ifclinearmomentmeasure",NULL ) -, SchemaEntry("ifcgeometricsetselect",NULL ) -, SchemaEntry("ifcsectionmodulusmeasure",NULL ) -, SchemaEntry("ifcbsplinecurveform",NULL ) -, SchemaEntry("ifcdimensionextentusage",NULL ) -, SchemaEntry("ifcthermalexpansioncoefficientmeasure",NULL ) -, SchemaEntry("ifchourinday",NULL ) -, SchemaEntry("ifclinearvelocitymeasure",NULL ) -, SchemaEntry("ifctorquemeasure",NULL ) -, SchemaEntry("ifctemperaturegradientmeasure",NULL ) -, SchemaEntry("ifcfillstyleselect",NULL ) -, SchemaEntry("ifcelectricchargemeasure",NULL ) -, SchemaEntry("ifcheatexchangertypeenum",NULL ) -, SchemaEntry("ifcelectriccurrentenum",NULL ) -, SchemaEntry("ifcdaylightsavinghour",NULL ) -, SchemaEntry("ifcshell",NULL ) -, SchemaEntry("ifcdoseequivalentmeasure",NULL ) -, SchemaEntry("ifcprojectordertypeenum",NULL ) -, SchemaEntry("ifcderivedmeasurevalue",NULL ) -, SchemaEntry("ifclightdistributioncurveenum",NULL ) -, SchemaEntry("ifcwarpingmomentmeasure",NULL ) -, SchemaEntry("ifcmembertypeenum",NULL ) -, SchemaEntry("ifcsoundpowermeasure",NULL ) -, SchemaEntry("ifctextalignment",NULL ) -, SchemaEntry("ifccurveoredgecurve",NULL ) -, SchemaEntry("ifcmassflowratemeasure",NULL ) -, SchemaEntry("ifcisothermalmoisturecapacitymeasure",NULL ) -, SchemaEntry("ifccsgselect",NULL ) -, SchemaEntry("ifccoolingtowertypeenum",NULL ) -, SchemaEntry("ifcmassmeasure",NULL ) -, SchemaEntry("ifcpileconstructionenum",NULL ) -, SchemaEntry("ifcdoorstyleoperationenum",NULL ) -, SchemaEntry("ifcflowdirectionenum",NULL ) -, SchemaEntry("ifcthermalloadsourceenum",NULL ) -, SchemaEntry("ifclengthmeasure",NULL ) -, SchemaEntry("ifcconstraintenum",NULL ) -, SchemaEntry("ifcaxis2placement",NULL ) -, SchemaEntry("ifcloadgrouptypeenum",NULL ) -, SchemaEntry("ifcvalue",NULL ) -, SchemaEntry("ifcreinforcingbarsurfaceenum",NULL ) -, SchemaEntry("ifcprojectorderrecordtypeenum",NULL ) -, SchemaEntry("ifcdatetimeselect",NULL ) -, SchemaEntry("ifcstructuralsurfacetypeenum",NULL ) -, SchemaEntry("ifcpermeablecoveringoperationenum",NULL ) -, SchemaEntry("ifcfontweight",NULL ) -, SchemaEntry("ifcphmeasure",NULL ) -, SchemaEntry("ifcdescriptivemeasure",NULL ) -, SchemaEntry("ifccurvestylefontselect",NULL ) -, SchemaEntry("ifcunit",NULL ) -, SchemaEntry("ifchatchlinedistanceselect",NULL ) -, SchemaEntry("ifctextstyleselect",NULL ) -, SchemaEntry("ifcmetricvalueselect",NULL ) -, SchemaEntry("ifcvectorordirection",NULL ) -, SchemaEntry("ifcassemblyplaceenum",NULL ) -, SchemaEntry("ifcairterminaltypeenum",NULL ) -, SchemaEntry("ifccoveringtypeenum",NULL ) -, SchemaEntry("ifcplanarforcemeasure",NULL ) -, SchemaEntry("ifcvalvetypeenum",NULL ) -, SchemaEntry("ifcalarmtypeenum",NULL ) -, SchemaEntry("ifcdynamicviscositymeasure",NULL ) -, SchemaEntry("ifccurrencyenum",NULL ) -, SchemaEntry("ifcmodulusofrotationalsubgradereactionmeasure",NULL ) -, SchemaEntry("ifccablecarrierfittingtypeenum",NULL ) -, SchemaEntry("ifcboolean",NULL ) -, SchemaEntry("ifcactionsourcetypeenum",NULL ) -, SchemaEntry("ifcstructuralactivityassignmentselect",NULL ) -, SchemaEntry("ifcdistributionchamberelementtypeenum",NULL ) -, SchemaEntry("ifcevaporativecoolertypeenum",NULL ) -, SchemaEntry("ifcmagneticfluxdensitymeasure",NULL ) -, SchemaEntry("ifclightdistributiondatasourceselect",NULL ) -, SchemaEntry("ifctubebundletypeenum",NULL ) -, SchemaEntry("ifcaccelerationmeasure",NULL ) -, SchemaEntry("ifcboilertypeenum",NULL ) -, SchemaEntry("ifcramptypeenum",NULL ) -, SchemaEntry("ifcluminousintensitydistributionmeasure",NULL ) -, SchemaEntry("ifctrimmingpreference",NULL ) -, SchemaEntry("ifcspecificheatcapacitymeasure",NULL ) -, SchemaEntry("ifcamountofsubstancemeasure",NULL ) -, SchemaEntry("ifcroleenum",NULL ) -, SchemaEntry("ifcdocumentconfidentialityenum",NULL ) -, SchemaEntry("ifcfrequencymeasure",NULL ) -, SchemaEntry("ifcsectiontypeenum",NULL ) -, SchemaEntry("ifcelementassemblytypeenum",NULL ) -, SchemaEntry("ifcfootingtypeenum",NULL ) -, SchemaEntry("ifclayereditem",NULL ) -, SchemaEntry("ifccablesegmenttypeenum",NULL ) -, SchemaEntry("ifcdefinedsymbolselect",NULL ) -, SchemaEntry("ifcbuildingelementproxytypeenum",NULL ) -, SchemaEntry("ifcelectricgeneratortypeenum",NULL ) -, SchemaEntry("ifcrotationalstiffnessmeasure",NULL ) -, SchemaEntry("ifcspaceheatertypeenum",NULL ) -, SchemaEntry("ifcareameasure",NULL ) -, SchemaEntry("ifclabel",NULL ) -, SchemaEntry("ifccostscheduletypeenum",NULL ) -, SchemaEntry("ifcswitchingdevicetypeenum",NULL ) -, SchemaEntry("ifcelectrictimecontroltypeenum",NULL ) -, SchemaEntry("ifcfiltertypeenum",NULL ) -, SchemaEntry("ifcpositivelengthmeasure",NULL ) -, SchemaEntry("ifcnullstyle",NULL ) -, SchemaEntry("ifcconditioncriterionselect",NULL ) -, SchemaEntry("ifcshearmodulusmeasure",NULL ) -, SchemaEntry("ifcnormalisedratiomeasure",NULL ) -, SchemaEntry("ifcdoorpaneloperationenum",NULL ) -, SchemaEntry("ifcpointorvertexpoint",NULL ) -, SchemaEntry("ifcrooftypeenum",NULL ) -, SchemaEntry("ifccountmeasure",NULL ) -, SchemaEntry("ifcelectricconductancemeasure",NULL ) -, SchemaEntry("ifcproceduretypeenum",NULL ) -, SchemaEntry("ifcflowinstrumenttypeenum",NULL ) -, SchemaEntry("ifcelectricmotortypeenum",NULL ) -, SchemaEntry("ifcsurfaceside",NULL ) -, SchemaEntry("ifcstructuralcurvetypeenum",NULL ) -, SchemaEntry("ifccondensertypeenum",NULL ) -, SchemaEntry("ifclinearstiffnessmeasure",NULL ) -, SchemaEntry("ifcunitenum",NULL ) -, SchemaEntry("ifcoccupanttypeenum",NULL ) -, SchemaEntry("ifcthermalloadtypeenum",NULL ) -, SchemaEntry("ifcreinforcingbarroleenum",NULL ) -, SchemaEntry("ifcbenchmarkenum",NULL ) -, SchemaEntry("ifcpositiveplaneanglemeasure",NULL ) -, SchemaEntry("ifctexttransformation",NULL ) -, SchemaEntry("ifcdraughtingcalloutelement",NULL ) -, SchemaEntry("ifcratiomeasure",NULL ) -, SchemaEntry("ifcsolidanglemeasure",NULL ) -, SchemaEntry("ifcpipesegmenttypeenum",NULL ) -, SchemaEntry("ifccablecarriersegmenttypeenum",NULL ) -, SchemaEntry("ifccolourorfactor",NULL ) -, SchemaEntry("ifcidentifier",NULL ) -, SchemaEntry("ifctendontypeenum",NULL ) -, SchemaEntry("ifccontrollertypeenum",NULL ) -, SchemaEntry("ifcradioactivitymeasure",NULL ) -, SchemaEntry("ifctimemeasure",NULL ) -, SchemaEntry("ifcpumptypeenum",NULL ) -, SchemaEntry("ifcelectricheatertypeenum",NULL ) -, SchemaEntry("ifcbeamtypeenum",NULL ) -, SchemaEntry("ifcstateenum",NULL ) -, SchemaEntry("ifcsiprefix",NULL ) -, SchemaEntry("ifcnumericmeasure",NULL ) -, SchemaEntry("ifcoutlettypeenum",NULL ) -, SchemaEntry("ifccompoundplaneanglemeasure",NULL ) -, SchemaEntry("ifcservicelifefactortypeenum",NULL ) -, SchemaEntry("ifclogicaloperatorenum",NULL ) -, SchemaEntry("ifcbooleanoperand",NULL ) -, SchemaEntry("ifcobjectreferenceselect",NULL ) -, SchemaEntry("ifccooledbeamtypeenum",NULL ) -, SchemaEntry("ifcductsilencertypeenum",NULL ) -, SchemaEntry("ifcsectionalareaintegralmeasure",NULL ) -, SchemaEntry("ifcfontvariant",NULL ) -, SchemaEntry("ifcvolumetricflowratemeasure",NULL ) -, SchemaEntry("ifcplatetypeenum",NULL ) -, SchemaEntry("ifcenvironmentalimpactcategoryenum",NULL ) -, SchemaEntry("ifcvibrationisolatortypeenum",NULL ) -, SchemaEntry("ifcthermodynamictemperaturemeasure",NULL ) -, SchemaEntry("ifcrotationalmassmeasure",NULL ) -, SchemaEntry("ifcsecondinminute",NULL ) -, SchemaEntry("ifcdayinmonthnumber",NULL ) -, SchemaEntry("ifcdimensioncount",NULL ) -, SchemaEntry("ifcwindowstyleoperationenum",NULL ) -, SchemaEntry("ifcthermalresistancemeasure",NULL ) -, SchemaEntry("ifcmeasurevalue",NULL ) -, SchemaEntry("ifcwindowpaneloperationenum",NULL ) -, SchemaEntry("ifcchillertypeenum",NULL ) -, SchemaEntry("ifcpositiveratiomeasure",NULL ) -, SchemaEntry("ifcinteger",NULL ) -, SchemaEntry("ifclogical",NULL ) -, SchemaEntry("ifcjunctionboxtypeenum",NULL ) -, SchemaEntry("ifcaddresstypeenum",NULL ) -, SchemaEntry("ifcwasteterminaltypeenum",NULL ) -, SchemaEntry("ifctrimmingselect",NULL ) -, SchemaEntry("ifclightemissionsourceenum",NULL ) -, SchemaEntry("ifcsoundscaleenum",NULL ) -, SchemaEntry("ifcluminousfluxmeasure",NULL ) -, SchemaEntry("ifcelectricresistancemeasure",NULL ) -, SchemaEntry("ifcintegercountratemeasure",NULL ) -, SchemaEntry("ifcphysicalorvirtualenum",NULL ) -, SchemaEntry("ifcmolecularweightmeasure",NULL ) -, SchemaEntry("ifcprofiletypeenum",NULL ) -, SchemaEntry("ifcboxalignment",NULL ) -, SchemaEntry("ifcglobalorlocalenum",NULL ) -, SchemaEntry("ifcspecularroughness",NULL ) -, SchemaEntry("ifclamptypeenum",NULL ) -, SchemaEntry("ifcpiletypeenum",NULL ) -, SchemaEntry("ifcelectriccurrentmeasure",NULL ) -, SchemaEntry("ifcfantypeenum",NULL ) -, SchemaEntry("ifcsurfaceorfacesurface",NULL ) -, SchemaEntry("ifcpipefittingtypeenum",NULL ) -, SchemaEntry("ifctanktypeenum",NULL ) -, SchemaEntry("ifccurvefontorscaledcurvefontselect",NULL ) -, SchemaEntry("ifcwindowstyleconstructionenum",NULL ) -, SchemaEntry("ifcairterminalboxtypeenum",NULL ) -, SchemaEntry("ifcstairflighttypeenum",NULL ) -, SchemaEntry("ifcluminousintensitymeasure",NULL ) -, SchemaEntry("ifcmotorconnectiontypeenum",NULL ) -, SchemaEntry("ifcplaneanglemeasure",NULL ) -, SchemaEntry("ifcactuatortypeenum",NULL ) -, SchemaEntry("ifccolumntypeenum",NULL ) -, SchemaEntry("ifctextfontselect",NULL ) -, SchemaEntry("ifcdoorpanelpositionenum",NULL ) -, SchemaEntry("ifccoiltypeenum",NULL ) -, SchemaEntry("ifcangularvelocitymeasure",NULL ) -, SchemaEntry("ifcanalysismodeltypeenum",NULL ) -, SchemaEntry("ifclibraryselect",NULL ) -, SchemaEntry("ifcforcemeasure",NULL ) -, SchemaEntry("ifcfillareastyletileshapeselect",NULL ) -, SchemaEntry("ifcelectricappliancetypeenum",NULL ) -, SchemaEntry("ifcsurfacetextureenum",NULL ) -, SchemaEntry("ifccharacterstyleselect",NULL ) -, SchemaEntry("ifcenergymeasure",NULL ) -, SchemaEntry("ifcreal",NULL ) -, SchemaEntry("ifccompressortypeenum",NULL ) -, SchemaEntry("ifcelectricdistributionpointfunctionenum",NULL ) + SchemaEntry("ifcstairtypeenum",nullptr ) +, SchemaEntry("ifcspacetypeenum",nullptr ) +, SchemaEntry("ifcwalltypeenum",nullptr ) +, SchemaEntry("ifcmonthinyearnumber",nullptr ) +, SchemaEntry("ifcheatfluxdensitymeasure",nullptr ) +, SchemaEntry("ifckinematicviscositymeasure",nullptr ) +, SchemaEntry("ifcsequenceenum",nullptr ) +, SchemaEntry("ifcairtoairheatrecoverytypeenum",nullptr ) +, SchemaEntry("ifcactorselect",nullptr ) +, SchemaEntry("ifctransformertypeenum",nullptr ) +, SchemaEntry("ifcunitaryequipmenttypeenum",nullptr ) +, SchemaEntry("ifcelectricflowstoragedevicetypeenum",nullptr ) +, SchemaEntry("ifcenergysequenceenum",nullptr ) +, SchemaEntry("ifcworkcontroltypeenum",nullptr ) +, SchemaEntry("ifccurvaturemeasure",nullptr ) +, SchemaEntry("ifcparametervalue",nullptr ) +, SchemaEntry("ifcappliedvalueselect",nullptr ) +, SchemaEntry("ifcwarpingconstantmeasure",nullptr ) +, SchemaEntry("ifcarithmeticoperatorenum",nullptr ) +, SchemaEntry("ifclinearforcemeasure",nullptr ) +, SchemaEntry("ifcwindowpanelpositionenum",nullptr ) +, SchemaEntry("ifcflowmetertypeenum",nullptr ) +, SchemaEntry("ifcrampflighttypeenum",nullptr ) +, SchemaEntry("ifcspecularhighlightselect",nullptr ) +, SchemaEntry("ifcactiontypeenum",nullptr ) +, SchemaEntry("ifcgeometricprojectionenum",nullptr ) +, SchemaEntry("ifctimeseriesdatatypeenum",nullptr ) +, SchemaEntry("ifcmagneticfluxmeasure",nullptr ) +, SchemaEntry("ifcobjecttypeenum",nullptr ) +, SchemaEntry("ifcdataoriginenum",nullptr ) +, SchemaEntry("ifcmassdensitymeasure",nullptr ) +, SchemaEntry("ifclightfixturetypeenum",nullptr ) +, SchemaEntry("ifcservicelifetypeenum",nullptr ) +, SchemaEntry("ifcelectricvoltagemeasure",nullptr ) +, SchemaEntry("ifcheatingvaluemeasure",nullptr ) +, SchemaEntry("ifcpresentabletext",nullptr ) +, SchemaEntry("ifcaheadorbehind",nullptr ) +, SchemaEntry("ifcsimplevalue",nullptr ) +, SchemaEntry("ifcsensortypeenum",nullptr ) +, SchemaEntry("ifcderivedunitenum",nullptr ) +, SchemaEntry("ifcsizeselect",nullptr ) +, SchemaEntry("ifctransportelementtypeenum",nullptr ) +, SchemaEntry("ifcinventorytypeenum",nullptr ) +, SchemaEntry("ifctextdecoration",nullptr ) +, SchemaEntry("ifcdirectionsenseenum",nullptr ) +, SchemaEntry("ifcductfittingtypeenum",nullptr ) +, SchemaEntry("ifcdocumentstatusenum",nullptr ) +, SchemaEntry("ifcslabtypeenum",nullptr ) +, SchemaEntry("ifcdoorstyleconstructionenum",nullptr ) +, SchemaEntry("ifcvolumemeasure",nullptr ) +, SchemaEntry("ifcinductancemeasure",nullptr ) +, SchemaEntry("ifccurtainwalltypeenum",nullptr ) +, SchemaEntry("ifcsiunitname",nullptr ) +, SchemaEntry("ifcspecularexponent",nullptr ) +, SchemaEntry("ifcsoundpressuremeasure",nullptr ) +, SchemaEntry("ifcanalysistheorytypeenum",nullptr ) +, SchemaEntry("ifcgasterminaltypeenum",nullptr ) +, SchemaEntry("ifcyearnumber",nullptr ) +, SchemaEntry("ifcmodulusofelasticitymeasure",nullptr ) +, SchemaEntry("ifcchangeactionenum",nullptr ) +, SchemaEntry("ifcdampertypeenum",nullptr ) +, SchemaEntry("ifcevaporatortypeenum",nullptr ) +, SchemaEntry("ifcionconcentrationmeasure",nullptr ) +, SchemaEntry("ifcductsegmenttypeenum",nullptr ) +, SchemaEntry("ifcprotectivedevicetypeenum",nullptr ) +, SchemaEntry("ifcabsorbeddosemeasure",nullptr ) +, SchemaEntry("ifcmassperlengthmeasure",nullptr ) +, SchemaEntry("ifctextfontname",nullptr ) +, SchemaEntry("ifcorientationselect",nullptr ) +, SchemaEntry("ifcilluminancemeasure",nullptr ) +, SchemaEntry("ifcfiresuppressionterminaltypeenum",nullptr ) +, SchemaEntry("ifcfontstyle",nullptr ) +, SchemaEntry("ifcmomentofinertiameasure",nullptr ) +, SchemaEntry("ifcmodulusofsubgradereactionmeasure",nullptr ) +, SchemaEntry("ifccomplexnumber",nullptr ) +, SchemaEntry("ifchumidifiertypeenum",nullptr ) +, SchemaEntry("ifcpresentationstyleselect",nullptr ) +, SchemaEntry("ifcthermaltransmittancemeasure",nullptr ) +, SchemaEntry("ifcribplatedirectionenum",nullptr ) +, SchemaEntry("ifcclassificationnotationselect",nullptr ) +, SchemaEntry("ifcminuteinhour",nullptr ) +, SchemaEntry("ifcinternalorexternalenum",nullptr ) +, SchemaEntry("ifcrotationalfrequencymeasure",nullptr ) +, SchemaEntry("ifcsanitaryterminaltypeenum",nullptr ) +, SchemaEntry("ifcsymbolstyleselect",nullptr ) +, SchemaEntry("ifcelementcompositionenum",nullptr ) +, SchemaEntry("ifctextpath",nullptr ) +, SchemaEntry("ifcpowermeasure",nullptr ) +, SchemaEntry("ifcsurfacestyleelementselect",nullptr ) +, SchemaEntry("ifcresourceconsumptionenum",nullptr ) +, SchemaEntry("ifcelectriccapacitancemeasure",nullptr ) +, SchemaEntry("ifclayersetdirectionenum",nullptr ) +, SchemaEntry("ifcrailingtypeenum",nullptr ) +, SchemaEntry("ifcobjectiveenum",nullptr ) +, SchemaEntry("ifcdocumentselect",nullptr ) +, SchemaEntry("ifcmodulusoflinearsubgradereactionmeasure",nullptr ) +, SchemaEntry("ifcthermaladmittancemeasure",nullptr ) +, SchemaEntry("ifctransitioncode",nullptr ) +, SchemaEntry("ifcconnectiontypeenum",nullptr ) +, SchemaEntry("ifcmonetarymeasure",nullptr ) +, SchemaEntry("ifcstackterminaltypeenum",nullptr ) +, SchemaEntry("ifccolour",nullptr ) +, SchemaEntry("ifctext",nullptr ) +, SchemaEntry("ifccontextdependentmeasure",nullptr ) +, SchemaEntry("ifcthermalconductivitymeasure",nullptr ) +, SchemaEntry("ifcprojectedortruelengthenum",nullptr ) +, SchemaEntry("ifcpressuremeasure",nullptr ) +, SchemaEntry("ifcmoisturediffusivitymeasure",nullptr ) +, SchemaEntry("ifcbooleanoperator",nullptr ) +, SchemaEntry("ifcpropertysourceenum",nullptr ) +, SchemaEntry("ifctimestamp",nullptr ) +, SchemaEntry("ifcmaterialselect",nullptr ) +, SchemaEntry("ifcgloballyuniqueid",nullptr ) +, SchemaEntry("ifcreflectancemethodenum",nullptr ) +, SchemaEntry("ifcvaporpermeabilitymeasure",nullptr ) +, SchemaEntry("ifctimeseriesscheduletypeenum",nullptr ) +, SchemaEntry("ifclinearmomentmeasure",nullptr ) +, SchemaEntry("ifcgeometricsetselect",nullptr ) +, SchemaEntry("ifcsectionmodulusmeasure",nullptr ) +, SchemaEntry("ifcbsplinecurveform",nullptr ) +, SchemaEntry("ifcdimensionextentusage",nullptr ) +, SchemaEntry("ifcthermalexpansioncoefficientmeasure",nullptr ) +, SchemaEntry("ifchourinday",nullptr ) +, SchemaEntry("ifclinearvelocitymeasure",nullptr ) +, SchemaEntry("ifctorquemeasure",nullptr ) +, SchemaEntry("ifctemperaturegradientmeasure",nullptr ) +, SchemaEntry("ifcfillstyleselect",nullptr ) +, SchemaEntry("ifcelectricchargemeasure",nullptr ) +, SchemaEntry("ifcheatexchangertypeenum",nullptr ) +, SchemaEntry("ifcelectriccurrentenum",nullptr ) +, SchemaEntry("ifcdaylightsavinghour",nullptr ) +, SchemaEntry("ifcshell",nullptr ) +, SchemaEntry("ifcdoseequivalentmeasure",nullptr ) +, SchemaEntry("ifcprojectordertypeenum",nullptr ) +, SchemaEntry("ifcderivedmeasurevalue",nullptr ) +, SchemaEntry("ifclightdistributioncurveenum",nullptr ) +, SchemaEntry("ifcwarpingmomentmeasure",nullptr ) +, SchemaEntry("ifcmembertypeenum",nullptr ) +, SchemaEntry("ifcsoundpowermeasure",nullptr ) +, SchemaEntry("ifctextalignment",nullptr ) +, SchemaEntry("ifccurveoredgecurve",nullptr ) +, SchemaEntry("ifcmassflowratemeasure",nullptr ) +, SchemaEntry("ifcisothermalmoisturecapacitymeasure",nullptr ) +, SchemaEntry("ifccsgselect",nullptr ) +, SchemaEntry("ifccoolingtowertypeenum",nullptr ) +, SchemaEntry("ifcmassmeasure",nullptr ) +, SchemaEntry("ifcpileconstructionenum",nullptr ) +, SchemaEntry("ifcdoorstyleoperationenum",nullptr ) +, SchemaEntry("ifcflowdirectionenum",nullptr ) +, SchemaEntry("ifcthermalloadsourceenum",nullptr ) +, SchemaEntry("ifclengthmeasure",nullptr ) +, SchemaEntry("ifcconstraintenum",nullptr ) +, SchemaEntry("ifcaxis2placement",nullptr ) +, SchemaEntry("ifcloadgrouptypeenum",nullptr ) +, SchemaEntry("ifcvalue",nullptr ) +, SchemaEntry("ifcreinforcingbarsurfaceenum",nullptr ) +, SchemaEntry("ifcprojectorderrecordtypeenum",nullptr ) +, SchemaEntry("ifcdatetimeselect",nullptr ) +, SchemaEntry("ifcstructuralsurfacetypeenum",nullptr ) +, SchemaEntry("ifcpermeablecoveringoperationenum",nullptr ) +, SchemaEntry("ifcfontweight",nullptr ) +, SchemaEntry("ifcphmeasure",nullptr ) +, SchemaEntry("ifcdescriptivemeasure",nullptr ) +, SchemaEntry("ifccurvestylefontselect",nullptr ) +, SchemaEntry("ifcunit",nullptr ) +, SchemaEntry("ifchatchlinedistanceselect",nullptr ) +, SchemaEntry("ifctextstyleselect",nullptr ) +, SchemaEntry("ifcmetricvalueselect",nullptr ) +, SchemaEntry("ifcvectorordirection",nullptr ) +, SchemaEntry("ifcassemblyplaceenum",nullptr ) +, SchemaEntry("ifcairterminaltypeenum",nullptr ) +, SchemaEntry("ifccoveringtypeenum",nullptr ) +, SchemaEntry("ifcplanarforcemeasure",nullptr ) +, SchemaEntry("ifcvalvetypeenum",nullptr ) +, SchemaEntry("ifcalarmtypeenum",nullptr ) +, SchemaEntry("ifcdynamicviscositymeasure",nullptr ) +, SchemaEntry("ifccurrencyenum",nullptr ) +, SchemaEntry("ifcmodulusofrotationalsubgradereactionmeasure",nullptr ) +, SchemaEntry("ifccablecarrierfittingtypeenum",nullptr ) +, SchemaEntry("ifcboolean",nullptr ) +, SchemaEntry("ifcactionsourcetypeenum",nullptr ) +, SchemaEntry("ifcstructuralactivityassignmentselect",nullptr ) +, SchemaEntry("ifcdistributionchamberelementtypeenum",nullptr ) +, SchemaEntry("ifcevaporativecoolertypeenum",nullptr ) +, SchemaEntry("ifcmagneticfluxdensitymeasure",nullptr ) +, SchemaEntry("ifclightdistributiondatasourceselect",nullptr ) +, SchemaEntry("ifctubebundletypeenum",nullptr ) +, SchemaEntry("ifcaccelerationmeasure",nullptr ) +, SchemaEntry("ifcboilertypeenum",nullptr ) +, SchemaEntry("ifcramptypeenum",nullptr ) +, SchemaEntry("ifcluminousintensitydistributionmeasure",nullptr ) +, SchemaEntry("ifctrimmingpreference",nullptr ) +, SchemaEntry("ifcspecificheatcapacitymeasure",nullptr ) +, SchemaEntry("ifcamountofsubstancemeasure",nullptr ) +, SchemaEntry("ifcroleenum",nullptr ) +, SchemaEntry("ifcdocumentconfidentialityenum",nullptr ) +, SchemaEntry("ifcfrequencymeasure",nullptr ) +, SchemaEntry("ifcsectiontypeenum",nullptr ) +, SchemaEntry("ifcelementassemblytypeenum",nullptr ) +, SchemaEntry("ifcfootingtypeenum",nullptr ) +, SchemaEntry("ifclayereditem",nullptr ) +, SchemaEntry("ifccablesegmenttypeenum",nullptr ) +, SchemaEntry("ifcdefinedsymbolselect",nullptr ) +, SchemaEntry("ifcbuildingelementproxytypeenum",nullptr ) +, SchemaEntry("ifcelectricgeneratortypeenum",nullptr ) +, SchemaEntry("ifcrotationalstiffnessmeasure",nullptr ) +, SchemaEntry("ifcspaceheatertypeenum",nullptr ) +, SchemaEntry("ifcareameasure",nullptr ) +, SchemaEntry("ifclabel",nullptr ) +, SchemaEntry("ifccostscheduletypeenum",nullptr ) +, SchemaEntry("ifcswitchingdevicetypeenum",nullptr ) +, SchemaEntry("ifcelectrictimecontroltypeenum",nullptr ) +, SchemaEntry("ifcfiltertypeenum",nullptr ) +, SchemaEntry("ifcpositivelengthmeasure",nullptr ) +, SchemaEntry("ifcnullstyle",nullptr ) +, SchemaEntry("ifcconditioncriterionselect",nullptr ) +, SchemaEntry("ifcshearmodulusmeasure",nullptr ) +, SchemaEntry("ifcnormalisedratiomeasure",nullptr ) +, SchemaEntry("ifcdoorpaneloperationenum",nullptr ) +, SchemaEntry("ifcpointorvertexpoint",nullptr ) +, SchemaEntry("ifcrooftypeenum",nullptr ) +, SchemaEntry("ifccountmeasure",nullptr ) +, SchemaEntry("ifcelectricconductancemeasure",nullptr ) +, SchemaEntry("ifcproceduretypeenum",nullptr ) +, SchemaEntry("ifcflowinstrumenttypeenum",nullptr ) +, SchemaEntry("ifcelectricmotortypeenum",nullptr ) +, SchemaEntry("ifcsurfaceside",nullptr ) +, SchemaEntry("ifcstructuralcurvetypeenum",nullptr ) +, SchemaEntry("ifccondensertypeenum",nullptr ) +, SchemaEntry("ifclinearstiffnessmeasure",nullptr ) +, SchemaEntry("ifcunitenum",nullptr ) +, SchemaEntry("ifcoccupanttypeenum",nullptr ) +, SchemaEntry("ifcthermalloadtypeenum",nullptr ) +, SchemaEntry("ifcreinforcingbarroleenum",nullptr ) +, SchemaEntry("ifcbenchmarkenum",nullptr ) +, SchemaEntry("ifcpositiveplaneanglemeasure",nullptr ) +, SchemaEntry("ifctexttransformation",nullptr ) +, SchemaEntry("ifcdraughtingcalloutelement",nullptr ) +, SchemaEntry("ifcratiomeasure",nullptr ) +, SchemaEntry("ifcsolidanglemeasure",nullptr ) +, SchemaEntry("ifcpipesegmenttypeenum",nullptr ) +, SchemaEntry("ifccablecarriersegmenttypeenum",nullptr ) +, SchemaEntry("ifccolourorfactor",nullptr ) +, SchemaEntry("ifcidentifier",nullptr ) +, SchemaEntry("ifctendontypeenum",nullptr ) +, SchemaEntry("ifccontrollertypeenum",nullptr ) +, SchemaEntry("ifcradioactivitymeasure",nullptr ) +, SchemaEntry("ifctimemeasure",nullptr ) +, SchemaEntry("ifcpumptypeenum",nullptr ) +, SchemaEntry("ifcelectricheatertypeenum",nullptr ) +, SchemaEntry("ifcbeamtypeenum",nullptr ) +, SchemaEntry("ifcstateenum",nullptr ) +, SchemaEntry("ifcsiprefix",nullptr ) +, SchemaEntry("ifcnumericmeasure",nullptr ) +, SchemaEntry("ifcoutlettypeenum",nullptr ) +, SchemaEntry("ifccompoundplaneanglemeasure",nullptr ) +, SchemaEntry("ifcservicelifefactortypeenum",nullptr ) +, SchemaEntry("ifclogicaloperatorenum",nullptr ) +, SchemaEntry("ifcbooleanoperand",nullptr ) +, SchemaEntry("ifcobjectreferenceselect",nullptr ) +, SchemaEntry("ifccooledbeamtypeenum",nullptr ) +, SchemaEntry("ifcductsilencertypeenum",nullptr ) +, SchemaEntry("ifcsectionalareaintegralmeasure",nullptr ) +, SchemaEntry("ifcfontvariant",nullptr ) +, SchemaEntry("ifcvolumetricflowratemeasure",nullptr ) +, SchemaEntry("ifcplatetypeenum",nullptr ) +, SchemaEntry("ifcenvironmentalimpactcategoryenum",nullptr ) +, SchemaEntry("ifcvibrationisolatortypeenum",nullptr ) +, SchemaEntry("ifcthermodynamictemperaturemeasure",nullptr ) +, SchemaEntry("ifcrotationalmassmeasure",nullptr ) +, SchemaEntry("ifcsecondinminute",nullptr ) +, SchemaEntry("ifcdayinmonthnumber",nullptr ) +, SchemaEntry("ifcdimensioncount",nullptr ) +, SchemaEntry("ifcwindowstyleoperationenum",nullptr ) +, SchemaEntry("ifcthermalresistancemeasure",nullptr ) +, SchemaEntry("ifcmeasurevalue",nullptr ) +, SchemaEntry("ifcwindowpaneloperationenum",nullptr ) +, SchemaEntry("ifcchillertypeenum",nullptr ) +, SchemaEntry("ifcpositiveratiomeasure",nullptr ) +, SchemaEntry("ifcinteger",nullptr ) +, SchemaEntry("ifclogical",nullptr ) +, SchemaEntry("ifcjunctionboxtypeenum",nullptr ) +, SchemaEntry("ifcaddresstypeenum",nullptr ) +, SchemaEntry("ifcwasteterminaltypeenum",nullptr ) +, SchemaEntry("ifctrimmingselect",nullptr ) +, SchemaEntry("ifclightemissionsourceenum",nullptr ) +, SchemaEntry("ifcsoundscaleenum",nullptr ) +, SchemaEntry("ifcluminousfluxmeasure",nullptr ) +, SchemaEntry("ifcelectricresistancemeasure",nullptr ) +, SchemaEntry("ifcintegercountratemeasure",nullptr ) +, SchemaEntry("ifcphysicalorvirtualenum",nullptr ) +, SchemaEntry("ifcmolecularweightmeasure",nullptr ) +, SchemaEntry("ifcprofiletypeenum",nullptr ) +, SchemaEntry("ifcboxalignment",nullptr ) +, SchemaEntry("ifcglobalorlocalenum",nullptr ) +, SchemaEntry("ifcspecularroughness",nullptr ) +, SchemaEntry("ifclamptypeenum",nullptr ) +, SchemaEntry("ifcpiletypeenum",nullptr ) +, SchemaEntry("ifcelectriccurrentmeasure",nullptr ) +, SchemaEntry("ifcfantypeenum",nullptr ) +, SchemaEntry("ifcsurfaceorfacesurface",nullptr ) +, SchemaEntry("ifcpipefittingtypeenum",nullptr ) +, SchemaEntry("ifctanktypeenum",nullptr ) +, SchemaEntry("ifccurvefontorscaledcurvefontselect",nullptr ) +, SchemaEntry("ifcwindowstyleconstructionenum",nullptr ) +, SchemaEntry("ifcairterminalboxtypeenum",nullptr ) +, SchemaEntry("ifcstairflighttypeenum",nullptr ) +, SchemaEntry("ifcluminousintensitymeasure",nullptr ) +, SchemaEntry("ifcmotorconnectiontypeenum",nullptr ) +, SchemaEntry("ifcplaneanglemeasure",nullptr ) +, SchemaEntry("ifcactuatortypeenum",nullptr ) +, SchemaEntry("ifccolumntypeenum",nullptr ) +, SchemaEntry("ifctextfontselect",nullptr ) +, SchemaEntry("ifcdoorpanelpositionenum",nullptr ) +, SchemaEntry("ifccoiltypeenum",nullptr ) +, SchemaEntry("ifcangularvelocitymeasure",nullptr ) +, SchemaEntry("ifcanalysismodeltypeenum",nullptr ) +, SchemaEntry("ifclibraryselect",nullptr ) +, SchemaEntry("ifcforcemeasure",nullptr ) +, SchemaEntry("ifcfillareastyletileshapeselect",nullptr ) +, SchemaEntry("ifcelectricappliancetypeenum",nullptr ) +, SchemaEntry("ifcsurfacetextureenum",nullptr ) +, SchemaEntry("ifccharacterstyleselect",nullptr ) +, SchemaEntry("ifcenergymeasure",nullptr ) +, SchemaEntry("ifcreal",nullptr ) +, SchemaEntry("ifccompressortypeenum",nullptr ) +, SchemaEntry("ifcelectricdistributionpointfunctionenum",nullptr ) , SchemaEntry("ifcroot",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcobjectdefinition",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifctypeobject",&STEP::ObjectHelper::Construct ) diff --git a/code/AssetLib/IFC/IFCUtil.cpp b/code/AssetLib/IFC/IFCUtil.cpp index 2620160df..e1a733828 100644 --- a/code/AssetLib/IFC/IFCUtil.cpp +++ b/code/AssetLib/IFC/IFCUtil.cpp @@ -71,7 +71,7 @@ aiMesh* TempMesh::ToMesh() ai_assert(mVerts.size() == std::accumulate(mVertcnt.begin(),mVertcnt.end(),size_t(0))); if (mVerts.empty()) { - return NULL; + return nullptr; } std::unique_ptr mesh(new aiMesh()); @@ -162,7 +162,7 @@ void TempMesh::RemoveDegenerates() } if(drop) { - IFCImporter::LogDebug("removing degenerate faces"); + IFCImporter::LogVerboseDebug("removing degenerate faces"); } } @@ -437,7 +437,7 @@ void TempMesh::RemoveAdjacentDuplicates() { base += cnt; } if(drop) { - IFCImporter::LogDebug("removing duplicate vertices"); + IFCImporter::LogVerboseDebug("removing duplicate vertices"); } } diff --git a/code/AssetLib/IFC/IFCUtil.h b/code/AssetLib/IFC/IFCUtil.h index b9aad4440..2b7fba3b2 100644 --- a/code/AssetLib/IFC/IFCUtil.h +++ b/code/AssetLib/IFC/IFCUtil.h @@ -201,7 +201,7 @@ struct ConversionData struct MeshCacheIndex { const IFC::Schema_2x3::IfcRepresentationItem* item; unsigned int matindex; - MeshCacheIndex() : item(NULL), matindex(0) { } + MeshCacheIndex() : item(nullptr), matindex(0) { } MeshCacheIndex(const IFC::Schema_2x3::IfcRepresentationItem* i, unsigned int mi) : item(i), matindex(mi) { } bool operator == (const MeshCacheIndex& o) const { return item == o.item && matindex == o.matindex; } bool operator < (const MeshCacheIndex& o) const { return item < o.item || (item == o.item && matindex < o.matindex); } diff --git a/code/AssetLib/Irr/IRRLoader.cpp b/code/AssetLib/Irr/IRRLoader.cpp index f7e71b547..5d5253516 100644 --- a/code/AssetLib/Irr/IRRLoader.cpp +++ b/code/AssetLib/Irr/IRRLoader.cpp @@ -45,26 +45,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of the Irr importer class */ - - #ifndef ASSIMP_BUILD_NO_IRR_IMPORTER #include "AssetLib/Irr/IRRLoader.h" #include "Common/Importer.h" -#include -#include #include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include #include @@ -87,9 +85,8 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -IRRImporter::IRRImporter() -: fps() -, configSpeedFlag(){ +IRRImporter::IRRImporter() : + fps(), configSpeedFlag() { // empty } @@ -101,105 +98,101 @@ IRRImporter::~IRRImporter() { // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool IRRImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const { +bool IRRImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { const std::string extension = GetExtension(pFile); - if ( extension == "irr" ) { + if (extension == "irr") { return true; } else if (extension == "xml" || checkSig) { /* If CanRead() is called in order to check whether we * support a specific file extension in general pIOHandler * might be nullptr and it's our duty to return true here. */ - if (nullptr == pIOHandler ) { + if (nullptr == pIOHandler) { return true; } - const char* tokens[] = {"irr_scene"}; - return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1); + const char *tokens[] = { "irr_scene" }; + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); } return false; } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* IRRImporter::GetInfo () const -{ +const aiImporterDesc *IRRImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ -void IRRImporter::SetupProperties(const Importer* pImp) -{ +void IRRImporter::SetupProperties(const Importer *pImp) { // read the output frame rate of all node animation channels - fps = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_IRR_ANIM_FPS,100); - if (fps < 10.) { + fps = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_IRR_ANIM_FPS, 100); + if (fps < 10.) { ASSIMP_LOG_ERROR("IRR: Invalid FPS configuration"); fps = 100; } // AI_CONFIG_FAVOUR_SPEED - configSpeedFlag = (0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED,0)); + configSpeedFlag = (0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED, 0)); } // ------------------------------------------------------------------------------------------------ // Build a mesh tha consists of a single squad (a side of a skybox) -aiMesh* IRRImporter::BuildSingleQuadMesh(const SkyboxVertex& v1, - const SkyboxVertex& v2, - const SkyboxVertex& v3, - const SkyboxVertex& v4) -{ +aiMesh *IRRImporter::BuildSingleQuadMesh(const SkyboxVertex &v1, + const SkyboxVertex &v2, + const SkyboxVertex &v3, + const SkyboxVertex &v4) { // allocate and prepare the mesh - aiMesh* out = new aiMesh(); + aiMesh *out = new aiMesh(); out->mPrimitiveTypes = aiPrimitiveType_POLYGON; out->mNumFaces = 1; // build the face - out->mFaces = new aiFace[1]; - aiFace& face = out->mFaces[0]; + out->mFaces = new aiFace[1]; + aiFace &face = out->mFaces[0]; face.mNumIndices = 4; - face.mIndices = new unsigned int[4]; - for (unsigned int i = 0; i < 4;++i) + face.mIndices = new unsigned int[4]; + for (unsigned int i = 0; i < 4; ++i) face.mIndices[i] = i; out->mNumVertices = 4; // copy vertex positions - aiVector3D* vec = out->mVertices = new aiVector3D[4]; + aiVector3D *vec = out->mVertices = new aiVector3D[4]; *vec++ = v1.position; *vec++ = v2.position; *vec++ = v3.position; - *vec = v4.position; + *vec = v4.position; // copy vertex normals vec = out->mNormals = new aiVector3D[4]; *vec++ = v1.normal; *vec++ = v2.normal; *vec++ = v3.normal; - *vec = v4.normal; + *vec = v4.normal; // copy texture coordinates vec = out->mTextureCoords[0] = new aiVector3D[4]; *vec++ = v1.uv; *vec++ = v2.uv; *vec++ = v3.uv; - *vec = v4.uv; + *vec = v4.uv; return out; } // ------------------------------------------------------------------------------------------------ -void IRRImporter::BuildSkybox(std::vector& meshes, std::vector materials) -{ +void IRRImporter::BuildSkybox(std::vector &meshes, std::vector materials) { // Update the material of the skybox - replace the name and disable shading for skyboxes. - for (unsigned int i = 0; i < 6;++i) { - aiMaterial* out = ( aiMaterial* ) (*(materials.end()-(6-i))); + for (unsigned int i = 0; i < 6; ++i) { + aiMaterial *out = (aiMaterial *)(*(materials.end() - (6 - i))); aiString s; - s.length = ::ai_snprintf( s.data, MAXLEN, "SkyboxSide_%u",i ); - out->AddProperty(&s,AI_MATKEY_NAME); + s.length = ::ai_snprintf(s.data, MAXLEN, "SkyboxSide_%u", i); + out->AddProperty(&s, AI_MATKEY_NAME); int shading = aiShadingMode_NoShading; - out->AddProperty(&shading,1,AI_MATKEY_SHADING_MODEL); + out->AddProperty(&shading, 1, AI_MATKEY_SHADING_MODEL); } // Skyboxes are much more difficult. They are represented @@ -209,64 +202,62 @@ void IRRImporter::BuildSkybox(std::vector& meshes, std::vectormMaterialIndex = static_cast(materials.size()-6u); + meshes.push_back(BuildSingleQuadMesh( + SkyboxVertex(-l, -l, -l, 0, 0, 1, 1.0, 1.0), + SkyboxVertex(l, -l, -l, 0, 0, 1, 0.0, 1.0), + SkyboxVertex(l, l, -l, 0, 0, 1, 0.0, 0.0), + SkyboxVertex(-l, l, -l, 0, 0, 1, 1.0, 0.0))); + meshes.back()->mMaterialIndex = static_cast(materials.size() - 6u); // LEFT SIDE - meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l,-l,-l, -1, 0, 0, 1.0,1.0), - SkyboxVertex( l,-l, l, -1, 0, 0, 0.0,1.0), - SkyboxVertex( l, l, l, -1, 0, 0, 0.0,0.0), - SkyboxVertex( l, l,-l, -1, 0, 0, 1.0,0.0)) ); - meshes.back()->mMaterialIndex = static_cast(materials.size()-5u); + meshes.push_back(BuildSingleQuadMesh( + SkyboxVertex(l, -l, -l, -1, 0, 0, 1.0, 1.0), + SkyboxVertex(l, -l, l, -1, 0, 0, 0.0, 1.0), + SkyboxVertex(l, l, l, -1, 0, 0, 0.0, 0.0), + SkyboxVertex(l, l, -l, -1, 0, 0, 1.0, 0.0))); + meshes.back()->mMaterialIndex = static_cast(materials.size() - 5u); // BACK SIDE - meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l,-l, l, 0, 0, -1, 1.0,1.0), - SkyboxVertex(-l,-l, l, 0, 0, -1, 0.0,1.0), - SkyboxVertex(-l, l, l, 0, 0, -1, 0.0,0.0), - SkyboxVertex( l, l, l, 0, 0, -1, 1.0,0.0)) ); - meshes.back()->mMaterialIndex = static_cast(materials.size()-4u); + meshes.push_back(BuildSingleQuadMesh( + SkyboxVertex(l, -l, l, 0, 0, -1, 1.0, 1.0), + SkyboxVertex(-l, -l, l, 0, 0, -1, 0.0, 1.0), + SkyboxVertex(-l, l, l, 0, 0, -1, 0.0, 0.0), + SkyboxVertex(l, l, l, 0, 0, -1, 1.0, 0.0))); + meshes.back()->mMaterialIndex = static_cast(materials.size() - 4u); // RIGHT SIDE - meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex(-l,-l, l, 1, 0, 0, 1.0,1.0), - SkyboxVertex(-l,-l,-l, 1, 0, 0, 0.0,1.0), - SkyboxVertex(-l, l,-l, 1, 0, 0, 0.0,0.0), - SkyboxVertex(-l, l, l, 1, 0, 0, 1.0,0.0)) ); - meshes.back()->mMaterialIndex = static_cast(materials.size()-3u); + meshes.push_back(BuildSingleQuadMesh( + SkyboxVertex(-l, -l, l, 1, 0, 0, 1.0, 1.0), + SkyboxVertex(-l, -l, -l, 1, 0, 0, 0.0, 1.0), + SkyboxVertex(-l, l, -l, 1, 0, 0, 0.0, 0.0), + SkyboxVertex(-l, l, l, 1, 0, 0, 1.0, 0.0))); + meshes.back()->mMaterialIndex = static_cast(materials.size() - 3u); // TOP SIDE - meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l, l,-l, 0, -1, 0, 1.0,1.0), - SkyboxVertex( l, l, l, 0, -1, 0, 0.0,1.0), - SkyboxVertex(-l, l, l, 0, -1, 0, 0.0,0.0), - SkyboxVertex(-l, l,-l, 0, -1, 0, 1.0,0.0)) ); - meshes.back()->mMaterialIndex = static_cast(materials.size()-2u); + meshes.push_back(BuildSingleQuadMesh( + SkyboxVertex(l, l, -l, 0, -1, 0, 1.0, 1.0), + SkyboxVertex(l, l, l, 0, -1, 0, 0.0, 1.0), + SkyboxVertex(-l, l, l, 0, -1, 0, 0.0, 0.0), + SkyboxVertex(-l, l, -l, 0, -1, 0, 1.0, 0.0))); + meshes.back()->mMaterialIndex = static_cast(materials.size() - 2u); // BOTTOM SIDE - meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l,-l, l, 0, 1, 0, 0.0,0.0), - SkyboxVertex( l,-l,-l, 0, 1, 0, 1.0,0.0), - SkyboxVertex(-l,-l,-l, 0, 1, 0, 1.0,1.0), - SkyboxVertex(-l,-l, l, 0, 1, 0, 0.0,1.0)) ); - meshes.back()->mMaterialIndex = static_cast(materials.size()-1u); + meshes.push_back(BuildSingleQuadMesh( + SkyboxVertex(l, -l, l, 0, 1, 0, 0.0, 0.0), + SkyboxVertex(l, -l, -l, 0, 1, 0, 1.0, 0.0), + SkyboxVertex(-l, -l, -l, 0, 1, 0, 1.0, 1.0), + SkyboxVertex(-l, -l, l, 0, 1, 0, 0.0, 1.0))); + meshes.back()->mMaterialIndex = static_cast(materials.size() - 1u); } // ------------------------------------------------------------------------------------------------ -void IRRImporter::CopyMaterial(std::vector& materials, - std::vector< std::pair >& inmaterials, - unsigned int& defMatIdx, - aiMesh* mesh) -{ - if (inmaterials.empty()) { +void IRRImporter::CopyMaterial(std::vector &materials, + std::vector> &inmaterials, + unsigned int &defMatIdx, + aiMesh *mesh) { + if (inmaterials.empty()) { // Do we have a default material? If not we need to create one - if (UINT_MAX == defMatIdx) - { + if (UINT_MAX == defMatIdx) { defMatIdx = (unsigned int)materials.size(); //TODO: add this materials to someone? /*aiMaterial* mat = new aiMaterial(); @@ -280,8 +271,7 @@ void IRRImporter::CopyMaterial(std::vector& materials, } mesh->mMaterialIndex = defMatIdx; return; - } - else if (inmaterials.size() > 1) { + } else if (inmaterials.size() > 1) { ASSIMP_LOG_INFO("IRR: Skipping additional materials"); } @@ -289,26 +279,27 @@ void IRRImporter::CopyMaterial(std::vector& materials, materials.push_back(inmaterials[0].first); } - // ------------------------------------------------------------------------------------------------ -inline -int ClampSpline(int idx, int size) { - return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) ); +inline int ClampSpline(int idx, int size) { + return (idx < 0 ? size + idx : (idx >= size ? idx - size : idx)); } // ------------------------------------------------------------------------------------------------ -inline void FindSuitableMultiple(int& angle) -{ - if (angle < 3) angle = 3; - else if (angle < 10) angle = 10; - else if (angle < 20) angle = 20; - else if (angle < 30) angle = 30; +inline void FindSuitableMultiple(int &angle) { + if (angle < 3) + angle = 3; + else if (angle < 10) + angle = 10; + else if (angle < 20) + angle = 20; + else if (angle < 30) + angle = 30; } // ------------------------------------------------------------------------------------------------ -void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector& anims) -{ - ai_assert(nullptr != root && nullptr != real); +void IRRImporter::ComputeAnimations(Node *root, aiNode *real, std::vector &anims) { + ai_assert(nullptr != root); + ai_assert(nullptr != real); // XXX totally WIP - doesn't produce proper results, need to evaluate // whether there's any use for Irrlicht's proprietary scene format @@ -319,9 +310,9 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectoranimators.empty()) { return; } - unsigned int total( 0 ); - for (std::list::iterator it = root->animators.begin();it != root->animators.end(); ++it) { - if ((*it).type == Animator::UNKNOWN || (*it).type == Animator::OTHER) { + unsigned int total(0); + for (std::list::iterator it = root->animators.begin(); it != root->animators.end(); ++it) { + if ((*it).type == Animator::UNKNOWN || (*it).type == Animator::OTHER) { ASSIMP_LOG_WARN("IRR: Skipping unknown or unsupported animator"); continue; } @@ -329,7 +320,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector::iterator it = root->animators.begin(); - it != root->animators.end(); ++it) - { - if ((*it).type == Animator::UNKNOWN || (*it).type == Animator::OTHER)continue; + it != root->animators.end(); ++it) { + if ((*it).type == Animator::UNKNOWN || (*it).type == Animator::OTHER) continue; - Animator& in = *it ; - aiNodeAnim* anim = new aiNodeAnim(); + Animator &in = *it; + aiNodeAnim *anim = new aiNodeAnim(); - if (cur != total-1) { + if (cur != total - 1) { // Build a new name - a prefix instead of a suffix because it is // easier to check against anim->mNodeName.length = ::ai_snprintf(anim->mNodeName.data, MAXLEN, - "$INST_DUMMY_%i_%s",total-1, - (root->name.length() ? root->name.c_str() : "")); + "$INST_DUMMY_%i_%s", total - 1, + (root->name.length() ? root->name.c_str() : "")); // we'll also need to insert a dummy in the node hierarchy. - aiNode* dummy = new aiNode(); + aiNode *dummy = new aiNode(); - for (unsigned int i = 0; i < real->mParent->mNumChildren;++i) + for (unsigned int i = 0; i < real->mParent->mNumChildren; ++i) if (real->mParent->mChildren[i] == real) real->mParent->mChildren[i] = dummy; @@ -362,56 +352,54 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectormName = anim->mNodeName; dummy->mNumChildren = 1; - dummy->mChildren = new aiNode*[dummy->mNumChildren]; + dummy->mChildren = new aiNode *[dummy->mNumChildren]; dummy->mChildren[0] = real; // the transformation matrix of the dummy node is the identity real->mParent = dummy; - } - else anim->mNodeName.Set(root->name); + } else + anim->mNodeName.Set(root->name); ++cur; - switch (in.type) { - case Animator::ROTATION: - { - // ----------------------------------------------------- - // find out how long a full rotation will take - // This is the least common multiple of 360.f and all - // three euler angles. Although we'll surely find a - // possible multiple (haha) it could be somewhat large - // for our purposes. So we need to modify the angles - // here in order to get good results. - // ----------------------------------------------------- - int angles[3]; - angles[0] = (int)(in.direction.x*100); - angles[1] = (int)(in.direction.y*100); - angles[2] = (int)(in.direction.z*100); + switch (in.type) { + case Animator::ROTATION: { + // ----------------------------------------------------- + // find out how long a full rotation will take + // This is the least common multiple of 360.f and all + // three euler angles. Although we'll surely find a + // possible multiple (haha) it could be somewhat large + // for our purposes. So we need to modify the angles + // here in order to get good results. + // ----------------------------------------------------- + int angles[3]; + angles[0] = (int)(in.direction.x * 100); + angles[1] = (int)(in.direction.y * 100); + angles[2] = (int)(in.direction.z * 100); - angles[0] %= 360; - angles[1] %= 360; - angles[2] %= 360; + angles[0] %= 360; + angles[1] %= 360; + angles[2] %= 360; - if ( (angles[0]*angles[1]) != 0 && (angles[1]*angles[2]) != 0 ) - { - FindSuitableMultiple(angles[0]); - FindSuitableMultiple(angles[1]); - FindSuitableMultiple(angles[2]); - } + if ((angles[0] * angles[1]) != 0 && (angles[1] * angles[2]) != 0) { + FindSuitableMultiple(angles[0]); + FindSuitableMultiple(angles[1]); + FindSuitableMultiple(angles[2]); + } - int lcm = 360; + int lcm = 360; - if (angles[0]) - lcm = Math::lcm(lcm,angles[0]); + if (angles[0]) + lcm = Math::lcm(lcm, angles[0]); - if (angles[1]) - lcm = Math::lcm(lcm,angles[1]); + if (angles[1]) + lcm = Math::lcm(lcm, angles[1]); - if (angles[2]) - lcm = Math::lcm(lcm,angles[2]); + if (angles[2]) + lcm = Math::lcm(lcm, angles[2]); - if (360 == lcm) - break; + if (360 == lcm) + break; #if 0 // This can be a division through zero, but we don't care @@ -420,166 +408,156 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectormNumRotationKeys = (unsigned int)(max*fps); - anim->mRotationKeys = new aiQuatKey[anim->mNumRotationKeys]; + anim->mNumRotationKeys = (unsigned int)(max * fps); + anim->mRotationKeys = new aiQuatKey[anim->mNumRotationKeys]; - // begin with a zero angle - aiVector3D angle; - for (unsigned int i = 0; i < anim->mNumRotationKeys;++i) - { - // build the quaternion for the given euler angles - aiQuatKey& q = anim->mRotationKeys[i]; + // begin with a zero angle + aiVector3D angle; + for (unsigned int i = 0; i < anim->mNumRotationKeys; ++i) { + // build the quaternion for the given euler angles + aiQuatKey &q = anim->mRotationKeys[i]; - q.mValue = aiQuaternion(angle.x, angle.y, angle.z); - q.mTime = (double)i; + q.mValue = aiQuaternion(angle.x, angle.y, angle.z); + q.mTime = (double)i; - // increase the angle - angle += in.direction; - } - - // This animation is repeated and repeated ... - anim->mPostState = anim->mPreState = aiAnimBehaviour_REPEAT; + // increase the angle + angle += in.direction; } - break; - case Animator::FLY_CIRCLE: - { - // ----------------------------------------------------- - // Find out how much time we'll need to perform a - // full circle. - // ----------------------------------------------------- - const double seconds = (1. / in.speed) / 1000.; - const double tdelta = 1000. / fps; + // This animation is repeated and repeated ... + anim->mPostState = anim->mPreState = aiAnimBehaviour_REPEAT; + } break; - anim->mNumPositionKeys = (unsigned int) (fps * seconds); + case Animator::FLY_CIRCLE: { + // ----------------------------------------------------- + // Find out how much time we'll need to perform a + // full circle. + // ----------------------------------------------------- + const double seconds = (1. / in.speed) / 1000.; + const double tdelta = 1000. / fps; + + anim->mNumPositionKeys = (unsigned int)(fps * seconds); + anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; + + // from Irrlicht, what else should we do than copying it? + aiVector3D vecU, vecV; + if (in.direction.y) { + vecV = aiVector3D(50, 0, 0) ^ in.direction; + } else + vecV = aiVector3D(0, 50, 00) ^ in.direction; + vecV.Normalize(); + vecU = (vecV ^ in.direction).Normalize(); + + // build the output keys + for (unsigned int i = 0; i < anim->mNumPositionKeys; ++i) { + aiVectorKey &key = anim->mPositionKeys[i]; + key.mTime = i * tdelta; + + const ai_real t = (ai_real)(in.speed * key.mTime); + key.mValue = in.circleCenter + in.circleRadius * ((vecU * std::cos(t)) + (vecV * std::sin(t))); + } + + // This animation is repeated and repeated ... + anim->mPostState = anim->mPreState = aiAnimBehaviour_REPEAT; + } break; + + case Animator::FLY_STRAIGHT: { + anim->mPostState = anim->mPreState = (in.loop ? aiAnimBehaviour_REPEAT : aiAnimBehaviour_CONSTANT); + const double seconds = in.timeForWay / 1000.; + const double tdelta = 1000. / fps; + + anim->mNumPositionKeys = (unsigned int)(fps * seconds); + anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; + + aiVector3D diff = in.direction - in.circleCenter; + const ai_real lengthOfWay = diff.Length(); + diff.Normalize(); + + const double timeFactor = lengthOfWay / in.timeForWay; + + // build the output keys + for (unsigned int i = 0; i < anim->mNumPositionKeys; ++i) { + aiVectorKey &key = anim->mPositionKeys[i]; + key.mTime = i * tdelta; + key.mValue = in.circleCenter + diff * ai_real(timeFactor * key.mTime); + } + } break; + + case Animator::FOLLOW_SPLINE: { + // repeat outside the defined time range + anim->mPostState = anim->mPreState = aiAnimBehaviour_REPEAT; + const int size = (int)in.splineKeys.size(); + if (!size) { + // We have no point in the spline. That's bad. Really bad. + ASSIMP_LOG_WARN("IRR: Spline animators with no points defined"); + + delete anim; + anim = nullptr; + break; + } else if (size == 1) { + // We have just one point in the spline so we don't need the full calculation + anim->mNumPositionKeys = 1; anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; - // from Irrlicht, what else should we do than copying it? - aiVector3D vecU,vecV; - if (in.direction.y) { - vecV = aiVector3D(50,0,0) ^ in.direction; - } - else vecV = aiVector3D(0,50,00) ^ in.direction; - vecV.Normalize(); - vecU = (vecV ^ in.direction).Normalize(); - - // build the output keys - for (unsigned int i = 0; i < anim->mNumPositionKeys;++i) { - aiVectorKey& key = anim->mPositionKeys[i]; - key.mTime = i * tdelta; - - const ai_real t = (ai_real) ( in.speed * key.mTime ); - key.mValue = in.circleCenter + in.circleRadius * ((vecU * std::cos(t)) + (vecV * std::sin(t))); - } - - // This animation is repeated and repeated ... - anim->mPostState = anim->mPreState = aiAnimBehaviour_REPEAT; + anim->mPositionKeys[0].mValue = in.splineKeys[0].mValue; + anim->mPositionKeys[0].mTime = 0.f; + break; } - break; - case Animator::FLY_STRAIGHT: - { - anim->mPostState = anim->mPreState = (in.loop ? aiAnimBehaviour_REPEAT : aiAnimBehaviour_CONSTANT); - const double seconds = in.timeForWay / 1000.; - const double tdelta = 1000. / fps; + unsigned int ticksPerFull = 15; + anim->mNumPositionKeys = (unsigned int)(ticksPerFull * fps); + anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; - anim->mNumPositionKeys = (unsigned int) (fps * seconds); - anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; + for (unsigned int i = 0; i < anim->mNumPositionKeys; ++i) { + aiVectorKey &key = anim->mPositionKeys[i]; - aiVector3D diff = in.direction - in.circleCenter; - const ai_real lengthOfWay = diff.Length(); - diff.Normalize(); + const ai_real dt = (i * in.speed * ai_real(0.001)); + const ai_real u = dt - std::floor(dt); + const int idx = (int)std::floor(dt) % size; - const double timeFactor = lengthOfWay / in.timeForWay; + // get the 4 current points to evaluate the spline + const aiVector3D &p0 = in.splineKeys[ClampSpline(idx - 1, size)].mValue; + const aiVector3D &p1 = in.splineKeys[ClampSpline(idx + 0, size)].mValue; + const aiVector3D &p2 = in.splineKeys[ClampSpline(idx + 1, size)].mValue; + const aiVector3D &p3 = in.splineKeys[ClampSpline(idx + 2, size)].mValue; - // build the output keys - for (unsigned int i = 0; i < anim->mNumPositionKeys;++i) { - aiVectorKey& key = anim->mPositionKeys[i]; - key.mTime = i * tdelta; - key.mValue = in.circleCenter + diff * ai_real(timeFactor * key.mTime); - } + // compute polynomials + const ai_real u2 = u * u; + const ai_real u3 = u2 * 2; + + const ai_real h1 = ai_real(2.0) * u3 - ai_real(3.0) * u2 + ai_real(1.0); + const ai_real h2 = ai_real(-2.0) * u3 + ai_real(3.0) * u3; + const ai_real h3 = u3 - ai_real(2.0) * u3; + const ai_real h4 = u3 - u2; + + // compute the spline tangents + const aiVector3D t1 = (p2 - p0) * in.tightness; + aiVector3D t2 = (p3 - p1) * in.tightness; + + // and use them to get the interpolated point + t2 = (h1 * p1 + p2 * h2 + t1 * h3 + h4 * t2); + + // build a simple translation matrix from it + key.mValue = t2; + key.mTime = (double)i; } - break; - - case Animator::FOLLOW_SPLINE: - { - // repeat outside the defined time range - anim->mPostState = anim->mPreState = aiAnimBehaviour_REPEAT; - const int size = (int)in.splineKeys.size(); - if (!size) { - // We have no point in the spline. That's bad. Really bad. - ASSIMP_LOG_WARN("IRR: Spline animators with no points defined"); - - delete anim; - anim = nullptr; - break; - } - else if (size == 1) { - // We have just one point in the spline so we don't need the full calculation - anim->mNumPositionKeys = 1; - anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; - - anim->mPositionKeys[0].mValue = in.splineKeys[0].mValue; - anim->mPositionKeys[0].mTime = 0.f; - break; - } - - unsigned int ticksPerFull = 15; - anim->mNumPositionKeys = (unsigned int) ( ticksPerFull * fps ); - anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; - - for (unsigned int i = 0; i < anim->mNumPositionKeys;++i) - { - aiVectorKey& key = anim->mPositionKeys[i]; - - const ai_real dt = (i * in.speed * ai_real( 0.001 ) ); - const ai_real u = dt - std::floor(dt); - const int idx = (int)std::floor(dt) % size; - - // get the 4 current points to evaluate the spline - const aiVector3D& p0 = in.splineKeys[ ClampSpline( idx - 1, size ) ].mValue; - const aiVector3D& p1 = in.splineKeys[ ClampSpline( idx + 0, size ) ].mValue; - const aiVector3D& p2 = in.splineKeys[ ClampSpline( idx + 1, size ) ].mValue; - const aiVector3D& p3 = in.splineKeys[ ClampSpline( idx + 2, size ) ].mValue; - - // compute polynomials - const ai_real u2 = u*u; - const ai_real u3 = u2*2; - - const ai_real h1 = ai_real( 2.0 ) * u3 - ai_real( 3.0 ) * u2 + ai_real( 1.0 ); - const ai_real h2 = ai_real( -2.0 ) * u3 + ai_real( 3.0 ) * u3; - const ai_real h3 = u3 - ai_real( 2.0 ) * u3; - const ai_real h4 = u3 - u2; - - // compute the spline tangents - const aiVector3D t1 = ( p2 - p0 ) * in.tightness; - aiVector3D t2 = ( p3 - p1 ) * in.tightness; - - // and use them to get the interpolated point - t2 = (h1 * p1 + p2 * h2 + t1 * h3 + h4 * t2); - - // build a simple translation matrix from it - key.mValue = t2; - key.mTime = (double) i; - } - } - break; + } break; default: // UNKNOWN , OTHER break; }; - if (anim) { + if (anim) { anims.push_back(anim); ++total; } @@ -588,29 +566,27 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector p; - p.reserve(mat->mNumProperties+1); + std::vector p; + p.reserve(mat->mNumProperties + 1); - for (unsigned int i = 0; i < mat->mNumProperties;++i) - { - aiMaterialProperty* prop = mat->mProperties[i]; - if (!::strcmp( prop->mKey.data, "$tex.file")) { + for (unsigned int i = 0; i < mat->mNumProperties; ++i) { + aiMaterialProperty *prop = mat->mProperties[i]; + if (!::strcmp(prop->mKey.data, "$tex.file")) { // Setup the mapping key - aiMaterialProperty* m = new aiMaterialProperty(); + aiMaterialProperty *m = new aiMaterialProperty(); m->mKey.Set("$tex.mapping"); - m->mIndex = prop->mIndex; + m->mIndex = prop->mIndex; m->mSemantic = prop->mSemantic; - m->mType = aiPTI_Integer; + m->mType = aiPTI_Integer; m->mDataLength = 4; m->mData = new char[4]; - *((int*)m->mData) = mode; + *((int *)m->mData) = mode; p.push_back(prop); p.push_back(m); @@ -619,137 +595,129 @@ void SetupMapping (aiMaterial* mat, aiTextureMapping mode, const aiVector3D& axi if (mode == aiTextureMapping_CYLINDER || mode == aiTextureMapping_PLANE || mode == aiTextureMapping_SPHERE) { m = new aiMaterialProperty(); m->mKey.Set("$tex.mapaxis"); - m->mIndex = prop->mIndex; + m->mIndex = prop->mIndex; m->mSemantic = prop->mSemantic; - m->mType = aiPTI_Float; + m->mType = aiPTI_Float; m->mDataLength = 12; m->mData = new char[12]; - *((aiVector3D*)m->mData) = axis; + *((aiVector3D *)m->mData) = axis; p.push_back(m); } - } - else if (! ::strcmp( prop->mKey.data, "$tex.uvwsrc")) { + } else if (!::strcmp(prop->mKey.data, "$tex.uvwsrc")) { delete mat->mProperties[i]; - } - else p.push_back(prop); + } else + p.push_back(prop); } - if (p.empty())return; + if (p.empty()) return; // rebuild the output array - if (p.size() > mat->mNumAllocated) { + if (p.size() > mat->mNumAllocated) { delete[] mat->mProperties; - mat->mProperties = new aiMaterialProperty*[p.size()*2]; + mat->mProperties = new aiMaterialProperty *[p.size() * 2]; - mat->mNumAllocated = static_cast(p.size()*2); + mat->mNumAllocated = static_cast(p.size() * 2); } mat->mNumProperties = (unsigned int)p.size(); - ::memcpy(mat->mProperties,&p[0],sizeof(void*)*mat->mNumProperties); + ::memcpy(mat->mProperties, &p[0], sizeof(void *) * mat->mNumProperties); } // ------------------------------------------------------------------------------------------------ -void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, - BatchLoader& batch, - std::vector& meshes, - std::vector& anims, - std::vector& attach, - std::vector& materials, - unsigned int& defMatIdx) -{ +void IRRImporter::GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene, + BatchLoader &batch, + std::vector &meshes, + std::vector &anims, + std::vector &attach, + std::vector &materials, + unsigned int &defMatIdx) { unsigned int oldMeshSize = (unsigned int)meshes.size(); //unsigned int meshTrafoAssign = 0; // Now determine the type of the node - switch (root->type) - { + switch (root->type) { case Node::ANIMMESH: - case Node::MESH: - { - if (!root->meshPath.length()) - break; + case Node::MESH: { + if (!root->meshPath.length()) + break; - // Get the loaded mesh from the scene and add it to - // the list of all scenes to be attached to the - // graph we're currently building - aiScene* localScene = batch.GetImport(root->id); - if (!localScene) { - ASSIMP_LOG_ERROR("IRR: Unable to load external file: " + root->meshPath); - break; - } - attach.push_back(AttachmentInfo(localScene,rootOut)); + // Get the loaded mesh from the scene and add it to + // the list of all scenes to be attached to the + // graph we're currently building + aiScene *localScene = batch.GetImport(root->id); + if (!localScene) { + ASSIMP_LOG_ERROR("IRR: Unable to load external file: " + root->meshPath); + break; + } + attach.push_back(AttachmentInfo(localScene, rootOut)); - // Now combine the material we've loaded for this mesh - // with the real materials we got from the file. As we - // don't execute any pp-steps on the file, the numbers - // should be equal. If they are not, we can impossibly - // do this ... - if (root->materials.size() != (unsigned int)localScene->mNumMaterials) { - ASSIMP_LOG_WARN("IRR: Failed to match imported materials " - "with the materials found in the IRR scene file"); + // Now combine the material we've loaded for this mesh + // with the real materials we got from the file. As we + // don't execute any pp-steps on the file, the numbers + // should be equal. If they are not, we can impossibly + // do this ... + if (root->materials.size() != (unsigned int)localScene->mNumMaterials) { + ASSIMP_LOG_WARN("IRR: Failed to match imported materials " + "with the materials found in the IRR scene file"); - break; - } - for (unsigned int i = 0; i < localScene->mNumMaterials;++i) { - // Delete the old material, we don't need it anymore - delete localScene->mMaterials[i]; + break; + } + for (unsigned int i = 0; i < localScene->mNumMaterials; ++i) { + // Delete the old material, we don't need it anymore + delete localScene->mMaterials[i]; - std::pair& src = root->materials[i]; - localScene->mMaterials[i] = src.first; - } + std::pair &src = root->materials[i]; + localScene->mMaterials[i] = src.first; + } - // NOTE: Each mesh should have exactly one material assigned, - // but we do it in a separate loop if this behaviour changes - // in future. - for (unsigned int i = 0; i < localScene->mNumMeshes;++i) { - // Process material flags - aiMesh* mesh = localScene->mMeshes[i]; + // NOTE: Each mesh should have exactly one material assigned, + // but we do it in a separate loop if this behaviour changes + // in future. + for (unsigned int i = 0; i < localScene->mNumMeshes; ++i) { + // Process material flags + aiMesh *mesh = localScene->mMeshes[i]; + // If "trans_vertex_alpha" mode is enabled, search all vertex colors + // and check whether they have a common alpha value. This is quite + // often the case so we can simply extract it to a shared oacity + // value. + std::pair &src = root->materials[mesh->mMaterialIndex]; + aiMaterial *mat = (aiMaterial *)src.first; - // If "trans_vertex_alpha" mode is enabled, search all vertex colors - // and check whether they have a common alpha value. This is quite - // often the case so we can simply extract it to a shared oacity - // value. - std::pair& src = root->materials[mesh->mMaterialIndex]; - aiMaterial* mat = (aiMaterial*)src.first; + if (mesh->HasVertexColors(0) && src.second & AI_IRRMESH_MAT_trans_vertex_alpha) { + bool bdo = true; + for (unsigned int a = 1; a < mesh->mNumVertices; ++a) { - if (mesh->HasVertexColors(0) && src.second & AI_IRRMESH_MAT_trans_vertex_alpha) - { - bool bdo = true; - for (unsigned int a = 1; a < mesh->mNumVertices;++a) { - - if (mesh->mColors[0][a].a != mesh->mColors[0][a-1].a) { - bdo = false; - break; - } - } - if (bdo) { - ASSIMP_LOG_INFO("IRR: Replacing mesh vertex alpha with common opacity"); - - for (unsigned int a = 0; a < mesh->mNumVertices;++a) - mesh->mColors[0][a].a = 1.f; - - mat->AddProperty(& mesh->mColors[0][0].a, 1, AI_MATKEY_OPACITY); + if (mesh->mColors[0][a].a != mesh->mColors[0][a - 1].a) { + bdo = false; + break; } } + if (bdo) { + ASSIMP_LOG_INFO("IRR: Replacing mesh vertex alpha with common opacity"); - // If we have a second texture coordinate set and a second texture - // (either lightmap, normalmap, 2layered material) we need to - // setup the correct UV index for it. The texture can either - // be diffuse (lightmap & 2layer) or a normal map (normal & parallax) - if (mesh->HasTextureCoords(1)) { + for (unsigned int a = 0; a < mesh->mNumVertices; ++a) + mesh->mColors[0][a].a = 1.f; - int idx = 1; - if (src.second & (AI_IRRMESH_MAT_solid_2layer | AI_IRRMESH_MAT_lightmap)) { - mat->AddProperty(&idx,1,AI_MATKEY_UVWSRC_DIFFUSE(0)); - } - else if (src.second & AI_IRRMESH_MAT_normalmap_solid) { - mat->AddProperty(&idx,1,AI_MATKEY_UVWSRC_NORMALS(0)); - } + mat->AddProperty(&mesh->mColors[0][0].a, 1, AI_MATKEY_OPACITY); + } + } + + // If we have a second texture coordinate set and a second texture + // (either lightmap, normalmap, 2layered material) we need to + // setup the correct UV index for it. The texture can either + // be diffuse (lightmap & 2layer) or a normal map (normal & parallax) + if (mesh->HasTextureCoords(1)) { + + int idx = 1; + if (src.second & (AI_IRRMESH_MAT_solid_2layer | AI_IRRMESH_MAT_lightmap)) { + mat->AddProperty(&idx, 1, AI_MATKEY_UVWSRC_DIFFUSE(0)); + } else if (src.second & AI_IRRMESH_MAT_normalmap_solid) { + mat->AddProperty(&idx, 1, AI_MATKEY_UVWSRC_NORMALS(0)); } } } - break; + } break; case Node::LIGHT: case Node::CAMERA: @@ -757,85 +725,78 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, // We're already finished with lights and cameras break; + case Node::SPHERE: { + // Generate the sphere model. Our input parameter to + // the sphere generation algorithm is the number of + // subdivisions of each triangle - but here we have + // the number of poylgons on a specific axis. Just + // use some hardcoded limits to approximate this ... + unsigned int mul = root->spherePolyCountX * root->spherePolyCountY; + if (mul < 100) + mul = 2; + else if (mul < 300) + mul = 3; + else + mul = 4; - case Node::SPHERE: - { - // Generate the sphere model. Our input parameter to - // the sphere generation algorithm is the number of - // subdivisions of each triangle - but here we have - // the number of poylgons on a specific axis. Just - // use some hardcoded limits to approximate this ... - unsigned int mul = root->spherePolyCountX*root->spherePolyCountY; - if (mul < 100)mul = 2; - else if (mul < 300)mul = 3; - else mul = 4; - - meshes.push_back(StandardShapes::MakeMesh(mul, + meshes.push_back(StandardShapes::MakeMesh(mul, &StandardShapes::MakeSphere)); - // Adjust scaling - root->scaling *= root->sphereRadius/2; + // Adjust scaling + root->scaling *= root->sphereRadius / 2; - // Copy one output material - CopyMaterial(materials, root->materials, defMatIdx, meshes.back()); + // Copy one output material + CopyMaterial(materials, root->materials, defMatIdx, meshes.back()); - // Now adjust this output material - if there is a first texture - // set, setup spherical UV mapping around the Y axis. - SetupMapping ( (aiMaterial*) materials.back(), aiTextureMapping_SPHERE); - } - break; + // Now adjust this output material - if there is a first texture + // set, setup spherical UV mapping around the Y axis. + SetupMapping((aiMaterial *)materials.back(), aiTextureMapping_SPHERE); + } break; - case Node::CUBE: - { - // Generate an unit cube first - meshes.push_back(StandardShapes::MakeMesh( + case Node::CUBE: { + // Generate an unit cube first + meshes.push_back(StandardShapes::MakeMesh( &StandardShapes::MakeHexahedron)); - // Adjust scaling - root->scaling *= root->sphereRadius; + // Adjust scaling + root->scaling *= root->sphereRadius; - // Copy one output material - CopyMaterial(materials, root->materials, defMatIdx, meshes.back()); + // Copy one output material + CopyMaterial(materials, root->materials, defMatIdx, meshes.back()); - // Now adjust this output material - if there is a first texture - // set, setup cubic UV mapping - SetupMapping ( (aiMaterial*) materials.back(), aiTextureMapping_BOX ); + // Now adjust this output material - if there is a first texture + // set, setup cubic UV mapping + SetupMapping((aiMaterial *)materials.back(), aiTextureMapping_BOX); + } break; + + case Node::SKYBOX: { + // A skybox is defined by six materials + if (root->materials.size() < 6) { + ASSIMP_LOG_ERROR("IRR: There should be six materials for a skybox"); + break; } - break; + // copy those materials and generate 6 meshes for our new skybox + materials.reserve(materials.size() + 6); + for (unsigned int i = 0; i < 6; ++i) + materials.insert(materials.end(), root->materials[i].first); - case Node::SKYBOX: - { - // A skybox is defined by six materials - if (root->materials.size() < 6) { - ASSIMP_LOG_ERROR("IRR: There should be six materials for a skybox"); - break; - } + BuildSkybox(meshes, materials); - // copy those materials and generate 6 meshes for our new skybox - materials.reserve(materials.size() + 6); - for (unsigned int i = 0; i < 6;++i) - materials.insert(materials.end(),root->materials[i].first); + // ************************************************************* + // Skyboxes will require a different code path for rendering, + // so there must be a way for the user to add special support + // for IRR skyboxes. We add a 'IRR.SkyBox_' prefix to the node. + // ************************************************************* + root->name = "IRR.SkyBox_" + root->name; + ASSIMP_LOG_INFO("IRR: Loading skybox, this will " + "require special handling to be displayed correctly"); + } break; - BuildSkybox(meshes,materials); - - // ************************************************************* - // Skyboxes will require a different code path for rendering, - // so there must be a way for the user to add special support - // for IRR skyboxes. We add a 'IRR.SkyBox_' prefix to the node. - // ************************************************************* - root->name = "IRR.SkyBox_" + root->name; - ASSIMP_LOG_INFO("IRR: Loading skybox, this will " - "require special handling to be displayed correctly"); - } - break; - - case Node::TERRAIN: - { - // to support terrains, we'd need to have a texture decoder - ASSIMP_LOG_ERROR("IRR: Unsupported node - TERRAIN"); - } - break; + case Node::TERRAIN: { + // to support terrains, we'd need to have a texture decoder + ASSIMP_LOG_ERROR("IRR: Unsupported node - TERRAIN"); + } break; default: // DUMMY break; @@ -843,13 +804,13 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, // Check whether we added a mesh (or more than one ...). In this case // we'll also need to attach it to the node - if (oldMeshSize != (unsigned int) meshes.size()) { + if (oldMeshSize != (unsigned int)meshes.size()) { rootOut->mNumMeshes = (unsigned int)meshes.size() - oldMeshSize; - rootOut->mMeshes = new unsigned int[rootOut->mNumMeshes]; + rootOut->mMeshes = new unsigned int[rootOut->mNumMeshes]; - for (unsigned int a = 0; a < rootOut->mNumMeshes;++a) { - rootOut->mMeshes[a] = oldMeshSize+a; + for (unsigned int a = 0; a < rootOut->mNumMeshes; ++a) { + rootOut->mMeshes[a] = oldMeshSize + a; } } @@ -860,10 +821,10 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, // node from the given translation, rotation and scaling values. // (the rotation is given in Euler angles, XYZ order) //std::swap((float&)root->rotation.z,(float&)root->rotation.y); - rootOut->mTransformation.FromEulerAnglesXYZ(AI_DEG_TO_RAD(root->rotation) ); + rootOut->mTransformation.FromEulerAnglesXYZ(AI_DEG_TO_RAD(root->rotation)); // apply scaling - aiMatrix4x4& mat = rootOut->mTransformation; + aiMatrix4x4 &mat = rootOut->mTransformation; mat.a1 *= root->scaling.x; mat.b1 *= root->scaling.x; mat.c1 *= root->scaling.x; @@ -880,30 +841,29 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, mat.c4 += root->position.z; // now compute animations for the node - ComputeAnimations(root,rootOut, anims); + ComputeAnimations(root, rootOut, anims); // Add all children recursively. First allocate enough storage // for them, then call us again rootOut->mNumChildren = (unsigned int)root->children.size(); - if (rootOut->mNumChildren) { + if (rootOut->mNumChildren) { - rootOut->mChildren = new aiNode*[rootOut->mNumChildren]; - for (unsigned int i = 0; i < rootOut->mNumChildren;++i) { + rootOut->mChildren = new aiNode *[rootOut->mNumChildren]; + for (unsigned int i = 0; i < rootOut->mNumChildren; ++i) { - aiNode* node = rootOut->mChildren[i] = new aiNode(); + aiNode *node = rootOut->mChildren[i] = new aiNode(); node->mParent = rootOut; - GenerateGraph(root->children[i],node,scene,batch,meshes, - anims,attach,materials,defMatIdx); + GenerateGraph(root->children[i], node, scene, batch, meshes, + anims, attach, materials, defMatIdx); } } } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void IRRImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ - std::unique_ptr file( pIOHandler->Open( pFile)); +void IRRImporter::InternReadFile(const std::string &pFile, + aiScene *pScene, IOSystem *pIOHandler) { + std::unique_ptr file(pIOHandler->Open(pFile)); // Check whether we can read from the file if (file.get() == nullptr) { @@ -912,28 +872,28 @@ void IRRImporter::InternReadFile( const std::string& pFile, // Construct the irrXML parser CIrrXML_IOStreamReader st(file.get()); - reader = createIrrXMLReader((IFileReadCallBack*) &st); + reader = createIrrXMLReader((IFileReadCallBack *)&st); // The root node of the scene - Node* root = new Node(Node::DUMMY); + Node *root = new Node(Node::DUMMY); root->parent = nullptr; root->name = ""; // Current node parent - Node* curParent = root; + Node *curParent = root; // Scenegraph node we're currently working on - Node* curNode = nullptr; + Node *curNode = nullptr; // List of output cameras - std::vector cameras; + std::vector cameras; // List of output lights - std::vector lights; + std::vector lights; // Batch loader used to load external models BatchLoader batch(pIOHandler); -// batch.SetBasePath(pFile); + // batch.SetBasePath(pFile); cameras.reserve(5); lights.reserve(5); @@ -942,11 +902,11 @@ void IRRImporter::InternReadFile( const std::string& pFile, unsigned int guessedAnimCnt = 0, guessedMeshCnt = 0, guessedMatCnt = 0; // Parse the XML file - while (reader->read()) { - switch (reader->getNodeType()) { + while (reader->read()) { + switch (reader->getNodeType()) { case EXN_ELEMENT: - if (!ASSIMP_stricmp(reader->getNodeName(),"node")) { + if (!ASSIMP_stricmp(reader->getNodeName(), "node")) { // *********************************************************************** /* What we're going to do with the node depends * on its type: @@ -967,56 +927,46 @@ void IRRImporter::InternReadFile( const std::string& pFile, * materials assigned (except lights, cameras and dummies, of course). */ // *********************************************************************** - const char* sz = reader->getAttributeValueSafe("type"); - Node* nd; - if (!ASSIMP_stricmp(sz,"mesh") || !ASSIMP_stricmp(sz,"octTree")) { + const char *sz = reader->getAttributeValueSafe("type"); + Node *nd; + if (!ASSIMP_stricmp(sz, "mesh") || !ASSIMP_stricmp(sz, "octTree")) { // OctTree's and meshes are treated equally nd = new Node(Node::MESH); - } - else if (!ASSIMP_stricmp(sz,"cube")) { + } else if (!ASSIMP_stricmp(sz, "cube")) { nd = new Node(Node::CUBE); ++guessedMeshCnt; // meshes.push_back(StandardShapes::MakeMesh(&StandardShapes::MakeHexahedron)); - } - else if (!ASSIMP_stricmp(sz,"skybox")) { + } else if (!ASSIMP_stricmp(sz, "skybox")) { nd = new Node(Node::SKYBOX); guessedMeshCnt += 6; - } - else if (!ASSIMP_stricmp(sz,"camera")) { + } else if (!ASSIMP_stricmp(sz, "camera")) { nd = new Node(Node::CAMERA); // Setup a temporary name for the camera - aiCamera* cam = new aiCamera(); - cam->mName.Set( nd->name ); + aiCamera *cam = new aiCamera(); + cam->mName.Set(nd->name); cameras.push_back(cam); - } - else if (!ASSIMP_stricmp(sz,"light")) { + } else if (!ASSIMP_stricmp(sz, "light")) { nd = new Node(Node::LIGHT); // Setup a temporary name for the light - aiLight* cam = new aiLight(); - cam->mName.Set( nd->name ); + aiLight *cam = new aiLight(); + cam->mName.Set(nd->name); lights.push_back(cam); - } - else if (!ASSIMP_stricmp(sz,"sphere")) { + } else if (!ASSIMP_stricmp(sz, "sphere")) { nd = new Node(Node::SPHERE); ++guessedMeshCnt; - } - else if (!ASSIMP_stricmp(sz,"animatedMesh")) { + } else if (!ASSIMP_stricmp(sz, "animatedMesh")) { nd = new Node(Node::ANIMMESH); - } - else if (!ASSIMP_stricmp(sz,"empty")) { + } else if (!ASSIMP_stricmp(sz, "empty")) { nd = new Node(Node::DUMMY); - } - else if (!ASSIMP_stricmp(sz,"terrain")) { + } else if (!ASSIMP_stricmp(sz, "terrain")) { nd = new Node(Node::TERRAIN); - } - else if (!ASSIMP_stricmp(sz,"billBoard")) { + } else if (!ASSIMP_stricmp(sz, "billBoard")) { // We don't support billboards, so ignore them ASSIMP_LOG_ERROR("IRR: Billboards are not supported by Assimp"); nd = new Node(Node::DUMMY); - } - else { + } else { ASSIMP_LOG_WARN("IRR: Found unknown node: " + std::string(sz)); /* We skip the contents of nodes we don't know. @@ -1031,18 +981,15 @@ void IRRImporter::InternReadFile( const std::string& pFile, curNode = nd; nd->parent = curParent; curParent->children.push_back(nd); - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"materials")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "materials")) { inMaterials = true; - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"animators")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "animators")) { inAnimator = true; - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"attributes")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "attributes")) { /* We should have a valid node here * FIX: no ... the scene root node is also contained in an attributes block */ - if (!curNode) { + if (!curNode) { #if 0 ASSIMP_LOG_ERROR("IRR: Encountered element, but " "there is no node active"); @@ -1050,26 +997,25 @@ void IRRImporter::InternReadFile( const std::string& pFile, continue; } - Animator* curAnim = nullptr; + Animator *curAnim = nullptr; // Materials can occur for nearly any type of node - if (inMaterials && curNode->type != Node::DUMMY) { + if (inMaterials && curNode->type != Node::DUMMY) { /* This is a material description - parse it! */ - curNode->materials.push_back(std::pair< aiMaterial*, unsigned int > () ); - std::pair< aiMaterial*, unsigned int >& p = curNode->materials.back(); + curNode->materials.push_back(std::pair()); + std::pair &p = curNode->materials.back(); p.first = ParseMaterial(p.second); ++guessedMatCnt; continue; - } - else if (inAnimator) { + } else if (inAnimator) { /* This is an animation path - add a new animator * to the list. */ curNode->animators.push_back(Animator()); - curAnim = & curNode->animators.back(); + curAnim = &curNode->animators.back(); ++guessedAnimCnt; } @@ -1077,9 +1023,9 @@ void IRRImporter::InternReadFile( const std::string& pFile, /* Parse all elements in the attributes block * and process them. */ - while (reader->read()) { - if (reader->getNodeType() == EXN_ELEMENT) { - if (!ASSIMP_stricmp(reader->getNodeName(),"vector3d")) { + while (reader->read()) { + if (reader->getNodeType() == EXN_ELEMENT) { + if (!ASSIMP_stricmp(reader->getNodeName(), "vector3d")) { VectorProperty prop; ReadVectorProperty(prop); @@ -1087,185 +1033,153 @@ void IRRImporter::InternReadFile( const std::string& pFile, if (curAnim->type == Animator::ROTATION && prop.name == "Rotation") { // We store the rotation euler angles in 'direction' curAnim->direction = prop.value; - } - else if (curAnim->type == Animator::FOLLOW_SPLINE) { + } else if (curAnim->type == Animator::FOLLOW_SPLINE) { // Check whether the vector follows the PointN naming scheme, // here N is the ONE-based index of the point - if (prop.name.length() >= 6 && prop.name.substr(0,5) == "Point") { + if (prop.name.length() >= 6 && prop.name.substr(0, 5) == "Point") { // Add a new key to the list curAnim->splineKeys.push_back(aiVectorKey()); - aiVectorKey& key = curAnim->splineKeys.back(); + aiVectorKey &key = curAnim->splineKeys.back(); // and parse its properties key.mValue = prop.value; - key.mTime = strtoul10(&prop.name[5]); + key.mTime = strtoul10(&prop.name[5]); } - } - else if (curAnim->type == Animator::FLY_CIRCLE) { - if (prop.name == "Center") { + } else if (curAnim->type == Animator::FLY_CIRCLE) { + if (prop.name == "Center") { curAnim->circleCenter = prop.value; - } - else if (prop.name == "Direction") { + } else if (prop.name == "Direction") { curAnim->direction = prop.value; // From Irrlicht's source - a workaround for backward compatibility with Irrlicht 1.1 if (curAnim->direction == aiVector3D()) { - curAnim->direction = aiVector3D(0.f,1.f,0.f); - } - else curAnim->direction.Normalize(); + curAnim->direction = aiVector3D(0.f, 1.f, 0.f); + } else + curAnim->direction.Normalize(); } - } - else if (curAnim->type == Animator::FLY_STRAIGHT) { - if (prop.name == "Start") { + } else if (curAnim->type == Animator::FLY_STRAIGHT) { + if (prop.name == "Start") { // We reuse the field here curAnim->circleCenter = prop.value; - } - else if (prop.name == "End") { + } else if (prop.name == "End") { // We reuse the field here curAnim->direction = prop.value; } } - } - else { - if (prop.name == "Position") { + } else { + if (prop.name == "Position") { curNode->position = prop.value; - } - else if (prop.name == "Rotation") { + } else if (prop.name == "Rotation") { curNode->rotation = prop.value; - } - else if (prop.name == "Scale") { + } else if (prop.name == "Scale") { curNode->scaling = prop.value; - } - else if (Node::CAMERA == curNode->type) - { - aiCamera* cam = cameras.back(); - if (prop.name == "Target") { + } else if (Node::CAMERA == curNode->type) { + aiCamera *cam = cameras.back(); + if (prop.name == "Target") { cam->mLookAt = prop.value; - } - else if (prop.name == "UpVector") { + } else if (prop.name == "UpVector") { cam->mUp = prop.value; } } } - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"bool")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "bool")) { BoolProperty prop; ReadBoolProperty(prop); if (inAnimator && curAnim->type == Animator::FLY_CIRCLE && prop.name == "Loop") { curAnim->loop = prop.value; } - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"float")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "float")) { FloatProperty prop; ReadFloatProperty(prop); if (inAnimator) { // The speed property exists for several animators - if (prop.name == "Speed") { + if (prop.name == "Speed") { curAnim->speed = prop.value; - } - else if (curAnim->type == Animator::FLY_CIRCLE && prop.name == "Radius") { + } else if (curAnim->type == Animator::FLY_CIRCLE && prop.name == "Radius") { curAnim->circleRadius = prop.value; - } - else if (curAnim->type == Animator::FOLLOW_SPLINE && prop.name == "Tightness") { + } else if (curAnim->type == Animator::FOLLOW_SPLINE && prop.name == "Tightness") { curAnim->tightness = prop.value; } - } - else { - if (prop.name == "FramesPerSecond" && Node::ANIMMESH == curNode->type) { + } else { + if (prop.name == "FramesPerSecond" && Node::ANIMMESH == curNode->type) { curNode->framesPerSecond = prop.value; - } - else if (Node::CAMERA == curNode->type) { + } else if (Node::CAMERA == curNode->type) { /* This is the vertical, not the horizontal FOV. * We need to compute the right FOV from the * screen aspect which we don't know yet. */ - if (prop.name == "Fovy") { - cameras.back()->mHorizontalFOV = prop.value; - } - else if (prop.name == "Aspect") { + if (prop.name == "Fovy") { + cameras.back()->mHorizontalFOV = prop.value; + } else if (prop.name == "Aspect") { cameras.back()->mAspect = prop.value; - } - else if (prop.name == "ZNear") { + } else if (prop.name == "ZNear") { cameras.back()->mClipPlaneNear = prop.value; - } - else if (prop.name == "ZFar") { + } else if (prop.name == "ZFar") { cameras.back()->mClipPlaneFar = prop.value; } - } - else if (Node::LIGHT == curNode->type) { + } else if (Node::LIGHT == curNode->type) { /* Additional light information */ if (prop.name == "Attenuation") { - lights.back()->mAttenuationLinear = prop.value; - } - else if (prop.name == "OuterCone") { - lights.back()->mAngleOuterCone = AI_DEG_TO_RAD( prop.value ); - } - else if (prop.name == "InnerCone") { - lights.back()->mAngleInnerCone = AI_DEG_TO_RAD( prop.value ); + lights.back()->mAttenuationLinear = prop.value; + } else if (prop.name == "OuterCone") { + lights.back()->mAngleOuterCone = AI_DEG_TO_RAD(prop.value); + } else if (prop.name == "InnerCone") { + lights.back()->mAngleInnerCone = AI_DEG_TO_RAD(prop.value); } } // radius of the sphere to be generated - // or alternatively, size of the cube - else if ((Node::SPHERE == curNode->type && prop.name == "Radius") - || (Node::CUBE == curNode->type && prop.name == "Size" )) { + else if ((Node::SPHERE == curNode->type && prop.name == "Radius") || (Node::CUBE == curNode->type && prop.name == "Size")) { - curNode->sphereRadius = prop.value; + curNode->sphereRadius = prop.value; } } - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"int")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "int")) { IntProperty prop; ReadIntProperty(prop); if (inAnimator) { - if (curAnim->type == Animator::FLY_STRAIGHT && prop.name == "TimeForWay") { + if (curAnim->type == Animator::FLY_STRAIGHT && prop.name == "TimeForWay") { curAnim->timeForWay = prop.value; } - } - else { + } else { // sphere polgon numbers in each direction - if (Node::SPHERE == curNode->type) { + if (Node::SPHERE == curNode->type) { - if (prop.name == "PolyCountX") { + if (prop.name == "PolyCountX") { curNode->spherePolyCountX = prop.value; - } - else if (prop.name == "PolyCountY") { + } else if (prop.name == "PolyCountY") { curNode->spherePolyCountY = prop.value; } } } - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"string") ||!ASSIMP_stricmp(reader->getNodeName(),"enum")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "string") || !ASSIMP_stricmp(reader->getNodeName(), "enum")) { StringProperty prop; ReadStringProperty(prop); - if (prop.value.length()) { - if (prop.name == "Name") { + if (prop.value.length()) { + if (prop.name == "Name") { curNode->name = prop.value; /* If we're either a camera or a light source * we need to update the name in the aiLight/ * aiCamera structure, too. */ - if (Node::CAMERA == curNode->type) { + if (Node::CAMERA == curNode->type) { cameras.back()->mName.Set(prop.value); - } - else if (Node::LIGHT == curNode->type) { + } else if (Node::LIGHT == curNode->type) { lights.back()->mName.Set(prop.value); } - } - else if (Node::LIGHT == curNode->type && "LightType" == prop.name) - { + } else if (Node::LIGHT == curNode->type && "LightType" == prop.name) { if (prop.value == "Spot") lights.back()->mType = aiLightSource_SPOT; else if (prop.value == "Point") lights.back()->mType = aiLightSource_POINT; else if (prop.value == "Directional") lights.back()->mType = aiLightSource_DIRECTIONAL; - else - { + else { // We won't pass the validation with aiLightSourceType_UNDEFINED, // so we remove the light and replace it with a silly dummy node delete lights.back(); @@ -1274,10 +1188,8 @@ void IRRImporter::InternReadFile( const std::string& pFile, ASSIMP_LOG_ERROR("Ignoring light of unknown type: " + prop.value); } - } - else if ((prop.name == "Mesh" && Node::MESH == curNode->type) || - Node::ANIMMESH == curNode->type) - { + } else if ((prop.name == "Mesh" && Node::MESH == curNode->type) || + Node::ANIMMESH == curNode->type) { /* This is the file name of the mesh - either * animated or not. We need to make sure we setup * the correct post-processing settings here. @@ -1287,10 +1199,10 @@ void IRRImporter::InternReadFile( const std::string& pFile, /* If the mesh is a static one remove all animations from the impor data */ - if (Node::ANIMMESH != curNode->type) { + if (Node::ANIMMESH != curNode->type) { pp |= aiProcess_RemoveComponent; - SetGenericProperty(map.ints,AI_CONFIG_PP_RVC_FLAGS, - aiComponent_ANIMATIONS | aiComponent_BONEWEIGHTS); + SetGenericProperty(map.ints, AI_CONFIG_PP_RVC_FLAGS, + aiComponent_ANIMATIONS | aiComponent_BONEWEIGHTS); } /* TODO: maybe implement the protection against recursive @@ -1303,39 +1215,29 @@ void IRRImporter::InternReadFile( const std::string& pFile, const std::string extension = GetExtension(prop.value); if ("irr" == extension) { ASSIMP_LOG_ERROR("IRR: Can't load another IRR file recursively"); - } - else - { - curNode->id = batch.AddLoadRequest(prop.value,pp,&map); + } else { + curNode->id = batch.AddLoadRequest(prop.value, pp, &map); curNode->meshPath = prop.value; } - } - else if (inAnimator && prop.name == "Type") - { + } else if (inAnimator && prop.name == "Type") { // type of the animator - if (prop.value == "rotation") { + if (prop.value == "rotation") { curAnim->type = Animator::ROTATION; - } - else if (prop.value == "flyCircle") { + } else if (prop.value == "flyCircle") { curAnim->type = Animator::FLY_CIRCLE; - } - else if (prop.value == "flyStraight") { + } else if (prop.value == "flyStraight") { curAnim->type = Animator::FLY_CIRCLE; - } - else if (prop.value == "followSpline") { + } else if (prop.value == "followSpline") { curAnim->type = Animator::FOLLOW_SPLINE; - } - else { - ASSIMP_LOG_WARN("IRR: Ignoring unknown animator: " - + prop.value); + } else { + ASSIMP_LOG_WARN("IRR: Ignoring unknown animator: " + prop.value); curAnim->type = Animator::UNKNOWN; } } } } - } - else if (reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(reader->getNodeName(),"attributes")) { + } else if (reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(reader->getNodeName(), "attributes")) { break; } } @@ -1345,23 +1247,22 @@ void IRRImporter::InternReadFile( const std::string& pFile, case EXN_ELEMENT_END: // If we reached the end of a node, we need to continue processing its parent - if (!ASSIMP_stricmp(reader->getNodeName(),"node")) { - if (!curNode) { + if (!ASSIMP_stricmp(reader->getNodeName(), "node")) { + if (!curNode) { // currently is no node set. We need to go // back in the node hierarchy if (!curParent) { curParent = root; ASSIMP_LOG_ERROR("IRR: Too many closing elements"); - } - else curParent = curParent->parent; - } - else curNode = nullptr; + } else + curParent = curParent->parent; + } else + curNode = nullptr; } // clear all flags - else if (!ASSIMP_stricmp(reader->getNodeName(),"materials")) { + else if (!ASSIMP_stricmp(reader->getNodeName(), "materials")) { inMaterials = false; - } - else if (!ASSIMP_stricmp(reader->getNodeName(),"animators")) { + } else if (!ASSIMP_stricmp(reader->getNodeName(), "animators")) { inAnimator = false; } break; @@ -1375,7 +1276,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, // Now iterate through all cameras and compute their final (horizontal) FOV for (aiCamera *cam : cameras) { // screen aspect could be missing - if (cam->mAspect) { + if (cam->mAspect) { cam->mHorizontalFOV *= cam->mAspect; } else { ASSIMP_LOG_WARN("IRR: Camera aspect is not given, can't compute horizontal FOV"); @@ -1386,49 +1287,48 @@ void IRRImporter::InternReadFile( const std::string& pFile, /* Allocate a tempoary scene data structure */ - aiScene* tempScene = new aiScene(); + aiScene *tempScene = new aiScene(); tempScene->mRootNode = new aiNode(); tempScene->mRootNode->mName.Set(""); /* Copy the cameras to the output array */ - if (!cameras.empty()) { + if (!cameras.empty()) { tempScene->mNumCameras = (unsigned int)cameras.size(); - tempScene->mCameras = new aiCamera*[tempScene->mNumCameras]; - ::memcpy(tempScene->mCameras,&cameras[0],sizeof(void*)*tempScene->mNumCameras); + tempScene->mCameras = new aiCamera *[tempScene->mNumCameras]; + ::memcpy(tempScene->mCameras, &cameras[0], sizeof(void *) * tempScene->mNumCameras); } /* Copy the light sources to the output array */ - if (!lights.empty()) { + if (!lights.empty()) { tempScene->mNumLights = (unsigned int)lights.size(); - tempScene->mLights = new aiLight*[tempScene->mNumLights]; - ::memcpy(tempScene->mLights,&lights[0],sizeof(void*)*tempScene->mNumLights); + tempScene->mLights = new aiLight *[tempScene->mNumLights]; + ::memcpy(tempScene->mLights, &lights[0], sizeof(void *) * tempScene->mNumLights); } // temporary data - std::vector< aiNodeAnim*> anims; - std::vector< aiMaterial*> materials; - std::vector< AttachmentInfo > attach; - std::vector meshes; + std::vector anims; + std::vector materials; + std::vector attach; + std::vector meshes; // try to guess how much storage we'll need - anims.reserve (guessedAnimCnt + (guessedAnimCnt >> 2)); - meshes.reserve (guessedMeshCnt + (guessedMeshCnt >> 2)); - materials.reserve (guessedMatCnt + (guessedMatCnt >> 2)); + anims.reserve(guessedAnimCnt + (guessedAnimCnt >> 2)); + meshes.reserve(guessedMeshCnt + (guessedMeshCnt >> 2)); + materials.reserve(guessedMatCnt + (guessedMatCnt >> 2)); /* Now process our scenegraph recursively: generate final * meshes and generate animation channels for all nodes. */ unsigned int defMatIdx = UINT_MAX; - GenerateGraph(root,tempScene->mRootNode, tempScene, - batch, meshes, anims, attach, materials, defMatIdx); + GenerateGraph(root, tempScene->mRootNode, tempScene, + batch, meshes, anims, attach, materials, defMatIdx); - if (!anims.empty()) - { + if (!anims.empty()) { tempScene->mNumAnimations = 1; - tempScene->mAnimations = new aiAnimation*[tempScene->mNumAnimations]; - aiAnimation* an = tempScene->mAnimations[0] = new aiAnimation(); + tempScene->mAnimations = new aiAnimation *[tempScene->mNumAnimations]; + aiAnimation *an = tempScene->mAnimations[0] = new aiAnimation(); // *********************************************************** // This is only the global animation channel of the scene. @@ -1441,39 +1341,37 @@ void IRRImporter::InternReadFile( const std::string& pFile, // copy all node animation channels to the global channel an->mNumChannels = (unsigned int)anims.size(); - an->mChannels = new aiNodeAnim*[an->mNumChannels]; - ::memcpy(an->mChannels, & anims [0], sizeof(void*)*an->mNumChannels); + an->mChannels = new aiNodeAnim *[an->mNumChannels]; + ::memcpy(an->mChannels, &anims[0], sizeof(void *) * an->mNumChannels); } - if (!meshes.empty()) { + if (!meshes.empty()) { // copy all meshes to the temporary scene tempScene->mNumMeshes = (unsigned int)meshes.size(); - tempScene->mMeshes = new aiMesh*[tempScene->mNumMeshes]; - ::memcpy(tempScene->mMeshes,&meshes[0],tempScene->mNumMeshes* - sizeof(void*)); + tempScene->mMeshes = new aiMesh *[tempScene->mNumMeshes]; + ::memcpy(tempScene->mMeshes, &meshes[0], tempScene->mNumMeshes * sizeof(void *)); } /* Copy all materials to the output array */ if (!materials.empty()) { tempScene->mNumMaterials = (unsigned int)materials.size(); - tempScene->mMaterials = new aiMaterial*[tempScene->mNumMaterials]; - ::memcpy(tempScene->mMaterials,&materials[0],sizeof(void*)* - tempScene->mNumMaterials); + tempScene->mMaterials = new aiMaterial *[tempScene->mNumMaterials]; + ::memcpy(tempScene->mMaterials, &materials[0], sizeof(void *) * tempScene->mNumMaterials); } /* Now merge all sub scenes and attach them to the correct * attachment points in the scenegraph. */ - SceneCombiner::MergeScenes(&pScene,tempScene,attach, - AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | (!configSpeedFlag ? ( - AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY | AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES) : 0)); - + SceneCombiner::MergeScenes(&pScene, tempScene, attach, + AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | (!configSpeedFlag ? ( + AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY | AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES) : + 0)); /* If we have no meshes | no materials now set the INCOMPLETE * scene flag. This is necessary if we failed to load all * models from external files */ - if (!pScene->mNumMeshes || !pScene->mNumMaterials) { + if (!pScene->mNumMeshes || !pScene->mNumMaterials) { ASSIMP_LOG_WARN("IRR: No meshes loaded, setting AI_SCENE_FLAGS_INCOMPLETE"); pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; } @@ -1483,7 +1381,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, */ delete root; - delete reader; + delete reader; } #endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER diff --git a/code/AssetLib/Irr/IRRMeshLoader.cpp b/code/AssetLib/Irr/IRRMeshLoader.cpp index 13db70e91..d07ff87ea 100644 --- a/code/AssetLib/Irr/IRRMeshLoader.cpp +++ b/code/AssetLib/Irr/IRRMeshLoader.cpp @@ -139,8 +139,9 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, std::unique_ptr file( pIOHandler->Open( pFile)); // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open IRRMESH file " + pFile + ""); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open IRRMESH file " + pFile + "."); + } // Construct the irrXML parser CIrrXML_IOStreamReader st(file.get()); diff --git a/code/AssetLib/LWO/LWOAnimation.cpp b/code/AssetLib/LWO/LWOAnimation.cpp index 228dea26d..d4b69b00b 100644 --- a/code/AssetLib/LWO/LWOAnimation.cpp +++ b/code/AssetLib/LWO/LWOAnimation.cpp @@ -538,11 +538,11 @@ void AnimResolver::GetKeys(std::vector &out, // ------------------------------------------------------------------------------------------------ // Extract animation channel void AnimResolver::ExtractAnimChannel(aiNodeAnim **out, unsigned int /*= 0*/) { - *out = NULL; + *out = nullptr; //FIXME: crashes if more than one component is animated at different timings, to be resolved. - // If we have no envelopes, return NULL + // If we have no envelopes, return nullptr if (envelopes.empty()) { return; } diff --git a/code/AssetLib/LWO/LWOAnimation.h b/code/AssetLib/LWO/LWOAnimation.h index a46787965..329548ef4 100644 --- a/code/AssetLib/LWO/LWOAnimation.h +++ b/code/AssetLib/LWO/LWOAnimation.h @@ -211,7 +211,7 @@ public: // ------------------------------------------------------------------ /** @brief Extract a node animation channel * @param out Receives a pointer to a newly allocated node anim. - * If there's just one keyframe defined, *out is set to NULL and + * If there's just one keyframe defined, *out is set to nullptr and * no animation channel is computed. * @param flags Any combination of the AI_LWO_ANIM_FLAG_XXX flags. */ @@ -261,7 +261,7 @@ protected: * @param envl_y Y-component envelope * @param envl_z Z-component envelope * @param flags Any combination of the AI_LWO_ANIM_FLAG_XXX flags. - * @note Up to two input envelopes may be NULL + * @note Up to two input envelopes may be nullptr */ void GetKeys(std::vector& out, LWO::Envelope* envl_x, diff --git a/code/AssetLib/LWO/LWOBLoader.cpp b/code/AssetLib/LWO/LWOBLoader.cpp index fe542df1b..751a7c18a 100644 --- a/code/AssetLib/LWO/LWOBLoader.cpp +++ b/code/AssetLib/LWO/LWOBLoader.cpp @@ -255,7 +255,7 @@ void LWOImporter::LoadLWOBSurface(unsigned int size) mSurfaces->push_back( LWO::Surface () ); LWO::Surface& surf = mSurfaces->back(); - LWO::Texture* pTex = NULL; + LWO::Texture *pTex = nullptr; GetS0(surf.mName,size); bool running = true; diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index 7a9738228..ef11f2d15 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -422,7 +422,7 @@ void LWOImporter::InternReadFile(const std::string &pFile, // So we use a separate implementation. ComputeNormals(mesh, smoothingGroups, _mSurfaces[j]); } else { - ASSIMP_LOG_DEBUG("LWO2: No need to compute normals, they're already there"); + ASSIMP_LOG_VERBOSE_DEBUG("LWO2: No need to compute normals, they're already there"); } ++p; } @@ -917,7 +917,7 @@ inline void CreateNewEntry(std::vector &list, unsigned int srcIdx) { // ------------------------------------------------------------------------------------------------ inline void LWOImporter::DoRecursiveVMAPAssignment(VMapEntry *base, unsigned int numRead, unsigned int idx, float *data) { - ai_assert(NULL != data); + ai_assert(nullptr != data); LWO::ReferrerList &refList = mCurLayer->mPointReferrers; unsigned int i; diff --git a/code/AssetLib/LWO/LWOLoader.h b/code/AssetLib/LWO/LWOLoader.h index e9eb7ff1c..1ab85033f 100644 --- a/code/AssetLib/LWO/LWOLoader.h +++ b/code/AssetLib/LWO/LWOLoader.h @@ -305,7 +305,7 @@ private: /** Add children to a node * @param node Node to become a father * @param parent Index of the node - * @param apcNodes Flat list of nodes - used nodes are set to NULL. + * @param apcNodes Flat list of nodes - used nodes are set to nullptr. */ void AddChildren(aiNode* node, uint16_t parent, std::vector& apcNodes); diff --git a/code/AssetLib/LWO/LWOMaterial.cpp b/code/AssetLib/LWO/LWOMaterial.cpp index 65fcebddb..be2892829 100644 --- a/code/AssetLib/LWO/LWOMaterial.cpp +++ b/code/AssetLib/LWO/LWOMaterial.cpp @@ -79,7 +79,7 @@ inline aiTextureMapMode GetMapMode(LWO::Texture::Wrap in) { // ------------------------------------------------------------------------------------------------ bool LWOImporter::HandleTextures(aiMaterial *pcMat, const TextureList &in, aiTextureType type) { - ai_assert(NULL != pcMat); + ai_assert(nullptr != pcMat); unsigned int cur = 0, temp = 0; aiString s; @@ -154,7 +154,7 @@ bool LWOImporter::HandleTextures(aiMaterial *pcMat, const TextureList &in, aiTex static_assert(sizeof(aiUVTransform) / sizeof(ai_real) == 5, "sizeof(aiUVTransform)/sizeof(ai_real) == 5"); pcMat->AddProperty(&trafo, 1, AI_MATKEY_UVTRANSFORM(type, cur)); } - ASSIMP_LOG_DEBUG("LWO2: Setting up non-UV mapping"); + ASSIMP_LOG_VERBOSE_DEBUG("LWO2: Setting up non-UV mapping"); } // The older LWOB format does not use indirect references to clips. @@ -603,7 +603,7 @@ void LWOImporter::LoadLWO2TextureBlock(LE_NCONST IFF::SubChunkHeader *head, unsi } // get the destination channel - TextureList *listRef = NULL; + TextureList *listRef = nullptr; switch (tex.type) { case AI_LWO_COLR: listRef = &surf.mColorTextures; diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp index baa90d786..38b44f842 100644 --- a/code/AssetLib/LWS/LWSLoader.cpp +++ b/code/AssetLib/LWS/LWSLoader.cpp @@ -101,7 +101,7 @@ void LWS::Element::Parse(const char *&buffer) { SkipSpaces(&buffer); if (children.back().tokens[0] == "Plugin") { - ASSIMP_LOG_DEBUG("LWS: Skipping over plugin-specific data"); + ASSIMP_LOG_VERBOSE_DEBUG("LWS: Skipping over plugin-specific data"); // strange stuff inside Plugin/Endplugin blocks. Needn't // follow LWS syntax, so we skip over it @@ -342,7 +342,7 @@ void LWSImporter::BuildGraph(aiNode *nd, LWS::NodeDesc &src, std::vectormRootNode->mChildren[0]; - obj->mRootNode->mChildren[0] = NULL; + obj->mRootNode->mChildren[0] = nullptr; delete obj->mRootNode; obj->mRootNode = newRootNode; @@ -600,7 +600,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy d.number = cur_object++; } std::string path = FindLWOFile(c); - d.id = batch.AddLoadRequest(path, 0, NULL); + d.id = batch.AddLoadRequest(path, 0, nullptr); d.path = path; nodes.push_back(d); diff --git a/code/AssetLib/LWS/LWSLoader.h b/code/AssetLib/LWS/LWSLoader.h index cc181fa43..5f4cb204f 100644 --- a/code/AssetLib/LWS/LWSLoader.h +++ b/code/AssetLib/LWS/LWSLoader.h @@ -84,7 +84,19 @@ public: */ struct NodeDesc { NodeDesc() : - type(), id(), number(0), parent(0), name(""), isPivotSet(false), lightColor(1.f, 1.f, 1.f), lightIntensity(1.f), lightType(0), lightFalloffType(0), lightConeAngle(45.f), lightEdgeAngle(), parent_resolved(NULL) {} + type(), + id(), + number(0), + parent(0), + name(""), + isPivotSet(false), + lightColor(1.f, 1.f, 1.f), + lightIntensity(1.f), + lightType(0), + lightFalloffType(0), + lightConeAngle(45.f), + lightEdgeAngle(), + parent_resolved(nullptr) {} enum { diff --git a/code/AssetLib/M3D/M3DExporter.cpp b/code/AssetLib/M3D/M3DExporter.cpp index 17ba24a44..9583636a1 100644 --- a/code/AssetLib/M3D/M3DExporter.cpp +++ b/code/AssetLib/M3D/M3DExporter.cpp @@ -181,7 +181,7 @@ M3D_INDEX addMaterial(const Assimp::M3DWrapper &m3d, const aiMaterial *mat) { } m3d->material[mi].name = SafeStr(name, true); m3d->material[mi].numprop = 0; - m3d->material[mi].prop = NULL; + m3d->material[mi].prop = nullptr; // iterate through the material property table and see what we got for (k = 0; k < 15; k++) { unsigned int j; @@ -229,8 +229,8 @@ M3D_INDEX addMaterial(const Assimp::M3DWrapper &m3d, const aiMaterial *mat) { } if (aiTxProps[k].pKey && mat->GetTexture((aiTextureType)aiTxProps[k].type, - aiTxProps[k].index, &name, NULL, NULL, NULL, - NULL, NULL) == AI_SUCCESS) { + aiTxProps[k].index, &name, nullptr, nullptr, nullptr, + nullptr, nullptr) == AI_SUCCESS) { unsigned int i; for (j = name.length - 1; j > 0 && name.data[j] != '.'; j++) ; @@ -259,7 +259,7 @@ M3D_INDEX addMaterial(const Assimp::M3DWrapper &m3d, const aiMaterial *mat) { m3d->texture[i].name = fn; m3d->texture[i].w = 0; m3d->texture[i].h = 0; - m3d->texture[i].d = NULL; + m3d->texture[i].d = nullptr; } addProp(&m3d->material[mi], m3d_propertytypes[k].id + 128, i); diff --git a/code/AssetLib/M3D/M3DImporter.cpp b/code/AssetLib/M3D/M3DImporter.cpp index c69783c30..d6fe678ec 100644 --- a/code/AssetLib/M3D/M3DImporter.cpp +++ b/code/AssetLib/M3D/M3DImporter.cpp @@ -618,8 +618,10 @@ aiColor4D M3DImporter::mkColor(uint32_t c) { void M3DImporter::convertPose(const M3DWrapper &m3d, aiMatrix4x4 *m, unsigned int posid, unsigned int orientid) { ai_assert(m != nullptr); ai_assert(m3d); - ai_assert(posid != M3D_UNDEF && posid < m3d->numvertex); - ai_assert(orientid != M3D_UNDEF && orientid < m3d->numvertex); + ai_assert(posid != M3D_UNDEF); + ai_assert(posid < m3d->numvertex); + ai_assert(orientid != M3D_UNDEF); + ai_assert(orientid < m3d->numvertex); if (!m3d->numvertex || !m3d->vertex) return; m3dv_t *p = &m3d->vertex[posid]; diff --git a/code/AssetLib/M3D/M3DMaterials.h b/code/AssetLib/M3D/M3DMaterials.h index 469ddf52b..1aa6f7536 100644 --- a/code/AssetLib/M3D/M3DMaterials.h +++ b/code/AssetLib/M3D/M3DMaterials.h @@ -71,14 +71,14 @@ static const aiMatProp aiProps[] = { { AI_MATKEY_OPACITY }, /* m3dp_d */ { AI_MATKEY_SHADING_MODEL }, /* m3dp_il */ - { NULL, 0, 0 }, /* m3dp_Pr */ + { nullptr, 0, 0 }, /* m3dp_Pr */ { AI_MATKEY_REFLECTIVITY }, /* m3dp_Pm */ - { NULL, 0, 0 }, /* m3dp_Ps */ + { nullptr, 0, 0 }, /* m3dp_Ps */ { AI_MATKEY_REFRACTI }, /* m3dp_Ni */ - { NULL, 0, 0 }, /* m3dp_Nt */ - { NULL, 0, 0 }, - { NULL, 0, 0 }, - { NULL, 0, 0 } + { nullptr, 0, 0 }, /* m3dp_Nt */ + { nullptr, 0, 0 }, + { nullptr, 0, 0 }, + { nullptr, 0, 0 } }; /* --- Texture Map Properties --- !!!!! must match m3d_propertytypes !!!!! */ @@ -88,19 +88,19 @@ static const aiMatProp aiTxProps[] = { { AI_MATKEY_TEXTURE_SPECULAR(0) }, /* m3dp_map_Ks */ { AI_MATKEY_TEXTURE_SHININESS(0) }, /* m3dp_map_Ns */ { AI_MATKEY_TEXTURE_EMISSIVE(0) }, /* m3dp_map_Ke */ - { NULL, 0, 0 }, /* m3dp_map_Tf */ + { nullptr, 0, 0 }, /* m3dp_map_Tf */ { AI_MATKEY_TEXTURE_HEIGHT(0) }, /* m3dp_bump */ { AI_MATKEY_TEXTURE_OPACITY(0) }, /* m3dp_map_d */ { AI_MATKEY_TEXTURE_NORMALS(0) }, /* m3dp_map_N */ { AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE_ROUGHNESS,0) },/* m3dp_map_Pr */ { AI_MATKEY_TEXTURE(aiTextureType_METALNESS,0) }, /* m3dp_map_Pm */ - { NULL, 0, 0 }, /* m3dp_map_Ps */ + { nullptr, 0, 0 }, /* m3dp_map_Ps */ { AI_MATKEY_TEXTURE(aiTextureType_REFLECTION,0) }, /* m3dp_map_Ni */ - { NULL, 0, 0 }, /* m3dp_map_Nt */ - { NULL, 0, 0 }, - { NULL, 0, 0 }, - { NULL, 0, 0 } + { nullptr, 0, 0 }, /* m3dp_map_Nt */ + { nullptr, 0, 0 }, + { nullptr, 0, 0 }, + { nullptr, 0, 0 } }; #endif // AI_M3DMATERIALS_H_INC diff --git a/code/AssetLib/M3D/M3DWrapper.cpp b/code/AssetLib/M3D/M3DWrapper.cpp index 98792217f..b72812377 100644 --- a/code/AssetLib/M3D/M3DWrapper.cpp +++ b/code/AssetLib/M3D/M3DWrapper.cpp @@ -72,7 +72,7 @@ unsigned char *m3dimporter_readfile(char *fn, unsigned int *size) { std::unique_ptr pStream( (reinterpret_cast(m3dimporter_pIOHandler))->Open(file, "rb")); size_t fileSize = 0; - unsigned char *data = NULL; + unsigned char *data = nullptr; // sometimes pStream is nullptr in a single-threaded scenario too for some reason // (should be an empty object returning nothing I guess) if (pStream) { diff --git a/code/AssetLib/M3D/m3d.h b/code/AssetLib/M3D/m3d.h index 75bcdfeb7..3d7a2564c 100644 --- a/code/AssetLib/M3D/m3d.h +++ b/code/AssetLib/M3D/m3d.h @@ -5071,7 +5071,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size ptr += sprintf(ptr, "\r\n"); } /* mathematical shapes face */ - if (model->numshape && model->numshape && !(flags & M3D_EXP_NOFACE)) { + if (model->numshape !(flags & M3D_EXP_NOFACE)) { for (j = 0; j < model->numshape; j++) { sn = _m3d_safestr(model->shape[j].name, 0); if (!sn) { diff --git a/code/AssetLib/MD2/MD2Loader.cpp b/code/AssetLib/MD2/MD2Loader.cpp index 473ab99bc..abc5f06ff 100644 --- a/code/AssetLib/MD2/MD2Loader.cpp +++ b/code/AssetLib/MD2/MD2Loader.cpp @@ -221,20 +221,21 @@ void MD2Importer::InternReadFile( const std::string& pFile, std::unique_ptr file( pIOHandler->Open( pFile)); // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open MD2 file " + pFile + ""); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open MD2 file " + pFile + ""); + } // check whether the md3 file is large enough to contain // at least the file header fileSize = (unsigned int)file->FileSize(); - if( fileSize < sizeof(MD2::Header)) - throw DeadlyImportError( "MD2 File is too small"); + if (fileSize < sizeof(MD2::Header)) { + throw DeadlyImportError("MD2 File is too small"); + } std::vector mBuffer2(fileSize); file->Read(&mBuffer2[0], 1, fileSize); mBuffer = &mBuffer2[0]; - m_pcHeader = (BE_NCONST MD2::Header*)mBuffer; #ifdef AI_BUILD_BIG_ENDIAN diff --git a/code/AssetLib/MD3/MD3Loader.cpp b/code/AssetLib/MD3/MD3Loader.cpp index 30be0276e..92d567801 100644 --- a/code/AssetLib/MD3/MD3Loader.cpp +++ b/code/AssetLib/MD3/MD3Loader.cpp @@ -50,21 +50,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * http://www.heppler.com/shader/shader/ */ - #ifndef ASSIMP_BUILD_NO_MD3_IMPORTER #include "AssetLib/MD3/MD3Loader.h" #include "Common/Importer.h" -#include #include -#include #include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include #include @@ -86,8 +85,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Convert a Q3 shader blend function to the appropriate enum value -Q3Shader::BlendFunc StringToBlendFunc(const std::string& m) -{ +Q3Shader::BlendFunc StringToBlendFunc(const std::string &m) { if (m == "GL_ONE") { return Q3Shader::BLEND_GL_ONE; } @@ -109,9 +107,8 @@ Q3Shader::BlendFunc StringToBlendFunc(const std::string& m) // ------------------------------------------------------------------------------------------------ // Load a Quake 3 shader -bool Q3Shader::LoadShader(ShaderData& fill, const std::string& pFile,IOSystem* io) -{ - std::unique_ptr file( io->Open( pFile, "rt")); +bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *io) { + std::unique_ptr file(io->Open(pFile, "rt")); if (!file.get()) return false; // if we can't access the file, don't worry and return @@ -119,19 +116,19 @@ bool Q3Shader::LoadShader(ShaderData& fill, const std::string& pFile,IOSystem* i // read file in memory const size_t s = file->FileSize(); - std::vector _buff(s+1); - file->Read(&_buff[0],s,1); + std::vector _buff(s + 1); + file->Read(&_buff[0], s, 1); _buff[s] = 0; // remove comments from it (C++ style) - CommentRemover::RemoveLineComments("//",&_buff[0]); - const char* buff = &_buff[0]; + CommentRemover::RemoveLineComments("//", &_buff[0]); + const char *buff = &_buff[0]; - Q3Shader::ShaderDataBlock* curData = NULL; - Q3Shader::ShaderMapBlock* curMap = NULL; + Q3Shader::ShaderDataBlock *curData = nullptr; + Q3Shader::ShaderMapBlock *curMap = nullptr; // read line per line - for (;SkipSpacesAndLineEnd(&buff);SkipLine(&buff)) { + for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) { if (*buff == '{') { ++buff; @@ -143,74 +140,67 @@ bool Q3Shader::LoadShader(ShaderData& fill, const std::string& pFile,IOSystem* i } // read this data section - for (;SkipSpacesAndLineEnd(&buff);SkipLine(&buff)) { + for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) { if (*buff == '{') { ++buff; // add new map section curData->maps.push_back(Q3Shader::ShaderMapBlock()); curMap = &curData->maps.back(); - for (;SkipSpacesAndLineEnd(&buff);SkipLine(&buff)) { + for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) { // 'map' - Specifies texture file name - if (TokenMatchI(buff,"map",3) || TokenMatchI(buff,"clampmap",8)) { + if (TokenMatchI(buff, "map", 3) || TokenMatchI(buff, "clampmap", 8)) { curMap->name = GetNextToken(buff); } // 'blendfunc' - Alpha blending mode - else if (TokenMatchI(buff,"blendfunc",9)) { + else if (TokenMatchI(buff, "blendfunc", 9)) { const std::string blend_src = GetNextToken(buff); if (blend_src == "add") { - curMap->blend_src = Q3Shader::BLEND_GL_ONE; + curMap->blend_src = Q3Shader::BLEND_GL_ONE; curMap->blend_dest = Q3Shader::BLEND_GL_ONE; - } - else if (blend_src == "filter") { - curMap->blend_src = Q3Shader::BLEND_GL_DST_COLOR; + } else if (blend_src == "filter") { + curMap->blend_src = Q3Shader::BLEND_GL_DST_COLOR; curMap->blend_dest = Q3Shader::BLEND_GL_ZERO; - } - else if (blend_src == "blend") { - curMap->blend_src = Q3Shader::BLEND_GL_SRC_ALPHA; + } else if (blend_src == "blend") { + curMap->blend_src = Q3Shader::BLEND_GL_SRC_ALPHA; curMap->blend_dest = Q3Shader::BLEND_GL_ONE_MINUS_SRC_ALPHA; - } - else { - curMap->blend_src = StringToBlendFunc(blend_src); + } else { + curMap->blend_src = StringToBlendFunc(blend_src); curMap->blend_dest = StringToBlendFunc(GetNextToken(buff)); } } // 'alphafunc' - Alpha testing mode - else if (TokenMatchI(buff,"alphafunc",9)) { + else if (TokenMatchI(buff, "alphafunc", 9)) { const std::string at = GetNextToken(buff); if (at == "GT0") { curMap->alpha_test = Q3Shader::AT_GT0; - } - else if (at == "LT128") { + } else if (at == "LT128") { curMap->alpha_test = Q3Shader::AT_LT128; - } - else if (at == "GE128") { + } else if (at == "GE128") { curMap->alpha_test = Q3Shader::AT_GE128; } - } - else if (*buff == '}') { + } else if (*buff == '}') { ++buff; // close this map section - curMap = NULL; + curMap = nullptr; break; } } - } - else if (*buff == '}') { + } else if (*buff == '}') { ++buff; - curData = NULL; + curData = nullptr; break; } // 'cull' specifies culling behaviour for the model - else if (TokenMatchI(buff,"cull",4)) { + else if (TokenMatchI(buff, "cull", 4)) { SkipSpaces(&buff); - if (!ASSIMP_strincmp(buff,"back",4)) { + if (!ASSIMP_strincmp(buff, "back", 4)) { curData->cull = Q3Shader::CULL_CCW; - } else if (!ASSIMP_strincmp(buff,"front",5)) { + } else if (!ASSIMP_strincmp(buff, "front", 5)) { curData->cull = Q3Shader::CULL_CW; - } else if (!ASSIMP_strincmp(buff,"none",4) || !ASSIMP_strincmp(buff,"disable",7)) { + } else if (!ASSIMP_strincmp(buff, "none", 4) || !ASSIMP_strincmp(buff, "disable", 7)) { curData->cull = Q3Shader::CULL_NONE; } else { ASSIMP_LOG_ERROR("Q3Shader: Unrecognized cull mode"); @@ -231,9 +221,8 @@ bool Q3Shader::LoadShader(ShaderData& fill, const std::string& pFile,IOSystem* i // ------------------------------------------------------------------------------------------------ // Load a Quake 3 skin -bool Q3Shader::LoadSkin(SkinData& fill, const std::string& pFile,IOSystem* io) -{ - std::unique_ptr file( io->Open( pFile, "rt")); +bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io) { + std::unique_ptr file(io->Open(pFile, "rt")); if (!file.get()) return false; // if we can't access the file, don't worry and return @@ -241,28 +230,29 @@ bool Q3Shader::LoadSkin(SkinData& fill, const std::string& pFile,IOSystem* io) // read file in memory const size_t s = file->FileSize(); - std::vector _buff(s+1);const char* buff = &_buff[0]; - file->Read(&_buff[0],s,1); + std::vector _buff(s + 1); + const char *buff = &_buff[0]; + file->Read(&_buff[0], s, 1); _buff[s] = 0; // remove commas - std::replace(_buff.begin(),_buff.end(),',',' '); + std::replace(_buff.begin(), _buff.end(), ',', ' '); // read token by token and fill output table - for (;*buff;) { + for (; *buff;) { SkipSpacesAndLineEnd(&buff); // get first identifier std::string ss = GetNextToken(buff); // ignore tokens starting with tag_ - if (!::strncmp(&ss[0],"tag_",std::min((size_t)4, ss.length()))) + if (!::strncmp(&ss[0], "tag_", std::min((size_t)4, ss.length()))) continue; fill.textures.push_back(SkinData::TextureEntry()); SkinData::TextureEntry &entry = fill.textures.back(); - entry.first = ss; + entry.first = ss; entry.second = GetNextToken(buff); } return true; @@ -270,9 +260,8 @@ bool Q3Shader::LoadSkin(SkinData& fill, const std::string& pFile,IOSystem* io) // ------------------------------------------------------------------------------------------------ // Convert Q3Shader to material -void Q3Shader::ConvertShaderToMaterial(aiMaterial* out, const ShaderDataBlock& shader) -{ - ai_assert(NULL != out); +void Q3Shader::ConvertShaderToMaterial(aiMaterial *out, const ShaderDataBlock &shader) { + ai_assert(nullptr != out); /* IMPORTANT: This is not a real conversion. Actually we're just guessing and * hacking around to build an aiMaterial that looks nearly equal to the @@ -284,13 +273,13 @@ void Q3Shader::ConvertShaderToMaterial(aiMaterial* out, const ShaderDataBlock& s // Two-sided material? if (shader.cull == Q3Shader::CULL_NONE) { const int twosided = 1; - out->AddProperty(&twosided,1,AI_MATKEY_TWOSIDED); + out->AddProperty(&twosided, 1, AI_MATKEY_TWOSIDED); } - unsigned int cur_emissive = 0, cur_diffuse = 0, cur_lm =0; + unsigned int cur_emissive = 0, cur_diffuse = 0, cur_lm = 0; // Iterate through all textures - for (std::list< Q3Shader::ShaderMapBlock >::const_iterator it = shader.maps.begin(); it != shader.maps.end();++it) { + for (std::list::const_iterator it = shader.maps.begin(); it != shader.maps.end(); ++it) { // CONVERSION BEHAVIOUR: // @@ -309,70 +298,58 @@ void Q3Shader::ConvertShaderToMaterial(aiMaterial* out, const ShaderDataBlock& s // Textures with alpha funcs // - aiTextureFlags_UseAlpha is set (otherwise aiTextureFlags_NoAlpha is explicitly set) aiString s((*it).name); - aiTextureType type; unsigned int index; + aiTextureType type; + unsigned int index; if ((*it).blend_src == Q3Shader::BLEND_GL_ONE && (*it).blend_dest == Q3Shader::BLEND_GL_ONE) { if (it == shader.maps.begin()) { const int additive = aiBlendMode_Additive; - out->AddProperty(&additive,1,AI_MATKEY_BLEND_FUNC); + out->AddProperty(&additive, 1, AI_MATKEY_BLEND_FUNC); index = cur_diffuse++; - type = aiTextureType_DIFFUSE; - } - else { + type = aiTextureType_DIFFUSE; + } else { index = cur_emissive++; - type = aiTextureType_EMISSIVE; + type = aiTextureType_EMISSIVE; } - } - else if ((*it).blend_src == Q3Shader::BLEND_GL_DST_COLOR && (*it).blend_dest == Q3Shader::BLEND_GL_ZERO) { + } else if ((*it).blend_src == Q3Shader::BLEND_GL_DST_COLOR && (*it).blend_dest == Q3Shader::BLEND_GL_ZERO) { index = cur_lm++; - type = aiTextureType_LIGHTMAP; - } - else { + type = aiTextureType_LIGHTMAP; + } else { const int blend = aiBlendMode_Default; - out->AddProperty(&blend,1,AI_MATKEY_BLEND_FUNC); + out->AddProperty(&blend, 1, AI_MATKEY_BLEND_FUNC); index = cur_diffuse++; - type = aiTextureType_DIFFUSE; + type = aiTextureType_DIFFUSE; } // setup texture - out->AddProperty(&s,AI_MATKEY_TEXTURE(type,index)); + out->AddProperty(&s, AI_MATKEY_TEXTURE(type, index)); // setup texture flags const int use_alpha = ((*it).alpha_test != Q3Shader::AT_NONE ? aiTextureFlags_UseAlpha : aiTextureFlags_IgnoreAlpha); - out->AddProperty(&use_alpha,1,AI_MATKEY_TEXFLAGS(type,index)); + out->AddProperty(&use_alpha, 1, AI_MATKEY_TEXFLAGS(type, index)); } // If at least one emissive texture was set, set the emissive base color to 1 to ensure // the texture is actually displayed. if (0 != cur_emissive) { - aiColor3D one(1.f,1.f,1.f); - out->AddProperty(&one,1,AI_MATKEY_COLOR_EMISSIVE); + aiColor3D one(1.f, 1.f, 1.f); + out->AddProperty(&one, 1, AI_MATKEY_COLOR_EMISSIVE); } } // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -MD3Importer::MD3Importer() - : configFrameID (0) - , configHandleMP (true) - , configSpeedFlag() - , pcHeader() - , mBuffer() - , fileSize() - , mScene() - , mIOHandler() -{} +MD3Importer::MD3Importer() : + configFrameID(0), configHandleMP(true), configSpeedFlag(), pcHeader(), mBuffer(), fileSize(), mScene(), mIOHandler() {} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MD3Importer::~MD3Importer() -{} +MD3Importer::~MD3Importer() {} // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool MD3Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ +bool MD3Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { const std::string extension = GetExtension(pFile); if (extension == "md3") return true; @@ -381,55 +358,53 @@ bool MD3Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool if (!extension.length() || checkSig) { uint32_t tokens[1]; tokens[0] = AI_MD3_MAGIC_NUMBER_LE; - return CheckMagicToken(pIOHandler,pFile,tokens,1); + return CheckMagicToken(pIOHandler, pFile, tokens, 1); } return false; } // ------------------------------------------------------------------------------------------------ -void MD3Importer::ValidateHeaderOffsets() -{ +void MD3Importer::ValidateHeaderOffsets() { // Check magic number if (pcHeader->IDENT != AI_MD3_MAGIC_NUMBER_BE && - pcHeader->IDENT != AI_MD3_MAGIC_NUMBER_LE) - throw DeadlyImportError( "Invalid MD3 file: Magic bytes not found"); + pcHeader->IDENT != AI_MD3_MAGIC_NUMBER_LE) + throw DeadlyImportError("Invalid MD3 file: Magic bytes not found"); // Check file format version if (pcHeader->VERSION > 15) - ASSIMP_LOG_WARN( "Unsupported MD3 file version. Continuing happily ..."); + ASSIMP_LOG_WARN("Unsupported MD3 file version. Continuing happily ..."); // Check some offset values whether they are valid if (!pcHeader->NUM_SURFACES) - throw DeadlyImportError( "Invalid md3 file: NUM_SURFACES is 0"); + throw DeadlyImportError("Invalid md3 file: NUM_SURFACES is 0"); if (pcHeader->OFS_FRAMES >= fileSize || pcHeader->OFS_SURFACES >= fileSize || - pcHeader->OFS_EOF > fileSize) { + pcHeader->OFS_EOF > fileSize) { throw DeadlyImportError("Invalid MD3 header: some offsets are outside the file"); } - if (pcHeader->NUM_SURFACES > AI_MAX_ALLOC(MD3::Surface)) { + if (pcHeader->NUM_SURFACES > AI_MAX_ALLOC(MD3::Surface)) { throw DeadlyImportError("Invalid MD3 header: too many surfaces, would overflow"); - } + } if (pcHeader->OFS_SURFACES + pcHeader->NUM_SURFACES * sizeof(MD3::Surface) >= fileSize) { throw DeadlyImportError("Invalid MD3 header: some surfaces are outside the file"); } - if (pcHeader->NUM_FRAMES <= configFrameID ) + if (pcHeader->NUM_FRAMES <= configFrameID) throw DeadlyImportError("The requested frame is not existing the file"); } // ------------------------------------------------------------------------------------------------ -void MD3Importer::ValidateSurfaceHeaderOffsets(const MD3::Surface* pcSurf) -{ +void MD3Importer::ValidateSurfaceHeaderOffsets(const MD3::Surface *pcSurf) { // Calculate the relative offset of the surface - const int32_t ofs = int32_t((const unsigned char*)pcSurf-this->mBuffer); + const int32_t ofs = int32_t((const unsigned char *)pcSurf - this->mBuffer); // Check whether all data chunks are inside the valid range - if (pcSurf->OFS_TRIANGLES + ofs + pcSurf->NUM_TRIANGLES * sizeof(MD3::Triangle) > fileSize || - pcSurf->OFS_SHADERS + ofs + pcSurf->NUM_SHADER * sizeof(MD3::Shader) > fileSize || - pcSurf->OFS_ST + ofs + pcSurf->NUM_VERTICES * sizeof(MD3::TexCoord) > fileSize || - pcSurf->OFS_XYZNORMAL + ofs + pcSurf->NUM_VERTICES * sizeof(MD3::Vertex) > fileSize) { + if (pcSurf->OFS_TRIANGLES + ofs + pcSurf->NUM_TRIANGLES * sizeof(MD3::Triangle) > fileSize || + pcSurf->OFS_SHADERS + ofs + pcSurf->NUM_SHADER * sizeof(MD3::Shader) > fileSize || + pcSurf->OFS_ST + ofs + pcSurf->NUM_VERTICES * sizeof(MD3::TexCoord) > fileSize || + pcSurf->OFS_XYZNORMAL + ofs + pcSurf->NUM_VERTICES * sizeof(MD3::Vertex) > fileSize) { throw DeadlyImportError("Invalid MD3 surface header: some offsets are outside the file"); } @@ -454,39 +429,37 @@ void MD3Importer::ValidateSurfaceHeaderOffsets(const MD3::Surface* pcSurf) } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* MD3Importer::GetInfo () const { +const aiImporterDesc *MD3Importer::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // Setup configuration properties -void MD3Importer::SetupProperties(const Importer* pImp) -{ +void MD3Importer::SetupProperties(const Importer *pImp) { // The // AI_CONFIG_IMPORT_MD3_KEYFRAME option overrides the // AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option. - configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD3_KEYFRAME,-1); - if(static_cast(-1) == configFrameID) { - configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0); + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD3_KEYFRAME, -1); + if (static_cast(-1) == configFrameID) { + configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME, 0); } // AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART - configHandleMP = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART,1)); + configHandleMP = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 1)); // AI_CONFIG_IMPORT_MD3_SKIN_NAME - configSkinFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SKIN_NAME,"default")); + configSkinFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SKIN_NAME, "default")); // AI_CONFIG_IMPORT_MD3_SHADER_SRC - configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC,"")); + configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC, "")); // AI_CONFIG_FAVOUR_SPEED - configSpeedFlag = (0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED,0)); + configSpeedFlag = (0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED, 0)); } // ------------------------------------------------------------------------------------------------ // Try to read the skin for a MD3 file -void MD3Importer::ReadSkin(Q3Shader::SkinData& fill) const -{ +void MD3Importer::ReadSkin(Q3Shader::SkinData &fill) const { // skip any postfixes (e.g. lower_1.md3) std::string::size_type s = filename.find_last_of('_'); if (s == std::string::npos) { @@ -497,51 +470,47 @@ void MD3Importer::ReadSkin(Q3Shader::SkinData& fill) const } ai_assert(s != std::string::npos); - const std::string skin_file = path + filename.substr(0,s) + "_" + configSkinFile + ".skin"; - Q3Shader::LoadSkin(fill,skin_file,mIOHandler); + const std::string skin_file = path + filename.substr(0, s) + "_" + configSkinFile + ".skin"; + Q3Shader::LoadSkin(fill, skin_file, mIOHandler); } // ------------------------------------------------------------------------------------------------ // Try to read the shader for a MD3 file -void MD3Importer::ReadShader(Q3Shader::ShaderData& fill) const -{ +void MD3Importer::ReadShader(Q3Shader::ShaderData &fill) const { // Determine Q3 model name from given path - const std::string::size_type s = path.find_last_of("\\/",path.length()-2); - const std::string model_file = path.substr(s+1,path.length()-(s+2)); + const std::string::size_type s = path.find_last_of("\\/", path.length() - 2); + const std::string model_file = path.substr(s + 1, path.length() - (s + 2)); // If no specific dir or file is given, use our default search behaviour if (!configShaderFile.length()) { - if(!Q3Shader::LoadShader(fill,path + "..\\..\\..\\scripts\\" + model_file + ".shader",mIOHandler)) { - Q3Shader::LoadShader(fill,path + "..\\..\\..\\scripts\\" + filename + ".shader",mIOHandler); + if (!Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + model_file + ".shader", mIOHandler)) { + Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + filename + ".shader", mIOHandler); } - } - else { + } else { // If the given string specifies a file, load this file. // Otherwise it's a directory. const std::string::size_type st = configShaderFile.find_last_of('.'); if (st == std::string::npos) { - if(!Q3Shader::LoadShader(fill,configShaderFile + model_file + ".shader",mIOHandler)) { - Q3Shader::LoadShader(fill,configShaderFile + filename + ".shader",mIOHandler); + if (!Q3Shader::LoadShader(fill, configShaderFile + model_file + ".shader", mIOHandler)) { + Q3Shader::LoadShader(fill, configShaderFile + filename + ".shader", mIOHandler); } - } - else { - Q3Shader::LoadShader(fill,configShaderFile,mIOHandler); + } else { + Q3Shader::LoadShader(fill, configShaderFile, mIOHandler); } } } // ------------------------------------------------------------------------------------------------ // Tiny helper to remove a single node from its parent' list -void RemoveSingleNodeFromList(aiNode* nd) -{ - if (!nd || nd->mNumChildren || !nd->mParent)return; - aiNode* par = nd->mParent; - for (unsigned int i = 0; i < par->mNumChildren;++i) { +void RemoveSingleNodeFromList(aiNode *nd) { + if (!nd || nd->mNumChildren || !nd->mParent) return; + aiNode *par = nd->mParent; + for (unsigned int i = 0; i < par->mNumChildren; ++i) { if (par->mChildren[i] == nd) { --par->mNumChildren; - for (;i < par->mNumChildren;++i) { - par->mChildren[i] = par->mChildren[i+1]; + for (; i < par->mNumChildren; ++i) { + par->mChildren[i] = par->mChildren[i + 1]; } delete nd; break; @@ -551,8 +520,7 @@ void RemoveSingleNodeFromList(aiNode* nd) // ------------------------------------------------------------------------------------------------ // Read a multi-part Q3 player model -bool MD3Importer::ReadMultipartFile() -{ +bool MD3Importer::ReadMultipartFile() { // check whether the file name contains a common postfix, e.g lower_2.md3 std::string::size_type s = filename.find_last_of('_'), t = filename.find_last_of('.'); @@ -561,38 +529,38 @@ bool MD3Importer::ReadMultipartFile() if (s == std::string::npos) s = t; - const std::string mod_filename = filename.substr(0,s); - const std::string suffix = filename.substr(s,t-s); + const std::string mod_filename = filename.substr(0, s); + const std::string suffix = filename.substr(s, t - s); - if (mod_filename == "lower" || mod_filename == "upper" || mod_filename == "head"){ + if (mod_filename == "lower" || mod_filename == "upper" || mod_filename == "head") { const std::string lower = path + "lower" + suffix + ".md3"; const std::string upper = path + "upper" + suffix + ".md3"; - const std::string head = path + "head" + suffix + ".md3"; + const std::string head = path + "head" + suffix + ".md3"; - aiScene* scene_upper = NULL; - aiScene* scene_lower = NULL; - aiScene* scene_head = NULL; + aiScene *scene_upper = nullptr; + aiScene *scene_lower = nullptr; + aiScene *scene_head = nullptr; std::string failure; - aiNode* tag_torso, *tag_head; + aiNode *tag_torso, *tag_head; std::vector attach; ASSIMP_LOG_INFO("Multi part MD3 player model: lower, upper and head parts are joined"); // ensure we won't try to load ourselves recursively BatchLoader::PropertyMap props; - SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0); + SetGenericProperty(props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0); // now read these three files BatchLoader batch(mIOHandler); - const unsigned int _lower = batch.AddLoadRequest(lower,0,&props); - const unsigned int _upper = batch.AddLoadRequest(upper,0,&props); - const unsigned int _head = batch.AddLoadRequest(head,0,&props); + const unsigned int _lower = batch.AddLoadRequest(lower, 0, &props); + const unsigned int _upper = batch.AddLoadRequest(upper, 0, &props); + const unsigned int _head = batch.AddLoadRequest(head, 0, &props); batch.LoadAll(); // now construct a dummy scene to place these three parts in - aiScene* master = new aiScene(); - aiNode* nd = master->mRootNode = new aiNode(); + aiScene *master = new aiScene(); + aiNode *nd = master->mRootNode = new aiNode(); nd->mName.Set(""); // ... and get them. We need all of them. @@ -610,7 +578,7 @@ bool MD3Importer::ReadMultipartFile() goto error_cleanup; } - scene_head = batch.GetImport(_head); + scene_head = batch.GetImport(_head); if (!scene_head) { ASSIMP_LOG_ERROR("M3D: Failed to read multi part model, head.md3 fails to load"); failure = "head"; @@ -630,43 +598,43 @@ bool MD3Importer::ReadMultipartFile() goto error_cleanup; } scene_upper->mRootNode->mName.Set("upper"); - attach.push_back(AttachmentInfo(scene_upper,tag_torso)); + attach.push_back(AttachmentInfo(scene_upper, tag_torso)); // tag_head tag_head = scene_upper->mRootNode->FindNode("tag_head"); if (!tag_head) { - ASSIMP_LOG_ERROR( "M3D: Failed to find attachment tag for multi part model: tag_head expected"); + ASSIMP_LOG_ERROR("M3D: Failed to find attachment tag for multi part model: tag_head expected"); goto error_cleanup; } scene_head->mRootNode->mName.Set("head"); - attach.push_back(AttachmentInfo(scene_head,tag_head)); + attach.push_back(AttachmentInfo(scene_head, tag_head)); // Remove tag_head and tag_torso from all other model parts ... // this ensures (together with AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) // that tag_torso/tag_head is also the name of the (unique) output node - RemoveSingleNodeFromList (scene_upper->mRootNode->FindNode("tag_torso")); - RemoveSingleNodeFromList (scene_head-> mRootNode->FindNode("tag_head" )); + RemoveSingleNodeFromList(scene_upper->mRootNode->FindNode("tag_torso")); + RemoveSingleNodeFromList(scene_head->mRootNode->FindNode("tag_head")); // Undo the rotations which we applied to the coordinate systems. We're // working in global Quake space here - scene_head->mRootNode->mTransformation = aiMatrix4x4(); + scene_head->mRootNode->mTransformation = aiMatrix4x4(); scene_lower->mRootNode->mTransformation = aiMatrix4x4(); scene_upper->mRootNode->mTransformation = aiMatrix4x4(); // and merge the scenes - SceneCombiner::MergeScenes(&mScene,master, attach, - AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | - AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES | - AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS | - (!configSpeedFlag ? AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY : 0)); + SceneCombiner::MergeScenes(&mScene, master, attach, + AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | + AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES | + AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS | + (!configSpeedFlag ? AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY : 0)); // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system - mScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f, - 0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f); + mScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f); return true; -error_cleanup: + error_cleanup: delete scene_upper; delete scene_lower; delete scene_head; @@ -681,36 +649,35 @@ error_cleanup: // ------------------------------------------------------------------------------------------------ // Convert a MD3 path to a proper value -void MD3Importer::ConvertPath(const char* texture_name, const char* header_name, std::string& out) const -{ +void MD3Importer::ConvertPath(const char *texture_name, const char *header_name, std::string &out) const { // If the MD3's internal path itself and the given path are using // the same directory, remove it completely to get right output paths. - const char* end1 = ::strrchr(header_name,'\\'); - if (!end1)end1 = ::strrchr(header_name,'/'); + const char *end1 = ::strrchr(header_name, '\\'); + if (!end1) end1 = ::strrchr(header_name, '/'); - const char* end2 = ::strrchr(texture_name,'\\'); - if (!end2)end2 = ::strrchr(texture_name,'/'); + const char *end2 = ::strrchr(texture_name, '\\'); + if (!end2) end2 = ::strrchr(texture_name, '/'); // HACK: If the paths starts with "models", ignore the // next two hierarchy levels, it specifies just the model name. // Ignored by Q3, it might be not equal to the real model location. - if (end2) { + if (end2) { size_t len2; const size_t len1 = (size_t)(end1 - header_name); - if (!ASSIMP_strincmp(texture_name,"models",6) && (texture_name[6] == '/' || texture_name[6] == '\\')) { + if (!ASSIMP_strincmp(texture_name, "models", 6) && (texture_name[6] == '/' || texture_name[6] == '\\')) { len2 = 6; // ignore the seventh - could be slash or backslash if (!header_name[0]) { // Use the file name only - out = end2+1; + out = end2 + 1; return; } - } - else len2 = std::min (len1, (size_t)(end2 - texture_name )); - if (!ASSIMP_strincmp(texture_name,header_name,static_cast(len2))) { + } else + len2 = std::min(len1, (size_t)(end2 - texture_name)); + if (!ASSIMP_strincmp(texture_name, header_name, static_cast(len2))) { // Use the file name only - out = end2+1; + out = end2 + 1; return; } } @@ -720,7 +687,7 @@ void MD3Importer::ConvertPath(const char* texture_name, const char* header_name, // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { +void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { mFile = pFile; mScene = pScene; mIOHandler = pIOHandler; @@ -735,7 +702,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS } filename = mFile.substr(s), path = mFile.substr(0, s); for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) { - *it = static_cast( tolower(*it) ); + *it = static_cast(tolower(*it)); } // Load multi-part model file, if necessary @@ -744,23 +711,24 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS return; } - std::unique_ptr file( pIOHandler->Open( pFile)); + std::unique_ptr file(pIOHandler->Open(pFile)); // Check whether we can read from the file - if( file.get() == NULL) - throw DeadlyImportError( "Failed to open MD3 file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open MD3 file " + pFile + "."); + } // Check whether the md3 file is large enough to contain the header fileSize = (unsigned int)file->FileSize(); - if( fileSize < sizeof(MD3::Header)) - throw DeadlyImportError( "MD3 File is too small."); + if (fileSize < sizeof(MD3::Header)) + throw DeadlyImportError("MD3 File is too small."); // Allocate storage and copy the contents of the file to a memory buffer - std::vector mBuffer2 (fileSize); - file->Read( &mBuffer2[0], 1, fileSize); + std::vector mBuffer2(fileSize); + file->Read(&mBuffer2[0], 1, fileSize); mBuffer = &mBuffer2[0]; - pcHeader = (BE_NCONST MD3::Header*)mBuffer; + pcHeader = (BE_NCONST MD3::Header *)mBuffer; // Ensure correct endianness #ifdef AI_BUILD_BIG_ENDIAN @@ -783,10 +751,10 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS ValidateHeaderOffsets(); // Navigate to the list of surfaces - BE_NCONST MD3::Surface* pcSurfaces = (BE_NCONST MD3::Surface*)(mBuffer + pcHeader->OFS_SURFACES); + BE_NCONST MD3::Surface *pcSurfaces = (BE_NCONST MD3::Surface *)(mBuffer + pcHeader->OFS_SURFACES); // Navigate to the list of tags - BE_NCONST MD3::Tag* pcTags = (BE_NCONST MD3::Tag*)(mBuffer + pcHeader->OFS_TAGS); + BE_NCONST MD3::Tag *pcTags = (BE_NCONST MD3::Tag *)(mBuffer + pcHeader->OFS_TAGS); // Allocate output storage pScene->mNumMeshes = pcHeader->NUM_SURFACES; @@ -797,14 +765,14 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // since those pointers will eventually have to point to real objects throw DeadlyImportError("MD3: Too many surfaces, would run out of memory"); } - pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; + pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]; pScene->mNumMaterials = pcHeader->NUM_SURFACES; - pScene->mMaterials = new aiMaterial*[pScene->mNumMeshes]; + pScene->mMaterials = new aiMaterial *[pScene->mNumMeshes]; // Set arrays to zero to ensue proper destruction if an exception is raised - ::memset(pScene->mMeshes,0,pScene->mNumMeshes*sizeof(aiMesh*)); - ::memset(pScene->mMaterials,0,pScene->mNumMaterials*sizeof(aiMaterial*)); + ::memset(pScene->mMeshes, 0, pScene->mNumMeshes * sizeof(aiMesh *)); + ::memset(pScene->mMaterials, 0, pScene->mNumMaterials * sizeof(aiMaterial *)); // Now read possible skins from .skin file Q3Shader::SkinData skins; @@ -815,13 +783,13 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS ReadShader(shaders); // Adjust all texture paths in the shader - const char* header_name = pcHeader->NAME; + const char *header_name = pcHeader->NAME; if (!shaders.blocks.empty()) { - for (std::list< Q3Shader::ShaderDataBlock >::iterator dit = shaders.blocks.begin(); dit != shaders.blocks.end(); ++dit) { - ConvertPath((*dit).name.c_str(),header_name,(*dit).name); + for (std::list::iterator dit = shaders.blocks.begin(); dit != shaders.blocks.end(); ++dit) { + ConvertPath((*dit).name.c_str(), header_name, (*dit).name); - for (std::list< Q3Shader::ShaderMapBlock >::iterator mit = (*dit).maps.begin(); mit != (*dit).maps.end(); ++mit) { - ConvertPath((*mit).name.c_str(),header_name,(*mit).name); + for (std::list::iterator mit = (*dit).maps.begin(); mit != (*dit).maps.end(); ++mit) { + ConvertPath((*mit).name.c_str(), header_name, (*mit).name); } } } @@ -829,7 +797,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // Read all surfaces from the file unsigned int iNum = pcHeader->NUM_SURFACES; unsigned int iNumMaterials = 0; - while (iNum-- > 0) { + while (iNum-- > 0) { // Ensure correct endianness #ifdef AI_BUILD_BIG_ENDIAN @@ -852,57 +820,52 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS ValidateSurfaceHeaderOffsets(pcSurfaces); // Navigate to the vertex list of the surface - BE_NCONST MD3::Vertex* pcVertices = (BE_NCONST MD3::Vertex*) - (((uint8_t*)pcSurfaces) + pcSurfaces->OFS_XYZNORMAL); + BE_NCONST MD3::Vertex *pcVertices = (BE_NCONST MD3::Vertex *)(((uint8_t *)pcSurfaces) + pcSurfaces->OFS_XYZNORMAL); // Navigate to the triangle list of the surface - BE_NCONST MD3::Triangle* pcTriangles = (BE_NCONST MD3::Triangle*) - (((uint8_t*)pcSurfaces) + pcSurfaces->OFS_TRIANGLES); + BE_NCONST MD3::Triangle *pcTriangles = (BE_NCONST MD3::Triangle *)(((uint8_t *)pcSurfaces) + pcSurfaces->OFS_TRIANGLES); // Navigate to the texture coordinate list of the surface - BE_NCONST MD3::TexCoord* pcUVs = (BE_NCONST MD3::TexCoord*) - (((uint8_t*)pcSurfaces) + pcSurfaces->OFS_ST); + BE_NCONST MD3::TexCoord *pcUVs = (BE_NCONST MD3::TexCoord *)(((uint8_t *)pcSurfaces) + pcSurfaces->OFS_ST); // Navigate to the shader list of the surface - BE_NCONST MD3::Shader* pcShaders = (BE_NCONST MD3::Shader*) - (((uint8_t*)pcSurfaces) + pcSurfaces->OFS_SHADERS); + BE_NCONST MD3::Shader *pcShaders = (BE_NCONST MD3::Shader *)(((uint8_t *)pcSurfaces) + pcSurfaces->OFS_SHADERS); // If the submesh is empty ignore it - if (0 == pcSurfaces->NUM_VERTICES || 0 == pcSurfaces->NUM_TRIANGLES) - { - pcSurfaces = (BE_NCONST MD3::Surface*)(((uint8_t*)pcSurfaces) + pcSurfaces->OFS_END); + if (0 == pcSurfaces->NUM_VERTICES || 0 == pcSurfaces->NUM_TRIANGLES) { + pcSurfaces = (BE_NCONST MD3::Surface *)(((uint8_t *)pcSurfaces) + pcSurfaces->OFS_END); pScene->mNumMeshes--; continue; } // Allocate output mesh pScene->mMeshes[iNum] = new aiMesh(); - aiMesh* pcMesh = pScene->mMeshes[iNum]; + aiMesh *pcMesh = pScene->mMeshes[iNum]; std::string _texture_name; - const char* texture_name = NULL; + const char *texture_name = nullptr; // Check whether we have a texture record for this surface in the .skin file - std::list< Q3Shader::SkinData::TextureEntry >::iterator it = std::find( - skins.textures.begin(), skins.textures.end(), pcSurfaces->NAME ); + std::list::iterator it = std::find( + skins.textures.begin(), skins.textures.end(), pcSurfaces->NAME); if (it != skins.textures.end()) { - texture_name = &*( _texture_name = (*it).second).begin(); - ASSIMP_LOG_DEBUG_F("MD3: Assigning skin texture ", (*it).second, " to surface ", pcSurfaces->NAME); + texture_name = &*(_texture_name = (*it).second).begin(); + ASSIMP_LOG_VERBOSE_DEBUG_F("MD3: Assigning skin texture ", (*it).second, " to surface ", pcSurfaces->NAME); (*it).resolved = true; // mark entry as resolved } // Get the first shader (= texture?) assigned to the surface - if (!texture_name && pcSurfaces->NUM_SHADER) { + if (!texture_name && pcSurfaces->NUM_SHADER) { texture_name = pcShaders->NAME; } std::string convertedPath; if (texture_name) { - ConvertPath(texture_name,header_name,convertedPath); + ConvertPath(texture_name, header_name, convertedPath); } - const Q3Shader::ShaderDataBlock* shader = NULL; + const Q3Shader::ShaderDataBlock *shader = nullptr; // Now search the current shader for a record with this name ( // excluding texture file extension) @@ -912,18 +875,18 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS sh = convertedPath.length(); } - const std::string without_ext = convertedPath.substr(0,sh); - std::list< Q3Shader::ShaderDataBlock >::const_iterator dit = std::find(shaders.blocks.begin(),shaders.blocks.end(),without_ext); + const std::string without_ext = convertedPath.substr(0, sh); + std::list::const_iterator dit = std::find(shaders.blocks.begin(), shaders.blocks.end(), without_ext); if (dit != shaders.blocks.end()) { // We made it! shader = &*dit; - ASSIMP_LOG_INFO("Found shader record for " +without_ext ); + ASSIMP_LOG_INFO("Found shader record for " + without_ext); } else { ASSIMP_LOG_WARN("Unable to find shader record for " + without_ext); } } - aiMaterial* pcHelper = new aiMaterial(); + aiMaterial *pcHelper = new aiMaterial(); const int iMode = (int)aiShadingMode_Gouraud; pcHelper->AddProperty(&iMode, 1, AI_MATKEY_SHADING_MODEL); @@ -931,51 +894,51 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // Add a small ambient color value - Quake 3 seems to have one aiColor3D clr; clr.b = clr.g = clr.r = 0.05f; - pcHelper->AddProperty(&clr, 1,AI_MATKEY_COLOR_AMBIENT); + pcHelper->AddProperty(&clr, 1, AI_MATKEY_COLOR_AMBIENT); clr.b = clr.g = clr.r = 1.0f; - pcHelper->AddProperty(&clr, 1,AI_MATKEY_COLOR_DIFFUSE); - pcHelper->AddProperty(&clr, 1,AI_MATKEY_COLOR_SPECULAR); + pcHelper->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE); + pcHelper->AddProperty(&clr, 1, AI_MATKEY_COLOR_SPECULAR); // use surface name + skin_name as material name aiString name; name.Set("MD3_[" + configSkinFile + "][" + pcSurfaces->NAME + "]"); - pcHelper->AddProperty(&name,AI_MATKEY_NAME); + pcHelper->AddProperty(&name, AI_MATKEY_NAME); if (!shader) { // Setup dummy texture file name to ensure UV coordinates are kept during postprocessing aiString szString; if (convertedPath.length()) { szString.Set(convertedPath); - } else { + } else { ASSIMP_LOG_WARN("Texture file name has zero length. Using default name"); szString.Set("dummy_texture.bmp"); } - pcHelper->AddProperty(&szString,AI_MATKEY_TEXTURE_DIFFUSE(0)); + pcHelper->AddProperty(&szString, AI_MATKEY_TEXTURE_DIFFUSE(0)); // prevent transparency by default int no_alpha = aiTextureFlags_IgnoreAlpha; - pcHelper->AddProperty(&no_alpha,1,AI_MATKEY_TEXFLAGS_DIFFUSE(0)); + pcHelper->AddProperty(&no_alpha, 1, AI_MATKEY_TEXFLAGS_DIFFUSE(0)); } else { - Q3Shader::ConvertShaderToMaterial(pcHelper,*shader); + Q3Shader::ConvertShaderToMaterial(pcHelper, *shader); } - pScene->mMaterials[iNumMaterials] = (aiMaterial*)pcHelper; + pScene->mMaterials[iNumMaterials] = (aiMaterial *)pcHelper; pcMesh->mMaterialIndex = iNumMaterials++; - // Ensure correct endianness + // Ensure correct endianness #ifdef AI_BUILD_BIG_ENDIAN - for (uint32_t i = 0; i < pcSurfaces->NUM_VERTICES;++i) { - AI_SWAP2( pcVertices[i].NORMAL ); - AI_SWAP2( pcVertices[i].X ); - AI_SWAP2( pcVertices[i].Y ); - AI_SWAP2( pcVertices[i].Z ); + for (uint32_t i = 0; i < pcSurfaces->NUM_VERTICES; ++i) { + AI_SWAP2(pcVertices[i].NORMAL); + AI_SWAP2(pcVertices[i].X); + AI_SWAP2(pcVertices[i].Y); + AI_SWAP2(pcVertices[i].Z); - AI_SWAP4( pcUVs[i].U ); - AI_SWAP4( pcUVs[i].V ); + AI_SWAP4(pcUVs[i].U); + AI_SWAP4(pcUVs[i].V); } - for (uint32_t i = 0; i < pcSurfaces->NUM_TRIANGLES;++i) { + for (uint32_t i = 0; i < pcSurfaces->NUM_TRIANGLES; ++i) { AI_SWAP4(pcTriangles[i].INDEXES[0]); AI_SWAP4(pcTriangles[i].INDEXES[1]); AI_SWAP4(pcTriangles[i].INDEXES[2]); @@ -986,56 +949,56 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // Fill mesh information pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - pcMesh->mNumVertices = pcSurfaces->NUM_TRIANGLES*3; - pcMesh->mNumFaces = pcSurfaces->NUM_TRIANGLES; - pcMesh->mFaces = new aiFace[pcSurfaces->NUM_TRIANGLES]; - pcMesh->mNormals = new aiVector3D[pcMesh->mNumVertices]; - pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices]; - pcMesh->mTextureCoords[0] = new aiVector3D[pcMesh->mNumVertices]; + pcMesh->mNumVertices = pcSurfaces->NUM_TRIANGLES * 3; + pcMesh->mNumFaces = pcSurfaces->NUM_TRIANGLES; + pcMesh->mFaces = new aiFace[pcSurfaces->NUM_TRIANGLES]; + pcMesh->mNormals = new aiVector3D[pcMesh->mNumVertices]; + pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices]; + pcMesh->mTextureCoords[0] = new aiVector3D[pcMesh->mNumVertices]; pcMesh->mNumUVComponents[0] = 2; // Fill in all triangles unsigned int iCurrent = 0; - for (unsigned int i = 0; i < (unsigned int)pcSurfaces->NUM_TRIANGLES;++i) { + for (unsigned int i = 0; i < (unsigned int)pcSurfaces->NUM_TRIANGLES; ++i) { pcMesh->mFaces[i].mIndices = new unsigned int[3]; pcMesh->mFaces[i].mNumIndices = 3; //unsigned int iTemp = iCurrent; - for (unsigned int c = 0; c < 3;++c,++iCurrent) { + for (unsigned int c = 0; c < 3; ++c, ++iCurrent) { pcMesh->mFaces[i].mIndices[c] = iCurrent; // Read vertices - aiVector3D& vec = pcMesh->mVertices[iCurrent]; + aiVector3D &vec = pcMesh->mVertices[iCurrent]; uint32_t index = pcTriangles->INDEXES[c]; if (index >= pcSurfaces->NUM_VERTICES) { - throw DeadlyImportError( "MD3: Invalid vertex index"); + throw DeadlyImportError("MD3: Invalid vertex index"); } - vec.x = pcVertices[index].X*AI_MD3_XYZ_SCALE; - vec.y = pcVertices[index].Y*AI_MD3_XYZ_SCALE; - vec.z = pcVertices[index].Z*AI_MD3_XYZ_SCALE; + vec.x = pcVertices[index].X * AI_MD3_XYZ_SCALE; + vec.y = pcVertices[index].Y * AI_MD3_XYZ_SCALE; + vec.z = pcVertices[index].Z * AI_MD3_XYZ_SCALE; // Convert the normal vector to uncompressed float3 format - aiVector3D& nor = pcMesh->mNormals[iCurrent]; - LatLngNormalToVec3(pcVertices[index].NORMAL,(ai_real*)&nor); + aiVector3D &nor = pcMesh->mNormals[iCurrent]; + LatLngNormalToVec3(pcVertices[index].NORMAL, (ai_real *)&nor); // Read texture coordinates pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[index].U; - pcMesh->mTextureCoords[0][iCurrent].y = 1.0f-pcUVs[index].V; + pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[index].V; } // Flip face order if necessary if (!shader || shader->cull == Q3Shader::CULL_CW) { - std::swap(pcMesh->mFaces[i].mIndices[2],pcMesh->mFaces[i].mIndices[1]); + std::swap(pcMesh->mFaces[i].mIndices[2], pcMesh->mFaces[i].mIndices[1]); } ++pcTriangles; } // Go to the next surface - pcSurfaces = (BE_NCONST MD3::Surface*)(((unsigned char*)pcSurfaces) + pcSurfaces->OFS_END); + pcSurfaces = (BE_NCONST MD3::Surface *)(((unsigned char *)pcSurfaces) + pcSurfaces->OFS_END); } // For debugging purposes: check whether we found matches for all entries in the skins file if (!DefaultLogger::isNullLogger()) { - for (std::list< Q3Shader::SkinData::TextureEntry>::const_iterator it = skins.textures.begin();it != skins.textures.end(); ++it) { + for (std::list::const_iterator it = skins.textures.begin(); it != skins.textures.end(); ++it) { if (!(*it).resolved) { ASSIMP_LOG_ERROR_F("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second); } @@ -1043,7 +1006,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS } if (!pScene->mNumMeshes) { - throw DeadlyImportError( "MD3: File contains no valid mesh"); + throw DeadlyImportError("MD3: File contains no valid mesh"); } pScene->mNumMaterials = iNumMaterials; @@ -1055,11 +1018,11 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // Attach tiny children for all tags if (pcHeader->NUM_TAGS) { pScene->mRootNode->mNumChildren = pcHeader->NUM_TAGS; - pScene->mRootNode->mChildren = new aiNode*[pcHeader->NUM_TAGS]; + pScene->mRootNode->mChildren = new aiNode *[pcHeader->NUM_TAGS]; for (unsigned int i = 0; i < pcHeader->NUM_TAGS; ++i, ++pcTags) { - aiNode* nd = pScene->mRootNode->mChildren[i] = new aiNode(); - nd->mName.Set((const char*)pcTags->NAME); + aiNode *nd = pScene->mRootNode->mChildren[i] = new aiNode(); + nd->mName.Set((const char *)pcTags->NAME); nd->mParent = pScene->mRootNode; AI_SWAP4(pcTags->origin.x); @@ -1072,8 +1035,8 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS nd->mTransformation.c4 = pcTags->origin.z; // Copy rest of transformation (need to transpose to match row-order matrix) - for (unsigned int a = 0; a < 3;++a) { - for (unsigned int m = 0; m < 3;++m) { + for (unsigned int a = 0; a < 3; ++a) { + for (unsigned int m = 0; m < 3; ++m) { nd->mTransformation[m][a] = pcTags->orientation[a][m]; AI_SWAP4(nd->mTransformation[m][a]); } @@ -1081,16 +1044,15 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOS } } - for (unsigned int i = 0; i < pScene->mNumMeshes;++i) + for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) pScene->mRootNode->mMeshes[i] = i; // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system pScene->mRootNode->mTransformation = aiMatrix4x4( - 1.f,0.f,0.f,0.f, - 0.f,0.f,1.f,0.f, - 0.f,-1.f,0.f,0.f, - 0.f,0.f,0.f,1.f - ); + 1.f, 0.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, -1.f, 0.f, 0.f, + 0.f, 0.f, 0.f, 1.f); } #endif // !! ASSIMP_BUILD_NO_MD3_IMPORTER diff --git a/code/AssetLib/MD5/MD5Loader.cpp b/code/AssetLib/MD5/MD5Loader.cpp index d428873df..5428a9c74 100644 --- a/code/AssetLib/MD5/MD5Loader.cpp +++ b/code/AssetLib/MD5/MD5Loader.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -82,7 +80,15 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer MD5Importer::MD5Importer() : - mIOHandler(nullptr), mBuffer(), fileSize(), iLineNumber(), pScene(), bHadMD5Mesh(), bHadMD5Anim(), bHadMD5Camera(), configNoAutoLoad(false) { + mIOHandler(nullptr), + mBuffer(), + mFileSize(), + mLineNumber(), + mScene(), + mHadMD5Mesh(), + mHadMD5Anim(), + mHadMD5Camera(), + mCconfigNoAutoLoad(false) { // empty } @@ -106,6 +112,7 @@ bool MD5Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c const char *tokens[] = { "MD5Version" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); } + return false; } @@ -119,16 +126,15 @@ const aiImporterDesc *MD5Importer::GetInfo() const { // Setup import properties void MD5Importer::SetupProperties(const Importer *pImp) { // AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD - configNoAutoLoad = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD, 0)); + mCconfigNoAutoLoad = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD, 0)); } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void MD5Importer::InternReadFile(const std::string &pFile, - aiScene *_pScene, IOSystem *pIOHandler) { +void MD5Importer::InternReadFile(const std::string &pFile, aiScene *_pScene, IOSystem *pIOHandler) { mIOHandler = pIOHandler; - pScene = _pScene; - bHadMD5Mesh = bHadMD5Anim = bHadMD5Camera = false; + mScene = _pScene; + mHadMD5Mesh = mHadMD5Anim = mHadMD5Camera = false; // remove the file extension const std::string::size_type pos = pFile.find_last_of('.'); @@ -138,7 +144,7 @@ void MD5Importer::InternReadFile(const std::string &pFile, try { if (extension == "md5camera") { LoadMD5CameraFile(); - } else if (configNoAutoLoad || extension == "md5anim") { + } else if (mCconfigNoAutoLoad || extension == "md5anim") { // determine file extension and process just *one* file if (extension.length() == 0) { throw DeadlyImportError("Failure, need file extension to determine MD5 part type"); @@ -158,17 +164,17 @@ void MD5Importer::InternReadFile(const std::string &pFile, } // make sure we have at least one file - if (!bHadMD5Mesh && !bHadMD5Anim && !bHadMD5Camera) { + if (!mHadMD5Mesh && !mHadMD5Anim && !mHadMD5Camera) { throw DeadlyImportError("Failed to read valid contents out of this MD5* file"); } // Now rotate the whole scene 90 degrees around the x axis to match our internal coordinate system - pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f, + mScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f); // the output scene wouldn't pass the validation without this flag - if (!bHadMD5Mesh) { - pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; + if (!mHadMD5Mesh) { + mScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; } // clean the instance -- the BaseImporter instance may be reused later. @@ -181,17 +187,17 @@ void MD5Importer::LoadFileIntoMemory(IOStream *file) { // unload the previous buffer, if any UnloadFileFromMemory(); - ai_assert(NULL != file); - fileSize = (unsigned int)file->FileSize(); - ai_assert(fileSize); + ai_assert(nullptr != file); + mFileSize = (unsigned int)file->FileSize(); + ai_assert(mFileSize); // allocate storage and copy the contents of the file to a memory buffer - mBuffer = new char[fileSize + 1]; - file->Read((void *)mBuffer, 1, fileSize); - iLineNumber = 1; + mBuffer = new char[mFileSize + 1]; + file->Read((void *)mBuffer, 1, mFileSize); + mLineNumber = 1; // append a terminal 0 - mBuffer[fileSize] = '\0'; + mBuffer[mFileSize] = '\0'; // now remove all line comments from the file CommentRemover::RemoveLineComments("//", mBuffer, ' '); @@ -202,8 +208,8 @@ void MD5Importer::LoadFileIntoMemory(IOStream *file) { void MD5Importer::UnloadFileFromMemory() { // delete the file buffer delete[] mBuffer; - mBuffer = NULL; - fileSize = 0; + mBuffer = nullptr; + mFileSize = 0; } // ------------------------------------------------------------------------------------------------ @@ -243,7 +249,8 @@ void MD5Importer::MakeDataUnique(MD5::MeshDesc &meshSrc) { // ------------------------------------------------------------------------------------------------ // Recursive node graph construction from a MD5MESH void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &bones) { - ai_assert(NULL != piParent && !piParent->mNumChildren); + ai_assert(nullptr != piParent); + ai_assert(!piParent->mNumChildren); // First find out how many children we'll have for (int i = 0; i < (int)bones.size(); ++i) { @@ -293,7 +300,8 @@ void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &b // ------------------------------------------------------------------------------------------------ // Recursive node graph construction from a MD5ANIM void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneList &bones, const aiNodeAnim **node_anims) { - ai_assert(NULL != piParent && !piParent->mNumChildren); + ai_assert(nullptr != piParent); + ai_assert(!piParent->mNumChildren); // First find out how many children we'll have for (int i = 0; i < (int)bones.size(); ++i) { @@ -332,37 +340,37 @@ void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneLis // ------------------------------------------------------------------------------------------------ // Load a MD5MESH file void MD5Importer::LoadMD5MeshFile() { - std::string pFile = mFile + "md5mesh"; - std::unique_ptr file(mIOHandler->Open(pFile, "rb")); + std::string filename = mFile + "md5mesh"; + std::unique_ptr file(mIOHandler->Open(filename, "rb")); // Check whether we can read from the file if (file.get() == nullptr || !file->FileSize()) { - ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + pFile); + ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + filename); return; } - bHadMD5Mesh = true; + mHadMD5Mesh = true; LoadFileIntoMemory(file.get()); // now construct a parser and parse the file - MD5::MD5Parser parser(mBuffer, fileSize); + MD5::MD5Parser parser(mBuffer, mFileSize); // load the mesh information from it MD5::MD5MeshParser meshParser(parser.mSections); // create the bone hierarchy - first the root node and dummy nodes for all meshes - pScene->mRootNode = new aiNode(""); - pScene->mRootNode->mNumChildren = 2; - pScene->mRootNode->mChildren = new aiNode *[2]; + mScene->mRootNode = new aiNode(""); + mScene->mRootNode->mNumChildren = 2; + mScene->mRootNode->mChildren = new aiNode *[2]; // build the hierarchy from the MD5MESH file - aiNode *pcNode = pScene->mRootNode->mChildren[1] = new aiNode(); + aiNode *pcNode = mScene->mRootNode->mChildren[1] = new aiNode(); pcNode->mName.Set(""); - pcNode->mParent = pScene->mRootNode; + pcNode->mParent = mScene->mRootNode; AttachChilds_Mesh(-1, pcNode, meshParser.mJoints); - pcNode = pScene->mRootNode->mChildren[0] = new aiNode(); + pcNode = mScene->mRootNode->mChildren[0] = new aiNode(); pcNode->mName.Set(""); - pcNode->mParent = pScene->mRootNode; + pcNode->mParent = mScene->mRootNode; #if 0 if (pScene->mRootNode->mChildren[1]->mNumChildren) /* start at the right hierarchy level */ @@ -371,28 +379,31 @@ void MD5Importer::LoadMD5MeshFile() { // FIX: MD5 files exported from Blender can have empty meshes for (std::vector::const_iterator it = meshParser.mMeshes.begin(), end = meshParser.mMeshes.end(); it != end; ++it) { - if (!(*it).mFaces.empty() && !(*it).mVertices.empty()) - ++pScene->mNumMaterials; + if (!(*it).mFaces.empty() && !(*it).mVertices.empty()) { + ++mScene->mNumMaterials; + } } // generate all meshes - pScene->mNumMeshes = pScene->mNumMaterials; - pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]; - pScene->mMaterials = new aiMaterial *[pScene->mNumMeshes]; + mScene->mNumMeshes = mScene->mNumMaterials; + mScene->mMeshes = new aiMesh *[mScene->mNumMeshes]; + mScene->mMaterials = new aiMaterial *[mScene->mNumMeshes]; // storage for node mesh indices - pcNode->mNumMeshes = pScene->mNumMeshes; + pcNode->mNumMeshes = mScene->mNumMeshes; pcNode->mMeshes = new unsigned int[pcNode->mNumMeshes]; - for (unsigned int m = 0; m < pcNode->mNumMeshes; ++m) + for (unsigned int m = 0; m < pcNode->mNumMeshes; ++m) { pcNode->mMeshes[m] = m; + } unsigned int n = 0; for (std::vector::iterator it = meshParser.mMeshes.begin(), end = meshParser.mMeshes.end(); it != end; ++it) { MD5::MeshDesc &meshSrc = *it; - if (meshSrc.mFaces.empty() || meshSrc.mVertices.empty()) + if (meshSrc.mFaces.empty() || meshSrc.mVertices.empty()) { continue; + } - aiMesh *mesh = pScene->mMeshes[n] = new aiMesh(); + aiMesh *mesh = mScene->mMeshes[n] = new aiMesh(); mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; // generate unique vertices in our internal verbose format @@ -422,17 +433,19 @@ void MD5Importer::LoadMD5MeshFile() { for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) { MD5::WeightDesc &weightDesc = meshSrc.mWeights[w]; /* FIX for some invalid exporters */ - if (!(weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON)) + if (!(weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON)) { ++piCount[weightDesc.mBone]; + } } } // check how many we will need - for (unsigned int p = 0; p < meshParser.mJoints.size(); ++p) + for (unsigned int p = 0; p < meshParser.mJoints.size(); ++p) { if (piCount[p]) mesh->mNumBones++; + } - if (mesh->mNumBones) // just for safety - { + // just for safety + if (mesh->mNumBones) { mesh->mBones = new aiBone *[mesh->mNumBones]; for (unsigned int q = 0, h = 0; q < meshParser.mJoints.size(); ++q) { if (!piCount[q]) continue; @@ -457,8 +470,9 @@ void MD5Importer::LoadMD5MeshFile() { // there are models which have weights which don't sum to 1 ... ai_real fSum = 0.0; - for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) + for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) { fSum += meshSrc.mWeights[w].mWeight; + } if (!fSum) { ASSIMP_LOG_ERROR("MD5MESH: The sum of all vertex bone weights is 0"); continue; @@ -466,11 +480,12 @@ void MD5Importer::LoadMD5MeshFile() { // process bone weights for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) { - if (w >= meshSrc.mWeights.size()) + if (w >= meshSrc.mWeights.size()) { throw DeadlyImportError("MD5MESH: Invalid weight index"); + } MD5::WeightDesc &weightDesc = meshSrc.mWeights[w]; - if (weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON) { + if (weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON) { continue; } @@ -504,12 +519,12 @@ void MD5Importer::LoadMD5MeshFile() { for (unsigned int c = 0; c < mesh->mNumFaces; ++c) { mesh->mFaces[c].mNumIndices = 3; mesh->mFaces[c].mIndices = meshSrc.mFaces[c].mIndices; - meshSrc.mFaces[c].mIndices = NULL; + meshSrc.mFaces[c].mIndices = nullptr; } // generate a material for the mesh aiMaterial *mat = new aiMaterial(); - pScene->mMaterials[n] = mat; + mScene->mMaterials[n] = mat; // insert the typical doom3 textures: // nnn_local.tga - normal map @@ -555,10 +570,11 @@ void MD5Importer::LoadMD5AnimFile() { ASSIMP_LOG_WARN("Failed to read MD5ANIM file: " + pFile); return; } + LoadFileIntoMemory(file.get()); // parse the basic file structure - MD5::MD5Parser parser(mBuffer, fileSize); + MD5::MD5Parser parser(mBuffer, mFileSize); // load the animation information from the parse tree MD5::MD5AnimParser animParser(parser.mSections); @@ -568,10 +584,10 @@ void MD5Importer::LoadMD5AnimFile() { animParser.mBaseFrames.size() != animParser.mAnimatedBones.size()) { ASSIMP_LOG_ERROR("MD5ANIM: No frames or animated bones loaded"); } else { - bHadMD5Anim = true; + mHadMD5Anim = true; - pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations = 1]; - aiAnimation *anim = pScene->mAnimations[0] = new aiAnimation(); + mScene->mAnimations = new aiAnimation *[mScene->mNumAnimations = 1]; + aiAnimation *anim = mScene->mAnimations[0] = new aiAnimation(); anim->mNumChannels = (unsigned int)animParser.mAnimatedBones.size(); anim->mChannels = new aiNodeAnim *[anim->mNumChannels]; for (unsigned int i = 0; i < anim->mNumChannels; ++i) { @@ -637,15 +653,15 @@ void MD5Importer::LoadMD5AnimFile() { // If we didn't build the hierarchy yet (== we didn't load a MD5MESH), // construct it now from the data given in the MD5ANIM. - if (!pScene->mRootNode) { - pScene->mRootNode = new aiNode(); - pScene->mRootNode->mName.Set(""); + if (!mScene->mRootNode) { + mScene->mRootNode = new aiNode(); + mScene->mRootNode->mName.Set(""); - AttachChilds_Anim(-1, pScene->mRootNode, animParser.mAnimatedBones, (const aiNodeAnim **)anim->mChannels); + AttachChilds_Anim(-1, mScene->mRootNode, animParser.mAnimatedBones, (const aiNodeAnim **)anim->mChannels); // Call SkeletonMeshBuilder to construct a mesh to represent the shape - if (pScene->mRootNode->mNumChildren) { - SkeletonMeshBuilder skeleton_maker(pScene, pScene->mRootNode->mChildren[0]); + if (mScene->mRootNode->mNumChildren) { + SkeletonMeshBuilder skeleton_maker(mScene, mScene->mRootNode->mChildren[0]); } } } @@ -661,11 +677,11 @@ void MD5Importer::LoadMD5CameraFile() { if (!file.get() || !file->FileSize()) { throw DeadlyImportError("Failed to read MD5CAMERA file: " + pFile); } - bHadMD5Camera = true; + mHadMD5Camera = true; LoadFileIntoMemory(file.get()); // parse the basic file structure - MD5::MD5Parser parser(mBuffer, fileSize); + MD5::MD5Parser parser(mBuffer, mFileSize); // load the camera animation data from the parse tree MD5::MD5CameraParser cameraParser(parser.mSections); @@ -679,14 +695,14 @@ void MD5Importer::LoadMD5CameraFile() { // Construct output graph - a simple root with a dummy child. // The root node performs the coordinate system conversion - aiNode *root = pScene->mRootNode = new aiNode(""); + aiNode *root = mScene->mRootNode = new aiNode(""); root->mChildren = new aiNode *[root->mNumChildren = 1]; root->mChildren[0] = new aiNode(""); root->mChildren[0]->mParent = root; // ... but with one camera assigned to it - pScene->mCameras = new aiCamera *[pScene->mNumCameras = 1]; - aiCamera *cam = pScene->mCameras[0] = new aiCamera(); + mScene->mCameras = new aiCamera *[mScene->mNumCameras = 1]; + aiCamera *cam = mScene->mCameras[0] = new aiCamera(); cam->mName = ""; // FIXME: Fov is currently set to the first frame's value @@ -703,8 +719,8 @@ void MD5Importer::LoadMD5CameraFile() { cuts.push_back(static_cast(frames.size() - 1)); } - pScene->mNumAnimations = static_cast(cuts.size() - 1); - aiAnimation **tmp = pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations]; + mScene->mNumAnimations = static_cast(cuts.size() - 1); + aiAnimation **tmp = mScene->mAnimations = new aiAnimation *[mScene->mNumAnimations]; for (std::vector::const_iterator it = cuts.begin(); it != cuts.end() - 1; ++it) { aiAnimation *anim = *tmp++ = new aiAnimation(); diff --git a/code/AssetLib/MD5/MD5Loader.h b/code/AssetLib/MD5/MD5Loader.h index cfdd9ed0e..f62a57e68 100644 --- a/code/AssetLib/MD5/MD5Loader.h +++ b/code/AssetLib/MD5/MD5Loader.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -156,25 +155,25 @@ protected: char *mBuffer; /** Size of the file */ - unsigned int fileSize; + unsigned int mFileSize; /** Current line number. For debugging purposes */ - unsigned int iLineNumber; + unsigned int mLineNumber; /** Scene to be filled */ - aiScene *pScene; + aiScene *mScene; /** true if a MD5MESH file has already been parsed */ - bool bHadMD5Mesh; + bool mHadMD5Mesh; /** true if a MD5ANIM file has already been parsed */ - bool bHadMD5Anim; + bool mHadMD5Anim; /** true if a MD5CAMERA file has already been parsed */ - bool bHadMD5Camera; + bool mHadMD5Camera; /** configuration option: prevent anim autoload */ - bool configNoAutoLoad; + bool mCconfigNoAutoLoad; }; } // end of namespace Assimp diff --git a/code/AssetLib/MD5/MD5Parser.cpp b/code/AssetLib/MD5/MD5Parser.cpp index e2f697816..345f0e10c 100644 --- a/code/AssetLib/MD5/MD5Parser.cpp +++ b/code/AssetLib/MD5/MD5Parser.cpp @@ -45,25 +45,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of the MD5 parser class */ - // internal headers #include "AssetLib/MD5/MD5Loader.h" #include "Material/MaterialSystem.h" -#include #include #include -#include +#include #include +#include using namespace Assimp; using namespace Assimp::MD5; // ------------------------------------------------------------------------------------------------ // Parse the segment structure fo a MD5 file -MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize ) -{ - ai_assert(NULL != _buffer && 0 != _fileSize); +MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) { + ai_assert(nullptr != _buffer); + ai_assert(0 != _fileSize); buffer = _buffer; fileSize = _fileSize; @@ -78,48 +77,45 @@ MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize ) bool running = true; while (running) { mSections.push_back(Section()); - Section& sec = mSections.back(); - if(!ParseSection(sec)) { + Section &sec = mSections.back(); + if (!ParseSection(sec)) { break; } } - if ( !DefaultLogger::isNullLogger()) { + if (!DefaultLogger::isNullLogger()) { char szBuffer[128]; // should be sufficiently large - ::ai_snprintf(szBuffer,128,"MD5Parser end. Parsed %i sections",(int)mSections.size()); + ::ai_snprintf(szBuffer, 128, "MD5Parser end. Parsed %i sections", (int)mSections.size()); ASSIMP_LOG_DEBUG(szBuffer); } } // ------------------------------------------------------------------------------------------------ // Report error to the log stream -/*static*/ AI_WONT_RETURN void MD5Parser::ReportError (const char* error, unsigned int line) -{ +/*static*/ AI_WONT_RETURN void MD5Parser::ReportError(const char *error, unsigned int line) { char szBuffer[1024]; - ::ai_snprintf(szBuffer, 1024, "[MD5] Line %u: %s",line,error); + ::ai_snprintf(szBuffer, 1024, "[MD5] Line %u: %s", line, error); throw DeadlyImportError(szBuffer); } // ------------------------------------------------------------------------------------------------ // Report warning to the log stream -/*static*/ void MD5Parser::ReportWarning (const char* warn, unsigned int line) -{ +/*static*/ void MD5Parser::ReportWarning(const char *warn, unsigned int line) { char szBuffer[1024]; - ::sprintf(szBuffer,"[MD5] Line %u: %s",line,warn); + ::sprintf(szBuffer, "[MD5] Line %u: %s", line, warn); ASSIMP_LOG_WARN(szBuffer); } // ------------------------------------------------------------------------------------------------ // Parse and validate the MD5 header -void MD5Parser::ParseHeader() -{ +void MD5Parser::ParseHeader() { // parse and validate the file version SkipSpaces(); - if (!TokenMatch(buffer,"MD5Version",10)) { + if (!TokenMatch(buffer, "MD5Version", 10)) { ReportError("Invalid MD5 file: MD5Version tag has not been found"); } SkipSpaces(); - unsigned int iVer = ::strtoul10(buffer,(const char**)&buffer); + unsigned int iVer = ::strtoul10(buffer, (const char **)&buffer); if (10 != iVer) { ReportError("MD5 version tag is unknown (10 is expected)"); } @@ -127,23 +123,24 @@ void MD5Parser::ParseHeader() // print the command line options to the console // FIX: can break the log length limit, so we need to be careful - char* sz = buffer; - while (!IsLineEnd( *buffer++)); - ASSIMP_LOG_INFO(std::string(sz,std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer-sz)))); + char *sz = buffer; + while (!IsLineEnd(*buffer++)) + ; + ASSIMP_LOG_INFO(std::string(sz, std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer - sz)))); SkipSpacesAndLineEnd(); } // ------------------------------------------------------------------------------------------------ // Recursive MD5 parsing function -bool MD5Parser::ParseSection(Section& out) -{ +bool MD5Parser::ParseSection(Section &out) { // store the current line number for use in error messages out.iLineNumber = lineNumber; // first parse the name of the section - char* sz = buffer; - while (!IsSpaceOrNewLine( *buffer))buffer++; - out.mName = std::string(sz,(uintptr_t)(buffer-sz)); + char *sz = buffer; + while (!IsSpaceOrNewLine(*buffer)) + buffer++; + out.mName = std::string(sz, (uintptr_t)(buffer - sz)); SkipSpaces(); bool running = true; @@ -152,8 +149,7 @@ bool MD5Parser::ParseSection(Section& out) // it is a normal section so read all lines buffer++; bool run = true; - while (run) - { + while (run) { if (!SkipSpacesAndLineEnd()) { return false; // seems this was the last section } @@ -163,25 +159,26 @@ bool MD5Parser::ParseSection(Section& out) } out.mElements.push_back(Element()); - Element& elem = out.mElements.back(); + Element &elem = out.mElements.back(); elem.iLineNumber = lineNumber; elem.szStart = buffer; // terminate the line with zero - while (!IsLineEnd( *buffer))buffer++; + while (!IsLineEnd(*buffer)) + buffer++; if (*buffer) { ++lineNumber; *buffer++ = '\0'; } } break; - } - else if (!IsSpaceOrNewLine(*buffer)) { + } else if (!IsSpaceOrNewLine(*buffer)) { // it is an element at global scope. Parse its value and go on sz = buffer; - while (!IsSpaceOrNewLine( *buffer++)); - out.mGlobalValue = std::string(sz,(uintptr_t)(buffer-sz)); + while (!IsSpaceOrNewLine(*buffer++)) + ; + out.mGlobalValue = std::string(sz, (uintptr_t)(buffer - sz)); continue; } break; @@ -193,161 +190,161 @@ bool MD5Parser::ParseSection(Section& out) // Some dirty macros just because they're so funny and easy to debug // skip all spaces ... handle EOL correctly -#define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \ - MD5Parser::ReportWarning("Unexpected end of line",elem.iLineNumber); +#define AI_MD5_SKIP_SPACES() \ + if (!SkipSpaces(&sz)) \ + MD5Parser::ReportWarning("Unexpected end of line", elem.iLineNumber); - // read a triple float in brackets: (1.0 1.0 1.0) -#define AI_MD5_READ_TRIPLE(vec) \ - AI_MD5_SKIP_SPACES(); \ - if ('(' != *sz++) \ - MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber); \ - AI_MD5_SKIP_SPACES(); \ - sz = fast_atoreal_move(sz,(float&)vec.x); \ - AI_MD5_SKIP_SPACES(); \ - sz = fast_atoreal_move(sz,(float&)vec.y); \ - AI_MD5_SKIP_SPACES(); \ - sz = fast_atoreal_move(sz,(float&)vec.z); \ - AI_MD5_SKIP_SPACES(); \ - if (')' != *sz++) \ - MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber); +// read a triple float in brackets: (1.0 1.0 1.0) +#define AI_MD5_READ_TRIPLE(vec) \ + AI_MD5_SKIP_SPACES(); \ + if ('(' != *sz++) \ + MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber); \ + AI_MD5_SKIP_SPACES(); \ + sz = fast_atoreal_move(sz, (float &)vec.x); \ + AI_MD5_SKIP_SPACES(); \ + sz = fast_atoreal_move(sz, (float &)vec.y); \ + AI_MD5_SKIP_SPACES(); \ + sz = fast_atoreal_move(sz, (float &)vec.z); \ + AI_MD5_SKIP_SPACES(); \ + if (')' != *sz++) \ + MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber); - // parse a string, enclosed in quotation marks or not -#define AI_MD5_PARSE_STRING(out) \ - bool bQuota = (*sz == '\"'); \ - const char* szStart = sz; \ - while (!IsSpaceOrNewLine(*sz))++sz; \ - const char* szEnd = sz; \ - if (bQuota) { \ - szStart++; \ - if ('\"' != *(szEnd-=1)) { \ +// parse a string, enclosed in quotation marks or not +#define AI_MD5_PARSE_STRING(out) \ + bool bQuota = (*sz == '\"'); \ + const char *szStart = sz; \ + while (!IsSpaceOrNewLine(*sz)) \ + ++sz; \ + const char *szEnd = sz; \ + if (bQuota) { \ + szStart++; \ + if ('\"' != *(szEnd -= 1)) { \ MD5Parser::ReportWarning("Expected closing quotation marks in string", \ - elem.iLineNumber); \ - continue; \ - } \ - } \ - out.length = (size_t)(szEnd - szStart); \ - ::memcpy(out.data,szStart,out.length); \ + elem.iLineNumber); \ + continue; \ + } \ + } \ + out.length = (size_t)(szEnd - szStart); \ + ::memcpy(out.data, szStart, out.length); \ out.data[out.length] = '\0'; - // parse a string, enclosed in quotation marks -#define AI_MD5_PARSE_STRING_IN_QUOTATION(out) \ - while('\"'!=*sz)++sz; \ - const char* szStart = ++sz; \ - while('\"'!=*sz)++sz; \ - const char* szEnd = (sz++); \ - out.length = (ai_uint32) (szEnd - szStart); \ - ::memcpy(out.data,szStart,out.length); \ +// parse a string, enclosed in quotation marks +#define AI_MD5_PARSE_STRING_IN_QUOTATION(out) \ + while ('\"' != *sz) \ + ++sz; \ + const char *szStart = ++sz; \ + while ('\"' != *sz) \ + ++sz; \ + const char *szEnd = (sz++); \ + out.length = (ai_uint32)(szEnd - szStart); \ + ::memcpy(out.data, szStart, out.length); \ out.data[out.length] = '\0'; // ------------------------------------------------------------------------------------------------ // .MD5MESH parsing function -MD5MeshParser::MD5MeshParser(SectionList& mSections) -{ +MD5MeshParser::MD5MeshParser(SectionList &mSections) { ASSIMP_LOG_DEBUG("MD5MeshParser begin"); // now parse all sections - for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter){ - if ( (*iter).mName == "numMeshes") { + for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) { + if ((*iter).mName == "numMeshes") { mMeshes.reserve(::strtoul10((*iter).mGlobalValue.c_str())); - } - else if ( (*iter).mName == "numJoints") { + } else if ((*iter).mName == "numJoints") { mJoints.reserve(::strtoul10((*iter).mGlobalValue.c_str())); - } - else if ((*iter).mName == "joints") { + } else if ((*iter).mName == "joints") { // "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 ) - for (const auto & elem : (*iter).mElements){ + for (const auto &elem : (*iter).mElements) { mJoints.push_back(BoneDesc()); - BoneDesc& desc = mJoints.back(); - - const char* sz = elem.szStart; - AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName); + BoneDesc &desc = mJoints.back(); + + const char *sz = elem.szStart; + AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName); AI_MD5_SKIP_SPACES(); // negative values, at least -1, is allowed here - desc.mParentIndex = (int)strtol10(sz,&sz); + desc.mParentIndex = (int)strtol10(sz, &sz); AI_MD5_READ_TRIPLE(desc.mPositionXYZ); AI_MD5_READ_TRIPLE(desc.mRotationQuat); // normalized quaternion, so w is not there } - } - else if ((*iter).mName == "mesh") { + } else if ((*iter).mName == "mesh") { mMeshes.push_back(MeshDesc()); - MeshDesc& desc = mMeshes.back(); + MeshDesc &desc = mMeshes.back(); - for (const auto & elem : (*iter).mElements){ - const char* sz = elem.szStart; + for (const auto &elem : (*iter).mElements) { + const char *sz = elem.szStart; // shader attribute - if (TokenMatch(sz,"shader",6)) { + if (TokenMatch(sz, "shader", 6)) { AI_MD5_SKIP_SPACES(); AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader); } // numverts attribute - else if (TokenMatch(sz,"numverts",8)) { + else if (TokenMatch(sz, "numverts", 8)) { AI_MD5_SKIP_SPACES(); desc.mVertices.resize(strtoul10(sz)); } // numtris attribute - else if (TokenMatch(sz,"numtris",7)) { + else if (TokenMatch(sz, "numtris", 7)) { AI_MD5_SKIP_SPACES(); desc.mFaces.resize(strtoul10(sz)); } // numweights attribute - else if (TokenMatch(sz,"numweights",10)) { + else if (TokenMatch(sz, "numweights", 10)) { AI_MD5_SKIP_SPACES(); desc.mWeights.resize(strtoul10(sz)); } // vert attribute // "vert 0 ( 0.394531 0.513672 ) 0 1" - else if (TokenMatch(sz,"vert",4)) { + else if (TokenMatch(sz, "vert", 4)) { AI_MD5_SKIP_SPACES(); - const unsigned int idx = ::strtoul10(sz,&sz); + const unsigned int idx = ::strtoul10(sz, &sz); AI_MD5_SKIP_SPACES(); if (idx >= desc.mVertices.size()) - desc.mVertices.resize(idx+1); + desc.mVertices.resize(idx + 1); - VertexDesc& vert = desc.mVertices[idx]; + VertexDesc &vert = desc.mVertices[idx]; if ('(' != *sz++) - MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber); + MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber); AI_MD5_SKIP_SPACES(); - sz = fast_atoreal_move(sz,(float&)vert.mUV.x); + sz = fast_atoreal_move(sz, (float &)vert.mUV.x); AI_MD5_SKIP_SPACES(); - sz = fast_atoreal_move(sz,(float&)vert.mUV.y); + sz = fast_atoreal_move(sz, (float &)vert.mUV.y); AI_MD5_SKIP_SPACES(); if (')' != *sz++) - MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber); + MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber); AI_MD5_SKIP_SPACES(); - vert.mFirstWeight = ::strtoul10(sz,&sz); + vert.mFirstWeight = ::strtoul10(sz, &sz); AI_MD5_SKIP_SPACES(); - vert.mNumWeights = ::strtoul10(sz,&sz); + vert.mNumWeights = ::strtoul10(sz, &sz); } // tri attribute // "tri 0 15 13 12" - else if (TokenMatch(sz,"tri",3)) { + else if (TokenMatch(sz, "tri", 3)) { AI_MD5_SKIP_SPACES(); - const unsigned int idx = strtoul10(sz,&sz); + const unsigned int idx = strtoul10(sz, &sz); if (idx >= desc.mFaces.size()) - desc.mFaces.resize(idx+1); + desc.mFaces.resize(idx + 1); - aiFace& face = desc.mFaces[idx]; + aiFace &face = desc.mFaces[idx]; face.mIndices = new unsigned int[face.mNumIndices = 3]; - for (unsigned int i = 0; i < 3;++i) { + for (unsigned int i = 0; i < 3; ++i) { AI_MD5_SKIP_SPACES(); - face.mIndices[i] = strtoul10(sz,&sz); + face.mIndices[i] = strtoul10(sz, &sz); } } // weight attribute // "weight 362 5 0.500000 ( -3.553583 11.893474 9.719339 )" - else if (TokenMatch(sz,"weight",6)) { + else if (TokenMatch(sz, "weight", 6)) { AI_MD5_SKIP_SPACES(); - const unsigned int idx = strtoul10(sz,&sz); + const unsigned int idx = strtoul10(sz, &sz); AI_MD5_SKIP_SPACES(); if (idx >= desc.mWeights.size()) - desc.mWeights.resize(idx+1); + desc.mWeights.resize(idx + 1); - WeightDesc& weight = desc.mWeights[idx]; - weight.mBone = strtoul10(sz,&sz); + WeightDesc &weight = desc.mWeights[idx]; + weight.mBone = strtoul10(sz, &sz); AI_MD5_SKIP_SPACES(); - sz = fast_atoreal_move(sz,weight.mWeight); + sz = fast_atoreal_move(sz, weight.mWeight); AI_MD5_READ_TRIPLE(weight.vOffsetPosition); } } @@ -358,57 +355,54 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) // ------------------------------------------------------------------------------------------------ // .MD5ANIM parsing function -MD5AnimParser::MD5AnimParser(SectionList& mSections) -{ +MD5AnimParser::MD5AnimParser(SectionList &mSections) { ASSIMP_LOG_DEBUG("MD5AnimParser begin"); fFrameRate = 24.0f; mNumAnimatedComponents = UINT_MAX; - for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) { - if ((*iter).mName == "hierarchy") { + for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) { + if ((*iter).mName == "hierarchy") { // "sheath" 0 63 6 - for (const auto & elem : (*iter).mElements) { - mAnimatedBones.push_back ( AnimBoneDesc () ); - AnimBoneDesc& desc = mAnimatedBones.back(); + for (const auto &elem : (*iter).mElements) { + mAnimatedBones.push_back(AnimBoneDesc()); + AnimBoneDesc &desc = mAnimatedBones.back(); - const char* sz = elem.szStart; + const char *sz = elem.szStart; AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName); AI_MD5_SKIP_SPACES(); // parent index - negative values are allowed (at least -1) - desc.mParentIndex = ::strtol10(sz,&sz); + desc.mParentIndex = ::strtol10(sz, &sz); // flags (highest is 2^6-1) AI_MD5_SKIP_SPACES(); - if(63 < (desc.iFlags = ::strtoul10(sz,&sz))){ - MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",elem.iLineNumber); + if (63 < (desc.iFlags = ::strtoul10(sz, &sz))) { + MD5Parser::ReportWarning("Invalid flag combination in hierarchy section", elem.iLineNumber); } AI_MD5_SKIP_SPACES(); // index of the first animation keyframe component for this joint - desc.iFirstKeyIndex = ::strtoul10(sz,&sz); + desc.iFirstKeyIndex = ::strtoul10(sz, &sz); } - } - else if((*iter).mName == "baseframe") { + } else if ((*iter).mName == "baseframe") { // ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000242 0.707107 ) - for (const auto & elem : (*iter).mElements) { - const char* sz = elem.szStart; + for (const auto &elem : (*iter).mElements) { + const char *sz = elem.szStart; - mBaseFrames.push_back ( BaseFrameDesc () ); - BaseFrameDesc& desc = mBaseFrames.back(); + mBaseFrames.push_back(BaseFrameDesc()); + BaseFrameDesc &desc = mBaseFrames.back(); AI_MD5_READ_TRIPLE(desc.vPositionXYZ); AI_MD5_READ_TRIPLE(desc.vRotationQuat); } - } - else if((*iter).mName == "frame") { + } else if ((*iter).mName == "frame") { if (!(*iter).mGlobalValue.length()) { - MD5Parser::ReportWarning("A frame section must have a frame index",(*iter).iLineNumber); + MD5Parser::ReportWarning("A frame section must have a frame index", (*iter).iLineNumber); continue; } - mFrames.push_back ( FrameDesc () ); - FrameDesc& desc = mFrames.back(); + mFrames.push_back(FrameDesc()); + FrameDesc &desc = mFrames.back(); desc.iIndex = strtoul10((*iter).mGlobalValue.c_str()); // we do already know how much storage we will presumably need @@ -417,31 +411,28 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) } // now read all elements (continuous list of floats) - for (const auto & elem : (*iter).mElements){ - const char* sz = elem.szStart; - while (SkipSpacesAndLineEnd(&sz)) { - float f;sz = fast_atoreal_move(sz,f); + for (const auto &elem : (*iter).mElements) { + const char *sz = elem.szStart; + while (SkipSpacesAndLineEnd(&sz)) { + float f; + sz = fast_atoreal_move(sz, f); desc.mValues.push_back(f); } } - } - else if((*iter).mName == "numFrames") { + } else if ((*iter).mName == "numFrames") { mFrames.reserve(strtoul10((*iter).mGlobalValue.c_str())); - } - else if((*iter).mName == "numJoints") { + } else if ((*iter).mName == "numJoints") { const unsigned int num = strtoul10((*iter).mGlobalValue.c_str()); mAnimatedBones.reserve(num); // try to guess the number of animated components if that element is not given - if (UINT_MAX == mNumAnimatedComponents) { + if (UINT_MAX == mNumAnimatedComponents) { mNumAnimatedComponents = num * 6; } - } - else if((*iter).mName == "numAnimatedComponents") { - mAnimatedBones.reserve( strtoul10((*iter).mGlobalValue.c_str())); - } - else if((*iter).mName == "frameRate") { - fast_atoreal_move((*iter).mGlobalValue.c_str(),fFrameRate); + } else if ((*iter).mName == "numAnimatedComponents") { + mAnimatedBones.reserve(strtoul10((*iter).mGlobalValue.c_str())); + } else if ((*iter).mName == "frameRate") { + fast_atoreal_move((*iter).mGlobalValue.c_str(), fFrameRate); } } ASSIMP_LOG_DEBUG("MD5AnimParser end"); @@ -449,32 +440,27 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) // ------------------------------------------------------------------------------------------------ // .MD5CAMERA parsing function -MD5CameraParser::MD5CameraParser(SectionList& mSections) -{ +MD5CameraParser::MD5CameraParser(SectionList &mSections) { ASSIMP_LOG_DEBUG("MD5CameraParser begin"); fFrameRate = 24.0f; - for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) { - if ((*iter).mName == "numFrames") { + for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) { + if ((*iter).mName == "numFrames") { frames.reserve(strtoul10((*iter).mGlobalValue.c_str())); - } - else if ((*iter).mName == "frameRate") { - fFrameRate = fast_atof ((*iter).mGlobalValue.c_str()); - } - else if ((*iter).mName == "numCuts") { + } else if ((*iter).mName == "frameRate") { + fFrameRate = fast_atof((*iter).mGlobalValue.c_str()); + } else if ((*iter).mName == "numCuts") { cuts.reserve(strtoul10((*iter).mGlobalValue.c_str())); - } - else if ((*iter).mName == "cuts") { - for (const auto & elem : (*iter).mElements){ - cuts.push_back(strtoul10(elem.szStart)+1); + } else if ((*iter).mName == "cuts") { + for (const auto &elem : (*iter).mElements) { + cuts.push_back(strtoul10(elem.szStart) + 1); } - } - else if ((*iter).mName == "camera") { - for (const auto & elem : (*iter).mElements){ - const char* sz = elem.szStart; + } else if ((*iter).mName == "camera") { + for (const auto &elem : (*iter).mElements) { + const char *sz = elem.szStart; frames.push_back(CameraAnimFrameDesc()); - CameraAnimFrameDesc& cur = frames.back(); + CameraAnimFrameDesc &cur = frames.back(); AI_MD5_READ_TRIPLE(cur.vPositionXYZ); AI_MD5_READ_TRIPLE(cur.vRotationQuat); AI_MD5_SKIP_SPACES(); @@ -484,4 +470,3 @@ MD5CameraParser::MD5CameraParser(SectionList& mSections) } ASSIMP_LOG_DEBUG("MD5CameraParser end"); } - diff --git a/code/AssetLib/MDC/MDCLoader.cpp b/code/AssetLib/MDC/MDCLoader.cpp index 60146de81..5748fba0b 100644 --- a/code/AssetLib/MDC/MDCLoader.cpp +++ b/code/AssetLib/MDC/MDCLoader.cpp @@ -267,7 +267,7 @@ void MDCImporter::InternReadFile( // necessary that we don't crash if an exception occurs for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { - pScene->mMeshes[i] = NULL; + pScene->mMeshes[i] = nullptr; } // now read all surfaces @@ -347,8 +347,8 @@ void MDCImporter::InternReadFile( #endif - const MDC::CompressedVertex *pcCVerts = NULL; - int16_t *mdcCompVert = NULL; + const MDC::CompressedVertex *pcCVerts = nullptr; + int16_t *mdcCompVert = nullptr; // access compressed frames for large frame numbers, but never for the first if (this->configFrameID && pcSurface->ulNumCompFrames > 0) { @@ -359,7 +359,7 @@ void MDCImporter::InternReadFile( pcSurface->ulOffsetCompVerts) + *mdcCompVert * pcSurface->ulNumVertices; } else - mdcCompVert = NULL; + mdcCompVert = nullptr; } // copy all faces diff --git a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp index 261214dac..2bb7b42ee 100644 --- a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp +++ b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp @@ -829,7 +829,7 @@ void HL1MDLLoader::read_meshes() { } } else { for (int faceIdx = 0; faceIdx < num_faces; ++faceIdx) { - if (i & 1) { + if (faceIdx & 1) { // Preserve winding order. mesh_faces.push_back(HL1MeshFace{ tricmds[faceIdx + 1], diff --git a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h index c4293259c..2891ddb1e 100644 --- a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h +++ b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h @@ -222,12 +222,14 @@ void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, unsigned std::unique_ptr file(io_->Open(file_path)); - if (file.get() == NULL) + if (file.get() == nullptr) { throw DeadlyImportError("Failed to open MDL file " + DefaultIOSystem::fileName(file_path) + "."); + } const size_t file_size = file->FileSize(); - if (file_size < sizeof(MDLFileHeader)) + if (file_size < sizeof(MDLFileHeader)) { throw DeadlyImportError("MDL file is too small."); + } buffer = new unsigned char[1 + file_size]; file->Read((void *)buffer, 1, file_size); diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index 463be1f1b..e917e3b5e 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -278,7 +278,7 @@ void MDLImporter::SizeCheck(const void *szPos) { // ------------------------------------------------------------------------------------------------ // Just for debugging purposes void MDLImporter::SizeCheck(const void *szPos, const char *szFile, unsigned int iLine) { - ai_assert(NULL != szFile); + ai_assert(nullptr != szFile); if (!szPos || (const unsigned char *)szPos > mBuffer + iFileSize) { // remove a directory if there is one const char *szFilePtr = ::strrchr(szFile, '\\'); @@ -304,7 +304,7 @@ void MDLImporter::SizeCheck(const void *szPos, const char *szFile, unsigned int // ------------------------------------------------------------------------------------------------ // Validate a quake file header void MDLImporter::ValidateHeader_Quake1(const MDL::Header *pcHeader) { - // some values may not be NULL + // some values may not be nullptr if (!pcHeader->num_frames) throw DeadlyImportError("[Quake 1 MDL] There are no frames in the file"); @@ -359,7 +359,7 @@ void FlipQuakeHeader(BE_NCONST MDL::Header *pcHeader) { // ------------------------------------------------------------------------------------------------ // Read a Quake 1 file void MDLImporter::InternReadFile_Quake1() { - ai_assert(NULL != pScene); + ai_assert(nullptr != pScene); BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header *)this->mBuffer; @@ -548,7 +548,7 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1() { delete pScene->mTextures[0]; delete[] pScene->mTextures; - pScene->mTextures = NULL; + pScene->mTextures = nullptr; pScene->mNumTextures = 0; } else { clr.b = clr.a = clr.g = clr.r = 1.0f; @@ -572,7 +572,7 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1() { // ------------------------------------------------------------------------------------------------ // Read a MDL 3,4,5 file void MDLImporter::InternReadFile_3DGS_MDL345() { - ai_assert(NULL != pScene); + ai_assert(nullptr != pScene); // the header of MDL 3/4/5 is nearly identical to the original Quake1 header BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header *)this->mBuffer; @@ -791,7 +791,7 @@ void MDLImporter::ImportUVCoordinate_3DGS_MDL345( aiVector3D &vOut, const MDL::TexCoord_MDL3 *pcSrc, unsigned int iIndex) { - ai_assert(NULL != pcSrc); + ai_assert(nullptr != pcSrc); const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer; // validate UV indices @@ -860,7 +860,7 @@ void MDLImporter::CalculateUVCoordinates_MDL5() { // ------------------------------------------------------------------------------------------------ // Validate the header of a MDL7 file void MDLImporter::ValidateHeader_3DGS_MDL7(const MDL::Header_MDL7 *pcHeader) { - ai_assert(NULL != pcHeader); + ai_assert(nullptr != pcHeader); // There are some fixed sizes ... if (sizeof(MDL::ColorValue_MDL7) != pcHeader->colorvalue_stc_size) { @@ -887,7 +887,7 @@ void MDLImporter::ValidateHeader_3DGS_MDL7(const MDL::Header_MDL7 *pcHeader) { void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7 **apcOutBones) { const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer; const MDL::Bone_MDL7 *pcBones = (const MDL::Bone_MDL7 *)(pcHeader + 1); - ai_assert(NULL != apcOutBones); + ai_assert(nullptr != apcOutBones); // first find the bone that has NO parent, calculate the // animation matrix for it, then go on and search for the next parent @@ -979,7 +979,7 @@ MDL::IntBone_MDL7 **MDLImporter::LoadBones_3DGS_MDL7() { AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS != pcHeader->bone_stc_size && AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE != pcHeader->bone_stc_size) { ASSIMP_LOG_WARN("Unknown size of bone data structure"); - return NULL; + return nullptr; } MDL::IntBone_MDL7 **apcBonesOut = new MDL::IntBone_MDL7 *[pcHeader->bones_num]; @@ -990,7 +990,7 @@ MDL::IntBone_MDL7 **MDLImporter::LoadBones_3DGS_MDL7() { CalcAbsBoneMatrices_3DGS_MDL7(apcBonesOut); return apcBonesOut; } - return NULL; + return nullptr; } // ------------------------------------------------------------------------------------------------ @@ -1014,7 +1014,7 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7 &groupInfo, unsigned int iIndex = pcGroupTris->v_index[c]; if (iIndex > (unsigned int)groupInfo.pcGroup->numverts) { // (we might need to read this section a second time - to process frame vertices correctly) - pcGroupTris->v_index[c] = (uint16_t) (iIndex = groupInfo.pcGroup->numverts - 1 ); + pcGroupTris->v_index[c] = (uint16_t)(iIndex = groupInfo.pcGroup->numverts - 1); ASSIMP_LOG_WARN("Index overflow in MDL7 vertex list"); } @@ -1337,7 +1337,7 @@ void MDLImporter::SortByMaterials_3DGS_MDL7( // ------------------------------------------------------------------------------------------------ // Read a MDL7 file void MDLImporter::InternReadFile_3DGS_MDL7() { - ai_assert(NULL != pScene); + ai_assert(nullptr != pScene); MDL::IntSharedData_MDL7 sharedData; @@ -1368,7 +1368,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7() { // load all bones (they are shared by all groups, so // we'll need to add them to all groups/meshes later) - // apcBonesOut is a list of all bones or NULL if they could not been loaded + // apcBonesOut is a list of all bones or nullptr if they could not been loaded szCurrent += pcHeader->bones_num * pcHeader->bone_stc_size; sharedData.apcOutBones = this->LoadBones_3DGS_MDL7(); @@ -1558,9 +1558,9 @@ void MDLImporter::InternReadFile_3DGS_MDL7() { if (1 == pScene->mRootNode->mNumChildren && !sharedData.apcOutBones) { aiNode *pcOldRoot = this->pScene->mRootNode; pScene->mRootNode = pcOldRoot->mChildren[0]; - pcOldRoot->mChildren[0] = NULL; + pcOldRoot->mChildren[0] = nullptr; delete pcOldRoot; - pScene->mRootNode->mParent = NULL; + pScene->mRootNode->mParent = nullptr; } else pScene->mRootNode->mName.Set(""); @@ -1665,7 +1665,8 @@ void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7( // Attach bones to the output nodegraph void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7 **apcBones, aiNode *pcParent, uint16_t iParentIndex) { - ai_assert(NULL != apcBones && NULL != pcParent); + ai_assert(nullptr != apcBones); + ai_assert(nullptr != pcParent); // get a pointer to the header ... const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)this->mBuffer; @@ -1696,7 +1697,7 @@ void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7 **apcBon // Build output animations void MDLImporter::BuildOutputAnims_3DGS_MDL7( const MDL::IntBone_MDL7 **apcBonesOut) { - ai_assert(NULL != apcBonesOut); + ai_assert(nullptr != apcBonesOut); const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)mBuffer; // one animation ... @@ -1755,8 +1756,8 @@ void MDLImporter::BuildOutputAnims_3DGS_MDL7( void MDLImporter::AddAnimationBoneTrafoKey_3DGS_MDL7(unsigned int iTrafo, const MDL::BoneTransform_MDL7 *pcBoneTransforms, MDL::IntBone_MDL7 **apcBonesOut) { - ai_assert(NULL != pcBoneTransforms); - ai_assert(NULL != apcBonesOut); + ai_assert(nullptr != pcBoneTransforms); + ai_assert(nullptr != apcBonesOut); // first .. get the transformation matrix aiMatrix4x4 mTransform; @@ -1920,7 +1921,9 @@ void MDLImporter::JoinSkins_3DGS_MDL7( aiMaterial *pcMat1, aiMaterial *pcMat2, aiMaterial *pcMatOut) { - ai_assert(NULL != pcMat1 && NULL != pcMat2 && NULL != pcMatOut); + ai_assert(nullptr != pcMat1); + ai_assert(nullptr != pcMat2); + ai_assert(nullptr != pcMatOut); // first create a full copy of the first skin property set // and assign it to the output material diff --git a/code/AssetLib/MDL/MDLLoader.h b/code/AssetLib/MDL/MDLLoader.h index c747559c8..9c1b403c8 100644 --- a/code/AssetLib/MDL/MDLLoader.h +++ b/code/AssetLib/MDL/MDLLoader.h @@ -320,7 +320,7 @@ protected: /** Load the bone list of a MDL7 file * \return If the bones could be loaded successfully, a valid * array containing pointers to a temporary bone - * representation. NULL if the bones could not be loaded. + * representation. nullptr if the bones could not be loaded. */ MDL::IntBone_MDL7** LoadBones_3DGS_MDL7(); diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp index 1f46c1edf..83939e98b 100644 --- a/code/AssetLib/MDL/MDLMaterialLoader.cpp +++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp @@ -364,7 +364,7 @@ void MDLImporter::ParseTextureColorData(const unsigned char *szData, void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char *szData, unsigned int iType, unsigned int *piSkip) { - ai_assert(NULL != piSkip); + ai_assert(nullptr != piSkip); bool bNoRead = *piSkip == UINT_MAX; // allocate a new texture object @@ -428,7 +428,7 @@ void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char *szData, delete[] pc; } } else { - pcNew->pcData = NULL; + pcNew->pcData = nullptr; delete pcNew; } return; diff --git a/code/AssetLib/MMD/MMDImporter.cpp b/code/AssetLib/MMD/MMDImporter.cpp index 7c382bd09..0814f4813 100644 --- a/code/AssetLib/MMD/MMDImporter.cpp +++ b/code/AssetLib/MMD/MMDImporter.cpp @@ -134,7 +134,7 @@ void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene, // ------------------------------------------------------------------------------------------------ void MMDImporter::CreateDataFromImport(const pmx::PmxModel *pModel, aiScene *pScene) { - if (pModel == NULL) { + if (pModel == nullptr) { return; } diff --git a/code/AssetLib/MMD/MMDImporter.h b/code/AssetLib/MMD/MMDImporter.h index 1cc91c782..b1fdb9f6a 100644 --- a/code/AssetLib/MMD/MMDImporter.h +++ b/code/AssetLib/MMD/MMDImporter.h @@ -93,4 +93,4 @@ private: } // Namespace Assimp -#endif \ No newline at end of file +#endif diff --git a/code/AssetLib/MMD/MMDPmdParser.h b/code/AssetLib/MMD/MMDPmdParser.h index dad9ed4bc..375126ec4 100644 --- a/code/AssetLib/MMD/MMDPmdParser.h +++ b/code/AssetLib/MMD/MMDPmdParser.h @@ -131,7 +131,7 @@ namespace pmd stream->read((char*) &index_count, sizeof(uint32_t)); stream->read((char*) &buffer, sizeof(char) * 20); char* pstar = strchr(buffer, '*'); - if (NULL == pstar) + if (nullptr == pstar) { texture_filename = std::string(buffer); sphere_filename.clear(); diff --git a/code/AssetLib/MS3D/MS3DLoader.cpp b/code/AssetLib/MS3D/MS3DLoader.cpp index 9f0149c2b..b5b6673f3 100644 --- a/code/AssetLib/MS3D/MS3DLoader.cpp +++ b/code/AssetLib/MS3D/MS3DLoader.cpp @@ -657,7 +657,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, } // fixup to pass the validation if not a single animation channel is non-trivial if (!anim->mNumChannels) { - anim->mChannels = NULL; + anim->mChannels = nullptr; } } } diff --git a/code/AssetLib/NFF/NFFLoader.cpp b/code/AssetLib/NFF/NFFLoader.cpp index edb64a34f..8d85b5acf 100644 --- a/code/AssetLib/NFF/NFFLoader.cpp +++ b/code/AssetLib/NFF/NFFLoader.cpp @@ -154,7 +154,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector &output, return; } - ShadingInfo *curShader = NULL; + ShadingInfo *curShader = nullptr; // No read the file line per line char line[4096]; @@ -238,9 +238,9 @@ void NFFImporter::InternReadFile(const std::string &pFile, bool hasCam = false; - MeshInfo *currentMeshWithNormals = NULL; - MeshInfo *currentMesh = NULL; - MeshInfo *currentMeshWithUVCoords = NULL; + MeshInfo *currentMeshWithNormals = nullptr; + MeshInfo *currentMesh = nullptr; + MeshInfo *currentMeshWithUVCoords = nullptr; ShadingInfo s; // current material info @@ -542,7 +542,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, // search the list of all shaders we have for this object whether // there is an identical one. In this case, we append our mesh // data to it. - MeshInfo *mesh = NULL; + MeshInfo *mesh = nullptr; for (std::vector::iterator it = meshes.begin() + objStart, end = meshes.end(); it != end; ++it) { if ((*it).shader == shader && (*it).matIndex == matIdx) { @@ -603,11 +603,11 @@ void NFFImporter::InternReadFile(const std::string &pFile, while (GetNextLine(buffer, line)) { sz = line; if ('p' == line[0] || TokenMatch(sz, "tpp", 3)) { - MeshInfo *out = NULL; + MeshInfo *out = nullptr; // 'tpp' - texture polygon patch primitive if ('t' == line[0]) { - currentMeshWithUVCoords = NULL; + currentMeshWithUVCoords = nullptr; for (auto &mesh : meshesWithUVCoords) { if (mesh.shader == s) { currentMeshWithUVCoords = &mesh; @@ -624,7 +624,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } // 'pp' - polygon patch primitive else if ('p' == line[1]) { - currentMeshWithNormals = NULL; + currentMeshWithNormals = nullptr; for (auto &mesh : meshesWithNormals) { if (mesh.shader == s) { currentMeshWithNormals = &mesh; @@ -642,7 +642,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } // 'p' - polygon primitive else { - currentMesh = NULL; + currentMesh = nullptr; for (auto &mesh : meshes) { if (mesh.shader == s) { currentMesh = &mesh; @@ -969,8 +969,8 @@ void NFFImporter::InternReadFile(const std::string &pFile, root->mNumChildren = numNamed + (hasCam ? 1 : 0) + (unsigned int)lights.size(); root->mNumMeshes = pScene->mNumMeshes - numNamed; - aiNode **ppcChildren = NULL; - unsigned int *pMeshes = NULL; + aiNode **ppcChildren = nullptr; + unsigned int *pMeshes = nullptr; if (root->mNumMeshes) pMeshes = root->mMeshes = new unsigned int[root->mNumMeshes]; if (root->mNumChildren) @@ -1037,7 +1037,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, mesh->mNumFaces = (unsigned int)src.faces.size(); // Generate sub nodes for named meshes - if (src.name[0] && NULL != ppcChildren) { + if (src.name[0] && nullptr != ppcChildren) { aiNode *const node = *ppcChildren = new aiNode(); node->mParent = root; node->mNumMeshes = 1; diff --git a/code/AssetLib/Obj/ObjExporter.cpp b/code/AssetLib/Obj/ObjExporter.cpp index 350436959..882f3a917 100644 --- a/code/AssetLib/Obj/ObjExporter.cpp +++ b/code/AssetLib/Obj/ObjExporter.cpp @@ -70,14 +70,14 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write both the main OBJ file and the material script { std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); } outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } { std::unique_ptr outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .mtl file: " + std::string(exporter.GetMaterialLibFileName())); } outfile->Write( exporter.mOutputMat.str().c_str(), static_cast(exporter.mOutputMat.tellp()),1); @@ -97,7 +97,7 @@ void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* p // we're still here - export successfully completed. Write both the main OBJ file and the material script { std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); } outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); diff --git a/code/AssetLib/Obj/ObjFileData.h b/code/AssetLib/Obj/ObjFileData.h index 2974a4c23..5982be44d 100644 --- a/code/AssetLib/Obj/ObjFileData.h +++ b/code/AssetLib/Obj/ObjFileData.h @@ -41,12 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #ifndef OBJ_FILEDATA_H_INC -# define OBJ_FILEDATA_H_INC +#define OBJ_FILEDATA_H_INC -# include -# include -# include -# include +#include +#include +#include +#include namespace Assimp { namespace ObjFile { @@ -215,7 +215,11 @@ struct Mesh { /// Constructor explicit Mesh(const std::string &name) : - m_name(name), m_pMaterial(NULL), m_uiNumIndices(0), m_uiMaterialIndex(NoMaterial), m_hasNormals(false) { + m_name(name), + m_pMaterial(nullptr), + m_uiNumIndices(0), + m_uiMaterialIndex(NoMaterial), + m_hasNormals(false) { memset(m_uiUVCoordinates, 0, sizeof(unsigned int) * AI_MAX_NUMBER_OF_TEXTURECOORDS); } @@ -275,13 +279,13 @@ struct Model { //! \brief The default class constructor Model() : m_ModelName(""), - m_pCurrent(NULL), - m_pCurrentMaterial(NULL), - m_pDefaultMaterial(NULL), - m_pGroupFaceIDs(NULL), + m_pCurrent(nullptr), + m_pCurrentMaterial(nullptr), + m_pDefaultMaterial(nullptr), + m_pGroupFaceIDs(nullptr), m_strActiveGroup(""), m_TextureCoordDim(0), - m_pCurrentMesh(NULL) { + m_pCurrentMesh(nullptr) { // empty } diff --git a/code/AssetLib/Obj/ObjFileImporter.cpp b/code/AssetLib/Obj/ObjFileImporter.cpp index 462245e44..b6e1f9061 100644 --- a/code/AssetLib/Obj/ObjFileImporter.cpp +++ b/code/AssetLib/Obj/ObjFileImporter.cpp @@ -252,9 +252,9 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model *pModel, aiScene aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile::Object *pObject, aiNode *pParent, aiScene *pScene, std::vector &MeshArray) { - ai_assert(NULL != pModel); - if (NULL == pObject) { - return NULL; + ai_assert(nullptr != pModel); + if (nullptr == pObject) { + return nullptr; } // Store older mesh size to be able to computes mesh offsets for new mesh instances @@ -264,7 +264,7 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile pNode->mName = pObject->m_strObjName; // If we have a parent node, store it - ai_assert(NULL != pParent); + ai_assert(nullptr != pParent); appendChildToParentNode(pParent, pNode); for (size_t i = 0; i < pObject->m_Meshes.size(); ++i) { @@ -308,20 +308,20 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile // Create topology data aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjFile::Object *pData, unsigned int meshIndex) { // Checking preconditions - ai_assert(NULL != pModel); + ai_assert(nullptr != pModel); - if (NULL == pData) { - return NULL; + if (nullptr == pData) { + return nullptr; } // Create faces ObjFile::Mesh *pObjMesh = pModel->m_Meshes[meshIndex]; if (!pObjMesh) { - return NULL; + return nullptr; } if (pObjMesh->m_Faces.empty()) { - return NULL; + return nullptr; } std::unique_ptr pMesh(new aiMesh); @@ -331,7 +331,7 @@ aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjF for (size_t index = 0; index < pObjMesh->m_Faces.size(); index++) { ObjFile::Face *const inp = pObjMesh->m_Faces[index]; - ai_assert(NULL != inp); + ai_assert(nullptr != inp); if (inp->m_PrimitiveType == aiPrimitiveType_LINE) { pMesh->mNumFaces += static_cast(inp->m_vertices.size() - 1); @@ -400,7 +400,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model *pModel, aiMesh *pMesh, unsigned int numIndices) { // Checking preconditions - ai_assert(NULL != pCurrentObject); + ai_assert(nullptr != pCurrentObject); // Break, if no faces are stored in object if (pCurrentObject->m_Meshes.empty()) @@ -408,7 +408,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model *pModel, // Get current mesh ObjFile::Mesh *pObjMesh = pModel->m_Meshes[uiMeshIndex]; - if (NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1) { + if (nullptr == pObjMesh || pObjMesh->m_uiNumIndices < 1) { return; } @@ -561,7 +561,7 @@ void ObjFileImporter::addTextureMappingModeProperty(aiMaterial *mat, aiTextureTy // ------------------------------------------------------------------------------------------------ // Creates the material void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pScene) { - if (NULL == pScene) { + if (nullptr == pScene) { return; } @@ -717,8 +717,8 @@ void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pSc // Appends this node to the parent node void ObjFileImporter::appendChildToParentNode(aiNode *pParent, aiNode *pChild) { // Checking preconditions - ai_assert(NULL != pParent); - ai_assert(NULL != pChild); + ai_assert(nullptr != pParent); + ai_assert(nullptr != pChild); // Assign parent to child pChild->mParent = pParent; diff --git a/code/AssetLib/Obj/ObjFileMtlImporter.cpp b/code/AssetLib/Obj/ObjFileMtlImporter.cpp index 8b529758e..6464a55e0 100644 --- a/code/AssetLib/Obj/ObjFileMtlImporter.cpp +++ b/code/AssetLib/Obj/ObjFileMtlImporter.cpp @@ -200,7 +200,7 @@ void ObjFileMtlImporter::load() { // ------------------------------------------------------------------- // Loads a color definition void ObjFileMtlImporter::getColorRGBA(aiColor3D *pColor) { - ai_assert(NULL != pColor); + ai_assert(nullptr != pColor); ai_real r(0.0), g(0.0), b(0.0); m_DataIt = getFloat(m_DataIt, m_DataItEnd, r); @@ -274,7 +274,7 @@ void ObjFileMtlImporter::createMaterial() { // ------------------------------------------------------------------- // Gets a texture name from data. void ObjFileMtlImporter::getTexture() { - aiString *out(NULL); + aiString *out(nullptr); int clampIndex = -1; const char *pPtr(&(*m_DataIt)); @@ -332,7 +332,7 @@ void ObjFileMtlImporter::getTexture() { std::string texture; m_DataIt = getName(m_DataIt, m_DataItEnd, texture); - if (NULL != out) { + if (nullptr != out) { out->Set(texture); } } diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp index a825b96ca..a8039ae23 100644 --- a/code/AssetLib/Obj/ObjFileParser.cpp +++ b/code/AssetLib/Obj/ObjFileParser.cpp @@ -253,7 +253,6 @@ static bool isDataDefinitionEnd(const char *tmp) { if (*tmp == '\\') { tmp++; if (IsLineEnd(*tmp)) { - tmp++; return true; } } @@ -495,19 +494,19 @@ void ObjFileParser::getFace(aiPrimitiveType type) { } // Set active material, if one set - if (NULL != m_pModel->m_pCurrentMaterial) { + if (nullptr != m_pModel->m_pCurrentMaterial) { face->m_pMaterial = m_pModel->m_pCurrentMaterial; } else { face->m_pMaterial = m_pModel->m_pDefaultMaterial; } // Create a default object, if nothing is there - if (NULL == m_pModel->m_pCurrent) { + if (nullptr == m_pModel->m_pCurrent) { createObject(DefaultObjName); } // Assign face to mesh - if (NULL == m_pModel->m_pCurrentMesh) { + if (nullptr == m_pModel->m_pCurrentMesh) { createMesh(DefaultObjName); } @@ -754,7 +753,7 @@ void ObjFileParser::getObjectName() { std::string strObjectName(pStart, &(*m_DataIt)); if (!strObjectName.empty()) { // Reset current object - m_pModel->m_pCurrent = NULL; + m_pModel->m_pCurrent = nullptr; // Search for actual object for (std::vector::const_iterator it = m_pModel->m_Objects.begin(); @@ -767,7 +766,7 @@ void ObjFileParser::getObjectName() { } // Allocate a new object, if current one was not found before - if (NULL == m_pModel->m_pCurrent) { + if (nullptr == m_pModel->m_pCurrent) { createObject(strObjectName); } } @@ -776,7 +775,7 @@ void ObjFileParser::getObjectName() { // ------------------------------------------------------------------- // Creates a new object instance void ObjFileParser::createObject(const std::string &objName) { - ai_assert(NULL != m_pModel); + ai_assert(nullptr != m_pModel); m_pModel->m_pCurrent = new ObjFile::Object; m_pModel->m_pCurrent->m_strObjName = objName; @@ -793,11 +792,12 @@ void ObjFileParser::createObject(const std::string &objName) { // ------------------------------------------------------------------- // Creates a new mesh void ObjFileParser::createMesh(const std::string &meshName) { - ai_assert(NULL != m_pModel); + ai_assert(nullptr != m_pModel); + m_pModel->m_pCurrentMesh = new ObjFile::Mesh(meshName); m_pModel->m_Meshes.push_back(m_pModel->m_pCurrentMesh); unsigned int meshId = static_cast(m_pModel->m_Meshes.size() - 1); - if (NULL != m_pModel->m_pCurrent) { + if (nullptr != m_pModel->m_pCurrent) { m_pModel->m_pCurrent->m_Meshes.push_back(meshId); } else { ASSIMP_LOG_ERROR("OBJ: No object detected to attach a new mesh instance."); diff --git a/code/AssetLib/Ogre/OgreBinarySerializer.cpp b/code/AssetLib/Ogre/OgreBinarySerializer.cpp index bc12b6403..360da898f 100644 --- a/code/AssetLib/Ogre/OgreBinarySerializer.cpp +++ b/code/AssetLib/Ogre/OgreBinarySerializer.cpp @@ -168,7 +168,7 @@ void OgreBinarySerializer::RollbackHeader() { void OgreBinarySerializer::SkipBytes(size_t numBytes) { #if (OGRE_BINARY_SERIALIZER_DEBUG == 1) - ASSIMP_LOG_DEBUG_F("Skipping ", numBytes, " bytes"); + ASSIMP_LOG_VERBOSE_DEBUG_F("Skipping ", numBytes, " bytes"); #endif m_reader->IncPtr(numBytes); @@ -207,8 +207,8 @@ Mesh *OgreBinarySerializer::ImportMesh(MemoryStreamReader *stream) { void OgreBinarySerializer::ReadMesh(Mesh *mesh) { mesh->hasSkeletalAnimations = Read(); - ASSIMP_LOG_DEBUG("Reading Mesh"); - ASSIMP_LOG_DEBUG_F(" - Skeletal animations: ", mesh->hasSkeletalAnimations ? "true" : "false"); + ASSIMP_LOG_VERBOSE_DEBUG("Reading Mesh"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Skeletal animations: ", mesh->hasSkeletalAnimations ? "true" : "false"); if (!AtEnd()) { uint16_t id = ReadHeader(); @@ -364,9 +364,9 @@ void OgreBinarySerializer::ReadSubMesh(Mesh *mesh) { submesh->indexData->faceCount = static_cast(submesh->indexData->count / 3); submesh->indexData->is32bit = Read(); - ASSIMP_LOG_DEBUG_F("Reading SubMesh ", mesh->subMeshes.size()); - ASSIMP_LOG_DEBUG_F(" - Material: '", submesh->materialRef, "'"); - ASSIMP_LOG_DEBUG_F(" - Uses shared geometry: ", submesh->usesSharedVertexData ? "true" : "false"); + ASSIMP_LOG_VERBOSE_DEBUG_F("Reading SubMesh ", mesh->subMeshes.size()); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Material: '", submesh->materialRef, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Uses shared geometry: ", submesh->usesSharedVertexData ? "true" : "false"); // Index buffer if (submesh->indexData->count > 0) { @@ -374,7 +374,7 @@ void OgreBinarySerializer::ReadSubMesh(Mesh *mesh) { uint8_t *indexBuffer = ReadBytes(numBytes); submesh->indexData->buffer = MemoryStreamPtr(new Assimp::MemoryIOStream(indexBuffer, numBytes, true)); - ASSIMP_LOG_DEBUG_F(" - ", submesh->indexData->faceCount, + ASSIMP_LOG_VERBOSE_DEBUG_F(" - ", submesh->indexData->faceCount, " faces from ", submesh->indexData->count, (submesh->indexData->is32bit ? " 32bit" : " 16bit"), " indexes of ", numBytes, " bytes"); } @@ -475,7 +475,7 @@ void OgreBinarySerializer::ReadSubMeshNames(Mesh *mesh) { } submesh->name = ReadLine(); - ASSIMP_LOG_DEBUG_F(" - SubMesh ", submesh->index, " name '", submesh->name, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - SubMesh ", submesh->index, " name '", submesh->name, "'"); if (!AtEnd()) id = ReadHeader(); @@ -488,7 +488,7 @@ void OgreBinarySerializer::ReadSubMeshNames(Mesh *mesh) { void OgreBinarySerializer::ReadGeometry(VertexData *dest) { dest->count = Read(); - ASSIMP_LOG_DEBUG_F(" - Reading geometry of ", dest->count, " vertices"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Reading geometry of ", dest->count, " vertices"); if (!AtEnd()) { uint16_t id = ReadHeader(); @@ -536,7 +536,7 @@ void OgreBinarySerializer::ReadGeometryVertexElement(VertexData *dest) { element.offset = Read(); element.index = Read(); - ASSIMP_LOG_DEBUG_F(" - Vertex element ", element.SemanticToString(), " of type ", + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Vertex element ", element.SemanticToString(), " of type ", element.TypeToString(), " index=", element.index, " source=", element.source); dest->vertexElements.push_back(element); @@ -557,7 +557,7 @@ void OgreBinarySerializer::ReadGeometryVertexBuffer(VertexData *dest) { uint8_t *vertexBuffer = ReadBytes(numBytes); dest->vertexBindings[bindIndex] = MemoryStreamPtr(new Assimp::MemoryIOStream(vertexBuffer, numBytes, true)); - ASSIMP_LOG_DEBUG_F(" - Read vertex buffer for source ", bindIndex, " of ", numBytes, " bytes"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Read vertex buffer for source ", bindIndex, " of ", numBytes, " bytes"); } void OgreBinarySerializer::ReadEdgeList(Mesh * /*mesh*/) { @@ -807,7 +807,7 @@ void OgreBinarySerializer::ReadSkeleton(Skeleton *skeleton) { << " Supported versions: " << SKELETON_VERSION_1_8 << " and " << SKELETON_VERSION_1_1); } - ASSIMP_LOG_DEBUG("Reading Skeleton"); + ASSIMP_LOG_VERBOSE_DEBUG("Reading Skeleton"); bool firstBone = true; bool firstAnim = true; @@ -821,7 +821,7 @@ void OgreBinarySerializer::ReadSkeleton(Skeleton *skeleton) { } case SKELETON_BONE: { if (firstBone) { - ASSIMP_LOG_DEBUG(" - Bones"); + ASSIMP_LOG_VERBOSE_DEBUG(" - Bones"); firstBone = false; } @@ -834,7 +834,7 @@ void OgreBinarySerializer::ReadSkeleton(Skeleton *skeleton) { } case SKELETON_ANIMATION: { if (firstAnim) { - ASSIMP_LOG_DEBUG(" - Animations"); + ASSIMP_LOG_VERBOSE_DEBUG(" - Animations"); firstAnim = false; } @@ -874,7 +874,7 @@ void OgreBinarySerializer::ReadBone(Skeleton *skeleton) { throw DeadlyImportError(Formatter::format() << "Ogre Skeleton bone indexes not contiguous. Error at bone index " << bone->id); } - ASSIMP_LOG_DEBUG_F(" ", bone->id, " ", bone->name); + ASSIMP_LOG_VERBOSE_DEBUG_F(" ", bone->id, " ", bone->name); skeleton->bones.push_back(bone); } @@ -919,7 +919,7 @@ void OgreBinarySerializer::ReadSkeletonAnimation(Skeleton *skeleton) { skeleton->animations.push_back(anim); - ASSIMP_LOG_DEBUG_F(" ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)"); } void OgreBinarySerializer::ReadSkeletonAnimationTrack(Skeleton * /*skeleton*/, Animation *dest) { diff --git a/code/AssetLib/Ogre/OgreMaterial.cpp b/code/AssetLib/Ogre/OgreMaterial.cpp index f79206406..74e5eb760 100644 --- a/code/AssetLib/Ogre/OgreMaterial.cpp +++ b/code/AssetLib/Ogre/OgreMaterial.cpp @@ -175,7 +175,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste if (materialFile) { break; } - ASSIMP_LOG_DEBUG_F( "Source file for material '", materialName, "' ", potentialFiles[i], " does not exist"); + ASSIMP_LOG_VERBOSE_DEBUG_F( "Source file for material '", materialName, "' ", potentialFiles[i], " does not exist"); } if (!materialFile) { @@ -201,7 +201,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste ss << &data[0]; } - ASSIMP_LOG_DEBUG_F("Reading material '", materialName, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F("Reading material '", materialName, "'"); aiMaterial *material = new aiMaterial(); m_textures.clear(); @@ -245,7 +245,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste return material; } - ASSIMP_LOG_DEBUG_F("material '", materialName, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F("material '", materialName, "'"); while(linePart != partBlockEnd) { @@ -353,7 +353,7 @@ bool OgreImporter::ReadTechnique(const std::string &techniqueName, stringstream return false; } - ASSIMP_LOG_DEBUG_F(" technique '", techniqueName, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" technique '", techniqueName, "'"); const string partPass = "pass"; @@ -389,7 +389,7 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat return false; } - ASSIMP_LOG_DEBUG_F(" pass '", passName, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" pass '", passName, "'"); const string partAmbient = "ambient"; const string partDiffuse = "diffuse"; @@ -416,7 +416,7 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat ss >> r >> g >> b; const aiColor3D color(r, g, b); - ASSIMP_LOG_DEBUG_F( " ", linePart, " ", r, " ", g, " ", b); + ASSIMP_LOG_VERBOSE_DEBUG_F( " ", linePart, " ", r, " ", g, " ", b); if (linePart == partAmbient) { @@ -455,7 +455,7 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr return false; } - ASSIMP_LOG_DEBUG_F(" texture_unit '", textureUnitName, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" texture_unit '", textureUnitName, "'"); const string partTexture = "texture"; const string partTextCoordSet = "tex_coord_set"; @@ -490,7 +490,7 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr if (posSuffix != string::npos && posUnderscore != string::npos && posSuffix > posUnderscore) { string identifier = Ogre::ToLower(textureRef.substr(posUnderscore, posSuffix - posUnderscore)); - ASSIMP_LOG_DEBUG_F( "Detecting texture type from filename postfix '", identifier, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F( "Detecting texture type from filename postfix '", identifier, "'"); if (identifier == "_n" || identifier == "_nrm" || identifier == "_nrml" || identifier == "_normal" || identifier == "_normals" || identifier == "_normalmap") { @@ -580,7 +580,7 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr unsigned int textureTypeIndex = m_textures[textureType]; m_textures[textureType]++; - ASSIMP_LOG_DEBUG_F( " texture '", textureRef, "' type ", textureType, + ASSIMP_LOG_VERBOSE_DEBUG_F( " texture '", textureRef, "' type ", textureType, " index ", textureTypeIndex, " UV ", uvCoord); aiString assimpTextureRef(textureRef); diff --git a/code/AssetLib/Ogre/OgreStructs.cpp b/code/AssetLib/Ogre/OgreStructs.cpp index 69cfae1cd..4a4f9479e 100644 --- a/code/AssetLib/Ogre/OgreStructs.cpp +++ b/code/AssetLib/Ogre/OgreStructs.cpp @@ -43,199 +43,183 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER #include "OgreStructs.h" +#include #include #include #include -#include - -namespace Assimp -{ -namespace Ogre -{ +namespace Assimp { +namespace Ogre { // VertexElement VertexElement::VertexElement() : - index(0), - source(0), - offset(0), - type(VET_FLOAT1), - semantic(VES_POSITION) -{ + index(0), + source(0), + offset(0), + type(VET_FLOAT1), + semantic(VES_POSITION) { } -size_t VertexElement::Size() const -{ +size_t VertexElement::Size() const { return TypeSize(type); } -size_t VertexElement::ComponentCount() const -{ +size_t VertexElement::ComponentCount() const { return ComponentCount(type); } -size_t VertexElement::ComponentCount(Type type) -{ - switch(type) - { - case VET_COLOUR: - case VET_COLOUR_ABGR: - case VET_COLOUR_ARGB: - case VET_FLOAT1: - case VET_DOUBLE1: - case VET_SHORT1: - case VET_USHORT1: - case VET_INT1: - case VET_UINT1: - return 1; - case VET_FLOAT2: - case VET_DOUBLE2: - case VET_SHORT2: - case VET_USHORT2: - case VET_INT2: - case VET_UINT2: - return 2; - case VET_FLOAT3: - case VET_DOUBLE3: - case VET_SHORT3: - case VET_USHORT3: - case VET_INT3: - case VET_UINT3: - return 3; - case VET_FLOAT4: - case VET_DOUBLE4: - case VET_SHORT4: - case VET_USHORT4: - case VET_INT4: - case VET_UINT4: - case VET_UBYTE4: - return 4; +size_t VertexElement::ComponentCount(Type type) { + switch (type) { + case VET_COLOUR: + case VET_COLOUR_ABGR: + case VET_COLOUR_ARGB: + case VET_FLOAT1: + case VET_DOUBLE1: + case VET_SHORT1: + case VET_USHORT1: + case VET_INT1: + case VET_UINT1: + return 1; + case VET_FLOAT2: + case VET_DOUBLE2: + case VET_SHORT2: + case VET_USHORT2: + case VET_INT2: + case VET_UINT2: + return 2; + case VET_FLOAT3: + case VET_DOUBLE3: + case VET_SHORT3: + case VET_USHORT3: + case VET_INT3: + case VET_UINT3: + return 3; + case VET_FLOAT4: + case VET_DOUBLE4: + case VET_SHORT4: + case VET_USHORT4: + case VET_INT4: + case VET_UINT4: + case VET_UBYTE4: + return 4; } return 0; } -size_t VertexElement::TypeSize(Type type) -{ - switch(type) - { - case VET_COLOUR: - case VET_COLOUR_ABGR: - case VET_COLOUR_ARGB: - return sizeof(unsigned int); - case VET_FLOAT1: - return sizeof(float); - case VET_FLOAT2: - return sizeof(float)*2; - case VET_FLOAT3: - return sizeof(float)*3; - case VET_FLOAT4: - return sizeof(float)*4; - case VET_DOUBLE1: - return sizeof(double); - case VET_DOUBLE2: - return sizeof(double)*2; - case VET_DOUBLE3: - return sizeof(double)*3; - case VET_DOUBLE4: - return sizeof(double)*4; - case VET_SHORT1: - return sizeof(short); - case VET_SHORT2: - return sizeof(short)*2; - case VET_SHORT3: - return sizeof(short)*3; - case VET_SHORT4: - return sizeof(short)*4; - case VET_USHORT1: - return sizeof(unsigned short); - case VET_USHORT2: - return sizeof(unsigned short)*2; - case VET_USHORT3: - return sizeof(unsigned short)*3; - case VET_USHORT4: - return sizeof(unsigned short)*4; - case VET_INT1: - return sizeof(int); - case VET_INT2: - return sizeof(int)*2; - case VET_INT3: - return sizeof(int)*3; - case VET_INT4: - return sizeof(int)*4; - case VET_UINT1: - return sizeof(unsigned int); - case VET_UINT2: - return sizeof(unsigned int)*2; - case VET_UINT3: - return sizeof(unsigned int)*3; - case VET_UINT4: - return sizeof(unsigned int)*4; - case VET_UBYTE4: - return sizeof(unsigned char)*4; +size_t VertexElement::TypeSize(Type type) { + switch (type) { + case VET_COLOUR: + case VET_COLOUR_ABGR: + case VET_COLOUR_ARGB: + return sizeof(unsigned int); + case VET_FLOAT1: + return sizeof(float); + case VET_FLOAT2: + return sizeof(float) * 2; + case VET_FLOAT3: + return sizeof(float) * 3; + case VET_FLOAT4: + return sizeof(float) * 4; + case VET_DOUBLE1: + return sizeof(double); + case VET_DOUBLE2: + return sizeof(double) * 2; + case VET_DOUBLE3: + return sizeof(double) * 3; + case VET_DOUBLE4: + return sizeof(double) * 4; + case VET_SHORT1: + return sizeof(short); + case VET_SHORT2: + return sizeof(short) * 2; + case VET_SHORT3: + return sizeof(short) * 3; + case VET_SHORT4: + return sizeof(short) * 4; + case VET_USHORT1: + return sizeof(unsigned short); + case VET_USHORT2: + return sizeof(unsigned short) * 2; + case VET_USHORT3: + return sizeof(unsigned short) * 3; + case VET_USHORT4: + return sizeof(unsigned short) * 4; + case VET_INT1: + return sizeof(int); + case VET_INT2: + return sizeof(int) * 2; + case VET_INT3: + return sizeof(int) * 3; + case VET_INT4: + return sizeof(int) * 4; + case VET_UINT1: + return sizeof(unsigned int); + case VET_UINT2: + return sizeof(unsigned int) * 2; + case VET_UINT3: + return sizeof(unsigned int) * 3; + case VET_UINT4: + return sizeof(unsigned int) * 4; + case VET_UBYTE4: + return sizeof(unsigned char) * 4; } return 0; } -std::string VertexElement::TypeToString() -{ +std::string VertexElement::TypeToString() { return TypeToString(type); } -std::string VertexElement::TypeToString(Type type) -{ - switch(type) - { - case VET_COLOUR: return "COLOUR"; - case VET_COLOUR_ABGR: return "COLOUR_ABGR"; - case VET_COLOUR_ARGB: return "COLOUR_ARGB"; - case VET_FLOAT1: return "FLOAT1"; - case VET_FLOAT2: return "FLOAT2"; - case VET_FLOAT3: return "FLOAT3"; - case VET_FLOAT4: return "FLOAT4"; - case VET_DOUBLE1: return "DOUBLE1"; - case VET_DOUBLE2: return "DOUBLE2"; - case VET_DOUBLE3: return "DOUBLE3"; - case VET_DOUBLE4: return "DOUBLE4"; - case VET_SHORT1: return "SHORT1"; - case VET_SHORT2: return "SHORT2"; - case VET_SHORT3: return "SHORT3"; - case VET_SHORT4: return "SHORT4"; - case VET_USHORT1: return "USHORT1"; - case VET_USHORT2: return "USHORT2"; - case VET_USHORT3: return "USHORT3"; - case VET_USHORT4: return "USHORT4"; - case VET_INT1: return "INT1"; - case VET_INT2: return "INT2"; - case VET_INT3: return "INT3"; - case VET_INT4: return "INT4"; - case VET_UINT1: return "UINT1"; - case VET_UINT2: return "UINT2"; - case VET_UINT3: return "UINT3"; - case VET_UINT4: return "UINT4"; - case VET_UBYTE4: return "UBYTE4"; +std::string VertexElement::TypeToString(Type type) { + switch (type) { + case VET_COLOUR: return "COLOUR"; + case VET_COLOUR_ABGR: return "COLOUR_ABGR"; + case VET_COLOUR_ARGB: return "COLOUR_ARGB"; + case VET_FLOAT1: return "FLOAT1"; + case VET_FLOAT2: return "FLOAT2"; + case VET_FLOAT3: return "FLOAT3"; + case VET_FLOAT4: return "FLOAT4"; + case VET_DOUBLE1: return "DOUBLE1"; + case VET_DOUBLE2: return "DOUBLE2"; + case VET_DOUBLE3: return "DOUBLE3"; + case VET_DOUBLE4: return "DOUBLE4"; + case VET_SHORT1: return "SHORT1"; + case VET_SHORT2: return "SHORT2"; + case VET_SHORT3: return "SHORT3"; + case VET_SHORT4: return "SHORT4"; + case VET_USHORT1: return "USHORT1"; + case VET_USHORT2: return "USHORT2"; + case VET_USHORT3: return "USHORT3"; + case VET_USHORT4: return "USHORT4"; + case VET_INT1: return "INT1"; + case VET_INT2: return "INT2"; + case VET_INT3: return "INT3"; + case VET_INT4: return "INT4"; + case VET_UINT1: return "UINT1"; + case VET_UINT2: return "UINT2"; + case VET_UINT3: return "UINT3"; + case VET_UINT4: return "UINT4"; + case VET_UBYTE4: return "UBYTE4"; } return "Uknown_VertexElement::Type"; } -std::string VertexElement::SemanticToString() -{ +std::string VertexElement::SemanticToString() { return SemanticToString(semantic); } -std::string VertexElement::SemanticToString(Semantic semantic) -{ - switch(semantic) - { - case VES_POSITION: return "POSITION"; - case VES_BLEND_WEIGHTS: return "BLEND_WEIGHTS"; - case VES_BLEND_INDICES: return "BLEND_INDICES"; - case VES_NORMAL: return "NORMAL"; - case VES_DIFFUSE: return "DIFFUSE"; - case VES_SPECULAR: return "SPECULAR"; - case VES_TEXTURE_COORDINATES: return "TEXTURE_COORDINATES"; - case VES_BINORMAL: return "BINORMAL"; - case VES_TANGENT: return "TANGENT"; +std::string VertexElement::SemanticToString(Semantic semantic) { + switch (semantic) { + case VES_POSITION: return "POSITION"; + case VES_BLEND_WEIGHTS: return "BLEND_WEIGHTS"; + case VES_BLEND_INDICES: return "BLEND_INDICES"; + case VES_NORMAL: return "NORMAL"; + case VES_DIFFUSE: return "DIFFUSE"; + case VES_SPECULAR: return "SPECULAR"; + case VES_TEXTURE_COORDINATES: return "TEXTURE_COORDINATES"; + case VES_BINORMAL: return "BINORMAL"; + case VES_TANGENT: return "TANGENT"; } return "Uknown_VertexElement::Semantic"; } @@ -243,27 +227,21 @@ std::string VertexElement::SemanticToString(Semantic semantic) // IVertexData IVertexData::IVertexData() : - count(0) -{ + count(0) { } -bool IVertexData::HasBoneAssignments() const -{ +bool IVertexData::HasBoneAssignments() const { return !boneAssignments.empty(); } -void IVertexData::AddVertexMapping(uint32_t oldIndex, uint32_t newIndex) -{ +void IVertexData::AddVertexMapping(uint32_t oldIndex, uint32_t newIndex) { BoneAssignmentsForVertex(oldIndex, newIndex, boneAssignmentsMap[newIndex]); vertexIndexMapping[oldIndex].push_back(newIndex); } -void IVertexData::BoneAssignmentsForVertex(uint32_t currentIndex, uint32_t newIndex, VertexBoneAssignmentList &dest) const -{ - for (const auto &boneAssign : boneAssignments) - { - if (boneAssign.vertexIndex == currentIndex) - { +void IVertexData::BoneAssignmentsForVertex(uint32_t currentIndex, uint32_t newIndex, VertexBoneAssignmentList &dest) const { + for (const auto &boneAssign : boneAssignments) { + if (boneAssign.vertexIndex == currentIndex) { VertexBoneAssignment a = boneAssign; a.vertexIndex = newIndex; dest.push_back(a); @@ -271,15 +249,12 @@ void IVertexData::BoneAssignmentsForVertex(uint32_t currentIndex, uint32_t newIn } } -AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices) -{ +AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices) { AssimpVertexBoneWeightList weights; - for(size_t vi=0; vi(vi)]; - for (VertexBoneAssignmentList::const_iterator iter=vertexWeights.begin(), end=vertexWeights.end(); - iter!=end; ++iter) - { + for (VertexBoneAssignmentList::const_iterator iter = vertexWeights.begin(), end = vertexWeights.end(); + iter != end; ++iter) { std::vector &boneWeights = weights[iter->boneIndex]; boneWeights.push_back(aiVertexWeight(static_cast(vi), iter->weight)); } @@ -287,11 +262,9 @@ AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices) return weights; } -std::set IVertexData::ReferencedBonesByWeights() const -{ +std::set IVertexData::ReferencedBonesByWeights() const { std::set referenced; - for (const auto &boneAssign : boneAssignments) - { + for (const auto &boneAssign : boneAssignments) { referenced.insert(boneAssign.boneIndex); } return referenced; @@ -299,44 +272,36 @@ std::set IVertexData::ReferencedBonesByWeights() const // VertexData -VertexData::VertexData() -{ +VertexData::VertexData() { } -VertexData::~VertexData() -{ +VertexData::~VertexData() { Reset(); } -void VertexData::Reset() -{ +void VertexData::Reset() { // Releases shared ptr memory streams. vertexBindings.clear(); vertexElements.clear(); } -uint32_t VertexData::VertexSize(uint16_t source) const -{ +uint32_t VertexData::VertexSize(uint16_t source) const { uint32_t size = 0; - for(const auto &element : vertexElements) - { + for (const auto &element : vertexElements) { if (element.source == source) size += static_cast(element.Size()); } return size; } -MemoryStream *VertexData::VertexBuffer(uint16_t source) -{ +MemoryStream *VertexData::VertexBuffer(uint16_t source) { if (vertexBindings.find(source) != vertexBindings.end()) return vertexBindings[source].get(); return 0; } -VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, uint16_t index) -{ - for(auto & element : vertexElements) - { +VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, uint16_t index) { + for (auto &element : vertexElements) { if (element.semantic == semantic && element.index == index) return &element; } @@ -345,125 +310,108 @@ VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, ui // VertexDataXml -VertexDataXml::VertexDataXml() -{ +VertexDataXml::VertexDataXml() { } -bool VertexDataXml::HasPositions() const -{ +bool VertexDataXml::HasPositions() const { return !positions.empty(); } -bool VertexDataXml::HasNormals() const -{ +bool VertexDataXml::HasNormals() const { return !normals.empty(); } -bool VertexDataXml::HasTangents() const -{ +bool VertexDataXml::HasTangents() const { return !tangents.empty(); } -bool VertexDataXml::HasUvs() const -{ +bool VertexDataXml::HasUvs() const { return !uvs.empty(); } -size_t VertexDataXml::NumUvs() const -{ +size_t VertexDataXml::NumUvs() const { return uvs.size(); } // IndexData IndexData::IndexData() : - count(0), - faceCount(0), - is32bit(false) -{ + count(0), + faceCount(0), + is32bit(false) { } -IndexData::~IndexData() -{ +IndexData::~IndexData() { Reset(); } -void IndexData::Reset() -{ +void IndexData::Reset() { // Release shared ptr memory stream. buffer.reset(); } -size_t IndexData::IndexSize() const -{ +size_t IndexData::IndexSize() const { return (is32bit ? sizeof(uint32_t) : sizeof(uint16_t)); } -size_t IndexData::FaceSize() const -{ +size_t IndexData::FaceSize() const { return IndexSize() * 3; } // Mesh -Mesh::Mesh() - : hasSkeletalAnimations(false) - , skeleton(NULL) - , sharedVertexData(NULL) - , subMeshes() - , animations() - , poses() -{ +Mesh::Mesh() : + hasSkeletalAnimations(false), + skeleton(nullptr), + sharedVertexData(nullptr), + subMeshes(), + animations(), + poses() { } -Mesh::~Mesh() -{ +Mesh::~Mesh() { Reset(); } -void Mesh::Reset() -{ +void Mesh::Reset() { OGRE_SAFE_DELETE(skeleton) OGRE_SAFE_DELETE(sharedVertexData) - for(auto &mesh : subMeshes) { + for (auto &mesh : subMeshes) { OGRE_SAFE_DELETE(mesh) } subMeshes.clear(); - for(auto &anim : animations) { + for (auto &anim : animations) { OGRE_SAFE_DELETE(anim) } animations.clear(); - for(auto &pose : poses) { + for (auto &pose : poses) { OGRE_SAFE_DELETE(pose) } poses.clear(); } -size_t Mesh::NumSubMeshes() const -{ +size_t Mesh::NumSubMeshes() const { return subMeshes.size(); } -SubMesh *Mesh::GetSubMesh( size_t index ) const -{ - for ( size_t i = 0; i < subMeshes.size(); ++i ) { - if ( subMeshes[ i ]->index == index ) { - return subMeshes[ i ]; +SubMesh *Mesh::GetSubMesh(size_t index) const { + for (size_t i = 0; i < subMeshes.size(); ++i) { + if (subMeshes[i]->index == index) { + return subMeshes[i]; } } return 0; } -void Mesh::ConvertToAssimpScene(aiScene* dest) -{ - if ( nullptr == dest ) { +void Mesh::ConvertToAssimpScene(aiScene *dest) { + if (nullptr == dest) { return; } // Setup dest->mNumMeshes = static_cast(NumSubMeshes()); - dest->mMeshes = new aiMesh*[dest->mNumMeshes]; + dest->mMeshes = new aiMesh *[dest->mNumMeshes]; // Create root node dest->mRootNode = new aiNode(); @@ -471,35 +419,30 @@ void Mesh::ConvertToAssimpScene(aiScene* dest) dest->mRootNode->mMeshes = new unsigned int[dest->mRootNode->mNumMeshes]; // Export meshes - for(size_t i=0; imNumMeshes; ++i) { + for (size_t i = 0; i < dest->mNumMeshes; ++i) { dest->mMeshes[i] = subMeshes[i]->ConvertToAssimpMesh(this); dest->mRootNode->mMeshes[i] = static_cast(i); } // Export skeleton - if (skeleton) - { + if (skeleton) { // Bones - if (!skeleton->bones.empty()) - { + if (!skeleton->bones.empty()) { BoneList rootBones = skeleton->RootBones(); dest->mRootNode->mNumChildren = static_cast(rootBones.size()); - dest->mRootNode->mChildren = new aiNode*[dest->mRootNode->mNumChildren]; + dest->mRootNode->mChildren = new aiNode *[dest->mRootNode->mNumChildren]; - for(size_t i=0, len=rootBones.size(); imRootNode->mChildren[i] = rootBones[i]->ConvertToAssimpNode(skeleton, dest->mRootNode); } } // Animations - if (!skeleton->animations.empty()) - { + if (!skeleton->animations.empty()) { dest->mNumAnimations = static_cast(skeleton->animations.size()); - dest->mAnimations = new aiAnimation*[dest->mNumAnimations]; + dest->mAnimations = new aiAnimation *[dest->mNumAnimations]; - for(size_t i=0, len=skeleton->animations.size(); ianimations.size(); i < len; ++i) { dest->mAnimations[i] = skeleton->animations[i]->ConvertToAssimpAnimation(); } } @@ -509,34 +452,29 @@ void Mesh::ConvertToAssimpScene(aiScene* dest) // ISubMesh ISubMesh::ISubMesh() : - index(0), - materialIndex(-1), - usesSharedVertexData(false), - operationType(OT_POINT_LIST) -{ + index(0), + materialIndex(-1), + usesSharedVertexData(false), + operationType(OT_POINT_LIST) { } // SubMesh SubMesh::SubMesh() : - vertexData(0), - indexData(new IndexData()) -{ + vertexData(0), + indexData(new IndexData()) { } -SubMesh::~SubMesh() -{ +SubMesh::~SubMesh() { Reset(); } -void SubMesh::Reset() -{ +void SubMesh::Reset(){ OGRE_SAFE_DELETE(vertexData) - OGRE_SAFE_DELETE(indexData) + OGRE_SAFE_DELETE(indexData) } -aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) -{ +aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) { if (operationType != OT_TRIANGLE_LIST) { throw DeadlyImportError(Formatter::format() << "Only mesh operation type OT_TRIANGLE_LIST is supported. Found " << operationType); } @@ -555,9 +493,9 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) VertexData *src = (!usesSharedVertexData ? vertexData : parent->sharedVertexData); VertexElement *positionsElement = src->GetVertexElement(VertexElement::VES_POSITION); - VertexElement *normalsElement = src->GetVertexElement(VertexElement::VES_NORMAL); - VertexElement *uv1Element = src->GetVertexElement(VertexElement::VES_TEXTURE_COORDINATES, 0); - VertexElement *uv2Element = src->GetVertexElement(VertexElement::VES_TEXTURE_COORDINATES, 1); + VertexElement *normalsElement = src->GetVertexElement(VertexElement::VES_NORMAL); + VertexElement *uv1Element = src->GetVertexElement(VertexElement::VES_TEXTURE_COORDINATES, 0); + VertexElement *uv2Element = src->GetVertexElement(VertexElement::VES_TEXTURE_COORDINATES, 1); // Sanity checks if (!positionsElement) { @@ -578,22 +516,22 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) dest->mVertices = new aiVector3D[dest->mNumVertices]; // Source streams - MemoryStream *positions = src->VertexBuffer(positionsElement->source); - MemoryStream *normals = (normalsElement ? src->VertexBuffer(normalsElement->source) : 0); - MemoryStream *uv1 = (uv1Element ? src->VertexBuffer(uv1Element->source) : 0); - MemoryStream *uv2 = (uv2Element ? src->VertexBuffer(uv2Element->source) : 0); + MemoryStream *positions = src->VertexBuffer(positionsElement->source); + MemoryStream *normals = (normalsElement ? src->VertexBuffer(normalsElement->source) : 0); + MemoryStream *uv1 = (uv1Element ? src->VertexBuffer(uv1Element->source) : 0); + MemoryStream *uv2 = (uv2Element ? src->VertexBuffer(uv2Element->source) : 0); // Element size - const size_t sizePosition = positionsElement->Size(); - const size_t sizeNormal = (normalsElement ? normalsElement->Size() : 0); - const size_t sizeUv1 = (uv1Element ? uv1Element->Size() : 0); - const size_t sizeUv2 = (uv2Element ? uv2Element->Size() : 0); + const size_t sizePosition = positionsElement->Size(); + const size_t sizeNormal = (normalsElement ? normalsElement->Size() : 0); + const size_t sizeUv1 = (uv1Element ? uv1Element->Size() : 0); + const size_t sizeUv2 = (uv2Element ? uv2Element->Size() : 0); // Vertex width - const size_t vWidthPosition = src->VertexSize(positionsElement->source); - const size_t vWidthNormal = (normalsElement ? src->VertexSize(normalsElement->source) : 0); - const size_t vWidthUv1 = (uv1Element ? src->VertexSize(uv1Element->source) : 0); - const size_t vWidthUv2 = (uv2Element ? src->VertexSize(uv2Element->source) : 0); + const size_t vWidthPosition = src->VertexSize(positionsElement->source); + const size_t vWidthNormal = (normalsElement ? src->VertexSize(normalsElement->source) : 0); + const size_t vWidthUv1 = (uv1Element ? src->VertexSize(uv1Element->source) : 0); + const size_t vWidthUv2 = (uv2Element ? src->VertexSize(uv2Element->source) : 0); bool boneAssignments = src->HasBoneAssignments(); @@ -602,28 +540,20 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) dest->mNormals = new aiVector3D[dest->mNumVertices]; // Prepare UVs, ignoring incompatible UVs. - if (uv1) - { - if (uv1Element->type == VertexElement::VET_FLOAT2 || uv1Element->type == VertexElement::VET_FLOAT3) - { + if (uv1) { + if (uv1Element->type == VertexElement::VET_FLOAT2 || uv1Element->type == VertexElement::VET_FLOAT3) { dest->mNumUVComponents[0] = static_cast(uv1Element->ComponentCount()); dest->mTextureCoords[0] = new aiVector3D[dest->mNumVertices]; - } - else - { + } else { ASSIMP_LOG_WARN(Formatter::format() << "Ogre imported UV0 type " << uv1Element->TypeToString() << " is not compatible with Assimp. Ignoring UV."); uv1 = 0; } } - if (uv2) - { - if (uv2Element->type == VertexElement::VET_FLOAT2 || uv2Element->type == VertexElement::VET_FLOAT3) - { + if (uv2) { + if (uv2Element->type == VertexElement::VET_FLOAT2 || uv2Element->type == VertexElement::VET_FLOAT3) { dest->mNumUVComponents[1] = static_cast(uv2Element->ComponentCount()); dest->mTextureCoords[1] = new aiVector3D[dest->mNumVertices]; - } - else - { + } else { ASSIMP_LOG_WARN(Formatter::format() << "Ogre imported UV0 type " << uv2Element->TypeToString() << " is not compatible with Assimp. Ignoring UV."); uv2 = 0; } @@ -633,24 +563,19 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) aiVector3D *uv2Dest = (uv2 ? dest->mTextureCoords[1] : 0); MemoryStream *faces = indexData->buffer.get(); - for (size_t fi=0, isize=indexData->IndexSize(), fsize=indexData->FaceSize(); - fimNumFaces; ++fi) - { + for (size_t fi = 0, isize = indexData->IndexSize(), fsize = indexData->FaceSize(); + fi < dest->mNumFaces; ++fi) { // Source Ogre face aiFace ogreFace; ogreFace.mNumIndices = 3; ogreFace.mIndices = new unsigned int[3]; faces->Seek(fi * fsize, aiOrigin_SET); - if (indexData->is32bit) - { + if (indexData->is32bit) { faces->Read(&ogreFace.mIndices[0], isize, 3); - } - else - { + } else { uint16_t iout = 0; - for (size_t ii=0; ii<3; ++ii) - { + for (size_t ii = 0; ii < 3; ++ii) { faces->Read(&iout, isize, 1); ogreFace.mIndices[ii] = static_cast(iout); } @@ -662,8 +587,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) face.mIndices = new unsigned int[3]; const size_t pos = fi * 3; - for (size_t v=0; v<3; ++v) - { + for (size_t v = 0; v < 3; ++v) { const size_t newIndex = pos + v; // Write face index @@ -678,21 +602,18 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) positions->Read(&dest->mVertices[newIndex], sizePosition, 1); // Normal - if (normals) - { + if (normals) { normals->Seek((vWidthNormal * ogreVertexIndex) + normalsElement->offset, aiOrigin_SET); normals->Read(&dest->mNormals[newIndex], sizeNormal, 1); } // UV0 - if (uv1 && uv1Dest) - { + if (uv1 && uv1Dest) { uv1->Seek((vWidthUv1 * ogreVertexIndex) + uv1Element->offset, aiOrigin_SET); uv1->Read(&uv1Dest[newIndex], sizeUv1, 1); uv1Dest[newIndex].y = (uv1Dest[newIndex].y * -1) + 1; // Flip UV from Ogre to Assimp form } // UV1 - if (uv2 && uv2Dest) - { + if (uv2 && uv2Dest) { uv2->Seek((vWidthUv2 * ogreVertexIndex) + uv2Element->offset, aiOrigin_SET); uv2->Read(&uv2Dest[newIndex], sizeUv2, 1); uv2Dest[newIndex].y = (uv2Dest[newIndex].y * -1) + 1; // Flip UV from Ogre to Assimp form @@ -701,17 +622,15 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) } // Bones and bone weights - if (parent->skeleton && boneAssignments) - { + if (parent->skeleton && boneAssignments) { AssimpVertexBoneWeightList weights = src->AssimpBoneWeights(dest->mNumVertices); std::set referencedBones = src->ReferencedBonesByWeights(); dest->mNumBones = static_cast(referencedBones.size()); - dest->mBones = new aiBone*[dest->mNumBones]; + dest->mBones = new aiBone *[dest->mNumBones]; size_t assimpBoneIndex = 0; - for(std::set::const_iterator rbIter=referencedBones.begin(), rbEnd=referencedBones.end(); rbIter != rbEnd; ++rbIter, ++assimpBoneIndex) - { + for (std::set::const_iterator rbIter = referencedBones.begin(), rbEnd = referencedBones.end(); rbIter != rbEnd; ++rbIter, ++assimpBoneIndex) { Bone *bone = parent->skeleton->BoneById((*rbIter)); dest->mBones[assimpBoneIndex] = bone->ConvertToAssimpBone(parent->skeleton, weights[bone->id]); } @@ -723,45 +642,39 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) // MeshXml MeshXml::MeshXml() : - skeleton(0), - sharedVertexData(0) -{ + skeleton(0), + sharedVertexData(0) { } -MeshXml::~MeshXml() -{ +MeshXml::~MeshXml() { Reset(); } -void MeshXml::Reset() -{ +void MeshXml::Reset() { OGRE_SAFE_DELETE(skeleton) OGRE_SAFE_DELETE(sharedVertexData) - for(auto &mesh : subMeshes) { + for (auto &mesh : subMeshes) { OGRE_SAFE_DELETE(mesh) } subMeshes.clear(); } -size_t MeshXml::NumSubMeshes() const -{ +size_t MeshXml::NumSubMeshes() const { return subMeshes.size(); } -SubMeshXml *MeshXml::GetSubMesh(uint16_t index) const -{ - for(size_t i=0; iindex == index) return subMeshes[i]; return 0; } -void MeshXml::ConvertToAssimpScene(aiScene* dest) -{ +void MeshXml::ConvertToAssimpScene(aiScene *dest) { // Setup dest->mNumMeshes = static_cast(NumSubMeshes()); - dest->mMeshes = new aiMesh*[dest->mNumMeshes]; + dest->mMeshes = new aiMesh *[dest->mNumMeshes]; // Create root node dest->mRootNode = new aiNode(); @@ -769,36 +682,30 @@ void MeshXml::ConvertToAssimpScene(aiScene* dest) dest->mRootNode->mMeshes = new unsigned int[dest->mRootNode->mNumMeshes]; // Export meshes - for(size_t i=0; imNumMeshes; ++i) - { + for (size_t i = 0; i < dest->mNumMeshes; ++i) { dest->mMeshes[i] = subMeshes[i]->ConvertToAssimpMesh(this); dest->mRootNode->mMeshes[i] = static_cast(i); } // Export skeleton - if (skeleton) - { + if (skeleton) { // Bones - if (!skeleton->bones.empty()) - { + if (!skeleton->bones.empty()) { BoneList rootBones = skeleton->RootBones(); dest->mRootNode->mNumChildren = static_cast(rootBones.size()); - dest->mRootNode->mChildren = new aiNode*[dest->mRootNode->mNumChildren]; + dest->mRootNode->mChildren = new aiNode *[dest->mRootNode->mNumChildren]; - for(size_t i=0, len=rootBones.size(); imRootNode->mChildren[i] = rootBones[i]->ConvertToAssimpNode(skeleton, dest->mRootNode); } } // Animations - if (!skeleton->animations.empty()) - { + if (!skeleton->animations.empty()) { dest->mNumAnimations = static_cast(skeleton->animations.size()); - dest->mAnimations = new aiAnimation*[dest->mNumAnimations]; + dest->mAnimations = new aiAnimation *[dest->mNumAnimations]; - for(size_t i=0, len=skeleton->animations.size(); ianimations.size(); i < len; ++i) { dest->mAnimations[i] = skeleton->animations[i]->ConvertToAssimpAnimation(); } } @@ -808,24 +715,20 @@ void MeshXml::ConvertToAssimpScene(aiScene* dest) // SubMeshXml SubMeshXml::SubMeshXml() : - indexData(new IndexDataXml()), - vertexData(0) -{ + indexData(new IndexDataXml()), + vertexData(0) { } -SubMeshXml::~SubMeshXml() -{ +SubMeshXml::~SubMeshXml() { Reset(); } -void SubMeshXml::Reset() -{ +void SubMeshXml::Reset(){ OGRE_SAFE_DELETE(indexData) - OGRE_SAFE_DELETE(vertexData) + OGRE_SAFE_DELETE(vertexData) } -aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) -{ +aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) { aiMesh *dest = new aiMesh(); dest->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; @@ -855,14 +758,12 @@ aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) dest->mNormals = new aiVector3D[dest->mNumVertices]; // Prepare UVs - for(size_t uvi=0; uvimNumUVComponents[uvi] = 2; dest->mTextureCoords[uvi] = new aiVector3D[dest->mNumVertices]; } - for (size_t fi=0; fimNumFaces; ++fi) - { + for (size_t fi = 0; fi < dest->mNumFaces; ++fi) { // Source Ogre face aiFace &ogreFace = indexData->faces[fi]; @@ -872,8 +773,7 @@ aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) face.mIndices = new unsigned int[3]; const size_t pos = fi * 3; - for (size_t v=0; v<3; ++v) - { + for (size_t v = 0; v < 3; ++v) { const size_t newIndex = pos + v; // Write face index @@ -891,8 +791,7 @@ aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) dest->mNormals[newIndex] = src->normals[ogreVertexIndex]; // UVs - for(size_t uvi=0; uvimTextureCoords[uvi]; std::vector &uvSrc = src->uvs[uvi]; uvDest[newIndex] = uvSrc[ogreVertexIndex]; @@ -901,17 +800,15 @@ aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) } // Bones and bone weights - if (parent->skeleton && boneAssignments) - { + if (parent->skeleton && boneAssignments) { AssimpVertexBoneWeightList weights = src->AssimpBoneWeights(dest->mNumVertices); std::set referencedBones = src->ReferencedBonesByWeights(); dest->mNumBones = static_cast(referencedBones.size()); - dest->mBones = new aiBone*[dest->mNumBones]; + dest->mBones = new aiBone *[dest->mNumBones]; size_t assimpBoneIndex = 0; - for(std::set::const_iterator rbIter=referencedBones.begin(), rbEnd=referencedBones.end(); rbIter != rbEnd; ++rbIter, ++assimpBoneIndex) - { + for (std::set::const_iterator rbIter = referencedBones.begin(), rbEnd = referencedBones.end(); rbIter != rbEnd; ++rbIter, ++assimpBoneIndex) { Bone *bone = parent->skeleton->BoneById((*rbIter)); dest->mBones[assimpBoneIndex] = bone->ConvertToAssimpBone(parent->skeleton, weights[bone->id]); } @@ -923,48 +820,46 @@ aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) // Animation Animation::Animation(Skeleton *parent) : - parentMesh(NULL), - parentSkeleton(parent), - length(0.0f), - baseTime(-1.0f) -{ + parentMesh(nullptr), + parentSkeleton(parent), + length(0.0f), + baseTime(-1.0f) { + // empty } Animation::Animation(Mesh *parent) : - parentMesh(parent), - parentSkeleton(0), - length(0.0f), - baseTime(-1.0f) -{ + parentMesh(parent), + parentSkeleton(0), + length(0.0f), + baseTime(-1.0f) { + // empty } -VertexData *Animation::AssociatedVertexData(VertexAnimationTrack *track) const -{ - if (!parentMesh) - return 0; +VertexData *Animation::AssociatedVertexData(VertexAnimationTrack *track) const { + if (nullptr == parentMesh) { + return nullptr; + } bool sharedGeom = (track->target == 0); - if (sharedGeom) + if (sharedGeom) { return parentMesh->sharedVertexData; - else - return parentMesh->GetSubMesh(track->target-1)->vertexData; + } + + return parentMesh->GetSubMesh(track->target - 1)->vertexData; } -aiAnimation *Animation::ConvertToAssimpAnimation() -{ +aiAnimation *Animation::ConvertToAssimpAnimation() { aiAnimation *anim = new aiAnimation(); anim->mName = name; anim->mDuration = static_cast(length); anim->mTicksPerSecond = 1.0; // Tracks - if (!tracks.empty()) - { + if (!tracks.empty()) { anim->mNumChannels = static_cast(tracks.size()); - anim->mChannels = new aiNodeAnim*[anim->mNumChannels]; + anim->mChannels = new aiNodeAnim *[anim->mNumChannels]; - for(size_t i=0, len=tracks.size(); imChannels[i] = tracks[i].ConvertToAssimpAnimationNode(parentSkeleton); } } @@ -974,65 +869,54 @@ aiAnimation *Animation::ConvertToAssimpAnimation() // Skeleton Skeleton::Skeleton() : - bones(), - animations(), - blendMode(ANIMBLEND_AVERAGE) -{ + bones(), + animations(), + blendMode(ANIMBLEND_AVERAGE) { } -Skeleton::~Skeleton() -{ +Skeleton::~Skeleton() { Reset(); } -void Skeleton::Reset() -{ - for(auto &bone : bones) { +void Skeleton::Reset() { + for (auto &bone : bones) { OGRE_SAFE_DELETE(bone) } bones.clear(); - for(auto &anim : animations) { + for (auto &anim : animations) { OGRE_SAFE_DELETE(anim) } animations.clear(); } -BoneList Skeleton::RootBones() const -{ +BoneList Skeleton::RootBones() const { BoneList rootBones; - for(BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) - { + for (BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) { if (!(*iter)->IsParented()) rootBones.push_back((*iter)); } return rootBones; } -size_t Skeleton::NumRootBones() const -{ +size_t Skeleton::NumRootBones() const { size_t num = 0; - for(BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) - { + for (BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) { if (!(*iter)->IsParented()) num++; } return num; } -Bone *Skeleton::BoneByName(const std::string &name) const -{ - for(BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) - { +Bone *Skeleton::BoneByName(const std::string &name) const { + for (BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) { if ((*iter)->name == name) return (*iter); } return 0; } -Bone *Skeleton::BoneById(uint16_t id) const -{ - for(BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) - { +Bone *Skeleton::BoneById(uint16_t id) const { + for (BoneList::const_iterator iter = bones.begin(); iter != bones.end(); ++iter) { if ((*iter)->id == id) return (*iter); } @@ -1042,25 +926,21 @@ Bone *Skeleton::BoneById(uint16_t id) const // Bone Bone::Bone() : - id(0), - parent(0), - parentId(-1), - scale(1.0f, 1.0f, 1.0f) -{ + id(0), + parent(0), + parentId(-1), + scale(1.0f, 1.0f, 1.0f) { } -bool Bone::IsParented() const -{ +bool Bone::IsParented() const { return (parentId != -1 && parent != 0); } -uint16_t Bone::ParentId() const -{ +uint16_t Bone::ParentId() const { return static_cast(parentId); } -void Bone::AddChild(Bone *bone) -{ +void Bone::AddChild(Bone *bone) { if (!bone) return; if (bone->IsParented()) @@ -1071,8 +951,7 @@ void Bone::AddChild(Bone *bone) children.push_back(bone->id); } -void Bone::CalculateWorldMatrixAndDefaultPose(Skeleton *skeleton) -{ +void Bone::CalculateWorldMatrixAndDefaultPose(Skeleton *skeleton) { if (!IsParented()) worldMatrix = aiMatrix4x4(scale, rotation, position).Inverse(); else @@ -1081,8 +960,7 @@ void Bone::CalculateWorldMatrixAndDefaultPose(Skeleton *skeleton) defaultPose = aiMatrix4x4(scale, rotation, position); // Recursively for all children now that the parent matrix has been calculated. - for (auto boneId : children) - { + for (auto boneId : children) { Bone *child = skeleton->BoneById(boneId); if (!child) { throw DeadlyImportError(Formatter::format() << "CalculateWorldMatrixAndDefaultPose: Failed to find child bone " << boneId << " for parent " << id << " " << name); @@ -1091,21 +969,18 @@ void Bone::CalculateWorldMatrixAndDefaultPose(Skeleton *skeleton) } } -aiNode *Bone::ConvertToAssimpNode(Skeleton *skeleton, aiNode *parentNode) -{ +aiNode *Bone::ConvertToAssimpNode(Skeleton *skeleton, aiNode *parentNode) { // Bone node - aiNode* node = new aiNode(name); + aiNode *node = new aiNode(name); node->mParent = parentNode; node->mTransformation = defaultPose; // Children - if (!children.empty()) - { + if (!children.empty()) { node->mNumChildren = static_cast(children.size()); - node->mChildren = new aiNode*[node->mNumChildren]; + node->mChildren = new aiNode *[node->mNumChildren]; - for(size_t i=0, len=children.size(); iBoneById(children[i]); if (!child) { throw DeadlyImportError(Formatter::format() << "ConvertToAssimpNode: Failed to find child bone " << children[i] << " for parent " << id << " " << name); @@ -1116,14 +991,12 @@ aiNode *Bone::ConvertToAssimpNode(Skeleton *skeleton, aiNode *parentNode) return node; } -aiBone *Bone::ConvertToAssimpBone(Skeleton * /*parent*/, const std::vector &boneWeights) -{ +aiBone *Bone::ConvertToAssimpBone(Skeleton * /*parent*/, const std::vector &boneWeights) { aiBone *bone = new aiBone(); bone->mName = name; bone->mOffsetMatrix = worldMatrix; - if (!boneWeights.empty()) - { + if (!boneWeights.empty()) { bone->mNumWeights = static_cast(boneWeights.size()); bone->mWeights = new aiVertexWeight[boneWeights.size()]; memcpy(bone->mWeights, &boneWeights[0], boneWeights.size() * sizeof(aiVertexWeight)); @@ -1135,13 +1008,11 @@ aiBone *Bone::ConvertToAssimpBone(Skeleton * /*parent*/, const std::vectormScalingKeys = new aiVectorKey[numKeyframes]; nodeAnim->mNumPositionKeys = static_cast(numKeyframes); nodeAnim->mNumRotationKeys = static_cast(numKeyframes); - nodeAnim->mNumScalingKeys = static_cast(numKeyframes); + nodeAnim->mNumScalingKeys = static_cast(numKeyframes); - for(size_t kfi=0; kfidefaultPose * kfSource.Transform(); finalTransform.Decompose(scale, rot, pos); @@ -1190,17 +1062,15 @@ aiNodeAnim *VertexAnimationTrack::ConvertToAssimpAnimationNode(Skeleton *skeleto // TransformKeyFrame TransformKeyFrame::TransformKeyFrame() : - timePos(0.0f), - scale(1.0f, 1.0f, 1.0f) -{ + timePos(0.0f), + scale(1.0f, 1.0f, 1.0f) { } -aiMatrix4x4 TransformKeyFrame::Transform() -{ +aiMatrix4x4 TransformKeyFrame::Transform() { return aiMatrix4x4(scale, rotation, position); } -} // Ogre -} // Assimp +} // namespace Ogre +} // namespace Assimp #endif // ASSIMP_BUILD_NO_OGRE_IMPORTER diff --git a/code/AssetLib/Ogre/OgreXmlSerializer.cpp b/code/AssetLib/Ogre/OgreXmlSerializer.cpp index 406220a9d..31c2ee74e 100644 --- a/code/AssetLib/Ogre/OgreXmlSerializer.cpp +++ b/code/AssetLib/Ogre/OgreXmlSerializer.cpp @@ -268,7 +268,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) { throw DeadlyImportError("Root node is <" + m_currentNodeName + "> expecting "); } - ASSIMP_LOG_DEBUG("Reading Mesh"); + ASSIMP_LOG_VERBOSE_DEBUG("Reading Mesh"); NextNode(); @@ -294,7 +294,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) { ReadBoneAssignments(mesh->sharedVertexData); } else if (m_currentNodeName == nnSkeletonLink) { mesh->skeletonRef = ReadAttribute("name"); - ASSIMP_LOG_DEBUG_F("Read skeleton link ", mesh->skeletonRef); + ASSIMP_LOG_VERBOSE_DEBUG_F("Read skeleton link ", mesh->skeletonRef); NextNode(); } // Assimp incompatible/ignored nodes @@ -305,7 +305,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) { void OgreXmlSerializer::ReadGeometry(VertexDataXml *dest) { dest->count = ReadAttribute("vertexcount"); - ASSIMP_LOG_DEBUG_F(" - Reading geometry of ", dest->count, " vertices"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Reading geometry of ", dest->count, " vertices"); NextNode(); while (m_currentNodeName == nnVertexBuffer) { @@ -325,19 +325,19 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest) { } if (positions) { - ASSIMP_LOG_DEBUG(" - Contains positions"); + ASSIMP_LOG_VERBOSE_DEBUG(" - Contains positions"); dest->positions.reserve(dest->count); } if (normals) { - ASSIMP_LOG_DEBUG(" - Contains normals"); + ASSIMP_LOG_VERBOSE_DEBUG(" - Contains normals"); dest->normals.reserve(dest->count); } if (tangents) { - ASSIMP_LOG_DEBUG(" - Contains tangents"); + ASSIMP_LOG_VERBOSE_DEBUG(" - Contains tangents"); dest->tangents.reserve(dest->count); } if (uvs > 0) { - ASSIMP_LOG_DEBUG_F(" - Contains ", uvs, " texture coords"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Contains ", uvs, " texture coords"); dest->uvs.resize(uvs); for (size_t i = 0, len = dest->uvs.size(); i < len; ++i) { dest->uvs[i].reserve(dest->count); @@ -464,9 +464,9 @@ void OgreXmlSerializer::ReadSubMesh(MeshXml *mesh) { submesh->usesSharedVertexData = ReadAttribute(anUseSharedVertices); } - ASSIMP_LOG_DEBUG_F("Reading SubMesh ", mesh->subMeshes.size()); - ASSIMP_LOG_DEBUG_F(" - Material: '", submesh->materialRef, "'"); - ASSIMP_LOG_DEBUG_F(" - Uses shared geometry: ", (submesh->usesSharedVertexData ? "true" : "false")); + ASSIMP_LOG_VERBOSE_DEBUG_F("Reading SubMesh ", mesh->subMeshes.size()); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Material: '", submesh->materialRef, "'"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Uses shared geometry: ", (submesh->usesSharedVertexData ? "true" : "false")); // TODO: maybe we have always just 1 faces and 1 geometry and always in this order. this loop will only work correct, when the order // of faces and geometry changed, and not if we have more than one of one @@ -505,7 +505,7 @@ void OgreXmlSerializer::ReadSubMesh(MeshXml *mesh) { } if (submesh->indexData->faces.size() == submesh->indexData->faceCount) { - ASSIMP_LOG_DEBUG_F(" - Faces ", submesh->indexData->faceCount); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - Faces ", submesh->indexData->faceCount); } else { throw DeadlyImportError(Formatter::format() << "Read only " << submesh->indexData->faces.size() << " faces when should have read " << submesh->indexData->faceCount); } @@ -571,7 +571,7 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest) { } } - ASSIMP_LOG_DEBUG_F(" - ", dest->boneAssignments.size(), " bone assignments"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" - ", dest->boneAssignments.size(), " bone assignments"); } // Skeleton @@ -648,7 +648,7 @@ void OgreXmlSerializer::ReadSkeleton(Skeleton *skeleton) { throw DeadlyImportError("Root node is <" + m_currentNodeName + "> expecting "); } - ASSIMP_LOG_DEBUG("Reading Skeleton"); + ASSIMP_LOG_VERBOSE_DEBUG("Reading Skeleton"); // Optional blend mode from root node if (HasAttribute("blendmode")) { @@ -678,7 +678,7 @@ void OgreXmlSerializer::ReadAnimations(Skeleton *skeleton) { throw DeadlyImportError("Cannot read for a Skeleton without bones"); } - ASSIMP_LOG_DEBUG(" - Animations"); + ASSIMP_LOG_VERBOSE_DEBUG(" - Animations"); NextNode(); while (m_currentNodeName == nnAnimation) { @@ -693,7 +693,7 @@ void OgreXmlSerializer::ReadAnimations(Skeleton *skeleton) { ReadAnimationTracks(anim); skeleton->animations.push_back(anim); - ASSIMP_LOG_DEBUG_F(" ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)"); + ASSIMP_LOG_VERBOSE_DEBUG_F(" ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)"); } } @@ -793,7 +793,7 @@ static bool BoneCompare(Bone *a, Bone *b) { } void OgreXmlSerializer::ReadBones(Skeleton *skeleton) { - ASSIMP_LOG_DEBUG(" - Bones"); + ASSIMP_LOG_VERBOSE_DEBUG(" - Bones"); NextNode(); while (m_currentNodeName == nnBone) { @@ -851,7 +851,7 @@ void OgreXmlSerializer::ReadBones(Skeleton *skeleton) { as per the Ogre skeleton spec. It might be more that other (later) code in this imported does not break. */ for (size_t i = 0, len = skeleton->bones.size(); i < len; ++i) { Bone *b = skeleton->bones[i]; - ASSIMP_LOG_DEBUG_F(" ", b->id, " ", b->name); + ASSIMP_LOG_VERBOSE_DEBUG_F(" ", b->id, " ", b->name); if (b->id != static_cast(i)) { throw DeadlyImportError(Formatter::format() << "Bone ids are not in sequence starting from 0. Missing index " << i); diff --git a/code/AssetLib/Ply/PlyExporter.cpp b/code/AssetLib/Ply/PlyExporter.cpp index 28ff0c602..d82c55ca9 100644 --- a/code/AssetLib/Ply/PlyExporter.cpp +++ b/code/AssetLib/Ply/PlyExporter.cpp @@ -77,7 +77,7 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write the file. std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .ply file: " + std::string(pFile)); } @@ -91,7 +91,7 @@ void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene* // we're still here - export successfully completed. Write the file. std::unique_ptr outfile(pIOSystem->Open(pFile, "wb")); - if (outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .ply file: " + std::string(pFile)); } diff --git a/code/AssetLib/Ply/PlyLoader.cpp b/code/AssetLib/Ply/PlyLoader.cpp index 8f41bd1a0..b8dbf2598 100644 --- a/code/AssetLib/Ply/PlyLoader.cpp +++ b/code/AssetLib/Ply/PlyLoader.cpp @@ -693,7 +693,7 @@ void PLYImporter::GetMaterialColor(const std::vector &avL unsigned int aiPositions[4], PLY::EDataType aiTypes[4], aiColor4D *clrOut) { - ai_assert(NULL != clrOut); + ai_assert(nullptr != clrOut); if (0xFFFFFFFF == aiPositions[0]) clrOut->r = 0.0f; @@ -736,7 +736,7 @@ void PLYImporter::GetMaterialColor(const std::vector &avL // ------------------------------------------------------------------------------------------------ // Extract a material from the PLY DOM void PLYImporter::LoadMaterial(std::vector *pvOut, std::string &defaultTexture, const bool pointsOnly) { - ai_assert(NULL != pvOut); + ai_assert(nullptr != pvOut); // diffuse[4], specular[4], ambient[4] // rgba order @@ -752,7 +752,7 @@ void PLYImporter::LoadMaterial(std::vector *pvOut, std::string &de { EDT_Char, EDT_Char, EDT_Char, EDT_Char }, { EDT_Char, EDT_Char, EDT_Char, EDT_Char } }; - PLY::ElementInstanceList *pcList = NULL; + PLY::ElementInstanceList *pcList = nullptr; unsigned int iPhong = 0xFFFFFFFF; PLY::EDataType ePhong = EDT_Char; @@ -835,7 +835,7 @@ void PLYImporter::LoadMaterial(std::vector *pvOut, std::string &de } } // check whether we have a valid source for the material data - if (NULL != pcList) { + if (nullptr != pcList) { for (std::vector::const_iterator i = pcList->alInstances.begin(); i != pcList->alInstances.end(); ++i) { aiColor4D clrOut; aiMaterial *pcHelper = new aiMaterial(); diff --git a/code/AssetLib/Ply/PlyParser.cpp b/code/AssetLib/Ply/PlyParser.cpp index d47ca5b6f..6fd7044f1 100644 --- a/code/AssetLib/Ply/PlyParser.cpp +++ b/code/AssetLib/Ply/PlyParser.cpp @@ -42,285 +42,201 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Implementation of the PLY parser class */ - #ifndef ASSIMP_BUILD_NO_PLY_IMPORTER +#include "PlyLoader.h" +#include #include #include -#include -#include "PlyLoader.h" using namespace Assimp; // ------------------------------------------------------------------------------------------------ PLY::EDataType PLY::Property::ParseDataType(std::vector &buffer) { - ai_assert(!buffer.empty()); + ai_assert(!buffer.empty()); - PLY::EDataType eOut = PLY::EDT_INVALID; + PLY::EDataType eOut = PLY::EDT_INVALID; - if (PLY::DOM::TokenMatch(buffer, "char", 4) || - PLY::DOM::TokenMatch(buffer, "int8", 4)) - { - eOut = PLY::EDT_Char; - } - else if (PLY::DOM::TokenMatch(buffer, "uchar", 5) || - PLY::DOM::TokenMatch(buffer, "uint8", 5)) - { - eOut = PLY::EDT_UChar; - } - else if (PLY::DOM::TokenMatch(buffer, "short", 5) || - PLY::DOM::TokenMatch(buffer, "int16", 5)) - { - eOut = PLY::EDT_Short; - } - else if (PLY::DOM::TokenMatch(buffer, "ushort", 6) || - PLY::DOM::TokenMatch(buffer, "uint16", 6)) - { - eOut = PLY::EDT_UShort; - } - else if (PLY::DOM::TokenMatch(buffer, "int32", 5) || PLY::DOM::TokenMatch(buffer, "int", 3)) - { - eOut = PLY::EDT_Int; - } - else if (PLY::DOM::TokenMatch(buffer, "uint32", 6) || PLY::DOM::TokenMatch(buffer, "uint", 4)) - { - eOut = PLY::EDT_UInt; - } - else if (PLY::DOM::TokenMatch(buffer, "float", 5) || PLY::DOM::TokenMatch(buffer, "float32", 7)) - { - eOut = PLY::EDT_Float; - } - else if (PLY::DOM::TokenMatch(buffer, "double64", 8) || PLY::DOM::TokenMatch(buffer, "double", 6) || - PLY::DOM::TokenMatch(buffer, "float64", 7)) - { - eOut = PLY::EDT_Double; - } - if (PLY::EDT_INVALID == eOut) - { - ASSIMP_LOG_INFO("Found unknown data type in PLY file. This is OK"); - } + if (PLY::DOM::TokenMatch(buffer, "char", 4) || + PLY::DOM::TokenMatch(buffer, "int8", 4)) { + eOut = PLY::EDT_Char; + } else if (PLY::DOM::TokenMatch(buffer, "uchar", 5) || + PLY::DOM::TokenMatch(buffer, "uint8", 5)) { + eOut = PLY::EDT_UChar; + } else if (PLY::DOM::TokenMatch(buffer, "short", 5) || + PLY::DOM::TokenMatch(buffer, "int16", 5)) { + eOut = PLY::EDT_Short; + } else if (PLY::DOM::TokenMatch(buffer, "ushort", 6) || + PLY::DOM::TokenMatch(buffer, "uint16", 6)) { + eOut = PLY::EDT_UShort; + } else if (PLY::DOM::TokenMatch(buffer, "int32", 5) || PLY::DOM::TokenMatch(buffer, "int", 3)) { + eOut = PLY::EDT_Int; + } else if (PLY::DOM::TokenMatch(buffer, "uint32", 6) || PLY::DOM::TokenMatch(buffer, "uint", 4)) { + eOut = PLY::EDT_UInt; + } else if (PLY::DOM::TokenMatch(buffer, "float", 5) || PLY::DOM::TokenMatch(buffer, "float32", 7)) { + eOut = PLY::EDT_Float; + } else if (PLY::DOM::TokenMatch(buffer, "double64", 8) || PLY::DOM::TokenMatch(buffer, "double", 6) || + PLY::DOM::TokenMatch(buffer, "float64", 7)) { + eOut = PLY::EDT_Double; + } + if (PLY::EDT_INVALID == eOut) { + ASSIMP_LOG_INFO("Found unknown data type in PLY file. This is OK"); + } - return eOut; + return eOut; } // ------------------------------------------------------------------------------------------------ PLY::ESemantic PLY::Property::ParseSemantic(std::vector &buffer) { - ai_assert(!buffer.empty()); + ai_assert(!buffer.empty()); - PLY::ESemantic eOut = PLY::EST_INVALID; - if (PLY::DOM::TokenMatch(buffer, "red", 3)) { - eOut = PLY::EST_Red; - } - else if (PLY::DOM::TokenMatch(buffer, "green", 5)) { - eOut = PLY::EST_Green; - } - else if (PLY::DOM::TokenMatch(buffer, "blue", 4)) { - eOut = PLY::EST_Blue; - } - else if (PLY::DOM::TokenMatch(buffer, "alpha", 5)) { - eOut = PLY::EST_Alpha; - } - else if (PLY::DOM::TokenMatch(buffer, "vertex_index", 12) || PLY::DOM::TokenMatch(buffer, "vertex_indices", 14)) { - eOut = PLY::EST_VertexIndex; - } - else if (PLY::DOM::TokenMatch(buffer, "texcoord", 8)) // Manage uv coords on faces - { - eOut = PLY::EST_TextureCoordinates; - } - else if (PLY::DOM::TokenMatch(buffer, "material_index", 14)) - { - eOut = PLY::EST_MaterialIndex; - } - else if (PLY::DOM::TokenMatch(buffer, "ambient_red", 11)) - { - eOut = PLY::EST_AmbientRed; - } - else if (PLY::DOM::TokenMatch(buffer, "ambient_green", 13)) - { - eOut = PLY::EST_AmbientGreen; - } - else if (PLY::DOM::TokenMatch(buffer, "ambient_blue", 12)) - { - eOut = PLY::EST_AmbientBlue; - } - else if (PLY::DOM::TokenMatch(buffer, "ambient_alpha", 13)) - { - eOut = PLY::EST_AmbientAlpha; - } - else if (PLY::DOM::TokenMatch(buffer, "diffuse_red", 11)) - { - eOut = PLY::EST_DiffuseRed; - } - else if (PLY::DOM::TokenMatch(buffer, "diffuse_green", 13)) - { - eOut = PLY::EST_DiffuseGreen; - } - else if (PLY::DOM::TokenMatch(buffer, "diffuse_blue", 12)) - { - eOut = PLY::EST_DiffuseBlue; - } - else if (PLY::DOM::TokenMatch(buffer, "diffuse_alpha", 13)) - { - eOut = PLY::EST_DiffuseAlpha; - } - else if (PLY::DOM::TokenMatch(buffer, "specular_red", 12)) - { - eOut = PLY::EST_SpecularRed; - } - else if (PLY::DOM::TokenMatch(buffer, "specular_green", 14)) - { - eOut = PLY::EST_SpecularGreen; - } - else if (PLY::DOM::TokenMatch(buffer, "specular_blue", 13)) - { - eOut = PLY::EST_SpecularBlue; - } - else if (PLY::DOM::TokenMatch(buffer, "specular_alpha", 14)) - { - eOut = PLY::EST_SpecularAlpha; - } - else if (PLY::DOM::TokenMatch(buffer, "opacity", 7)) - { - eOut = PLY::EST_Opacity; - } - else if (PLY::DOM::TokenMatch(buffer, "specular_power", 14)) - { - eOut = PLY::EST_PhongPower; - } - else if (PLY::DOM::TokenMatch(buffer, "r", 1)) - { - eOut = PLY::EST_Red; - } - else if (PLY::DOM::TokenMatch(buffer, "g", 1)) - { - eOut = PLY::EST_Green; - } - else if (PLY::DOM::TokenMatch(buffer, "b", 1)) - { - eOut = PLY::EST_Blue; - } + PLY::ESemantic eOut = PLY::EST_INVALID; + if (PLY::DOM::TokenMatch(buffer, "red", 3)) { + eOut = PLY::EST_Red; + } else if (PLY::DOM::TokenMatch(buffer, "green", 5)) { + eOut = PLY::EST_Green; + } else if (PLY::DOM::TokenMatch(buffer, "blue", 4)) { + eOut = PLY::EST_Blue; + } else if (PLY::DOM::TokenMatch(buffer, "alpha", 5)) { + eOut = PLY::EST_Alpha; + } else if (PLY::DOM::TokenMatch(buffer, "vertex_index", 12) || PLY::DOM::TokenMatch(buffer, "vertex_indices", 14)) { + eOut = PLY::EST_VertexIndex; + } else if (PLY::DOM::TokenMatch(buffer, "texcoord", 8)) // Manage uv coords on faces + { + eOut = PLY::EST_TextureCoordinates; + } else if (PLY::DOM::TokenMatch(buffer, "material_index", 14)) { + eOut = PLY::EST_MaterialIndex; + } else if (PLY::DOM::TokenMatch(buffer, "ambient_red", 11)) { + eOut = PLY::EST_AmbientRed; + } else if (PLY::DOM::TokenMatch(buffer, "ambient_green", 13)) { + eOut = PLY::EST_AmbientGreen; + } else if (PLY::DOM::TokenMatch(buffer, "ambient_blue", 12)) { + eOut = PLY::EST_AmbientBlue; + } else if (PLY::DOM::TokenMatch(buffer, "ambient_alpha", 13)) { + eOut = PLY::EST_AmbientAlpha; + } else if (PLY::DOM::TokenMatch(buffer, "diffuse_red", 11)) { + eOut = PLY::EST_DiffuseRed; + } else if (PLY::DOM::TokenMatch(buffer, "diffuse_green", 13)) { + eOut = PLY::EST_DiffuseGreen; + } else if (PLY::DOM::TokenMatch(buffer, "diffuse_blue", 12)) { + eOut = PLY::EST_DiffuseBlue; + } else if (PLY::DOM::TokenMatch(buffer, "diffuse_alpha", 13)) { + eOut = PLY::EST_DiffuseAlpha; + } else if (PLY::DOM::TokenMatch(buffer, "specular_red", 12)) { + eOut = PLY::EST_SpecularRed; + } else if (PLY::DOM::TokenMatch(buffer, "specular_green", 14)) { + eOut = PLY::EST_SpecularGreen; + } else if (PLY::DOM::TokenMatch(buffer, "specular_blue", 13)) { + eOut = PLY::EST_SpecularBlue; + } else if (PLY::DOM::TokenMatch(buffer, "specular_alpha", 14)) { + eOut = PLY::EST_SpecularAlpha; + } else if (PLY::DOM::TokenMatch(buffer, "opacity", 7)) { + eOut = PLY::EST_Opacity; + } else if (PLY::DOM::TokenMatch(buffer, "specular_power", 14)) { + eOut = PLY::EST_PhongPower; + } else if (PLY::DOM::TokenMatch(buffer, "r", 1)) { + eOut = PLY::EST_Red; + } else if (PLY::DOM::TokenMatch(buffer, "g", 1)) { + eOut = PLY::EST_Green; + } else if (PLY::DOM::TokenMatch(buffer, "b", 1)) { + eOut = PLY::EST_Blue; + } - // NOTE: Blender3D exports texture coordinates as s,t tuples - else if (PLY::DOM::TokenMatch(buffer, "u", 1) || PLY::DOM::TokenMatch(buffer, "s", 1) || PLY::DOM::TokenMatch(buffer, "tx", 2) || PLY::DOM::TokenMatch(buffer, "texture_u", 9)) - { - eOut = PLY::EST_UTextureCoord; - } - else if (PLY::DOM::TokenMatch(buffer, "v", 1) || PLY::DOM::TokenMatch(buffer, "t", 1) || PLY::DOM::TokenMatch(buffer, "ty", 2) || PLY::DOM::TokenMatch(buffer, "texture_v", 9)) - { - eOut = PLY::EST_VTextureCoord; - } - else if (PLY::DOM::TokenMatch(buffer, "x", 1)) - { - eOut = PLY::EST_XCoord; - } - else if (PLY::DOM::TokenMatch(buffer, "y", 1)) { - eOut = PLY::EST_YCoord; - } - else if (PLY::DOM::TokenMatch(buffer, "z", 1)) { - eOut = PLY::EST_ZCoord; - } - else if (PLY::DOM::TokenMatch(buffer, "nx", 2)) { - eOut = PLY::EST_XNormal; - } - else if (PLY::DOM::TokenMatch(buffer, "ny", 2)) { - eOut = PLY::EST_YNormal; - } - else if (PLY::DOM::TokenMatch(buffer, "nz", 2)) { - eOut = PLY::EST_ZNormal; - } - else { - ASSIMP_LOG_INFO("Found unknown property semantic in file. This is ok"); - PLY::DOM::SkipLine(buffer); - } - return eOut; + // NOTE: Blender3D exports texture coordinates as s,t tuples + else if (PLY::DOM::TokenMatch(buffer, "u", 1) || PLY::DOM::TokenMatch(buffer, "s", 1) || PLY::DOM::TokenMatch(buffer, "tx", 2) || PLY::DOM::TokenMatch(buffer, "texture_u", 9)) { + eOut = PLY::EST_UTextureCoord; + } else if (PLY::DOM::TokenMatch(buffer, "v", 1) || PLY::DOM::TokenMatch(buffer, "t", 1) || PLY::DOM::TokenMatch(buffer, "ty", 2) || PLY::DOM::TokenMatch(buffer, "texture_v", 9)) { + eOut = PLY::EST_VTextureCoord; + } else if (PLY::DOM::TokenMatch(buffer, "x", 1)) { + eOut = PLY::EST_XCoord; + } else if (PLY::DOM::TokenMatch(buffer, "y", 1)) { + eOut = PLY::EST_YCoord; + } else if (PLY::DOM::TokenMatch(buffer, "z", 1)) { + eOut = PLY::EST_ZCoord; + } else if (PLY::DOM::TokenMatch(buffer, "nx", 2)) { + eOut = PLY::EST_XNormal; + } else if (PLY::DOM::TokenMatch(buffer, "ny", 2)) { + eOut = PLY::EST_YNormal; + } else if (PLY::DOM::TokenMatch(buffer, "nz", 2)) { + eOut = PLY::EST_ZNormal; + } else { + ASSIMP_LOG_INFO("Found unknown property semantic in file. This is ok"); + PLY::DOM::SkipLine(buffer); + } + return eOut; } // ------------------------------------------------------------------------------------------------ -bool PLY::Property::ParseProperty(std::vector &buffer, PLY::Property* pOut) -{ - ai_assert(!buffer.empty()); +bool PLY::Property::ParseProperty(std::vector &buffer, PLY::Property *pOut) { + ai_assert(!buffer.empty()); - // Forms supported: - // "property float x" - // "property list uchar int vertex_index" + // Forms supported: + // "property float x" + // "property list uchar int vertex_index" - // skip leading spaces - if (!PLY::DOM::SkipSpaces(buffer)) { - return false; - } - - // skip the "property" string at the beginning - if (!PLY::DOM::TokenMatch(buffer, "property", 8)) - { - // seems not to be a valid property entry - return false; - } - // get next word - if (!PLY::DOM::SkipSpaces(buffer)) { - return false; - } - if (PLY::DOM::TokenMatch(buffer, "list", 4)) - { - pOut->bIsList = true; - - // seems to be a list. - if (EDT_INVALID == (pOut->eFirstType = PLY::Property::ParseDataType(buffer))) - { - // unable to parse list size data type - PLY::DOM::SkipLine(buffer); - return false; + // skip leading spaces + if (!PLY::DOM::SkipSpaces(buffer)) { + return false; } - if (!PLY::DOM::SkipSpaces(buffer))return false; - if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer))) - { - // unable to parse list data type - PLY::DOM::SkipLine(buffer); - return false; + + // skip the "property" string at the beginning + if (!PLY::DOM::TokenMatch(buffer, "property", 8)) { + // seems not to be a valid property entry + return false; } - } - else - { - if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer))) - { - // unable to parse data type. Skip the property - PLY::DOM::SkipLine(buffer); - return false; + // get next word + if (!PLY::DOM::SkipSpaces(buffer)) { + return false; } - } + if (PLY::DOM::TokenMatch(buffer, "list", 4)) { + pOut->bIsList = true; - if (!PLY::DOM::SkipSpaces(buffer)) - return false; + // seems to be a list. + if (EDT_INVALID == (pOut->eFirstType = PLY::Property::ParseDataType(buffer))) { + // unable to parse list size data type + PLY::DOM::SkipLine(buffer); + return false; + } + if (!PLY::DOM::SkipSpaces(buffer)) return false; + if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer))) { + // unable to parse list data type + PLY::DOM::SkipLine(buffer); + return false; + } + } else { + if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer))) { + // unable to parse data type. Skip the property + PLY::DOM::SkipLine(buffer); + return false; + } + } - pOut->Semantic = PLY::Property::ParseSemantic(buffer); + if (!PLY::DOM::SkipSpaces(buffer)) + return false; - if (PLY::EST_INVALID == pOut->Semantic) - { - ASSIMP_LOG_INFO("Found unknown semantic in PLY file. This is OK"); - std::string(&buffer[0], &buffer[0] + strlen(&buffer[0])); - } + pOut->Semantic = PLY::Property::ParseSemantic(buffer); - PLY::DOM::SkipSpacesAndLineEnd(buffer); - return true; + if (PLY::EST_INVALID == pOut->Semantic) { + ASSIMP_LOG_INFO("Found unknown semantic in PLY file. This is OK"); + std::string(&buffer[0], &buffer[0] + strlen(&buffer[0])); + } + + PLY::DOM::SkipSpacesAndLineEnd(buffer); + return true; } // ------------------------------------------------------------------------------------------------ -PLY::EElementSemantic PLY::Element::ParseSemantic(std::vector &buffer) -{ - ai_assert(!buffer.empty()); +PLY::EElementSemantic PLY::Element::ParseSemantic(std::vector &buffer) { + ai_assert(!buffer.empty()); - PLY::EElementSemantic eOut = PLY::EEST_INVALID; - if (PLY::DOM::TokenMatch(buffer, "vertex", 6)) - { - eOut = PLY::EEST_Vertex; - } - else if (PLY::DOM::TokenMatch(buffer, "face", 4)) - { - eOut = PLY::EEST_Face; - } - else if (PLY::DOM::TokenMatch(buffer, "tristrips", 9)) - { - eOut = PLY::EEST_TriStrip; - } + PLY::EElementSemantic eOut = PLY::EEST_INVALID; + if (PLY::DOM::TokenMatch(buffer, "vertex", 6)) { + eOut = PLY::EEST_Vertex; + } else if (PLY::DOM::TokenMatch(buffer, "face", 4)) { + eOut = PLY::EEST_Face; + } else if (PLY::DOM::TokenMatch(buffer, "tristrips", 9)) { + eOut = PLY::EEST_TriStrip; + } #if 0 // TODO: maybe implement this? else if (PLY::DOM::TokenMatch(buffer,"range_grid",10)) @@ -328,815 +244,715 @@ PLY::EElementSemantic PLY::Element::ParseSemantic(std::vector &buffer) eOut = PLY::EEST_Face; } #endif - else if (PLY::DOM::TokenMatch(buffer, "edge", 4)) - { - eOut = PLY::EEST_Edge; - } - else if (PLY::DOM::TokenMatch(buffer, "material", 8)) - { - eOut = PLY::EEST_Material; - } - else if (PLY::DOM::TokenMatch(buffer, "TextureFile", 11)) - { - eOut = PLY::EEST_TextureFile; - } + else if (PLY::DOM::TokenMatch(buffer, "edge", 4)) { + eOut = PLY::EEST_Edge; + } else if (PLY::DOM::TokenMatch(buffer, "material", 8)) { + eOut = PLY::EEST_Material; + } else if (PLY::DOM::TokenMatch(buffer, "TextureFile", 11)) { + eOut = PLY::EEST_TextureFile; + } - return eOut; + return eOut; } // ------------------------------------------------------------------------------------------------ -bool PLY::Element::ParseElement(IOStreamBuffer &streamBuffer, std::vector &buffer, PLY::Element* pOut) -{ - ai_assert(NULL != pOut); - // Example format: "element vertex 8" +bool PLY::Element::ParseElement(IOStreamBuffer &streamBuffer, std::vector &buffer, PLY::Element *pOut) { + ai_assert(nullptr != pOut); + // Example format: "element vertex 8" - // skip leading spaces - if (!PLY::DOM::SkipSpaces(buffer)) - { - return false; - } + // skip leading spaces + if (!PLY::DOM::SkipSpaces(buffer)) { + return false; + } - // skip the "element" string at the beginning - if (!PLY::DOM::TokenMatch(buffer, "element", 7) && !PLY::DOM::TokenMatch(buffer, "comment", 7)) - { - // seems not to be a valid property entry - return false; - } - // get next word - if (!PLY::DOM::SkipSpaces(buffer)) - return false; + // skip the "element" string at the beginning + if (!PLY::DOM::TokenMatch(buffer, "element", 7) && !PLY::DOM::TokenMatch(buffer, "comment", 7)) { + // seems not to be a valid property entry + return false; + } + // get next word + if (!PLY::DOM::SkipSpaces(buffer)) + return false; - // parse the semantic of the element - pOut->eSemantic = PLY::Element::ParseSemantic(buffer); - if (PLY::EEST_INVALID == pOut->eSemantic) - { - // if the exact semantic can't be determined, just store - // the original string identifier - pOut->szName = std::string(&buffer[0], &buffer[0] + strlen(&buffer[0])); - } + // parse the semantic of the element + pOut->eSemantic = PLY::Element::ParseSemantic(buffer); + if (PLY::EEST_INVALID == pOut->eSemantic) { + // if the exact semantic can't be determined, just store + // the original string identifier + pOut->szName = std::string(&buffer[0], &buffer[0] + strlen(&buffer[0])); + } - if (!PLY::DOM::SkipSpaces(buffer)) - return false; + if (!PLY::DOM::SkipSpaces(buffer)) + return false; - if (PLY::EEST_TextureFile == pOut->eSemantic) - { - char* endPos = &buffer[0] + (strlen(&buffer[0]) - 1); - pOut->szName = std::string(&buffer[0], endPos); + if (PLY::EEST_TextureFile == pOut->eSemantic) { + char *endPos = &buffer[0] + (strlen(&buffer[0]) - 1); + pOut->szName = std::string(&buffer[0], endPos); + + // go to the next line + PLY::DOM::SkipSpacesAndLineEnd(buffer); + + return true; + } + + //parse the number of occurrences of this element + const char *pCur = (char *)&buffer[0]; + pOut->NumOccur = strtoul10(pCur, &pCur); // go to the next line PLY::DOM::SkipSpacesAndLineEnd(buffer); - return true; - } + // now parse all properties of the element + while (true) { + streamBuffer.getNextLine(buffer); + pCur = (char *)&buffer[0]; - //parse the number of occurrences of this element - const char* pCur = (char*)&buffer[0]; - pOut->NumOccur = strtoul10(pCur, &pCur); + // skip all comments + PLY::DOM::SkipComments(buffer); - // go to the next line - PLY::DOM::SkipSpacesAndLineEnd(buffer); + PLY::Property prop; + if (!PLY::Property::ParseProperty(buffer, &prop)) + break; - // now parse all properties of the element - while (true) - { - streamBuffer.getNextLine(buffer); - pCur = (char*)&buffer[0]; - - // skip all comments - PLY::DOM::SkipComments(buffer); - - PLY::Property prop; - if (!PLY::Property::ParseProperty(buffer, &prop)) - break; - - pOut->alProperties.push_back(prop); - } - - return true; -} - -// ------------------------------------------------------------------------------------------------ -bool PLY::DOM::SkipSpaces(std::vector &buffer) -{ - const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0]; - bool ret = false; - if (pCur) - { - const char* szCur = pCur; - ret = Assimp::SkipSpaces(pCur, &pCur); - - uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; - buffer.erase(buffer.begin(), buffer.begin() + iDiff); - return ret; - } - - return ret; -} - -bool PLY::DOM::SkipLine(std::vector &buffer) -{ - const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0]; - bool ret = false; - if (pCur) - { - const char* szCur = pCur; - ret = Assimp::SkipLine(pCur, &pCur); - - uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; - buffer.erase(buffer.begin(), buffer.begin() + iDiff); - return ret; - } - - return ret; -} - -bool PLY::DOM::TokenMatch(std::vector &buffer, const char* token, unsigned int len) -{ - const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0]; - bool ret = false; - if (pCur) - { - const char* szCur = pCur; - ret = Assimp::TokenMatch(pCur, token, len); - - uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; - buffer.erase(buffer.begin(), buffer.begin() + iDiff); - return ret; - } - - return ret; -} - -bool PLY::DOM::SkipSpacesAndLineEnd(std::vector &buffer) -{ - const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0]; - bool ret = false; - if (pCur) - { - const char* szCur = pCur; - ret = Assimp::SkipSpacesAndLineEnd(pCur, &pCur); - - uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; - buffer.erase(buffer.begin(), buffer.begin() + iDiff); - return ret; - } - - return ret; -} - -bool PLY::DOM::SkipComments(std::vector &buffer) -{ - ai_assert(!buffer.empty()); - - std::vector nbuffer = buffer; - // skip spaces - if (!SkipSpaces(nbuffer)) { - return false; - } - - if (TokenMatch(nbuffer, "comment", 7)) - { - if (!SkipSpaces(nbuffer)) - SkipLine(nbuffer); - - if (!TokenMatch(nbuffer, "TextureFile", 11)) - { - SkipLine(nbuffer); - buffer = nbuffer; - return true; + pOut->alProperties.push_back(prop); } return true; - } +} - return false; +// ------------------------------------------------------------------------------------------------ +bool PLY::DOM::SkipSpaces(std::vector &buffer) { + const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0]; + bool ret = false; + if (pCur) { + const char *szCur = pCur; + ret = Assimp::SkipSpaces(pCur, &pCur); + + uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; + buffer.erase(buffer.begin(), buffer.begin() + iDiff); + return ret; + } + + return ret; +} + +bool PLY::DOM::SkipLine(std::vector &buffer) { + const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0]; + bool ret = false; + if (pCur) { + const char *szCur = pCur; + ret = Assimp::SkipLine(pCur, &pCur); + + uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; + buffer.erase(buffer.begin(), buffer.begin() + iDiff); + return ret; + } + + return ret; +} + +bool PLY::DOM::TokenMatch(std::vector &buffer, const char *token, unsigned int len) { + const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0]; + bool ret = false; + if (pCur) { + const char *szCur = pCur; + ret = Assimp::TokenMatch(pCur, token, len); + + uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; + buffer.erase(buffer.begin(), buffer.begin() + iDiff); + return ret; + } + + return ret; +} + +bool PLY::DOM::SkipSpacesAndLineEnd(std::vector &buffer) { + const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0]; + bool ret = false; + if (pCur) { + const char *szCur = pCur; + ret = Assimp::SkipSpacesAndLineEnd(pCur, &pCur); + + uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur; + buffer.erase(buffer.begin(), buffer.begin() + iDiff); + return ret; + } + + return ret; +} + +bool PLY::DOM::SkipComments(std::vector &buffer) { + ai_assert(!buffer.empty()); + + std::vector nbuffer = buffer; + // skip spaces + if (!SkipSpaces(nbuffer)) { + return false; + } + + if (TokenMatch(nbuffer, "comment", 7)) { + if (!SkipSpaces(nbuffer)) + SkipLine(nbuffer); + + if (!TokenMatch(nbuffer, "TextureFile", 11)) { + SkipLine(nbuffer); + buffer = nbuffer; + return true; + } + + return true; + } + + return false; } // ------------------------------------------------------------------------------------------------ bool PLY::DOM::ParseHeader(IOStreamBuffer &streamBuffer, std::vector &buffer, bool isBinary) { - ASSIMP_LOG_DEBUG("PLY::DOM::ParseHeader() begin"); + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseHeader() begin"); - // parse all elements - while (!buffer.empty()) - { - // skip all comments - PLY::DOM::SkipComments(buffer); + // parse all elements + while (!buffer.empty()) { + // skip all comments + PLY::DOM::SkipComments(buffer); - PLY::Element out; - if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) - { - // add the element to the list of elements - alElements.push_back(out); + PLY::Element out; + if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) { + // add the element to the list of elements + alElements.push_back(out); + } else if (TokenMatch(buffer, "end_header", 10)) { + // we have reached the end of the header + break; + } else { + // ignore unknown header elements + streamBuffer.getNextLine(buffer); + } } - else if (TokenMatch(buffer, "end_header", 10)) - { - // we have reached the end of the header - break; - } - else - { - // ignore unknown header elements - streamBuffer.getNextLine(buffer); - } - } - if (!isBinary) // it would occur an error, if binary data start with values as space or line end. - SkipSpacesAndLineEnd(buffer); + if (!isBinary) // it would occur an error, if binary data start with values as space or line end. + SkipSpacesAndLineEnd(buffer); - ASSIMP_LOG_DEBUG("PLY::DOM::ParseHeader() succeeded"); - return true; + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseHeader() succeeded"); + return true; } // ------------------------------------------------------------------------------------------------ -bool PLY::DOM::ParseElementInstanceLists(IOStreamBuffer &streamBuffer, std::vector &buffer, PLYImporter* loader) -{ - ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceLists() begin"); - alElementData.resize(alElements.size()); +bool PLY::DOM::ParseElementInstanceLists(IOStreamBuffer &streamBuffer, std::vector &buffer, PLYImporter *loader) { + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceLists() begin"); + alElementData.resize(alElements.size()); - std::vector::const_iterator i = alElements.begin(); - std::vector::iterator a = alElementData.begin(); + std::vector::const_iterator i = alElements.begin(); + std::vector::iterator a = alElementData.begin(); - // parse all element instances - //construct vertices and faces - for (; i != alElements.end(); ++i, ++a) - { - if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip) - { - PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), NULL, loader); + // parse all element instances + //construct vertices and faces + for (; i != alElements.end(); ++i, ++a) { + if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip) { + PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), nullptr, loader); + } else { + (*a).alInstances.resize((*i).NumOccur); + PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), &(*a), nullptr); + } } - else - { - (*a).alInstances.resize((*i).NumOccur); - PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), &(*a), NULL); - } - } - ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceLists() succeeded"); - return true; + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceLists() succeeded"); + return true; } // ------------------------------------------------------------------------------------------------ bool PLY::DOM::ParseElementInstanceListsBinary(IOStreamBuffer &streamBuffer, std::vector &buffer, - const char* &pCur, - unsigned int &bufferSize, - PLYImporter* loader, - bool p_bBE) -{ - ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() begin"); - alElementData.resize(alElements.size()); + const char *&pCur, + unsigned int &bufferSize, + PLYImporter *loader, + bool p_bBE) { + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() begin"); + alElementData.resize(alElements.size()); - std::vector::const_iterator i = alElements.begin(); - std::vector::iterator a = alElementData.begin(); + std::vector::const_iterator i = alElements.begin(); + std::vector::iterator a = alElementData.begin(); - // parse all element instances - for (; i != alElements.end(); ++i, ++a) - { - if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip) - { - PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), NULL, loader, p_bBE); + // parse all element instances + for (; i != alElements.end(); ++i, ++a) { + if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip) { + PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), nullptr, loader, p_bBE); + } else { + (*a).alInstances.resize((*i).NumOccur); + PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), &(*a), nullptr, p_bBE); + } } - else - { - (*a).alInstances.resize((*i).NumOccur); - PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), &(*a), NULL, p_bBE); - } - } - ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() succeeded"); - return true; + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() succeeded"); + return true; } // ------------------------------------------------------------------------------------------------ -bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer &streamBuffer, DOM* p_pcOut, PLYImporter* loader, bool p_bBE) -{ - ai_assert(NULL != p_pcOut); - ai_assert(NULL != loader); +bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer &streamBuffer, DOM *p_pcOut, PLYImporter *loader, bool p_bBE) { + ai_assert(nullptr != p_pcOut); + ai_assert(nullptr != loader); - std::vector buffer; - streamBuffer.getNextLine(buffer); + std::vector buffer; + streamBuffer.getNextLine(buffer); - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() begin"); + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() begin"); - if (!p_pcOut->ParseHeader(streamBuffer, buffer, true)) - { - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() failure"); - return false; - } + if (!p_pcOut->ParseHeader(streamBuffer, buffer, true)) { + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() failure"); + return false; + } - streamBuffer.getNextBlock(buffer); - unsigned int bufferSize = static_cast(buffer.size()); - const char* pCur = (char*)&buffer[0]; - if (!p_pcOut->ParseElementInstanceListsBinary(streamBuffer, buffer, pCur, bufferSize, loader, p_bBE)) - { - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() failure"); - return false; - } - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() succeeded"); - return true; + streamBuffer.getNextBlock(buffer); + unsigned int bufferSize = static_cast(buffer.size()); + const char *pCur = (char *)&buffer[0]; + if (!p_pcOut->ParseElementInstanceListsBinary(streamBuffer, buffer, pCur, bufferSize, loader, p_bBE)) { + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() failure"); + return false; + } + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() succeeded"); + return true; } // ------------------------------------------------------------------------------------------------ -bool PLY::DOM::ParseInstance(IOStreamBuffer &streamBuffer, DOM* p_pcOut, PLYImporter* loader) -{ - ai_assert(NULL != p_pcOut); - ai_assert(NULL != loader); +bool PLY::DOM::ParseInstance(IOStreamBuffer &streamBuffer, DOM *p_pcOut, PLYImporter *loader) { + ai_assert(nullptr != p_pcOut); + ai_assert(nullptr != loader); - std::vector buffer; - streamBuffer.getNextLine(buffer); + std::vector buffer; + streamBuffer.getNextLine(buffer); - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() begin"); + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() begin"); - if (!p_pcOut->ParseHeader(streamBuffer, buffer, false)) - { - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() failure"); - return false; - } + if (!p_pcOut->ParseHeader(streamBuffer, buffer, false)) { + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() failure"); + return false; + } - //get next line after header - streamBuffer.getNextLine(buffer); - if (!p_pcOut->ParseElementInstanceLists(streamBuffer, buffer, loader)) - { - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() failure"); - return false; - } - ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() succeeded"); - return true; + //get next line after header + streamBuffer.getNextLine(buffer); + if (!p_pcOut->ParseElementInstanceLists(streamBuffer, buffer, loader)) { + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() failure"); + return false; + } + ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() succeeded"); + return true; } // ------------------------------------------------------------------------------------------------ bool PLY::ElementInstanceList::ParseInstanceList( - IOStreamBuffer &streamBuffer, - std::vector &buffer, - const PLY::Element* pcElement, - PLY::ElementInstanceList* p_pcOut, - PLYImporter* loader) -{ - ai_assert(NULL != pcElement); + IOStreamBuffer &streamBuffer, + std::vector &buffer, + const PLY::Element *pcElement, + PLY::ElementInstanceList *p_pcOut, + PLYImporter *loader) { + ai_assert(nullptr != pcElement); - // parse all elements - if (EEST_INVALID == pcElement->eSemantic || pcElement->alProperties.empty()) - { - // if the element has an unknown semantic we can skip all lines - // However, there could be comments - for (unsigned int i = 0; i < pcElement->NumOccur; ++i) - { - PLY::DOM::SkipComments(buffer); - PLY::DOM::SkipLine(buffer); - streamBuffer.getNextLine(buffer); + // parse all elements + if (EEST_INVALID == pcElement->eSemantic || pcElement->alProperties.empty()) { + // if the element has an unknown semantic we can skip all lines + // However, there could be comments + for (unsigned int i = 0; i < pcElement->NumOccur; ++i) { + PLY::DOM::SkipComments(buffer); + PLY::DOM::SkipLine(buffer); + streamBuffer.getNextLine(buffer); + } + } else { + const char *pCur = (const char *)&buffer[0]; + // be sure to have enough storage + for (unsigned int i = 0; i < pcElement->NumOccur; ++i) { + if (p_pcOut) + PLY::ElementInstance::ParseInstance(pCur, pcElement, &p_pcOut->alInstances[i]); + else { + ElementInstance elt; + PLY::ElementInstance::ParseInstance(pCur, pcElement, &elt); + + // Create vertex or face + if (pcElement->eSemantic == EEST_Vertex) { + //call loader instance from here + loader->LoadVertex(pcElement, &elt, i); + } else if (pcElement->eSemantic == EEST_Face) { + //call loader instance from here + loader->LoadFace(pcElement, &elt, i); + } else if (pcElement->eSemantic == EEST_TriStrip) { + //call loader instance from here + loader->LoadFace(pcElement, &elt, i); + } + } + + streamBuffer.getNextLine(buffer); + pCur = (buffer.empty()) ? nullptr : (const char *)&buffer[0]; + } } - } - else - { - const char* pCur = (const char*)&buffer[0]; - // be sure to have enough storage - for (unsigned int i = 0; i < pcElement->NumOccur; ++i) - { - if (p_pcOut) - PLY::ElementInstance::ParseInstance(pCur, pcElement, &p_pcOut->alInstances[i]); - else - { - ElementInstance elt; - PLY::ElementInstance::ParseInstance(pCur, pcElement, &elt); - - // Create vertex or face - if (pcElement->eSemantic == EEST_Vertex) - { - //call loader instance from here - loader->LoadVertex(pcElement, &elt, i); - } - else if (pcElement->eSemantic == EEST_Face) - { - //call loader instance from here - loader->LoadFace(pcElement, &elt, i); - } - else if (pcElement->eSemantic == EEST_TriStrip) - { - //call loader instance from here - loader->LoadFace(pcElement, &elt, i); - } - } - - streamBuffer.getNextLine(buffer); - pCur = (buffer.empty()) ? NULL : (const char*)&buffer[0]; - } - } - return true; + return true; } // ------------------------------------------------------------------------------------------------ bool PLY::ElementInstanceList::ParseInstanceListBinary( - IOStreamBuffer &streamBuffer, - std::vector &buffer, - const char* &pCur, - unsigned int &bufferSize, - const PLY::Element* pcElement, - PLY::ElementInstanceList* p_pcOut, - PLYImporter* loader, - bool p_bBE /* = false */) -{ - ai_assert(NULL != pcElement); + IOStreamBuffer &streamBuffer, + std::vector &buffer, + const char *&pCur, + unsigned int &bufferSize, + const PLY::Element *pcElement, + PLY::ElementInstanceList *p_pcOut, + PLYImporter *loader, + bool p_bBE /* = false */) { + ai_assert(nullptr != pcElement); - // we can add special handling code for unknown element semantics since - // we can't skip it as a whole block (we don't know its exact size - // due to the fact that lists could be contained in the property list - // of the unknown element) - for (unsigned int i = 0; i < pcElement->NumOccur; ++i) - { - if (p_pcOut) - PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &p_pcOut->alInstances[i], p_bBE); - else - { - ElementInstance elt; - PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &elt, p_bBE); + // we can add special handling code for unknown element semantics since + // we can't skip it as a whole block (we don't know its exact size + // due to the fact that lists could be contained in the property list + // of the unknown element) + for (unsigned int i = 0; i < pcElement->NumOccur; ++i) { + if (p_pcOut) + PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &p_pcOut->alInstances[i], p_bBE); + else { + ElementInstance elt; + PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &elt, p_bBE); - // Create vertex or face - if (pcElement->eSemantic == EEST_Vertex) - { - //call loader instance from here - loader->LoadVertex(pcElement, &elt, i); - } - else if (pcElement->eSemantic == EEST_Face) - { - //call loader instance from here - loader->LoadFace(pcElement, &elt, i); - } - else if (pcElement->eSemantic == EEST_TriStrip) - { - //call loader instance from here - loader->LoadFace(pcElement, &elt, i); - } + // Create vertex or face + if (pcElement->eSemantic == EEST_Vertex) { + //call loader instance from here + loader->LoadVertex(pcElement, &elt, i); + } else if (pcElement->eSemantic == EEST_Face) { + //call loader instance from here + loader->LoadFace(pcElement, &elt, i); + } else if (pcElement->eSemantic == EEST_TriStrip) { + //call loader instance from here + loader->LoadFace(pcElement, &elt, i); + } + } } - } - return true; + return true; } // ------------------------------------------------------------------------------------------------ -bool PLY::ElementInstance::ParseInstance(const char* &pCur, - const PLY::Element* pcElement, - PLY::ElementInstance* p_pcOut) -{ - ai_assert(NULL != pcElement); - ai_assert(NULL != p_pcOut); +bool PLY::ElementInstance::ParseInstance(const char *&pCur, + const PLY::Element *pcElement, + PLY::ElementInstance *p_pcOut) { + ai_assert(nullptr != pcElement); + ai_assert(nullptr != p_pcOut); - // allocate enough storage - p_pcOut->alProperties.resize(pcElement->alProperties.size()); + // allocate enough storage + p_pcOut->alProperties.resize(pcElement->alProperties.size()); - std::vector::iterator i = p_pcOut->alProperties.begin(); - std::vector::const_iterator a = pcElement->alProperties.begin(); - for (; i != p_pcOut->alProperties.end(); ++i, ++a) - { - if (!(PLY::PropertyInstance::ParseInstance(pCur, &(*a), &(*i)))) - { - ASSIMP_LOG_WARN("Unable to parse property instance. " - "Skipping this element instance"); + std::vector::iterator i = p_pcOut->alProperties.begin(); + std::vector::const_iterator a = pcElement->alProperties.begin(); + for (; i != p_pcOut->alProperties.end(); ++i, ++a) { + if (!(PLY::PropertyInstance::ParseInstance(pCur, &(*a), &(*i)))) { + ASSIMP_LOG_WARN("Unable to parse property instance. " + "Skipping this element instance"); - PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a).eType); - (*i).avList.push_back(v); + PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a).eType); + (*i).avList.push_back(v); + } } - } - return true; + return true; } // ------------------------------------------------------------------------------------------------ bool PLY::ElementInstance::ParseInstanceBinary( - IOStreamBuffer &streamBuffer, - std::vector &buffer, - const char* &pCur, - unsigned int &bufferSize, - const PLY::Element* pcElement, - PLY::ElementInstance* p_pcOut, - bool p_bBE /* = false */) -{ - ai_assert(NULL != pcElement); - ai_assert(NULL != p_pcOut); + IOStreamBuffer &streamBuffer, + std::vector &buffer, + const char *&pCur, + unsigned int &bufferSize, + const PLY::Element *pcElement, + PLY::ElementInstance *p_pcOut, + bool p_bBE /* = false */) { + ai_assert(nullptr != pcElement); + ai_assert(nullptr != p_pcOut); - // allocate enough storage - p_pcOut->alProperties.resize(pcElement->alProperties.size()); + // allocate enough storage + p_pcOut->alProperties.resize(pcElement->alProperties.size()); - std::vector::iterator i = p_pcOut->alProperties.begin(); - std::vector::const_iterator a = pcElement->alProperties.begin(); - for (; i != p_pcOut->alProperties.end(); ++i, ++a) - { - if (!(PLY::PropertyInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, &(*a), &(*i), p_bBE))) - { - ASSIMP_LOG_WARN("Unable to parse binary property instance. " - "Skipping this element instance"); + std::vector::iterator i = p_pcOut->alProperties.begin(); + std::vector::const_iterator a = pcElement->alProperties.begin(); + for (; i != p_pcOut->alProperties.end(); ++i, ++a) { + if (!(PLY::PropertyInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, &(*a), &(*i), p_bBE))) { + ASSIMP_LOG_WARN("Unable to parse binary property instance. " + "Skipping this element instance"); - (*i).avList.push_back(PLY::PropertyInstance::DefaultValue((*a).eType)); + (*i).avList.push_back(PLY::PropertyInstance::DefaultValue((*a).eType)); + } } - } - return true; + return true; } // ------------------------------------------------------------------------------------------------ -bool PLY::PropertyInstance::ParseInstance(const char* &pCur, - const PLY::Property* prop, PLY::PropertyInstance* p_pcOut) -{ - ai_assert(NULL != prop); - ai_assert(NULL != p_pcOut); +bool PLY::PropertyInstance::ParseInstance(const char *&pCur, + const PLY::Property *prop, PLY::PropertyInstance *p_pcOut) { + ai_assert(nullptr != prop); + ai_assert(nullptr != p_pcOut); - // skip spaces at the beginning - if (!SkipSpaces(&pCur)) - { - return false; - } - - if (prop->bIsList) - { - // parse the number of elements in the list - PLY::PropertyInstance::ValueUnion v; - PLY::PropertyInstance::ParseValue(pCur, prop->eFirstType, &v); - - // convert to unsigned int - unsigned int iNum = PLY::PropertyInstance::ConvertTo(v, prop->eFirstType); - - // parse all list elements - p_pcOut->avList.resize(iNum); - for (unsigned int i = 0; i < iNum; ++i) - { - if (!SkipSpaces(&pCur)) + // skip spaces at the beginning + if (!SkipSpaces(&pCur)) { return false; - - PLY::PropertyInstance::ParseValue(pCur, prop->eType, &p_pcOut->avList[i]); } - } - else - { - // parse the property - PLY::PropertyInstance::ValueUnion v; - PLY::PropertyInstance::ParseValue(pCur, prop->eType, &v); - p_pcOut->avList.push_back(v); - } - SkipSpacesAndLineEnd(&pCur); - return true; + if (prop->bIsList) { + // parse the number of elements in the list + PLY::PropertyInstance::ValueUnion v; + PLY::PropertyInstance::ParseValue(pCur, prop->eFirstType, &v); + + // convert to unsigned int + unsigned int iNum = PLY::PropertyInstance::ConvertTo(v, prop->eFirstType); + + // parse all list elements + p_pcOut->avList.resize(iNum); + for (unsigned int i = 0; i < iNum; ++i) { + if (!SkipSpaces(&pCur)) + return false; + + PLY::PropertyInstance::ParseValue(pCur, prop->eType, &p_pcOut->avList[i]); + } + } else { + // parse the property + PLY::PropertyInstance::ValueUnion v; + + PLY::PropertyInstance::ParseValue(pCur, prop->eType, &v); + p_pcOut->avList.push_back(v); + } + SkipSpacesAndLineEnd(&pCur); + return true; } // ------------------------------------------------------------------------------------------------ bool PLY::PropertyInstance::ParseInstanceBinary(IOStreamBuffer &streamBuffer, std::vector &buffer, - const char* &pCur, - unsigned int &bufferSize, - const PLY::Property* prop, - PLY::PropertyInstance* p_pcOut, - bool p_bBE) -{ - ai_assert(NULL != prop); - ai_assert(NULL != p_pcOut); + const char *&pCur, + unsigned int &bufferSize, + const PLY::Property *prop, + PLY::PropertyInstance *p_pcOut, + bool p_bBE) { + ai_assert(nullptr != prop); + ai_assert(nullptr != p_pcOut); - // parse all elements - if (prop->bIsList) - { - // parse the number of elements in the list - PLY::PropertyInstance::ValueUnion v; - PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eFirstType, &v, p_bBE); + // parse all elements + if (prop->bIsList) { + // parse the number of elements in the list + PLY::PropertyInstance::ValueUnion v; + PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eFirstType, &v, p_bBE); - // convert to unsigned int - unsigned int iNum = PLY::PropertyInstance::ConvertTo(v, prop->eFirstType); + // convert to unsigned int + unsigned int iNum = PLY::PropertyInstance::ConvertTo(v, prop->eFirstType); - // parse all list elements - p_pcOut->avList.resize(iNum); - for (unsigned int i = 0; i < iNum; ++i) - { - PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &p_pcOut->avList[i], p_bBE); + // parse all list elements + p_pcOut->avList.resize(iNum); + for (unsigned int i = 0; i < iNum; ++i) { + PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &p_pcOut->avList[i], p_bBE); + } + } else { + // parse the property + PLY::PropertyInstance::ValueUnion v; + PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &v, p_bBE); + p_pcOut->avList.push_back(v); } - } - else - { - // parse the property - PLY::PropertyInstance::ValueUnion v; - PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &v, p_bBE); - p_pcOut->avList.push_back(v); - } - return true; + return true; } // ------------------------------------------------------------------------------------------------ -PLY::PropertyInstance::ValueUnion PLY::PropertyInstance::DefaultValue(PLY::EDataType eType) -{ - PLY::PropertyInstance::ValueUnion out; +PLY::PropertyInstance::ValueUnion PLY::PropertyInstance::DefaultValue(PLY::EDataType eType) { + PLY::PropertyInstance::ValueUnion out; - switch (eType) - { - case EDT_Float: - out.fFloat = 0.f; + switch (eType) { + case EDT_Float: + out.fFloat = 0.f; + return out; + + case EDT_Double: + out.fDouble = 0.; + return out; + + default:; + }; + out.iUInt = 0; return out; - - case EDT_Double: - out.fDouble = 0.; - return out; - - default:; - }; - out.iUInt = 0; - return out; } // ------------------------------------------------------------------------------------------------ -bool PLY::PropertyInstance::ParseValue(const char* &pCur, - PLY::EDataType eType, - PLY::PropertyInstance::ValueUnion* out) -{ - ai_assert(NULL != pCur); - ai_assert(NULL != out); +bool PLY::PropertyInstance::ParseValue(const char *&pCur, + PLY::EDataType eType, + PLY::PropertyInstance::ValueUnion *out) { + ai_assert(nullptr != pCur); + ai_assert(nullptr != out); - //calc element size - bool ret = true; - switch (eType) - { - case EDT_UInt: - case EDT_UShort: - case EDT_UChar: + //calc element size + bool ret = true; + switch (eType) { + case EDT_UInt: + case EDT_UShort: + case EDT_UChar: - out->iUInt = (uint32_t)strtoul10(pCur, &pCur); - break; + out->iUInt = (uint32_t)strtoul10(pCur, &pCur); + break; - case EDT_Int: - case EDT_Short: - case EDT_Char: + case EDT_Int: + case EDT_Short: + case EDT_Char: - out->iInt = (int32_t)strtol10(pCur, &pCur); - break; + out->iInt = (int32_t)strtol10(pCur, &pCur); + break; - case EDT_Float: - // technically this should cast to float, but people tend to use float descriptors for double data - // this is the best way to not risk losing precision on import and it doesn't hurt to do this - ai_real f; - pCur = fast_atoreal_move(pCur, f); - out->fFloat = (ai_real)f; - break; + case EDT_Float: + // technically this should cast to float, but people tend to use float descriptors for double data + // this is the best way to not risk losing precision on import and it doesn't hurt to do this + ai_real f; + pCur = fast_atoreal_move(pCur, f); + out->fFloat = (ai_real)f; + break; - case EDT_Double: - double d; - pCur = fast_atoreal_move(pCur, d); - out->fDouble = (double)d; - break; + case EDT_Double: + double d; + pCur = fast_atoreal_move(pCur, d); + out->fDouble = (double)d; + break; - case EDT_INVALID: - default: - ret = false; - break; - } + case EDT_INVALID: + default: + ret = false; + break; + } - return ret; + return ret; } // ------------------------------------------------------------------------------------------------ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer &streamBuffer, - std::vector &buffer, - const char* &pCur, - unsigned int &bufferSize, - PLY::EDataType eType, - PLY::PropertyInstance::ValueUnion* out, - bool p_bBE) -{ - ai_assert(NULL != out); + std::vector &buffer, + const char *&pCur, + unsigned int &bufferSize, + PLY::EDataType eType, + PLY::PropertyInstance::ValueUnion *out, + bool p_bBE) { + ai_assert(nullptr != out); - //calc element size - unsigned int lsize = 0; - switch (eType) - { - case EDT_Char: - case EDT_UChar: - lsize = 1; - break; + //calc element size + unsigned int lsize = 0; + switch (eType) { + case EDT_Char: + case EDT_UChar: + lsize = 1; + break; - case EDT_UShort: - case EDT_Short: - lsize = 2; - break; + case EDT_UShort: + case EDT_Short: + lsize = 2; + break; - case EDT_UInt: - case EDT_Int: - case EDT_Float: - lsize = 4; - break; + case EDT_UInt: + case EDT_Int: + case EDT_Float: + lsize = 4; + break; - case EDT_Double: - lsize = 8; - break; + case EDT_Double: + lsize = 8; + break; - case EDT_INVALID: - default: - break; - } - - //read the next file block if needed - if (bufferSize < lsize) - { - std::vector nbuffer; - if (streamBuffer.getNextBlock(nbuffer)) - { - //concat buffer contents - buffer = std::vector(buffer.end() - bufferSize, buffer.end()); - buffer.insert(buffer.end(), nbuffer.begin(), nbuffer.end()); - nbuffer.clear(); - bufferSize = static_cast(buffer.size()); - pCur = (char*)&buffer[0]; + case EDT_INVALID: + default: + break; } - else - { - throw DeadlyImportError("Invalid .ply file: File corrupted"); + + //read the next file block if needed + if (bufferSize < lsize) { + std::vector nbuffer; + if (streamBuffer.getNextBlock(nbuffer)) { + //concat buffer contents + buffer = std::vector(buffer.end() - bufferSize, buffer.end()); + buffer.insert(buffer.end(), nbuffer.begin(), nbuffer.end()); + nbuffer.clear(); + bufferSize = static_cast(buffer.size()); + pCur = (char *)&buffer[0]; + } else { + throw DeadlyImportError("Invalid .ply file: File corrupted"); + } } - } - bool ret = true; - switch (eType) - { - case EDT_UInt: - { - uint32_t t; - memcpy(&t, pCur, sizeof(uint32_t)); - pCur += sizeof(uint32_t); + bool ret = true; + switch (eType) { + case EDT_UInt: { + uint32_t t; + memcpy(&t, pCur, sizeof(uint32_t)); + pCur += sizeof(uint32_t); - // Swap endianness - if (p_bBE)ByteSwap::Swap(&t); - out->iUInt = t; - break; - } + // Swap endianness + if (p_bBE) ByteSwap::Swap(&t); + out->iUInt = t; + break; + } - case EDT_UShort: - { - uint16_t t; - memcpy(&t, pCur, sizeof(uint16_t)); - pCur += sizeof(uint16_t); + case EDT_UShort: { + uint16_t t; + memcpy(&t, pCur, sizeof(uint16_t)); + pCur += sizeof(uint16_t); - // Swap endianness - if (p_bBE)ByteSwap::Swap(&t); - out->iUInt = t; - break; - } + // Swap endianness + if (p_bBE) ByteSwap::Swap(&t); + out->iUInt = t; + break; + } - case EDT_UChar: - { - uint8_t t; - memcpy(&t, pCur, sizeof(uint8_t)); - pCur += sizeof(uint8_t); - out->iUInt = t; - break; - } + case EDT_UChar: { + uint8_t t; + memcpy(&t, pCur, sizeof(uint8_t)); + pCur += sizeof(uint8_t); + out->iUInt = t; + break; + } - case EDT_Int: - { - int32_t t; - memcpy(&t, pCur, sizeof(int32_t)); - pCur += sizeof(int32_t); + case EDT_Int: { + int32_t t; + memcpy(&t, pCur, sizeof(int32_t)); + pCur += sizeof(int32_t); - // Swap endianness - if (p_bBE)ByteSwap::Swap(&t); - out->iInt = t; - break; - } + // Swap endianness + if (p_bBE) ByteSwap::Swap(&t); + out->iInt = t; + break; + } - case EDT_Short: - { - int16_t t; - memcpy(&t, pCur, sizeof(int16_t)); - pCur += sizeof(int16_t); + case EDT_Short: { + int16_t t; + memcpy(&t, pCur, sizeof(int16_t)); + pCur += sizeof(int16_t); - // Swap endianness - if (p_bBE)ByteSwap::Swap(&t); - out->iInt = t; - break; - } + // Swap endianness + if (p_bBE) ByteSwap::Swap(&t); + out->iInt = t; + break; + } - case EDT_Char: - { - int8_t t; - memcpy(&t, pCur, sizeof(int8_t)); - pCur += sizeof(int8_t); - out->iInt = t; - break; - } + case EDT_Char: { + int8_t t; + memcpy(&t, pCur, sizeof(int8_t)); + pCur += sizeof(int8_t); + out->iInt = t; + break; + } - case EDT_Float: - { - float t; - memcpy(&t, pCur, sizeof(float)); - pCur += sizeof(float); + case EDT_Float: { + float t; + memcpy(&t, pCur, sizeof(float)); + pCur += sizeof(float); - // Swap endianness - if (p_bBE)ByteSwap::Swap(&t); - out->fFloat = t; - break; - } - case EDT_Double: - { - double t; - memcpy(&t, pCur, sizeof(double)); - pCur += sizeof(double); + // Swap endianness + if (p_bBE) ByteSwap::Swap(&t); + out->fFloat = t; + break; + } + case EDT_Double: { + double t; + memcpy(&t, pCur, sizeof(double)); + pCur += sizeof(double); - // Swap endianness - if (p_bBE)ByteSwap::Swap(&t); - out->fDouble = t; - break; - } - default: - ret = false; - } + // Swap endianness + if (p_bBE) ByteSwap::Swap(&t); + out->fDouble = t; + break; + } + default: + ret = false; + } - bufferSize -= lsize; + bufferSize -= lsize; - return ret; + return ret; } #endif // !! ASSIMP_BUILD_NO_PLY_IMPORTER diff --git a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp index 131e61534..52a2b7503 100644 --- a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp +++ b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp @@ -43,27 +43,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER #include "Q3BSPFileImporter.h" -#include "Q3BSPFileParser.h" #include "Q3BSPFileData.h" +#include "Q3BSPFileParser.h" #include #ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include +#include #else -# include "../contrib/zlib/zlib.h" +#include "../contrib/zlib/zlib.h" #endif -#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include #include -#include +#include static const aiImporterDesc desc = { "Quake III BSP Importer", @@ -84,7 +84,7 @@ using namespace Q3BSP; // ------------------------------------------------------------------------------------------------ // Local function to create a material key name. -static void createKey( int id1, int id2, std::string &key ) { +static void createKey(int id1, int id2, std::string &key) { std::ostringstream str; str << id1 << "." << id2; key = str.str(); @@ -92,27 +92,27 @@ static void createKey( int id1, int id2, std::string &key ) { // ------------------------------------------------------------------------------------------------ // Local function to extract the texture ids from a material key-name. -static void extractIds( const std::string &key, int &id1, int &id2 ) { +static void extractIds(const std::string &key, int &id1, int &id2) { id1 = -1; id2 = -1; if (key.empty()) { return; } - const std::string::size_type pos = key.find( "." ); + const std::string::size_type pos = key.find("."); if (std::string::npos == pos) { return; } - std::string tmp1 = key.substr( 0, pos ); - std::string tmp2 = key.substr( pos + 1, key.size() - pos - 1 ); - id1 = atoi( tmp1.c_str() ); - id2 = atoi( tmp2.c_str() ); + std::string tmp1 = key.substr(0, pos); + std::string tmp2 = key.substr(pos + 1, key.size() - pos - 1); + id1 = atoi(tmp1.c_str()); + id2 = atoi(tmp2.c_str()); } // ------------------------------------------------------------------------------------------------ // Local helper function to normalize filenames. -static void normalizePathName( const std::string &rPath, std::string &normalizedPath ) { +static void normalizePathName(const std::string &rPath, std::string &normalizedPath) { normalizedPath = ""; if (rPath.empty()) { return; @@ -125,12 +125,12 @@ static void normalizePathName( const std::string &rPath, std::string &normalized #endif static const unsigned int numDelimiters = 2; - const char delimiters[ numDelimiters ] = { '/', '\\' }; + const char delimiters[numDelimiters] = { '/', '\\' }; normalizedPath = rPath; for (const char delimiter : delimiters) { - for ( size_t j=0; jfirst; - if ( !matName.empty() ) { + if (!matName.empty()) { delete it->second; } } @@ -164,9 +161,9 @@ Q3BSPFileImporter::~Q3BSPFileImporter() { // ------------------------------------------------------------------------------------------------ // Returns true, if the loader can read this. -bool Q3BSPFileImporter::CanRead( const std::string& rFile, IOSystem* /*pIOHandler*/, bool checkSig ) const { - if(!checkSig) { - return SimpleExtensionCheck( rFile, "pk3", "bsp" ); +bool Q3BSPFileImporter::CanRead(const std::string &rFile, IOSystem * /*pIOHandler*/, bool checkSig) const { + if (!checkSig) { + return SimpleExtensionCheck(rFile, "pk3", "bsp"); } return false; @@ -174,69 +171,69 @@ bool Q3BSPFileImporter::CanRead( const std::string& rFile, IOSystem* /*pIOHandle // ------------------------------------------------------------------------------------------------ // Adds extensions. -const aiImporterDesc* Q3BSPFileImporter::GetInfo () const { +const aiImporterDesc *Q3BSPFileImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // Import method. -void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* scene, IOSystem* ioHandler) { - ZipArchiveIOSystem Archive( ioHandler, rFile ); - if ( !Archive.isOpen() ) { - throw DeadlyImportError( "Failed to open file " + rFile + "." ); +void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene *scene, IOSystem *ioHandler) { + ZipArchiveIOSystem Archive(ioHandler, rFile); + if (!Archive.isOpen()) { + throw DeadlyImportError("Failed to open file " + rFile + "."); } - std::string archiveName( "" ), mapName( "" ); - separateMapName( rFile, archiveName, mapName ); + std::string archiveName(""), mapName(""); + separateMapName(rFile, archiveName, mapName); - if ( mapName.empty() ) { - if ( !findFirstMapInArchive( Archive, mapName ) ) { + if (mapName.empty()) { + if (!findFirstMapInArchive(Archive, mapName)) { return; } } - Q3BSPFileParser fileParser( mapName, &Archive ); + Q3BSPFileParser fileParser(mapName, &Archive); Q3BSPModel *pBSPModel = fileParser.getModel(); - if ( nullptr != pBSPModel ) { - CreateDataFromImport( pBSPModel, scene, &Archive ); + if (nullptr != pBSPModel) { + CreateDataFromImport(pBSPModel, scene, &Archive); } } // ------------------------------------------------------------------------------------------------ // Separates the map name from the import name. -void Q3BSPFileImporter::separateMapName( const std::string &importName, std::string &archiveName, std::string &mapName ) { +void Q3BSPFileImporter::separateMapName(const std::string &importName, std::string &archiveName, std::string &mapName) { archiveName = ""; mapName = ""; if (importName.empty()) { return; } - const std::string::size_type pos = importName.rfind( "," ); - if ( std::string::npos == pos ) { + const std::string::size_type pos = importName.rfind(","); + if (std::string::npos == pos) { archiveName = importName; return; } - archiveName = importName.substr( 0, pos ); - mapName = importName.substr( pos, importName.size() - pos - 1 ); + archiveName = importName.substr(0, pos); + mapName = importName.substr(pos, importName.size() - pos - 1); } // ------------------------------------------------------------------------------------------------ // Returns the first map in the map archive. -bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, std::string &mapName ) { +bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, std::string &mapName) { mapName = ""; std::vector fileList; - bspArchive.getFileListExtension( fileList, "bsp" ); + bspArchive.getFileListExtension(fileList, "bsp"); if (fileList.empty()) { return false; } - std::vector::iterator it( fileList.begin() ); - for ( ; it != fileList.end(); ++it ) { - const std::string::size_type pos = (*it).find( "maps/" ); - if ( std::string::npos != pos ) { - std::string::size_type extPos = (*it).find( ".bsp" ); - if ( std::string::npos != extPos ) { + std::vector::iterator it(fileList.begin()); + for (; it != fileList.end(); ++it) { + const std::string::size_type pos = (*it).find("maps/"); + if (std::string::npos != pos) { + std::string::size_type extPos = (*it).find(".bsp"); + if (std::string::npos != extPos) { mapName = *it; return true; } @@ -248,122 +245,122 @@ bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, st // ------------------------------------------------------------------------------------------------ // Creates the assimp specific data. -void Q3BSPFileImporter::CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, - ZipArchiveIOSystem *pArchive ) { +void Q3BSPFileImporter::CreateDataFromImport(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene, + ZipArchiveIOSystem *pArchive) { if (nullptr == pModel || nullptr == pScene) { return; } pScene->mRootNode = new aiNode; - if ( !pModel->m_ModelName.empty() ) { - pScene->mRootNode->mName.Set( pModel->m_ModelName ); + if (!pModel->m_ModelName.empty()) { + pScene->mRootNode->mName.Set(pModel->m_ModelName); } // Create the face to material relation map - createMaterialMap( pModel ); + createMaterialMap(pModel); // Create all nodes - CreateNodes( pModel, pScene, pScene->mRootNode ); + CreateNodes(pModel, pScene, pScene->mRootNode); // Create the assigned materials - createMaterials( pModel, pScene, pArchive ); + createMaterials(pModel, pScene, pArchive); } // ------------------------------------------------------------------------------------------------ // Creates all assimp nodes. -void Q3BSPFileImporter::CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, - aiNode *pParent ) { - if ( nullptr == pModel ) { +void Q3BSPFileImporter::CreateNodes(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene, + aiNode *pParent) { + if (nullptr == pModel) { return; } - unsigned int matIdx( 0 ); - std::vector MeshArray; - std::vector NodeArray; - for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it ) { - std::vector *pArray = (*it).second; - size_t numVerts = countData( *pArray ); - if ( 0 != numVerts ) { - aiMesh *pMesh( nullptr ); - aiNode *pNode = CreateTopology( pModel, matIdx, *pArray, &pMesh ); - if ( nullptr != pNode ) { - NodeArray.push_back( pNode ); - MeshArray.push_back( pMesh ); + unsigned int matIdx(0); + std::vector MeshArray; + std::vector NodeArray; + for (FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it) { + std::vector *pArray = (*it).second; + size_t numVerts = countData(*pArray); + if (0 != numVerts) { + aiMesh *pMesh(nullptr); + aiNode *pNode = CreateTopology(pModel, matIdx, *pArray, &pMesh); + if (nullptr != pNode) { + NodeArray.push_back(pNode); + MeshArray.push_back(pMesh); } } matIdx++; } - pScene->mNumMeshes = static_cast( MeshArray.size() ); - if ( pScene->mNumMeshes > 0 ) { - pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ]; - for ( size_t i = 0; i < MeshArray.size(); i++ ) { - aiMesh *pMesh = MeshArray[ i ]; - if ( nullptr != pMesh ) { - pScene->mMeshes[ i ] = pMesh; + pScene->mNumMeshes = static_cast(MeshArray.size()); + if (pScene->mNumMeshes > 0) { + pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]; + for (size_t i = 0; i < MeshArray.size(); i++) { + aiMesh *pMesh = MeshArray[i]; + if (nullptr != pMesh) { + pScene->mMeshes[i] = pMesh; } } } pParent->mNumChildren = static_cast(MeshArray.size()); - pParent->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren ]; - for ( size_t i=0; imChildren = new aiNode *[pScene->mRootNode->mNumChildren]; + for (size_t i = 0; i < NodeArray.size(); i++) { + aiNode *pNode = NodeArray[i]; pNode->mParent = pParent; - pParent->mChildren[ i ] = pNode; - pParent->mChildren[ i ]->mMeshes[ 0 ] = static_cast(i); + pParent->mChildren[i] = pNode; + pParent->mChildren[i]->mMeshes[0] = static_cast(i); } } // ------------------------------------------------------------------------------------------------ // Creates the topology. -aiNode *Q3BSPFileImporter::CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx, - std::vector &rArray, aiMesh **pMesh ) { - size_t numVerts = countData( rArray ); - if ( 0 == numVerts ) { +aiNode *Q3BSPFileImporter::CreateTopology(const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx, + std::vector &rArray, aiMesh **pMesh) { + size_t numVerts = countData(rArray); + if (0 == numVerts) { return nullptr; } - size_t numFaces = countFaces( rArray ); - if ( 0 == numFaces ) { + size_t numFaces = countFaces(rArray); + if (0 == numFaces) { return nullptr; } aiMesh *mesh = new aiMesh; - size_t numTriangles = countTriangles( rArray ); + size_t numTriangles = countTriangles(rArray); mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - mesh->mFaces = new aiFace[ numTriangles ]; + mesh->mFaces = new aiFace[numTriangles]; mesh->mNumFaces = static_cast(numTriangles); mesh->mNumVertices = static_cast(numVerts); - mesh->mVertices = new aiVector3D[ numVerts ]; - mesh->mNormals = new aiVector3D[ numVerts ]; - mesh->mTextureCoords[ 0 ] = new aiVector3D[ numVerts ]; - mesh->mTextureCoords[ 1 ] = new aiVector3D[ numVerts ]; + mesh->mVertices = new aiVector3D[numVerts]; + mesh->mNormals = new aiVector3D[numVerts]; + mesh->mTextureCoords[0] = new aiVector3D[numVerts]; + mesh->mTextureCoords[1] = new aiVector3D[numVerts]; mesh->mMaterialIndex = materialIdx; unsigned int faceIdx = 0; unsigned int vertIdx = 0; - mesh->mNumUVComponents[ 0 ] = 2; - mesh->mNumUVComponents[ 1 ] = 2; - for ( std::vector::const_iterator it = rArray.begin(); it != rArray.end(); ++it ) { + mesh->mNumUVComponents[0] = 2; + mesh->mNumUVComponents[1] = 2; + for (std::vector::const_iterator it = rArray.begin(); it != rArray.end(); ++it) { Q3BSP::sQ3BSPFace *pQ3BSPFace = *it; - ai_assert( NULL != pQ3BSPFace ); - if ( nullptr == pQ3BSPFace ) { + ai_assert(nullptr != pQ3BSPFace); + if (nullptr == pQ3BSPFace) { continue; } - if ( pQ3BSPFace->iNumOfFaceVerts > 0 ) { - if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh ) { - createTriangleTopology( pModel, pQ3BSPFace, mesh, faceIdx, vertIdx ); + if (pQ3BSPFace->iNumOfFaceVerts > 0) { + if (pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh) { + createTriangleTopology(pModel, pQ3BSPFace, mesh, faceIdx, vertIdx); } } } aiNode *pNode = new aiNode; pNode->mNumMeshes = 1; - pNode->mMeshes = new unsigned int[ 1 ]; + pNode->mMeshes = new unsigned int[1]; *pMesh = mesh; return pNode; @@ -371,27 +368,27 @@ aiNode *Q3BSPFileImporter::CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsi // ------------------------------------------------------------------------------------------------ // Creates the triangle topology from a face array. -void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, sQ3BSPFace *pQ3BSPFace, - aiMesh* pMesh, unsigned int &faceIdx, unsigned int &vertIdx ) { - ai_assert( faceIdx < pMesh->mNumFaces ); +void Q3BSPFileImporter::createTriangleTopology(const Q3BSP::Q3BSPModel *pModel, sQ3BSPFace *pQ3BSPFace, + aiMesh *pMesh, unsigned int &faceIdx, unsigned int &vertIdx) { + ai_assert(faceIdx < pMesh->mNumFaces); - m_pCurrentFace = getNextFace( pMesh, faceIdx ); - if ( nullptr == m_pCurrentFace ) { + m_pCurrentFace = getNextFace(pMesh, faceIdx); + if (nullptr == m_pCurrentFace) { return; } m_pCurrentFace->mNumIndices = 3; - m_pCurrentFace->mIndices = new unsigned int[ m_pCurrentFace->mNumIndices ]; + m_pCurrentFace->mIndices = new unsigned int[m_pCurrentFace->mNumIndices]; - size_t idx( 0 ); - for ( size_t i = 0; i < (size_t) pQ3BSPFace->iNumOfFaceVerts; ++i ) { - const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[ pQ3BSPFace->iFaceVertexIndex + i ]; - if ( index >= pModel->m_Vertices.size() ) { + size_t idx(0); + for (size_t i = 0; i < (size_t)pQ3BSPFace->iNumOfFaceVerts; ++i) { + const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[pQ3BSPFace->iFaceVertexIndex + i]; + if (index >= pModel->m_Vertices.size()) { continue; } - sQ3BSPVertex *pVertex = pModel->m_Vertices[ index ]; - if ( nullptr == pVertex ) { + sQ3BSPVertex *pVertex = pModel->m_Vertices[index]; + if (nullptr == pVertex) { continue; } if (idx > 2) { @@ -400,15 +397,15 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, if (nullptr != m_pCurrentFace) { m_pCurrentFace->mNumIndices = 3; m_pCurrentFace->mIndices = new unsigned int[3]; - m_pCurrentFace->mIndices[ idx ] = vertIdx; + m_pCurrentFace->mIndices[idx] = vertIdx; } } - pMesh->mVertices[ vertIdx ].Set( pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z ); - pMesh->mNormals[ vertIdx ].Set( pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z ); + pMesh->mVertices[vertIdx].Set(pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z); + pMesh->mNormals[vertIdx].Set(pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z); - pMesh->mTextureCoords[ 0 ][ vertIdx ].Set( pVertex->vTexCoord.x, pVertex->vTexCoord.y, 0.0f ); - pMesh->mTextureCoords[ 1 ][ vertIdx ].Set( pVertex->vLightmap.x, pVertex->vLightmap.y, 0.0f ); + pMesh->mTextureCoords[0][vertIdx].Set(pVertex->vTexCoord.x, pVertex->vTexCoord.y, 0.0f); + pMesh->mTextureCoords[1][vertIdx].Set(pVertex->vLightmap.x, pVertex->vLightmap.y, 0.0f); vertIdx++; idx++; @@ -417,65 +414,61 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, // ------------------------------------------------------------------------------------------------ // Creates all referenced materials. -void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, - ZipArchiveIOSystem *pArchive ) { - if ( m_MaterialLookupMap.empty() ) { +void Q3BSPFileImporter::createMaterials(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene, + ZipArchiveIOSystem *pArchive) { + if (m_MaterialLookupMap.empty()) { return; } - pScene->mMaterials = new aiMaterial*[ m_MaterialLookupMap.size() ]; + pScene->mMaterials = new aiMaterial *[m_MaterialLookupMap.size()]; aiString aiMatName; - int textureId( -1 ), lightmapId( -1 ); - for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); - ++it ) { - const std::string matName( it->first ); - if ( matName.empty() ) { + int textureId(-1), lightmapId(-1); + for (FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); + ++it) { + const std::string matName(it->first); + if (matName.empty()) { continue; } - aiMatName.Set( matName ); + aiMatName.Set(matName); aiMaterial *pMatHelper = new aiMaterial; - pMatHelper->AddProperty( &aiMatName, AI_MATKEY_NAME ); + pMatHelper->AddProperty(&aiMatName, AI_MATKEY_NAME); - extractIds( matName, textureId, lightmapId ); + extractIds(matName, textureId, lightmapId); // Adding the texture - if ( -1 != textureId ) { - sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ]; - if ( nullptr != pTexture ) { - std::string tmp( "*" ), texName( "" ); + if (-1 != textureId) { + sQ3BSPTexture *pTexture = pModel->m_Textures[textureId]; + if (nullptr != pTexture) { + std::string tmp("*"), texName(""); tmp += pTexture->strName; tmp += ".jpg"; - normalizePathName( tmp, texName ); + normalizePathName(tmp, texName); - if ( !importTextureFromArchive( pModel, pArchive, pScene, pMatHelper, textureId ) ) { + if (!importTextureFromArchive(pModel, pArchive, pScene, pMatHelper, textureId)) { ASSIMP_LOG_ERROR("Cannot import texture from archive " + texName); } } - } - if ( -1 != lightmapId ) - { - importLightmap( pModel, pScene, pMatHelper, lightmapId ); + if (-1 != lightmapId) { + importLightmap(pModel, pScene, pMatHelper, lightmapId); } - pScene->mMaterials[ pScene->mNumMaterials ] = pMatHelper; + pScene->mMaterials[pScene->mNumMaterials] = pMatHelper; pScene->mNumMaterials++; } pScene->mNumTextures = static_cast(mTextures.size()); - pScene->mTextures = new aiTexture*[ pScene->mNumTextures ]; - std::copy( mTextures.begin(), mTextures.end(), pScene->mTextures ); + pScene->mTextures = new aiTexture *[pScene->mNumTextures]; + std::copy(mTextures.begin(), mTextures.end(), pScene->mTextures); } // ------------------------------------------------------------------------------------------------ // Counts the number of referenced vertices. -size_t Q3BSPFileImporter::countData( const std::vector &faceArray ) const { - size_t numVerts( 0 ); - for ( std::vector::const_iterator it = faceArray.begin(); it != faceArray.end(); - ++it ) - { +size_t Q3BSPFileImporter::countData(const std::vector &faceArray) const { + size_t numVerts(0); + for (std::vector::const_iterator it = faceArray.begin(); it != faceArray.end(); + ++it) { sQ3BSPFace *pQ3BSPFace = *it; - if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh ) - { + if (pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh) { Q3BSP::sQ3BSPFace *face = *it; if (nullptr != face) { numVerts += face->iNumOfFaceVerts; @@ -488,15 +481,12 @@ size_t Q3BSPFileImporter::countData( const std::vector &faceArray ) // ------------------------------------------------------------------------------------------------ // Counts the faces with vertices. -size_t Q3BSPFileImporter::countFaces( const std::vector &rArray ) const -{ +size_t Q3BSPFileImporter::countFaces(const std::vector &rArray) const { size_t numFaces = 0; - for ( std::vector::const_iterator it = rArray.begin(); it != rArray.end(); - ++it ) - { + for (std::vector::const_iterator it = rArray.begin(); it != rArray.end(); + ++it) { Q3BSP::sQ3BSPFace *pQ3BSPFace = *it; - if ( pQ3BSPFace->iNumOfFaceVerts > 0 ) - { + if (pQ3BSPFace->iNumOfFaceVerts > 0) { numFaces++; } } @@ -506,15 +496,12 @@ size_t Q3BSPFileImporter::countFaces( const std::vector &rAr // ------------------------------------------------------------------------------------------------ // Counts the number of triangles in a Q3-face-array. -size_t Q3BSPFileImporter::countTriangles( const std::vector &rArray ) const -{ +size_t Q3BSPFileImporter::countTriangles(const std::vector &rArray) const { size_t numTriangles = 0; - for ( std::vector::const_iterator it = rArray.begin(); it != rArray.end(); - ++it ) - { + for (std::vector::const_iterator it = rArray.begin(); it != rArray.end(); + ++it) { const Q3BSP::sQ3BSPFace *pQ3BSPFace = *it; - if ( NULL != pQ3BSPFace ) - { + if (nullptr != pQ3BSPFace) { numTriangles += pQ3BSPFace->iNumOfFaceVerts / 3; } } @@ -524,38 +511,34 @@ size_t Q3BSPFileImporter::countTriangles( const std::vector // ------------------------------------------------------------------------------------------------ // Creates the faces-to-material map. -void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel ) { - std::string key( "" ); - std::vector *pCurFaceArray = NULL; - for ( size_t idx = 0; idx < pModel->m_Faces.size(); idx++ ) - { - Q3BSP::sQ3BSPFace *pQ3BSPFace = pModel->m_Faces[ idx ]; +void Q3BSPFileImporter::createMaterialMap(const Q3BSP::Q3BSPModel *pModel) { + std::string key(""); + std::vector *pCurFaceArray = nullptr; + for (size_t idx = 0; idx < pModel->m_Faces.size(); idx++) { + Q3BSP::sQ3BSPFace *pQ3BSPFace = pModel->m_Faces[idx]; const int texId = pQ3BSPFace->iTextureID; const int lightMapId = pQ3BSPFace->iLightmapID; - createKey( texId, lightMapId, key ); - FaceMapIt it = m_MaterialLookupMap.find( key ); - if ( m_MaterialLookupMap.end() == it ) { - pCurFaceArray = new std::vector; - m_MaterialLookupMap[ key ] = pCurFaceArray; - } - else - { + createKey(texId, lightMapId, key); + FaceMapIt it = m_MaterialLookupMap.find(key); + if (m_MaterialLookupMap.end() == it) { + pCurFaceArray = new std::vector; + m_MaterialLookupMap[key] = pCurFaceArray; + } else { pCurFaceArray = (*it).second; } - ai_assert( nullptr != pCurFaceArray ); - if (nullptr != pCurFaceArray ) - { - pCurFaceArray->push_back( pQ3BSPFace ); + ai_assert(nullptr != pCurFaceArray); + if (nullptr != pCurFaceArray) { + pCurFaceArray->push_back(pQ3BSPFace); } } } // ------------------------------------------------------------------------------------------------ // Returns the next face. -aiFace *Q3BSPFileImporter::getNextFace( aiMesh *mesh, unsigned int &faceIdx ) { - aiFace *face( nullptr ); - if ( faceIdx < mesh->mNumFaces ) { - face = &mesh->mFaces[ faceIdx ]; +aiFace *Q3BSPFileImporter::getNextFace(aiMesh *mesh, unsigned int &faceIdx) { + aiFace *face(nullptr); + if (faceIdx < mesh->mNumFaces) { + face = &mesh->mFaces[faceIdx]; ++faceIdx; } @@ -564,31 +547,31 @@ aiFace *Q3BSPFileImporter::getNextFace( aiMesh *mesh, unsigned int &faceIdx ) { // ------------------------------------------------------------------------------------------------ // Imports a texture file. -bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model, - ZipArchiveIOSystem *archive, aiScene*, - aiMaterial *pMatHelper, int textureId ) { - if (nullptr == archive || nullptr == pMatHelper ) { +bool Q3BSPFileImporter::importTextureFromArchive(const Q3BSP::Q3BSPModel *model, + ZipArchiveIOSystem *archive, aiScene *, + aiMaterial *pMatHelper, int textureId) { + if (nullptr == archive || nullptr == pMatHelper) { return false; } - if ( textureId < 0 || textureId >= static_cast( model->m_Textures.size() ) ) { + if (textureId < 0 || textureId >= static_cast(model->m_Textures.size())) { return false; } bool res = true; - sQ3BSPTexture *pTexture = model->m_Textures[ textureId ]; - if ( !pTexture ) { + sQ3BSPTexture *pTexture = model->m_Textures[textureId]; + if (!pTexture) { return false; } std::vector supportedExtensions; - supportedExtensions.push_back( ".jpg" ); - supportedExtensions.push_back( ".png" ); - supportedExtensions.push_back( ".tga" ); + supportedExtensions.push_back(".jpg"); + supportedExtensions.push_back(".png"); + supportedExtensions.push_back(".tga"); std::string textureName, ext; - if ( expandFile( archive, pTexture->strName, supportedExtensions, textureName, ext ) ) { - IOStream *pTextureStream = archive->Open( textureName.c_str() ); - if ( pTextureStream ) { + if (expandFile(archive, pTexture->strName, supportedExtensions, textureName, ext)) { + IOStream *pTextureStream = archive->Open(textureName.c_str()); + if (pTextureStream) { size_t texSize = pTextureStream->FileSize(); aiTexture *curTexture = new aiTexture; curTexture->mHeight = 0; @@ -605,20 +588,20 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model res = true; aiString name; - name.data[ 0 ] = '*'; - name.length = 1 + ASSIMP_itoa10( name.data + 1, static_cast(MAXLEN-1), static_cast(mTextures.size()) ); + name.data[0] = '*'; + name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast(MAXLEN - 1), static_cast(mTextures.size())); - archive->Close( pTextureStream ); + archive->Close(pTextureStream); - pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) ); + pMatHelper->AddProperty(&name, AI_MATKEY_TEXTURE_DIFFUSE(0)); mTextures.push_back(curTexture); } else { // If it doesn't exist in the archive, it is probably just a reference to an external file. // We'll leave it up to the user to figure out which extension the file has. aiString name; - strncpy( name.data, pTexture->strName, sizeof name.data ); - name.length = static_cast(strlen( name.data )); - pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) ); + strncpy(name.data, pTexture->strName, sizeof name.data); + name.length = static_cast(strlen(name.data)); + pMatHelper->AddProperty(&name, AI_MATKEY_TEXTURE_DIFFUSE(0)); } } @@ -627,19 +610,18 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model // ------------------------------------------------------------------------------------------------ // Imports a light map file. -bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, - aiMaterial *pMatHelper, int lightmapId ) -{ - if (nullptr == pModel || nullptr == pScene || nullptr == pMatHelper ) { +bool Q3BSPFileImporter::importLightmap(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene, + aiMaterial *pMatHelper, int lightmapId) { + if (nullptr == pModel || nullptr == pScene || nullptr == pMatHelper) { return false; } - if ( lightmapId < 0 || lightmapId >= static_cast( pModel->m_Lightmaps.size() ) ) { + if (lightmapId < 0 || lightmapId >= static_cast(pModel->m_Lightmaps.size())) { return false; } - sQ3BSPLightmap *pLightMap = pModel->m_Lightmaps[ lightmapId ]; - if (nullptr == pLightMap ) { + sQ3BSPLightmap *pLightMap = pModel->m_Lightmaps[lightmapId]; + if (nullptr == pLightMap) { return false; } @@ -649,21 +631,21 @@ bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene pTexture->mHeight = CE_BSP_LIGHTMAPHEIGHT; pTexture->pcData = new aiTexel[CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT]; - ::memcpy( pTexture->pcData, pLightMap->bLMapData, pTexture->mWidth ); + ::memcpy(pTexture->pcData, pLightMap->bLMapData, pTexture->mWidth); size_t p = 0; - for ( size_t i = 0; i < CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT; ++i ) { - pTexture->pcData[ i ].r = pLightMap->bLMapData[ p++ ]; - pTexture->pcData[ i ].g = pLightMap->bLMapData[ p++ ]; - pTexture->pcData[ i ].b = pLightMap->bLMapData[ p++ ]; - pTexture->pcData[ i ].a = 0xFF; + for (size_t i = 0; i < CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT; ++i) { + pTexture->pcData[i].r = pLightMap->bLMapData[p++]; + pTexture->pcData[i].g = pLightMap->bLMapData[p++]; + pTexture->pcData[i].b = pLightMap->bLMapData[p++]; + pTexture->pcData[i].a = 0xFF; } aiString name; - name.data[ 0 ] = '*'; - name.length = 1 + ASSIMP_itoa10( name.data + 1, static_cast(MAXLEN-1), static_cast(mTextures.size()) ); + name.data[0] = '*'; + name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast(MAXLEN - 1), static_cast(mTextures.size())); - pMatHelper->AddProperty( &name,AI_MATKEY_TEXTURE_LIGHTMAP( 1 ) ); - mTextures.push_back( pTexture ); + pMatHelper->AddProperty(&name, AI_MATKEY_TEXTURE_LIGHTMAP(1)); + mTextures.push_back(pTexture); return true; } @@ -671,25 +653,21 @@ bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene // ------------------------------------------------------------------------------------------------ // Will search for a supported extension. bool Q3BSPFileImporter::expandFile(ZipArchiveIOSystem *pArchive, const std::string &rFilename, - const std::vector &rExtList, std::string &rFile, - std::string &rExt ) -{ - ai_assert( NULL != pArchive ); - ai_assert( !rFilename.empty() ); + const std::vector &rExtList, std::string &rFile, + std::string &rExt) { + ai_assert(nullptr != pArchive); + ai_assert(!rFilename.empty()); - if ( rExtList.empty() ) - { - rFile = rFilename; + if (rExtList.empty()) { + rFile = rFilename; rExt = ""; return true; } bool found = false; - for ( std::vector::const_iterator it = rExtList.begin(); it != rExtList.end(); ++it ) - { + for (std::vector::const_iterator it = rExtList.begin(); it != rExtList.end(); ++it) { const std::string textureName = rFilename + *it; - if ( pArchive->Exists( textureName.c_str() ) ) - { + if (pArchive->Exists(textureName.c_str())) { rExt = *it; rFile = textureName; found = true; diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index 693c49abe..717b5702e 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -45,17 +43,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of the Q3D importer class */ - #ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER // internal headers #include "Q3DLoader.h" #include #include -#include -#include -#include #include +#include +#include +#include using namespace Assimp; @@ -74,68 +71,66 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -Q3DImporter::Q3DImporter() -{} +Q3DImporter::Q3DImporter() { + // empty +} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -Q3DImporter::~Q3DImporter() -{} +Q3DImporter::~Q3DImporter() { + // empty +} // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool Q3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ +bool Q3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { const std::string extension = GetExtension(pFile); if (extension == "q3s" || extension == "q3o") return true; - else if (!extension.length() || checkSig) { + else if (!extension.length() || checkSig) { if (!pIOHandler) return true; - const char* tokens[] = {"quick3Do","quick3Ds"}; - return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2); + const char *tokens[] = { "quick3Do", "quick3Ds" }; + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2); } return false; } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* Q3DImporter::GetInfo () const -{ +const aiImporterDesc *Q3DImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void Q3DImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ - StreamReaderLE stream(pIOHandler->Open(pFile,"rb")); +void Q3DImporter::InternReadFile(const std::string &pFile, + aiScene *pScene, IOSystem *pIOHandler) { + StreamReaderLE stream(pIOHandler->Open(pFile, "rb")); // The header is 22 bytes large if (stream.GetRemainingSize() < 22) throw DeadlyImportError("File is either empty or corrupt: " + pFile); // Check the file's signature - if (ASSIMP_strincmp( (const char*)stream.GetPtr(), "quick3Do", 8 ) && - ASSIMP_strincmp( (const char*)stream.GetPtr(), "quick3Ds", 8 )) - { + if (ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Do", 8) && + ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Ds", 8)) { throw DeadlyImportError("Not a Quick3D file. Signature string is: " + - std::string((const char*)stream.GetPtr(),8)); + std::string((const char *)stream.GetPtr(), 8)); } // Print the file format version ASSIMP_LOG_INFO_F("Quick3D File format version: ", - std::string(&((const char*)stream.GetPtr())[8],2)); + std::string(&((const char *)stream.GetPtr())[8], 2)); // ... an store it - char major = ((const char*)stream.GetPtr())[8]; - char minor = ((const char*)stream.GetPtr())[9]; + char major = ((const char *)stream.GetPtr())[8]; + char minor = ((const char *)stream.GetPtr())[9]; stream.IncPtr(10); - unsigned int numMeshes = (unsigned int)stream.GetI4(); - unsigned int numMats = (unsigned int)stream.GetI4(); - unsigned int numTextures = (unsigned int)stream.GetI4(); + unsigned int numMeshes = (unsigned int)stream.GetI4(); + unsigned int numMats = (unsigned int)stream.GetI4(); + unsigned int numTextures = (unsigned int)stream.GetI4(); std::vector materials; materials.reserve(numMats); @@ -146,124 +141,109 @@ void Q3DImporter::InternReadFile( const std::string& pFile, // Allocate the scene root node pScene->mRootNode = new aiNode(); - aiColor3D fgColor (0.6f,0.6f,0.6f); + aiColor3D fgColor(0.6f, 0.6f, 0.6f); // Now read all file chunks - while (true) - { - if (stream.GetRemainingSize() < 1)break; + while (true) { + if (stream.GetRemainingSize() < 1) break; char c = stream.GetI1(); - switch (c) - { + switch (c) { // Meshes chunk - case 'm': - { - for (unsigned int quak = 0; quak < numMeshes; ++quak) - { - meshes.push_back(Mesh()); - Mesh& mesh = meshes.back(); + case 'm': { + for (unsigned int quak = 0; quak < numMeshes; ++quak) { + meshes.push_back(Mesh()); + Mesh &mesh = meshes.back(); - // read all vertices - unsigned int numVerts = (unsigned int)stream.GetI4(); - if (!numVerts) - throw DeadlyImportError("Quick3D: Found mesh with zero vertices"); + // read all vertices + unsigned int numVerts = (unsigned int)stream.GetI4(); + if (!numVerts) + throw DeadlyImportError("Quick3D: Found mesh with zero vertices"); - std::vector& verts = mesh.verts; - verts.resize(numVerts); + std::vector &verts = mesh.verts; + verts.resize(numVerts); - for (unsigned int i = 0; i < numVerts;++i) - { - verts[i].x = stream.GetF4(); - verts[i].y = stream.GetF4(); - verts[i].z = stream.GetF4(); - } - - // read all faces - numVerts = (unsigned int)stream.GetI4(); - if (!numVerts) - throw DeadlyImportError("Quick3D: Found mesh with zero faces"); - - std::vector& faces = mesh.faces; - faces.reserve(numVerts); - - // number of indices - for (unsigned int i = 0; i < numVerts;++i) - { - faces.push_back(Face(stream.GetI2()) ); - if (faces.back().indices.empty()) - throw DeadlyImportError("Quick3D: Found face with zero indices"); - } - - // indices - for (unsigned int i = 0; i < numVerts;++i) - { - Face& vec = faces[i]; - for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a) - vec.indices[a] = stream.GetI4(); - } - - // material indices - for (unsigned int i = 0; i < numVerts;++i) - { - faces[i].mat = (unsigned int)stream.GetI4(); - } - - // read all normals - numVerts = (unsigned int)stream.GetI4(); - std::vector& normals = mesh.normals; - normals.resize(numVerts); - - for (unsigned int i = 0; i < numVerts;++i) - { - normals[i].x = stream.GetF4(); - normals[i].y = stream.GetF4(); - normals[i].z = stream.GetF4(); - } - - numVerts = (unsigned int)stream.GetI4(); - if (numTextures && numVerts) - { - // read all texture coordinates - std::vector& uv = mesh.uv; - uv.resize(numVerts); - - for (unsigned int i = 0; i < numVerts;++i) - { - uv[i].x = stream.GetF4(); - uv[i].y = stream.GetF4(); - } - - // UV indices - for (unsigned int i = 0; i < (unsigned int)faces.size();++i) - { - Face& vec = faces[i]; - for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a) - { - vec.uvindices[a] = stream.GetI4(); - if (!i && !a) - mesh.prevUVIdx = vec.uvindices[a]; - else if (vec.uvindices[a] != mesh.prevUVIdx) - mesh.prevUVIdx = UINT_MAX; - } - } - } - - // we don't need the rest, but we need to get to the next chunk - stream.IncPtr(36); - if (minor > '0' && major == '3') - stream.IncPtr(mesh.faces.size()); + for (unsigned int i = 0; i < numVerts; ++i) { + verts[i].x = stream.GetF4(); + verts[i].y = stream.GetF4(); + verts[i].z = stream.GetF4(); } - // stream.IncPtr(4); // unknown value here + + // read all faces + numVerts = (unsigned int)stream.GetI4(); + if (!numVerts) + throw DeadlyImportError("Quick3D: Found mesh with zero faces"); + + std::vector &faces = mesh.faces; + faces.reserve(numVerts); + + // number of indices + for (unsigned int i = 0; i < numVerts; ++i) { + faces.push_back(Face(stream.GetI2())); + if (faces.back().indices.empty()) + throw DeadlyImportError("Quick3D: Found face with zero indices"); + } + + // indices + for (unsigned int i = 0; i < numVerts; ++i) { + Face &vec = faces[i]; + for (unsigned int a = 0; a < (unsigned int)vec.indices.size(); ++a) + vec.indices[a] = stream.GetI4(); + } + + // material indices + for (unsigned int i = 0; i < numVerts; ++i) { + faces[i].mat = (unsigned int)stream.GetI4(); + } + + // read all normals + numVerts = (unsigned int)stream.GetI4(); + std::vector &normals = mesh.normals; + normals.resize(numVerts); + + for (unsigned int i = 0; i < numVerts; ++i) { + normals[i].x = stream.GetF4(); + normals[i].y = stream.GetF4(); + normals[i].z = stream.GetF4(); + } + + numVerts = (unsigned int)stream.GetI4(); + if (numTextures && numVerts) { + // read all texture coordinates + std::vector &uv = mesh.uv; + uv.resize(numVerts); + + for (unsigned int i = 0; i < numVerts; ++i) { + uv[i].x = stream.GetF4(); + uv[i].y = stream.GetF4(); + } + + // UV indices + for (unsigned int i = 0; i < (unsigned int)faces.size(); ++i) { + Face &vec = faces[i]; + for (unsigned int a = 0; a < (unsigned int)vec.indices.size(); ++a) { + vec.uvindices[a] = stream.GetI4(); + if (!i && !a) + mesh.prevUVIdx = vec.uvindices[a]; + else if (vec.uvindices[a] != mesh.prevUVIdx) + mesh.prevUVIdx = UINT_MAX; + } + } + } + + // we don't need the rest, but we need to get to the next chunk + stream.IncPtr(36); + if (minor > '0' && major == '3') + stream.IncPtr(mesh.faces.size()); } - break; + // stream.IncPtr(4); // unknown value here + } break; // materials chunk case 'c': - for (unsigned int i = 0; i < numMats; ++i) - { + for (unsigned int i = 0; i < numMats; ++i) { materials.push_back(Material()); - Material& mat = materials.back(); + Material &mat = materials.back(); // read the material name c = stream.GetI1(); @@ -308,17 +288,18 @@ void Q3DImporter::InternReadFile( const std::string& pFile, if (!numTextures) { break; } - pScene->mTextures = new aiTexture*[pScene->mNumTextures]; + pScene->mTextures = new aiTexture *[pScene->mNumTextures]; // to make sure we won't crash if we leave through an exception - ::memset(pScene->mTextures,0,sizeof(void*)*pScene->mNumTextures); + ::memset(pScene->mTextures, 0, sizeof(void *) * pScene->mNumTextures); for (unsigned int i = 0; i < pScene->mNumTextures; ++i) { - aiTexture* tex = pScene->mTextures[i] = new aiTexture; + aiTexture *tex = pScene->mTextures[i] = new aiTexture; // skip the texture name - while (stream.GetI1()); + while (stream.GetI1()) + ; // read texture width and height - tex->mWidth = (unsigned int)stream.GetI4(); + tex->mWidth = (unsigned int)stream.GetI4(); tex->mHeight = (unsigned int)stream.GetI4(); if (!tex->mWidth || !tex->mHeight) { @@ -326,11 +307,10 @@ void Q3DImporter::InternReadFile( const std::string& pFile, } unsigned int mul = tex->mWidth * tex->mHeight; - aiTexel* begin = tex->pcData = new aiTexel[mul]; - aiTexel* const end = & begin[mul-1] +1; + aiTexel *begin = tex->pcData = new aiTexel[mul]; + aiTexel *const end = &begin[mul - 1] + 1; - - for (;begin != end; ++begin) { + for (; begin != end; ++begin) { begin->r = stream.GetI1(); begin->g = stream.GetI1(); begin->b = stream.GetI1(); @@ -341,68 +321,66 @@ void Q3DImporter::InternReadFile( const std::string& pFile, break; // scene chunk - case 's': - { - // skip position and rotation - stream.IncPtr(12); + case 's': { + // skip position and rotation + stream.IncPtr(12); - for (unsigned int i = 0; i < 4;++i) - for (unsigned int a = 0; a < 4;++a) - pScene->mRootNode->mTransformation[i][a] = stream.GetF4(); + for (unsigned int i = 0; i < 4; ++i) + for (unsigned int a = 0; a < 4; ++a) + pScene->mRootNode->mTransformation[i][a] = stream.GetF4(); - stream.IncPtr(16); + stream.IncPtr(16); - // now setup a single camera - pScene->mNumCameras = 1; - pScene->mCameras = new aiCamera*[1]; - aiCamera* cam = pScene->mCameras[0] = new aiCamera(); - cam->mPosition.x = stream.GetF4(); - cam->mPosition.y = stream.GetF4(); - cam->mPosition.z = stream.GetF4(); - cam->mName.Set("Q3DCamera"); + // now setup a single camera + pScene->mNumCameras = 1; + pScene->mCameras = new aiCamera *[1]; + aiCamera *cam = pScene->mCameras[0] = new aiCamera(); + cam->mPosition.x = stream.GetF4(); + cam->mPosition.y = stream.GetF4(); + cam->mPosition.z = stream.GetF4(); + cam->mName.Set("Q3DCamera"); - // skip eye rotation for the moment - stream.IncPtr(12); + // skip eye rotation for the moment + stream.IncPtr(12); - // read the default material color - fgColor .r = stream.GetF4(); - fgColor .g = stream.GetF4(); - fgColor .b = stream.GetF4(); + // read the default material color + fgColor.r = stream.GetF4(); + fgColor.g = stream.GetF4(); + fgColor.b = stream.GetF4(); - // skip some unimportant properties - stream.IncPtr(29); + // skip some unimportant properties + stream.IncPtr(29); - // setup a single point light with no attenuation - pScene->mNumLights = 1; - pScene->mLights = new aiLight*[1]; - aiLight* light = pScene->mLights[0] = new aiLight(); - light->mName.Set("Q3DLight"); - light->mType = aiLightSource_POINT; + // setup a single point light with no attenuation + pScene->mNumLights = 1; + pScene->mLights = new aiLight *[1]; + aiLight *light = pScene->mLights[0] = new aiLight(); + light->mName.Set("Q3DLight"); + light->mType = aiLightSource_POINT; - light->mAttenuationConstant = 1; - light->mAttenuationLinear = 0; - light->mAttenuationQuadratic = 0; + light->mAttenuationConstant = 1; + light->mAttenuationLinear = 0; + light->mAttenuationQuadratic = 0; - light->mColorDiffuse.r = stream.GetF4(); - light->mColorDiffuse.g = stream.GetF4(); - light->mColorDiffuse.b = stream.GetF4(); + light->mColorDiffuse.r = stream.GetF4(); + light->mColorDiffuse.g = stream.GetF4(); + light->mColorDiffuse.b = stream.GetF4(); - light->mColorSpecular = light->mColorDiffuse; + light->mColorSpecular = light->mColorDiffuse; + // We don't need the rest, but we need to know where this chunk ends. + unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4()); - // We don't need the rest, but we need to know where this chunk ends. - unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4()); + // skip the background file name + while (stream.GetI1()) + ; - // skip the background file name - while (stream.GetI1()); + // skip background texture data + the remaining fields + stream.IncPtr(temp * 3 + 20); // 4 bytes of unknown data here - // skip background texture data + the remaining fields - stream.IncPtr(temp*3 + 20); // 4 bytes of unknown data here - - // TODO - goto outer; - } - break; + // TODO + goto outer; + } break; default: throw DeadlyImportError("Quick3D: Unknown chunk"); @@ -416,55 +394,50 @@ outer: throw DeadlyImportError("Quick3D: No meshes loaded"); // If we have no materials loaded - generate a default mat - if (materials.empty()) - { + if (materials.empty()) { ASSIMP_LOG_INFO("Quick3D: No material found, generating one"); materials.push_back(Material()); - materials.back().diffuse = fgColor ; + materials.back().diffuse = fgColor; } // find out which materials we'll need typedef std::pair FaceIdx; - typedef std::vector< FaceIdx > FaceIdxArray; - FaceIdxArray* fidx = new FaceIdxArray[materials.size()]; + typedef std::vector FaceIdxArray; + FaceIdxArray *fidx = new FaceIdxArray[materials.size()]; unsigned int p = 0; for (std::vector::iterator it = meshes.begin(), end = meshes.end(); - it != end; ++it,++p) - { + it != end; ++it, ++p) { unsigned int q = 0; for (std::vector::iterator fit = (*it).faces.begin(), fend = (*it).faces.end(); - fit != fend; ++fit,++q) - { - if ((*fit).mat >= materials.size()) - { + fit != fend; ++fit, ++q) { + if ((*fit).mat >= materials.size()) { ASSIMP_LOG_WARN("Quick3D: Material index overflow"); (*fit).mat = 0; } - if (fidx[(*fit).mat].empty())++pScene->mNumMeshes; - fidx[(*fit).mat].push_back( FaceIdx(p,q) ); + if (fidx[(*fit).mat].empty()) ++pScene->mNumMeshes; + fidx[(*fit).mat].push_back(FaceIdx(p, q)); } } pScene->mNumMaterials = pScene->mNumMeshes; - pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; - pScene->mMeshes = new aiMesh*[pScene->mNumMaterials]; + pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials]; + pScene->mMeshes = new aiMesh *[pScene->mNumMaterials]; - for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i) - { - if (fidx[i].empty())continue; + for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i) { + if (fidx[i].empty()) continue; // Allocate a mesh and a material - aiMesh* mesh = pScene->mMeshes[real] = new aiMesh(); - aiMaterial* mat = new aiMaterial(); + aiMesh *mesh = pScene->mMeshes[real] = new aiMesh(); + aiMaterial *mat = new aiMaterial(); pScene->mMaterials[real] = mat; mesh->mMaterialIndex = real; // Build the output material - Material& srcMat = materials[i]; - mat->AddProperty(&srcMat.diffuse, 1,AI_MATKEY_COLOR_DIFFUSE); - mat->AddProperty(&srcMat.specular, 1,AI_MATKEY_COLOR_SPECULAR); - mat->AddProperty(&srcMat.ambient, 1,AI_MATKEY_COLOR_AMBIENT); + Material &srcMat = materials[i]; + mat->AddProperty(&srcMat.diffuse, 1, AI_MATKEY_COLOR_DIFFUSE); + mat->AddProperty(&srcMat.specular, 1, AI_MATKEY_COLOR_SPECULAR); + mat->AddProperty(&srcMat.ambient, 1, AI_MATKEY_COLOR_AMBIENT); // NOTE: Ignore transparency for the moment - it seems // unclear how to interpret the data @@ -482,57 +455,48 @@ outer: mat->AddProperty(&m, 1, AI_MATKEY_SHADING_MODEL); if (srcMat.name.length) - mat->AddProperty(&srcMat.name,AI_MATKEY_NAME); + mat->AddProperty(&srcMat.name, AI_MATKEY_NAME); // Add a texture - if (srcMat.texIdx < pScene->mNumTextures || real < pScene->mNumTextures) - { + if (srcMat.texIdx < pScene->mNumTextures || real < pScene->mNumTextures) { srcMat.name.data[0] = '*'; - srcMat.name.length = ASSIMP_itoa10(&srcMat.name.data[1],1000, - (srcMat.texIdx < pScene->mNumTextures ? srcMat.texIdx : real)); - mat->AddProperty(&srcMat.name,AI_MATKEY_TEXTURE_DIFFUSE(0)); + srcMat.name.length = ASSIMP_itoa10(&srcMat.name.data[1], 1000, + (srcMat.texIdx < pScene->mNumTextures ? srcMat.texIdx : real)); + mat->AddProperty(&srcMat.name, AI_MATKEY_TEXTURE_DIFFUSE(0)); } mesh->mNumFaces = (unsigned int)fidx[i].size(); - aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces]; + aiFace *faces = mesh->mFaces = new aiFace[mesh->mNumFaces]; // Now build the output mesh. First find out how many // vertices we'll need - for (FaceIdxArray::const_iterator it = fidx[i].begin(),end = fidx[i].end(); - it != end; ++it) - { - mesh->mNumVertices += (unsigned int)meshes[(*it).first].faces[ - (*it).second].indices.size(); + for (FaceIdxArray::const_iterator it = fidx[i].begin(), end = fidx[i].end(); + it != end; ++it) { + mesh->mNumVertices += (unsigned int)meshes[(*it).first].faces[(*it).second].indices.size(); } - aiVector3D* verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices]; - aiVector3D* norms = mesh->mNormals = new aiVector3D[mesh->mNumVertices]; - aiVector3D* uv; - if (real < pScene->mNumTextures) - { - uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices]; - mesh->mNumUVComponents[0] = 2; + aiVector3D *verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices]; + aiVector3D *norms = mesh->mNormals = new aiVector3D[mesh->mNumVertices]; + aiVector3D *uv = nullptr; + if (real < pScene->mNumTextures) { + uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices]; + mesh->mNumUVComponents[0] = 2; } - else uv = NULL; // Build the final array unsigned int cnt = 0; - for (FaceIdxArray::const_iterator it = fidx[i].begin(),end = fidx[i].end(); - it != end; ++it, ++faces) - { - Mesh& curMesh = meshes[(*it).first]; + for (FaceIdxArray::const_iterator it = fidx[i].begin(), end = fidx[i].end(); + it != end; ++it, ++faces) { + Mesh &curMesh = meshes[(*it).first]; Face &face = curMesh.faces[(*it).second]; faces->mNumIndices = (unsigned int)face.indices.size(); - faces->mIndices = new unsigned int [faces->mNumIndices]; - + faces->mIndices = new unsigned int[faces->mNumIndices]; aiVector3D faceNormal; bool fnOK = false; - for (unsigned int n = 0; n < faces->mNumIndices;++n, ++cnt, ++norms, ++verts) - { - if (face.indices[n] >= curMesh.verts.size()) - { + for (unsigned int n = 0; n < faces->mNumIndices; ++n, ++cnt, ++norms, ++verts) { + if (face.indices[n] >= curMesh.verts.size()) { ASSIMP_LOG_WARN("Quick3D: Vertex index overflow"); face.indices[n] = 0; } @@ -540,11 +504,9 @@ outer: // copy vertices *verts = curMesh.verts[face.indices[n]]; - if (face.indices[n] >= curMesh.normals.size() && faces->mNumIndices >= 3) - { + if (face.indices[n] >= curMesh.normals.size() && faces->mNumIndices >= 3) { // we have no normal here - assign the face normal - if (!fnOK) - { + if (!fnOK) { const aiVector3D &pV1 = curMesh.verts[face.indices[0]]; const aiVector3D &pV2 = curMesh.verts[face.indices[1]]; const aiVector3D &pV3 = curMesh.verts[face.indices.size() - 1]; @@ -557,16 +519,12 @@ outer: } // copy texture coordinates - if (uv && curMesh.uv.size()) - { + if (uv && curMesh.uv.size()) { if (curMesh.prevUVIdx != 0xffffffff && curMesh.uv.size() >= curMesh.verts.size()) // workaround { *uv = curMesh.uv[face.indices[n]]; - } - else - { - if (face.uvindices[n] >= curMesh.uv.size()) - { + } else { + if (face.uvindices[n] >= curMesh.uv.size()) { ASSIMP_LOG_WARN("Quick3D: Texture coordinate index overflow"); face.uvindices[n] = 0; } @@ -579,7 +537,6 @@ outer: // setup the new vertex index faces->mIndices[n] = cnt; } - } ++real; } @@ -589,8 +546,8 @@ outer: // Now we need to attach the meshes to the root node of the scene pScene->mRootNode->mNumMeshes = pScene->mNumMeshes; - pScene->mRootNode->mMeshes = new unsigned int [pScene->mNumMeshes]; - for (unsigned int i = 0; i < pScene->mNumMeshes;++i) + pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes]; + for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) pScene->mRootNode->mMeshes[i] = i; /*pScene->mRootNode->mTransformation *= aiMatrix4x4( @@ -600,13 +557,12 @@ outer: 0.f, 0.f, 0.f, 1.f);*/ // Add cameras and light sources to the scene root node - pScene->mRootNode->mNumChildren = pScene->mNumLights+pScene->mNumCameras; - if (pScene->mRootNode->mNumChildren) - { - pScene->mRootNode->mChildren = new aiNode* [ pScene->mRootNode->mNumChildren ]; + pScene->mRootNode->mNumChildren = pScene->mNumLights + pScene->mNumCameras; + if (pScene->mRootNode->mNumChildren) { + pScene->mRootNode->mChildren = new aiNode *[pScene->mRootNode->mNumChildren]; // the light source - aiNode* nd = pScene->mRootNode->mChildren[0] = new aiNode(); + aiNode *nd = pScene->mRootNode->mChildren[0] = new aiNode(); nd->mParent = pScene->mRootNode; nd->mName.Set("Q3DLight"); nd->mTransformation = pScene->mRootNode->mTransformation; diff --git a/code/AssetLib/Raw/RawLoader.cpp b/code/AssetLib/Raw/RawLoader.cpp index 092323cc0..1363e29c1 100644 --- a/code/AssetLib/Raw/RawLoader.cpp +++ b/code/AssetLib/Raw/RawLoader.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -45,18 +43,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of the RAW importer class */ - #ifndef ASSIMP_BUILD_NO_RAW_IMPORTER // internal headers #include "RawLoader.h" #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include using namespace Assimp; @@ -75,146 +72,129 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -RAWImporter::RAWImporter() -{} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -RAWImporter::~RAWImporter() -{} - -// ------------------------------------------------------------------------------------------------ -// Returns whether the class can handle the format of the given file. -bool RAWImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const -{ - return SimpleExtensionCheck(pFile,"raw"); +RAWImporter::RAWImporter() { + // empty } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* RAWImporter::GetInfo () const -{ +// Destructor, private as well +RAWImporter::~RAWImporter() { + // empty +} + +// ------------------------------------------------------------------------------------------------ +// Returns whether the class can handle the format of the given file. +bool RAWImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const { + return SimpleExtensionCheck(pFile, "raw"); +} + +// ------------------------------------------------------------------------------------------------ +const aiImporterDesc *RAWImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void RAWImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ - std::unique_ptr file( pIOHandler->Open( pFile, "rb")); +void RAWImporter::InternReadFile(const std::string &pFile, + aiScene *pScene, IOSystem *pIOHandler) { + std::unique_ptr file(pIOHandler->Open(pFile, "rb")); // Check whether we can read from the file - if( file.get() == NULL) { - throw DeadlyImportError( "Failed to open RAW file " + pFile + "."); + if (file.get() == nullptr) { + throw DeadlyImportError("Failed to open RAW file " + pFile + "."); } // allocate storage and copy the contents of the file to a memory buffer // (terminate it with zero) std::vector mBuffer2; - TextFileToBuffer(file.get(),mBuffer2); - const char* buffer = &mBuffer2[0]; + TextFileToBuffer(file.get(), mBuffer2); + const char *buffer = &mBuffer2[0]; // list of groups loaded from the file - std::vector< GroupInformation > outGroups(1,GroupInformation("")); - std::vector< GroupInformation >::iterator curGroup = outGroups.begin(); + std::vector outGroups(1, GroupInformation("")); + std::vector::iterator curGroup = outGroups.begin(); // now read all lines char line[4096]; - while (GetNextLine(buffer,line)) - { + while (GetNextLine(buffer, line)) { // if the line starts with a non-numeric identifier, it marks // the beginning of a new group - const char* sz = line;SkipSpaces(&sz); - if (IsLineEnd(*sz))continue; - if (!IsNumeric(*sz)) - { - const char* sz2 = sz; - while (!IsSpaceOrNewLine(*sz2))++sz2; - const unsigned int length = (unsigned int)(sz2-sz); + const char *sz = line; + SkipSpaces(&sz); + if (IsLineEnd(*sz)) continue; + if (!IsNumeric(*sz)) { + const char *sz2 = sz; + while (!IsSpaceOrNewLine(*sz2)) + ++sz2; + const unsigned int length = (unsigned int)(sz2 - sz); // find an existing group with this name - for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end(); - it != end;++it) - { - if (length == (*it).name.length() && !::strcmp(sz,(*it).name.c_str())) - { - curGroup = it;sz2 = NULL; + for (std::vector::iterator it = outGroups.begin(), end = outGroups.end(); + it != end; ++it) { + if (length == (*it).name.length() && !::strcmp(sz, (*it).name.c_str())) { + curGroup = it; + sz2 = nullptr; break; } } - if (sz2) - { - outGroups.push_back(GroupInformation(std::string(sz,length))); - curGroup = outGroups.end()-1; + if (sz2) { + outGroups.push_back(GroupInformation(std::string(sz, length))); + curGroup = outGroups.end() - 1; } - } - else - { + } else { // there can be maximally 12 floats plus an extra texture file name float data[12]; unsigned int num; - for (num = 0; num < 12;++num) - { - if(!SkipSpaces(&sz) || !IsNumeric(*sz))break; - sz = fast_atoreal_move(sz,data[num]); + for (num = 0; num < 12; ++num) { + if (!SkipSpaces(&sz) || !IsNumeric(*sz)) break; + sz = fast_atoreal_move(sz, data[num]); } - if (num != 12 && num != 9) - { + if (num != 12 && num != 9) { ASSIMP_LOG_ERROR("A line may have either 9 or 12 floats and an optional texture"); continue; } - MeshInformation* output = NULL; + MeshInformation *output = nullptr; - const char* sz2 = sz; + const char *sz2 = sz; unsigned int length; - if (!IsLineEnd(*sz)) - { - while (!IsSpaceOrNewLine(*sz2))++sz2; - length = (unsigned int)(sz2-sz); - } - else if (9 == num) - { + if (!IsLineEnd(*sz)) { + while (!IsSpaceOrNewLine(*sz2)) + ++sz2; + length = (unsigned int)(sz2 - sz); + } else if (9 == num) { sz = "%default%"; length = 9; - } - else - { + } else { sz = ""; length = 0; } // search in the list of meshes whether we have one with this texture - for (auto &mesh : (*curGroup).meshes) - { - if (length == mesh.name.length() && (length ? !::strcmp(sz, mesh.name.c_str()) : true)) - { + for (auto &mesh : (*curGroup).meshes) { + if (length == mesh.name.length() && (length ? !::strcmp(sz, mesh.name.c_str()) : true)) { output = &mesh; break; } } // if we don't have the mesh, create it - if (!output) - { - (*curGroup).meshes.push_back(MeshInformation(std::string(sz,length))); + if (!output) { + (*curGroup).meshes.push_back(MeshInformation(std::string(sz, length))); output = &((*curGroup).meshes.back()); } - if (12 == num) - { - aiColor4D v(data[0],data[1],data[2],1.0f); + if (12 == num) { + aiColor4D v(data[0], data[1], data[2], 1.0f); output->colors.push_back(v); output->colors.push_back(v); output->colors.push_back(v); - output->vertices.push_back(aiVector3D(data[3],data[4],data[5])); - output->vertices.push_back(aiVector3D(data[6],data[7],data[8])); - output->vertices.push_back(aiVector3D(data[9],data[10],data[11])); - } - else - { - output->vertices.push_back(aiVector3D(data[0],data[1],data[2])); - output->vertices.push_back(aiVector3D(data[3],data[4],data[5])); - output->vertices.push_back(aiVector3D(data[6],data[7],data[8])); + output->vertices.push_back(aiVector3D(data[3], data[4], data[5])); + output->vertices.push_back(aiVector3D(data[6], data[7], data[8])); + output->vertices.push_back(aiVector3D(data[9], data[10], data[11])); + } else { + output->vertices.push_back(aiVector3D(data[0], data[1], data[2])); + output->vertices.push_back(aiVector3D(data[3], data[4], data[5])); + output->vertices.push_back(aiVector3D(data[6], data[7], data[8])); } } } @@ -224,105 +204,96 @@ void RAWImporter::InternReadFile( const std::string& pFile, // count the number of valid groups // (meshes can't be empty) - for (auto & outGroup : outGroups) - { - if (!outGroup.meshes.empty()) - { + for (auto &outGroup : outGroups) { + if (!outGroup.meshes.empty()) { ++pScene->mRootNode->mNumChildren; - pScene->mNumMeshes += (unsigned int) outGroup.meshes.size(); + pScene->mNumMeshes += (unsigned int)outGroup.meshes.size(); } } - if (!pScene->mNumMeshes) - { + if (!pScene->mNumMeshes) { throw DeadlyImportError("RAW: No meshes loaded. The file seems to be corrupt or empty."); } - pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; - aiNode** cc; - if (1 == pScene->mRootNode->mNumChildren) - { + pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]; + aiNode **cc; + if (1 == pScene->mRootNode->mNumChildren) { cc = &pScene->mRootNode; pScene->mRootNode->mNumChildren = 0; } else { - cc = new aiNode*[pScene->mRootNode->mNumChildren]; - memset(cc, 0, sizeof(aiNode*) * pScene->mRootNode->mNumChildren); + cc = new aiNode *[pScene->mRootNode->mNumChildren]; + memset(cc, 0, sizeof(aiNode *) * pScene->mRootNode->mNumChildren); pScene->mRootNode->mChildren = cc; } pScene->mNumMaterials = pScene->mNumMeshes; - aiMaterial** mats = pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; + aiMaterial **mats = pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials]; unsigned int meshIdx = 0; - for (auto & outGroup : outGroups) - { - if (outGroup.meshes.empty())continue; + for (auto &outGroup : outGroups) { + if (outGroup.meshes.empty()) continue; - aiNode* node; - if (pScene->mRootNode->mNumChildren) - { + aiNode *node; + if (pScene->mRootNode->mNumChildren) { node = *cc = new aiNode(); node->mParent = pScene->mRootNode; - } - else node = *cc; + } else + node = *cc; node->mName.Set(outGroup.name); // add all meshes - node->mNumMeshes = (unsigned int) outGroup.meshes.size(); - unsigned int* pi = node->mMeshes = new unsigned int[ node->mNumMeshes ]; - for (std::vector< MeshInformation >::iterator it2 = outGroup.meshes.begin(), - end2 = outGroup.meshes.end(); it2 != end2; ++it2) - { + node->mNumMeshes = (unsigned int)outGroup.meshes.size(); + unsigned int *pi = node->mMeshes = new unsigned int[node->mNumMeshes]; + for (std::vector::iterator it2 = outGroup.meshes.begin(), + end2 = outGroup.meshes.end(); + it2 != end2; ++it2) { ai_assert(!(*it2).vertices.empty()); // allocate the mesh *pi++ = meshIdx; - aiMesh* mesh = pScene->mMeshes[meshIdx] = new aiMesh(); + aiMesh *mesh = pScene->mMeshes[meshIdx] = new aiMesh(); mesh->mMaterialIndex = meshIdx++; mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; // allocate storage for the vertex components and copy them mesh->mNumVertices = (unsigned int)(*it2).vertices.size(); - mesh->mVertices = new aiVector3D[ mesh->mNumVertices ]; - ::memcpy(mesh->mVertices,&(*it2).vertices[0],sizeof(aiVector3D)*mesh->mNumVertices); + mesh->mVertices = new aiVector3D[mesh->mNumVertices]; + ::memcpy(mesh->mVertices, &(*it2).vertices[0], sizeof(aiVector3D) * mesh->mNumVertices); - if ((*it2).colors.size()) - { + if ((*it2).colors.size()) { ai_assert((*it2).colors.size() == mesh->mNumVertices); - mesh->mColors[0] = new aiColor4D[ mesh->mNumVertices ]; - ::memcpy(mesh->mColors[0],&(*it2).colors[0],sizeof(aiColor4D)*mesh->mNumVertices); + mesh->mColors[0] = new aiColor4D[mesh->mNumVertices]; + ::memcpy(mesh->mColors[0], &(*it2).colors[0], sizeof(aiColor4D) * mesh->mNumVertices); } // generate triangles ai_assert(0 == mesh->mNumVertices % 3); - aiFace* fc = mesh->mFaces = new aiFace[ mesh->mNumFaces = mesh->mNumVertices/3 ]; - aiFace* const fcEnd = fc + mesh->mNumFaces; + aiFace *fc = mesh->mFaces = new aiFace[mesh->mNumFaces = mesh->mNumVertices / 3]; + aiFace *const fcEnd = fc + mesh->mNumFaces; unsigned int n = 0; - while (fc != fcEnd) - { - aiFace& f = *fc++; + while (fc != fcEnd) { + aiFace &f = *fc++; f.mIndices = new unsigned int[f.mNumIndices = 3]; - for (unsigned int m = 0; m < 3;++m) + for (unsigned int m = 0; m < 3; ++m) f.mIndices[m] = n++; } // generate a material for the mesh - aiMaterial* mat = new aiMaterial(); + aiMaterial *mat = new aiMaterial(); - aiColor4D clr(1.0f,1.0f,1.0f,1.0f); + aiColor4D clr(1.0f, 1.0f, 1.0f, 1.0f); if ("%default%" == (*it2).name) // a gray default material { clr.r = clr.g = clr.b = 0.6f; - } - else if ((*it2).name.length() > 0) // a texture + } else if ((*it2).name.length() > 0) // a texture { aiString s; s.Set((*it2).name); - mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0)); + mat->AddProperty(&s, AI_MATKEY_TEXTURE_DIFFUSE(0)); } - mat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE); + mat->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE); *mats++ = mat; } } diff --git a/code/AssetLib/SIB/SIBImporter.cpp b/code/AssetLib/SIB/SIBImporter.cpp index ac5646412..b36c6d9b1 100644 --- a/code/AssetLib/SIB/SIBImporter.cpp +++ b/code/AssetLib/SIB/SIBImporter.cpp @@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Nevertheless, this implementation is reasonably complete. */ - #ifndef ASSIMP_BUILD_NO_SIB_IMPORTER // internal headers @@ -60,15 +59,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #ifdef ASSIMP_USE_HUNTER -# include +#include #else //# include "../contrib/ConvertUTF/ConvertUTF.h" -# include "../contrib/utf8cpp/source/utf8.h" +#include "../contrib/utf8cpp/source/utf8.h" #endif -#include -#include -#include #include +#include +#include +#include #include @@ -86,14 +85,14 @@ static const aiImporterDesc desc = { }; struct SIBChunk { - uint32_t Tag; - uint32_t Size; + uint32_t Tag; + uint32_t Size; } PACK_STRUCT; -enum { - POS, - NRM, - UV, +enum { + POS, + NRM, + UV, N }; @@ -122,14 +121,14 @@ struct SIBObject { }; struct SIB { - std::vector mtls; - std::vector meshes; - std::vector lights; + std::vector mtls; + std::vector meshes; + std::vector lights; std::vector objs, insts; }; // ------------------------------------------------------------------------------------------------ -static SIBEdge& GetEdge(SIBMesh* mesh, uint32_t posA, uint32_t posB) { +static SIBEdge &GetEdge(SIBMesh *mesh, uint32_t posA, uint32_t posB) { SIBPair pair = (posA < posB) ? SIBPair(posA, posB) : SIBPair(posB, posA); std::map::iterator it = mesh->edgeMap.find(pair); if (it != mesh->edgeMap.end()) @@ -146,10 +145,9 @@ static SIBEdge& GetEdge(SIBMesh* mesh, uint32_t posA, uint32_t posB) { // ------------------------------------------------------------------------------------------------ // Helpers for reading chunked data. -#define TAG(A,B,C,D) ((A << 24) | (B << 16) | (C << 8) | D) +#define TAG(A, B, C, D) ((A << 24) | (B << 16) | (C << 8) | D) -static SIBChunk ReadChunk(StreamReaderLE* stream) -{ +static SIBChunk ReadChunk(StreamReaderLE *stream) { SIBChunk chunk; chunk.Tag = stream->GetU4(); chunk.Size = stream->GetU4(); @@ -159,8 +157,7 @@ static SIBChunk ReadChunk(StreamReaderLE* stream) return chunk; } -static aiColor3D ReadColor(StreamReaderLE* stream) -{ +static aiColor3D ReadColor(StreamReaderLE *stream) { float r = stream->GetF4(); float g = stream->GetF4(); float b = stream->GetF4(); @@ -168,37 +165,36 @@ static aiColor3D ReadColor(StreamReaderLE* stream) return aiColor3D(r, g, b); } -static void UnknownChunk(StreamReaderLE* /*stream*/, const SIBChunk& chunk) -{ +static void UnknownChunk(StreamReaderLE * /*stream*/, const SIBChunk &chunk) { char temp[5] = { - static_cast(( chunk.Tag>>24 ) & 0xff), - static_cast(( chunk.Tag>>16 ) & 0xff), - static_cast(( chunk.Tag>>8 ) & 0xff), + static_cast((chunk.Tag >> 24) & 0xff), + static_cast((chunk.Tag >> 16) & 0xff), + static_cast((chunk.Tag >> 8) & 0xff), static_cast(chunk.Tag & 0xff), '\0' }; - ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '",temp,"' chunk.")); + ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '", temp, "' chunk.")); } // Reads a UTF-16LE string and returns it at UTF-8. static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) { - if ( nullptr == stream || 0 == numWChars ) { + if (nullptr == stream || 0 == numWChars) { static const aiString empty; return empty; } // Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8) std::vector str; - str.reserve( numWChars * 4 + 1 ); - uint16_t *temp = new uint16_t[ numWChars ]; - for ( uint32_t n = 0; n < numWChars; ++n ) { - temp[ n ] = stream->GetU2(); + str.reserve(numWChars * 4 + 1); + uint16_t *temp = new uint16_t[numWChars]; + for (uint32_t n = 0; n < numWChars; ++n) { + temp[n] = stream->GetU2(); } // Convert it and NUL-terminate. - const uint16_t *start( temp ), *end( temp + numWChars ); - utf8::utf16to8( start, end, back_inserter( str ) ); - str[ str.size() - 1 ] = '\0'; + const uint16_t *start(temp), *end(temp + numWChars); + utf8::utf16to8(start, end, back_inserter(str)); + str[str.size() - 1] = '\0'; // Return the final string. aiString result = aiString((const char *)&str[0]); @@ -221,52 +217,49 @@ SIBImporter::~SIBImporter() { // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool SIBImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const { +bool SIBImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const { return SimpleExtensionCheck(pFile, "sib"); } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* SIBImporter::GetInfo () const { +const aiImporterDesc *SIBImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ -static void ReadVerts(SIBMesh* mesh, StreamReaderLE* stream, uint32_t count) { - if ( nullptr == mesh || nullptr == stream ) { +static void ReadVerts(SIBMesh *mesh, StreamReaderLE *stream, uint32_t count) { + if (nullptr == mesh || nullptr == stream) { return; } mesh->pos.resize(count); - for ( uint32_t n=0; npos[ n ].x = stream->GetF4(); - mesh->pos[ n ].y = stream->GetF4(); - mesh->pos[ n ].z = stream->GetF4(); + for (uint32_t n = 0; n < count; ++n) { + mesh->pos[n].x = stream->GetF4(); + mesh->pos[n].y = stream->GetF4(); + mesh->pos[n].z = stream->GetF4(); } } // ------------------------------------------------------------------------------------------------ -static void ReadFaces(SIBMesh* mesh, StreamReaderLE* stream) -{ +static void ReadFaces(SIBMesh *mesh, StreamReaderLE *stream) { uint32_t ptIdx = 0; - while (stream->GetRemainingSizeToLimit() > 0) - { + while (stream->GetRemainingSizeToLimit() > 0) { uint32_t numPoints = stream->GetU4(); // Store room for the N index channels, plus the point count. size_t pos = mesh->idx.size() + 1; - mesh->idx.resize(pos + numPoints*N); - mesh->idx[pos-1] = numPoints; + mesh->idx.resize(pos + numPoints * N); + mesh->idx[pos - 1] = numPoints; uint32_t *idx = &mesh->idx[pos]; - mesh->faceStart.push_back(static_cast(pos-1)); + mesh->faceStart.push_back(static_cast(pos - 1)); mesh->mtls.push_back(0); // Read all the position data. // UV/normals will be supplied later. // Positions are supplied indexed already, so we preserve that // mapping. UVs are supplied uniquely, so we allocate unique indices. - for (uint32_t n=0;nGetU4(); if (p >= mesh->pos.size()) throw DeadlyImportError("Vertex index is out of range."); @@ -277,17 +270,15 @@ static void ReadFaces(SIBMesh* mesh, StreamReaderLE* stream) } // Allocate data channels for normals/UVs. - mesh->nrm.resize(ptIdx, aiVector3D(0,0,0)); - mesh->uv.resize(ptIdx, aiVector3D(0,0,0)); + mesh->nrm.resize(ptIdx, aiVector3D(0, 0, 0)); + mesh->uv.resize(ptIdx, aiVector3D(0, 0, 0)); mesh->numPts = ptIdx; } // ------------------------------------------------------------------------------------------------ -static void ReadUVs(SIBMesh* mesh, StreamReaderLE* stream) -{ - while (stream->GetRemainingSizeToLimit() > 0) - { +static void ReadUVs(SIBMesh *mesh, StreamReaderLE *stream) { + while (stream->GetRemainingSizeToLimit() > 0) { uint32_t faceIdx = stream->GetU4(); uint32_t numPoints = stream->GetU4(); @@ -297,8 +288,7 @@ static void ReadUVs(SIBMesh* mesh, StreamReaderLE* stream) uint32_t pos = mesh->faceStart[faceIdx]; uint32_t *idx = &mesh->idx[pos + 1]; - for (uint32_t n=0;nuv[id].x = stream->GetF4(); mesh->uv[id].y = stream->GetF4(); @@ -307,19 +297,16 @@ static void ReadUVs(SIBMesh* mesh, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ReadMtls(SIBMesh* mesh, StreamReaderLE* stream) -{ +static void ReadMtls(SIBMesh *mesh, StreamReaderLE *stream) { // Material assignments are stored run-length encoded. // Also, we add 1 to each material so that we can use mtl #0 // as the default material. uint32_t prevFace = stream->GetU4(); uint32_t prevMtl = stream->GetU4() + 1; - while (stream->GetRemainingSizeToLimit() > 0) - { + while (stream->GetRemainingSizeToLimit() > 0) { uint32_t face = stream->GetU4(); uint32_t mtl = stream->GetU4() + 1; - while (prevFace < face) - { + while (prevFace < face) { if (prevFace >= mesh->mtls.size()) throw DeadlyImportError("Invalid face index."); mesh->mtls[prevFace++] = prevMtl; @@ -334,8 +321,7 @@ static void ReadMtls(SIBMesh* mesh, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ReadAxis(aiMatrix4x4& axis, StreamReaderLE* stream) -{ +static void ReadAxis(aiMatrix4x4 &axis, StreamReaderLE *stream) { axis.a4 = stream->GetF4(); axis.b4 = stream->GetF4(); axis.c4 = stream->GetF4(); @@ -355,10 +341,8 @@ static void ReadAxis(aiMatrix4x4& axis, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ReadEdges(SIBMesh* mesh, StreamReaderLE* stream) -{ - while (stream->GetRemainingSizeToLimit() > 0) - { +static void ReadEdges(SIBMesh *mesh, StreamReaderLE *stream) { + while (stream->GetRemainingSizeToLimit() > 0) { uint32_t posA = stream->GetU4(); uint32_t posB = stream->GetU4(); GetEdge(mesh, posA, posB); @@ -366,10 +350,8 @@ static void ReadEdges(SIBMesh* mesh, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ReadCreases(SIBMesh* mesh, StreamReaderLE* stream) -{ - while (stream->GetRemainingSizeToLimit() > 0) - { +static void ReadCreases(SIBMesh *mesh, StreamReaderLE *stream) { + while (stream->GetRemainingSizeToLimit() > 0) { uint32_t edge = stream->GetU4(); if (edge >= mesh->edges.size()) throw DeadlyImportError("SIB: Invalid edge index."); @@ -378,22 +360,19 @@ static void ReadCreases(SIBMesh* mesh, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ConnectFaces(SIBMesh* mesh) -{ +static void ConnectFaces(SIBMesh *mesh) { // Find faces connected to each edge. size_t numFaces = mesh->faceStart.size(); - for (size_t faceIdx=0;faceIdxidx[mesh->faceStart[faceIdx]]; uint32_t numPoints = *idx++; - uint32_t prev = idx[(numPoints-1)*N+POS]; + uint32_t prev = idx[(numPoints - 1) * N + POS]; - for (uint32_t i=0;i& faceNormals) -{ +static aiVector3D CalculateVertexNormal(SIBMesh *mesh, uint32_t faceIdx, uint32_t pos, + const std::vector &faceNormals) { // Creased edges complicate this. We need to find the start/end range of the // ring of faces that touch this position. // We do this in two passes. The first pass is to find the end of the range, // the second is to work backwards to the start and calculate the final normal. aiVector3D vtxNormal; - for (int pass=0;pass<2;pass++) - { + for (int pass = 0; pass < 2; pass++) { vtxNormal = aiVector3D(0, 0, 0); uint32_t startFaceIdx = faceIdx; uint32_t prevFaceIdx = faceIdx; // Process each connected face. - while (true) - { + while (true) { // Accumulate the face normal. vtxNormal += faceNormals[faceIdx]; uint32_t nextFaceIdx = 0xffffffff; // Move to the next edge sharing this position. - uint32_t* idx = &mesh->idx[mesh->faceStart[faceIdx]]; + uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]]; uint32_t numPoints = *idx++; - uint32_t posA = idx[(numPoints-1)*N+POS]; - for (uint32_t n=0;nfaceStart.size(); // Calculate face normals. std::vector faceNormals(numFaces); - for (size_t faceIdx=0;faceIdxidx[mesh->faceStart[faceIdx]]; + for (size_t faceIdx = 0; faceIdx < numFaces; faceIdx++) { + uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]]; uint32_t numPoints = *idx++; aiVector3D faceNormal(0, 0, 0); - uint32_t *prev = &idx[(numPoints-1)*N]; + uint32_t *prev = &idx[(numPoints - 1) * N]; - for (uint32_t i=0;ipos[prev[POS]] ^ mesh->pos[next[POS]]; prev = next; @@ -506,15 +476,13 @@ static void CalculateNormals(SIBMesh* mesh) } // Calculate vertex normals. - for (size_t faceIdx=0;faceIdxidx[mesh->faceStart[faceIdx]]; + for (size_t faceIdx = 0; faceIdx < numFaces; faceIdx++) { + uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]]; uint32_t numPoints = *idx++; - for (uint32_t i=0;i(faceIdx), pos, faceNormals); mesh->nrm[nrm] = vtxNorm; } @@ -522,43 +490,39 @@ static void CalculateNormals(SIBMesh* mesh) } // ------------------------------------------------------------------------------------------------ -struct TempMesh -{ +struct TempMesh { std::vector vtx; std::vector nrm; std::vector uv; - std::vector faces; + std::vector faces; }; -static void ReadShape(SIB* sib, StreamReaderLE* stream) -{ +static void ReadShape(SIB *sib, StreamReaderLE *stream) { SIBMesh smesh; aiString name; - while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); - switch (chunk.Tag) - { - case TAG('M','I','R','P'): break; // mirror plane maybe? - case TAG('I','M','R','P'): break; // instance mirror? (not supported here yet) - case TAG('D','I','N','F'): break; // display info, not needed - case TAG('P','I','N','F'): break; // ? - case TAG('V','M','I','R'): break; // ? - case TAG('F','M','I','R'): break; // ? - case TAG('T','X','S','M'): break; // ? - case TAG('F','A','H','S'): break; // ? - case TAG('V','R','T','S'): ReadVerts(&smesh, stream, chunk.Size/12); break; - case TAG('F','A','C','S'): ReadFaces(&smesh, stream); break; - case TAG('F','T','V','S'): ReadUVs(&smesh, stream); break; - case TAG('S','N','A','M'): name = ReadString(stream, chunk.Size/2); break; - case TAG('F','A','M','A'): ReadMtls(&smesh, stream); break; - case TAG('A','X','I','S'): ReadAxis(smesh.axis, stream); break; - case TAG('E','D','G','S'): ReadEdges(&smesh, stream); break; - case TAG('E','C','R','S'): ReadCreases(&smesh, stream); break; - default: UnknownChunk(stream, chunk); break; + switch (chunk.Tag) { + case TAG('M', 'I', 'R', 'P'): break; // mirror plane maybe? + case TAG('I', 'M', 'R', 'P'): break; // instance mirror? (not supported here yet) + case TAG('D', 'I', 'N', 'F'): break; // display info, not needed + case TAG('P', 'I', 'N', 'F'): break; // ? + case TAG('V', 'M', 'I', 'R'): break; // ? + case TAG('F', 'M', 'I', 'R'): break; // ? + case TAG('T', 'X', 'S', 'M'): break; // ? + case TAG('F', 'A', 'H', 'S'): break; // ? + case TAG('V', 'R', 'T', 'S'): ReadVerts(&smesh, stream, chunk.Size / 12); break; + case TAG('F', 'A', 'C', 'S'): ReadFaces(&smesh, stream); break; + case TAG('F', 'T', 'V', 'S'): ReadUVs(&smesh, stream); break; + case TAG('S', 'N', 'A', 'M'): name = ReadString(stream, chunk.Size / 2); break; + case TAG('F', 'A', 'M', 'A'): ReadMtls(&smesh, stream); break; + case TAG('A', 'X', 'I', 'S'): ReadAxis(smesh.axis, stream); break; + case TAG('E', 'D', 'G', 'S'): ReadEdges(&smesh, stream); break; + case TAG('E', 'C', 'R', 'S'): ReadCreases(&smesh, stream); break; + default: UnknownChunk(stream, chunk); break; } stream->SetCurrentPos(stream->GetReadLimit()); @@ -585,25 +549,22 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) std::vector meshes(sib->mtls.size()); // Un-index the source data and apply to each vertex. - for (unsigned fi=0;fi= meshes.size()) - { + if (mtl >= meshes.size()) { ASSIMP_LOG_ERROR("SIB: Face material index is invalid."); mtl = 0; } - TempMesh& dest = meshes[mtl]; + TempMesh &dest = meshes[mtl]; aiFace face; face.mNumIndices = *idx++; face.mIndices = new unsigned[face.mNumIndices]; - for (unsigned pt=0;pt(vtxIdx); @@ -611,7 +572,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) // we did it when creating the data. aiVector3D pos = smesh.pos[idx[POS]]; aiVector3D nrm = smesh.nrm[idx[NRM]]; - aiVector3D uv = smesh.uv[idx[UV]]; + aiVector3D uv = smesh.uv[idx[UV]]; // The verts are supplied in world-space, so let's // transform them back into the local space of this mesh: @@ -632,13 +593,12 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) // Now that we know the size of everything, // we can build the final one-material-per-mesh data. - for (size_t n=0;nmName = name; mesh->mNumFaces = static_cast(src.faces.size()); mesh->mFaces = new aiFace[mesh->mNumFaces]; @@ -649,14 +609,12 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) mesh->mNumUVComponents[0] = 2; mesh->mMaterialIndex = static_cast(n); - for (unsigned i=0;imNumVertices;i++) - { + for (unsigned i = 0; i < mesh->mNumVertices; i++) { mesh->mVertices[i] = src.vtx[i]; mesh->mNormals[i] = src.nrm[i]; mesh->mTextureCoords[0][i] = src.uv[i]; } - for (unsigned i=0;imNumFaces;i++) - { + for (unsigned i = 0; i < mesh->mNumFaces; i++) { mesh->mFaces[i] = src.faces[i]; } @@ -668,8 +626,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ReadMaterial(SIB* sib, StreamReaderLE* stream) -{ +static void ReadMaterial(SIB *sib, StreamReaderLE *stream) { aiColor3D diff = ReadColor(stream); aiColor3D ambi = ReadColor(stream); aiColor3D spec = ReadColor(stream); @@ -677,11 +634,11 @@ static void ReadMaterial(SIB* sib, StreamReaderLE* stream) float shiny = (float)stream->GetU4(); uint32_t nameLen = stream->GetU4(); - aiString name = ReadString(stream, nameLen/2); + aiString name = ReadString(stream, nameLen / 2); uint32_t texLen = stream->GetU4(); - aiString tex = ReadString(stream, texLen/2); + aiString tex = ReadString(stream, texLen / 2); - aiMaterial* mtl = new aiMaterial(); + aiMaterial *mtl = new aiMaterial(); mtl->AddProperty(&diff, 1, AI_MATKEY_COLOR_DIFFUSE); mtl->AddProperty(&ambi, 1, AI_MATKEY_COLOR_AMBIENT); mtl->AddProperty(&spec, 1, AI_MATKEY_COLOR_SPECULAR); @@ -697,8 +654,7 @@ static void ReadMaterial(SIB* sib, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ReadLightInfo(aiLight* light, StreamReaderLE* stream) -{ +static void ReadLightInfo(aiLight *light, StreamReaderLE *stream) { uint32_t type = stream->GetU4(); switch (type) { case 0: light->mType = aiLightSource_POINT; break; @@ -728,7 +684,7 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream) // 99% and 1% percentiles. // OpenGL: I = cos(angle)^E // Solving: angle = acos(I^(1/E)) - ai_real E = ai_real( 1.0 ) / std::max(spotExponent, (ai_real)0.00001); + ai_real E = ai_real(1.0) / std::max(spotExponent, (ai_real)0.00001); ai_real inner = std::acos(std::pow((ai_real)0.99, E)); ai_real outer = std::acos(std::pow((ai_real)0.01, E)); @@ -739,20 +695,17 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream) light->mAngleOuterCone = outer; } -static void ReadLight(SIB* sib, StreamReaderLE* stream) -{ - aiLight* light = new aiLight(); +static void ReadLight(SIB *sib, StreamReaderLE *stream) { + aiLight *light = new aiLight(); - while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); - switch (chunk.Tag) - { - case TAG('L','N','F','O'): ReadLightInfo(light, stream); break; - case TAG('S','N','A','M'): light->mName = ReadString(stream, chunk.Size/2); break; - default: UnknownChunk(stream, chunk); break; + switch (chunk.Tag) { + case TAG('L', 'N', 'F', 'O'): ReadLightInfo(light, stream); break; + case TAG('S', 'N', 'A', 'M'): light->mName = ReadString(stream, chunk.Size / 2); break; + default: UnknownChunk(stream, chunk); break; } stream->SetCurrentPos(stream->GetReadLimit()); @@ -763,8 +716,7 @@ static void ReadLight(SIB* sib, StreamReaderLE* stream) } // ------------------------------------------------------------------------------------------------ -static void ReadScale(aiMatrix4x4& axis, StreamReaderLE* stream) -{ +static void ReadScale(aiMatrix4x4 &axis, StreamReaderLE *stream) { aiMatrix4x4 scale; scale.a1 = stream->GetF4(); scale.b1 = stream->GetF4(); @@ -786,68 +738,61 @@ static void ReadScale(aiMatrix4x4& axis, StreamReaderLE* stream) axis = axis * scale; } -static void ReadInstance(SIB* sib, StreamReaderLE* stream) -{ +static void ReadInstance(SIB *sib, StreamReaderLE *stream) { SIBObject inst; uint32_t shapeIndex = 0; - while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); - switch (chunk.Tag) - { - case TAG('D','I','N','F'): break; // display info, not needed - case TAG('P','I','N','F'): break; // ? - case TAG('A','X','I','S'): ReadAxis(inst.axis, stream); break; - case TAG('I','N','S','I'): shapeIndex = stream->GetU4(); break; - case TAG('S','M','T','X'): ReadScale(inst.axis, stream); break; - case TAG('S','N','A','M'): inst.name = ReadString(stream, chunk.Size/2); break; - default: UnknownChunk(stream, chunk); break; + switch (chunk.Tag) { + case TAG('D', 'I', 'N', 'F'): break; // display info, not needed + case TAG('P', 'I', 'N', 'F'): break; // ? + case TAG('A', 'X', 'I', 'S'): ReadAxis(inst.axis, stream); break; + case TAG('I', 'N', 'S', 'I'): shapeIndex = stream->GetU4(); break; + case TAG('S', 'M', 'T', 'X'): ReadScale(inst.axis, stream); break; + case TAG('S', 'N', 'A', 'M'): inst.name = ReadString(stream, chunk.Size / 2); break; + default: UnknownChunk(stream, chunk); break; } stream->SetCurrentPos(stream->GetReadLimit()); stream->SetReadLimit(oldLimit); } - if ( shapeIndex >= sib->objs.size() ) { - throw DeadlyImportError( "SIB: Invalid shape index." ); + if (shapeIndex >= sib->objs.size()) { + throw DeadlyImportError("SIB: Invalid shape index."); } - const SIBObject& src = sib->objs[shapeIndex]; + const SIBObject &src = sib->objs[shapeIndex]; inst.meshIdx = src.meshIdx; inst.meshCount = src.meshCount; sib->insts.push_back(inst); } // ------------------------------------------------------------------------------------------------ -static void CheckVersion(StreamReaderLE* stream) -{ +static void CheckVersion(StreamReaderLE *stream) { uint32_t version = stream->GetU4(); - if ( version < 1 || version > 2 ) { - throw DeadlyImportError( "SIB: Unsupported file version." ); + if (version < 1 || version > 2) { + throw DeadlyImportError("SIB: Unsupported file version."); } } -static void ReadScene(SIB* sib, StreamReaderLE* stream) -{ +static void ReadScene(SIB *sib, StreamReaderLE *stream) { // Parse each chunk in turn. - while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) - { + while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) { SIBChunk chunk = ReadChunk(stream); unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size); - switch (chunk.Tag) - { - case TAG('H','E','A','D'): CheckVersion(stream); break; - case TAG('S','H','A','P'): ReadShape(sib, stream); break; - case TAG('G','R','P','S'): break; // group assignment, we don't import this - case TAG('T','E','X','P'): break; // ? - case TAG('I','N','S','T'): ReadInstance(sib, stream); break; - case TAG('M','A','T','R'): ReadMaterial(sib, stream); break; - case TAG('L','G','H','T'): ReadLight(sib, stream); break; - default: UnknownChunk(stream, chunk); break; + switch (chunk.Tag) { + case TAG('H', 'E', 'A', 'D'): CheckVersion(stream); break; + case TAG('S', 'H', 'A', 'P'): ReadShape(sib, stream); break; + case TAG('G', 'R', 'P', 'S'): break; // group assignment, we don't import this + case TAG('T', 'E', 'X', 'P'): break; // ? + case TAG('I', 'N', 'S', 'T'): ReadInstance(sib, stream); break; + case TAG('M', 'A', 'T', 'R'): ReadMaterial(sib, stream); break; + case TAG('L', 'G', 'H', 'T'): ReadLight(sib, stream); break; + default: UnknownChunk(stream, chunk); break; } stream->SetCurrentPos(stream->GetReadLimit()); @@ -857,9 +802,8 @@ static void ReadScene(SIB* sib, StreamReaderLE* stream) // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void SIBImporter::InternReadFile(const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ +void SIBImporter::InternReadFile(const std::string &pFile, + aiScene *pScene, IOSystem *pIOHandler) { StreamReaderLE stream(pIOHandler->Open(pFile, "rb")); // We should have at least one chunk @@ -869,7 +813,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, SIB sib; // Default material. - aiMaterial* defmtl = new aiMaterial; + aiMaterial *defmtl = new aiMaterial; aiString defname = aiString(AI_DEFAULT_MATERIAL_NAME); defmtl->AddProperty(&defname, AI_MATKEY_NAME); sib.mtls.push_back(defmtl); @@ -886,57 +830,54 @@ void SIBImporter::InternReadFile(const std::string& pFile, pScene->mNumMaterials = static_cast(sib.mtls.size()); pScene->mNumMeshes = static_cast(sib.meshes.size()); pScene->mNumLights = static_cast(sib.lights.size()); - pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : NULL; - pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : NULL; - pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : NULL; + pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial *[pScene->mNumMaterials] : nullptr; + pScene->mMeshes = pScene->mNumMeshes ? new aiMesh *[pScene->mNumMeshes] : nullptr; + pScene->mLights = pScene->mNumLights ? new aiLight *[pScene->mNumLights] : nullptr; if (pScene->mNumMaterials) - memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials); + memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial *) * pScene->mNumMaterials); if (pScene->mNumMeshes) - memcpy(pScene->mMeshes, &sib.meshes[0], sizeof(aiMesh*) * pScene->mNumMeshes); + memcpy(pScene->mMeshes, &sib.meshes[0], sizeof(aiMesh *) * pScene->mNumMeshes); if (pScene->mNumLights) - memcpy(pScene->mLights, &sib.lights[0], sizeof(aiLight*) * pScene->mNumLights); + memcpy(pScene->mLights, &sib.lights[0], sizeof(aiLight *) * pScene->mNumLights); // Construct the root node. size_t childIdx = 0; aiNode *root = new aiNode(); root->mName.Set(""); root->mNumChildren = static_cast(sib.objs.size() + sib.lights.size()); - root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : NULL; + root->mChildren = root->mNumChildren ? new aiNode *[root->mNumChildren] : nullptr; pScene->mRootNode = root; // Add nodes for each object. - for (size_t n=0;nmChildren); - SIBObject& obj = sib.objs[n]; - aiNode* node = new aiNode; + SIBObject &obj = sib.objs[n]; + aiNode *node = new aiNode; root->mChildren[childIdx++] = node; node->mName = obj.name; node->mParent = root; node->mTransformation = obj.axis; node->mNumMeshes = static_cast(obj.meshCount); - node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : NULL; - for (unsigned i=0;imNumMeshes;i++) + node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : nullptr; + for (unsigned i = 0; i < node->mNumMeshes; i++) node->mMeshes[i] = static_cast(obj.meshIdx + i); // Mark instanced objects as being so. - if (n >= firstInst) - { - node->mMetaData = aiMetadata::Alloc( 1 ); - node->mMetaData->Set( 0, "IsInstance", true ); + if (n >= firstInst) { + node->mMetaData = aiMetadata::Alloc(1); + node->mMetaData->Set(0, "IsInstance", true); } } // Add nodes for each light. // (no transformation as the light is already in world space) - for (size_t n=0;nmChildren); - aiLight* light = sib.lights[n]; - if ( nullptr != light ) { - aiNode* node = new aiNode; - root->mChildren[ childIdx++ ] = node; + aiLight *light = sib.lights[n]; + if (nullptr != light) { + aiNode *node = new aiNode; + root->mChildren[childIdx++] = node; node->mName = light->mName; node->mParent = root; } diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 2d9d677a7..8a7625f93 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -577,7 +577,7 @@ void SMDImporter::GetAnimationFileList(const std::string &pFile, IOSystem* pIOHa char *context1, *context2; tok1 = strtok_s(&buf[0], "\r\n", &context1); - while (tok1 != NULL) { + while (tok1 != nullptr) { tok2 = strtok_s(tok1, " \t", &context2); if (tok2) { char *p = tok2; diff --git a/code/AssetLib/STEPParser/STEPFileReader.cpp b/code/AssetLib/STEPParser/STEPFileReader.cpp index 84c5c463a..d3f2a344c 100644 --- a/code/AssetLib/STEPParser/STEPFileReader.cpp +++ b/code/AssetLib/STEPParser/STEPFileReader.cpp @@ -299,7 +299,7 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, } // ------------------------------------------------------------------------------------------------ -std::shared_ptr EXPRESS::DataType::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= NULL*/) +std::shared_ptr EXPRESS::DataType::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= nullptr*/) { const char* cur = inout; SkipSpaces(&cur); @@ -422,7 +422,7 @@ std::shared_ptr EXPRESS::DataType::Parse(const char*& i } // ------------------------------------------------------------------------------------------------ -std::shared_ptr EXPRESS::LIST::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= NULL*/) { +std::shared_ptr EXPRESS::LIST::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= nullptr*/) { const std::shared_ptr list = std::make_shared(); EXPRESS::LIST::MemberList& members = list->members; @@ -540,9 +540,9 @@ void STEP::LazyObject::LazyInit() const { const char* acopy = args; std::shared_ptr conv_args = EXPRESS::LIST::Parse(acopy,(uint64_t)STEP::SyntaxError::LINE_NOT_SPECIFIED,&db.GetSchema()); delete[] args; - args = NULL; + args = nullptr; - // if the converter fails, it should throw an exception, but it should never return NULL + // if the converter fails, it should throw an exception, but it should never return nullptr try { obj = proc(db,*conv_args); } diff --git a/code/AssetLib/STL/STLExporter.cpp b/code/AssetLib/STL/STLExporter.cpp index 06723cdba..fd4c41033 100644 --- a/code/AssetLib/STL/STLExporter.cpp +++ b/code/AssetLib/STL/STLExporter.cpp @@ -72,7 +72,7 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write the file. std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .stl file: " + std::string(pFile)); } @@ -91,7 +91,7 @@ void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* // we're still here - export successfully completed. Write the file. std::unique_ptr outfile (pIOSystem->Open(pFile,"wb")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .stl file: " + std::string(pFile)); } diff --git a/code/AssetLib/STL/STLLoader.cpp b/code/AssetLib/STL/STLLoader.cpp index 702f4fe5d..2d710b084 100644 --- a/code/AssetLib/STL/STLLoader.cpp +++ b/code/AssetLib/STL/STLLoader.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -101,11 +99,13 @@ static bool IsAsciiSTL(const char *buffer, unsigned int fileSize) { const char *bufferEnd = buffer + fileSize; - if (!SkipSpaces(&buffer)) + if (!SkipSpaces(&buffer)) { return false; + } - if (buffer + 5 >= bufferEnd) + if (buffer + 5 >= bufferEnd) { return false; + } bool isASCII(strncmp(buffer, "solid", 5) == 0); if (isASCII) { @@ -370,13 +370,21 @@ void STLImporter::LoadASCIIFile(aiNode *root) { pMesh->mNumFaces = static_cast(positionBuffer.size() / 3); pMesh->mNumVertices = static_cast(positionBuffer.size()); pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; - memcpy(pMesh->mVertices, &positionBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D)); + for (size_t i=0; imNumVertices; ++i ) { + pMesh->mVertices[i].x = positionBuffer[i].x; + pMesh->mVertices[i].y = positionBuffer[i].y; + pMesh->mVertices[i].z = positionBuffer[i].z; + } positionBuffer.clear(); } // also only process normalBuffer when filled, else exception when accessing with index operator if (!normalBuffer.empty()) { pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; - memcpy(pMesh->mNormals, &normalBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D)); + for (size_t i=0; imNumVertices; ++i ) { + pMesh->mNormals[i].x = normalBuffer[i].x; + pMesh->mNormals[i].y = normalBuffer[i].y; + pMesh->mNormals[i].z = normalBuffer[i].z; + } normalBuffer.clear(); } diff --git a/code/AssetLib/Step/StepExporter.cpp b/code/AssetLib/Step/StepExporter.cpp index 279ecabe9..38723ca97 100644 --- a/code/AssetLib/Step/StepExporter.cpp +++ b/code/AssetLib/Step/StepExporter.cpp @@ -108,7 +108,7 @@ void ExportSceneStep(const char* pFile,IOSystem* pIOSystem, const aiScene* pScen // we're still here - export successfully completed. Write result to the given IOSYstem std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .stp file: " + std::string(pFile)); } @@ -204,7 +204,7 @@ void StepExporter::WriteFile() static const unsigned int date_nb_chars = 20; char date_str[date_nb_chars]; - std::time_t date = std::time(NULL); + std::time_t date = std::time(nullptr); std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date)); // write the header diff --git a/code/AssetLib/StepFile/StepFileGen1.cpp b/code/AssetLib/StepFile/StepFileGen1.cpp deleted file mode 100644 index 077b2d4c5..000000000 --- a/code/AssetLib/StepFile/StepFileGen1.cpp +++ /dev/null @@ -1,2194 +0,0 @@ -/* -Open Asset Import Library (ASSIMP) ----------------------------------------------------------------------- - -Copyright (c) 2006-2020, ASSIMP Development Team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the ASSIMP team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the ASSIMP Development Team. - -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 -OWNER 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. - ----------------------------------------------------------------------- -*/ - -/** MACHINE-GENERATED by scripts/ICFImporter/CppGenerator.py */ - -#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER - -#include "code/Importer/StepFile/StepReaderGen.h" - -namespace Assimp { -using namespace StepFile; - -namespace { - - typedef EXPRESS::ConversionSchema::SchemaEntry SchemaEntry; - - const SchemaEntry schema_raw[] = { - SchemaEntry("absorbed_dose_measure",NULL ) -, SchemaEntry("acceleration_measure",NULL ) -, SchemaEntry("action_items",NULL ) -, SchemaEntry("action_method_items",NULL ) -, SchemaEntry("action_request_item",NULL ) -, SchemaEntry("ahead_or_behind",NULL ) -, SchemaEntry("amount_of_substance_measure",NULL ) -, SchemaEntry("angle_direction_reference_select",NULL ) -, SchemaEntry("angle_direction_reference_with_a2p3d_select",NULL ) -, SchemaEntry("angle_relator",NULL ) -, SchemaEntry("annotation_plane_element",NULL ) -, SchemaEntry("annotation_representation_select",NULL ) -, SchemaEntry("annotation_symbol_occurrence_item",NULL ) -, SchemaEntry("annotation_text_occurrence_item",NULL ) -, SchemaEntry("approval_item",NULL ) -, SchemaEntry("approved_item",NULL ) -, SchemaEntry("area_measure",NULL ) -, SchemaEntry("area_or_view",NULL ) -, SchemaEntry("attribute_classification_item",NULL ) -, SchemaEntry("attribute_language_item",NULL ) -, SchemaEntry("attribute_type",NULL ) -, SchemaEntry("axis2_placement",NULL ) -, SchemaEntry("b_spline_curve_form",NULL ) -, SchemaEntry("b_spline_surface_form",NULL ) -, SchemaEntry("base_solid_select",NULL ) -, SchemaEntry("blend_end_condition_select",NULL ) -, SchemaEntry("blend_radius_variation_type",NULL ) -, SchemaEntry("boolean_operand",NULL ) -, SchemaEntry("boolean_operator",NULL ) -, SchemaEntry("box_characteristic_select",NULL ) -, SchemaEntry("box_height",NULL ) -, SchemaEntry("box_rotate_angle",NULL ) -, SchemaEntry("box_slant_angle",NULL ) -, SchemaEntry("box_width",NULL ) -, SchemaEntry("camera_model_d3_multi_clipping_interection_select",NULL ) -, SchemaEntry("camera_model_d3_multi_clipping_union_select",NULL ) -, SchemaEntry("capacitance_measure",NULL ) -, SchemaEntry("category_usage_item",NULL ) -, SchemaEntry("cc_classified_item",NULL ) -, SchemaEntry("cc_person_organization_item",NULL ) -, SchemaEntry("cc_specified_item",NULL ) -, SchemaEntry("celsius_temperature_measure",NULL ) -, SchemaEntry("central_or_parallel",NULL ) -, SchemaEntry("certification_item",NULL ) -, SchemaEntry("certified_item",NULL ) -, SchemaEntry("change_request_item",NULL ) -, SchemaEntry("character_spacing_select",NULL ) -, SchemaEntry("character_style_select",NULL ) -, SchemaEntry("characterized_action_definition",NULL ) -, SchemaEntry("characterized_definition",NULL ) -, SchemaEntry("characterized_material_property",NULL ) -, SchemaEntry("characterized_product_composition_value",NULL ) -, SchemaEntry("characterized_product_definition",NULL ) -, SchemaEntry("class_usage_effectivity_context_item",NULL ) -, SchemaEntry("classification_item",NULL ) -, SchemaEntry("classified_item",NULL ) -, SchemaEntry("compound_item_definition",NULL ) -, SchemaEntry("conductance_measure",NULL ) -, SchemaEntry("configuration_design_item",NULL ) -, SchemaEntry("configured_effectivity_context_item",NULL ) -, SchemaEntry("configured_effectivity_item",NULL ) -, SchemaEntry("constructive_geometry_representation_or_shape_represenation",NULL ) -, SchemaEntry("context_dependent_measure",NULL ) -, SchemaEntry("contract_item",NULL ) -, SchemaEntry("contracted_item",NULL ) -, SchemaEntry("count_measure",NULL ) -, SchemaEntry("csg_primitive",NULL ) -, SchemaEntry("csg_select",NULL ) -, SchemaEntry("curve_font_or_scaled_curve_font_select",NULL ) -, SchemaEntry("curve_on_surface",NULL ) -, SchemaEntry("curve_or_annotation_curve_occurrence",NULL ) -, SchemaEntry("curve_or_render",NULL ) -, SchemaEntry("curve_style_font_select",NULL ) -, SchemaEntry("date_and_time_item",NULL ) -, SchemaEntry("date_item",NULL ) -, SchemaEntry("date_time_item",NULL ) -, SchemaEntry("date_time_or_event_occurrence",NULL ) -, SchemaEntry("date_time_select",NULL ) -, SchemaEntry("day_in_month_number",NULL ) -, SchemaEntry("day_in_week_number",NULL ) -, SchemaEntry("day_in_year_number",NULL ) -, SchemaEntry("defined_symbol_select",NULL ) -, SchemaEntry("derived_property_select",NULL ) -, SchemaEntry("description_attribute_select",NULL ) -, SchemaEntry("descriptive_measure",NULL ) -, SchemaEntry("dimension_count",NULL ) -, SchemaEntry("dimension_extent_usage",NULL ) -, SchemaEntry("dimensional_characteristic",NULL ) -, SchemaEntry("direction_count_select",NULL ) -, SchemaEntry("document_identifier_assigned_item",NULL ) -, SchemaEntry("document_reference_item",NULL ) -, SchemaEntry("dose_equivalent_measure",NULL ) -, SchemaEntry("draughting_callout_element",NULL ) -, SchemaEntry("draughting_model_item_association_select",NULL ) -, SchemaEntry("draughting_model_item_select",NULL ) -, SchemaEntry("draughting_titled_item",NULL ) -, SchemaEntry("effectivity_item",NULL ) -, SchemaEntry("electric_charge_measure",NULL ) -, SchemaEntry("electric_current_measure",NULL ) -, SchemaEntry("electric_potential_measure",NULL ) -, SchemaEntry("energy_measure",NULL ) -, SchemaEntry("event_occurrence_item",NULL ) -, SchemaEntry("external_identification_item",NULL ) -, SchemaEntry("fill_area_style_tile_shape_select",NULL ) -, SchemaEntry("fill_style_select",NULL ) -, SchemaEntry("font_select",NULL ) -, SchemaEntry("force_measure",NULL ) -, SchemaEntry("founded_item_select",NULL ) -, SchemaEntry("frequency_measure",NULL ) -, SchemaEntry("generalized_surface_select",NULL ) -, SchemaEntry("geometric_item_specific_usage_select",NULL ) -, SchemaEntry("geometric_set_select",NULL ) -, SchemaEntry("groupable_item",NULL ) -, SchemaEntry("hour_in_day",NULL ) -, SchemaEntry("id_attribute_select",NULL ) -, SchemaEntry("identification_item",NULL ) -, SchemaEntry("identifier",NULL ) -, SchemaEntry("illuminance_measure",NULL ) -, SchemaEntry("inductance_measure",NULL ) -, SchemaEntry("instance_usage_context_select",NULL ) -, SchemaEntry("invisibility_context",NULL ) -, SchemaEntry("invisible_item",NULL ) -, SchemaEntry("ir_usage_item",NULL ) -, SchemaEntry("knot_type",NULL ) -, SchemaEntry("label",NULL ) -, SchemaEntry("layered_item",NULL ) -, SchemaEntry("length_measure",NULL ) -, SchemaEntry("limit_condition",NULL ) -, SchemaEntry("list_of_reversible_topology_item",NULL ) -, SchemaEntry("list_representation_item",NULL ) -, SchemaEntry("luminous_flux_measure",NULL ) -, SchemaEntry("luminous_intensity_measure",NULL ) -, SchemaEntry("magnetic_flux_density_measure",NULL ) -, SchemaEntry("magnetic_flux_measure",NULL ) -, SchemaEntry("marker_select",NULL ) -, SchemaEntry("marker_type",NULL ) -, SchemaEntry("mass_measure",NULL ) -, SchemaEntry("measure_value",NULL ) -, SchemaEntry("mechanical_design_and_draughting_relationship_select",NULL ) -, SchemaEntry("mechanical_design_geometric_presentation_area_items",NULL ) -, SchemaEntry("mechanical_design_geometric_presentation_representation_items",NULL ) -, SchemaEntry("message",NULL ) -, SchemaEntry("minute_in_hour",NULL ) -, SchemaEntry("month_in_year_number",NULL ) -, SchemaEntry("multi_language_attribute_item",NULL ) -, SchemaEntry("name_attribute_select",NULL ) -, SchemaEntry("name_item",NULL ) -, SchemaEntry("non_negative_length_measure",NULL ) -, SchemaEntry("nonnegative_integer",NULL ) -, SchemaEntry("null_style",NULL ) -, SchemaEntry("numeric_measure",NULL ) -, SchemaEntry("organization_item",NULL ) -, SchemaEntry("orientation_basis_select",NULL ) -, SchemaEntry("parameter_value",NULL ) -, SchemaEntry("pcurve_or_surface",NULL ) -, SchemaEntry("person_and_organization_item",NULL ) -, SchemaEntry("person_organization_select",NULL ) -, SchemaEntry("picture_representation_item_select",NULL ) -, SchemaEntry("plane_angle_measure",NULL ) -, SchemaEntry("plane_or_planar_box",NULL ) -, SchemaEntry("point_and_vector_member",NULL ) -, SchemaEntry("point_and_vector_members",NULL ) -, SchemaEntry("point_path_members",NULL ) -, SchemaEntry("positive_integer",NULL ) -, SchemaEntry("positive_length_measure",NULL ) -, SchemaEntry("positive_plane_angle_measure",NULL ) -, SchemaEntry("positive_ratio_measure",NULL ) -, SchemaEntry("power_measure",NULL ) -, SchemaEntry("preferred_surface_curve_representation",NULL ) -, SchemaEntry("presentable_text",NULL ) -, SchemaEntry("presentation_representation_select",NULL ) -, SchemaEntry("presentation_size_assignment_select",NULL ) -, SchemaEntry("presentation_style_select",NULL ) -//, SchemaEntry("presented_item_select",NULL ) -, SchemaEntry("pressure_measure",NULL ) -, SchemaEntry("product_definition_or_assembly_relationship",NULL ) -, SchemaEntry("product_definition_or_breakdown_element_usage",NULL ) -, SchemaEntry("product_definition_or_product_definition_relationship",NULL ) -, SchemaEntry("product_or_formation_or_definition",NULL ) -, SchemaEntry("project_item",NULL ) -, SchemaEntry("radioactivity_measure",NULL ) -, SchemaEntry("ratio_measure",NULL ) -, SchemaEntry("rendering_properties_select",NULL ) -, SchemaEntry("represented_definition",NULL ) -, SchemaEntry("requirement_assigned_item",NULL ) -, SchemaEntry("requirement_satisfaction_item",NULL ) -, SchemaEntry("requirement_source_item",NULL ) -, SchemaEntry("resistance_measure",NULL ) -, SchemaEntry("reversible_topology",NULL ) -, SchemaEntry("reversible_topology_item",NULL ) -, SchemaEntry("role_select",NULL ) -, SchemaEntry("rule_superseded_item",NULL ) -, SchemaEntry("second_in_minute",NULL ) -, SchemaEntry("security_classification_item",NULL ) -, SchemaEntry("set_of_reversible_topology_item",NULL ) -, SchemaEntry("set_representation_item",NULL ) -, SchemaEntry("shading_curve_method",NULL ) -, SchemaEntry("shading_surface_method",NULL ) -, SchemaEntry("shape_definition",NULL ) -, SchemaEntry("shell",NULL ) -, SchemaEntry("si_prefix",NULL ) -, SchemaEntry("si_unit_name",NULL ) -, SchemaEntry("size_select",NULL ) -, SchemaEntry("sketch_basis_select",NULL ) -, SchemaEntry("solid_angle_measure",NULL ) -, SchemaEntry("source",NULL ) -, SchemaEntry("source_item",NULL ) -, SchemaEntry("start_request_item",NULL ) -, SchemaEntry("string_representation_item_select",NULL ) -, SchemaEntry("style_context_select",NULL ) -, SchemaEntry("surface_side",NULL ) -, SchemaEntry("surface_side_style_select",NULL ) -, SchemaEntry("surface_style_element_select",NULL ) -, SchemaEntry("symbol_style_select",NULL ) -, SchemaEntry("text",NULL ) -, SchemaEntry("text_alignment",NULL ) -, SchemaEntry("text_delineation",NULL ) -, SchemaEntry("text_or_character",NULL ) -, SchemaEntry("text_path",NULL ) -, SchemaEntry("text_string_representation_item",NULL ) -, SchemaEntry("thermodynamic_temperature_measure",NULL ) -, SchemaEntry("time_interval_item",NULL ) -, SchemaEntry("time_measure",NULL ) -, SchemaEntry("tolerance_method_definition",NULL ) -, SchemaEntry("transformation",NULL ) -, SchemaEntry("transition_code",NULL ) -, SchemaEntry("trim_condition_select",NULL ) -, SchemaEntry("trim_intent",NULL ) -, SchemaEntry("trimming_preference",NULL ) -, SchemaEntry("trimming_select",NULL ) -, SchemaEntry("u_direction_count",NULL ) -, SchemaEntry("unit",NULL ) -, SchemaEntry("v_direction_count",NULL ) -, SchemaEntry("value_qualifier",NULL ) -, SchemaEntry("vector_or_direction",NULL ) -, SchemaEntry("velocity_measure",NULL ) -, SchemaEntry("volume_measure",NULL ) -, SchemaEntry("week_in_year_number",NULL ) -, SchemaEntry("work_item",NULL ) -, SchemaEntry("year_number",NULL ) -, SchemaEntry("measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("absorbed_dose_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("derived_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("absorbed_dose_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("abstract_variable",&STEP::ObjectHelper::Construct ) -, SchemaEntry("acceleration_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("acceleration_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_directive",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_method",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_method_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_method_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_method_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_property",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_property_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_request_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_request_solution",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_request_status",&STEP::ObjectHelper::Construct ) -, SchemaEntry("action_status",&STEP::ObjectHelper::Construct ) -, SchemaEntry("address",&STEP::ObjectHelper::Construct ) -, SchemaEntry("representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("advanced_brep_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("face_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("advanced_face",&STEP::ObjectHelper::Construct ) -, SchemaEntry("alternate_product_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("amount_of_substance_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("named_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("amount_of_substance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("angle_direction_reference",&STEP::ObjectHelper::Construct ) -, SchemaEntry("representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_curve_directed_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("angular_dimension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_aspect_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimensional_location",&STEP::ObjectHelper::Construct ) -, SchemaEntry("angular_location",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimensional_size",&STEP::ObjectHelper::Construct ) -, SchemaEntry("angular_size",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_tolerance_with_datum_reference",&STEP::ObjectHelper::Construct ) -, SchemaEntry("angularity_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("styled_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_curve_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_fill_area",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_fill_area_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_occurrence_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_occurrence_associativity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_plane",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_symbol_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_subfigure_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mapped_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_text",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_text_character",&STEP::ObjectHelper::Construct ) -, SchemaEntry("annotation_text_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_aspect",&STEP::ObjectHelper::Construct ) -, SchemaEntry("derived_shape_aspect",&STEP::ObjectHelper::Construct ) -, SchemaEntry("apex",&STEP::ObjectHelper::Construct ) -, SchemaEntry("application_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("application_context_element",&STEP::ObjectHelper::Construct ) -, SchemaEntry("application_protocol_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_action_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_action_method_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_action_request_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("approval_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_approval_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("attribute_classification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_attribute_classification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("certification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_certification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("classification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_classification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("contract_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_contract_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date_and_time_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_date_and_time_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_date_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_reference",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_document_reference",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_usage_constraint_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_document_usage_constraint_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("effectivity_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_effectivity_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("event_occurrence_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_event_occurrence_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("identification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("external_identification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_external_identification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("group_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_group_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_identification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("name_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_name_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organization_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_organization_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organizational_project_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_organizational_project_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("person_and_organization_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_person_and_organization_assignment",&STEP::ObjectHelper::Construct ) -//, SchemaEntry("presented_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_presented_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("security_classification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_security_classification_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_interval_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_time_interval_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("applied_usage_right",&STEP::ObjectHelper::Construct ) -, SchemaEntry("approval",&STEP::ObjectHelper::Construct ) -, SchemaEntry("approval_date_time",&STEP::ObjectHelper::Construct ) -, SchemaEntry("approval_person_organization",&STEP::ObjectHelper::Construct ) -, SchemaEntry("approval_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("approval_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("approval_status",&STEP::ObjectHelper::Construct ) -, SchemaEntry("area_in_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("area_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("area_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("assembly_component_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("assembly_component_usage_substitute",&STEP::ObjectHelper::Construct ) -, SchemaEntry("assigned_requirement",&STEP::ObjectHelper::Construct ) -, SchemaEntry("compound_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("atomic_formula",&STEP::ObjectHelper::Construct ) -, SchemaEntry("attribute_assertion",&STEP::ObjectHelper::Construct ) -, SchemaEntry("attribute_language_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("attribute_value_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("attribute_value_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("auxiliary_geometric_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("placement",&STEP::ObjectHelper::Construct ) -, SchemaEntry("axis1_placement",&STEP::ObjectHelper::Construct ) -, SchemaEntry("axis2_placement_2d",&STEP::ObjectHelper::Construct ) -, SchemaEntry("axis2_placement_3d",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("bounded_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("b_spline_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("b_spline_curve_with_knots",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("bounded_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("b_spline_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("b_spline_surface_with_knots",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_software_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("back_chaining_rule",&STEP::ObjectHelper::Construct ) -, SchemaEntry("back_chaining_rule_body",&STEP::ObjectHelper::Construct ) -, SchemaEntry("colour",&STEP::ObjectHelper::Construct ) -, SchemaEntry("background_colour",&STEP::ObjectHelper::Construct ) -, SchemaEntry("beveled_sheet_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("bezier_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("bezier_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("generic_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("binary_generic_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("binary_numeric_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("binary_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("block",&STEP::ObjectHelper::Construct ) -, SchemaEntry("expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("boolean_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("boolean_literal",&STEP::ObjectHelper::Construct ) -, SchemaEntry("boolean_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("boolean_result",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_curve_on_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("boundary_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("bounded_pcurve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("bounded_surface_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("founded_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("box_domain",&STEP::ObjectHelper::Construct ) -, SchemaEntry("half_space_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("boxed_half_space",&STEP::ObjectHelper::Construct ) -, SchemaEntry("breakdown_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("breakdown_element_group_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("breakdown_element_realization",&STEP::ObjectHelper::Construct ) -, SchemaEntry("breakdown_element_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("breakdown_of",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_model",&STEP::ObjectHelper::Construct ) -, SchemaEntry("manifold_solid_brep",&STEP::ObjectHelper::Construct ) -, SchemaEntry("brep_with_voids",&STEP::ObjectHelper::Construct ) -, SchemaEntry("bytes_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date",&STEP::ObjectHelper::Construct ) -, SchemaEntry("calendar_date",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_image",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_image_3d_with_scale",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_model",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_model_d3",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_model_d3_multi_clipping",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_model_d3_multi_clipping_intersection",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_model_d3_multi_clipping_union",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_model_d3_with_hlhsr",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_model_with_light_sources",&STEP::ObjectHelper::Construct ) -, SchemaEntry("representation_map",&STEP::ObjectHelper::Construct ) -, SchemaEntry("camera_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("capacitance_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("capacitance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("point",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cartesian_point",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cartesian_transformation_operator",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cartesian_transformation_operator_2d",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cartesian_transformation_operator_3d",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cc_design_approval",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cc_design_certification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cc_design_contract",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cc_design_date_and_time_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cc_design_person_and_organization_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cc_design_security_classification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cc_design_specification_reference",&STEP::ObjectHelper::Construct ) -, SchemaEntry("celsius_temperature_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("centre_of_symmetry",&STEP::ObjectHelper::Construct ) -, SchemaEntry("certification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("certification_type",&STEP::ObjectHelper::Construct ) -, SchemaEntry("change",&STEP::ObjectHelper::Construct ) -, SchemaEntry("change_request",&STEP::ObjectHelper::Construct ) -, SchemaEntry("character_glyph_font_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("character_glyph_style_outline",&STEP::ObjectHelper::Construct ) -, SchemaEntry("character_glyph_style_stroke",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symbol_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("generic_character_glyph_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("character_glyph_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("character_glyph_symbol_outline",&STEP::ObjectHelper::Construct ) -, SchemaEntry("character_glyph_symbol_stroke",&STEP::ObjectHelper::Construct ) -, SchemaEntry("general_property",&STEP::ObjectHelper::Construct ) -, SchemaEntry("characteristic_data_column_header",&STEP::ObjectHelper::Construct ) -, SchemaEntry("general_property_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("characteristic_data_column_header_link",&STEP::ObjectHelper::Construct ) -, SchemaEntry("characteristic_data_table_header",&STEP::ObjectHelper::Construct ) -, SchemaEntry("characteristic_data_table_header_decomposition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("group",&STEP::ObjectHelper::Construct ) -, SchemaEntry("characteristic_type",&STEP::ObjectHelper::Construct ) -, SchemaEntry("characterized_class",&STEP::ObjectHelper::Construct ) -, SchemaEntry("characterized_object",&STEP::ObjectHelper::Construct ) -, SchemaEntry("conic",&STEP::ObjectHelper::Construct ) -, SchemaEntry("circle",&STEP::ObjectHelper::Construct ) -, SchemaEntry("circular_runout_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("class_t",&STEP::ObjectHelper::Construct ) -, SchemaEntry("class_by_extension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("class_by_intension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("class_system",&STEP::ObjectHelper::Construct ) -, SchemaEntry("effectivity_context_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("class_usage_effectivity_context_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("classification_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("topological_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("connected_face_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("closed_shell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("coaxiality_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("colour_specification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("colour_rgb",&STEP::ObjectHelper::Construct ) -, SchemaEntry("common_datum",&STEP::ObjectHelper::Construct ) -, SchemaEntry("comparison_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("complex_clause",&STEP::ObjectHelper::Construct ) -, SchemaEntry("complex_conjunctive_clause",&STEP::ObjectHelper::Construct ) -, SchemaEntry("complex_disjunctive_clause",&STEP::ObjectHelper::Construct ) -, SchemaEntry("modified_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shelled_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("complex_shelled_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_assembly_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_assembly_sequence_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("laminate_table",&STEP::ObjectHelper::Construct ) -, SchemaEntry("part_laminate_table",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_assembly_table",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_curve_segment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("material_designation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_material_designation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_shape_aspect",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_sheet_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_text",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_text_with_associated_curves",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_text_with_blanking_box",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_text_with_delineation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("composite_text_with_extent",&STEP::ObjectHelper::Construct ) -, SchemaEntry("compound_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("concentricity_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("concept_feature_operator",&STEP::ObjectHelper::Construct ) -, SchemaEntry("concept_feature_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("concept_feature_relationship_with_condition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_concept_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("conditional_concept_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("conductance_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("conductance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configuration_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configurable_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configuration_design",&STEP::ObjectHelper::Construct ) -, SchemaEntry("effectivity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_effectivity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configuration_effectivity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configuration_item_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configuration_item_hierarchical_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configuration_item_revision_sequence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configured_effectivity_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("configured_effectivity_context_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("conical_stepped_hole_transition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("elementary_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("conical_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("connected_edge_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("connected_face_sub_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("constructive_geometry_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("representation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("constructive_geometry_representation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("contact_ratio_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("invisibility",&STEP::ObjectHelper::Construct ) -, SchemaEntry("context_dependent_invisibility",&STEP::ObjectHelper::Construct ) -, SchemaEntry("over_riding_styled_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("context_dependent_over_riding_styled_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("context_dependent_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("context_dependent_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("contract",&STEP::ObjectHelper::Construct ) -, SchemaEntry("contract_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("contract_type",&STEP::ObjectHelper::Construct ) -, SchemaEntry("conversion_based_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("coordinated_universal_time_offset",&STEP::ObjectHelper::Construct ) -, SchemaEntry("csg_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("csg_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("currency",&STEP::ObjectHelper::Construct ) -, SchemaEntry("currency_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_bounded_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_dimension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_replica",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_style_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_style_font_and_scaling",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_style_font_pattern",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_style_rendering",&STEP::ObjectHelper::Construct ) -, SchemaEntry("curve_swept_solid_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cylindrical_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("cylindricity_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("data_environment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date_and_time",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date_time_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("date_time_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dated_effectivity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("datum",&STEP::ObjectHelper::Construct ) -, SchemaEntry("datum_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("datum_feature_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("datum_reference",&STEP::ObjectHelper::Construct ) -, SchemaEntry("datum_target",&STEP::ObjectHelper::Construct ) -, SchemaEntry("datum_target_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("default_tolerance_table",&STEP::ObjectHelper::Construct ) -, SchemaEntry("default_tolerance_table_cell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("defined_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("definitional_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("definitional_representation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("definitional_representation_relationship_with_same_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("degenerate_pcurve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("toroidal_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("degenerate_toroidal_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("derived_unit_element",&STEP::ObjectHelper::Construct ) -, SchemaEntry("description_attribute",&STEP::ObjectHelper::Construct ) -, SchemaEntry("descriptive_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("design_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("design_make_from_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("diameter_dimension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ratio_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dielectric_constant_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_callout_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_callout_component_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_callout_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("terminator_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_curve_terminator",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_curve_terminator_to_projection_curve_associativity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_pair",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_related_tolerance_zone_element",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimension_text_associativity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimensional_characteristic_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimensional_exponents",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimensional_location_with_path",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dimensional_size_with_path",&STEP::ObjectHelper::Construct ) -, SchemaEntry("executed_action",&STEP::ObjectHelper::Construct ) -, SchemaEntry("directed_action",&STEP::ObjectHelper::Construct ) -, SchemaEntry("directed_dimensional_location",&STEP::ObjectHelper::Construct ) -, SchemaEntry("direction",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_file",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_identifier",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_identifier_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_product_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_product_equivalence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_representation_type",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_type",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_usage_constraint",&STEP::ObjectHelper::Construct ) -, SchemaEntry("document_usage_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dose_equivalent_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("dose_equivalent_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("double_offset_shelled_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("item_defined_transformation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("transformation_with_derived_angle",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draped_defined_transformation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_annotation_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_elements",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_model",&STEP::ObjectHelper::Construct ) -, SchemaEntry("item_identified_representation_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_model_item_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_colour",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_pre_defined_colour",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_curve_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_pre_defined_curve_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_text_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_pre_defined_text_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_subfigure_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_symbol_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_literal",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_literal_with_delineation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_text_literal_with_delineation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("draughting_title",&STEP::ObjectHelper::Construct ) -, SchemaEntry("drawing_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("drawing_revision",&STEP::ObjectHelper::Construct ) -, SchemaEntry("drawing_revision_sequence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_area",&STEP::ObjectHelper::Construct ) -, SchemaEntry("drawing_sheet_revision",&STEP::ObjectHelper::Construct ) -, SchemaEntry("drawing_sheet_revision_sequence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("drawing_sheet_revision_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("edge",&STEP::ObjectHelper::Construct ) -, SchemaEntry("edge_based_wireframe_model",&STEP::ObjectHelper::Construct ) -, SchemaEntry("edge_based_wireframe_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("edge_blended_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("edge_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("edge_loop",&STEP::ObjectHelper::Construct ) -, SchemaEntry("effectivity_context_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("effectivity_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("electric_charge_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("electric_charge_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("electric_current_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("electric_current_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("electric_potential_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("electric_potential_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("elementary_brep_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ellipse",&STEP::ObjectHelper::Construct ) -, SchemaEntry("energy_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("energy_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("property_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fact_type",&STEP::ObjectHelper::Construct ) -, SchemaEntry("entity_assertion",&STEP::ObjectHelper::Construct ) -, SchemaEntry("enum_reference_prefix",&STEP::ObjectHelper::Construct ) -, SchemaEntry("environment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("evaluated_characteristic",&STEP::ObjectHelper::Construct ) -, SchemaEntry("evaluated_degenerate_pcurve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("evaluation_product_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("event_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("event_occurrence_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("event_occurrence_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_concept_feature_category",&STEP::ObjectHelper::Construct ) -, SchemaEntry("exclusive_product_concept_feature_category",&STEP::ObjectHelper::Construct ) -, SchemaEntry("uncertainty_qualifier",&STEP::ObjectHelper::Construct ) -, SchemaEntry("standard_uncertainty",&STEP::ObjectHelper::Construct ) -, SchemaEntry("expanded_uncertainty",&STEP::ObjectHelper::Construct ) -, SchemaEntry("representation_item_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("explicit_procedural_representation_item_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("explicit_procedural_geometric_representation_item_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("explicit_procedural_representation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("explicit_procedural_shape_representation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("expression_conversion_based_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("extension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("extent",&STEP::ObjectHelper::Construct ) -, SchemaEntry("external_source",&STEP::ObjectHelper::Construct ) -, SchemaEntry("external_class_library",&STEP::ObjectHelper::Construct ) -, SchemaEntry("external_source_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_class",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_colour",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_context_dependent_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_conversion_based_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_currency",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_curve_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_dimension_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_general_property",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_hatch_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_item_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_marker",&STEP::ObjectHelper::Construct ) -, SchemaEntry("picture_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_picture_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_string",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_terminator_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_text_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_tile",&STEP::ObjectHelper::Construct ) -, SchemaEntry("externally_defined_tile_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("swept_area_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("extruded_area_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("swept_face_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("extruded_face_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("extruded_face_solid_with_trim_conditions",&STEP::ObjectHelper::Construct ) -, SchemaEntry("extruded_face_solid_with_draft_angle",&STEP::ObjectHelper::Construct ) -, SchemaEntry("extruded_face_solid_with_multiple_draft_angles",&STEP::ObjectHelper::Construct ) -, SchemaEntry("face",&STEP::ObjectHelper::Construct ) -, SchemaEntry("face_based_surface_model",&STEP::ObjectHelper::Construct ) -, SchemaEntry("face_bound",&STEP::ObjectHelper::Construct ) -, SchemaEntry("face_outer_bound",&STEP::ObjectHelper::Construct ) -, SchemaEntry("faceted_brep",&STEP::ObjectHelper::Construct ) -, SchemaEntry("faceted_brep_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fill_area_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fill_area_style_colour",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fill_area_style_hatching",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fill_area_style_tile_coloured_region",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fill_area_style_tile_curve_with_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fill_area_style_tile_symbol_with_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("fill_area_style_tiles",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_representation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("flat_pattern_ply_representation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("flatness_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("force_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("force_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("forward_chaining_rule",&STEP::ObjectHelper::Construct ) -, SchemaEntry("forward_chaining_rule_premise",&STEP::ObjectHelper::Construct ) -, SchemaEntry("frequency_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("frequency_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("func",&STEP::ObjectHelper::Construct ) -, SchemaEntry("functional_breakdown_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("functional_element_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("functionally_defined_transformation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("general_material_property",&STEP::ObjectHelper::Construct ) -, SchemaEntry("general_property_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("simple_generic_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("generic_literal",&STEP::ObjectHelper::Construct ) -, SchemaEntry("generic_variable",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_alignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_curve_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_intersection",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_item_specific_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_model_element_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("representation_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_representation_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_tolerance_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometric_tolerance_with_defined_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometrical_tolerance_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometrically_bounded_2d_wireframe_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometrically_bounded_surface_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("geometrically_bounded_wireframe_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("global_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("global_uncertainty_assigned_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("global_unit_assigned_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ground_fact",&STEP::ObjectHelper::Construct ) -, SchemaEntry("group_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("hardness_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("hidden_element_over_riding_styled_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("hyperbola",&STEP::ObjectHelper::Construct ) -, SchemaEntry("id_attribute",&STEP::ObjectHelper::Construct ) -, SchemaEntry("identification_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("illuminance_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("illuminance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("included_text_block",&STEP::ObjectHelper::Construct ) -, SchemaEntry("inclusion_product_concept_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("user_selected_elements",&STEP::ObjectHelper::Construct ) -, SchemaEntry("indirectly_selected_elements",&STEP::ObjectHelper::Construct ) -, SchemaEntry("indirectly_selected_shape_elements",&STEP::ObjectHelper::Construct ) -, SchemaEntry("inductance_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("inductance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("information_right",&STEP::ObjectHelper::Construct ) -, SchemaEntry("information_usage_right",&STEP::ObjectHelper::Construct ) -, SchemaEntry("instance_usage_context_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("instanced_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("literal_number",&STEP::ObjectHelper::Construct ) -, SchemaEntry("int_literal",&STEP::ObjectHelper::Construct ) -, SchemaEntry("integer_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("intersection_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("interval_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("iso4217_currency",&STEP::ObjectHelper::Construct ) -, SchemaEntry("known_source",&STEP::ObjectHelper::Construct ) -, SchemaEntry("laid_defined_transformation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("language",&STEP::ObjectHelper::Construct ) -, SchemaEntry("leader_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("leader_directed_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("leader_directed_dimension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("leader_terminator",&STEP::ObjectHelper::Construct ) -, SchemaEntry("length_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("length_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("light_source",&STEP::ObjectHelper::Construct ) -, SchemaEntry("light_source_ambient",&STEP::ObjectHelper::Construct ) -, SchemaEntry("light_source_directional",&STEP::ObjectHelper::Construct ) -, SchemaEntry("light_source_positional",&STEP::ObjectHelper::Construct ) -, SchemaEntry("light_source_spot",&STEP::ObjectHelper::Construct ) -, SchemaEntry("limits_and_fits",&STEP::ObjectHelper::Construct ) -, SchemaEntry("line",&STEP::ObjectHelper::Construct ) -, SchemaEntry("line_profile_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("linear_dimension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("simple_clause",&STEP::ObjectHelper::Construct ) -, SchemaEntry("literal_conjunction",&STEP::ObjectHelper::Construct ) -, SchemaEntry("literal_disjunction",&STEP::ObjectHelper::Construct ) -, SchemaEntry("local_time",&STEP::ObjectHelper::Construct ) -, SchemaEntry("logical_literal",&STEP::ObjectHelper::Construct ) -, SchemaEntry("logical_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("loop",&STEP::ObjectHelper::Construct ) -, SchemaEntry("loss_tangent_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("lot_effectivity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("luminous_flux_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("luminous_flux_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("luminous_intensity_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("luminous_intensity_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("magnetic_flux_density_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("magnetic_flux_density_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("magnetic_flux_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("magnetic_flux_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("make_from_usage_option",&STEP::ObjectHelper::Construct ) -, SchemaEntry("manifold_subsurface_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("manifold_surface_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mass_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mass_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("material_designation_characterization",&STEP::ObjectHelper::Construct ) -, SchemaEntry("material_property",&STEP::ObjectHelper::Construct ) -, SchemaEntry("property_definition_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("material_property_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("measure_qualification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("measure_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mechanical_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mechanical_design_and_draughting_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mechanical_design_geometric_presentation_area",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mechanical_design_geometric_presentation_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mechanical_design_presentation_representation_with_draughting",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mechanical_design_shaded_presentation_area",&STEP::ObjectHelper::Construct ) -, SchemaEntry("mechanical_design_shaded_presentation_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("min_and_major_ply_orientation_basis",&STEP::ObjectHelper::Construct ) -, SchemaEntry("modified_geometric_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("modified_solid_with_placed_configuration",&STEP::ObjectHelper::Construct ) -, SchemaEntry("moments_of_inertia_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("multi_language_attribute_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("multiple_arity_boolean_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("multiple_arity_generic_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("multiple_arity_numeric_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("name_attribute",&STEP::ObjectHelper::Construct ) -, SchemaEntry("next_assembly_usage_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("non_manifold_surface_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("null_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("numeric_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("object_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("offset_curve_2d",&STEP::ObjectHelper::Construct ) -, SchemaEntry("offset_curve_3d",&STEP::ObjectHelper::Construct ) -, SchemaEntry("offset_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("one_direction_repeat_factor",&STEP::ObjectHelper::Construct ) -, SchemaEntry("open_shell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ordinal_date",&STEP::ObjectHelper::Construct ) -, SchemaEntry("projection_directed_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ordinate_dimension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organization",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organization_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organization_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organizational_address",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organizational_project",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organizational_project_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("organizational_project_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("oriented_closed_shell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("oriented_edge",&STEP::ObjectHelper::Construct ) -, SchemaEntry("oriented_face",&STEP::ObjectHelper::Construct ) -, SchemaEntry("oriented_open_shell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("path",&STEP::ObjectHelper::Construct ) -, SchemaEntry("oriented_path",&STEP::ObjectHelper::Construct ) -, SchemaEntry("oriented_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("outer_boundary_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("package_product_concept_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("parabola",&STEP::ObjectHelper::Construct ) -, SchemaEntry("parallel_offset",&STEP::ObjectHelper::Construct ) -, SchemaEntry("parallelism_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("parametric_representation_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("partial_document_with_structured_text_representation_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pcurve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("percentage_laminate_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("zone_structural_makeup",&STEP::ObjectHelper::Construct ) -, SchemaEntry("percentage_laminate_table",&STEP::ObjectHelper::Construct ) -, SchemaEntry("percentage_ply_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("perpendicular_to",&STEP::ObjectHelper::Construct ) -, SchemaEntry("perpendicularity_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("person",&STEP::ObjectHelper::Construct ) -, SchemaEntry("person_and_organization",&STEP::ObjectHelper::Construct ) -, SchemaEntry("person_and_organization_address",&STEP::ObjectHelper::Construct ) -, SchemaEntry("person_and_organization_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("personal_address",&STEP::ObjectHelper::Construct ) -, SchemaEntry("physical_breakdown_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("physical_element_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_view",&STEP::ObjectHelper::Construct ) -, SchemaEntry("picture_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("placed_datum_target_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("placed_feature",&STEP::ObjectHelper::Construct ) -, SchemaEntry("planar_extent",&STEP::ObjectHelper::Construct ) -, SchemaEntry("planar_box",&STEP::ObjectHelper::Construct ) -, SchemaEntry("plane",&STEP::ObjectHelper::Construct ) -, SchemaEntry("plane_angle_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("plane_angle_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("plus_minus_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ply_laminate_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ply_laminate_sequence_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ply_laminate_table",&STEP::ObjectHelper::Construct ) -, SchemaEntry("point_and_vector",&STEP::ObjectHelper::Construct ) -, SchemaEntry("point_on_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("point_on_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("point_path",&STEP::ObjectHelper::Construct ) -, SchemaEntry("point_replica",&STEP::ObjectHelper::Construct ) -, SchemaEntry("point_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("polar_complex_number_literal",&STEP::ObjectHelper::Construct ) -, SchemaEntry("poly_loop",&STEP::ObjectHelper::Construct ) -, SchemaEntry("polyline",&STEP::ObjectHelper::Construct ) -, SchemaEntry("position_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("positioned_sketch",&STEP::ObjectHelper::Construct ) -, SchemaEntry("power_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("power_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_dimension_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_geometrical_tolerance_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_marker",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_point_marker_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_surface_condition_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_surface_side_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_terminator_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pre_defined_tile",&STEP::ObjectHelper::Construct ) -, SchemaEntry("precision_qualifier",&STEP::ObjectHelper::Construct ) -, SchemaEntry("predefined_picture_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_layer_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_size",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_style_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("presentation_style_by_context",&STEP::ObjectHelper::Construct ) -//, SchemaEntry("presented_item_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pressure_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("pressure_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("procedural_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("procedural_representation_sequence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("procedural_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("procedural_shape_representation_sequence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_category",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_class",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_concept",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_concept_context",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_concept_feature_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_concept_feature_category_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_concept_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_context_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_context_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_element_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_formation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_formation_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_formation_with_specified_source",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_group_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_occurrence_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_shape",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_substitute",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_definition_with_associated_documents",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_identification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_material_composition_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_related_product_category",&STEP::ObjectHelper::Construct ) -, SchemaEntry("product_specification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tolerance_zone_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("projected_zone_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("projection_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("promissory_usage_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("property_definition_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("qualified_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("qualitative_uncertainty",&STEP::ObjectHelper::Construct ) -, SchemaEntry("quantified_assembly_component_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("quasi_uniform_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("quasi_uniform_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("radioactivity_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("radioactivity_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("radius_dimension",&STEP::ObjectHelper::Construct ) -, SchemaEntry("range_characteristic",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ratio_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rational_b_spline_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rational_b_spline_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rational_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("real_literal",&STEP::ObjectHelper::Construct ) -, SchemaEntry("real_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rectangular_composite_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rectangular_trimmed_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("referenced_modified_datum",&STEP::ObjectHelper::Construct ) -, SchemaEntry("relative_event_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rep_item_group",&STEP::ObjectHelper::Construct ) -, SchemaEntry("reparametrised_composite_curve_segment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("representation_relationship_with_transformation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("requirement_assigned_object",&STEP::ObjectHelper::Construct ) -, SchemaEntry("requirement_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("requirement_source",&STEP::ObjectHelper::Construct ) -, SchemaEntry("requirement_view_definition_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("resistance_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("resistance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("revolved_area_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("revolved_face_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("revolved_face_solid_with_trim_conditions",&STEP::ObjectHelper::Construct ) -, SchemaEntry("right_angular_wedge",&STEP::ObjectHelper::Construct ) -, SchemaEntry("right_circular_cone",&STEP::ObjectHelper::Construct ) -, SchemaEntry("right_circular_cylinder",&STEP::ObjectHelper::Construct ) -, SchemaEntry("right_to_usage_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("role_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("roundness_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("row_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("row_value",&STEP::ObjectHelper::Construct ) -, SchemaEntry("row_variable",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_action",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_condition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_set",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_set_group",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_superseded_assignment",&STEP::ObjectHelper::Construct ) -, SchemaEntry("rule_supersedence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_curve_swept_area_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ruled_surface_swept_area_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("runout_zone_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("runout_zone_orientation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("runout_zone_orientation_reference_direction",&STEP::ObjectHelper::Construct ) -, SchemaEntry("satisfied_requirement",&STEP::ObjectHelper::Construct ) -, SchemaEntry("satisfies_requirement",&STEP::ObjectHelper::Construct ) -, SchemaEntry("satisfying_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("scalar_variable",&STEP::ObjectHelper::Construct ) -, SchemaEntry("scattering_parameter",&STEP::ObjectHelper::Construct ) -, SchemaEntry("sculptured_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("seam_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("security_classification",&STEP::ObjectHelper::Construct ) -, SchemaEntry("security_classification_level",&STEP::ObjectHelper::Construct ) -, SchemaEntry("serial_numbered_effectivity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_aspect_associativity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_aspect_deriving_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_definition_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_dimension_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_feature_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shape_representation_with_parameters",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shell_based_surface_model",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shell_based_wireframe_model",&STEP::ObjectHelper::Construct ) -, SchemaEntry("shell_based_wireframe_shape_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_absorbed_dose_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_capacitance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_conductance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_dose_equivalent_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_electric_charge_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_electric_potential_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_energy_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_force_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_frequency_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_illuminance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_inductance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_magnetic_flux_density_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_magnetic_flux_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_power_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_pressure_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_radioactivity_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_resistance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("si_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("simple_boolean_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("simple_numeric_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("slash_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("smeared_material_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_angle_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_angle_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_curve_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_replica",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_chamfered_edges",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_angle_based_chamfer",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_shape_element_pattern",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_circular_pattern",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_depression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_pocket",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_circular_pocket",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_protrusion",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_circular_protrusion",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_hole",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_stepped_round_hole",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_conical_bottom_round_hole",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_constant_radius_edge_blend",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_slot",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_curved_slot",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_double_offset_chamfer",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_flat_bottom_round_hole",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_general_pocket",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_general_protrusion",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_groove",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_incomplete_circular_pattern",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_rectangular_pattern",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_incomplete_rectangular_pattern",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_rectangular_pocket",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_rectangular_protrusion",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_single_offset_chamfer",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_spherical_bottom_round_hole",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_stepped_round_hole_and_conical_transitions",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_straight_slot",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_tee_section_slot",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_through_depression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_trapezoidal_section_slot",&STEP::ObjectHelper::Construct ) -, SchemaEntry("solid_with_variable_radius_edge_blend",&STEP::ObjectHelper::Construct ) -, SchemaEntry("source_for_requirement",&STEP::ObjectHelper::Construct ) -, SchemaEntry("sourced_requirement",&STEP::ObjectHelper::Construct ) -, SchemaEntry("specification_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("specified_higher_usage_occurrence",&STEP::ObjectHelper::Construct ) -, SchemaEntry("sphere",&STEP::ObjectHelper::Construct ) -, SchemaEntry("spherical_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("start_request",&STEP::ObjectHelper::Construct ) -, SchemaEntry("start_work",&STEP::ObjectHelper::Construct ) -, SchemaEntry("straightness_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("structured_dimension_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("structured_text_composition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("structured_text_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("subedge",&STEP::ObjectHelper::Construct ) -, SchemaEntry("subface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("supplied_part_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_condition_callout",&STEP::ObjectHelper::Construct ) -, SchemaEntry("swept_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_of_linear_extrusion",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_of_revolution",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_patch",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_profile_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_rendering_properties",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_replica",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_side_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_boundary",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_control_grid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_fill_area",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_parameter_line",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_reflectance_ambient",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_reflectance_ambient_diffuse",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_reflectance_ambient_diffuse_specular",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_rendering",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_rendering_with_properties",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_segmentation_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_silhouette",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_transparent",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_style_usage",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surface_texture_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("surfaced_open_shell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("swept_disk_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symbol_colour",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symbol_representation_map",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symbol_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symbol_target",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symmetric_shape_aspect",&STEP::ObjectHelper::Construct ) -, SchemaEntry("symmetry_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("table_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tactile_appearance_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tagged_text_format",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tagged_text_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tangent",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_font_family",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_font_in_family",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_literal_with_associated_curves",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_literal_with_blanking_box",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_literal_with_extent",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_string_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_style_for_defined_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_style_with_box_characteristics",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_style_with_mirror",&STEP::ObjectHelper::Construct ) -, SchemaEntry("text_style_with_spacing",&STEP::ObjectHelper::Construct ) -, SchemaEntry("thermal_resistance_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("thermal_resistance_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("thermodynamic_temperature_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("thermodynamic_temperature_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("thickened_face_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("thickness_laminate_definition",&STEP::ObjectHelper::Construct ) -, SchemaEntry("thickness_laminate_table",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_interval",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_interval_based_effectivity",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_interval_relationship",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_interval_role",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_interval_with_bounds",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("time_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tolerance_value",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tolerance_zone",&STEP::ObjectHelper::Construct ) -, SchemaEntry("tolerance_zone_form",&STEP::ObjectHelper::Construct ) -, SchemaEntry("torus",&STEP::ObjectHelper::Construct ) -, SchemaEntry("total_runout_tolerance",&STEP::ObjectHelper::Construct ) -, SchemaEntry("track_blended_solid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("track_blended_solid_with_end_conditions",&STEP::ObjectHelper::Construct ) -, SchemaEntry("trimmed_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("two_direction_repeat_factor",&STEP::ObjectHelper::Construct ) -, SchemaEntry("type_qualifier",&STEP::ObjectHelper::Construct ) -, SchemaEntry("unary_generic_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("unary_numeric_expression",&STEP::ObjectHelper::Construct ) -, SchemaEntry("uncertainty_assigned_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("uncertainty_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("uniform_curve",&STEP::ObjectHelper::Construct ) -, SchemaEntry("uniform_resource_identifier",&STEP::ObjectHelper::Construct ) -, SchemaEntry("uniform_surface",&STEP::ObjectHelper::Construct ) -, SchemaEntry("usage_association",&STEP::ObjectHelper::Construct ) -, SchemaEntry("user_defined_curve_font",&STEP::ObjectHelper::Construct ) -, SchemaEntry("user_defined_marker",&STEP::ObjectHelper::Construct ) -, SchemaEntry("user_defined_terminator_symbol",&STEP::ObjectHelper::Construct ) -, SchemaEntry("user_selected_shape_elements",&STEP::ObjectHelper::Construct ) -, SchemaEntry("value_range",&STEP::ObjectHelper::Construct ) -, SchemaEntry("value_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("variable_semantics",&STEP::ObjectHelper::Construct ) -, SchemaEntry("variational_representation_item",&STEP::ObjectHelper::Construct ) -, SchemaEntry("vector",&STEP::ObjectHelper::Construct ) -, SchemaEntry("vector_style",&STEP::ObjectHelper::Construct ) -, SchemaEntry("velocity_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("velocity_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("versioned_action_request",&STEP::ObjectHelper::Construct ) -, SchemaEntry("vertex",&STEP::ObjectHelper::Construct ) -, SchemaEntry("vertex_loop",&STEP::ObjectHelper::Construct ) -, SchemaEntry("vertex_point",&STEP::ObjectHelper::Construct ) -, SchemaEntry("vertex_shell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("view_volume",&STEP::ObjectHelper::Construct ) -, SchemaEntry("visual_appearance_representation",&STEP::ObjectHelper::Construct ) -, SchemaEntry("volume_measure_with_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("volume_unit",&STEP::ObjectHelper::Construct ) -, SchemaEntry("week_of_year_and_day_date",&STEP::ObjectHelper::Construct ) -, SchemaEntry("wire_shell",&STEP::ObjectHelper::Construct ) -, SchemaEntry("year_month",&STEP::ObjectHelper::Construct ) - - }; -} - -// ----------------------------------------------------------------------------------------------------------- -void StepFile::GetSchema(EXPRESS::ConversionSchema& out) -{ - out = EXPRESS::ConversionSchema(schema_raw); -} - -namespace STEP { - - // ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const STEP::DB& db, const LIST& params, NotImplemented* in) -{ - return 0; -} -*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, measure_with_unit* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to measure_with_unit"); } do { // convert the 'value_component' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->value_component, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to measure_with_unit to be a `measure_value`")); } - } while(0); - do { // convert the 'unit_component' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->unit_component, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to measure_with_unit to be a `unit`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, absorbed_dose_measure_with_unit* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to absorbed_dose_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, derived_unit* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to derived_unit"); } do { // convert the 'elements' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->elements, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to derived_unit to be a `SET [1:?] OF derived_unit_element`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, absorbed_dose_unit* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to absorbed_dose_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB&, const LIST&, abstract_variable*) { - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, acceleration_measure_with_unit* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to acceleration_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, acceleration_unit* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to acceleration_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, action* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to action"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to action to be a `label`")); } - } while(0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->description, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to action to be a `text`")); } - } while(0); - do { // convert the 'chosen_method' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - try { GenericConvert( in->chosen_method, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to action to be a `action_method`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, action_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to action_assignment"); } do { // convert the 'assigned_action' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->assigned_action, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to action_assignment to be a `action`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, action_method* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to action_method"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to action_method to be a `label`")); } - } while(0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->description, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to action_method to be a `text`")); } - } while(0); - do { // convert the 'consequence' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - try { GenericConvert( in->consequence, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to action_method to be a `text`")); } - } while(0); - do { // convert the 'purpose' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3]=true; break; } - try { GenericConvert( in->purpose, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to action_method to be a `text`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, action_method_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to action_method_assignment"); } do { // convert the 'assigned_action_method' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->assigned_action_method, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to action_method_assignment to be a `action_method`")); } - } while(0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->role, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to action_method_assignment to be a `action_method_role`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, action_method_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to action_method_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to action_method_relationship to be a `label`")); } - } while(0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->description, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to action_method_relationship to be a `text`")); } - } while(0); - do { // convert the 'relating_method' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - try { GenericConvert( in->relating_method, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to action_method_relationship to be a `action_method`")); } - } while(0); - do { // convert the 'related_method' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3]=true; break; } - try { GenericConvert( in->related_method, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to action_method_relationship to be a `action_method`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, action_request_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to action_request_assignment"); } do { // convert the 'assigned_action_request' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->assigned_action_request, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to action_request_assignment to be a `versioned_action_request`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill

(const DB& db, const LIST& params, address* in) -{ - size_t base = 0; - if (params.GetSize() < 12) { throw STEP::TypeError("expected 12 arguments to address"); } do { // convert the 'internal_location' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->internal_location, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to address to be a `label`")); } - } while(0); - do { // convert the 'street_number' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->street_number, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to address to be a `label`")); } - } while(0); - do { // convert the 'street' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->street, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to address to be a `label`")); } - } while(0); - do { // convert the 'postal_box' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->postal_box, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to address to be a `label`")); } - } while(0); - do { // convert the 'town' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->town, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to address to be a `label`")); } - } while(0); - do { // convert the 'region' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[5]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->region, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to address to be a `label`")); } - } while(0); - do { // convert the 'postal_code' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[6]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->postal_code, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to address to be a `label`")); } - } while(0); - do { // convert the 'country' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[7]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->country, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to address to be a `label`")); } - } while(0); - do { // convert the 'facsimile_number' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[8]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->facsimile_number, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to address to be a `label`")); } - } while(0); - do { // convert the 'telephone_number' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[9]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->telephone_number, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to address to be a `label`")); } - } while(0); - do { // convert the 'electronic_mail_address' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[10]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->electronic_mail_address, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 10 to address to be a `label`")); } - } while(0); - do { // convert the 'telex_number' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[11]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->telex_number, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 11 to address to be a `label`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, representation* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to representation"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to representation to be a `label`")); } - } while(0); - do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->items, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to representation to be a `SET [1:?] OF representation_item`")); } - } while(0); - do { // convert the 'context_of_items' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - try { GenericConvert( in->context_of_items, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to representation to be a `representation_context`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_representation* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, advanced_brep_shape_representation* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to advanced_brep_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, face_surface* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to face_surface"); } do { // convert the 'face_geometry' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->face_geometry, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to face_surface to be a `surface`")); } - } while(0); - do { // convert the 'same_sense' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->same_sense, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to face_surface to be a `BOOLEAN`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, advanced_face* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to advanced_face"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, amount_of_substance_measure_with_unit* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to amount_of_substance_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, named_unit* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to named_unit"); } do { // convert the 'dimensions' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->dimensions, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to named_unit to be a `dimensional_exponents`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, amount_of_substance_unit* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to amount_of_substance_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB&, const LIST&, angle_direction_reference*) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, representation_item* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to representation_item"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to representation_item to be a `label`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_representation_item* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to geometric_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_callout* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to draughting_callout"); } do { // convert the 'contents' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->contents, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to draughting_callout to be a `SET [1:?] OF draughting_callout_element`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_curve_directed_callout* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to dimension_curve_directed_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, angular_dimension* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to angular_dimension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_aspect_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to shape_aspect_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to shape_aspect_relationship to be a `label`")); } - } while(0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->description, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to shape_aspect_relationship to be a `text`")); } - } while(0); - do { // convert the 'relating_shape_aspect' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - try { GenericConvert( in->relating_shape_aspect, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to shape_aspect_relationship to be a `shape_aspect`")); } - } while(0); - do { // convert the 'related_shape_aspect' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3]=true; break; } - try { GenericConvert( in->related_shape_aspect, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to shape_aspect_relationship to be a `shape_aspect`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimensional_location* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to dimensional_location"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, angular_location* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to angular_location"); } do { // convert the 'angle_selection' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert( in->angle_selection, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to angular_location to be a `angle_relator`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimensional_size* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to dimensional_size"); } do { // convert the 'applies_to' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->applies_to, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to dimensional_size to be a `shape_aspect`")); } - } while(0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to dimensional_size to be a `label`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, angular_size* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to angular_size"); } do { // convert the 'angle_selection' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert( in->angle_selection, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to angular_size to be a `angle_relator`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_tolerance* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to geometric_tolerance"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to geometric_tolerance to be a `label`")); } - } while(0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->description, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to geometric_tolerance to be a `text`")); } - } while(0); - do { // convert the 'magnitude' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - try { GenericConvert( in->magnitude, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to geometric_tolerance to be a `measure_with_unit`")); } - } while(0); - do { // convert the 'toleranced_shape_aspect' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3]=true; break; } - try { GenericConvert( in->toleranced_shape_aspect, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to geometric_tolerance to be a `shape_aspect`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_tolerance_with_datum_reference* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to geometric_tolerance_with_datum_reference"); } do { // convert the 'datum_system' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->datum_system, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to geometric_tolerance_with_datum_reference to be a `SET [1:?] OF datum_reference`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, angularity_tolerance* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to angularity_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, styled_item* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to styled_item"); } do { // convert the 'styles' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->styles, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to styled_item to be a `SET [1:?] OF presentation_style_assignment`")); } - } while(0); - do { // convert the 'item' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->item, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to styled_item to be a `representation_item`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_occurrence* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to annotation_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_curve_occurrence* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to annotation_curve_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_fill_area* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to annotation_fill_area"); } do { // convert the 'boundaries' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert( in->boundaries, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to annotation_fill_area to be a `SET [1:?] OF curve`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_fill_area_occurrence* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to annotation_fill_area_occurrence"); } do { // convert the 'fill_style_target' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert( in->fill_style_target, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to annotation_fill_area_occurrence to be a `point`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_occurrence_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to annotation_occurrence_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->name, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to annotation_occurrence_relationship to be a `label`")); } - } while(0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->description, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to annotation_occurrence_relationship to be a `text`")); } - } while(0); - do { // convert the 'relating_annotation_occurrence' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } - try { GenericConvert( in->relating_annotation_occurrence, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to annotation_occurrence_relationship to be a `annotation_occurrence`")); } - } while(0); - do { // convert the 'related_annotation_occurrence' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3]=true; break; } - try { GenericConvert( in->related_annotation_occurrence, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to annotation_occurrence_relationship to be a `annotation_occurrence`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_occurrence_associativity* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to annotation_occurrence_associativity"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_plane* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to annotation_plane"); } do { // convert the 'elements' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert( in->elements, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to annotation_plane to be a `SET [1:?] OF annotation_plane_element`")); } - } while(0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_symbol_occurrence* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to annotation_symbol_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_subfigure_occurrence* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to annotation_subfigure_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mapped_item* in) -{ - size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to mapped_item"); } do { // convert the 'mapping_source' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - try { GenericConvert( in->mapping_source, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to mapped_item to be a `representation_map`")); } - } while(0); - do { // convert the 'mapping_target' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } - try { GenericConvert( in->mapping_target, arg, db ); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to mapped_item to be a `representation_item`")); } - } while(0); - return base; -} - -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to annotation_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_text* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to annotation_text"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_text_character* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to annotation_text_character"); } do { // convert the 'alignment' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->alignment, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to annotation_text_character to be a `text_alignment`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, annotation_text_occurrence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to annotation_text_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_aspect* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to shape_aspect"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to shape_aspect to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to shape_aspect to be a `text`")); } - } while (0); - do { // convert the 'of_shape' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->of_shape, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to shape_aspect to be a `product_definition_shape`")); } - } while (0); - do { // convert the 'product_definitional' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->product_definitional, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to shape_aspect to be a `LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, derived_shape_aspect* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to derived_shape_aspect"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, apex* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to apex"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, application_context_element* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to application_context_element"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to application_context_element to be a `label`")); } - } while (0); - do { // convert the 'frame_of_reference' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->frame_of_reference, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to application_context_element to be a `application_context`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_action_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_action_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_action_assignment to be a `SET [1:?] OF action_items`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_action_method_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_action_method_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_action_method_assignment to be a `SET [1:?] OF action_method_items`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_action_request_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_action_request_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_action_request_assignment to be a `SET [1:?] OF action_request_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, approval_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to approval_assignment"); } do { // convert the 'assigned_approval' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_approval, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to approval_assignment to be a `approval`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_approval_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_approval_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_approval_assignment to be a `SET [1:?] OF approval_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, attribute_classification_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to attribute_classification_assignment"); } do { // convert the 'assigned_class' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_class, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to attribute_classification_assignment to be a `group`")); } - } while (0); - do { // convert the 'attribute_name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->attribute_name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to attribute_classification_assignment to be a `label`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to attribute_classification_assignment to be a `classification_role`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_attribute_classification_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to applied_attribute_classification_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to applied_attribute_classification_assignment to be a `SET [1:?] OF attribute_classification_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, certification_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to certification_assignment"); } do { // convert the 'assigned_certification' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_certification, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to certification_assignment to be a `certification`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_certification_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_certification_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_certification_assignment to be a `SET [1:?] OF certification_item`")); } - } while (0); - return base; -} - -} // ! STEP -} // ! Assimp - -#endif diff --git a/code/AssetLib/StepFile/StepFileGen2.cpp b/code/AssetLib/StepFile/StepFileGen2.cpp deleted file mode 100644 index ea12cd7ba..000000000 --- a/code/AssetLib/StepFile/StepFileGen2.cpp +++ /dev/null @@ -1,3068 +0,0 @@ -/* -Open Asset Import Library (ASSIMP) ----------------------------------------------------------------------- - -Copyright (c) 2006-2020, ASSIMP Development Team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the ASSIMP team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the ASSIMP Development Team. - -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 -OWNER 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 "code/Importer/StepFile/StepReaderGen.h" - -namespace Assimp { -using namespace StepFile; -namespace STEP { - - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, classification_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to classification_assignment"); } do { // convert the 'assigned_class' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_class, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to classification_assignment to be a `group`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to classification_assignment to be a `classification_role`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_classification_assignment* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_classification_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_classification_assignment to be a `SET [1:?] OF classification_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, contract_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to contract_assignment"); } do { // convert the 'assigned_contract' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_contract, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to contract_assignment to be a `contract`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_contract_assignment* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_contract_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_contract_assignment to be a `SET [1:?] OF contract_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, date_and_time_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to date_and_time_assignment"); } do { // convert the 'assigned_date_and_time' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_date_and_time, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to date_and_time_assignment to be a `date_and_time`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to date_and_time_assignment to be a `date_time_role`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_date_and_time_assignment* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_date_and_time_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_date_and_time_assignment to be a `SET [1:?] OF date_and_time_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, date_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to date_assignment"); } do { // convert the 'assigned_date' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_date, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to date_assignment to be a `date`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to date_assignment to be a `date_role`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_date_assignment* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_date_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_date_assignment to be a `SET [1:?] OF date_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, document_reference* in) - { - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to document_reference"); } do { // convert the 'assigned_document' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_document, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to document_reference to be a `document`")); } - } while (0); - do { // convert the 'source' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->source, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to document_reference to be a `label`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_document_reference* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_document_reference"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_document_reference to be a `SET [1:?] OF document_reference_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, document_usage_constraint_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to document_usage_constraint_assignment"); } do { // convert the 'assigned_document_usage' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_document_usage, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to document_usage_constraint_assignment to be a `document_usage_constraint`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to document_usage_constraint_assignment to be a `document_usage_role`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_document_usage_constraint_assignment* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_document_usage_constraint_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_document_usage_constraint_assignment to be a `SET [1:?] OF document_reference_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, effectivity_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to effectivity_assignment"); } do { // convert the 'assigned_effectivity' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_effectivity, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to effectivity_assignment to be a `effectivity`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_effectivity_assignment* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_effectivity_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_effectivity_assignment to be a `SET [1:?] OF effectivity_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, event_occurrence_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to event_occurrence_assignment"); } do { // convert the 'assigned_event_occurrence' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_event_occurrence, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to event_occurrence_assignment to be a `event_occurrence`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to event_occurrence_assignment to be a `event_occurrence_role`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, applied_event_occurrence_assignment* in) - { - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_event_occurrence_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_event_occurrence_assignment to be a `SET [1:?] OF event_occurrence_item`")); } - } while (0); - return base; - } - // ----------------------------------------------------------------------------------------------------------- - template <> size_t GenericFill(const DB& db, const LIST& params, identification_assignment* in) - { - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to identification_assignment"); } do { // convert the 'assigned_id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to identification_assignment to be a `identifier`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to identification_assignment to be a `identification_role`")); } - } while (0); - return base; - } -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, external_identification_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to external_identification_assignment"); } do { // convert the 'source' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->source, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to external_identification_assignment to be a `external_source`")); } - } while (0); - return base; -} - -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_external_identification_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to applied_external_identification_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to applied_external_identification_assignment to be a `SET [1:?] OF external_identification_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, group_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to group_assignment"); } do { // convert the 'assigned_group' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_group, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to group_assignment to be a `group`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_group_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_group_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_group_assignment to be a `SET [1:?] OF groupable_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_identification_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_identification_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_identification_assignment to be a `SET [1:?] OF identification_item`")); } - } while (0); - return base; -} - -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, name_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to name_assignment"); } do { // convert the 'assigned_name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to name_assignment to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_name_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_name_assignment"); } do { // convert the 'item' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->item, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_name_assignment to be a `name_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, organization_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to organization_assignment"); } do { // convert the 'assigned_organization' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_organization, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to organization_assignment to be a `organization`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to organization_assignment to be a `organization_role`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_organization_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_organization_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_organization_assignment to be a `SET [1:?] OF organization_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, organizational_project_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to organizational_project_assignment"); } do { // convert the 'assigned_organizational_project' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_organizational_project, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to organizational_project_assignment to be a `organizational_project`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to organizational_project_assignment to be a `organizational_project_role`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_organizational_project_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_organizational_project_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_organizational_project_assignment to be a `SET [1:?] OF project_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, person_and_organization_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to person_and_organization_assignment"); } do { // convert the 'assigned_person_and_organization' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_person_and_organization, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to person_and_organization_assignment to be a `person_and_organization`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to person_and_organization_assignment to be a `person_and_organization_role`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_person_and_organization_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_person_and_organization_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_person_and_organization_assignment to be a `SET [1:?] OF person_and_organization_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, presented_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_presented_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to applied_presented_item"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to applied_presented_item to be a `SET [1:?] OF presented_item_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, security_classification_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to security_classification_assignment"); } do { // convert the 'assigned_security_classification' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_security_classification, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to security_classification_assignment to be a `security_classification`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_security_classification_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_security_classification_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to applied_security_classification_assignment to be a `SET [1:?] OF security_classification_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, time_interval_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to time_interval_assignment"); } do { // convert the 'assigned_time_interval' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_time_interval, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to time_interval_assignment to be a `time_interval`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to time_interval_assignment to be a `time_interval_role`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_time_interval_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to applied_time_interval_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to applied_time_interval_assignment to be a `SET [0:?] OF time_interval_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, applied_usage_right* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to applied_usage_right"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, area_in_set* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to area_in_set"); } do { // convert the 'area' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->area, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to area_in_set to be a `presentation_area`")); } - } while (0); - do { // convert the 'in_set' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->in_set, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to area_in_set to be a `presentation_set`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, area_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to area_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, area_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to area_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to product_definition_relationship"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to product_definition_relationship to be a `identifier`")); } - } while (0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_definition_relationship to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_definition_relationship to be a `text`")); } - } while (0); - do { // convert the 'relating_product_definition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->relating_product_definition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to product_definition_relationship to be a `product_definition`")); } - } while (0); - do { // convert the 'related_product_definition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4] = true; break; } - try { GenericConvert(in->related_product_definition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to product_definition_relationship to be a `product_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to product_definition_usage"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, assembly_component_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to assembly_component_usage"); } do { // convert the 'reference_designator' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->reference_designator, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to assembly_component_usage to be a `identifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, assigned_requirement* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to assigned_requirement"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to assigned_requirement to be a `SET [1:1] OF product_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, compound_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to compound_representation_item"); } do { // convert the 'item_element' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->item_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to compound_representation_item to be a `compound_item_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, atomic_formula* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to atomic_formula"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, attribute_assertion* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, attribute_language_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to attribute_language_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to attribute_language_assignment to be a `SET [1:?] OF attribute_language_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, attribute_value_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to attribute_value_assignment"); } do { // convert the 'attribute_name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->attribute_name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to attribute_value_assignment to be a `label`")); } - } while (0); - do { // convert the 'attribute_value' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->attribute_value, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to attribute_value_assignment to be a `attribute_type`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to attribute_value_assignment to be a `attribute_value_role`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, auxiliary_geometric_representation_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, placement* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to placement"); } do { // convert the 'location' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->location, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to placement to be a `cartesian_point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, axis1_placement* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to axis1_placement"); } do { // convert the 'axis' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->axis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to axis1_placement to be a `direction`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, axis2_placement_2d* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to axis2_placement_2d"); } do { // convert the 'ref_direction' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->ref_direction, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to axis2_placement_2d to be a `direction`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, axis2_placement_3d* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to axis2_placement_3d"); } do { // convert the 'axis' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->axis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to axis2_placement_3d to be a `direction`")); } - } while (0); - do { // convert the 'ref_direction' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->ref_direction, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to axis2_placement_3d to be a `direction`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, bounded_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to bounded_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, b_spline_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to b_spline_curve"); } do { // convert the 'degree' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->degree, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to b_spline_curve to be a `INTEGER`")); } - } while (0); - do { // convert the 'control_points_list' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->control_points_list, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to b_spline_curve to be a `LIST [2:?] OF cartesian_point`")); } - } while (0); - do { // convert the 'curve_form' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->curve_form, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to b_spline_curve to be a `b_spline_curve_form`")); } - } while (0); - do { // convert the 'closed_curve' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->closed_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to b_spline_curve to be a `LOGICAL`")); } - } while (0); - do { // convert the 'self_intersect' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4] = true; break; } - try { GenericConvert(in->self_intersect, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to b_spline_curve to be a `LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, b_spline_curve_with_knots* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to b_spline_curve_with_knots"); } do { // convert the 'knot_multiplicities' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->knot_multiplicities, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to b_spline_curve_with_knots to be a `LIST [2:?] OF INTEGER`")); } - } while (0); - do { // convert the 'knots' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->knots, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to b_spline_curve_with_knots to be a `LIST [2:?] OF parameter_value`")); } - } while (0); - do { // convert the 'knot_spec' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->knot_spec, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to b_spline_curve_with_knots to be a `knot_type`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, bounded_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to bounded_surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, b_spline_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to b_spline_surface"); } do { // convert the 'u_degree' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->u_degree, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to b_spline_surface to be a `INTEGER`")); } - } while (0); - do { // convert the 'v_degree' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->v_degree, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to b_spline_surface to be a `INTEGER`")); } - } while (0); - do { // convert the 'surface_form' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->surface_form, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to b_spline_surface to be a `b_spline_surface_form`")); } - } while (0); - do { // convert the 'u_closed' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->u_closed, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to b_spline_surface to be a `LOGICAL`")); } - } while (0); - do { // convert the 'v_closed' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4] = true; break; } - try { GenericConvert(in->v_closed, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to b_spline_surface to be a `LOGICAL`")); } - } while (0); - do { // convert the 'self_intersect' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[5] = true; break; } - try { GenericConvert(in->self_intersect, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to b_spline_surface to be a `LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, b_spline_surface_with_knots* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 12) { throw STEP::TypeError("expected 12 arguments to b_spline_surface_with_knots"); } do { // convert the 'u_multiplicities' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->u_multiplicities, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to b_spline_surface_with_knots to be a `LIST [2:?] OF INTEGER`")); } - } while (0); - do { // convert the 'v_multiplicities' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->v_multiplicities, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to b_spline_surface_with_knots to be a `LIST [2:?] OF INTEGER`")); } - } while (0); - do { // convert the 'u_knots' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->u_knots, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to b_spline_surface_with_knots to be a `LIST [2:?] OF parameter_value`")); } - } while (0); - do { // convert the 'v_knots' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->v_knots, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 10 to b_spline_surface_with_knots to be a `LIST [2:?] OF parameter_value`")); } - } while (0); - do { // convert the 'knot_spec' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->knot_spec, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 11 to b_spline_surface_with_knots to be a `knot_type`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to product_definition"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to product_definition to be a `identifier`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_definition to be a `text`")); } - } while (0); - do { // convert the 'formation' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->formation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_definition to be a `product_definition_formation`")); } - } while (0); - do { // convert the 'frame_of_reference' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->frame_of_reference, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to product_definition to be a `product_definition_context`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_software_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to rule_software_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to rule_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, back_chaining_rule* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to back_chaining_rule"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, back_chaining_rule_body* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, colour* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, background_colour* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to background_colour"); } do { // convert the 'presentation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->presentation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to background_colour to be a `area_or_view`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, beveled_sheet_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to beveled_sheet_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, bezier_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to bezier_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, bezier_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to bezier_surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, generic_expression* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, binary_generic_expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to binary_generic_expression"); } do { // convert the 'operands' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->operands, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to binary_generic_expression to be a `LIST [2:2] OF generic_expression`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, binary_numeric_expression* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, binary_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to binary_representation_item"); } do { // convert the 'binary_value' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->binary_value, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to binary_representation_item to be a `BINARY`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, block* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to block"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to block to be a `axis2_placement_3d`")); } - } while (0); - do { // convert the 'x' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->x, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to block to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'y' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->y, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to block to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'z' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->z, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to block to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, boolean_expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, boolean_literal* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to boolean_literal"); } do { // convert the 'the_value' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->the_value, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to boolean_literal to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, boolean_representation_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, boolean_result* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to boolean_result"); } do { // convert the 'operator' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->operator_, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to boolean_result to be a `boolean_operator`")); } - } while (0); - do { // convert the 'first_operand' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->first_operand, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to boolean_result to be a `boolean_operand`")); } - } while (0); - do { // convert the 'second_operand' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->second_operand, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to boolean_result to be a `boolean_operand`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_curve"); } do { // convert the 'segments' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->segments, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to composite_curve to be a `LIST [1:?] OF composite_curve_segment`")); } - } while (0); - do { // convert the 'self_intersect' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->self_intersect, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to composite_curve to be a `LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_curve_on_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_curve_on_surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, boundary_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to boundary_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, bounded_pcurve* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, bounded_surface_curve* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, founded_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, box_domain* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to box_domain"); } do { // convert the 'corner' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->corner, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to box_domain to be a `cartesian_point`")); } - } while (0); - do { // convert the 'xlength' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->xlength, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to box_domain to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'ylength' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->ylength, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to box_domain to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'zlength' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->zlength, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to box_domain to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, half_space_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to half_space_solid"); } do { // convert the 'base_surface' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->base_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to half_space_solid to be a `surface`")); } - } while (0); - do { // convert the 'agreement_flag' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->agreement_flag, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to half_space_solid to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, boxed_half_space* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to boxed_half_space"); } do { // convert the 'enclosure' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->enclosure, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to boxed_half_space to be a `box_domain`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, breakdown_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to breakdown_context"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, breakdown_element_group_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to breakdown_element_group_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to breakdown_element_group_assignment to be a `SET [1:1] OF product_definition_or_breakdown_element_usage`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, breakdown_element_realization* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, breakdown_element_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to breakdown_element_usage"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, breakdown_of* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to breakdown_of"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_model* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to solid_model"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, manifold_solid_brep* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to manifold_solid_brep"); } do { // convert the 'outer' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->outer, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to manifold_solid_brep to be a `closed_shell`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, brep_with_voids* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to brep_with_voids"); } do { // convert the 'voids' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->voids, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to brep_with_voids to be a `SET [1:?] OF oriented_closed_shell`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, bytes_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to bytes_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, date* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to date"); } do { // convert the 'year_component' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->year_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to date to be a `year_number`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, calendar_date* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to calendar_date"); } do { // convert the 'day_component' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->day_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to calendar_date to be a `day_in_month_number`")); } - } while (0); - do { // convert the 'month_component' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->month_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to calendar_date to be a `month_in_year_number`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_image* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to camera_image"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_image_3d_with_scale* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to camera_image_3d_with_scale"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_model* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to camera_model"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_model_d3* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to camera_model_d3"); } do { // convert the 'view_reference_system' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->view_reference_system, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to camera_model_d3 to be a `axis2_placement_3d`")); } - } while (0); - do { // convert the 'perspective_of_volume' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->perspective_of_volume, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to camera_model_d3 to be a `view_volume`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_model_d3_multi_clipping* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to camera_model_d3_multi_clipping"); } do { // convert the 'shape_clipping' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->shape_clipping, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to camera_model_d3_multi_clipping to be a `SET [1:?] OF camera_model_d3_multi_clipping_interection_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_model_d3_multi_clipping_intersection* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to camera_model_d3_multi_clipping_intersection"); } do { // convert the 'shape_clipping' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->shape_clipping, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to camera_model_d3_multi_clipping_intersection to be a `SET [2:?] OF camera_model_d3_multi_clipping_interection_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_model_d3_multi_clipping_union* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to camera_model_d3_multi_clipping_union"); } do { // convert the 'shape_clipping' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->shape_clipping, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to camera_model_d3_multi_clipping_union to be a `SET [2:?] OF camera_model_d3_multi_clipping_union_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_model_d3_with_hlhsr* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to camera_model_d3_with_hlhsr"); } do { // convert the 'hidden_line_surface_removal' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->hidden_line_surface_removal, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to camera_model_d3_with_hlhsr to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_model_with_light_sources* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to camera_model_with_light_sources"); } do { // convert the 'sources' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sources, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to camera_model_with_light_sources to be a `SET [1:?] OF light_source`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, representation_map* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to representation_map"); } do { // convert the 'mapping_origin' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->mapping_origin, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to representation_map to be a `representation_item`")); } - } while (0); - do { // convert the 'mapped_representation' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->mapped_representation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to representation_map to be a `representation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, camera_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to camera_usage"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, capacitance_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to capacitance_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, capacitance_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to capacitance_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, point* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to point"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cartesian_point* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to cartesian_point"); } do { // convert the 'coordinates' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->coordinates, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to cartesian_point to be a `LIST [1:3] OF length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cartesian_transformation_operator* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to cartesian_transformation_operator"); } do { // convert the 'axis1' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->axis1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to cartesian_transformation_operator to be a `direction`")); } - } while (0); - do { // convert the 'axis2' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->axis2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to cartesian_transformation_operator to be a `direction`")); } - } while (0); - do { // convert the 'local_origin' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->local_origin, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to cartesian_transformation_operator to be a `cartesian_point`")); } - } while (0); - do { // convert the 'scale' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->scale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to cartesian_transformation_operator to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cartesian_transformation_operator_2d* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to cartesian_transformation_operator_2d"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cartesian_transformation_operator_3d* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to cartesian_transformation_operator_3d"); } do { // convert the 'axis3' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->axis3, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to cartesian_transformation_operator_3d to be a `direction`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cc_design_approval* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to cc_design_approval"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to cc_design_approval to be a `SET [1:?] OF approved_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cc_design_certification* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to cc_design_certification"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to cc_design_certification to be a `SET [1:?] OF certified_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cc_design_contract* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to cc_design_contract"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to cc_design_contract to be a `SET [1:?] OF contracted_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cc_design_date_and_time_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to cc_design_date_and_time_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to cc_design_date_and_time_assignment to be a `SET [1:?] OF date_time_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cc_design_person_and_organization_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to cc_design_person_and_organization_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to cc_design_person_and_organization_assignment to be a `SET [1:?] OF cc_person_organization_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cc_design_security_classification* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to cc_design_security_classification"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to cc_design_security_classification to be a `SET [1:?] OF cc_classified_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cc_design_specification_reference* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to cc_design_specification_reference"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to cc_design_specification_reference to be a `SET [1:?] OF cc_specified_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, celsius_temperature_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to celsius_temperature_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, centre_of_symmetry* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to centre_of_symmetry"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, change* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to change"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to change to be a `SET [1:?] OF work_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, change_request* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to change_request"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to change_request to be a `SET [1:?] OF change_request_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, character_glyph_style_outline* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to character_glyph_style_outline"); } do { // convert the 'outline_style' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->outline_style, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to character_glyph_style_outline to be a `curve_style`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, character_glyph_style_stroke* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to character_glyph_style_stroke"); } do { // convert the 'stroke_style' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->stroke_style, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to character_glyph_style_stroke to be a `curve_style`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, symbol_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to symbol_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, generic_character_glyph_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to generic_character_glyph_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, character_glyph_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to character_glyph_symbol"); } do { // convert the 'character_box' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->character_box, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to character_glyph_symbol to be a `planar_extent`")); } - } while (0); - do { // convert the 'baseline_ratio' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->baseline_ratio, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to character_glyph_symbol to be a `ratio_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, character_glyph_symbol_outline* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to character_glyph_symbol_outline"); } do { // convert the 'outlines' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->outlines, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to character_glyph_symbol_outline to be a `SET [1:?] OF annotation_fill_area`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, character_glyph_symbol_stroke* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to character_glyph_symbol_stroke"); } do { // convert the 'strokes' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->strokes, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to character_glyph_symbol_stroke to be a `SET [1:?] OF curve`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, general_property* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to general_property"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to general_property to be a `identifier`")); } - } while (0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to general_property to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to general_property to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, characteristic_data_column_header* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to characteristic_data_column_header"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, general_property_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to general_property_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to general_property_relationship to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to general_property_relationship to be a `text`")); } - } while (0); - do { // convert the 'relating_property' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->relating_property, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to general_property_relationship to be a `general_property`")); } - } while (0); - do { // convert the 'related_property' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->related_property, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to general_property_relationship to be a `general_property`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, characteristic_data_column_header_link* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to characteristic_data_column_header_link"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, characteristic_data_table_header* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to characteristic_data_table_header"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, characteristic_data_table_header_decomposition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to characteristic_data_table_header_decomposition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, group* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to group"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to group to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to group to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, characteristic_type* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to characteristic_type"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, characterized_class* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, characterized_object* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to characterized_object"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to characterized_object to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to characterized_object to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, conic* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to conic"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to conic to be a `axis2_placement`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, circle* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to circle"); } do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to circle to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, circular_runout_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to circular_runout_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, class_by_extension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to class_by_extension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, class_by_intension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to class_by_intension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, class_system* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to class_system"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, effectivity_context_assignment* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to effectivity_context_assignment"); } do { // convert the 'assigned_effectivity_assignment' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->assigned_effectivity_assignment, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to effectivity_context_assignment to be a `effectivity_assignment`")); } - } while (0); - do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to effectivity_context_assignment to be a `effectivity_context_role`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, class_usage_effectivity_context_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to class_usage_effectivity_context_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to class_usage_effectivity_context_assignment to be a `SET [1:?] OF class_usage_effectivity_context_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, topological_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to topological_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, connected_face_set* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to connected_face_set"); } do { // convert the 'cfs_faces' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->cfs_faces, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to connected_face_set to be a `SET [1:?] OF face`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, closed_shell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to closed_shell"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, coaxiality_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to coaxiality_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, colour_specification* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to colour_specification"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to colour_specification to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, colour_rgb* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to colour_rgb"); } do { // convert the 'red' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->red, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to colour_rgb to be a `REAL`")); } - } while (0); - do { // convert the 'green' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->green, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to colour_rgb to be a `REAL`")); } - } while (0); - do { // convert the 'blue' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->blue, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to colour_rgb to be a `REAL`")); } - } while (0); - return base; -} -/* -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, common_datum* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, comparison_expression* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, complex_clause* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to complex_clause"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, complex_conjunctive_clause* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to complex_conjunctive_clause"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, complex_disjunctive_clause* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to complex_disjunctive_clause"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, modified_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to modified_solid"); } do { // convert the 'rationale' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->rationale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to modified_solid to be a `text`")); } - } while (0); - do { // convert the 'base_solid' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->base_solid, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to modified_solid to be a `base_solid_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shelled_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to shelled_solid"); } do { // convert the 'deleted_face_set' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->deleted_face_set, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to shelled_solid to be a `SET [1:?] OF face_surface`")); } - } while (0); - do { // convert the 'thickness' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->thickness, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to shelled_solid to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, complex_shelled_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to complex_shelled_solid"); } do { // convert the 'thickness_list' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->thickness_list, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to complex_shelled_solid to be a `LIST [1:?] OF length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_assembly_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to composite_assembly_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_assembly_sequence_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to composite_assembly_sequence_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, laminate_table* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to laminate_table"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, part_laminate_table* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to part_laminate_table"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_assembly_table* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to composite_assembly_table"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_curve_segment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_curve_segment"); } do { // convert the 'transition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->transition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to composite_curve_segment to be a `transition_code`")); } - } while (0); - do { // convert the 'same_sense' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->same_sense, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to composite_curve_segment to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'parent_curve' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->parent_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to composite_curve_segment to be a `curve`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, material_designation* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to material_designation"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to material_designation to be a `label`")); } - } while (0); - do { // convert the 'definitions' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->definitions, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to material_designation to be a `SET [1:?] OF characterized_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_material_designation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to composite_material_designation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_shape_aspect* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to composite_shape_aspect"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_sheet_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_sheet_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_text* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to composite_text"); } do { // convert the 'collected_text' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->collected_text, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to composite_text to be a `SET [2:?] OF text_or_character`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_text_with_associated_curves* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_text_with_associated_curves"); } do { // convert the 'associated_curves' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->associated_curves, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to composite_text_with_associated_curves to be a `SET [1:?] OF curve`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_text_with_blanking_box* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_text_with_blanking_box"); } do { // convert the 'blanking' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->blanking, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to composite_text_with_blanking_box to be a `planar_box`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_text_with_delineation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_text_with_delineation"); } do { // convert the 'delineation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->delineation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to composite_text_with_delineation to be a `text_delineation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, composite_text_with_extent* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to composite_text_with_extent"); } do { // convert the 'extent' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->extent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to composite_text_with_extent to be a `planar_extent`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, compound_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to compound_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, concentricity_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to concentricity_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, concept_feature_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to concept_feature_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to concept_feature_relationship to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to concept_feature_relationship to be a `text`")); } - } while (0); - do { // convert the 'relating_product_concept_feature' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->relating_product_concept_feature, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to concept_feature_relationship to be a `product_concept_feature`")); } - } while (0); - do { // convert the 'related_product_concept_feature' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->related_product_concept_feature, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to concept_feature_relationship to be a `product_concept_feature`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, concept_feature_relationship_with_condition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to concept_feature_relationship_with_condition"); } do { // convert the 'conditional_operator' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->conditional_operator, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to concept_feature_relationship_with_condition to be a `concept_feature_operator`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_concept_feature* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to product_concept_feature"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to product_concept_feature to be a `identifier`")); } - } while (0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_concept_feature to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_concept_feature to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, conditional_concept_feature* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to conditional_concept_feature"); } do { // convert the 'condition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->condition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to conditional_concept_feature to be a `concept_feature_relationship_with_condition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, conductance_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to conductance_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, conductance_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to conductance_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configuration_item* in) -{ - size_t base = 0; - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to configuration_item"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to configuration_item to be a `identifier`")); } - } while (0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to configuration_item to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to configuration_item to be a `text`")); } - } while (0); - do { // convert the 'item_concept' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->item_concept, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to configuration_item to be a `product_concept`")); } - } while (0); - do { // convert the 'purpose' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->purpose, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to configuration_item to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configurable_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to configurable_item"); } do { // convert the 'item_concept_feature' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->item_concept_feature, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to configurable_item to be a `SET [1:?] OF product_concept_feature_association`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, effectivity* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to effectivity"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to effectivity to be a `identifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_effectivity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to product_definition_effectivity"); } do { // convert the 'usage' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->usage, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_definition_effectivity to be a `product_definition_relationship`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configuration_effectivity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to configuration_effectivity"); } do { // convert the 'configuration' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->configuration, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to configuration_effectivity to be a `configuration_design`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configuration_item_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to configuration_item_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to configuration_item_relationship to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to configuration_item_relationship to be a `text`")); } - } while (0); - do { // convert the 'relating_configuration_item' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->relating_configuration_item, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to configuration_item_relationship to be a `configuration_item`")); } - } while (0); - do { // convert the 'related_configuration_item' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->related_configuration_item, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to configuration_item_relationship to be a `configuration_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configuration_item_hierarchical_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to configuration_item_hierarchical_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configuration_item_revision_sequence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to configuration_item_revision_sequence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configured_effectivity_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to configured_effectivity_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to configured_effectivity_assignment to be a `SET [1:?] OF configured_effectivity_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, configured_effectivity_context_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to configured_effectivity_context_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to configured_effectivity_context_assignment to be a `SET [1:?] OF configured_effectivity_context_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, conical_stepped_hole_transition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to conical_stepped_hole_transition"); } do { // convert the 'transition_number' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->transition_number, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to conical_stepped_hole_transition to be a `positive_integer`")); } - } while (0); - do { // convert the 'cone_apex_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->cone_apex_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to conical_stepped_hole_transition to be a `plane_angle_measure`")); } - } while (0); - do { // convert the 'cone_base_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->cone_base_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to conical_stepped_hole_transition to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, elementary_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to elementary_surface"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to elementary_surface to be a `axis2_placement_3d`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, conical_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to conical_surface"); } do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to conical_surface to be a `length_measure`")); } - } while (0); - do { // convert the 'semi_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->semi_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to conical_surface to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, connected_edge_set* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to connected_edge_set"); } do { // convert the 'ces_edges' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->ces_edges, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to connected_edge_set to be a `SET [1:?] OF edge`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, connected_face_sub_set* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to connected_face_sub_set"); } do { // convert the 'parent_face_set' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_face_set, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to connected_face_sub_set to be a `connected_face_set`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, constructive_geometry_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to constructive_geometry_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, representation_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to representation_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to representation_relationship to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to representation_relationship to be a `text`")); } - } while (0); - do { // convert the 'rep_1' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->rep_1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to representation_relationship to be a `representation`")); } - } while (0); - do { // convert the 'rep_2' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->rep_2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to representation_relationship to be a `representation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, constructive_geometry_representation_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to constructive_geometry_representation_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, contact_ratio_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to contact_ratio_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, invisibility* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to invisibility"); } do { // convert the 'invisible_items' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->invisible_items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to invisibility to be a `SET [1:?] OF invisible_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, context_dependent_invisibility* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to context_dependent_invisibility"); } do { // convert the 'presentation_context' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->presentation_context, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to context_dependent_invisibility to be a `invisibility_context`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, over_riding_styled_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to over_riding_styled_item"); } do { // convert the 'over_ridden_style' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->over_ridden_style, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to over_riding_styled_item to be a `styled_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, context_dependent_over_riding_styled_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to context_dependent_over_riding_styled_item"); } do { // convert the 'style_context' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->style_context, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to context_dependent_over_riding_styled_item to be a `LIST [1:?] OF style_context_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, context_dependent_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to context_dependent_unit"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to context_dependent_unit to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, conversion_based_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to conversion_based_unit"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to conversion_based_unit to be a `label`")); } - } while (0); - do { // convert the 'conversion_factor' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->conversion_factor, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to conversion_based_unit to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, csg_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to csg_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, csg_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to csg_solid"); } do { // convert the 'tree_root_expression' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->tree_root_expression, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to csg_solid to be a `csg_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, currency* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to currency"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, currency_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to currency_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_bounded_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to curve_bounded_surface"); } do { // convert the 'basis_surface' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to curve_bounded_surface to be a `surface`")); } - } while (0); - do { // convert the 'boundaries' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->boundaries, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to curve_bounded_surface to be a `SET [1:?] OF boundary_curve`")); } - } while (0); - do { // convert the 'implicit_outer' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->implicit_outer, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to curve_bounded_surface to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_dimension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to curve_dimension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_replica* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to curve_replica"); } do { // convert the 'parent_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to curve_replica to be a `curve`")); } - } while (0); - do { // convert the 'transformation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->transformation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to curve_replica to be a `cartesian_transformation_operator`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to curve_style"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to curve_style to be a `label`")); } - } while (0); - do { // convert the 'curve_font' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->curve_font, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to curve_style to be a `curve_font_or_scaled_curve_font_select`")); } - } while (0); - do { // convert the 'curve_width' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->curve_width, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to curve_style to be a `size_select`")); } - } while (0); - do { // convert the 'curve_colour' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->curve_colour, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to curve_style to be a `colour`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_style_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to curve_style_font"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to curve_style_font to be a `label`")); } - } while (0); - do { // convert the 'pattern_list' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->pattern_list, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to curve_style_font to be a `LIST [1:?] OF curve_style_font_pattern`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_style_font_and_scaling* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to curve_style_font_and_scaling"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to curve_style_font_and_scaling to be a `label`")); } - } while (0); - do { // convert the 'curve_font' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->curve_font, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to curve_style_font_and_scaling to be a `curve_style_font_select`")); } - } while (0); - do { // convert the 'curve_font_scaling' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->curve_font_scaling, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to curve_style_font_and_scaling to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_style_font_pattern* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to curve_style_font_pattern"); } do { // convert the 'visible_segment_length' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->visible_segment_length, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to curve_style_font_pattern to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'invisible_segment_length' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->invisible_segment_length, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to curve_style_font_pattern to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, curve_swept_solid_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to curve_swept_solid_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cylindrical_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to cylindrical_surface"); } do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to cylindrical_surface to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, cylindricity_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to cylindricity_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, date_representation_item* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, date_time_representation_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dated_effectivity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to dated_effectivity"); } do { // convert the 'effectivity_end_date' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->effectivity_end_date, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to dated_effectivity to be a `date_time_or_event_occurrence`")); } - } while (0); - do { // convert the 'effectivity_start_date' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->effectivity_start_date, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to dated_effectivity to be a `date_time_or_event_occurrence`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, datum* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to datum"); } do { // convert the 'identification' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->identification, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to datum to be a `identifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, datum_feature* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to datum_feature"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, datum_feature_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to datum_feature_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, datum_reference* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to datum_reference"); } do { // convert the 'precedence' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->precedence, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to datum_reference to be a `INTEGER`")); } - } while (0); - do { // convert the 'referenced_datum' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->referenced_datum, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to datum_reference to be a `datum`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, datum_target* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to datum_target"); } do { // convert the 'target_id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->target_id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to datum_target to be a `identifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, datum_target_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to datum_target_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, default_tolerance_table* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to default_tolerance_table"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, default_tolerance_table_cell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to default_tolerance_table_cell"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, defined_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to defined_symbol"); } do { // convert the 'definition' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->definition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to defined_symbol to be a `defined_symbol_select`")); } - } while (0); - do { // convert the 'target' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->target, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to defined_symbol to be a `symbol_target`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, definitional_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to definitional_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, definitional_representation_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to definitional_representation_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, definitional_representation_relationship_with_same_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to definitional_representation_relationship_with_same_context"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, degenerate_pcurve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to degenerate_pcurve"); } do { // convert the 'basis_surface' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->basis_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to degenerate_pcurve to be a `surface`")); } - } while (0); - do { // convert the 'reference_to_curve' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->reference_to_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to degenerate_pcurve to be a `definitional_representation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, toroidal_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to toroidal_surface"); } do { // convert the 'major_radius' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->major_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to toroidal_surface to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'minor_radius' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->minor_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to toroidal_surface to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, degenerate_toroidal_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to degenerate_toroidal_surface"); } do { // convert the 'select_outer' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->select_outer, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to degenerate_toroidal_surface to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, descriptive_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to descriptive_representation_item"); } do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to descriptive_representation_item to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to product_definition_context"); } do { // convert the 'life_cycle_stage' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->life_cycle_stage, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_definition_context to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, design_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to design_context"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, design_make_from_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to design_make_from_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, diameter_dimension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to diameter_dimension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ratio_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to ratio_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dielectric_constant_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to dielectric_constant_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to dimension_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_callout_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to draughting_callout_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to draughting_callout_relationship to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to draughting_callout_relationship to be a `text`")); } - } while (0); - do { // convert the 'relating_draughting_callout' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->relating_draughting_callout, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to draughting_callout_relationship to be a `draughting_callout`")); } - } while (0); - do { // convert the 'related_draughting_callout' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->related_draughting_callout, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to draughting_callout_relationship to be a `draughting_callout`")); } - } while (0); - return base; -} - -} -} diff --git a/code/AssetLib/StepFile/StepFileGen3.cpp b/code/AssetLib/StepFile/StepFileGen3.cpp deleted file mode 100644 index b3e34027e..000000000 --- a/code/AssetLib/StepFile/StepFileGen3.cpp +++ /dev/null @@ -1,5746 +0,0 @@ -/* -Open Asset Import Library (ASSIMP) ----------------------------------------------------------------------- - -Copyright (c) 2006-2020, ASSIMP Development Team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the ASSIMP team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the ASSIMP Development Team. - -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 -OWNER 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 "code/Importer/StepFile/StepReaderGen.h" - -namespace Assimp { -using namespace StepFile; -namespace STEP { - -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_callout_component_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to dimension_callout_component_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_callout_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to dimension_callout_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to dimension_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, terminator_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to terminator_symbol"); } do { // convert the 'annotated_curve' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->annotated_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to terminator_symbol to be a `annotation_curve_occurrence`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_curve_terminator* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to dimension_curve_terminator"); } do { // convert the 'role' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->role, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to dimension_curve_terminator to be a `dimension_extent_usage`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_curve_terminator_to_projection_curve_associativity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to dimension_curve_terminator_to_projection_curve_associativity"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimension_pair* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to dimension_pair"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, dimension_text_associativity* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimensional_location_with_path* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to dimensional_location_with_path"); } do { // convert the 'path' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->path, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to dimensional_location_with_path to be a `shape_aspect`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dimensional_size_with_path* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to dimensional_size_with_path"); } do { // convert the 'path' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->path, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to dimensional_size_with_path to be a `shape_aspect`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, executed_action* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to executed_action"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, directed_action* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to directed_action"); } do { // convert the 'directive' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->directive, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to directed_action to be a `action_directive`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, directed_dimensional_location* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to directed_dimensional_location"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, direction* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to direction"); } do { // convert the 'direction_ratios' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->direction_ratios, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to direction to be a `LIST [2:3] OF REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, document_file* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, document_identifier* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to document_identifier"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, document_identifier_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to document_identifier_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to document_identifier_assignment to be a `SET [1:?] OF document_identifier_assigned_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, document_product_association* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to document_product_association"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to document_product_association to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to document_product_association to be a `text`")); } - } while (0); - do { // convert the 'relating_document' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->relating_document, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to document_product_association to be a `document`")); } - } while (0); - do { // convert the 'related_product' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->related_product, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to document_product_association to be a `product_or_formation_or_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, document_product_equivalence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to document_product_equivalence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dose_equivalent_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to dose_equivalent_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, dose_equivalent_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to dose_equivalent_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, double_offset_shelled_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to double_offset_shelled_solid"); } do { // convert the 'thickness2' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->thickness2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to double_offset_shelled_solid to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, item_defined_transformation* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to item_defined_transformation"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to item_defined_transformation to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to item_defined_transformation to be a `text`")); } - } while (0); - do { // convert the 'transform_item_1' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->transform_item_1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to item_defined_transformation to be a `representation_item`")); } - } while (0); - do { // convert the 'transform_item_2' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->transform_item_2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to item_defined_transformation to be a `representation_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, transformation_with_derived_angle* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to transformation_with_derived_angle"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draped_defined_transformation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to draped_defined_transformation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_annotation_occurrence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to draughting_annotation_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_elements* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to draughting_elements"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_model* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to draughting_model"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, item_identified_representation_usage* in) -{ - size_t base = 0; - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to item_identified_representation_usage"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to item_identified_representation_usage to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to item_identified_representation_usage to be a `text`")); } - } while (0); - do { // convert the 'definition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->definition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to item_identified_representation_usage to be a `represented_definition`")); } - } while (0); - do { // convert the 'used_representation' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->used_representation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to item_identified_representation_usage to be a `representation`")); } - } while (0); - do { // convert the 'identified_item' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4] = true; break; } - try { GenericConvert(in->identified_item, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to item_identified_representation_usage to be a `representation_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_model_item_association* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to draughting_model_item_association"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_colour* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_pre_defined_colour* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_item* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_item"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to pre_defined_item to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_curve_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_curve_font"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_pre_defined_curve_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to draughting_pre_defined_curve_font"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_text_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_text_font"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_pre_defined_text_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to draughting_pre_defined_text_font"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_subfigure_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to draughting_subfigure_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_symbol_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to draughting_symbol_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_literal* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to text_literal"); } do { // convert the 'literal' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->literal, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to text_literal to be a `presentable_text`")); } - } while (0); - do { // convert the 'placement' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->placement, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to text_literal to be a `axis2_placement`")); } - } while (0); - do { // convert the 'alignment' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->alignment, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to text_literal to be a `text_alignment`")); } - } while (0); - do { // convert the 'path' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->path, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to text_literal to be a `text_path`")); } - } while (0); - do { // convert the 'font' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4] = true; break; } - try { GenericConvert(in->font, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to text_literal to be a `font_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_literal_with_delineation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to text_literal_with_delineation"); } do { // convert the 'delineation' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->delineation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to text_literal_with_delineation to be a `text_delineation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, draughting_text_literal_with_delineation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to draughting_text_literal_with_delineation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, presentation_set* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, drawing_revision* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to drawing_revision"); } do { // convert the 'revision_identifier' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->revision_identifier, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to drawing_revision to be a `identifier`")); } - } while (0); - do { // convert the 'drawing_identifier' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->drawing_identifier, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to drawing_revision to be a `drawing_definition`")); } - } while (0); - do { // convert the 'intended_scale' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->intended_scale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to drawing_revision to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, presentation_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to presentation_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, presentation_area* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to presentation_area"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, drawing_sheet_revision* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to drawing_sheet_revision"); } do { // convert the 'revision_identifier' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->revision_identifier, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to drawing_sheet_revision to be a `identifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, drawing_sheet_revision_sequence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to drawing_sheet_revision_sequence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, drawing_sheet_revision_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to drawing_sheet_revision_usage"); } do { // convert the 'sheet_number' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sheet_number, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to drawing_sheet_revision_usage to be a `identifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, edge* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to edge"); } do { // convert the 'edge_start' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->edge_start, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to edge to be a `vertex`")); } - } while (0); - do { // convert the 'edge_end' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->edge_end, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to edge to be a `vertex`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, edge_based_wireframe_model* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to edge_based_wireframe_model"); } do { // convert the 'ebwm_boundary' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->ebwm_boundary, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to edge_based_wireframe_model to be a `SET [1:?] OF connected_edge_set`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, edge_based_wireframe_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to edge_based_wireframe_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, edge_blended_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to edge_blended_solid"); } do { // convert the 'blended_edges' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->blended_edges, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to edge_blended_solid to be a `LIST [1:?] OF edge_curve`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, edge_curve* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to edge_curve"); } do { // convert the 'edge_geometry' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->edge_geometry, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to edge_curve to be a `curve`")); } - } while (0); - do { // convert the 'same_sense' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->same_sense, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to edge_curve to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, edge_loop* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, electric_charge_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to electric_charge_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, electric_charge_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to electric_charge_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, electric_current_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to electric_current_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, electric_current_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to electric_current_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, electric_potential_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to electric_potential_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, electric_potential_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to electric_potential_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, elementary_brep_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to elementary_brep_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ellipse* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to ellipse"); } do { // convert the 'semi_axis_1' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->semi_axis_1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to ellipse to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'semi_axis_2' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->semi_axis_2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to ellipse to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, energy_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to energy_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, energy_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to energy_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, property_definition* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to property_definition"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to property_definition to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to property_definition to be a `text`")); } - } while (0); - do { // convert the 'definition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->definition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to property_definition to be a `characterized_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, fact_type* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to fact_type"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, entity_assertion* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to entity_assertion"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, enum_reference_prefix* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to enum_reference_prefix"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, evaluated_characteristic* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, evaluated_degenerate_pcurve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to evaluated_degenerate_pcurve"); } do { // convert the 'equivalent_point' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->equivalent_point, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to evaluated_degenerate_pcurve to be a `cartesian_point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, evaluation_product_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to evaluation_product_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, event_occurrence* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to event_occurrence"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to event_occurrence to be a `identifier`")); } - } while (0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to event_occurrence to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to event_occurrence to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_concept_feature_category* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to product_concept_feature_category"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, exclusive_product_concept_feature_category* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to exclusive_product_concept_feature_category"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, uncertainty_qualifier* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to uncertainty_qualifier"); } do { // convert the 'measure_name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->measure_name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to uncertainty_qualifier to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to uncertainty_qualifier to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, standard_uncertainty* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to standard_uncertainty"); } do { // convert the 'uncertainty_value' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->uncertainty_value, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to standard_uncertainty to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, expanded_uncertainty* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to expanded_uncertainty"); } do { // convert the 'coverage_factor' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->coverage_factor, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to expanded_uncertainty to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, representation_item_relationship* in) -{ - size_t base = 0; - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to representation_item_relationship"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to representation_item_relationship to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to representation_item_relationship to be a `text`")); } - } while (0); - do { // convert the 'relating_representation_item' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->relating_representation_item, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to representation_item_relationship to be a `representation_item`")); } - } while (0); - do { // convert the 'related_representation_item' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->related_representation_item, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to representation_item_relationship to be a `representation_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, explicit_procedural_representation_item_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to explicit_procedural_representation_item_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, explicit_procedural_geometric_representation_item_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to explicit_procedural_geometric_representation_item_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, explicit_procedural_representation_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to explicit_procedural_representation_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, explicit_procedural_shape_representation_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to explicit_procedural_shape_representation_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, expression_conversion_based_unit* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, extension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to extension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, extent* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to extent"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, external_source* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to external_source"); } do { // convert the 'source_id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->source_id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to external_source to be a `source_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, external_class_library* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to external_class_library"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_class* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_colour* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_context_dependent_unit* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_conversion_based_unit* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_currency* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_item* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to externally_defined_item"); } do { // convert the 'item_id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->item_id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to externally_defined_item to be a `source_item`")); } - } while (0); - do { // convert the 'source' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->source, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to externally_defined_item to be a `external_source`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_curve_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to externally_defined_curve_font"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_dimension_definition* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_general_property* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_hatch_style* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_marker* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, picture_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to picture_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_picture_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to externally_defined_picture_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_representation_item* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_string* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to externally_defined_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_terminator_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to externally_defined_terminator_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_text_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to externally_defined_text_font"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_tile* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to externally_defined_tile"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, externally_defined_tile_style* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, swept_area_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to swept_area_solid"); } do { // convert the 'swept_area' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->swept_area, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to swept_area_solid to be a `curve_bounded_surface`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, extruded_area_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to extruded_area_solid"); } do { // convert the 'extruded_direction' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->extruded_direction, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to extruded_area_solid to be a `direction`")); } - } while (0); - do { // convert the 'depth' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->depth, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to extruded_area_solid to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, swept_face_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to swept_face_solid"); } do { // convert the 'swept_face' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->swept_face, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to swept_face_solid to be a `face_surface`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, extruded_face_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to extruded_face_solid"); } do { // convert the 'extruded_direction' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->extruded_direction, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to extruded_face_solid to be a `direction`")); } - } while (0); - do { // convert the 'depth' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->depth, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to extruded_face_solid to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, extruded_face_solid_with_trim_conditions* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 10) { throw STEP::TypeError("expected 10 arguments to extruded_face_solid_with_trim_conditions"); } do { // convert the 'first_trim_condition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->first_trim_condition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to extruded_face_solid_with_trim_conditions to be a `trim_condition_select`")); } - } while (0); - do { // convert the 'second_trim_condition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->second_trim_condition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to extruded_face_solid_with_trim_conditions to be a `trim_condition_select`")); } - } while (0); - do { // convert the 'first_trim_intent' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->first_trim_intent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to extruded_face_solid_with_trim_conditions to be a `trim_intent`")); } - } while (0); - do { // convert the 'second_trim_intent' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->second_trim_intent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to extruded_face_solid_with_trim_conditions to be a `trim_intent`")); } - } while (0); - do { // convert the 'first_offset' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4] = true; break; } - try { GenericConvert(in->first_offset, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to extruded_face_solid_with_trim_conditions to be a `non_negative_length_measure`")); } - } while (0); - do { // convert the 'second_offset' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[5] = true; break; } - try { GenericConvert(in->second_offset, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to extruded_face_solid_with_trim_conditions to be a `non_negative_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, extruded_face_solid_with_draft_angle* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 11) { throw STEP::TypeError("expected 11 arguments to extruded_face_solid_with_draft_angle"); } do { // convert the 'draft_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->draft_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 10 to extruded_face_solid_with_draft_angle to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, extruded_face_solid_with_multiple_draft_angles* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 11) { throw STEP::TypeError("expected 11 arguments to extruded_face_solid_with_multiple_draft_angles"); } do { // convert the 'draft_angles' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->draft_angles, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 10 to extruded_face_solid_with_multiple_draft_angles to be a `LIST [2:?] OF plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, face* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to face"); } do { // convert the 'bounds' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->bounds, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to face to be a `SET [1:?] OF face_bound`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, face_based_surface_model* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to face_based_surface_model"); } do { // convert the 'fbsm_faces' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->fbsm_faces, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to face_based_surface_model to be a `SET [1:?] OF connected_face_set`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, face_bound* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to face_bound"); } do { // convert the 'bound' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->bound, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to face_bound to be a `loop`")); } - } while (0); - do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to face_bound to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, face_outer_bound* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to face_outer_bound"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, faceted_brep* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to faceted_brep"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, faceted_brep_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to faceted_brep_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, fill_area_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to fill_area_style"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to fill_area_style to be a `label`")); } - } while (0); - do { // convert the 'fill_styles' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->fill_styles, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to fill_area_style to be a `SET [1:?] OF fill_style_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, fill_area_style_hatching* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to fill_area_style_hatching"); } do { // convert the 'hatch_line_appearance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->hatch_line_appearance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to fill_area_style_hatching to be a `curve_style`")); } - } while (0); - do { // convert the 'start_of_next_hatch_line' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->start_of_next_hatch_line, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to fill_area_style_hatching to be a `one_direction_repeat_factor`")); } - } while (0); - do { // convert the 'point_of_reference_hatch_line' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->point_of_reference_hatch_line, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to fill_area_style_hatching to be a `cartesian_point`")); } - } while (0); - do { // convert the 'pattern_start' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->pattern_start, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to fill_area_style_hatching to be a `cartesian_point`")); } - } while (0); - do { // convert the 'hatch_line_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->hatch_line_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to fill_area_style_hatching to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, fill_area_style_tile_coloured_region* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to fill_area_style_tile_coloured_region"); } do { // convert the 'closed_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->closed_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to fill_area_style_tile_coloured_region to be a `curve_or_annotation_curve_occurrence`")); } - } while (0); - do { // convert the 'region_colour' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->region_colour, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to fill_area_style_tile_coloured_region to be a `colour`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, fill_area_style_tile_curve_with_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to fill_area_style_tile_curve_with_style"); } do { // convert the 'styled_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->styled_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to fill_area_style_tile_curve_with_style to be a `annotation_curve_occurrence`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, fill_area_style_tile_symbol_with_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to fill_area_style_tile_symbol_with_style"); } do { // convert the 'symbol' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->symbol, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to fill_area_style_tile_symbol_with_style to be a `annotation_symbol_occurrence`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, fill_area_style_tiles* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to fill_area_style_tiles"); } do { // convert the 'tiling_pattern' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->tiling_pattern, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to fill_area_style_tiles to be a `two_direction_repeat_factor`")); } - } while (0); - do { // convert the 'tiles' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->tiles, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to fill_area_style_tiles to be a `SET [1:?] OF fill_area_style_tile_shape_select`")); } - } while (0); - do { // convert the 'tiling_scale' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->tiling_scale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to fill_area_style_tiles to be a `positive_ratio_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_representation_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to shape_representation_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, flat_pattern_ply_representation_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to flat_pattern_ply_representation_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, flatness_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to flatness_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, force_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to force_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, force_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to force_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, forward_chaining_rule* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to forward_chaining_rule"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, forward_chaining_rule_premise* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, frequency_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to frequency_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, frequency_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to frequency_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, func* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to func"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, functional_breakdown_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to functional_breakdown_context"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, functional_element_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to functional_element_usage"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, general_material_property* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to general_material_property"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, simple_generic_expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, generic_literal* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, generic_variable* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_alignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to geometric_alignment"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_set* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to geometric_set"); } do { // convert the 'elements' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->elements, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to geometric_set to be a `SET [1:?] OF geometric_set_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_curve_set* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to geometric_curve_set"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_intersection* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to geometric_intersection"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_item_specific_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to geometric_item_specific_usage"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, geometric_model_element_relationship* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, representation_context* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to representation_context"); } do { // convert the 'context_identifier' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->context_identifier, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to representation_context to be a `identifier`")); } - } while (0); - do { // convert the 'context_type' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->context_type, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to representation_context to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_representation_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to geometric_representation_context"); } do { // convert the 'coordinate_space_dimension' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->coordinate_space_dimension, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to geometric_representation_context to be a `dimension_count`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometric_tolerance_with_defined_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to geometric_tolerance_with_defined_unit"); } do { // convert the 'unit_size' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->unit_size, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to geometric_tolerance_with_defined_unit to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometrical_tolerance_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to geometrical_tolerance_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometrically_bounded_2d_wireframe_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to geometrically_bounded_2d_wireframe_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometrically_bounded_surface_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to geometrically_bounded_surface_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, geometrically_bounded_wireframe_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to geometrically_bounded_wireframe_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, global_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to global_assignment"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, global_uncertainty_assigned_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to global_uncertainty_assigned_context"); } do { // convert the 'uncertainty' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->uncertainty, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to global_uncertainty_assigned_context to be a `SET [1:?] OF uncertainty_measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, global_unit_assigned_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to global_unit_assigned_context"); } do { // convert the 'units' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->units, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to global_unit_assigned_context to be a `SET [1:?] OF unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ground_fact* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to ground_fact"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, hardness_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to hardness_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, hidden_element_over_riding_styled_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to hidden_element_over_riding_styled_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, hyperbola* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to hyperbola"); } do { // convert the 'semi_axis' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->semi_axis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to hyperbola to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'semi_imag_axis' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->semi_imag_axis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to hyperbola to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, illuminance_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to illuminance_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, illuminance_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to illuminance_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, included_text_block* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to included_text_block"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, inclusion_product_concept_feature* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to inclusion_product_concept_feature"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, user_selected_elements* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to user_selected_elements"); } do { // convert the 'picked_items' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->picked_items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to user_selected_elements to be a `SET [1:?] OF representation_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, indirectly_selected_elements* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to indirectly_selected_elements"); } do { // convert the 'indirectly_picked_items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->indirectly_picked_items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to indirectly_selected_elements to be a `SET [1:?] OF representation_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, indirectly_selected_shape_elements* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, inductance_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to inductance_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, inductance_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to inductance_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, information_right* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to information_right"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, information_usage_right* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to information_usage_right"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, instance_usage_context_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to instance_usage_context_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to instance_usage_context_assignment to be a `SET [1:?] OF instance_usage_context_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, instanced_feature* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, literal_number* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to literal_number"); } do { // convert the 'the_value' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->the_value, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to literal_number to be a `NUMBER`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, int_literal* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to int_literal"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, integer_representation_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to surface_curve"); } do { // convert the 'curve_3d' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->curve_3d, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_curve to be a `curve`")); } - } while (0); - do { // convert the 'associated_geometry' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->associated_geometry, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_curve to be a `LIST [1:2] OF pcurve_or_surface`")); } - } while (0); - do { // convert the 'master_representation' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->master_representation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to surface_curve to be a `preferred_surface_curve_representation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, intersection_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to intersection_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, interval_expression* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, iso4217_currency* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to iso4217_currency"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, known_source* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, laid_defined_transformation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to laid_defined_transformation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, language* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to language"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, leader_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to leader_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, leader_directed_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to leader_directed_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, leader_directed_dimension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to leader_directed_dimension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, leader_terminator* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to leader_terminator"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, length_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to length_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, length_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to length_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, light_source* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to light_source"); } do { // convert the 'light_colour' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->light_colour, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to light_source to be a `colour`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, light_source_ambient* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to light_source_ambient"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, light_source_directional* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to light_source_directional"); } do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to light_source_directional to be a `direction`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, light_source_positional* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to light_source_positional"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to light_source_positional to be a `cartesian_point`")); } - } while (0); - do { // convert the 'constant_attenuation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->constant_attenuation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to light_source_positional to be a `REAL`")); } - } while (0); - do { // convert the 'distance_attenuation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->distance_attenuation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to light_source_positional to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, light_source_spot* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to light_source_spot"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to light_source_spot to be a `cartesian_point`")); } - } while (0); - do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to light_source_spot to be a `direction`")); } - } while (0); - do { // convert the 'concentration_exponent' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->concentration_exponent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to light_source_spot to be a `REAL`")); } - } while (0); - do { // convert the 'constant_attenuation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->constant_attenuation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to light_source_spot to be a `REAL`")); } - } while (0); - do { // convert the 'distance_attenuation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->distance_attenuation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to light_source_spot to be a `REAL`")); } - } while (0); - do { // convert the 'spread_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->spread_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to light_source_spot to be a `positive_plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, line* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to line"); } do { // convert the 'pnt' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->pnt, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to line to be a `cartesian_point`")); } - } while (0); - do { // convert the 'dir' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->dir, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to line to be a `vector`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, line_profile_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to line_profile_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, linear_dimension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to linear_dimension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, simple_clause* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to simple_clause"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, literal_conjunction* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to literal_conjunction"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, literal_disjunction* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to literal_disjunction"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, logical_literal* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to logical_literal"); } do { // convert the 'lit_value' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->lit_value, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to logical_literal to be a `LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB&, const LIST& params, logical_representation_item* ) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, loop* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to loop"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, loss_tangent_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to loss_tangent_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, lot_effectivity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to lot_effectivity"); } do { // convert the 'effectivity_lot_id' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->effectivity_lot_id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to lot_effectivity to be a `identifier`")); } - } while (0); - do { // convert the 'effectivity_lot_size' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->effectivity_lot_size, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to lot_effectivity to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, luminous_flux_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to luminous_flux_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, luminous_flux_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to luminous_flux_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, luminous_intensity_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to luminous_intensity_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, luminous_intensity_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to luminous_intensity_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, magnetic_flux_density_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to magnetic_flux_density_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, magnetic_flux_density_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to magnetic_flux_density_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, magnetic_flux_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to magnetic_flux_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, magnetic_flux_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to magnetic_flux_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, make_from_usage_option* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to make_from_usage_option"); } do { // convert the 'ranking' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->ranking, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to make_from_usage_option to be a `INTEGER`")); } - } while (0); - do { // convert the 'ranking_rationale' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->ranking_rationale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to make_from_usage_option to be a `text`")); } - } while (0); - do { // convert the 'quantity' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->quantity, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to make_from_usage_option to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, manifold_subsurface_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to manifold_subsurface_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, manifold_surface_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to manifold_surface_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mass_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to mass_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mass_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to mass_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, material_property* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to material_property"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, property_definition_representation* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to property_definition_representation"); } do { // convert the 'definition' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->definition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to property_definition_representation to be a `represented_definition`")); } - } while (0); - do { // convert the 'used_representation' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->used_representation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to property_definition_representation to be a `representation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, material_property_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to material_property_representation"); } do { // convert the 'dependent_environment' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->dependent_environment, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to material_property_representation to be a `data_environment`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, measure_representation_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to product_context"); } do { // convert the 'discipline_type' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->discipline_type, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_context to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mechanical_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to mechanical_context"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mechanical_design_and_draughting_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to mechanical_design_and_draughting_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mechanical_design_geometric_presentation_area* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to mechanical_design_geometric_presentation_area"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mechanical_design_geometric_presentation_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to mechanical_design_geometric_presentation_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mechanical_design_presentation_representation_with_draughting* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to mechanical_design_presentation_representation_with_draughting"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mechanical_design_shaded_presentation_area* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to mechanical_design_shaded_presentation_area"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, mechanical_design_shaded_presentation_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to mechanical_design_shaded_presentation_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, min_and_major_ply_orientation_basis* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, modified_geometric_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to modified_geometric_tolerance"); } do { // convert the 'modifier' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->modifier, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to modified_geometric_tolerance to be a `limit_condition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, modified_solid_with_placed_configuration* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to modified_solid_with_placed_configuration"); } do { // convert the 'placing' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->placing, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to modified_solid_with_placed_configuration to be a `axis2_placement_3d`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, moments_of_inertia_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to moments_of_inertia_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, multi_language_attribute_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to multi_language_attribute_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to multi_language_attribute_assignment to be a `SET [1:?] OF multi_language_attribute_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, multiple_arity_boolean_expression* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, multiple_arity_generic_expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to multiple_arity_generic_expression"); } do { // convert the 'operands' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->operands, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to multiple_arity_generic_expression to be a `LIST [2:?] OF generic_expression`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, multiple_arity_numeric_expression* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, next_assembly_usage_occurrence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to next_assembly_usage_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, non_manifold_surface_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to non_manifold_surface_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, null_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to null_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, numeric_expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, offset_curve_2d* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to offset_curve_2d"); } do { // convert the 'basis_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to offset_curve_2d to be a `curve`")); } - } while (0); - do { // convert the 'distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to offset_curve_2d to be a `length_measure`")); } - } while (0); - do { // convert the 'self_intersect' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->self_intersect, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to offset_curve_2d to be a `LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, offset_curve_3d* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to offset_curve_3d"); } do { // convert the 'basis_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to offset_curve_3d to be a `curve`")); } - } while (0); - do { // convert the 'distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to offset_curve_3d to be a `length_measure`")); } - } while (0); - do { // convert the 'self_intersect' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->self_intersect, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to offset_curve_3d to be a `LOGICAL`")); } - } while (0); - do { // convert the 'ref_direction' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->ref_direction, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to offset_curve_3d to be a `direction`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, offset_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to offset_surface"); } do { // convert the 'basis_surface' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to offset_surface to be a `surface`")); } - } while (0); - do { // convert the 'distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to offset_surface to be a `length_measure`")); } - } while (0); - do { // convert the 'self_intersect' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->self_intersect, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to offset_surface to be a `LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, one_direction_repeat_factor* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to one_direction_repeat_factor"); } do { // convert the 'repeat_factor' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->repeat_factor, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to one_direction_repeat_factor to be a `vector`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, open_shell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to open_shell"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ordinal_date* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to ordinal_date"); } do { // convert the 'day_component' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->day_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to ordinal_date to be a `day_in_year_number`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, projection_directed_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to projection_directed_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ordinate_dimension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to ordinate_dimension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, organizational_address* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 14) { throw STEP::TypeError("expected 14 arguments to organizational_address"); } do { // convert the 'organizations' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->organizations, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 12 to organizational_address to be a `SET [1:?] OF organization`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 13 to organizational_address to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, oriented_closed_shell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to oriented_closed_shell"); } do { // convert the 'closed_shell_element' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->closed_shell_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to oriented_closed_shell to be a `closed_shell`")); } - } while (0); - do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to oriented_closed_shell to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, oriented_edge* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to oriented_edge"); } do { // convert the 'edge_element' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->edge_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to oriented_edge to be a `edge`")); } - } while (0); - do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to oriented_edge to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, oriented_face* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to oriented_face"); } do { // convert the 'face_element' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->face_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to oriented_face to be a `face`")); } - } while (0); - do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to oriented_face to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, oriented_open_shell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to oriented_open_shell"); } do { // convert the 'open_shell_element' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->open_shell_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to oriented_open_shell to be a `open_shell`")); } - } while (0); - do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to oriented_open_shell to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, path* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to path"); } do { // convert the 'edge_list' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->edge_list, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to path to be a `LIST [1:?] OF oriented_edge`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, oriented_path* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to oriented_path"); } do { // convert the 'path_element' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->path_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to oriented_path to be a `path`")); } - } while (0); - do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to oriented_path to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, oriented_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to oriented_surface"); } do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to oriented_surface to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, outer_boundary_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to outer_boundary_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, package_product_concept_feature* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to package_product_concept_feature"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, parabola* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to parabola"); } do { // convert the 'focal_dist' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->focal_dist, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to parabola to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, parallel_offset* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to parallel_offset"); } do { // convert the 'offset' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->offset, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to parallel_offset to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, parallelism_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to parallelism_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, parametric_representation_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to parametric_representation_context"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, partial_document_with_structured_text_representation_assignment* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pcurve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to pcurve"); } do { // convert the 'basis_surface' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to pcurve to be a `surface`")); } - } while (0); - do { // convert the 'reference_to_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->reference_to_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to pcurve to be a `definitional_representation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, percentage_laminate_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to percentage_laminate_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, zone_structural_makeup* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to zone_structural_makeup"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, percentage_laminate_table* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to percentage_laminate_table"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, percentage_ply_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to percentage_ply_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, perpendicular_to* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to perpendicular_to"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, perpendicularity_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to perpendicularity_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, person_and_organization_address* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, personal_address* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 14) { throw STEP::TypeError("expected 14 arguments to personal_address"); } do { // convert the 'people' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->people, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 12 to personal_address to be a `SET [1:?] OF person`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 13 to personal_address to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, physical_breakdown_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to physical_breakdown_context"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, physical_element_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to physical_element_usage"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, presentation_view* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to presentation_view"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, picture_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to picture_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, placed_datum_target_feature* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to placed_datum_target_feature"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, placed_feature* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to placed_feature"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, planar_extent* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to planar_extent"); } do { // convert the 'size_in_x' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->size_in_x, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to planar_extent to be a `length_measure`")); } - } while (0); - do { // convert the 'size_in_y' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->size_in_y, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to planar_extent to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, planar_box* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to planar_box"); } do { // convert the 'placement' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->placement, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to planar_box to be a `axis2_placement`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, plane* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to plane"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, plane_angle_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to plane_angle_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, plane_angle_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to plane_angle_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ply_laminate_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to ply_laminate_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ply_laminate_sequence_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to ply_laminate_sequence_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ply_laminate_table* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to ply_laminate_table"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, point_and_vector* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, point_on_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to point_on_curve"); } do { // convert the 'basis_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to point_on_curve to be a `curve`")); } - } while (0); - do { // convert the 'point_parameter' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->point_parameter, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to point_on_curve to be a `parameter_value`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, point_on_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to point_on_surface"); } do { // convert the 'basis_surface' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to point_on_surface to be a `surface`")); } - } while (0); - do { // convert the 'point_parameter_u' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->point_parameter_u, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to point_on_surface to be a `parameter_value`")); } - } while (0); - do { // convert the 'point_parameter_v' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->point_parameter_v, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to point_on_surface to be a `parameter_value`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, point_path* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, point_replica* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to point_replica"); } do { // convert the 'parent_pt' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_pt, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to point_replica to be a `point`")); } - } while (0); - do { // convert the 'transformation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->transformation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to point_replica to be a `cartesian_transformation_operator`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, point_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to point_style"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to point_style to be a `label`")); } - } while (0); - do { // convert the 'marker' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->marker, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to point_style to be a `marker_select`")); } - } while (0); - do { // convert the 'marker_size' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->marker_size, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to point_style to be a `size_select`")); } - } while (0); - do { // convert the 'marker_colour' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->marker_colour, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to point_style to be a `colour`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, polar_complex_number_literal* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to polar_complex_number_literal"); } do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to polar_complex_number_literal to be a `REAL`")); } - } while (0); - do { // convert the 'angle' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to polar_complex_number_literal to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, poly_loop* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to poly_loop"); } do { // convert the 'polygon' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->polygon, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to poly_loop to be a `LIST [3:?] OF cartesian_point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, polyline* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to polyline"); } do { // convert the 'points' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->points, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to polyline to be a `LIST [2:?] OF cartesian_point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, position_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to position_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, positioned_sketch* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to positioned_sketch"); } do { // convert the 'sketch_basis' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sketch_basis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to positioned_sketch to be a `sketch_basis_select`")); } - } while (0); - do { // convert the 'auxiliary_elements' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->auxiliary_elements, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to positioned_sketch to be a `SET [0:?] OF auxiliary_geometric_representation_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, power_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to power_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, power_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to power_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_dimension_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_dimension_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_geometrical_tolerance_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_geometrical_tolerance_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_marker* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_marker"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_point_marker_symbol* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_surface_condition_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_surface_condition_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_surface_side_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_surface_side_style"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_terminator_symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_terminator_symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pre_defined_tile* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pre_defined_tile"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, predefined_picture_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to predefined_picture_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, presentation_style_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to presentation_style_assignment"); } do { // convert the 'styles' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->styles, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to presentation_style_assignment to be a `SET [1:?] OF presentation_style_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, presentation_style_by_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to presentation_style_by_context"); } do { // convert the 'style_context' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style_context, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to presentation_style_by_context to be a `style_context_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pressure_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to pressure_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, pressure_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to pressure_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, procedural_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to procedural_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, procedural_representation_sequence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to procedural_representation_sequence"); } do { // convert the 'elements' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->elements, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to procedural_representation_sequence to be a `LIST [1:?] OF representation_item`")); } - } while (0); - do { // convert the 'suppressed_items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->suppressed_items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to procedural_representation_sequence to be a `SET [0:?] OF representation_item`")); } - } while (0); - do { // convert the 'rationale' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->rationale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to procedural_representation_sequence to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, procedural_shape_representation* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, procedural_shape_representation_sequence* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_category* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to product_category"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to product_category to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_category to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, product_class* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_concept_context* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to product_concept_context"); } do { // convert the 'market_segment_type' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->market_segment_type, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_concept_context to be a `label`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_concept_feature_category_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to product_concept_feature_category_usage"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_concept_feature_category_usage to be a `SET [1:?] OF category_usage_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_element_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to product_definition_element_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_formation* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to product_definition_formation"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to product_definition_formation to be a `identifier`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_definition_formation to be a `text`")); } - } while (0); - do { // convert the 'of_product' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->of_product, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_definition_formation to be a `product`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_formation_with_specified_source* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to product_definition_formation_with_specified_source"); } do { // convert the 'make_or_buy' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->make_or_buy, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to product_definition_formation_with_specified_source to be a `source`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_group_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to product_definition_group_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to product_definition_group_assignment to be a `SET [1:1] OF product_definition_or_product_definition_relationship`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_shape* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to product_definition_shape"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_definition_with_associated_documents* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to product_definition_with_associated_documents"); } do { // convert the 'documentation_ids' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->documentation_ids, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to product_definition_with_associated_documents to be a `SET [1:?] OF document`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, product_identification* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_material_composition_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to product_material_composition_relationship"); } do { // convert the 'class' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->class_, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to product_material_composition_relationship to be a `label`")); } - } while (0); - do { // convert the 'constituent_amount' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->constituent_amount, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to product_material_composition_relationship to be a `SET [1:?] OF characterized_product_composition_value`")); } - } while (0); - do { // convert the 'composition_basis' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->composition_basis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to product_material_composition_relationship to be a `label`")); } - } while (0); - do { // convert the 'determination_method' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->determination_method, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to product_material_composition_relationship to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, product_related_product_category* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to product_related_product_category"); } do { // convert the 'products' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->products, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to product_related_product_category to be a `SET [1:?] OF product`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, product_specification* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, tolerance_zone_definition* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to tolerance_zone_definition"); } do { // convert the 'zone' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->zone, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to tolerance_zone_definition to be a `tolerance_zone`")); } - } while (0); - do { // convert the 'boundaries' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->boundaries, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to tolerance_zone_definition to be a `SET [1:?] OF shape_aspect`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, projected_zone_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to projected_zone_definition"); } do { // convert the 'projection_end' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->projection_end, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to projected_zone_definition to be a `shape_aspect`")); } - } while (0); - do { // convert the 'projected_length' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->projected_length, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to projected_zone_definition to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, projection_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to projection_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, promissory_usage_occurrence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to promissory_usage_occurrence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, qualified_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to qualified_representation_item"); } do { // convert the 'qualifiers' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->qualifiers, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to qualified_representation_item to be a `SET [1:?] OF value_qualifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, qualitative_uncertainty* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to qualitative_uncertainty"); } do { // convert the 'uncertainty_value' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->uncertainty_value, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to qualitative_uncertainty to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, quantified_assembly_component_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to quantified_assembly_component_usage"); } do { // convert the 'quantity' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->quantity, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to quantified_assembly_component_usage to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, quasi_uniform_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to quasi_uniform_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, quasi_uniform_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to quasi_uniform_surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, radioactivity_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to radioactivity_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, radioactivity_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to radioactivity_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, radius_dimension* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to radius_dimension"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, range_characteristic* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ratio_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to ratio_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rational_b_spline_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to rational_b_spline_curve"); } do { // convert the 'weights_data' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->weights_data, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to rational_b_spline_curve to be a `LIST [2:?] OF REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rational_b_spline_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to rational_b_spline_surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, rational_representation_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, real_literal* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to real_literal"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, real_representation_item* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rectangular_composite_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to rectangular_composite_surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rectangular_trimmed_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to rectangular_trimmed_surface"); } do { // convert the 'basis_surface' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to rectangular_trimmed_surface to be a `surface`")); } - } while (0); - do { // convert the 'u1' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->u1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to rectangular_trimmed_surface to be a `parameter_value`")); } - } while (0); - do { // convert the 'u2' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->u2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to rectangular_trimmed_surface to be a `parameter_value`")); } - } while (0); - do { // convert the 'v1' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->v1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to rectangular_trimmed_surface to be a `parameter_value`")); } - } while (0); - do { // convert the 'v2' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->v2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to rectangular_trimmed_surface to be a `parameter_value`")); } - } while (0); - do { // convert the 'usense' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->usense, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to rectangular_trimmed_surface to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'vsense' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->vsense, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to rectangular_trimmed_surface to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, referenced_modified_datum* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to referenced_modified_datum"); } do { // convert the 'modifier' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->modifier, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to referenced_modified_datum to be a `limit_condition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, relative_event_occurrence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to relative_event_occurrence"); } do { // convert the 'base_event' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->base_event, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to relative_event_occurrence to be a `event_occurrence`")); } - } while (0); - do { // convert the 'offset' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->offset, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to relative_event_occurrence to be a `time_measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, rep_item_group* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, reparametrised_composite_curve_segment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to reparametrised_composite_curve_segment"); } do { // convert the 'param_length' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->param_length, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to reparametrised_composite_curve_segment to be a `parameter_value`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, representation_relationship_with_transformation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to representation_relationship_with_transformation"); } do { // convert the 'transformation_operator' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->transformation_operator, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to representation_relationship_with_transformation to be a `transformation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, requirement_assigned_object* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to requirement_assigned_object"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to requirement_assigned_object to be a `SET [1:1] OF requirement_assigned_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, requirement_assignment* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, requirement_source* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to requirement_source"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, requirement_view_definition_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to requirement_view_definition_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, resistance_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to resistance_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, resistance_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to resistance_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, revolved_area_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to revolved_area_solid"); } do { // convert the 'axis' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->axis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to revolved_area_solid to be a `axis1_placement`")); } - } while (0); - do { // convert the 'angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to revolved_area_solid to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, revolved_face_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to revolved_face_solid"); } do { // convert the 'axis' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->axis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to revolved_face_solid to be a `axis1_placement`")); } - } while (0); - do { // convert the 'angle' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to revolved_face_solid to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, revolved_face_solid_with_trim_conditions* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to revolved_face_solid_with_trim_conditions"); } do { // convert the 'first_trim_condition' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->first_trim_condition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to revolved_face_solid_with_trim_conditions to be a `trim_condition_select`")); } - } while (0); - do { // convert the 'second_trim_condition' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->second_trim_condition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to revolved_face_solid_with_trim_conditions to be a `trim_condition_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, right_angular_wedge* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to right_angular_wedge"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to right_angular_wedge to be a `axis2_placement_3d`")); } - } while (0); - do { // convert the 'x' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->x, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to right_angular_wedge to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'y' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->y, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to right_angular_wedge to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'z' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->z, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to right_angular_wedge to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'ltx' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->ltx, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to right_angular_wedge to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, right_circular_cone* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to right_circular_cone"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to right_circular_cone to be a `axis1_placement`")); } - } while (0); - do { // convert the 'height' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->height, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to right_circular_cone to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to right_circular_cone to be a `length_measure`")); } - } while (0); - do { // convert the 'semi_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->semi_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to right_circular_cone to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, right_circular_cylinder* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to right_circular_cylinder"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to right_circular_cylinder to be a `axis1_placement`")); } - } while (0); - do { // convert the 'height' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->height, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to right_circular_cylinder to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to right_circular_cylinder to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, right_to_usage_association* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to right_to_usage_association"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, roundness_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to roundness_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, row_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to row_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, row_value* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to row_value"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, row_variable* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_action* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to rule_action"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_condition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to rule_condition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_set* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to rule_set"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_set_group* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to rule_set_group"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_superseded_assignment* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to rule_superseded_assignment"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to rule_superseded_assignment to be a `SET [1:?] OF rule_superseded_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, rule_supersedence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to rule_supersedence"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_curve_swept_area_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to surface_curve_swept_area_solid"); } do { // convert the 'directrix' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->directrix, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_curve_swept_area_solid to be a `curve`")); } - } while (0); - do { // convert the 'start_param' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->start_param, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to surface_curve_swept_area_solid to be a `REAL`")); } - } while (0); - do { // convert the 'end_param' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->end_param, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to surface_curve_swept_area_solid to be a `REAL`")); } - } while (0); - do { // convert the 'reference_surface' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->reference_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to surface_curve_swept_area_solid to be a `surface`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, ruled_surface_swept_area_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to ruled_surface_swept_area_solid"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, runout_zone_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to runout_zone_definition"); } do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to runout_zone_definition to be a `runout_zone_orientation`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, runout_zone_orientation* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to runout_zone_orientation"); } do { // convert the 'angle' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to runout_zone_orientation to be a `measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, runout_zone_orientation_reference_direction* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to runout_zone_orientation_reference_direction"); } do { // convert the 'orientation_defining_relationship' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation_defining_relationship, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to runout_zone_orientation_reference_direction to be a `shape_aspect_relationship`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, satisfied_requirement* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to satisfied_requirement"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to satisfied_requirement to be a `SET [1:1] OF product_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, satisfies_requirement* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to satisfies_requirement"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, satisfying_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to satisfying_item"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to satisfying_item to be a `SET [1:1] OF requirement_satisfaction_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, scalar_variable* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, scattering_parameter* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to scattering_parameter"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, sculptured_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to sculptured_solid"); } do { // convert the 'sculpturing_element' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sculpturing_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to sculptured_solid to be a `generalized_surface_select`")); } - } while (0); - do { // convert the 'positive_side' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->positive_side, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to sculptured_solid to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, seam_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to seam_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, serial_numbered_effectivity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to serial_numbered_effectivity"); } do { // convert the 'effectivity_start_id' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->effectivity_start_id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to serial_numbered_effectivity to be a `identifier`")); } - } while (0); - do { // convert the 'effectivity_end_id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->effectivity_end_id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to serial_numbered_effectivity to be a `identifier`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_aspect_associativity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to shape_aspect_associativity"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_aspect_deriving_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to shape_aspect_deriving_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_definition_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to shape_definition_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_dimension_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to shape_dimension_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_feature_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to shape_feature_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shape_representation_with_parameters* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to shape_representation_with_parameters"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shell_based_surface_model* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to shell_based_surface_model"); } do { // convert the 'sbsm_boundary' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sbsm_boundary, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to shell_based_surface_model to be a `SET [1:?] OF shell`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shell_based_wireframe_model* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to shell_based_wireframe_model"); } do { // convert the 'sbwm_boundary' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sbwm_boundary, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to shell_based_wireframe_model to be a `SET [1:?] OF shell`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, shell_based_wireframe_shape_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to shell_based_wireframe_shape_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, si_absorbed_dose_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_capacitance_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_conductance_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_dose_equivalent_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_electric_charge_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_electric_potential_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_energy_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_force_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_frequency_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_illuminance_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_inductance_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_magnetic_flux_density_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_magnetic_flux_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_power_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_pressure_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_radioactivity_unit* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_resistance_unit* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, si_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to si_unit"); } do { // convert the 'prefix' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->prefix, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to si_unit to be a `si_prefix`")); } - } while (0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to si_unit to be a `si_unit_name`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, simple_boolean_expression* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, simple_numeric_expression* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, slash_expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, smeared_material_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to smeared_material_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_angle_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to solid_angle_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_angle_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to solid_angle_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_curve_font* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to solid_curve_font"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_replica* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to solid_replica"); } do { // convert the 'parent_solid' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_solid, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to solid_replica to be a `solid_model`")); } - } while (0); - do { // convert the 'transformation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->transformation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to solid_replica to be a `cartesian_transformation_operator_3d`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_chamfered_edges* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to solid_with_chamfered_edges"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_angle_based_chamfer* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to solid_with_angle_based_chamfer"); } do { // convert the 'offset_distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->offset_distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to solid_with_angle_based_chamfer to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'left_offset' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->left_offset, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_angle_based_chamfer to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'offset_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->offset_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_angle_based_chamfer to be a `positive_plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_shape_element_pattern* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to solid_with_shape_element_pattern"); } do { // convert the 'replicated_element' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->replicated_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to solid_with_shape_element_pattern to be a `modified_solid_with_placed_configuration`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_circular_pattern* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to solid_with_circular_pattern"); } do { // convert the 'replicate_count' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->replicate_count, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_circular_pattern to be a `positive_integer`")); } - } while (0); - do { // convert the 'angular_spacing' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->angular_spacing, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_circular_pattern to be a `plane_angle_measure`")); } - } while (0); - do { // convert the 'radial_alignment' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->radial_alignment, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_circular_pattern to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'reference_point' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->reference_point, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_circular_pattern to be a `point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_depression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to solid_with_depression"); } do { // convert the 'depth' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->depth, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to solid_with_depression to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_pocket* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to solid_with_pocket"); } do { // convert the 'floor_blend_radius' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->floor_blend_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_pocket to be a `non_negative_length_measure`")); } - } while (0); - do { // convert the 'draft_angle' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->draft_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_pocket to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_circular_pocket* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to solid_with_circular_pocket"); } do { // convert the 'pocket_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->pocket_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_circular_pocket to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_protrusion* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to solid_with_protrusion"); } do { // convert the 'protrusion_height' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->protrusion_height, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to solid_with_protrusion to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'protrusion_draft_angle' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->protrusion_draft_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_protrusion to be a `plane_angle_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_circular_protrusion* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to solid_with_circular_protrusion"); } do { // convert the 'protrusion_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->protrusion_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_circular_protrusion to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_hole* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to solid_with_hole"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_stepped_round_hole* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to solid_with_stepped_round_hole"); } do { // convert the 'segments' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->segments, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_stepped_round_hole to be a `positive_integer`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_conical_bottom_round_hole* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to solid_with_conical_bottom_round_hole"); } do { // convert the 'semi_apex_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->semi_apex_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_conical_bottom_round_hole to be a `positive_plane_angle_measure`")); } - } while (0); - do { // convert the 'tip_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->tip_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_conical_bottom_round_hole to be a `non_negative_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_constant_radius_edge_blend* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to solid_with_constant_radius_edge_blend"); } do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to solid_with_constant_radius_edge_blend to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_slot* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to solid_with_slot"); } do { // convert the 'slot_width' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->slot_width, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_slot to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'closed_ends' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->closed_ends, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_slot to be a `LIST [2:2] OF LOGICAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_curved_slot* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to solid_with_curved_slot"); } do { // convert the 'slot_centreline' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->slot_centreline, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_curved_slot to be a `bounded_curve`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_double_offset_chamfer* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to solid_with_double_offset_chamfer"); } do { // convert the 'left_offset_distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->left_offset_distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to solid_with_double_offset_chamfer to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'right_offset_distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->right_offset_distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_double_offset_chamfer to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_flat_bottom_round_hole* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to solid_with_flat_bottom_round_hole"); } do { // convert the 'fillet_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->fillet_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_flat_bottom_round_hole to be a `non_negative_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_general_pocket* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to solid_with_general_pocket"); } do { // convert the 'profile' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->profile, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_general_pocket to be a `positioned_sketch`")); } - } while (0); - do { // convert the 'reference_point' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->reference_point, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_general_pocket to be a `point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_general_protrusion* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to solid_with_general_protrusion"); } do { // convert the 'profile' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->profile, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_general_protrusion to be a `positioned_sketch`")); } - } while (0); - do { // convert the 'reference_point' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->reference_point, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_general_protrusion to be a `point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_groove* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 10) { throw STEP::TypeError("expected 10 arguments to solid_with_groove"); } do { // convert the 'groove_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->groove_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_groove to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'groove_width' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->groove_width, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_groove to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'draft_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->draft_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_groove to be a `plane_angle_measure`")); } - } while (0); - do { // convert the 'floor_fillet_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->floor_fillet_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_groove to be a `non_negative_length_measure`")); } - } while (0); - do { // convert the 'external_groove' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->external_groove, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to solid_with_groove to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_incomplete_circular_pattern* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 10) { throw STEP::TypeError("expected 10 arguments to solid_with_incomplete_circular_pattern"); } do { // convert the 'omitted_instances' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->omitted_instances, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to solid_with_incomplete_circular_pattern to be a `SET [1:?] OF positive_integer`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_rectangular_pattern* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to solid_with_rectangular_pattern"); } do { // convert the 'row_count' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->row_count, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_rectangular_pattern to be a `positive_integer`")); } - } while (0); - do { // convert the 'column_count' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->column_count, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_rectangular_pattern to be a `positive_integer`")); } - } while (0); - do { // convert the 'row_spacing' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - try { GenericConvert(in->row_spacing, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_rectangular_pattern to be a `length_measure`")); } - } while (0); - do { // convert the 'column_spacing' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3] = true; break; } - try { GenericConvert(in->column_spacing, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_rectangular_pattern to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_incomplete_rectangular_pattern* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to solid_with_incomplete_rectangular_pattern"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_rectangular_pocket* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 10) { throw STEP::TypeError("expected 10 arguments to solid_with_rectangular_pocket"); } do { // convert the 'pocket_length' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->pocket_length, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_rectangular_pocket to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'pocket_width' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->pocket_width, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_rectangular_pocket to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'corner_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->corner_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to solid_with_rectangular_pocket to be a `non_negative_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_rectangular_protrusion* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to solid_with_rectangular_protrusion"); } do { // convert the 'protrusion_length' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->protrusion_length, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_rectangular_protrusion to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'protrusion_width' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->protrusion_width, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_rectangular_protrusion to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'protrusion_corner_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->protrusion_corner_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_rectangular_protrusion to be a `non_negative_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_single_offset_chamfer* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to solid_with_single_offset_chamfer"); } do { // convert the 'offset_distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->offset_distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to solid_with_single_offset_chamfer to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_spherical_bottom_round_hole* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to solid_with_spherical_bottom_round_hole"); } do { // convert the 'sphere_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sphere_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_spherical_bottom_round_hole to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_stepped_round_hole_and_conical_transitions* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to solid_with_stepped_round_hole_and_conical_transitions"); } do { // convert the 'conical_transitions' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->conical_transitions, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to solid_with_stepped_round_hole_and_conical_transitions to be a `SET [1:?] OF conical_stepped_hole_transition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_straight_slot* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to solid_with_straight_slot"); } do { // convert the 'slot_length' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->slot_length, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_straight_slot to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_tee_section_slot* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to solid_with_tee_section_slot"); } do { // convert the 'tee_section_width' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->tee_section_width, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_tee_section_slot to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'collar_depth' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->collar_depth, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_tee_section_slot to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_through_depression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to solid_with_through_depression"); } do { // convert the 'exit_faces' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->exit_faces, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to solid_with_through_depression to be a `SET [1:?] OF face_surface`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_trapezoidal_section_slot* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to solid_with_trapezoidal_section_slot"); } do { // convert the 'draft_angle' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->draft_angle, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to solid_with_trapezoidal_section_slot to be a `plane_angle_measure`")); } - } while (0); - do { // convert the 'floor_fillet_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->floor_fillet_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to solid_with_trapezoidal_section_slot to be a `non_negative_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, solid_with_variable_radius_edge_blend* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to solid_with_variable_radius_edge_blend"); } do { // convert the 'point_list' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->point_list, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to solid_with_variable_radius_edge_blend to be a `LIST [2:?] OF point`")); } - } while (0); - do { // convert the 'radius_list' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius_list, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to solid_with_variable_radius_edge_blend to be a `LIST [2:?] OF positive_length_measure`")); } - } while (0); - do { // convert the 'edge_function_list' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->edge_function_list, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to solid_with_variable_radius_edge_blend to be a `LIST [1:?] OF blend_radius_variation_type`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, source_for_requirement* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to source_for_requirement"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to source_for_requirement to be a `SET [1:1] OF requirement_source_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, sourced_requirement* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to sourced_requirement"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to sourced_requirement to be a `SET [1:1] OF product_definition`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, specification_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to specification_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, specified_higher_usage_occurrence* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 8) { throw STEP::TypeError("expected 8 arguments to specified_higher_usage_occurrence"); } do { // convert the 'upper_usage' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->upper_usage, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to specified_higher_usage_occurrence to be a `assembly_component_usage`")); } - } while (0); - do { // convert the 'next_usage' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->next_usage, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to specified_higher_usage_occurrence to be a `next_assembly_usage_occurrence`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, sphere* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to sphere"); } do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to sphere to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'centre' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->centre, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to sphere to be a `point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, spherical_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to spherical_surface"); } do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to spherical_surface to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, start_request* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to start_request"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to start_request to be a `SET [1:?] OF start_request_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, start_work* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to start_work"); } do { // convert the 'items' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->items, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to start_work to be a `SET [1:?] OF work_item`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, straightness_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to straightness_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, structured_dimension_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to structured_dimension_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, structured_text_composition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to structured_text_composition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, structured_text_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to structured_text_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, subedge* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to subedge"); } do { // convert the 'parent_edge' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_edge, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to subedge to be a `edge`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, subface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to subface"); } do { // convert the 'parent_face' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_face, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to subface to be a `face`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, supplied_part_relationship* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to supplied_part_relationship"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_condition_callout* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to surface_condition_callout"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, swept_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to swept_surface"); } do { // convert the 'swept_curve' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->swept_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to swept_surface to be a `curve`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_of_linear_extrusion* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to surface_of_linear_extrusion"); } do { // convert the 'extrusion_axis' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->extrusion_axis, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_of_linear_extrusion to be a `vector`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_of_revolution* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to surface_of_revolution"); } do { // convert the 'axis_position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->axis_position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_of_revolution to be a `axis1_placement`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_patch* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to surface_patch"); } do { // convert the 'parent_surface' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_patch to be a `bounded_surface`")); } - } while (0); - do { // convert the 'u_transition' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->u_transition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_patch to be a `transition_code`")); } - } while (0); - do { // convert the 'v_transition' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->v_transition, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_patch to be a `transition_code`")); } - } while (0); - do { // convert the 'u_sense' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->u_sense, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to surface_patch to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'v_sense' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->v_sense, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to surface_patch to be a `BOOLEAN`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_profile_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to surface_profile_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_replica* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to surface_replica"); } do { // convert the 'parent_surface' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->parent_surface, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_replica to be a `surface`")); } - } while (0); - do { // convert the 'transformation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->transformation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_replica to be a `cartesian_transformation_operator_3d`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_side_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to surface_side_style"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_side_style to be a `label`")); } - } while (0); - do { // convert the 'styles' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->styles, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_side_style to be a `SET [1:7] OF surface_style_element_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_boundary* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to surface_style_boundary"); } do { // convert the 'style_of_boundary' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style_of_boundary, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_boundary to be a `curve_or_render`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_control_grid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to surface_style_control_grid"); } do { // convert the 'style_of_control_grid' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style_of_control_grid, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_control_grid to be a `curve_or_render`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_fill_area* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to surface_style_fill_area"); } do { // convert the 'fill_area' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->fill_area, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_fill_area to be a `fill_area_style`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_parameter_line* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to surface_style_parameter_line"); } do { // convert the 'style_of_parameter_lines' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style_of_parameter_lines, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_parameter_line to be a `curve_or_render`")); } - } while (0); - do { // convert the 'direction_counts' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->direction_counts, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_style_parameter_line to be a `SET [1:2] OF direction_count_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_reflectance_ambient* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to surface_style_reflectance_ambient"); } do { // convert the 'ambient_reflectance' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->ambient_reflectance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_reflectance_ambient to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_reflectance_ambient_diffuse* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to surface_style_reflectance_ambient_diffuse"); } do { // convert the 'diffuse_reflectance' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->diffuse_reflectance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_style_reflectance_ambient_diffuse to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_reflectance_ambient_diffuse_specular* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to surface_style_reflectance_ambient_diffuse_specular"); } do { // convert the 'specular_reflectance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->specular_reflectance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_style_reflectance_ambient_diffuse_specular to be a `REAL`")); } - } while (0); - do { // convert the 'specular_exponent' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->specular_exponent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to surface_style_reflectance_ambient_diffuse_specular to be a `REAL`")); } - } while (0); - do { // convert the 'specular_colour' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->specular_colour, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to surface_style_reflectance_ambient_diffuse_specular to be a `colour`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_rendering* in) -{ - size_t base = 0; - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to surface_style_rendering"); } do { // convert the 'rendering_method' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->rendering_method, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_rendering to be a `shading_surface_method`")); } - } while (0); - do { // convert the 'surface_colour' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->surface_colour, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_style_rendering to be a `colour`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_rendering_with_properties* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to surface_style_rendering_with_properties"); } do { // convert the 'properties' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->properties, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to surface_style_rendering_with_properties to be a `SET [1:2] OF rendering_properties_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_segmentation_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to surface_style_segmentation_curve"); } do { // convert the 'style_of_segmentation_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style_of_segmentation_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_segmentation_curve to be a `curve_or_render`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_silhouette* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to surface_style_silhouette"); } do { // convert the 'style_of_silhouette' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style_of_silhouette, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_silhouette to be a `curve_or_render`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_style_usage* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to surface_style_usage"); } do { // convert the 'side' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->side, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to surface_style_usage to be a `surface_side`")); } - } while (0); - do { // convert the 'style' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to surface_style_usage to be a `surface_side_style_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surface_texture_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to surface_texture_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, surfaced_open_shell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to surfaced_open_shell"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, swept_disk_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to swept_disk_solid"); } do { // convert the 'directrix' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->directrix, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to swept_disk_solid to be a `curve`")); } - } while (0); - do { // convert the 'radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to swept_disk_solid to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'inner_radius' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->inner_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to swept_disk_solid to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'start_param' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->start_param, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to swept_disk_solid to be a `REAL`")); } - } while (0); - do { // convert the 'end_param' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->end_param, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to swept_disk_solid to be a `REAL`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, symbol* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to symbol"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, symbol_representation_map* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to symbol_representation_map"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, symbol_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to symbol_style"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to symbol_style to be a `label`")); } - } while (0); - do { // convert the 'style_of_symbol' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->style_of_symbol, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to symbol_style to be a `symbol_style_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, symbol_target* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to symbol_target"); } do { // convert the 'placement' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->placement, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to symbol_target to be a `axis2_placement`")); } - } while (0); - do { // convert the 'x_scale' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->x_scale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to symbol_target to be a `positive_ratio_measure`")); } - } while (0); - do { // convert the 'y_scale' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->y_scale, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to symbol_target to be a `positive_ratio_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, symmetric_shape_aspect* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to symmetric_shape_aspect"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, symmetry_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to symmetry_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, table_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to table_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, tactile_appearance_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to tactile_appearance_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, tagged_text_format* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to tagged_text_format"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, tagged_text_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to tagged_text_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, tangent* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to tangent"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_literal_with_associated_curves* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to text_literal_with_associated_curves"); } do { // convert the 'associated_curves' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->associated_curves, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to text_literal_with_associated_curves to be a `SET [1:?] OF curve`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_literal_with_blanking_box* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to text_literal_with_blanking_box"); } do { // convert the 'blanking' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->blanking, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to text_literal_with_blanking_box to be a `planar_box`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_literal_with_extent* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to text_literal_with_extent"); } do { // convert the 'extent' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->extent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to text_literal_with_extent to be a `planar_extent`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_string_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to text_string_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_style* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to text_style"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to text_style to be a `label`")); } - } while (0); - do { // convert the 'character_appearance' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->character_appearance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to text_style to be a `character_style_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_style_with_box_characteristics* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to text_style_with_box_characteristics"); } do { // convert the 'characteristics' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->characteristics, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to text_style_with_box_characteristics to be a `SET [1:4] OF box_characteristic_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_style_with_mirror* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to text_style_with_mirror"); } do { // convert the 'mirror_placement' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->mirror_placement, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to text_style_with_mirror to be a `axis2_placement`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, text_style_with_spacing* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to text_style_with_spacing"); } do { // convert the 'character_spacing' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->character_spacing, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to text_style_with_spacing to be a `character_spacing_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, thermal_resistance_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to thermal_resistance_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, thermal_resistance_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to thermal_resistance_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, thermodynamic_temperature_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to thermodynamic_temperature_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, thermodynamic_temperature_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to thermodynamic_temperature_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, thickened_face_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to thickened_face_solid"); } do { // convert the 'base_element' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->base_element, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to thickened_face_solid to be a `generalized_surface_select`")); } - } while (0); - do { // convert the 'offset1' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->offset1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to thickened_face_solid to be a `length_measure`")); } - } while (0); - do { // convert the 'offset2' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->offset2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to thickened_face_solid to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, thickness_laminate_definition* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to thickness_laminate_definition"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, thickness_laminate_table* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to thickness_laminate_table"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, time_interval* in) -{ - size_t base = 0; - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to time_interval"); } do { // convert the 'id' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0] = true; break; } - try { GenericConvert(in->id, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to time_interval to be a `identifier`")); } - } while (0); - do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1] = true; break; } - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to time_interval to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2] = true; break; } - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to time_interval to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, time_interval_based_effectivity* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to time_interval_based_effectivity"); } do { // convert the 'effectivity_period' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->effectivity_period, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to time_interval_based_effectivity to be a `time_interval`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, time_interval_with_bounds* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to time_interval_with_bounds"); } do { // convert the 'primary_bound' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->primary_bound, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to time_interval_with_bounds to be a `date_time_or_event_occurrence`")); } - } while (0); - do { // convert the 'secondary_bound' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->secondary_bound, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to time_interval_with_bounds to be a `date_time_or_event_occurrence`")); } - } while (0); - do { // convert the 'duration' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->duration, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to time_interval_with_bounds to be a `time_measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, time_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to time_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, time_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to time_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, tolerance_zone* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to tolerance_zone"); } do { // convert the 'defining_tolerance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->defining_tolerance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to tolerance_zone to be a `SET [1:?] OF geometric_tolerance`")); } - } while (0); - do { // convert the 'form' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->form, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to tolerance_zone to be a `tolerance_zone_form`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, torus* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to torus"); } do { // convert the 'position' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->position, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to torus to be a `axis1_placement`")); } - } while (0); - do { // convert the 'major_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->major_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to torus to be a `positive_length_measure`")); } - } while (0); - do { // convert the 'minor_radius' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->minor_radius, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to torus to be a `positive_length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, total_runout_tolerance* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to total_runout_tolerance"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, track_blended_solid* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to track_blended_solid"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, track_blended_solid_with_end_conditions* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to track_blended_solid_with_end_conditions"); } do { // convert the 'end_conditions' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->end_conditions, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to track_blended_solid_with_end_conditions to be a `LIST [2:2] OF blend_end_condition_select`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, trimmed_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to trimmed_curve"); } do { // convert the 'basis_curve' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->basis_curve, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to trimmed_curve to be a `curve`")); } - } while (0); - do { // convert the 'trim_1' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->trim_1, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to trimmed_curve to be a `SET [1:2] OF trimming_select`")); } - } while (0); - do { // convert the 'trim_2' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->trim_2, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to trimmed_curve to be a `SET [1:2] OF trimming_select`")); } - } while (0); - do { // convert the 'sense_agreement' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->sense_agreement, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to trimmed_curve to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'master_representation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->master_representation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to trimmed_curve to be a `trimming_preference`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, two_direction_repeat_factor* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to two_direction_repeat_factor"); } do { // convert the 'second_repeat_factor' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->second_repeat_factor, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to two_direction_repeat_factor to be a `vector`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, unary_generic_expression* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to unary_generic_expression"); } do { // convert the 'operand' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->operand, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to unary_generic_expression to be a `generic_expression`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, unary_numeric_expression* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, uncertainty_assigned_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to uncertainty_assigned_representation"); } do { // convert the 'uncertainty' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->uncertainty, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to uncertainty_assigned_representation to be a `SET [1:?] OF uncertainty_measure_with_unit`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, uncertainty_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to uncertainty_measure_with_unit"); } do { // convert the 'name' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->name, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to uncertainty_measure_with_unit to be a `label`")); } - } while (0); - do { // convert the 'description' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->description, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to uncertainty_measure_with_unit to be a `text`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, uniform_curve* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to uniform_curve"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, uniform_resource_identifier* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to uniform_resource_identifier"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, uniform_surface* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to uniform_surface"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, usage_association* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to usage_association"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, user_defined_curve_font* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, user_defined_marker* in) -{ - size_t base = 0; - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, user_defined_terminator_symbol* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, user_selected_shape_elements* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to user_selected_shape_elements"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, value_range* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to value_range"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, value_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to value_representation_item"); } do { // convert the 'value_component' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->value_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to value_representation_item to be a `measure_value`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, variable_semantics* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, variational_representation_item* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to variational_representation_item"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, vector* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to vector"); } do { // convert the 'orientation' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->orientation, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to vector to be a `direction`")); } - } while (0); - do { // convert the 'magnitude' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->magnitude, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to vector to be a `length_measure`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -/*template <> size_t GenericFill(const DB& db, const LIST& params, vector_style* in) -{ - size_t base = 0; - return base; -}*/ -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, velocity_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to velocity_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, velocity_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to velocity_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, vertex* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to vertex"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, vertex_loop* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to vertex_loop"); } do { // convert the 'loop_vertex' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->loop_vertex, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to vertex_loop to be a `vertex`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, vertex_point* in) -{ - size_t base = 0; - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to vertex_point"); } do { // convert the 'vertex_geometry' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->vertex_geometry, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to vertex_point to be a `point`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, vertex_shell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to vertex_shell"); } do { // convert the 'vertex_shell_extent' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->vertex_shell_extent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to vertex_shell to be a `vertex_loop`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, view_volume* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 9) { throw STEP::TypeError("expected 9 arguments to view_volume"); } do { // convert the 'projection_type' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->projection_type, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to view_volume to be a `central_or_parallel`")); } - } while (0); - do { // convert the 'projection_point' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->projection_point, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to view_volume to be a `cartesian_point`")); } - } while (0); - do { // convert the 'view_plane_distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->view_plane_distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to view_volume to be a `length_measure`")); } - } while (0); - do { // convert the 'front_plane_distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->front_plane_distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to view_volume to be a `length_measure`")); } - } while (0); - do { // convert the 'front_plane_clipping' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->front_plane_clipping, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to view_volume to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'back_plane_distance' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->back_plane_distance, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to view_volume to be a `length_measure`")); } - } while (0); - do { // convert the 'back_plane_clipping' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->back_plane_clipping, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 6 to view_volume to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'view_volume_sides_clipping' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->view_volume_sides_clipping, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 7 to view_volume to be a `BOOLEAN`")); } - } while (0); - do { // convert the 'view_window' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->view_window, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to view_volume to be a `planar_box`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, visual_appearance_representation* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to visual_appearance_representation"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, volume_measure_with_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to volume_measure_with_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, volume_unit* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to volume_unit"); } return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, week_of_year_and_day_date* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to week_of_year_and_day_date"); } do { // convert the 'week_component' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->week_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to week_of_year_and_day_date to be a `week_in_year_number`")); } - } while (0); - do { // convert the 'day_component' argument - std::shared_ptr arg = params[base++]; - if (dynamic_cast(&*arg)) break; - try { GenericConvert(in->day_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to week_of_year_and_day_date to be a `day_in_week_number`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, wire_shell* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to wire_shell"); } do { // convert the 'wire_shell_extent' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->wire_shell_extent, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to wire_shell to be a `SET [1:?] OF loop`")); } - } while (0); - return base; -} -// ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, year_month* in) -{ - size_t base = GenericFill(db, params, static_cast(in)); - if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to year_month"); } do { // convert the 'month_component' argument - std::shared_ptr arg = params[base++]; - try { GenericConvert(in->month_component, arg, db); break; } - catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to year_month to be a `month_in_year_number`")); } - } while (0); - return base; -} - -} -} diff --git a/code/AssetLib/StepFile/StepFileImporter.cpp b/code/AssetLib/StepFile/StepFileImporter.cpp deleted file mode 100644 index f536ec90e..000000000 --- a/code/AssetLib/StepFile/StepFileImporter.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2020, assimp team - - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -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 -OWNER 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 ASSIMP_BUILD_NO_STEP_IMPORTER - -#include "StepFileImporter.h" -#include "../../Importer/STEPParser/STEPFileReader.h" -#include -#include - -namespace Assimp { -namespace StepFile { - -using namespace STEP; - -static const aiImporterDesc desc = { "StepFile Importer", - "", - "", - "", - 0, - 0, - 0, - 0, - 0, - "stp" }; - -StepFileImporter::StepFileImporter() -: BaseImporter() { - -} - -StepFileImporter::~StepFileImporter() { - -} - -bool StepFileImporter::CanRead(const std::string& file, IOSystem* pIOHandler, bool checkSig) const { - const std::string &extension = GetExtension(file); - if ( extension == "stp" || extension == "step" ) { - return true; - } else if ((!extension.length() || checkSig) && pIOHandler) { - const char* tokens[] = { "ISO-10303-21" }; - const bool found(SearchFileHeaderForToken(pIOHandler, file, tokens, 1)); - return found; - } - - return false; -} - -const aiImporterDesc *StepFileImporter::GetInfo() const { - return &desc; -} - -static const std::string mode = "rb"; -static const std::string StepFileSchema = "CONFIG_CONTROL_DESIGN"; - -void StepFileImporter::InternReadFile(const std::string &file, aiScene*, IOSystem* pIOHandler) { - // Read file into memory - std::shared_ptr fileStream(pIOHandler->Open(file, mode)); - if (!fileStream.get()) { - throw DeadlyImportError("Failed to open file " + file + "."); - } - - std::unique_ptr db(STEP::ReadFileHeader(fileStream)); - const STEP::HeaderInfo& head = static_cast(*db).GetHeader(); - if (!head.fileSchema.size() || head.fileSchema != StepFileSchema) { - DeadlyImportError("Unrecognized file schema: " + head.fileSchema); - } -} - -} // Namespace StepFile -} // Namespace Assimp - -#endif // ASSIMP_BUILD_NO_STEP_IMPORTER - diff --git a/code/AssetLib/StepFile/StepReaderGen.h b/code/AssetLib/StepFile/StepReaderGen.h deleted file mode 100644 index c45220a83..000000000 --- a/code/AssetLib/StepFile/StepReaderGen.h +++ /dev/null @@ -1,7291 +0,0 @@ -/* -Open Asset Import Library (ASSIMP) ----------------------------------------------------------------------- - -Copyright (c) 2006-2020, ASSIMP Development Team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the ASSIMP team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the ASSIMP Development Team. - -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 -OWNER 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. - ----------------------------------------------------------------------- -*/ - -/** MACHINE-GENERATED by scripts/ICFImporter/CppGenerator.py */ - -#ifndef INCLUDED_STEPFILE_READER_GEN_H -#define INCLUDED_STEPFILE_READER_GEN_H - -#include "code/Step/STEPFile.h" - -#ifdef _WIN32 -# pragma warning( disable : 4512 ) -#endif // _WIN32 -namespace Assimp { -namespace StepFile { - using namespace STEP; - using namespace STEP::EXPRESS; - - - struct NotImplemented : public ObjectHelper { - - }; - - - // ****************************************************************************** - // StepFile Custom data types - // ****************************************************************************** - - - // C++ wrapper type for absorbed_dose_measure - typedef REAL absorbed_dose_measure; - // C++ wrapper type for acceleration_measure - typedef REAL acceleration_measure; - // C++ wrapper type for action_items - typedef SELECT action_items; - // C++ wrapper type for action_method_items - typedef SELECT action_method_items; - // C++ wrapper type for action_request_item - typedef SELECT action_request_item; - // C++ wrapper type for ahead_or_behind - typedef ENUMERATION ahead_or_behind; - // C++ wrapper type for amount_of_substance_measure - typedef REAL amount_of_substance_measure; - // C++ wrapper type for angle_direction_reference_select - typedef SELECT angle_direction_reference_select; - // C++ wrapper type for angle_direction_reference_with_a2p3d_select - typedef SELECT angle_direction_reference_with_a2p3d_select; - // C++ wrapper type for angle_relator - typedef ENUMERATION angle_relator; - // C++ wrapper type for annotation_plane_element - typedef SELECT annotation_plane_element; - // C++ wrapper type for annotation_representation_select - typedef SELECT annotation_representation_select; - // C++ wrapper type for annotation_symbol_occurrence_item - typedef SELECT annotation_symbol_occurrence_item; - // C++ wrapper type for annotation_text_occurrence_item - typedef SELECT annotation_text_occurrence_item; - // C++ wrapper type for approval_item - typedef SELECT approval_item; - // C++ wrapper type for approved_item - typedef SELECT approved_item; - // C++ wrapper type for area_measure - typedef REAL area_measure; - // C++ wrapper type for area_or_view - typedef SELECT area_or_view; - // C++ wrapper type for attribute_classification_item - typedef SELECT attribute_classification_item; - // C++ wrapper type for attribute_language_item - typedef SELECT attribute_language_item; - // C++ wrapper type for attribute_type - typedef SELECT attribute_type; - // C++ wrapper type for axis2_placement - typedef SELECT axis2_placement; - // C++ wrapper type for b_spline_curve_form - typedef ENUMERATION b_spline_curve_form; - // C++ wrapper type for b_spline_surface_form - typedef ENUMERATION b_spline_surface_form; - // C++ wrapper type for base_solid_select - typedef SELECT base_solid_select; - // C++ wrapper type for blend_end_condition_select - typedef SELECT blend_end_condition_select; - // C++ wrapper type for blend_radius_variation_type - typedef ENUMERATION blend_radius_variation_type; - // C++ wrapper type for boolean_operand - typedef SELECT boolean_operand; - // C++ wrapper type for boolean_operator - typedef ENUMERATION boolean_operator; - // C++ wrapper type for box_characteristic_select - typedef SELECT box_characteristic_select; - // C++ wrapper type for box_height - typedef REAL box_height; - // C++ wrapper type for box_rotate_angle - typedef REAL box_rotate_angle; - // C++ wrapper type for box_slant_angle - typedef REAL box_slant_angle; - // C++ wrapper type for box_width - typedef REAL box_width; - // C++ wrapper type for camera_model_d3_multi_clipping_interection_select - typedef SELECT camera_model_d3_multi_clipping_interection_select; - // C++ wrapper type for camera_model_d3_multi_clipping_union_select - typedef SELECT camera_model_d3_multi_clipping_union_select; - // C++ wrapper type for capacitance_measure - typedef REAL capacitance_measure; - // C++ wrapper type for category_usage_item - typedef SELECT category_usage_item; - // C++ wrapper type for cc_classified_item - typedef SELECT cc_classified_item; - // C++ wrapper type for cc_person_organization_item - typedef SELECT cc_person_organization_item; - // C++ wrapper type for cc_specified_item - typedef SELECT cc_specified_item; - // C++ wrapper type for celsius_temperature_measure - typedef REAL celsius_temperature_measure; - // C++ wrapper type for central_or_parallel - typedef ENUMERATION central_or_parallel; - // C++ wrapper type for certification_item - typedef SELECT certification_item; - // C++ wrapper type for certified_item - typedef SELECT certified_item; - // C++ wrapper type for change_request_item - typedef SELECT change_request_item; - // C++ wrapper type for character_spacing_select - typedef SELECT character_spacing_select; - // C++ wrapper type for character_style_select - typedef SELECT character_style_select; - // C++ wrapper type for characterized_action_definition - typedef SELECT characterized_action_definition; - // C++ wrapper type for characterized_definition - typedef SELECT characterized_definition; - // C++ wrapper type for characterized_material_property - typedef SELECT characterized_material_property; - // C++ wrapper type for characterized_product_composition_value - typedef SELECT characterized_product_composition_value; - // C++ wrapper type for characterized_product_definition - typedef SELECT characterized_product_definition; - // C++ wrapper type for class_usage_effectivity_context_item - typedef SELECT class_usage_effectivity_context_item; - // C++ wrapper type for classification_item - typedef SELECT classification_item; - // C++ wrapper type for classified_item - typedef SELECT classified_item; - // C++ wrapper type for compound_item_definition - typedef SELECT compound_item_definition; - // C++ wrapper type for conductance_measure - typedef REAL conductance_measure; - // C++ wrapper type for configuration_design_item - typedef SELECT configuration_design_item; - // C++ wrapper type for configured_effectivity_context_item - typedef SELECT configured_effectivity_context_item; - // C++ wrapper type for configured_effectivity_item - typedef SELECT configured_effectivity_item; - // C++ wrapper type for constructive_geometry_representation_or_shape_represenation - typedef SELECT constructive_geometry_representation_or_shape_represenation; - // C++ wrapper type for context_dependent_measure - typedef REAL context_dependent_measure; - // C++ wrapper type for contract_item - typedef SELECT contract_item; - // C++ wrapper type for contracted_item - typedef SELECT contracted_item; - // C++ wrapper type for count_measure - typedef NUMBER count_measure; - // C++ wrapper type for csg_primitive - typedef SELECT csg_primitive; - // C++ wrapper type for csg_select - typedef SELECT csg_select; - // C++ wrapper type for curve_font_or_scaled_curve_font_select - typedef SELECT curve_font_or_scaled_curve_font_select; - // C++ wrapper type for curve_on_surface - typedef SELECT curve_on_surface; - // C++ wrapper type for curve_or_annotation_curve_occurrence - typedef SELECT curve_or_annotation_curve_occurrence; - // C++ wrapper type for curve_or_render - typedef SELECT curve_or_render; - // C++ wrapper type for curve_style_font_select - typedef SELECT curve_style_font_select; - // C++ wrapper type for date_and_time_item - typedef SELECT date_and_time_item; - // C++ wrapper type for date_item - typedef SELECT date_item; - // C++ wrapper type for date_time_item - typedef SELECT date_time_item; - // C++ wrapper type for date_time_or_event_occurrence - typedef SELECT date_time_or_event_occurrence; - // C++ wrapper type for date_time_select - typedef SELECT date_time_select; - // C++ wrapper type for day_in_month_number - typedef INTEGER day_in_month_number; - // C++ wrapper type for day_in_week_number - typedef INTEGER day_in_week_number; - // C++ wrapper type for day_in_year_number - typedef INTEGER day_in_year_number; - // C++ wrapper type for defined_symbol_select - typedef SELECT defined_symbol_select; - // C++ wrapper type for derived_property_select - typedef SELECT derived_property_select; - // C++ wrapper type for description_attribute_select - typedef SELECT description_attribute_select; - // C++ wrapper type for descriptive_measure - typedef STRING descriptive_measure; - // C++ wrapper type for dimension_count - typedef INTEGER dimension_count; - // C++ wrapper type for dimension_extent_usage - typedef ENUMERATION dimension_extent_usage; - // C++ wrapper type for dimensional_characteristic - typedef SELECT dimensional_characteristic; - // C++ wrapper type for direction_count_select - typedef SELECT direction_count_select; - // C++ wrapper type for document_identifier_assigned_item - typedef SELECT document_identifier_assigned_item; - // C++ wrapper type for document_reference_item - typedef SELECT document_reference_item; - // C++ wrapper type for dose_equivalent_measure - typedef REAL dose_equivalent_measure; - // C++ wrapper type for draughting_callout_element - typedef SELECT draughting_callout_element; - // C++ wrapper type for draughting_model_item_association_select - typedef SELECT draughting_model_item_association_select; - // C++ wrapper type for draughting_model_item_select - typedef SELECT draughting_model_item_select; - // C++ wrapper type for draughting_titled_item - typedef SELECT draughting_titled_item; - // C++ wrapper type for effectivity_item - typedef SELECT effectivity_item; - // C++ wrapper type for electric_charge_measure - typedef REAL electric_charge_measure; - // C++ wrapper type for electric_current_measure - typedef REAL electric_current_measure; - // C++ wrapper type for electric_potential_measure - typedef REAL electric_potential_measure; - // C++ wrapper type for energy_measure - typedef REAL energy_measure; - // C++ wrapper type for event_occurrence_item - typedef SELECT event_occurrence_item; - // C++ wrapper type for external_identification_item - typedef SELECT external_identification_item; - // C++ wrapper type for fill_area_style_tile_shape_select - typedef SELECT fill_area_style_tile_shape_select; - // C++ wrapper type for fill_style_select - typedef SELECT fill_style_select; - // C++ wrapper type for font_select - typedef SELECT font_select; - // C++ wrapper type for force_measure - typedef REAL force_measure; - // C++ wrapper type for founded_item_select - typedef SELECT founded_item_select; - // C++ wrapper type for frequency_measure - typedef REAL frequency_measure; - // C++ wrapper type for generalized_surface_select - typedef SELECT generalized_surface_select; - // C++ wrapper type for geometric_item_specific_usage_select - typedef SELECT geometric_item_specific_usage_select; - // C++ wrapper type for geometric_set_select - typedef SELECT geometric_set_select; - // C++ wrapper type for groupable_item - typedef SELECT groupable_item; - // C++ wrapper type for hour_in_day - typedef INTEGER hour_in_day; - // C++ wrapper type for id_attribute_select - typedef SELECT id_attribute_select; - // C++ wrapper type for identification_item - typedef SELECT identification_item; - // C++ wrapper type for identifier - typedef STRING identifier; - // C++ wrapper type for illuminance_measure - typedef REAL illuminance_measure; - // C++ wrapper type for inductance_measure - typedef REAL inductance_measure; - // C++ wrapper type for instance_usage_context_select - typedef SELECT instance_usage_context_select; - // C++ wrapper type for invisibility_context - typedef SELECT invisibility_context; - // C++ wrapper type for invisible_item - typedef SELECT invisible_item; - // C++ wrapper type for ir_usage_item - typedef SELECT ir_usage_item; - // C++ wrapper type for knot_type - typedef ENUMERATION knot_type; - // C++ wrapper type for label - typedef STRING label; - // C++ wrapper type for layered_item - typedef SELECT layered_item; - // C++ wrapper type for length_measure - typedef REAL length_measure; - // C++ wrapper type for limit_condition - typedef ENUMERATION limit_condition; - // C++ wrapper type for list_of_reversible_topology_item - typedef ListOf< SELECT, 0, 0 > list_of_reversible_topology_item; - // C++ wrapper type for luminous_flux_measure - typedef REAL luminous_flux_measure; - // C++ wrapper type for luminous_intensity_measure - typedef REAL luminous_intensity_measure; - // C++ wrapper type for magnetic_flux_density_measure - typedef REAL magnetic_flux_density_measure; - // C++ wrapper type for magnetic_flux_measure - typedef REAL magnetic_flux_measure; - // C++ wrapper type for marker_select - typedef SELECT marker_select; - // C++ wrapper type for marker_type - typedef ENUMERATION marker_type; - // C++ wrapper type for mass_measure - typedef REAL mass_measure; - // C++ wrapper type for measure_value - typedef SELECT measure_value; - // C++ wrapper type for mechanical_design_and_draughting_relationship_select - typedef SELECT mechanical_design_and_draughting_relationship_select; - // C++ wrapper type for mechanical_design_geometric_presentation_area_items - typedef SELECT mechanical_design_geometric_presentation_area_items; - // C++ wrapper type for mechanical_design_geometric_presentation_representation_items - typedef SELECT mechanical_design_geometric_presentation_representation_items; - // C++ wrapper type for message - typedef STRING message; - // C++ wrapper type for minute_in_hour - typedef INTEGER minute_in_hour; - // C++ wrapper type for month_in_year_number - typedef INTEGER month_in_year_number; - // C++ wrapper type for multi_language_attribute_item - typedef SELECT multi_language_attribute_item; - // C++ wrapper type for name_attribute_select - typedef SELECT name_attribute_select; - // C++ wrapper type for name_item - typedef SELECT name_item; - // C++ wrapper type for non_negative_length_measure - typedef REAL non_negative_length_measure; - // C++ wrapper type for nonnegative_integer - typedef INTEGER nonnegative_integer; - // C++ wrapper type for null_style - typedef ENUMERATION null_style; - // C++ wrapper type for numeric_measure - typedef NUMBER numeric_measure; - // C++ wrapper type for organization_item - typedef SELECT organization_item; - // C++ wrapper type for orientation_basis_select - typedef SELECT orientation_basis_select; - // C++ wrapper type for parameter_value - typedef REAL parameter_value; - // C++ wrapper type for pcurve_or_surface - typedef SELECT pcurve_or_surface; - // C++ wrapper type for person_and_organization_item - typedef SELECT person_and_organization_item; - // C++ wrapper type for person_organization_select - typedef SELECT person_organization_select; - // C++ wrapper type for picture_representation_item_select - typedef SELECT picture_representation_item_select; - // C++ wrapper type for plane_angle_measure - typedef REAL plane_angle_measure; - // C++ wrapper type for plane_or_planar_box - typedef SELECT plane_or_planar_box; - // C++ wrapper type for point_and_vector_member - typedef SELECT point_and_vector_member; - // C++ wrapper type for point_and_vector_members - typedef ListOf< SELECT, 2, 3 > point_and_vector_members; - // C++ wrapper type for positive_integer - typedef INTEGER positive_integer; - // C++ wrapper type for positive_length_measure - typedef REAL positive_length_measure; - // C++ wrapper type for positive_plane_angle_measure - typedef REAL positive_plane_angle_measure; - // C++ wrapper type for positive_ratio_measure - typedef REAL positive_ratio_measure; - // C++ wrapper type for power_measure - typedef REAL power_measure; - // C++ wrapper type for preferred_surface_curve_representation - typedef ENUMERATION preferred_surface_curve_representation; - // C++ wrapper type for presentable_text - typedef STRING presentable_text; - // C++ wrapper type for presentation_representation_select - typedef SELECT presentation_representation_select; - // C++ wrapper type for presentation_size_assignment_select - typedef SELECT presentation_size_assignment_select; - // C++ wrapper type for presentation_style_select - typedef SELECT presentation_style_select; - // C++ wrapper type for presented_item_select - //typedef SELECT presented_item_select; - // C++ wrapper type for pressure_measure - typedef REAL pressure_measure; - // C++ wrapper type for product_definition_or_assembly_relationship - typedef SELECT product_definition_or_assembly_relationship; - // C++ wrapper type for product_definition_or_breakdown_element_usage - typedef SELECT product_definition_or_breakdown_element_usage; - // C++ wrapper type for product_definition_or_product_definition_relationship - typedef SELECT product_definition_or_product_definition_relationship; - // C++ wrapper type for product_or_formation_or_definition - typedef SELECT product_or_formation_or_definition; - // C++ wrapper type for project_item - typedef SELECT project_item; - // C++ wrapper type for radioactivity_measure - typedef REAL radioactivity_measure; - // C++ wrapper type for ratio_measure - typedef REAL ratio_measure; - // C++ wrapper type for rendering_properties_select - typedef SELECT rendering_properties_select; - // C++ wrapper type for represented_definition - typedef SELECT represented_definition; - // C++ wrapper type for requirement_assigned_item - typedef SELECT requirement_assigned_item; - // C++ wrapper type for requirement_satisfaction_item - typedef SELECT requirement_satisfaction_item; - // C++ wrapper type for requirement_source_item - typedef SELECT requirement_source_item; - // C++ wrapper type for resistance_measure - typedef REAL resistance_measure; - // C++ wrapper type for reversible_topology - typedef SELECT reversible_topology; - // C++ wrapper type for reversible_topology_item - typedef SELECT reversible_topology_item; - // C++ wrapper type for role_select - typedef SELECT role_select; - // C++ wrapper type for rule_superseded_item - typedef SELECT rule_superseded_item; - // C++ wrapper type for second_in_minute - typedef REAL second_in_minute; - // C++ wrapper type for security_classification_item - typedef SELECT security_classification_item; - // C++ wrapper type for set_of_reversible_topology_item - typedef ListOf< SELECT, 0, 0 > set_of_reversible_topology_item; - // C++ wrapper type for shading_curve_method - typedef ENUMERATION shading_curve_method; - // C++ wrapper type for shading_surface_method - typedef ENUMERATION shading_surface_method; - // C++ wrapper type for shape_definition - typedef SELECT shape_definition; - // C++ wrapper type for shell - typedef SELECT shell; - // C++ wrapper type for si_prefix - typedef ENUMERATION si_prefix; - // C++ wrapper type for si_unit_name - typedef ENUMERATION si_unit_name; - // C++ wrapper type for size_select - typedef SELECT size_select; - // C++ wrapper type for sketch_basis_select - typedef SELECT sketch_basis_select; - // C++ wrapper type for solid_angle_measure - typedef REAL solid_angle_measure; - // C++ wrapper type for source - typedef ENUMERATION source; - // C++ wrapper type for source_item - typedef SELECT source_item; - // C++ wrapper type for start_request_item - typedef SELECT start_request_item; - // C++ wrapper type for string_representation_item_select - typedef SELECT string_representation_item_select; - // C++ wrapper type for style_context_select - typedef SELECT style_context_select; - // C++ wrapper type for surface_side - typedef ENUMERATION surface_side; - // C++ wrapper type for surface_side_style_select - typedef SELECT surface_side_style_select; - // C++ wrapper type for surface_style_element_select - typedef SELECT surface_style_element_select; - // C++ wrapper type for symbol_style_select - typedef SELECT symbol_style_select; - // C++ wrapper type for text - typedef STRING text; - // C++ wrapper type for text_alignment - typedef STRING text_alignment; - // C++ wrapper type for text_delineation - typedef STRING text_delineation; - // C++ wrapper type for text_or_character - typedef SELECT text_or_character; - // C++ wrapper type for text_path - typedef ENUMERATION text_path; - // C++ wrapper type for text_string_representation_item - typedef SELECT text_string_representation_item; - // C++ wrapper type for thermodynamic_temperature_measure - typedef REAL thermodynamic_temperature_measure; - // C++ wrapper type for time_interval_item - typedef SELECT time_interval_item; - // C++ wrapper type for time_measure - typedef REAL time_measure; - // C++ wrapper type for tolerance_method_definition - typedef SELECT tolerance_method_definition; - // C++ wrapper type for transformation - typedef SELECT transformation; - // C++ wrapper type for transition_code - typedef ENUMERATION transition_code; - // C++ wrapper type for trim_condition_select - typedef SELECT trim_condition_select; - // C++ wrapper type for trim_intent - typedef ENUMERATION trim_intent; - // C++ wrapper type for trimming_preference - typedef ENUMERATION trimming_preference; - // C++ wrapper type for trimming_select - typedef SELECT trimming_select; - // C++ wrapper type for u_direction_count - typedef INTEGER u_direction_count; - // C++ wrapper type for unit - typedef SELECT unit; - // C++ wrapper type for v_direction_count - typedef INTEGER v_direction_count; - // C++ wrapper type for value_qualifier - typedef SELECT value_qualifier; - // C++ wrapper type for vector_or_direction - typedef SELECT vector_or_direction; - // C++ wrapper type for velocity_measure - typedef REAL velocity_measure; - // C++ wrapper type for volume_measure - typedef REAL volume_measure; - // C++ wrapper type for week_in_year_number - typedef INTEGER week_in_year_number; - // C++ wrapper type for work_item - typedef SELECT work_item; - // C++ wrapper type for year_number - typedef INTEGER year_number; - - - // ****************************************************************************** - // StepFile Entities - // ****************************************************************************** - - struct measure_with_unit; - struct absorbed_dose_measure_with_unit; - struct derived_unit; - struct absorbed_dose_unit; - //struct abstract_variable; - struct acceleration_measure_with_unit; - struct acceleration_unit; - struct action; - struct action_assignment; - typedef NotImplemented action_directive; // (not currently used by Assimp) - struct action_method; - struct action_method_assignment; - struct action_method_relationship; - typedef NotImplemented action_method_role; // (not currently used by Assimp) - typedef NotImplemented action_property; // (not currently used by Assimp) - typedef NotImplemented action_property_representation; // (not currently used by Assimp) - typedef NotImplemented action_relationship; // (not currently used by Assimp) - struct action_request_assignment; - typedef NotImplemented action_request_solution; // (not currently used by Assimp) - typedef NotImplemented action_request_status; // (not currently used by Assimp) - typedef NotImplemented action_status; // (not currently used by Assimp) - struct address; - struct representation; - struct shape_representation; - struct advanced_brep_shape_representation; - struct face_surface; - struct advanced_face; - typedef NotImplemented alternate_product_relationship; // (not currently used by Assimp) - struct amount_of_substance_measure_with_unit; - struct named_unit; - struct amount_of_substance_unit; - struct angle_direction_reference; - struct representation_item; - struct geometric_representation_item; - struct draughting_callout; - struct dimension_curve_directed_callout; - struct angular_dimension; - struct shape_aspect_relationship; - struct dimensional_location; - struct angular_location; - struct dimensional_size; - struct angular_size; - struct geometric_tolerance; - struct geometric_tolerance_with_datum_reference; - struct angularity_tolerance; - struct styled_item; - struct annotation_occurrence; - struct annotation_curve_occurrence; - struct annotation_fill_area; - struct annotation_fill_area_occurrence; - struct annotation_occurrence_relationship; - struct annotation_occurrence_associativity; - struct annotation_plane; - struct annotation_symbol_occurrence; - struct annotation_subfigure_occurrence; - struct mapped_item; - struct annotation_symbol; - struct annotation_text; - struct annotation_text_character; - struct annotation_text_occurrence; - struct shape_aspect; - struct derived_shape_aspect; - struct apex; - typedef NotImplemented application_context; // (not currently used by Assimp) - struct application_context_element; - typedef NotImplemented application_protocol_definition; // (not currently used by Assimp) - struct applied_action_assignment; - struct applied_action_method_assignment; - struct applied_action_request_assignment; - struct approval_assignment; - struct applied_approval_assignment; - struct attribute_classification_assignment; - struct applied_attribute_classification_assignment; - struct certification_assignment; - struct applied_certification_assignment; - struct classification_assignment; - struct applied_classification_assignment; - struct contract_assignment; - struct applied_contract_assignment; - struct date_and_time_assignment; - struct applied_date_and_time_assignment; - struct date_assignment; - struct applied_date_assignment; - struct document_reference; - struct applied_document_reference; - struct document_usage_constraint_assignment; - struct applied_document_usage_constraint_assignment; - struct effectivity_assignment; - struct applied_effectivity_assignment; - struct event_occurrence_assignment; - struct applied_event_occurrence_assignment; - struct identification_assignment; - struct external_identification_assignment; - struct applied_external_identification_assignment; - struct group_assignment; - struct applied_group_assignment; - struct applied_identification_assignment; - struct name_assignment; - struct applied_name_assignment; - struct organization_assignment; - struct applied_organization_assignment; - struct organizational_project_assignment; - struct applied_organizational_project_assignment; - struct person_and_organization_assignment; - struct applied_person_and_organization_assignment; - //struct presented_item; - struct applied_presented_item; - struct security_classification_assignment; - struct applied_security_classification_assignment; - struct time_interval_assignment; - struct applied_time_interval_assignment; - struct applied_usage_right; - typedef NotImplemented approval; // (not currently used by Assimp) - typedef NotImplemented approval_date_time; // (not currently used by Assimp) - typedef NotImplemented approval_person_organization; // (not currently used by Assimp) - typedef NotImplemented approval_relationship; // (not currently used by Assimp) - typedef NotImplemented approval_role; // (not currently used by Assimp) - typedef NotImplemented approval_status; // (not currently used by Assimp) - struct area_in_set; - struct area_measure_with_unit; - struct area_unit; - struct product_definition_relationship; - struct product_definition_usage; - struct assembly_component_usage; - typedef NotImplemented assembly_component_usage_substitute; // (not currently used by Assimp) - struct assigned_requirement; - struct compound_representation_item; - struct atomic_formula; - struct attribute_assertion; - struct attribute_language_assignment; - struct attribute_value_assignment; - typedef NotImplemented attribute_value_role; // (not currently used by Assimp) - struct auxiliary_geometric_representation_item; - struct placement; - struct axis1_placement; - struct axis2_placement_2d; - struct axis2_placement_3d; - struct curve; - struct bounded_curve; - struct b_spline_curve; - struct b_spline_curve_with_knots; - struct surface; - struct bounded_surface; - struct b_spline_surface; - struct b_spline_surface_with_knots; - struct product_definition; - struct rule_software_definition; - struct rule_definition; - struct back_chaining_rule; - struct back_chaining_rule_body; - struct colour; - struct background_colour; - struct beveled_sheet_representation; - struct bezier_curve; - struct bezier_surface; - struct generic_expression; - struct binary_generic_expression; - struct binary_numeric_expression; - struct binary_representation_item; - struct block; - struct expression; - struct boolean_expression; - struct boolean_literal; - struct boolean_representation_item; - struct boolean_result; - struct composite_curve; - struct composite_curve_on_surface; - struct boundary_curve; - struct bounded_pcurve; - struct bounded_surface_curve; - struct founded_item; - struct box_domain; - struct half_space_solid; - struct boxed_half_space; - struct breakdown_context; - struct breakdown_element_group_assignment; - struct breakdown_element_realization; - struct breakdown_element_usage; - struct breakdown_of; - struct solid_model; - struct manifold_solid_brep; - struct brep_with_voids; - struct bytes_representation_item; - struct date; - struct calendar_date; - struct camera_image; - struct camera_image_3d_with_scale; - struct camera_model; - struct camera_model_d3; - struct camera_model_d3_multi_clipping; - struct camera_model_d3_multi_clipping_intersection; - struct camera_model_d3_multi_clipping_union; - struct camera_model_d3_with_hlhsr; - struct camera_model_with_light_sources; - struct representation_map; - struct camera_usage; - struct capacitance_measure_with_unit; - struct capacitance_unit; - struct point; - struct cartesian_point; - struct cartesian_transformation_operator; - struct cartesian_transformation_operator_2d; - struct cartesian_transformation_operator_3d; - struct cc_design_approval; - struct cc_design_certification; - struct cc_design_contract; - struct cc_design_date_and_time_assignment; - struct cc_design_person_and_organization_assignment; - struct cc_design_security_classification; - struct cc_design_specification_reference; - struct celsius_temperature_measure_with_unit; - struct centre_of_symmetry; - typedef NotImplemented certification; // (not currently used by Assimp) - typedef NotImplemented certification_type; // (not currently used by Assimp) - struct change; - struct change_request; - typedef NotImplemented character_glyph_font_usage; // (not currently used by Assimp) - struct character_glyph_style_outline; - struct character_glyph_style_stroke; - struct symbol_representation; - struct generic_character_glyph_symbol; - struct character_glyph_symbol; - struct character_glyph_symbol_outline; - struct character_glyph_symbol_stroke; - struct general_property; - struct characteristic_data_column_header; - struct general_property_relationship; - struct characteristic_data_column_header_link; - struct characteristic_data_table_header; - struct characteristic_data_table_header_decomposition; - struct group; - struct characteristic_type; - struct characterized_class; - struct characterized_object; - struct conic; - struct circle; - struct circular_runout_tolerance; - typedef NotImplemented class_t; // (not currently used by Assimp) - struct class_by_extension; - struct class_by_intension; - struct class_system; - struct effectivity_context_assignment; - struct class_usage_effectivity_context_assignment; - typedef NotImplemented classification_role; // (not currently used by Assimp) - struct topological_representation_item; - struct connected_face_set; - struct closed_shell; - struct coaxiality_tolerance; - struct colour_specification; - struct colour_rgb; - struct common_datum; - struct comparison_expression; - struct complex_clause; - struct complex_conjunctive_clause; - struct complex_disjunctive_clause; - struct modified_solid; - struct shelled_solid; - struct complex_shelled_solid; - struct composite_assembly_definition; - struct composite_assembly_sequence_definition; - struct laminate_table; - struct part_laminate_table; - struct composite_assembly_table; - struct composite_curve_segment; - struct material_designation; - struct composite_material_designation; - struct composite_shape_aspect; - struct composite_sheet_representation; - struct composite_text; - struct composite_text_with_associated_curves; - struct composite_text_with_blanking_box; - struct composite_text_with_delineation; - struct composite_text_with_extent; - struct compound_shape_representation; - struct concentricity_tolerance; - typedef NotImplemented concept_feature_operator; // (not currently used by Assimp) - struct concept_feature_relationship; - struct concept_feature_relationship_with_condition; - struct product_concept_feature; - struct conditional_concept_feature; - struct conductance_measure_with_unit; - struct conductance_unit; - struct configuration_item; - struct configurable_item; - typedef NotImplemented configuration_design; // (not currently used by Assimp) - struct effectivity; - struct product_definition_effectivity; - struct configuration_effectivity; - struct configuration_item_relationship; - struct configuration_item_hierarchical_relationship; - struct configuration_item_revision_sequence; - struct configured_effectivity_assignment; - struct configured_effectivity_context_assignment; - struct conical_stepped_hole_transition; - struct elementary_surface; - struct conical_surface; - struct connected_edge_set; - struct connected_face_sub_set; - struct constructive_geometry_representation; - struct representation_relationship; - struct constructive_geometry_representation_relationship; - struct contact_ratio_representation; - struct invisibility; - struct context_dependent_invisibility; - struct over_riding_styled_item; - struct context_dependent_over_riding_styled_item; - typedef NotImplemented context_dependent_shape_representation; // (not currently used by Assimp) - struct context_dependent_unit; - typedef NotImplemented contract; // (not currently used by Assimp) - typedef NotImplemented contract_relationship; // (not currently used by Assimp) - typedef NotImplemented contract_type; // (not currently used by Assimp) - struct conversion_based_unit; - typedef NotImplemented coordinated_universal_time_offset; // (not currently used by Assimp) - struct csg_shape_representation; - struct csg_solid; - struct currency; - struct currency_measure_with_unit; - struct curve_bounded_surface; - struct curve_dimension; - struct curve_replica; - struct curve_style; - struct curve_style_font; - struct curve_style_font_and_scaling; - struct curve_style_font_pattern; - typedef NotImplemented curve_style_rendering; // (not currently used by Assimp) - struct curve_swept_solid_shape_representation; - struct cylindrical_surface; - struct cylindricity_tolerance; - typedef NotImplemented data_environment; // (not currently used by Assimp) - typedef NotImplemented date_and_time; // (not currently used by Assimp) - struct date_representation_item; - typedef NotImplemented date_role; // (not currently used by Assimp) - struct date_time_representation_item; - typedef NotImplemented date_time_role; // (not currently used by Assimp) - struct dated_effectivity; - struct datum; - struct datum_feature; - struct datum_feature_callout; - struct datum_reference; - struct datum_target; - struct datum_target_callout; - struct default_tolerance_table; - struct default_tolerance_table_cell; - struct defined_symbol; - struct definitional_representation; - struct definitional_representation_relationship; - struct definitional_representation_relationship_with_same_context; - struct degenerate_pcurve; - struct toroidal_surface; - struct degenerate_toroidal_surface; - typedef NotImplemented derived_unit_element; // (not currently used by Assimp) - typedef NotImplemented description_attribute; // (not currently used by Assimp) - struct descriptive_representation_item; - struct product_definition_context; - struct design_context; - struct design_make_from_relationship; - struct diameter_dimension; - struct ratio_measure_with_unit; - struct dielectric_constant_measure_with_unit; - struct dimension_callout; - struct draughting_callout_relationship; - struct dimension_callout_component_relationship; - struct dimension_callout_relationship; - struct dimension_curve; - struct terminator_symbol; - struct dimension_curve_terminator; - struct dimension_curve_terminator_to_projection_curve_associativity; - struct dimension_pair; - typedef NotImplemented dimension_related_tolerance_zone_element; // (not currently used by Assimp) - struct dimension_text_associativity; - typedef NotImplemented dimensional_characteristic_representation; // (not currently used by Assimp) - typedef NotImplemented dimensional_exponents; // (not currently used by Assimp) - struct dimensional_location_with_path; - struct dimensional_size_with_path; - struct executed_action; - struct directed_action; - struct directed_dimensional_location; - struct direction; - typedef NotImplemented document; // (not currently used by Assimp) - struct document_file; - struct document_identifier; - struct document_identifier_assignment; - struct document_product_association; - struct document_product_equivalence; - typedef NotImplemented document_relationship; // (not currently used by Assimp) - typedef NotImplemented document_representation_type; // (not currently used by Assimp) - typedef NotImplemented document_type; // (not currently used by Assimp) - typedef NotImplemented document_usage_constraint; // (not currently used by Assimp) - typedef NotImplemented document_usage_role; // (not currently used by Assimp) - struct dose_equivalent_measure_with_unit; - struct dose_equivalent_unit; - struct double_offset_shelled_solid; - struct item_defined_transformation; - struct transformation_with_derived_angle; - struct draped_defined_transformation; - struct draughting_annotation_occurrence; - struct draughting_elements; - struct draughting_model; - struct item_identified_representation_usage; - struct draughting_model_item_association; - struct pre_defined_colour; - struct draughting_pre_defined_colour; - struct pre_defined_item; - struct pre_defined_curve_font; - struct draughting_pre_defined_curve_font; - struct pre_defined_text_font; - struct draughting_pre_defined_text_font; - struct draughting_subfigure_representation; - struct draughting_symbol_representation; - struct text_literal; - struct text_literal_with_delineation; - struct draughting_text_literal_with_delineation; - typedef NotImplemented draughting_title; // (not currently used by Assimp) - typedef NotImplemented drawing_definition; // (not currently used by Assimp) - struct presentation_set; - struct drawing_revision; - typedef NotImplemented drawing_revision_sequence; // (not currently used by Assimp) - struct presentation_representation; - struct presentation_area; - struct drawing_sheet_revision; - struct drawing_sheet_revision_sequence; - struct drawing_sheet_revision_usage; - struct edge; - struct edge_based_wireframe_model; - struct edge_based_wireframe_shape_representation; - struct edge_blended_solid; - struct edge_curve; - struct edge_loop; - typedef NotImplemented effectivity_context_role; // (not currently used by Assimp) - typedef NotImplemented effectivity_relationship; // (not currently used by Assimp) - struct electric_charge_measure_with_unit; - struct electric_charge_unit; - struct electric_current_measure_with_unit; - struct electric_current_unit; - struct electric_potential_measure_with_unit; - struct electric_potential_unit; - struct elementary_brep_shape_representation; - struct ellipse; - struct energy_measure_with_unit; - struct energy_unit; - struct property_definition; - struct fact_type; - struct entity_assertion; - struct enum_reference_prefix; - typedef NotImplemented environment; // (not currently used by Assimp) - struct evaluated_characteristic; - struct evaluated_degenerate_pcurve; - struct evaluation_product_definition; - struct event_occurrence; - typedef NotImplemented event_occurrence_relationship; // (not currently used by Assimp) - typedef NotImplemented event_occurrence_role; // (not currently used by Assimp) - struct product_concept_feature_category; - struct exclusive_product_concept_feature_category; - struct uncertainty_qualifier; - struct standard_uncertainty; - struct expanded_uncertainty; - struct representation_item_relationship; - struct explicit_procedural_representation_item_relationship; - struct explicit_procedural_geometric_representation_item_relationship; - struct explicit_procedural_representation_relationship; - struct explicit_procedural_shape_representation_relationship; - struct expression_conversion_based_unit; - struct extension; - struct extent; - struct external_source; - struct external_class_library; - typedef NotImplemented external_source_relationship; // (not currently used by Assimp) - struct externally_defined_class; - struct externally_defined_colour; - struct externally_defined_context_dependent_unit; - struct externally_defined_conversion_based_unit; - struct externally_defined_currency; - struct externally_defined_item; - struct externally_defined_curve_font; - struct externally_defined_dimension_definition; - struct externally_defined_general_property; - struct externally_defined_hatch_style; - typedef NotImplemented externally_defined_item_relationship; // (not currently used by Assimp) - struct externally_defined_marker; - struct picture_representation_item; - struct externally_defined_picture_representation_item; - struct externally_defined_representation_item; - struct externally_defined_string; - struct externally_defined_symbol; - struct externally_defined_terminator_symbol; - struct externally_defined_text_font; - struct externally_defined_tile; - struct externally_defined_tile_style; - struct swept_area_solid; - struct extruded_area_solid; - struct swept_face_solid; - struct extruded_face_solid; - struct extruded_face_solid_with_trim_conditions; - struct extruded_face_solid_with_draft_angle; - struct extruded_face_solid_with_multiple_draft_angles; - struct face; - struct face_based_surface_model; - struct face_bound; - struct face_outer_bound; - struct faceted_brep; - struct faceted_brep_shape_representation; - struct fill_area_style; - typedef NotImplemented fill_area_style_colour; // (not currently used by Assimp) - struct fill_area_style_hatching; - struct fill_area_style_tile_coloured_region; - struct fill_area_style_tile_curve_with_style; - struct fill_area_style_tile_symbol_with_style; - struct fill_area_style_tiles; - struct shape_representation_relationship; - struct flat_pattern_ply_representation_relationship; - struct flatness_tolerance; - struct force_measure_with_unit; - struct force_unit; - struct forward_chaining_rule; - struct forward_chaining_rule_premise; - struct frequency_measure_with_unit; - struct frequency_unit; - struct func; - struct functional_breakdown_context; - struct functional_element_usage; - typedef NotImplemented functionally_defined_transformation; // (not currently used by Assimp) - struct general_material_property; - typedef NotImplemented general_property_association; // (not currently used by Assimp) - struct simple_generic_expression; - struct generic_literal; - struct generic_variable; - struct geometric_alignment; - struct geometric_set; - struct geometric_curve_set; - struct geometric_intersection; - struct geometric_item_specific_usage; - struct geometric_model_element_relationship; - struct representation_context; - struct geometric_representation_context; - typedef NotImplemented geometric_tolerance_relationship; // (not currently used by Assimp) - struct geometric_tolerance_with_defined_unit; - struct geometrical_tolerance_callout; - struct geometrically_bounded_2d_wireframe_representation; - struct geometrically_bounded_surface_shape_representation; - struct geometrically_bounded_wireframe_shape_representation; - struct global_assignment; - struct global_uncertainty_assigned_context; - struct global_unit_assigned_context; - struct ground_fact; - typedef NotImplemented group_relationship; // (not currently used by Assimp) - struct hardness_representation; - struct hidden_element_over_riding_styled_item; - struct hyperbola; - typedef NotImplemented id_attribute; // (not currently used by Assimp) - typedef NotImplemented identification_role; // (not currently used by Assimp) - struct illuminance_measure_with_unit; - struct illuminance_unit; - struct included_text_block; - struct inclusion_product_concept_feature; - struct user_selected_elements; - struct indirectly_selected_elements; - struct indirectly_selected_shape_elements; - struct inductance_measure_with_unit; - struct inductance_unit; - struct information_right; - struct information_usage_right; - struct instance_usage_context_assignment; - struct instanced_feature; - struct literal_number; - struct int_literal; - struct integer_representation_item; - struct surface_curve; - struct intersection_curve; - struct interval_expression; - struct iso4217_currency; - struct known_source; - struct laid_defined_transformation; - struct language; - struct leader_curve; - struct leader_directed_callout; - struct leader_directed_dimension; - struct leader_terminator; - struct length_measure_with_unit; - struct length_unit; - struct light_source; - struct light_source_ambient; - struct light_source_directional; - struct light_source_positional; - struct light_source_spot; - typedef NotImplemented limits_and_fits; // (not currently used by Assimp) - struct line; - struct line_profile_tolerance; - struct linear_dimension; - struct simple_clause; - struct literal_conjunction; - struct literal_disjunction; - typedef NotImplemented local_time; // (not currently used by Assimp) - struct logical_literal; - struct logical_representation_item; - struct loop; - struct loss_tangent_measure_with_unit; - struct lot_effectivity; - struct luminous_flux_measure_with_unit; - struct luminous_flux_unit; - struct luminous_intensity_measure_with_unit; - struct luminous_intensity_unit; - struct magnetic_flux_density_measure_with_unit; - struct magnetic_flux_density_unit; - struct magnetic_flux_measure_with_unit; - struct magnetic_flux_unit; - struct make_from_usage_option; - struct manifold_subsurface_shape_representation; - struct manifold_surface_shape_representation; - struct mass_measure_with_unit; - struct mass_unit; - typedef NotImplemented material_designation_characterization; // (not currently used by Assimp) - struct material_property; - struct property_definition_representation; - struct material_property_representation; - typedef NotImplemented measure_qualification; // (not currently used by Assimp) - struct measure_representation_item; - struct product_context; - struct mechanical_context; - struct mechanical_design_and_draughting_relationship; - struct mechanical_design_geometric_presentation_area; - struct mechanical_design_geometric_presentation_representation; - struct mechanical_design_presentation_representation_with_draughting; - struct mechanical_design_shaded_presentation_area; - struct mechanical_design_shaded_presentation_representation; - struct min_and_major_ply_orientation_basis; - struct modified_geometric_tolerance; - struct modified_solid_with_placed_configuration; - struct moments_of_inertia_representation; - struct multi_language_attribute_assignment; - struct multiple_arity_boolean_expression; - struct multiple_arity_generic_expression; - struct multiple_arity_numeric_expression; - typedef NotImplemented name_attribute; // (not currently used by Assimp) - struct next_assembly_usage_occurrence; - struct non_manifold_surface_shape_representation; - struct null_representation_item; - struct numeric_expression; - typedef NotImplemented object_role; // (not currently used by Assimp) - struct offset_curve_2d; - struct offset_curve_3d; - struct offset_surface; - struct one_direction_repeat_factor; - struct open_shell; - struct ordinal_date; - struct projection_directed_callout; - struct ordinate_dimension; - typedef NotImplemented organization; // (not currently used by Assimp) - typedef NotImplemented organization_relationship; // (not currently used by Assimp) - typedef NotImplemented organization_role; // (not currently used by Assimp) - struct organizational_address; - typedef NotImplemented organizational_project; // (not currently used by Assimp) - typedef NotImplemented organizational_project_relationship; // (not currently used by Assimp) - typedef NotImplemented organizational_project_role; // (not currently used by Assimp) - struct oriented_closed_shell; - struct oriented_edge; - struct oriented_face; - struct oriented_open_shell; - struct path; - struct oriented_path; - struct oriented_surface; - struct outer_boundary_curve; - struct package_product_concept_feature; - struct parabola; - struct parallel_offset; - struct parallelism_tolerance; - struct parametric_representation_context; - struct partial_document_with_structured_text_representation_assignment; - struct pcurve; - struct percentage_laminate_definition; - struct zone_structural_makeup; - struct percentage_laminate_table; - struct percentage_ply_definition; - struct perpendicular_to; - struct perpendicularity_tolerance; - typedef NotImplemented person; // (not currently used by Assimp) - typedef NotImplemented person_and_organization; // (not currently used by Assimp) - struct person_and_organization_address; - typedef NotImplemented person_and_organization_role; // (not currently used by Assimp) - struct personal_address; - struct physical_breakdown_context; - struct physical_element_usage; - struct presentation_view; - struct picture_representation; - struct placed_datum_target_feature; - struct placed_feature; - struct planar_extent; - struct planar_box; - struct plane; - struct plane_angle_measure_with_unit; - struct plane_angle_unit; - typedef NotImplemented plus_minus_tolerance; // (not currently used by Assimp) - struct ply_laminate_definition; - struct ply_laminate_sequence_definition; - struct ply_laminate_table; - struct point_and_vector; - struct point_on_curve; - struct point_on_surface; - struct point_path; - struct point_replica; - struct point_style; - struct polar_complex_number_literal; - struct poly_loop; - struct polyline; - struct position_tolerance; - struct positioned_sketch; - struct power_measure_with_unit; - struct power_unit; - struct pre_defined_symbol; - struct pre_defined_dimension_symbol; - struct pre_defined_geometrical_tolerance_symbol; - struct pre_defined_marker; - struct pre_defined_point_marker_symbol; - struct pre_defined_surface_condition_symbol; - struct pre_defined_surface_side_style; - struct pre_defined_terminator_symbol; - struct pre_defined_tile; - typedef NotImplemented precision_qualifier; // (not currently used by Assimp) - struct predefined_picture_representation_item; - typedef NotImplemented presentation_layer_assignment; // (not currently used by Assimp) - typedef NotImplemented presentation_size; // (not currently used by Assimp) - struct presentation_style_assignment; - struct presentation_style_by_context; - typedef NotImplemented presented_item_representation; // (not currently used by Assimp) - struct pressure_measure_with_unit; - struct pressure_unit; - struct procedural_representation; - struct procedural_representation_sequence; - struct procedural_shape_representation; - struct procedural_shape_representation_sequence; - typedef NotImplemented product; // (not currently used by Assimp) - struct product_category; - struct product_class; - typedef NotImplemented product_concept; // (not currently used by Assimp) - struct product_concept_context; - typedef NotImplemented product_concept_feature_association; // (not currently used by Assimp) - struct product_concept_feature_category_usage; - typedef NotImplemented product_concept_relationship; // (not currently used by Assimp) - typedef NotImplemented product_definition_context_association; // (not currently used by Assimp) - typedef NotImplemented product_definition_context_role; // (not currently used by Assimp) - struct product_definition_element_relationship; - struct product_definition_formation; - typedef NotImplemented product_definition_formation_relationship; // (not currently used by Assimp) - struct product_definition_formation_with_specified_source; - struct product_definition_group_assignment; - typedef NotImplemented product_definition_occurrence_relationship; // (not currently used by Assimp) - struct product_definition_shape; - typedef NotImplemented product_definition_substitute; // (not currently used by Assimp) - struct product_definition_with_associated_documents; - struct product_identification; - struct product_material_composition_relationship; - struct product_related_product_category; - struct product_specification; - struct tolerance_zone_definition; - struct projected_zone_definition; - struct projection_curve; - struct promissory_usage_occurrence; - typedef NotImplemented property_definition_relationship; // (not currently used by Assimp) - struct qualified_representation_item; - struct qualitative_uncertainty; - struct quantified_assembly_component_usage; - struct quasi_uniform_curve; - struct quasi_uniform_surface; - struct radioactivity_measure_with_unit; - struct radioactivity_unit; - struct radius_dimension; - struct range_characteristic; - struct ratio_unit; - struct rational_b_spline_curve; - struct rational_b_spline_surface; - struct rational_representation_item; - struct real_literal; - struct real_representation_item; - struct rectangular_composite_surface; - struct rectangular_trimmed_surface; - struct referenced_modified_datum; - struct relative_event_occurrence; - struct rep_item_group; - struct reparametrised_composite_curve_segment; - struct representation_relationship_with_transformation; - struct requirement_assigned_object; - struct requirement_assignment; - struct requirement_source; - struct requirement_view_definition_relationship; - struct resistance_measure_with_unit; - struct resistance_unit; - struct revolved_area_solid; - struct revolved_face_solid; - struct revolved_face_solid_with_trim_conditions; - struct right_angular_wedge; - struct right_circular_cone; - struct right_circular_cylinder; - struct right_to_usage_association; - typedef NotImplemented role_association; // (not currently used by Assimp) - struct roundness_tolerance; - struct row_representation_item; - struct row_value; - struct row_variable; - struct rule_action; - struct rule_condition; - struct rule_set; - struct rule_set_group; - struct rule_superseded_assignment; - struct rule_supersedence; - struct surface_curve_swept_area_solid; - struct ruled_surface_swept_area_solid; - struct runout_zone_definition; - struct runout_zone_orientation; - struct runout_zone_orientation_reference_direction; - struct satisfied_requirement; - struct satisfies_requirement; - struct satisfying_item; - struct scalar_variable; - struct scattering_parameter; - struct sculptured_solid; - struct seam_curve; - typedef NotImplemented security_classification; // (not currently used by Assimp) - typedef NotImplemented security_classification_level; // (not currently used by Assimp) - struct serial_numbered_effectivity; - struct shape_aspect_associativity; - struct shape_aspect_deriving_relationship; - struct shape_definition_representation; - struct shape_dimension_representation; - struct shape_feature_definition; - struct shape_representation_with_parameters; - struct shell_based_surface_model; - struct shell_based_wireframe_model; - struct shell_based_wireframe_shape_representation; - struct si_absorbed_dose_unit; - struct si_capacitance_unit; - struct si_conductance_unit; - struct si_dose_equivalent_unit; - struct si_electric_charge_unit; - struct si_electric_potential_unit; - struct si_energy_unit; - struct si_force_unit; - struct si_frequency_unit; - struct si_illuminance_unit; - struct si_inductance_unit; - struct si_magnetic_flux_density_unit; - struct si_magnetic_flux_unit; - struct si_power_unit; - struct si_pressure_unit; - struct si_radioactivity_unit; - struct si_resistance_unit; - struct si_unit; - struct simple_boolean_expression; - struct simple_numeric_expression; - struct slash_expression; - struct smeared_material_definition; - struct solid_angle_measure_with_unit; - struct solid_angle_unit; - struct solid_curve_font; - struct solid_replica; - struct solid_with_chamfered_edges; - struct solid_with_angle_based_chamfer; - struct solid_with_shape_element_pattern; - struct solid_with_circular_pattern; - struct solid_with_depression; - struct solid_with_pocket; - struct solid_with_circular_pocket; - struct solid_with_protrusion; - struct solid_with_circular_protrusion; - struct solid_with_hole; - struct solid_with_stepped_round_hole; - struct solid_with_conical_bottom_round_hole; - struct solid_with_constant_radius_edge_blend; - struct solid_with_slot; - struct solid_with_curved_slot; - struct solid_with_double_offset_chamfer; - struct solid_with_flat_bottom_round_hole; - struct solid_with_general_pocket; - struct solid_with_general_protrusion; - struct solid_with_groove; - struct solid_with_incomplete_circular_pattern; - struct solid_with_rectangular_pattern; - struct solid_with_incomplete_rectangular_pattern; - struct solid_with_rectangular_pocket; - struct solid_with_rectangular_protrusion; - struct solid_with_single_offset_chamfer; - struct solid_with_spherical_bottom_round_hole; - struct solid_with_stepped_round_hole_and_conical_transitions; - struct solid_with_straight_slot; - struct solid_with_tee_section_slot; - struct solid_with_through_depression; - struct solid_with_trapezoidal_section_slot; - struct solid_with_variable_radius_edge_blend; - struct source_for_requirement; - struct sourced_requirement; - struct specification_definition; - struct specified_higher_usage_occurrence; - struct sphere; - struct spherical_surface; - struct start_request; - struct start_work; - struct straightness_tolerance; - struct structured_dimension_callout; - struct structured_text_composition; - struct structured_text_representation; - struct subedge; - struct subface; - struct supplied_part_relationship; - struct surface_condition_callout; - struct swept_surface; - struct surface_of_linear_extrusion; - struct surface_of_revolution; - struct surface_patch; - struct surface_profile_tolerance; - typedef NotImplemented surface_rendering_properties; // (not currently used by Assimp) - struct surface_replica; - struct surface_side_style; - struct surface_style_boundary; - struct surface_style_control_grid; - struct surface_style_fill_area; - struct surface_style_parameter_line; - struct surface_style_reflectance_ambient; - struct surface_style_reflectance_ambient_diffuse; - struct surface_style_reflectance_ambient_diffuse_specular; - struct surface_style_rendering; - struct surface_style_rendering_with_properties; - struct surface_style_segmentation_curve; - struct surface_style_silhouette; - typedef NotImplemented surface_style_transparent; // (not currently used by Assimp) - struct surface_style_usage; - struct surface_texture_representation; - struct surfaced_open_shell; - struct swept_disk_solid; - struct symbol; - typedef NotImplemented symbol_colour; // (not currently used by Assimp) - struct symbol_representation_map; - struct symbol_style; - struct symbol_target; - struct symmetric_shape_aspect; - struct symmetry_tolerance; - struct table_representation_item; - struct tactile_appearance_representation; - struct tagged_text_format; - struct tagged_text_item; - struct tangent; - typedef NotImplemented text_font; // (not currently used by Assimp) - typedef NotImplemented text_font_family; // (not currently used by Assimp) - typedef NotImplemented text_font_in_family; // (not currently used by Assimp) - struct text_literal_with_associated_curves; - struct text_literal_with_blanking_box; - struct text_literal_with_extent; - struct text_string_representation; - struct text_style; - typedef NotImplemented text_style_for_defined_font; // (not currently used by Assimp) - struct text_style_with_box_characteristics; - struct text_style_with_mirror; - struct text_style_with_spacing; - struct thermal_resistance_measure_with_unit; - struct thermal_resistance_unit; - struct thermodynamic_temperature_measure_with_unit; - struct thermodynamic_temperature_unit; - struct thickened_face_solid; - struct thickness_laminate_definition; - struct thickness_laminate_table; - struct time_interval; - struct time_interval_based_effectivity; - typedef NotImplemented time_interval_relationship; // (not currently used by Assimp) - typedef NotImplemented time_interval_role; // (not currently used by Assimp) - struct time_interval_with_bounds; - struct time_measure_with_unit; - struct time_unit; - typedef NotImplemented tolerance_value; // (not currently used by Assimp) - struct tolerance_zone; - typedef NotImplemented tolerance_zone_form; // (not currently used by Assimp) - struct torus; - struct total_runout_tolerance; - struct track_blended_solid; - struct track_blended_solid_with_end_conditions; - struct trimmed_curve; - struct two_direction_repeat_factor; - typedef NotImplemented type_qualifier; // (not currently used by Assimp) - struct unary_generic_expression; - struct unary_numeric_expression; - struct uncertainty_assigned_representation; - struct uncertainty_measure_with_unit; - struct uniform_curve; - struct uniform_resource_identifier; - struct uniform_surface; - struct usage_association; - struct user_defined_curve_font; - struct user_defined_marker; - struct user_defined_terminator_symbol; - struct user_selected_shape_elements; - struct value_range; - struct value_representation_item; - struct variable_semantics; - struct variational_representation_item; - struct vector; - struct vector_style; - struct velocity_measure_with_unit; - struct velocity_unit; - typedef NotImplemented versioned_action_request; // (not currently used by Assimp) - struct vertex; - struct vertex_loop; - struct vertex_point; - struct vertex_shell; - struct view_volume; - struct visual_appearance_representation; - struct volume_measure_with_unit; - struct volume_unit; - struct week_of_year_and_day_date; - struct wire_shell; - struct year_month; - - - - // C++ wrapper for measure_with_unit - struct measure_with_unit : ObjectHelper { measure_with_unit() : Object("measure_with_unit") {} - measure_value::Out value_component; - unit::Out unit_component; - }; - - // C++ wrapper for absorbed_dose_measure_with_unit - struct absorbed_dose_measure_with_unit : measure_with_unit, ObjectHelper { absorbed_dose_measure_with_unit() : Object("absorbed_dose_measure_with_unit") {} - - }; - - // C++ wrapper for derived_unit - struct derived_unit : ObjectHelper { derived_unit() : Object("derived_unit") {} - ListOf< Lazy< NotImplemented >, 1, 0 > elements; - }; - - // C++ wrapper for absorbed_dose_unit - struct absorbed_dose_unit : derived_unit, ObjectHelper { absorbed_dose_unit() : Object("absorbed_dose_unit") {} - - }; - - // C++ wrapper for abstract_variable - struct abstract_variable : ObjectHelper { abstract_variable() : Object("abstract_variable") {} - - }; - - // C++ wrapper for acceleration_measure_with_unit - struct acceleration_measure_with_unit : measure_with_unit, ObjectHelper { acceleration_measure_with_unit() : Object("acceleration_measure_with_unit") {} - - }; - - // C++ wrapper for acceleration_unit - struct acceleration_unit : derived_unit, ObjectHelper { acceleration_unit() : Object("acceleration_unit") {} - - }; - - // C++ wrapper for action - struct action : ObjectHelper { action() : Object("action") {} - label::Out name; - Maybe< text::Out > description; - Lazy< action_method > chosen_method; - }; - - // C++ wrapper for action_assignment - struct action_assignment : ObjectHelper { action_assignment() : Object("action_assignment") {} - Lazy< action > assigned_action; - }; - - // C++ wrapper for action_method - struct action_method : ObjectHelper { action_method() : Object("action_method") {} - label::Out name; - Maybe< text::Out > description; - text::Out consequence; - text::Out purpose; - }; - - // C++ wrapper for action_method_assignment - struct action_method_assignment : ObjectHelper { action_method_assignment() : Object("action_method_assignment") {} - Lazy< action_method > assigned_action_method; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for action_method_relationship - struct action_method_relationship : ObjectHelper { action_method_relationship() : Object("action_method_relationship") {} - label::Out name; - Maybe< text::Out > description; - Lazy< action_method > relating_method; - Lazy< action_method > related_method; - }; - - // C++ wrapper for action_request_assignment - struct action_request_assignment : ObjectHelper { action_request_assignment() : Object("action_request_assignment") {} - Lazy< NotImplemented > assigned_action_request; - }; - - // C++ wrapper for address - struct address : ObjectHelper { address() : Object("address") {} - Maybe< label::Out > internal_location; - Maybe< label::Out > street_number; - Maybe< label::Out > street; - Maybe< label::Out > postal_box; - Maybe< label::Out > town; - Maybe< label::Out > region; - Maybe< label::Out > postal_code; - Maybe< label::Out > country; - Maybe< label::Out > facsimile_number; - Maybe< label::Out > telephone_number; - Maybe< label::Out > electronic_mail_address; - Maybe< label::Out > telex_number; - }; - - // C++ wrapper for representation - struct representation : ObjectHelper { representation() : Object("representation") {} - label::Out name; - ListOf< Lazy< representation_item >, 1, 0 > items; - Lazy< representation_context > context_of_items; - }; - - // C++ wrapper for shape_representation - struct shape_representation : representation, ObjectHelper { shape_representation() : Object("shape_representation") {} - - }; - - // C++ wrapper for advanced_brep_shape_representation - struct advanced_brep_shape_representation : shape_representation, ObjectHelper { advanced_brep_shape_representation() : Object("advanced_brep_shape_representation") {} - - }; - - // C++ wrapper for face_surface - struct face_surface : ObjectHelper { face_surface() : Object("face_surface") {} - Lazy< surface > face_geometry; - BOOLEAN::Out same_sense; - }; - - // C++ wrapper for advanced_face - struct advanced_face : face_surface, ObjectHelper { advanced_face() : Object("advanced_face") {} - - }; - - // C++ wrapper for amount_of_substance_measure_with_unit - struct amount_of_substance_measure_with_unit : measure_with_unit, ObjectHelper { amount_of_substance_measure_with_unit() : Object("amount_of_substance_measure_with_unit") {} - - }; - - // C++ wrapper for named_unit - struct named_unit : ObjectHelper { named_unit() : Object("named_unit") {} - Lazy< NotImplemented > dimensions; - }; - - // C++ wrapper for amount_of_substance_unit - struct amount_of_substance_unit : named_unit, ObjectHelper { amount_of_substance_unit() : Object("amount_of_substance_unit") {} - - }; - - // C++ wrapper for angle_direction_reference - struct angle_direction_reference : ObjectHelper { angle_direction_reference() : Object("angle_direction_reference") {} - - }; - - // C++ wrapper for representation_item - struct representation_item : ObjectHelper { representation_item() : Object("representation_item") {} - label::Out name; - }; - - // C++ wrapper for geometric_representation_item - struct geometric_representation_item : representation_item, ObjectHelper { geometric_representation_item() : Object("geometric_representation_item") {} - - }; - - // C++ wrapper for draughting_callout - struct draughting_callout : geometric_representation_item, ObjectHelper { draughting_callout() : Object("draughting_callout") {} - ListOf< draughting_callout_element, 1, 0 >::Out contents; - }; - - // C++ wrapper for dimension_curve_directed_callout - struct dimension_curve_directed_callout : draughting_callout, ObjectHelper { dimension_curve_directed_callout() : Object("dimension_curve_directed_callout") {} - - }; - - // C++ wrapper for angular_dimension - struct angular_dimension : dimension_curve_directed_callout, ObjectHelper { angular_dimension() : Object("angular_dimension") {} - - }; - - // C++ wrapper for shape_aspect_relationship - struct shape_aspect_relationship : ObjectHelper { shape_aspect_relationship() : Object("shape_aspect_relationship") {} - label::Out name; - Maybe< text::Out > description; - Lazy< shape_aspect > relating_shape_aspect; - Lazy< shape_aspect > related_shape_aspect; - }; - - // C++ wrapper for dimensional_location - struct dimensional_location : shape_aspect_relationship, ObjectHelper { dimensional_location() : Object("dimensional_location") {} - - }; - - // C++ wrapper for angular_location - struct angular_location : dimensional_location, ObjectHelper { angular_location() : Object("angular_location") {} - angle_relator::Out angle_selection; - }; - - // C++ wrapper for dimensional_size - struct dimensional_size : ObjectHelper { dimensional_size() : Object("dimensional_size") {} - Lazy< shape_aspect > applies_to; - label::Out name; - }; - - // C++ wrapper for angular_size - struct angular_size : dimensional_size, ObjectHelper { angular_size() : Object("angular_size") {} - angle_relator::Out angle_selection; - }; - - // C++ wrapper for geometric_tolerance - struct geometric_tolerance : ObjectHelper { geometric_tolerance() : Object("geometric_tolerance") {} - label::Out name; - text::Out description; - Lazy< measure_with_unit > magnitude; - Lazy< shape_aspect > toleranced_shape_aspect; - }; - - // C++ wrapper for geometric_tolerance_with_datum_reference - struct geometric_tolerance_with_datum_reference : geometric_tolerance, ObjectHelper { geometric_tolerance_with_datum_reference() : Object("geometric_tolerance_with_datum_reference") {} - ListOf< Lazy< datum_reference >, 1, 0 > datum_system; - }; - - // C++ wrapper for angularity_tolerance - struct angularity_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { angularity_tolerance() : Object("angularity_tolerance") {} - - }; - - // C++ wrapper for styled_item - struct styled_item : representation_item, ObjectHelper { styled_item() : Object("styled_item") {} - ListOf< Lazy< presentation_style_assignment >, 1, 0 > styles; - Lazy< representation_item > item; - }; - - // C++ wrapper for annotation_occurrence - struct annotation_occurrence : styled_item, ObjectHelper { annotation_occurrence() : Object("annotation_occurrence") {} - - }; - - // C++ wrapper for annotation_curve_occurrence - struct annotation_curve_occurrence : annotation_occurrence, ObjectHelper { annotation_curve_occurrence() : Object("annotation_curve_occurrence") {} - - }; - - // C++ wrapper for annotation_fill_area - struct annotation_fill_area : geometric_representation_item, ObjectHelper { annotation_fill_area() : Object("annotation_fill_area") {} - ListOf< Lazy< curve >, 1, 0 > boundaries; - }; - - // C++ wrapper for annotation_fill_area_occurrence - struct annotation_fill_area_occurrence : annotation_occurrence, ObjectHelper { annotation_fill_area_occurrence() : Object("annotation_fill_area_occurrence") {} - Lazy< point > fill_style_target; - }; - - // C++ wrapper for annotation_occurrence_relationship - struct annotation_occurrence_relationship : ObjectHelper { annotation_occurrence_relationship() : Object("annotation_occurrence_relationship") {} - label::Out name; - text::Out description; - Lazy< annotation_occurrence > relating_annotation_occurrence; - Lazy< annotation_occurrence > related_annotation_occurrence; - }; - - // C++ wrapper for annotation_occurrence_associativity - struct annotation_occurrence_associativity : annotation_occurrence_relationship, ObjectHelper { annotation_occurrence_associativity() : Object("annotation_occurrence_associativity") {} - - }; - - // C++ wrapper for annotation_plane - struct annotation_plane : ObjectHelper { annotation_plane() : Object("annotation_plane") {} - Maybe< ListOf< annotation_plane_element, 1, 0 >::Out > elements; - }; - - // C++ wrapper for annotation_symbol_occurrence - struct annotation_symbol_occurrence : annotation_occurrence, ObjectHelper { annotation_symbol_occurrence() : Object("annotation_symbol_occurrence") {} - - }; - - // C++ wrapper for annotation_subfigure_occurrence - struct annotation_subfigure_occurrence : annotation_symbol_occurrence, ObjectHelper { annotation_subfigure_occurrence() : Object("annotation_subfigure_occurrence") {} - - }; - - // C++ wrapper for mapped_item - struct mapped_item : representation_item, ObjectHelper { mapped_item() : Object("mapped_item") {} - Lazy< representation_map > mapping_source; - Lazy< representation_item > mapping_target; - }; - - // C++ wrapper for annotation_symbol - struct annotation_symbol : mapped_item, ObjectHelper { annotation_symbol() : Object("annotation_symbol") {} - - }; - - // C++ wrapper for annotation_text - struct annotation_text : mapped_item, ObjectHelper { annotation_text() : Object("annotation_text") {} - - }; - - // C++ wrapper for annotation_text_character - struct annotation_text_character : mapped_item, ObjectHelper { annotation_text_character() : Object("annotation_text_character") {} - text_alignment::Out alignment; - }; - - // C++ wrapper for annotation_text_occurrence - struct annotation_text_occurrence : annotation_occurrence, ObjectHelper { annotation_text_occurrence() : Object("annotation_text_occurrence") {} - - }; - - // C++ wrapper for shape_aspect - struct shape_aspect : ObjectHelper { shape_aspect() : Object("shape_aspect") {} - label::Out name; - Maybe< text::Out > description; - Lazy< product_definition_shape > of_shape; - LOGICAL::Out product_definitional; - }; - - // C++ wrapper for derived_shape_aspect - struct derived_shape_aspect : shape_aspect, ObjectHelper { derived_shape_aspect() : Object("derived_shape_aspect") {} - - }; - - // C++ wrapper for apex - struct apex : derived_shape_aspect, ObjectHelper { apex() : Object("apex") {} - - }; - - // C++ wrapper for application_context_element - struct application_context_element : ObjectHelper { application_context_element() : Object("application_context_element") {} - label::Out name; - Lazy< NotImplemented > frame_of_reference; - }; - - // C++ wrapper for applied_action_assignment - struct applied_action_assignment : action_assignment, ObjectHelper { applied_action_assignment() : Object("applied_action_assignment") {} - ListOf< action_items, 1, 0 >::Out items; - }; - - // C++ wrapper for applied_action_method_assignment - struct applied_action_method_assignment : action_method_assignment, ObjectHelper { applied_action_method_assignment() : Object("applied_action_method_assignment") {} - ListOf< action_method_items, 1, 0 >::Out items; - }; - - // C++ wrapper for applied_action_request_assignment - struct applied_action_request_assignment : action_request_assignment, ObjectHelper { applied_action_request_assignment() : Object("applied_action_request_assignment") {} - ListOf< action_request_item, 1, 0 >::Out items; - }; - - // C++ wrapper for approval_assignment - struct approval_assignment : ObjectHelper { approval_assignment() : Object("approval_assignment") {} - Lazy< NotImplemented > assigned_approval; - }; - - // C++ wrapper for applied_approval_assignment - struct applied_approval_assignment : approval_assignment, ObjectHelper { applied_approval_assignment() : Object("applied_approval_assignment") {} - ListOf< approval_item, 1, 0 >::Out items; - }; - - // C++ wrapper for attribute_classification_assignment - struct attribute_classification_assignment : ObjectHelper { attribute_classification_assignment() : Object("attribute_classification_assignment") {} - Lazy< group > assigned_class; - label::Out attribute_name; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_attribute_classification_assignment - struct applied_attribute_classification_assignment : attribute_classification_assignment, ObjectHelper { applied_attribute_classification_assignment() : Object("applied_attribute_classification_assignment") {} - ListOf< attribute_classification_item, 1, 0 >::Out items; - }; - - // C++ wrapper for certification_assignment - struct certification_assignment : ObjectHelper { certification_assignment() : Object("certification_assignment") {} - Lazy< NotImplemented > assigned_certification; - }; - - // C++ wrapper for applied_certification_assignment - struct applied_certification_assignment : certification_assignment, ObjectHelper { applied_certification_assignment() : Object("applied_certification_assignment") {} - ListOf< certification_item, 1, 0 >::Out items; - }; - - // C++ wrapper for classification_assignment - struct classification_assignment : ObjectHelper { classification_assignment() : Object("classification_assignment") {} - Lazy< group > assigned_class; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_classification_assignment - struct applied_classification_assignment : classification_assignment, ObjectHelper { applied_classification_assignment() : Object("applied_classification_assignment") {} - ListOf< classification_item, 1, 0 >::Out items; - }; - - // C++ wrapper for contract_assignment - struct contract_assignment : ObjectHelper { contract_assignment() : Object("contract_assignment") {} - Lazy< NotImplemented > assigned_contract; - }; - - // C++ wrapper for applied_contract_assignment - struct applied_contract_assignment : contract_assignment, ObjectHelper { applied_contract_assignment() : Object("applied_contract_assignment") {} - ListOf< contract_item, 1, 0 >::Out items; - }; - - // C++ wrapper for date_and_time_assignment - struct date_and_time_assignment : ObjectHelper { date_and_time_assignment() : Object("date_and_time_assignment") {} - Lazy< NotImplemented > assigned_date_and_time; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_date_and_time_assignment - struct applied_date_and_time_assignment : date_and_time_assignment, ObjectHelper { applied_date_and_time_assignment() : Object("applied_date_and_time_assignment") {} - ListOf< date_and_time_item, 1, 0 >::Out items; - }; - - // C++ wrapper for date_assignment - struct date_assignment : ObjectHelper { date_assignment() : Object("date_assignment") {} - Lazy< date > assigned_date; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_date_assignment - struct applied_date_assignment : date_assignment, ObjectHelper { applied_date_assignment() : Object("applied_date_assignment") {} - ListOf< date_item, 1, 0 >::Out items; - }; - - // C++ wrapper for document_reference - struct document_reference : ObjectHelper { document_reference() : Object("document_reference") {} - Lazy< NotImplemented > assigned_document; - label::Out source; - }; - - // C++ wrapper for applied_document_reference - struct applied_document_reference : document_reference, ObjectHelper { applied_document_reference() : Object("applied_document_reference") {} - ListOf< document_reference_item, 1, 0 >::Out items; - }; - - // C++ wrapper for document_usage_constraint_assignment - struct document_usage_constraint_assignment : ObjectHelper { document_usage_constraint_assignment() : Object("document_usage_constraint_assignment") {} - Lazy< NotImplemented > assigned_document_usage; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_document_usage_constraint_assignment - struct applied_document_usage_constraint_assignment : document_usage_constraint_assignment, ObjectHelper { applied_document_usage_constraint_assignment() : Object("applied_document_usage_constraint_assignment") {} - ListOf< document_reference_item, 1, 0 >::Out items; - }; - - // C++ wrapper for effectivity_assignment - struct effectivity_assignment : ObjectHelper { effectivity_assignment() : Object("effectivity_assignment") {} - Lazy< effectivity > assigned_effectivity; - }; - - // C++ wrapper for applied_effectivity_assignment - struct applied_effectivity_assignment : effectivity_assignment, ObjectHelper { applied_effectivity_assignment() : Object("applied_effectivity_assignment") {} - ListOf< effectivity_item, 1, 0 >::Out items; - }; - - // C++ wrapper for event_occurrence_assignment - struct event_occurrence_assignment : ObjectHelper { event_occurrence_assignment() : Object("event_occurrence_assignment") {} - Lazy< event_occurrence > assigned_event_occurrence; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_event_occurrence_assignment - struct applied_event_occurrence_assignment : event_occurrence_assignment, ObjectHelper { applied_event_occurrence_assignment() : Object("applied_event_occurrence_assignment") {} - ListOf< event_occurrence_item, 1, 0 >::Out items; - }; - - // C++ wrapper for identification_assignment - struct identification_assignment : ObjectHelper { identification_assignment() : Object("identification_assignment") {} - identifier::Out assigned_id; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for external_identification_assignment - struct external_identification_assignment : identification_assignment, ObjectHelper { external_identification_assignment() : Object("external_identification_assignment") {} - Lazy< external_source > source; - }; - - // C++ wrapper for applied_external_identification_assignment - struct applied_external_identification_assignment : external_identification_assignment, ObjectHelper { applied_external_identification_assignment() : Object("applied_external_identification_assignment") {} - ListOf< external_identification_item, 1, 0 >::Out items; - }; - - // C++ wrapper for group_assignment - struct group_assignment : ObjectHelper { group_assignment() : Object("group_assignment") {} - Lazy< group > assigned_group; - }; - - // C++ wrapper for applied_group_assignment - struct applied_group_assignment : group_assignment, ObjectHelper { applied_group_assignment() : Object("applied_group_assignment") {} - ListOf< groupable_item, 1, 0 >::Out items; - }; - - // C++ wrapper for applied_identification_assignment - struct applied_identification_assignment : identification_assignment, ObjectHelper { applied_identification_assignment() : Object("applied_identification_assignment") {} - ListOf< identification_item, 1, 0 >::Out items; - }; - - // C++ wrapper for name_assignment - struct name_assignment : ObjectHelper { name_assignment() : Object("name_assignment") {} - label::Out assigned_name; - }; - - // C++ wrapper for applied_name_assignment - struct applied_name_assignment : name_assignment, ObjectHelper { applied_name_assignment() : Object("applied_name_assignment") {} - name_item::Out item; - }; - - // C++ wrapper for organization_assignment - struct organization_assignment : ObjectHelper { organization_assignment() : Object("organization_assignment") {} - Lazy< NotImplemented > assigned_organization; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_organization_assignment - struct applied_organization_assignment : organization_assignment, ObjectHelper { applied_organization_assignment() : Object("applied_organization_assignment") {} - ListOf< organization_item, 1, 0 >::Out items; - }; - - // C++ wrapper for organizational_project_assignment - struct organizational_project_assignment : ObjectHelper { organizational_project_assignment() : Object("organizational_project_assignment") {} - Lazy< NotImplemented > assigned_organizational_project; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_organizational_project_assignment - struct applied_organizational_project_assignment : organizational_project_assignment, ObjectHelper { applied_organizational_project_assignment() : Object("applied_organizational_project_assignment") {} - ListOf< project_item, 1, 0 >::Out items; - }; - - // C++ wrapper for person_and_organization_assignment - struct person_and_organization_assignment : ObjectHelper { person_and_organization_assignment() : Object("person_and_organization_assignment") {} - Lazy< NotImplemented > assigned_person_and_organization; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_person_and_organization_assignment - struct applied_person_and_organization_assignment : person_and_organization_assignment, ObjectHelper { applied_person_and_organization_assignment() : Object("applied_person_and_organization_assignment") {} - ListOf< person_and_organization_item, 1, 0 >::Out items; - }; - - // C++ wrapper for presented_item - struct presented_item : ObjectHelper { presented_item() : Object("presented_item") {} - - }; - - // C++ wrapper for applied_presented_item - struct applied_presented_item : presented_item, ObjectHelper { applied_presented_item() : Object("applied_presented_item") {} - ListOf< presented_item_select, 1, 0 >::Out items; - }; - - // C++ wrapper for security_classification_assignment - struct security_classification_assignment : ObjectHelper { security_classification_assignment() : Object("security_classification_assignment") {} - Lazy< NotImplemented > assigned_security_classification; - }; - - // C++ wrapper for applied_security_classification_assignment - struct applied_security_classification_assignment : security_classification_assignment, ObjectHelper { applied_security_classification_assignment() : Object("applied_security_classification_assignment") {} - ListOf< security_classification_item, 1, 0 >::Out items; - }; - - // C++ wrapper for time_interval_assignment - struct time_interval_assignment : ObjectHelper { time_interval_assignment() : Object("time_interval_assignment") {} - Lazy< time_interval > assigned_time_interval; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for applied_time_interval_assignment - struct applied_time_interval_assignment : time_interval_assignment, ObjectHelper { applied_time_interval_assignment() : Object("applied_time_interval_assignment") {} - ListOf< time_interval_item, 0, 0 >::Out items; - }; - - // C++ wrapper for applied_usage_right - struct applied_usage_right : applied_action_assignment, ObjectHelper { applied_usage_right() : Object("applied_usage_right") {} - - }; - - // C++ wrapper for area_in_set - struct area_in_set : ObjectHelper { area_in_set() : Object("area_in_set") {} - Lazy< presentation_area > area; - Lazy< presentation_set > in_set; - }; - - // C++ wrapper for area_measure_with_unit - struct area_measure_with_unit : measure_with_unit, ObjectHelper { area_measure_with_unit() : Object("area_measure_with_unit") {} - - }; - - // C++ wrapper for area_unit - struct area_unit : derived_unit, ObjectHelper { area_unit() : Object("area_unit") {} - - }; - - // C++ wrapper for product_definition_relationship - struct product_definition_relationship : ObjectHelper { product_definition_relationship() : Object("product_definition_relationship") {} - identifier::Out id; - label::Out name; - Maybe< text::Out > description; - Lazy< product_definition > relating_product_definition; - Lazy< product_definition > related_product_definition; - }; - - // C++ wrapper for product_definition_usage - struct product_definition_usage : product_definition_relationship, ObjectHelper { product_definition_usage() : Object("product_definition_usage") {} - - }; - - // C++ wrapper for assembly_component_usage - struct assembly_component_usage : product_definition_usage, ObjectHelper { assembly_component_usage() : Object("assembly_component_usage") {} - Maybe< identifier::Out > reference_designator; - }; - - // C++ wrapper for assigned_requirement - struct assigned_requirement : group_assignment, ObjectHelper { assigned_requirement() : Object("assigned_requirement") {} - ListOf< Lazy< product_definition >, 1, 1 > items; - }; - - // C++ wrapper for compound_representation_item - struct compound_representation_item : representation_item, ObjectHelper { compound_representation_item() : Object("compound_representation_item") {} - compound_item_definition::Out item_element; - }; - - // C++ wrapper for atomic_formula - struct atomic_formula : compound_representation_item, ObjectHelper { atomic_formula() : Object("atomic_formula") {} - - }; - - // C++ wrapper for attribute_assertion - struct attribute_assertion : ObjectHelper { attribute_assertion() : Object("attribute_assertion") {} - - }; - - // C++ wrapper for attribute_language_assignment - struct attribute_language_assignment : attribute_classification_assignment, ObjectHelper { attribute_language_assignment() : Object("attribute_language_assignment") {} - ListOf< attribute_language_item, 1, 0 >::Out items; - }; - - // C++ wrapper for attribute_value_assignment - struct attribute_value_assignment : ObjectHelper { attribute_value_assignment() : Object("attribute_value_assignment") {} - label::Out attribute_name; - attribute_type::Out attribute_value; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for auxiliary_geometric_representation_item - struct auxiliary_geometric_representation_item : ObjectHelper { auxiliary_geometric_representation_item() : Object("auxiliary_geometric_representation_item") {} - - }; - - // C++ wrapper for placement - struct placement : geometric_representation_item, ObjectHelper { placement() : Object("placement") {} - Lazy< cartesian_point > location; - }; - - // C++ wrapper for axis1_placement - struct axis1_placement : placement, ObjectHelper { axis1_placement() : Object("axis1_placement") {} - Maybe< Lazy< direction > > axis; - }; - - // C++ wrapper for axis2_placement_2d - struct axis2_placement_2d : placement, ObjectHelper { axis2_placement_2d() : Object("axis2_placement_2d") {} - Maybe< Lazy< direction > > ref_direction; - }; - - // C++ wrapper for axis2_placement_3d - struct axis2_placement_3d : placement, ObjectHelper { axis2_placement_3d() : Object("axis2_placement_3d") {} - Maybe< Lazy< direction > > axis; - Maybe< Lazy< direction > > ref_direction; - }; - - // C++ wrapper for curve - struct curve : geometric_representation_item, ObjectHelper { curve() : Object("curve") {} - - }; - - // C++ wrapper for bounded_curve - struct bounded_curve : curve, ObjectHelper { bounded_curve() : Object("bounded_curve") {} - - }; - - // C++ wrapper for b_spline_curve - struct b_spline_curve : bounded_curve, ObjectHelper { b_spline_curve() : Object("b_spline_curve") {} - INTEGER::Out degree; - ListOf< Lazy< cartesian_point >, 2, 0 > control_points_list; - b_spline_curve_form::Out curve_form; - LOGICAL::Out closed_curve; - LOGICAL::Out self_intersect; - }; - - // C++ wrapper for b_spline_curve_with_knots - struct b_spline_curve_with_knots : b_spline_curve, ObjectHelper { b_spline_curve_with_knots() : Object("b_spline_curve_with_knots") {} - ListOf< INTEGER, 2, 0 >::Out knot_multiplicities; - ListOf< parameter_value, 2, 0 >::Out knots; - knot_type::Out knot_spec; - }; - - // C++ wrapper for surface - struct surface : geometric_representation_item, ObjectHelper { surface() : Object("surface") {} - - }; - - // C++ wrapper for bounded_surface - struct bounded_surface : surface, ObjectHelper { bounded_surface() : Object("bounded_surface") {} - - }; - - // C++ wrapper for b_spline_surface - struct b_spline_surface : bounded_surface, ObjectHelper { b_spline_surface() : Object("b_spline_surface") {} - INTEGER::Out u_degree; - INTEGER::Out v_degree; - b_spline_surface_form::Out surface_form; - LOGICAL::Out u_closed; - LOGICAL::Out v_closed; - LOGICAL::Out self_intersect; - }; - - // C++ wrapper for b_spline_surface_with_knots - struct b_spline_surface_with_knots : b_spline_surface, ObjectHelper { b_spline_surface_with_knots() : Object("b_spline_surface_with_knots") {} - ListOf< INTEGER, 2, 0 >::Out u_multiplicities; - ListOf< INTEGER, 2, 0 >::Out v_multiplicities; - ListOf< parameter_value, 2, 0 >::Out u_knots; - ListOf< parameter_value, 2, 0 >::Out v_knots; - knot_type::Out knot_spec; - }; - - // C++ wrapper for product_definition - struct product_definition : ObjectHelper { product_definition() : Object("product_definition") {} - identifier::Out id; - Maybe< text::Out > description; - Lazy< product_definition_formation > formation; - Lazy< product_definition_context > frame_of_reference; - }; - - // C++ wrapper for rule_software_definition - struct rule_software_definition : product_definition, ObjectHelper { rule_software_definition() : Object("rule_software_definition") {} - - }; - - // C++ wrapper for rule_definition - struct rule_definition : rule_software_definition, ObjectHelper { rule_definition() : Object("rule_definition") {} - - }; - - // C++ wrapper for back_chaining_rule - struct back_chaining_rule : rule_definition, ObjectHelper { back_chaining_rule() : Object("back_chaining_rule") {} - - }; - - // C++ wrapper for back_chaining_rule_body - struct back_chaining_rule_body : ObjectHelper { back_chaining_rule_body() : Object("back_chaining_rule_body") {} - - }; - - // C++ wrapper for colour - struct colour : ObjectHelper { colour() : Object("colour") {} - - }; - - // C++ wrapper for background_colour - struct background_colour : colour, ObjectHelper { background_colour() : Object("background_colour") {} - area_or_view::Out presentation; - }; - - // C++ wrapper for beveled_sheet_representation - struct beveled_sheet_representation : shape_representation, ObjectHelper { beveled_sheet_representation() : Object("beveled_sheet_representation") {} - - }; - - // C++ wrapper for bezier_curve - struct bezier_curve : b_spline_curve, ObjectHelper { bezier_curve() : Object("bezier_curve") {} - - }; - - // C++ wrapper for bezier_surface - struct bezier_surface : b_spline_surface, ObjectHelper { bezier_surface() : Object("bezier_surface") {} - - }; - - // C++ wrapper for generic_expression - struct generic_expression : ObjectHelper { generic_expression() : Object("generic_expression") {} - - }; - - // C++ wrapper for binary_generic_expression - struct binary_generic_expression : generic_expression, ObjectHelper { binary_generic_expression() : Object("binary_generic_expression") {} - ListOf< Lazy< generic_expression >, 2, 2 > operands; - }; - - // C++ wrapper for binary_numeric_expression - struct binary_numeric_expression : ObjectHelper { binary_numeric_expression() : Object("binary_numeric_expression") {} - - }; - - // C++ wrapper for binary_representation_item - struct binary_representation_item : representation_item, ObjectHelper { binary_representation_item() : Object("binary_representation_item") {} - BINARY::Out binary_value; - }; - - // C++ wrapper for block - struct block : geometric_representation_item, ObjectHelper { block() : Object("block") {} - Lazy< axis2_placement_3d > position; - positive_length_measure::Out x; - positive_length_measure::Out y; - positive_length_measure::Out z; - }; - - // C++ wrapper for expression - struct expression : generic_expression, ObjectHelper { expression() : Object("expression") {} - - }; - - // C++ wrapper for boolean_expression - struct boolean_expression : expression, ObjectHelper { boolean_expression() : Object("boolean_expression") {} - - }; - - // C++ wrapper for boolean_literal - struct boolean_literal : ObjectHelper { boolean_literal() : Object("boolean_literal") {} - BOOLEAN::Out the_value; - }; - - // C++ wrapper for boolean_representation_item - struct boolean_representation_item : ObjectHelper { boolean_representation_item() : Object("boolean_representation_item") {} - - }; - - // C++ wrapper for boolean_result - struct boolean_result : geometric_representation_item, ObjectHelper { boolean_result() : Object("boolean_result") {} - boolean_operator::Out operator_; - boolean_operand::Out first_operand; - boolean_operand::Out second_operand; - }; - - // C++ wrapper for composite_curve - struct composite_curve : bounded_curve, ObjectHelper { composite_curve() : Object("composite_curve") {} - ListOf< Lazy< composite_curve_segment >, 1, 0 > segments; - LOGICAL::Out self_intersect; - }; - - // C++ wrapper for composite_curve_on_surface - struct composite_curve_on_surface : composite_curve, ObjectHelper { composite_curve_on_surface() : Object("composite_curve_on_surface") {} - - }; - - // C++ wrapper for boundary_curve - struct boundary_curve : composite_curve_on_surface, ObjectHelper { boundary_curve() : Object("boundary_curve") {} - - }; - - // C++ wrapper for bounded_pcurve - struct bounded_pcurve : ObjectHelper { bounded_pcurve() : Object("bounded_pcurve") {} - - }; - - // C++ wrapper for bounded_surface_curve - struct bounded_surface_curve : ObjectHelper { bounded_surface_curve() : Object("bounded_surface_curve") {} - - }; - - // C++ wrapper for founded_item - struct founded_item : ObjectHelper { founded_item() : Object("founded_item") {} - - }; - - // C++ wrapper for box_domain - struct box_domain : founded_item, ObjectHelper { box_domain() : Object("box_domain") {} - Lazy< cartesian_point > corner; - positive_length_measure::Out xlength; - positive_length_measure::Out ylength; - positive_length_measure::Out zlength; - }; - - // C++ wrapper for half_space_solid - struct half_space_solid : geometric_representation_item, ObjectHelper { half_space_solid() : Object("half_space_solid") {} - Lazy< surface > base_surface; - BOOLEAN::Out agreement_flag; - }; - - // C++ wrapper for boxed_half_space - struct boxed_half_space : half_space_solid, ObjectHelper { boxed_half_space() : Object("boxed_half_space") {} - Lazy< box_domain > enclosure; - }; - - // C++ wrapper for breakdown_context - struct breakdown_context : product_definition_relationship, ObjectHelper { breakdown_context() : Object("breakdown_context") {} - - }; - - // C++ wrapper for breakdown_element_group_assignment - struct breakdown_element_group_assignment : group_assignment, ObjectHelper { breakdown_element_group_assignment() : Object("breakdown_element_group_assignment") {} - ListOf< product_definition_or_breakdown_element_usage, 1, 1 >::Out items; - }; - - // C++ wrapper for breakdown_element_realization - struct breakdown_element_realization : ObjectHelper { breakdown_element_realization() : Object("breakdown_element_realization") {} - - }; - - // C++ wrapper for breakdown_element_usage - struct breakdown_element_usage : product_definition_relationship, ObjectHelper { breakdown_element_usage() : Object("breakdown_element_usage") {} - - }; - - // C++ wrapper for breakdown_of - struct breakdown_of : product_definition_relationship, ObjectHelper { breakdown_of() : Object("breakdown_of") {} - - }; - - // C++ wrapper for solid_model - struct solid_model : geometric_representation_item, ObjectHelper { solid_model() : Object("solid_model") {} - - }; - - // C++ wrapper for manifold_solid_brep - struct manifold_solid_brep : solid_model, ObjectHelper { manifold_solid_brep() : Object("manifold_solid_brep") {} - Lazy< closed_shell > outer; - }; - - // C++ wrapper for brep_with_voids - struct brep_with_voids : manifold_solid_brep, ObjectHelper { brep_with_voids() : Object("brep_with_voids") {} - ListOf< Lazy< oriented_closed_shell >, 1, 0 > voids; - }; - - // C++ wrapper for bytes_representation_item - struct bytes_representation_item : binary_representation_item, ObjectHelper { bytes_representation_item() : Object("bytes_representation_item") {} - - }; - - // C++ wrapper for date - struct date : ObjectHelper { date() : Object("date") {} - year_number::Out year_component; - }; - - // C++ wrapper for calendar_date - struct calendar_date : date, ObjectHelper { calendar_date() : Object("calendar_date") {} - day_in_month_number::Out day_component; - month_in_year_number::Out month_component; - }; - - // C++ wrapper for camera_image - struct camera_image : mapped_item, ObjectHelper { camera_image() : Object("camera_image") {} - - }; - - // C++ wrapper for camera_image_3d_with_scale - struct camera_image_3d_with_scale : camera_image, ObjectHelper { camera_image_3d_with_scale() : Object("camera_image_3d_with_scale") {} - - }; - - // C++ wrapper for camera_model - struct camera_model : geometric_representation_item, ObjectHelper { camera_model() : Object("camera_model") {} - - }; - - // C++ wrapper for camera_model_d3 - struct camera_model_d3 : camera_model, ObjectHelper { camera_model_d3() : Object("camera_model_d3") {} - Lazy< axis2_placement_3d > view_reference_system; - Lazy< view_volume > perspective_of_volume; - }; - - // C++ wrapper for camera_model_d3_multi_clipping - struct camera_model_d3_multi_clipping : camera_model_d3, ObjectHelper { camera_model_d3_multi_clipping() : Object("camera_model_d3_multi_clipping") {} - ListOf< camera_model_d3_multi_clipping_interection_select, 1, 0 >::Out shape_clipping; - }; - - // C++ wrapper for camera_model_d3_multi_clipping_intersection - struct camera_model_d3_multi_clipping_intersection : geometric_representation_item, ObjectHelper { camera_model_d3_multi_clipping_intersection() : Object("camera_model_d3_multi_clipping_intersection") {} - ListOf< camera_model_d3_multi_clipping_interection_select, 2, 0 >::Out shape_clipping; - }; - - // C++ wrapper for camera_model_d3_multi_clipping_union - struct camera_model_d3_multi_clipping_union : geometric_representation_item, ObjectHelper { camera_model_d3_multi_clipping_union() : Object("camera_model_d3_multi_clipping_union") {} - ListOf< camera_model_d3_multi_clipping_union_select, 2, 0 >::Out shape_clipping; - }; - - // C++ wrapper for camera_model_d3_with_hlhsr - struct camera_model_d3_with_hlhsr : camera_model_d3, ObjectHelper { camera_model_d3_with_hlhsr() : Object("camera_model_d3_with_hlhsr") {} - BOOLEAN::Out hidden_line_surface_removal; - }; - - // C++ wrapper for camera_model_with_light_sources - struct camera_model_with_light_sources : camera_model_d3, ObjectHelper { camera_model_with_light_sources() : Object("camera_model_with_light_sources") {} - ListOf< Lazy< light_source >, 1, 0 > sources; - }; - - // C++ wrapper for representation_map - struct representation_map : ObjectHelper { representation_map() : Object("representation_map") {} - Lazy< representation_item > mapping_origin; - Lazy< representation > mapped_representation; - }; - - // C++ wrapper for camera_usage - struct camera_usage : representation_map, ObjectHelper { camera_usage() : Object("camera_usage") {} - - }; - - // C++ wrapper for capacitance_measure_with_unit - struct capacitance_measure_with_unit : measure_with_unit, ObjectHelper { capacitance_measure_with_unit() : Object("capacitance_measure_with_unit") {} - - }; - - // C++ wrapper for capacitance_unit - struct capacitance_unit : derived_unit, ObjectHelper { capacitance_unit() : Object("capacitance_unit") {} - - }; - - // C++ wrapper for point - struct point : geometric_representation_item, ObjectHelper { point() : Object("point") {} - - }; - - // C++ wrapper for cartesian_point - struct cartesian_point : point, ObjectHelper { cartesian_point() : Object("cartesian_point") {} - ListOf< length_measure, 1, 3 >::Out coordinates; - }; - - // C++ wrapper for cartesian_transformation_operator - struct cartesian_transformation_operator : ObjectHelper { cartesian_transformation_operator() : Object("cartesian_transformation_operator") {} - Maybe< Lazy< direction > > axis1; - Maybe< Lazy< direction > > axis2; - Lazy< cartesian_point > local_origin; - Maybe< REAL::Out > scale; - }; - - // C++ wrapper for cartesian_transformation_operator_2d - struct cartesian_transformation_operator_2d : cartesian_transformation_operator, ObjectHelper { cartesian_transformation_operator_2d() : Object("cartesian_transformation_operator_2d") {} - - }; - - // C++ wrapper for cartesian_transformation_operator_3d - struct cartesian_transformation_operator_3d : cartesian_transformation_operator, ObjectHelper { cartesian_transformation_operator_3d() : Object("cartesian_transformation_operator_3d") {} - Maybe< Lazy< direction > > axis3; - }; - - // C++ wrapper for cc_design_approval - struct cc_design_approval : approval_assignment, ObjectHelper { cc_design_approval() : Object("cc_design_approval") {} - ListOf< approved_item, 1, 0 >::Out items; - }; - - // C++ wrapper for cc_design_certification - struct cc_design_certification : certification_assignment, ObjectHelper { cc_design_certification() : Object("cc_design_certification") {} - ListOf< certified_item, 1, 0 >::Out items; - }; - - // C++ wrapper for cc_design_contract - struct cc_design_contract : contract_assignment, ObjectHelper { cc_design_contract() : Object("cc_design_contract") {} - ListOf< contracted_item, 1, 0 >::Out items; - }; - - // C++ wrapper for cc_design_date_and_time_assignment - struct cc_design_date_and_time_assignment : date_and_time_assignment, ObjectHelper { cc_design_date_and_time_assignment() : Object("cc_design_date_and_time_assignment") {} - ListOf< date_time_item, 1, 0 >::Out items; - }; - - // C++ wrapper for cc_design_person_and_organization_assignment - struct cc_design_person_and_organization_assignment : person_and_organization_assignment, ObjectHelper { cc_design_person_and_organization_assignment() : Object("cc_design_person_and_organization_assignment") {} - ListOf< cc_person_organization_item, 1, 0 >::Out items; - }; - - // C++ wrapper for cc_design_security_classification - struct cc_design_security_classification : security_classification_assignment, ObjectHelper { cc_design_security_classification() : Object("cc_design_security_classification") {} - ListOf< cc_classified_item, 1, 0 >::Out items; - }; - - // C++ wrapper for cc_design_specification_reference - struct cc_design_specification_reference : document_reference, ObjectHelper { cc_design_specification_reference() : Object("cc_design_specification_reference") {} - ListOf< cc_specified_item, 1, 0 >::Out items; - }; - - // C++ wrapper for celsius_temperature_measure_with_unit - struct celsius_temperature_measure_with_unit : measure_with_unit, ObjectHelper { celsius_temperature_measure_with_unit() : Object("celsius_temperature_measure_with_unit") {} - - }; - - // C++ wrapper for centre_of_symmetry - struct centre_of_symmetry : derived_shape_aspect, ObjectHelper { centre_of_symmetry() : Object("centre_of_symmetry") {} - - }; - - // C++ wrapper for change - struct change : action_assignment, ObjectHelper { change() : Object("change") {} - ListOf< work_item, 1, 0 >::Out items; - }; - - // C++ wrapper for change_request - struct change_request : action_request_assignment, ObjectHelper { change_request() : Object("change_request") {} - ListOf< change_request_item, 1, 0 >::Out items; - }; - - // C++ wrapper for character_glyph_style_outline - struct character_glyph_style_outline : founded_item, ObjectHelper { character_glyph_style_outline() : Object("character_glyph_style_outline") {} - Lazy< curve_style > outline_style; - }; - - // C++ wrapper for character_glyph_style_stroke - struct character_glyph_style_stroke : founded_item, ObjectHelper { character_glyph_style_stroke() : Object("character_glyph_style_stroke") {} - Lazy< curve_style > stroke_style; - }; - - // C++ wrapper for symbol_representation - struct symbol_representation : representation, ObjectHelper { symbol_representation() : Object("symbol_representation") {} - - }; - - // C++ wrapper for generic_character_glyph_symbol - struct generic_character_glyph_symbol : symbol_representation, ObjectHelper { generic_character_glyph_symbol() : Object("generic_character_glyph_symbol") {} - - }; - - // C++ wrapper for character_glyph_symbol - struct character_glyph_symbol : generic_character_glyph_symbol, ObjectHelper { character_glyph_symbol() : Object("character_glyph_symbol") {} - Lazy< planar_extent > character_box; - ratio_measure::Out baseline_ratio; - }; - - // C++ wrapper for character_glyph_symbol_outline - struct character_glyph_symbol_outline : character_glyph_symbol, ObjectHelper { character_glyph_symbol_outline() : Object("character_glyph_symbol_outline") {} - ListOf< Lazy< annotation_fill_area >, 1, 0 > outlines; - }; - - // C++ wrapper for character_glyph_symbol_stroke - struct character_glyph_symbol_stroke : character_glyph_symbol, ObjectHelper { character_glyph_symbol_stroke() : Object("character_glyph_symbol_stroke") {} - ListOf< Lazy< curve >, 1, 0 > strokes; - }; - - // C++ wrapper for general_property - struct general_property : ObjectHelper { general_property() : Object("general_property") {} - identifier::Out id; - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for characteristic_data_column_header - struct characteristic_data_column_header : general_property, ObjectHelper { characteristic_data_column_header() : Object("characteristic_data_column_header") {} - - }; - - // C++ wrapper for general_property_relationship - struct general_property_relationship : ObjectHelper { general_property_relationship() : Object("general_property_relationship") {} - label::Out name; - Maybe< text::Out > description; - Lazy< general_property > relating_property; - Lazy< general_property > related_property; - }; - - // C++ wrapper for characteristic_data_column_header_link - struct characteristic_data_column_header_link : general_property_relationship, ObjectHelper { characteristic_data_column_header_link() : Object("characteristic_data_column_header_link") {} - - }; - - // C++ wrapper for characteristic_data_table_header - struct characteristic_data_table_header : general_property, ObjectHelper { characteristic_data_table_header() : Object("characteristic_data_table_header") {} - - }; - - // C++ wrapper for characteristic_data_table_header_decomposition - struct characteristic_data_table_header_decomposition : general_property_relationship, ObjectHelper { characteristic_data_table_header_decomposition() : Object("characteristic_data_table_header_decomposition") {} - - }; - - // C++ wrapper for group - struct group : ObjectHelper { group() : Object("group") {} - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for characteristic_type - struct characteristic_type : group, ObjectHelper { characteristic_type() : Object("characteristic_type") {} - - }; - - // C++ wrapper for characterized_class - struct characterized_class : ObjectHelper { characterized_class() : Object("characterized_class") {} - - }; - - // C++ wrapper for characterized_object - struct characterized_object : ObjectHelper { characterized_object() : Object("characterized_object") {} - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for conic - struct conic : curve, ObjectHelper { conic() : Object("conic") {} - axis2_placement::Out position; - }; - - // C++ wrapper for circle - struct circle : conic, ObjectHelper { circle() : Object("circle") {} - positive_length_measure::Out radius; - }; - - // C++ wrapper for circular_runout_tolerance - struct circular_runout_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { circular_runout_tolerance() : Object("circular_runout_tolerance") {} - - }; - - // C++ wrapper for class_by_extension - struct class_by_extension : class_t, ObjectHelper { class_by_extension() : Object("class_by_extension") {} - - }; - - // C++ wrapper for class_by_intension - struct class_by_intension : class_t, ObjectHelper { class_by_intension() : Object("class_by_intension") {} - - }; - - // C++ wrapper for class_system - struct class_system : group, ObjectHelper { class_system() : Object("class_system") {} - - }; - - // C++ wrapper for effectivity_context_assignment - struct effectivity_context_assignment : ObjectHelper { effectivity_context_assignment() : Object("effectivity_context_assignment") {} - Lazy< effectivity_assignment > assigned_effectivity_assignment; - Lazy< NotImplemented > role; - }; - - // C++ wrapper for class_usage_effectivity_context_assignment - struct class_usage_effectivity_context_assignment : effectivity_context_assignment, ObjectHelper { class_usage_effectivity_context_assignment() : Object("class_usage_effectivity_context_assignment") {} - ListOf< class_usage_effectivity_context_item, 1, 0 >::Out items; - }; - - // C++ wrapper for topological_representation_item - struct topological_representation_item : representation_item, ObjectHelper { topological_representation_item() : Object("topological_representation_item") {} - - }; - - // C++ wrapper for connected_face_set - struct connected_face_set : topological_representation_item, ObjectHelper { connected_face_set() : Object("connected_face_set") {} - ListOf< Lazy< face >, 1, 0 > cfs_faces; - }; - - // C++ wrapper for closed_shell - struct closed_shell : connected_face_set, ObjectHelper { closed_shell() : Object("closed_shell") {} - - }; - - // C++ wrapper for coaxiality_tolerance - struct coaxiality_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { coaxiality_tolerance() : Object("coaxiality_tolerance") {} - - }; - - // C++ wrapper for colour_specification - struct colour_specification : colour, ObjectHelper { colour_specification() : Object("colour_specification") {} - label::Out name; - }; - - // C++ wrapper for colour_rgb - struct colour_rgb : colour_specification, ObjectHelper { colour_rgb() : Object("colour_rgb") {} - REAL::Out red; - REAL::Out green; - REAL::Out blue; - }; - - // C++ wrapper for common_datum - struct common_datum : ObjectHelper { common_datum() : Object("common_datum") {} - - }; - - // C++ wrapper for comparison_expression - struct comparison_expression : ObjectHelper { comparison_expression() : Object("comparison_expression") {} - - }; - - // C++ wrapper for complex_clause - struct complex_clause : compound_representation_item, ObjectHelper { complex_clause() : Object("complex_clause") {} - - }; - - // C++ wrapper for complex_conjunctive_clause - struct complex_conjunctive_clause : complex_clause, ObjectHelper { complex_conjunctive_clause() : Object("complex_conjunctive_clause") {} - - }; - - // C++ wrapper for complex_disjunctive_clause - struct complex_disjunctive_clause : complex_clause, ObjectHelper { complex_disjunctive_clause() : Object("complex_disjunctive_clause") {} - - }; - - // C++ wrapper for modified_solid - struct modified_solid : solid_model, ObjectHelper { modified_solid() : Object("modified_solid") {} - text::Out rationale; - base_solid_select::Out base_solid; - }; - - // C++ wrapper for shelled_solid - struct shelled_solid : modified_solid, ObjectHelper { shelled_solid() : Object("shelled_solid") {} - ListOf< Lazy< face_surface >, 1, 0 > deleted_face_set; - length_measure::Out thickness; - }; - - // C++ wrapper for complex_shelled_solid - struct complex_shelled_solid : shelled_solid, ObjectHelper { complex_shelled_solid() : Object("complex_shelled_solid") {} - ListOf< length_measure, 1, 0 >::Out thickness_list; - }; - - // C++ wrapper for composite_assembly_definition - struct composite_assembly_definition : product_definition, ObjectHelper { composite_assembly_definition() : Object("composite_assembly_definition") {} - - }; - - // C++ wrapper for composite_assembly_sequence_definition - struct composite_assembly_sequence_definition : product_definition, ObjectHelper { composite_assembly_sequence_definition() : Object("composite_assembly_sequence_definition") {} - - }; - - // C++ wrapper for laminate_table - struct laminate_table : product_definition, ObjectHelper { laminate_table() : Object("laminate_table") {} - - }; - - // C++ wrapper for part_laminate_table - struct part_laminate_table : laminate_table, ObjectHelper { part_laminate_table() : Object("part_laminate_table") {} - - }; - - // C++ wrapper for composite_assembly_table - struct composite_assembly_table : part_laminate_table, ObjectHelper { composite_assembly_table() : Object("composite_assembly_table") {} - - }; - - // C++ wrapper for composite_curve_segment - struct composite_curve_segment : founded_item, ObjectHelper { composite_curve_segment() : Object("composite_curve_segment") {} - transition_code::Out transition; - BOOLEAN::Out same_sense; - Lazy< curve > parent_curve; - }; - - // C++ wrapper for material_designation - struct material_designation : ObjectHelper { material_designation() : Object("material_designation") {} - label::Out name; - ListOf< characterized_definition, 1, 0 >::Out definitions; - }; - - // C++ wrapper for composite_material_designation - struct composite_material_designation : material_designation, ObjectHelper { composite_material_designation() : Object("composite_material_designation") {} - - }; - - // C++ wrapper for composite_shape_aspect - struct composite_shape_aspect : shape_aspect, ObjectHelper { composite_shape_aspect() : Object("composite_shape_aspect") {} - - }; - - // C++ wrapper for composite_sheet_representation - struct composite_sheet_representation : shape_representation, ObjectHelper { composite_sheet_representation() : Object("composite_sheet_representation") {} - - }; - - // C++ wrapper for composite_text - struct composite_text : geometric_representation_item, ObjectHelper { composite_text() : Object("composite_text") {} - ListOf< text_or_character, 2, 0 >::Out collected_text; - }; - - // C++ wrapper for composite_text_with_associated_curves - struct composite_text_with_associated_curves : composite_text, ObjectHelper { composite_text_with_associated_curves() : Object("composite_text_with_associated_curves") {} - ListOf< Lazy< curve >, 1, 0 > associated_curves; - }; - - // C++ wrapper for composite_text_with_blanking_box - struct composite_text_with_blanking_box : composite_text, ObjectHelper { composite_text_with_blanking_box() : Object("composite_text_with_blanking_box") {} - Lazy< planar_box > blanking; - }; - - // C++ wrapper for composite_text_with_delineation - struct composite_text_with_delineation : composite_text, ObjectHelper { composite_text_with_delineation() : Object("composite_text_with_delineation") {} - text_delineation::Out delineation; - }; - - // C++ wrapper for composite_text_with_extent - struct composite_text_with_extent : composite_text, ObjectHelper { composite_text_with_extent() : Object("composite_text_with_extent") {} - Lazy< planar_extent > extent; - }; - - // C++ wrapper for compound_shape_representation - struct compound_shape_representation : shape_representation, ObjectHelper { compound_shape_representation() : Object("compound_shape_representation") {} - - }; - - // C++ wrapper for concentricity_tolerance - struct concentricity_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { concentricity_tolerance() : Object("concentricity_tolerance") {} - - }; - - // C++ wrapper for concept_feature_relationship - struct concept_feature_relationship : ObjectHelper { concept_feature_relationship() : Object("concept_feature_relationship") {} - label::Out name; - Maybe< text::Out > description; - Lazy< product_concept_feature > relating_product_concept_feature; - Lazy< product_concept_feature > related_product_concept_feature; - }; - - // C++ wrapper for concept_feature_relationship_with_condition - struct concept_feature_relationship_with_condition : concept_feature_relationship, ObjectHelper { concept_feature_relationship_with_condition() : Object("concept_feature_relationship_with_condition") {} - Lazy< NotImplemented > conditional_operator; - }; - - // C++ wrapper for product_concept_feature - struct product_concept_feature : ObjectHelper { product_concept_feature() : Object("product_concept_feature") {} - identifier::Out id; - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for conditional_concept_feature - struct conditional_concept_feature : product_concept_feature, ObjectHelper { conditional_concept_feature() : Object("conditional_concept_feature") {} - Lazy< concept_feature_relationship_with_condition > condition; - }; - - // C++ wrapper for conductance_measure_with_unit - struct conductance_measure_with_unit : measure_with_unit, ObjectHelper { conductance_measure_with_unit() : Object("conductance_measure_with_unit") {} - - }; - - // C++ wrapper for conductance_unit - struct conductance_unit : derived_unit, ObjectHelper { conductance_unit() : Object("conductance_unit") {} - - }; - - // C++ wrapper for configuration_item - struct configuration_item : ObjectHelper { configuration_item() : Object("configuration_item") {} - identifier::Out id; - label::Out name; - Maybe< text::Out > description; - Lazy< NotImplemented > item_concept; - Maybe< label::Out > purpose; - }; - - // C++ wrapper for configurable_item - struct configurable_item : configuration_item, ObjectHelper { configurable_item() : Object("configurable_item") {} - ListOf< Lazy< NotImplemented >, 1, 0 > item_concept_feature; - }; - - // C++ wrapper for effectivity - struct effectivity : ObjectHelper { effectivity() : Object("effectivity") {} - identifier::Out id; - }; - - // C++ wrapper for product_definition_effectivity - struct product_definition_effectivity : effectivity, ObjectHelper { product_definition_effectivity() : Object("product_definition_effectivity") {} - Lazy< product_definition_relationship > usage; - }; - - // C++ wrapper for configuration_effectivity - struct configuration_effectivity : product_definition_effectivity, ObjectHelper { configuration_effectivity() : Object("configuration_effectivity") {} - Lazy< NotImplemented > configuration; - }; - - // C++ wrapper for configuration_item_relationship - struct configuration_item_relationship : ObjectHelper { configuration_item_relationship() : Object("configuration_item_relationship") {} - label::Out name; - Maybe< text::Out > description; - Lazy< configuration_item > relating_configuration_item; - Lazy< configuration_item > related_configuration_item; - }; - - // C++ wrapper for configuration_item_hierarchical_relationship - struct configuration_item_hierarchical_relationship : configuration_item_relationship, ObjectHelper { configuration_item_hierarchical_relationship() : Object("configuration_item_hierarchical_relationship") {} - - }; - - // C++ wrapper for configuration_item_revision_sequence - struct configuration_item_revision_sequence : configuration_item_relationship, ObjectHelper { configuration_item_revision_sequence() : Object("configuration_item_revision_sequence") {} - - }; - - // C++ wrapper for configured_effectivity_assignment - struct configured_effectivity_assignment : effectivity_assignment, ObjectHelper { configured_effectivity_assignment() : Object("configured_effectivity_assignment") {} - ListOf< configured_effectivity_item, 1, 0 >::Out items; - }; - - // C++ wrapper for configured_effectivity_context_assignment - struct configured_effectivity_context_assignment : effectivity_context_assignment, ObjectHelper { configured_effectivity_context_assignment() : Object("configured_effectivity_context_assignment") {} - ListOf< configured_effectivity_context_item, 1, 0 >::Out items; - }; - - // C++ wrapper for conical_stepped_hole_transition - struct conical_stepped_hole_transition : geometric_representation_item, ObjectHelper { conical_stepped_hole_transition() : Object("conical_stepped_hole_transition") {} - positive_integer::Out transition_number; - plane_angle_measure::Out cone_apex_angle; - positive_length_measure::Out cone_base_radius; - }; - - // C++ wrapper for elementary_surface - struct elementary_surface : surface, ObjectHelper { elementary_surface() : Object("elementary_surface") {} - Lazy< axis2_placement_3d > position; - }; - - // C++ wrapper for conical_surface - struct conical_surface : elementary_surface, ObjectHelper { conical_surface() : Object("conical_surface") {} - length_measure::Out radius; - plane_angle_measure::Out semi_angle; - }; - - // C++ wrapper for connected_edge_set - struct connected_edge_set : topological_representation_item, ObjectHelper { connected_edge_set() : Object("connected_edge_set") {} - ListOf< Lazy< edge >, 1, 0 > ces_edges; - }; - - // C++ wrapper for connected_face_sub_set - struct connected_face_sub_set : connected_face_set, ObjectHelper { connected_face_sub_set() : Object("connected_face_sub_set") {} - Lazy< connected_face_set > parent_face_set; - }; - - // C++ wrapper for constructive_geometry_representation - struct constructive_geometry_representation : representation, ObjectHelper { constructive_geometry_representation() : Object("constructive_geometry_representation") {} - - }; - - // C++ wrapper for representation_relationship - struct representation_relationship : ObjectHelper { representation_relationship() : Object("representation_relationship") {} - label::Out name; - Maybe< text::Out > description; - Lazy< representation > rep_1; - Lazy< representation > rep_2; - }; - - // C++ wrapper for constructive_geometry_representation_relationship - struct constructive_geometry_representation_relationship : representation_relationship, ObjectHelper { constructive_geometry_representation_relationship() : Object("constructive_geometry_representation_relationship") {} - - }; - - // C++ wrapper for contact_ratio_representation - struct contact_ratio_representation : representation, ObjectHelper { contact_ratio_representation() : Object("contact_ratio_representation") {} - - }; - - // C++ wrapper for invisibility - struct invisibility : ObjectHelper { invisibility() : Object("invisibility") {} - ListOf< invisible_item, 1, 0 >::Out invisible_items; - }; - - // C++ wrapper for context_dependent_invisibility - struct context_dependent_invisibility : invisibility, ObjectHelper { context_dependent_invisibility() : Object("context_dependent_invisibility") {} - invisibility_context::Out presentation_context; - }; - - // C++ wrapper for over_riding_styled_item - struct over_riding_styled_item : styled_item, ObjectHelper { over_riding_styled_item() : Object("over_riding_styled_item") {} - Lazy< styled_item > over_ridden_style; - }; - - // C++ wrapper for context_dependent_over_riding_styled_item - struct context_dependent_over_riding_styled_item : over_riding_styled_item, ObjectHelper { context_dependent_over_riding_styled_item() : Object("context_dependent_over_riding_styled_item") {} - ListOf< style_context_select, 1, 0 >::Out style_context; - }; - - // C++ wrapper for context_dependent_unit - struct context_dependent_unit : named_unit, ObjectHelper { context_dependent_unit() : Object("context_dependent_unit") {} - label::Out name; - }; - - // C++ wrapper for conversion_based_unit - struct conversion_based_unit : named_unit, ObjectHelper { conversion_based_unit() : Object("conversion_based_unit") {} - label::Out name; - Lazy< measure_with_unit > conversion_factor; - }; - - // C++ wrapper for csg_shape_representation - struct csg_shape_representation : shape_representation, ObjectHelper { csg_shape_representation() : Object("csg_shape_representation") {} - - }; - - // C++ wrapper for csg_solid - struct csg_solid : solid_model, ObjectHelper { csg_solid() : Object("csg_solid") {} - csg_select::Out tree_root_expression; - }; - - // C++ wrapper for currency - struct currency : context_dependent_unit, ObjectHelper { currency() : Object("currency") {} - - }; - - // C++ wrapper for currency_measure_with_unit - struct currency_measure_with_unit : measure_with_unit, ObjectHelper { currency_measure_with_unit() : Object("currency_measure_with_unit") {} - - }; - - // C++ wrapper for curve_bounded_surface - struct curve_bounded_surface : bounded_surface, ObjectHelper { curve_bounded_surface() : Object("curve_bounded_surface") {} - Lazy< surface > basis_surface; - ListOf< Lazy< boundary_curve >, 1, 0 > boundaries; - BOOLEAN::Out implicit_outer; - }; - - // C++ wrapper for curve_dimension - struct curve_dimension : dimension_curve_directed_callout, ObjectHelper { curve_dimension() : Object("curve_dimension") {} - - }; - - // C++ wrapper for curve_replica - struct curve_replica : curve, ObjectHelper { curve_replica() : Object("curve_replica") {} - Lazy< curve > parent_curve; - Lazy< cartesian_transformation_operator > transformation; - }; - - // C++ wrapper for curve_style - struct curve_style : founded_item, ObjectHelper { curve_style() : Object("curve_style") {} - label::Out name; - curve_font_or_scaled_curve_font_select::Out curve_font; - size_select::Out curve_width; - Lazy< colour > curve_colour; - }; - - // C++ wrapper for curve_style_font - struct curve_style_font : founded_item, ObjectHelper { curve_style_font() : Object("curve_style_font") {} - label::Out name; - ListOf< Lazy< curve_style_font_pattern >, 1, 0 > pattern_list; - }; - - // C++ wrapper for curve_style_font_and_scaling - struct curve_style_font_and_scaling : founded_item, ObjectHelper { curve_style_font_and_scaling() : Object("curve_style_font_and_scaling") {} - label::Out name; - curve_style_font_select::Out curve_font; - REAL::Out curve_font_scaling; - }; - - // C++ wrapper for curve_style_font_pattern - struct curve_style_font_pattern : founded_item, ObjectHelper { curve_style_font_pattern() : Object("curve_style_font_pattern") {} - positive_length_measure::Out visible_segment_length; - positive_length_measure::Out invisible_segment_length; - }; - - // C++ wrapper for curve_swept_solid_shape_representation - struct curve_swept_solid_shape_representation : shape_representation, ObjectHelper { curve_swept_solid_shape_representation() : Object("curve_swept_solid_shape_representation") {} - - }; - - // C++ wrapper for cylindrical_surface - struct cylindrical_surface : elementary_surface, ObjectHelper { cylindrical_surface() : Object("cylindrical_surface") {} - positive_length_measure::Out radius; - }; - - // C++ wrapper for cylindricity_tolerance - struct cylindricity_tolerance : geometric_tolerance, ObjectHelper { cylindricity_tolerance() : Object("cylindricity_tolerance") {} - - }; - - // C++ wrapper for date_representation_item - struct date_representation_item : ObjectHelper { date_representation_item() : Object("date_representation_item") {} - - }; - - // C++ wrapper for date_time_representation_item - struct date_time_representation_item : ObjectHelper { date_time_representation_item() : Object("date_time_representation_item") {} - - }; - - // C++ wrapper for dated_effectivity - struct dated_effectivity : effectivity, ObjectHelper { dated_effectivity() : Object("dated_effectivity") {} - Maybe< date_time_or_event_occurrence::Out > effectivity_end_date; - date_time_or_event_occurrence::Out effectivity_start_date; - }; - - // C++ wrapper for datum - struct datum : shape_aspect, ObjectHelper { datum() : Object("datum") {} - identifier::Out identification; - }; - - // C++ wrapper for datum_feature - struct datum_feature : shape_aspect, ObjectHelper { datum_feature() : Object("datum_feature") {} - - }; - - // C++ wrapper for datum_feature_callout - struct datum_feature_callout : draughting_callout, ObjectHelper { datum_feature_callout() : Object("datum_feature_callout") {} - - }; - - // C++ wrapper for datum_reference - struct datum_reference : ObjectHelper { datum_reference() : Object("datum_reference") {} - INTEGER::Out precedence; - Lazy< datum > referenced_datum; - }; - - // C++ wrapper for datum_target - struct datum_target : shape_aspect, ObjectHelper { datum_target() : Object("datum_target") {} - identifier::Out target_id; - }; - - // C++ wrapper for datum_target_callout - struct datum_target_callout : draughting_callout, ObjectHelper { datum_target_callout() : Object("datum_target_callout") {} - - }; - - // C++ wrapper for default_tolerance_table - struct default_tolerance_table : representation, ObjectHelper { default_tolerance_table() : Object("default_tolerance_table") {} - - }; - - // C++ wrapper for default_tolerance_table_cell - struct default_tolerance_table_cell : compound_representation_item, ObjectHelper { default_tolerance_table_cell() : Object("default_tolerance_table_cell") {} - - }; - - // C++ wrapper for defined_symbol - struct defined_symbol : geometric_representation_item, ObjectHelper { defined_symbol() : Object("defined_symbol") {} - defined_symbol_select::Out definition; - Lazy< symbol_target > target; - }; - - // C++ wrapper for definitional_representation - struct definitional_representation : representation, ObjectHelper { definitional_representation() : Object("definitional_representation") {} - - }; - - // C++ wrapper for definitional_representation_relationship - struct definitional_representation_relationship : representation_relationship, ObjectHelper { definitional_representation_relationship() : Object("definitional_representation_relationship") {} - - }; - - // C++ wrapper for definitional_representation_relationship_with_same_context - struct definitional_representation_relationship_with_same_context : definitional_representation_relationship, ObjectHelper { definitional_representation_relationship_with_same_context() : Object("definitional_representation_relationship_with_same_context") {} - - }; - - // C++ wrapper for degenerate_pcurve - struct degenerate_pcurve : point, ObjectHelper { degenerate_pcurve() : Object("degenerate_pcurve") {} - Lazy< surface > basis_surface; - Lazy< definitional_representation > reference_to_curve; - }; - - // C++ wrapper for toroidal_surface - struct toroidal_surface : elementary_surface, ObjectHelper { toroidal_surface() : Object("toroidal_surface") {} - positive_length_measure::Out major_radius; - positive_length_measure::Out minor_radius; - }; - - // C++ wrapper for degenerate_toroidal_surface - struct degenerate_toroidal_surface : toroidal_surface, ObjectHelper { degenerate_toroidal_surface() : Object("degenerate_toroidal_surface") {} - BOOLEAN::Out select_outer; - }; - - // C++ wrapper for descriptive_representation_item - struct descriptive_representation_item : representation_item, ObjectHelper { descriptive_representation_item() : Object("descriptive_representation_item") {} - text::Out description; - }; - - // C++ wrapper for product_definition_context - struct product_definition_context : application_context_element, ObjectHelper { product_definition_context() : Object("product_definition_context") {} - label::Out life_cycle_stage; - }; - - // C++ wrapper for design_context - struct design_context : product_definition_context, ObjectHelper { design_context() : Object("design_context") {} - - }; - - // C++ wrapper for design_make_from_relationship - struct design_make_from_relationship : product_definition_relationship, ObjectHelper { design_make_from_relationship() : Object("design_make_from_relationship") {} - - }; - - // C++ wrapper for diameter_dimension - struct diameter_dimension : dimension_curve_directed_callout, ObjectHelper { diameter_dimension() : Object("diameter_dimension") {} - - }; - - // C++ wrapper for ratio_measure_with_unit - struct ratio_measure_with_unit : measure_with_unit, ObjectHelper { ratio_measure_with_unit() : Object("ratio_measure_with_unit") {} - - }; - - // C++ wrapper for dielectric_constant_measure_with_unit - struct dielectric_constant_measure_with_unit : ratio_measure_with_unit, ObjectHelper { dielectric_constant_measure_with_unit() : Object("dielectric_constant_measure_with_unit") {} - - }; - - // C++ wrapper for dimension_callout - struct dimension_callout : draughting_callout, ObjectHelper { dimension_callout() : Object("dimension_callout") {} - - }; - - // C++ wrapper for draughting_callout_relationship - struct draughting_callout_relationship : ObjectHelper { draughting_callout_relationship() : Object("draughting_callout_relationship") {} - label::Out name; - text::Out description; - Lazy< draughting_callout > relating_draughting_callout; - Lazy< draughting_callout > related_draughting_callout; - }; - - // C++ wrapper for dimension_callout_component_relationship - struct dimension_callout_component_relationship : draughting_callout_relationship, ObjectHelper { dimension_callout_component_relationship() : Object("dimension_callout_component_relationship") {} - - }; - - // C++ wrapper for dimension_callout_relationship - struct dimension_callout_relationship : draughting_callout_relationship, ObjectHelper { dimension_callout_relationship() : Object("dimension_callout_relationship") {} - - }; - - // C++ wrapper for dimension_curve - struct dimension_curve : annotation_curve_occurrence, ObjectHelper { dimension_curve() : Object("dimension_curve") {} - - }; - - // C++ wrapper for terminator_symbol - struct terminator_symbol : annotation_symbol_occurrence, ObjectHelper { terminator_symbol() : Object("terminator_symbol") {} - Lazy< annotation_curve_occurrence > annotated_curve; - }; - - // C++ wrapper for dimension_curve_terminator - struct dimension_curve_terminator : terminator_symbol, ObjectHelper { dimension_curve_terminator() : Object("dimension_curve_terminator") {} - dimension_extent_usage::Out role; - }; - - // C++ wrapper for dimension_curve_terminator_to_projection_curve_associativity - struct dimension_curve_terminator_to_projection_curve_associativity : annotation_occurrence_associativity, ObjectHelper { dimension_curve_terminator_to_projection_curve_associativity() : Object("dimension_curve_terminator_to_projection_curve_associativity") {} - - }; - - // C++ wrapper for dimension_pair - struct dimension_pair : draughting_callout_relationship, ObjectHelper { dimension_pair() : Object("dimension_pair") {} - - }; - - // C++ wrapper for dimension_text_associativity - struct dimension_text_associativity : ObjectHelper { dimension_text_associativity() : Object("dimension_text_associativity") {} - - }; - - // C++ wrapper for dimensional_location_with_path - struct dimensional_location_with_path : dimensional_location, ObjectHelper { dimensional_location_with_path() : Object("dimensional_location_with_path") {} - Lazy< shape_aspect > path; - }; - - // C++ wrapper for dimensional_size_with_path - struct dimensional_size_with_path : dimensional_size, ObjectHelper { dimensional_size_with_path() : Object("dimensional_size_with_path") {} - Lazy< shape_aspect > path; - }; - - // C++ wrapper for executed_action - struct executed_action : action, ObjectHelper { executed_action() : Object("executed_action") {} - - }; - - // C++ wrapper for directed_action - struct directed_action : executed_action, ObjectHelper { directed_action() : Object("directed_action") {} - Lazy< NotImplemented > directive; - }; - - // C++ wrapper for directed_dimensional_location - struct directed_dimensional_location : dimensional_location, ObjectHelper { directed_dimensional_location() : Object("directed_dimensional_location") {} - - }; - - // C++ wrapper for direction - struct direction : geometric_representation_item, ObjectHelper { direction() : Object("direction") {} - ListOf< REAL, 2, 3 >::Out direction_ratios; - }; - - // C++ wrapper for document_file - struct document_file : ObjectHelper { document_file() : Object("document_file") {} - - }; - - // C++ wrapper for document_identifier - struct document_identifier : group, ObjectHelper { document_identifier() : Object("document_identifier") {} - - }; - - // C++ wrapper for document_identifier_assignment - struct document_identifier_assignment : group_assignment, ObjectHelper { document_identifier_assignment() : Object("document_identifier_assignment") {} - ListOf< document_identifier_assigned_item, 1, 0 >::Out items; - }; - - // C++ wrapper for document_product_association - struct document_product_association : ObjectHelper { document_product_association() : Object("document_product_association") {} - label::Out name; - Maybe< text::Out > description; - Lazy< NotImplemented > relating_document; - product_or_formation_or_definition::Out related_product; - }; - - // C++ wrapper for document_product_equivalence - struct document_product_equivalence : document_product_association, ObjectHelper { document_product_equivalence() : Object("document_product_equivalence") {} - - }; - - // C++ wrapper for dose_equivalent_measure_with_unit - struct dose_equivalent_measure_with_unit : measure_with_unit, ObjectHelper { dose_equivalent_measure_with_unit() : Object("dose_equivalent_measure_with_unit") {} - - }; - - // C++ wrapper for dose_equivalent_unit - struct dose_equivalent_unit : derived_unit, ObjectHelper { dose_equivalent_unit() : Object("dose_equivalent_unit") {} - - }; - - // C++ wrapper for double_offset_shelled_solid - struct double_offset_shelled_solid : shelled_solid, ObjectHelper { double_offset_shelled_solid() : Object("double_offset_shelled_solid") {} - length_measure::Out thickness2; - }; - - // C++ wrapper for item_defined_transformation - struct item_defined_transformation : ObjectHelper { item_defined_transformation() : Object("item_defined_transformation") {} - label::Out name; - Maybe< text::Out > description; - Lazy< representation_item > transform_item_1; - Lazy< representation_item > transform_item_2; - }; - - // C++ wrapper for transformation_with_derived_angle - struct transformation_with_derived_angle : item_defined_transformation, ObjectHelper { transformation_with_derived_angle() : Object("transformation_with_derived_angle") {} - - }; - - // C++ wrapper for draped_defined_transformation - struct draped_defined_transformation : transformation_with_derived_angle, ObjectHelper { draped_defined_transformation() : Object("draped_defined_transformation") {} - - }; - - // C++ wrapper for draughting_annotation_occurrence - struct draughting_annotation_occurrence : annotation_occurrence, ObjectHelper { draughting_annotation_occurrence() : Object("draughting_annotation_occurrence") {} - - }; - - // C++ wrapper for draughting_elements - struct draughting_elements : draughting_callout, ObjectHelper { draughting_elements() : Object("draughting_elements") {} - - }; - - // C++ wrapper for draughting_model - struct draughting_model : representation, ObjectHelper { draughting_model() : Object("draughting_model") {} - - }; - - // C++ wrapper for item_identified_representation_usage - struct item_identified_representation_usage : ObjectHelper { item_identified_representation_usage() : Object("item_identified_representation_usage") {} - label::Out name; - Maybe< text::Out > description; - represented_definition::Out definition; - Lazy< representation > used_representation; - Lazy< representation_item > identified_item; - }; - - // C++ wrapper for draughting_model_item_association - struct draughting_model_item_association : item_identified_representation_usage, ObjectHelper { draughting_model_item_association() : Object("draughting_model_item_association") {} - - }; - - // C++ wrapper for pre_defined_colour - struct pre_defined_colour : ObjectHelper { pre_defined_colour() : Object("pre_defined_colour") {} - - }; - - // C++ wrapper for draughting_pre_defined_colour - struct draughting_pre_defined_colour : pre_defined_colour, ObjectHelper { draughting_pre_defined_colour() : Object("draughting_pre_defined_colour") {} - - }; - - // C++ wrapper for pre_defined_item - struct pre_defined_item : ObjectHelper { pre_defined_item() : Object("pre_defined_item") {} - label::Out name; - }; - - // C++ wrapper for pre_defined_curve_font - struct pre_defined_curve_font : pre_defined_item, ObjectHelper { pre_defined_curve_font() : Object("pre_defined_curve_font") {} - - }; - - // C++ wrapper for draughting_pre_defined_curve_font - struct draughting_pre_defined_curve_font : pre_defined_curve_font, ObjectHelper { draughting_pre_defined_curve_font() : Object("draughting_pre_defined_curve_font") {} - - }; - - // C++ wrapper for pre_defined_text_font - struct pre_defined_text_font : pre_defined_item, ObjectHelper { pre_defined_text_font() : Object("pre_defined_text_font") {} - - }; - - // C++ wrapper for draughting_pre_defined_text_font - struct draughting_pre_defined_text_font : pre_defined_text_font, ObjectHelper { draughting_pre_defined_text_font() : Object("draughting_pre_defined_text_font") {} - - }; - - // C++ wrapper for draughting_subfigure_representation - struct draughting_subfigure_representation : symbol_representation, ObjectHelper { draughting_subfigure_representation() : Object("draughting_subfigure_representation") {} - - }; - - // C++ wrapper for draughting_symbol_representation - struct draughting_symbol_representation : symbol_representation, ObjectHelper { draughting_symbol_representation() : Object("draughting_symbol_representation") {} - - }; - - // C++ wrapper for text_literal - struct text_literal : geometric_representation_item, ObjectHelper { text_literal() : Object("text_literal") {} - presentable_text::Out literal; - axis2_placement::Out placement; - text_alignment::Out alignment; - text_path::Out path; - font_select::Out font; - }; - - // C++ wrapper for text_literal_with_delineation - struct text_literal_with_delineation : text_literal, ObjectHelper { text_literal_with_delineation() : Object("text_literal_with_delineation") {} - text_delineation::Out delineation; - }; - - // C++ wrapper for draughting_text_literal_with_delineation - struct draughting_text_literal_with_delineation : text_literal_with_delineation, ObjectHelper { draughting_text_literal_with_delineation() : Object("draughting_text_literal_with_delineation") {} - - }; - - // C++ wrapper for presentation_set - struct presentation_set : ObjectHelper { presentation_set() : Object("presentation_set") {} - - }; - - // C++ wrapper for drawing_revision - struct drawing_revision : presentation_set, ObjectHelper { drawing_revision() : Object("drawing_revision") {} - identifier::Out revision_identifier; - Lazy< NotImplemented > drawing_identifier; - Maybe< text::Out > intended_scale; - }; - - // C++ wrapper for presentation_representation - struct presentation_representation : representation, ObjectHelper { presentation_representation() : Object("presentation_representation") {} - - }; - - // C++ wrapper for presentation_area - struct presentation_area : presentation_representation, ObjectHelper { presentation_area() : Object("presentation_area") {} - - }; - - // C++ wrapper for drawing_sheet_revision - struct drawing_sheet_revision : presentation_area, ObjectHelper { drawing_sheet_revision() : Object("drawing_sheet_revision") {} - identifier::Out revision_identifier; - }; - - // C++ wrapper for drawing_sheet_revision_sequence - struct drawing_sheet_revision_sequence : representation_relationship, ObjectHelper { drawing_sheet_revision_sequence() : Object("drawing_sheet_revision_sequence") {} - - }; - - // C++ wrapper for drawing_sheet_revision_usage - struct drawing_sheet_revision_usage : area_in_set, ObjectHelper { drawing_sheet_revision_usage() : Object("drawing_sheet_revision_usage") {} - identifier::Out sheet_number; - }; - - // C++ wrapper for edge - struct edge : topological_representation_item, ObjectHelper { edge() : Object("edge") {} - Lazy< vertex > edge_start; - Lazy< vertex > edge_end; - }; - - // C++ wrapper for edge_based_wireframe_model - struct edge_based_wireframe_model : geometric_representation_item, ObjectHelper { edge_based_wireframe_model() : Object("edge_based_wireframe_model") {} - ListOf< Lazy< connected_edge_set >, 1, 0 > ebwm_boundary; - }; - - // C++ wrapper for edge_based_wireframe_shape_representation - struct edge_based_wireframe_shape_representation : shape_representation, ObjectHelper { edge_based_wireframe_shape_representation() : Object("edge_based_wireframe_shape_representation") {} - - }; - - // C++ wrapper for edge_blended_solid - struct edge_blended_solid : modified_solid, ObjectHelper { edge_blended_solid() : Object("edge_blended_solid") {} - ListOf< Lazy< edge_curve >, 1, 0 > blended_edges; - }; - - // C++ wrapper for edge_curve - struct edge_curve : ObjectHelper { edge_curve() : Object("edge_curve") {} - Lazy< curve > edge_geometry; - BOOLEAN::Out same_sense; - }; - - // C++ wrapper for edge_loop - struct edge_loop : ObjectHelper { edge_loop() : Object("edge_loop") {} - - }; - - // C++ wrapper for electric_charge_measure_with_unit - struct electric_charge_measure_with_unit : measure_with_unit, ObjectHelper { electric_charge_measure_with_unit() : Object("electric_charge_measure_with_unit") {} - - }; - - // C++ wrapper for electric_charge_unit - struct electric_charge_unit : derived_unit, ObjectHelper { electric_charge_unit() : Object("electric_charge_unit") {} - - }; - - // C++ wrapper for electric_current_measure_with_unit - struct electric_current_measure_with_unit : measure_with_unit, ObjectHelper { electric_current_measure_with_unit() : Object("electric_current_measure_with_unit") {} - - }; - - // C++ wrapper for electric_current_unit - struct electric_current_unit : named_unit, ObjectHelper { electric_current_unit() : Object("electric_current_unit") {} - - }; - - // C++ wrapper for electric_potential_measure_with_unit - struct electric_potential_measure_with_unit : measure_with_unit, ObjectHelper { electric_potential_measure_with_unit() : Object("electric_potential_measure_with_unit") {} - - }; - - // C++ wrapper for electric_potential_unit - struct electric_potential_unit : derived_unit, ObjectHelper { electric_potential_unit() : Object("electric_potential_unit") {} - - }; - - // C++ wrapper for elementary_brep_shape_representation - struct elementary_brep_shape_representation : shape_representation, ObjectHelper { elementary_brep_shape_representation() : Object("elementary_brep_shape_representation") {} - - }; - - // C++ wrapper for ellipse - struct ellipse : conic, ObjectHelper { ellipse() : Object("ellipse") {} - positive_length_measure::Out semi_axis_1; - positive_length_measure::Out semi_axis_2; - }; - - // C++ wrapper for energy_measure_with_unit - struct energy_measure_with_unit : measure_with_unit, ObjectHelper { energy_measure_with_unit() : Object("energy_measure_with_unit") {} - - }; - - // C++ wrapper for energy_unit - struct energy_unit : derived_unit, ObjectHelper { energy_unit() : Object("energy_unit") {} - - }; - - // C++ wrapper for property_definition - struct property_definition : ObjectHelper { property_definition() : Object("property_definition") {} - label::Out name; - Maybe< text::Out > description; - characterized_definition::Out definition; - }; - - // C++ wrapper for fact_type - struct fact_type : property_definition, ObjectHelper { fact_type() : Object("fact_type") {} - - }; - - // C++ wrapper for entity_assertion - struct entity_assertion : fact_type, ObjectHelper { entity_assertion() : Object("entity_assertion") {} - - }; - - // C++ wrapper for enum_reference_prefix - struct enum_reference_prefix : descriptive_representation_item, ObjectHelper { enum_reference_prefix() : Object("enum_reference_prefix") {} - - }; - - // C++ wrapper for evaluated_characteristic - struct evaluated_characteristic : ObjectHelper { evaluated_characteristic() : Object("evaluated_characteristic") {} - - }; - - // C++ wrapper for evaluated_degenerate_pcurve - struct evaluated_degenerate_pcurve : degenerate_pcurve, ObjectHelper { evaluated_degenerate_pcurve() : Object("evaluated_degenerate_pcurve") {} - Lazy< cartesian_point > equivalent_point; - }; - - // C++ wrapper for evaluation_product_definition - struct evaluation_product_definition : product_definition, ObjectHelper { evaluation_product_definition() : Object("evaluation_product_definition") {} - - }; - - // C++ wrapper for event_occurrence - struct event_occurrence : ObjectHelper { event_occurrence() : Object("event_occurrence") {} - identifier::Out id; - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for product_concept_feature_category - struct product_concept_feature_category : group, ObjectHelper { product_concept_feature_category() : Object("product_concept_feature_category") {} - - }; - - // C++ wrapper for exclusive_product_concept_feature_category - struct exclusive_product_concept_feature_category : product_concept_feature_category, ObjectHelper { exclusive_product_concept_feature_category() : Object("exclusive_product_concept_feature_category") {} - - }; - - // C++ wrapper for uncertainty_qualifier - struct uncertainty_qualifier : ObjectHelper { uncertainty_qualifier() : Object("uncertainty_qualifier") {} - label::Out measure_name; - text::Out description; - }; - - // C++ wrapper for standard_uncertainty - struct standard_uncertainty : uncertainty_qualifier, ObjectHelper { standard_uncertainty() : Object("standard_uncertainty") {} - REAL::Out uncertainty_value; - }; - - // C++ wrapper for expanded_uncertainty - struct expanded_uncertainty : standard_uncertainty, ObjectHelper { expanded_uncertainty() : Object("expanded_uncertainty") {} - REAL::Out coverage_factor; - }; - - // C++ wrapper for representation_item_relationship - struct representation_item_relationship : ObjectHelper { representation_item_relationship() : Object("representation_item_relationship") {} - label::Out name; - Maybe< text::Out > description; - Lazy< representation_item > relating_representation_item; - Lazy< representation_item > related_representation_item; - }; - - // C++ wrapper for explicit_procedural_representation_item_relationship - struct explicit_procedural_representation_item_relationship : representation_item_relationship, ObjectHelper { explicit_procedural_representation_item_relationship() : Object("explicit_procedural_representation_item_relationship") {} - - }; - - // C++ wrapper for explicit_procedural_geometric_representation_item_relationship - struct explicit_procedural_geometric_representation_item_relationship : explicit_procedural_representation_item_relationship, ObjectHelper { explicit_procedural_geometric_representation_item_relationship() : Object("explicit_procedural_geometric_representation_item_relationship") {} - - }; - - // C++ wrapper for explicit_procedural_representation_relationship - struct explicit_procedural_representation_relationship : representation_relationship, ObjectHelper { explicit_procedural_representation_relationship() : Object("explicit_procedural_representation_relationship") {} - - }; - - // C++ wrapper for explicit_procedural_shape_representation_relationship - struct explicit_procedural_shape_representation_relationship : explicit_procedural_representation_relationship, ObjectHelper { explicit_procedural_shape_representation_relationship() : Object("explicit_procedural_shape_representation_relationship") {} - - }; - - // C++ wrapper for expression_conversion_based_unit - struct expression_conversion_based_unit : ObjectHelper { expression_conversion_based_unit() : Object("expression_conversion_based_unit") {} - - }; - - // C++ wrapper for extension - struct extension : derived_shape_aspect, ObjectHelper { extension() : Object("extension") {} - - }; - - // C++ wrapper for extent - struct extent : characterized_object, ObjectHelper { extent() : Object("extent") {} - - }; - - // C++ wrapper for external_source - struct external_source : ObjectHelper { external_source() : Object("external_source") {} - source_item::Out source_id; - }; - - // C++ wrapper for external_class_library - struct external_class_library : external_source, ObjectHelper { external_class_library() : Object("external_class_library") {} - - }; - - // C++ wrapper for externally_defined_class - struct externally_defined_class : ObjectHelper { externally_defined_class() : Object("externally_defined_class") {} - - }; - - // C++ wrapper for externally_defined_colour - struct externally_defined_colour : ObjectHelper { externally_defined_colour() : Object("externally_defined_colour") {} - - }; - - // C++ wrapper for externally_defined_context_dependent_unit - struct externally_defined_context_dependent_unit : ObjectHelper { externally_defined_context_dependent_unit() : Object("externally_defined_context_dependent_unit") {} - - }; - - // C++ wrapper for externally_defined_conversion_based_unit - struct externally_defined_conversion_based_unit : ObjectHelper { externally_defined_conversion_based_unit() : Object("externally_defined_conversion_based_unit") {} - - }; - - // C++ wrapper for externally_defined_currency - struct externally_defined_currency : ObjectHelper { externally_defined_currency() : Object("externally_defined_currency") {} - - }; - - // C++ wrapper for externally_defined_item - struct externally_defined_item : ObjectHelper { externally_defined_item() : Object("externally_defined_item") {} - source_item::Out item_id; - Lazy< external_source > source; - }; - - // C++ wrapper for externally_defined_curve_font - struct externally_defined_curve_font : externally_defined_item, ObjectHelper { externally_defined_curve_font() : Object("externally_defined_curve_font") {} - - }; - - // C++ wrapper for externally_defined_dimension_definition - struct externally_defined_dimension_definition : ObjectHelper { externally_defined_dimension_definition() : Object("externally_defined_dimension_definition") {} - - }; - - // C++ wrapper for externally_defined_general_property - struct externally_defined_general_property : ObjectHelper { externally_defined_general_property() : Object("externally_defined_general_property") {} - - }; - - // C++ wrapper for externally_defined_hatch_style - struct externally_defined_hatch_style : ObjectHelper { externally_defined_hatch_style() : Object("externally_defined_hatch_style") {} - - }; - - // C++ wrapper for externally_defined_marker - struct externally_defined_marker : ObjectHelper { externally_defined_marker() : Object("externally_defined_marker") {} - - }; - - // C++ wrapper for picture_representation_item - struct picture_representation_item : bytes_representation_item, ObjectHelper { picture_representation_item() : Object("picture_representation_item") {} - - }; - - // C++ wrapper for externally_defined_picture_representation_item - struct externally_defined_picture_representation_item : picture_representation_item, ObjectHelper { externally_defined_picture_representation_item() : Object("externally_defined_picture_representation_item") {} - - }; - - // C++ wrapper for externally_defined_representation_item - struct externally_defined_representation_item : ObjectHelper { externally_defined_representation_item() : Object("externally_defined_representation_item") {} - - }; - - // C++ wrapper for externally_defined_string - struct externally_defined_string : externally_defined_representation_item, ObjectHelper { externally_defined_string() : Object("externally_defined_string") {} - - }; - - // C++ wrapper for externally_defined_symbol - struct externally_defined_symbol : externally_defined_item, ObjectHelper { externally_defined_symbol() : Object("externally_defined_symbol") {} - - }; - - // C++ wrapper for externally_defined_terminator_symbol - struct externally_defined_terminator_symbol : externally_defined_symbol, ObjectHelper { externally_defined_terminator_symbol() : Object("externally_defined_terminator_symbol") {} - - }; - - // C++ wrapper for externally_defined_text_font - struct externally_defined_text_font : externally_defined_item, ObjectHelper { externally_defined_text_font() : Object("externally_defined_text_font") {} - - }; - - // C++ wrapper for externally_defined_tile - struct externally_defined_tile : externally_defined_item, ObjectHelper { externally_defined_tile() : Object("externally_defined_tile") {} - - }; - - // C++ wrapper for externally_defined_tile_style - struct externally_defined_tile_style : ObjectHelper { externally_defined_tile_style() : Object("externally_defined_tile_style") {} - - }; - - // C++ wrapper for swept_area_solid - struct swept_area_solid : solid_model, ObjectHelper { swept_area_solid() : Object("swept_area_solid") {} - Lazy< curve_bounded_surface > swept_area; - }; - - // C++ wrapper for extruded_area_solid - struct extruded_area_solid : swept_area_solid, ObjectHelper { extruded_area_solid() : Object("extruded_area_solid") {} - Lazy< direction > extruded_direction; - positive_length_measure::Out depth; - }; - - // C++ wrapper for swept_face_solid - struct swept_face_solid : solid_model, ObjectHelper { swept_face_solid() : Object("swept_face_solid") {} - Lazy< face_surface > swept_face; - }; - - // C++ wrapper for extruded_face_solid - struct extruded_face_solid : swept_face_solid, ObjectHelper { extruded_face_solid() : Object("extruded_face_solid") {} - Lazy< direction > extruded_direction; - positive_length_measure::Out depth; - }; - - // C++ wrapper for extruded_face_solid_with_trim_conditions - struct extruded_face_solid_with_trim_conditions : extruded_face_solid, ObjectHelper { extruded_face_solid_with_trim_conditions() : Object("extruded_face_solid_with_trim_conditions") {} - trim_condition_select::Out first_trim_condition; - trim_condition_select::Out second_trim_condition; - trim_intent::Out first_trim_intent; - trim_intent::Out second_trim_intent; - non_negative_length_measure::Out first_offset; - non_negative_length_measure::Out second_offset; - }; - - // C++ wrapper for extruded_face_solid_with_draft_angle - struct extruded_face_solid_with_draft_angle : extruded_face_solid_with_trim_conditions, ObjectHelper { extruded_face_solid_with_draft_angle() : Object("extruded_face_solid_with_draft_angle") {} - plane_angle_measure::Out draft_angle; - }; - - // C++ wrapper for extruded_face_solid_with_multiple_draft_angles - struct extruded_face_solid_with_multiple_draft_angles : extruded_face_solid_with_trim_conditions, ObjectHelper { extruded_face_solid_with_multiple_draft_angles() : Object("extruded_face_solid_with_multiple_draft_angles") {} - ListOf< plane_angle_measure, 2, 0 >::Out draft_angles; - }; - - // C++ wrapper for face - struct face : topological_representation_item, ObjectHelper { face() : Object("face") {} - ListOf< Lazy< face_bound >, 1, 0 > bounds; - }; - - // C++ wrapper for face_based_surface_model - struct face_based_surface_model : geometric_representation_item, ObjectHelper { face_based_surface_model() : Object("face_based_surface_model") {} - ListOf< Lazy< connected_face_set >, 1, 0 > fbsm_faces; - }; - - // C++ wrapper for face_bound - struct face_bound : topological_representation_item, ObjectHelper { face_bound() : Object("face_bound") {} - Lazy< loop > bound; - BOOLEAN::Out orientation; - }; - - // C++ wrapper for face_outer_bound - struct face_outer_bound : face_bound, ObjectHelper { face_outer_bound() : Object("face_outer_bound") {} - - }; - - // C++ wrapper for faceted_brep - struct faceted_brep : manifold_solid_brep, ObjectHelper { faceted_brep() : Object("faceted_brep") {} - - }; - - // C++ wrapper for faceted_brep_shape_representation - struct faceted_brep_shape_representation : shape_representation, ObjectHelper { faceted_brep_shape_representation() : Object("faceted_brep_shape_representation") {} - - }; - - // C++ wrapper for fill_area_style - struct fill_area_style : founded_item, ObjectHelper { fill_area_style() : Object("fill_area_style") {} - label::Out name; - ListOf< fill_style_select, 1, 0 >::Out fill_styles; - }; - - // C++ wrapper for fill_area_style_hatching - struct fill_area_style_hatching : geometric_representation_item, ObjectHelper { fill_area_style_hatching() : Object("fill_area_style_hatching") {} - Lazy< curve_style > hatch_line_appearance; - Lazy< one_direction_repeat_factor > start_of_next_hatch_line; - Lazy< cartesian_point > point_of_reference_hatch_line; - Lazy< cartesian_point > pattern_start; - plane_angle_measure::Out hatch_line_angle; - }; - - // C++ wrapper for fill_area_style_tile_coloured_region - struct fill_area_style_tile_coloured_region : geometric_representation_item, ObjectHelper { fill_area_style_tile_coloured_region() : Object("fill_area_style_tile_coloured_region") {} - curve_or_annotation_curve_occurrence::Out closed_curve; - Lazy< colour > region_colour; - }; - - // C++ wrapper for fill_area_style_tile_curve_with_style - struct fill_area_style_tile_curve_with_style : geometric_representation_item, ObjectHelper { fill_area_style_tile_curve_with_style() : Object("fill_area_style_tile_curve_with_style") {} - Lazy< annotation_curve_occurrence > styled_curve; - }; - - // C++ wrapper for fill_area_style_tile_symbol_with_style - struct fill_area_style_tile_symbol_with_style : geometric_representation_item, ObjectHelper { fill_area_style_tile_symbol_with_style() : Object("fill_area_style_tile_symbol_with_style") {} - Lazy< annotation_symbol_occurrence > symbol; - }; - - // C++ wrapper for fill_area_style_tiles - struct fill_area_style_tiles : geometric_representation_item, ObjectHelper { fill_area_style_tiles() : Object("fill_area_style_tiles") {} - Lazy< two_direction_repeat_factor > tiling_pattern; - ListOf< fill_area_style_tile_shape_select, 1, 0 >::Out tiles; - positive_ratio_measure::Out tiling_scale; - }; - - // C++ wrapper for shape_representation_relationship - struct shape_representation_relationship : representation_relationship, ObjectHelper { shape_representation_relationship() : Object("shape_representation_relationship") {} - - }; - - // C++ wrapper for flat_pattern_ply_representation_relationship - struct flat_pattern_ply_representation_relationship : shape_representation_relationship, ObjectHelper { flat_pattern_ply_representation_relationship() : Object("flat_pattern_ply_representation_relationship") {} - - }; - - // C++ wrapper for flatness_tolerance - struct flatness_tolerance : geometric_tolerance, ObjectHelper { flatness_tolerance() : Object("flatness_tolerance") {} - - }; - - // C++ wrapper for force_measure_with_unit - struct force_measure_with_unit : measure_with_unit, ObjectHelper { force_measure_with_unit() : Object("force_measure_with_unit") {} - - }; - - // C++ wrapper for force_unit - struct force_unit : derived_unit, ObjectHelper { force_unit() : Object("force_unit") {} - - }; - - // C++ wrapper for forward_chaining_rule - struct forward_chaining_rule : rule_definition, ObjectHelper { forward_chaining_rule() : Object("forward_chaining_rule") {} - - }; - - // C++ wrapper for forward_chaining_rule_premise - struct forward_chaining_rule_premise : ObjectHelper { forward_chaining_rule_premise() : Object("forward_chaining_rule_premise") {} - - }; - - // C++ wrapper for frequency_measure_with_unit - struct frequency_measure_with_unit : measure_with_unit, ObjectHelper { frequency_measure_with_unit() : Object("frequency_measure_with_unit") {} - - }; - - // C++ wrapper for frequency_unit - struct frequency_unit : derived_unit, ObjectHelper { frequency_unit() : Object("frequency_unit") {} - - }; - - // C++ wrapper for func - struct func : compound_representation_item, ObjectHelper { func() : Object("func") {} - - }; - - // C++ wrapper for functional_breakdown_context - struct functional_breakdown_context : breakdown_context, ObjectHelper { functional_breakdown_context() : Object("functional_breakdown_context") {} - - }; - - // C++ wrapper for functional_element_usage - struct functional_element_usage : breakdown_element_usage, ObjectHelper { functional_element_usage() : Object("functional_element_usage") {} - - }; - - // C++ wrapper for general_material_property - struct general_material_property : general_property, ObjectHelper { general_material_property() : Object("general_material_property") {} - - }; - - // C++ wrapper for simple_generic_expression - struct simple_generic_expression : generic_expression, ObjectHelper { simple_generic_expression() : Object("simple_generic_expression") {} - - }; - - // C++ wrapper for generic_literal - struct generic_literal : simple_generic_expression, ObjectHelper { generic_literal() : Object("generic_literal") {} - - }; - - // C++ wrapper for generic_variable - struct generic_variable : simple_generic_expression, ObjectHelper { generic_variable() : Object("generic_variable") {} - - }; - - // C++ wrapper for geometric_alignment - struct geometric_alignment : derived_shape_aspect, ObjectHelper { geometric_alignment() : Object("geometric_alignment") {} - - }; - - // C++ wrapper for geometric_set - struct geometric_set : geometric_representation_item, ObjectHelper { geometric_set() : Object("geometric_set") {} - ListOf< geometric_set_select, 1, 0 >::Out elements; - }; - - // C++ wrapper for geometric_curve_set - struct geometric_curve_set : geometric_set, ObjectHelper { geometric_curve_set() : Object("geometric_curve_set") {} - - }; - - // C++ wrapper for geometric_intersection - struct geometric_intersection : derived_shape_aspect, ObjectHelper { geometric_intersection() : Object("geometric_intersection") {} - - }; - - // C++ wrapper for geometric_item_specific_usage - struct geometric_item_specific_usage : item_identified_representation_usage, ObjectHelper { geometric_item_specific_usage() : Object("geometric_item_specific_usage") {} - - }; - - // C++ wrapper for geometric_model_element_relationship - struct geometric_model_element_relationship : ObjectHelper { geometric_model_element_relationship() : Object("geometric_model_element_relationship") {} - - }; - - // C++ wrapper for representation_context - struct representation_context : ObjectHelper { representation_context() : Object("representation_context") {} - identifier::Out context_identifier; - text::Out context_type; - }; - - // C++ wrapper for geometric_representation_context - struct geometric_representation_context : representation_context, ObjectHelper { geometric_representation_context() : Object("geometric_representation_context") {} - dimension_count::Out coordinate_space_dimension; - }; - - // C++ wrapper for geometric_tolerance_with_defined_unit - struct geometric_tolerance_with_defined_unit : geometric_tolerance, ObjectHelper { geometric_tolerance_with_defined_unit() : Object("geometric_tolerance_with_defined_unit") {} - Lazy< measure_with_unit > unit_size; - }; - - // C++ wrapper for geometrical_tolerance_callout - struct geometrical_tolerance_callout : draughting_callout, ObjectHelper { geometrical_tolerance_callout() : Object("geometrical_tolerance_callout") {} - - }; - - // C++ wrapper for geometrically_bounded_2d_wireframe_representation - struct geometrically_bounded_2d_wireframe_representation : shape_representation, ObjectHelper { geometrically_bounded_2d_wireframe_representation() : Object("geometrically_bounded_2d_wireframe_representation") {} - - }; - - // C++ wrapper for geometrically_bounded_surface_shape_representation - struct geometrically_bounded_surface_shape_representation : shape_representation, ObjectHelper { geometrically_bounded_surface_shape_representation() : Object("geometrically_bounded_surface_shape_representation") {} - - }; - - // C++ wrapper for geometrically_bounded_wireframe_shape_representation - struct geometrically_bounded_wireframe_shape_representation : shape_representation, ObjectHelper { geometrically_bounded_wireframe_shape_representation() : Object("geometrically_bounded_wireframe_shape_representation") {} - - }; - - // C++ wrapper for global_assignment - struct global_assignment : representation_item_relationship, ObjectHelper { global_assignment() : Object("global_assignment") {} - - }; - - // C++ wrapper for global_uncertainty_assigned_context - struct global_uncertainty_assigned_context : representation_context, ObjectHelper { global_uncertainty_assigned_context() : Object("global_uncertainty_assigned_context") {} - ListOf< Lazy< uncertainty_measure_with_unit >, 1, 0 > uncertainty; - }; - - // C++ wrapper for global_unit_assigned_context - struct global_unit_assigned_context : representation_context, ObjectHelper { global_unit_assigned_context() : Object("global_unit_assigned_context") {} - ListOf< unit, 1, 0 >::Out units; - }; - - // C++ wrapper for ground_fact - struct ground_fact : atomic_formula, ObjectHelper { ground_fact() : Object("ground_fact") {} - - }; - - // C++ wrapper for hardness_representation - struct hardness_representation : representation, ObjectHelper { hardness_representation() : Object("hardness_representation") {} - - }; - - // C++ wrapper for hidden_element_over_riding_styled_item - struct hidden_element_over_riding_styled_item : context_dependent_over_riding_styled_item, ObjectHelper { hidden_element_over_riding_styled_item() : Object("hidden_element_over_riding_styled_item") {} - - }; - - // C++ wrapper for hyperbola - struct hyperbola : conic, ObjectHelper { hyperbola() : Object("hyperbola") {} - positive_length_measure::Out semi_axis; - positive_length_measure::Out semi_imag_axis; - }; - - // C++ wrapper for illuminance_measure_with_unit - struct illuminance_measure_with_unit : measure_with_unit, ObjectHelper { illuminance_measure_with_unit() : Object("illuminance_measure_with_unit") {} - - }; - - // C++ wrapper for illuminance_unit - struct illuminance_unit : derived_unit, ObjectHelper { illuminance_unit() : Object("illuminance_unit") {} - - }; - - // C++ wrapper for included_text_block - struct included_text_block : mapped_item, ObjectHelper { included_text_block() : Object("included_text_block") {} - - }; - - // C++ wrapper for inclusion_product_concept_feature - struct inclusion_product_concept_feature : conditional_concept_feature, ObjectHelper { inclusion_product_concept_feature() : Object("inclusion_product_concept_feature") {} - - }; - - // C++ wrapper for user_selected_elements - struct user_selected_elements : representation_item, ObjectHelper { user_selected_elements() : Object("user_selected_elements") {} - ListOf< Lazy< representation_item >, 1, 0 > picked_items; - }; - - // C++ wrapper for indirectly_selected_elements - struct indirectly_selected_elements : user_selected_elements, ObjectHelper { indirectly_selected_elements() : Object("indirectly_selected_elements") {} - ListOf< Lazy< representation_item >, 1, 0 > indirectly_picked_items; - }; - - // C++ wrapper for indirectly_selected_shape_elements - struct indirectly_selected_shape_elements : ObjectHelper { indirectly_selected_shape_elements() : Object("indirectly_selected_shape_elements") {} - - }; - - // C++ wrapper for inductance_measure_with_unit - struct inductance_measure_with_unit : measure_with_unit, ObjectHelper { inductance_measure_with_unit() : Object("inductance_measure_with_unit") {} - - }; - - // C++ wrapper for inductance_unit - struct inductance_unit : derived_unit, ObjectHelper { inductance_unit() : Object("inductance_unit") {} - - }; - - // C++ wrapper for information_right - struct information_right : action_method, ObjectHelper { information_right() : Object("information_right") {} - - }; - - // C++ wrapper for information_usage_right - struct information_usage_right : action_method, ObjectHelper { information_usage_right() : Object("information_usage_right") {} - - }; - - // C++ wrapper for instance_usage_context_assignment - struct instance_usage_context_assignment : product_definition_context, ObjectHelper { instance_usage_context_assignment() : Object("instance_usage_context_assignment") {} - ListOf< instance_usage_context_select, 1, 0 >::Out items; - }; - - // C++ wrapper for instanced_feature - struct instanced_feature : ObjectHelper { instanced_feature() : Object("instanced_feature") {} - - }; - - // C++ wrapper for literal_number - struct literal_number : ObjectHelper { literal_number() : Object("literal_number") {} - NUMBER::Out the_value; - }; - - // C++ wrapper for int_literal - struct int_literal : literal_number, ObjectHelper { int_literal() : Object("int_literal") {} - - }; - - // C++ wrapper for integer_representation_item - struct integer_representation_item : ObjectHelper { integer_representation_item() : Object("integer_representation_item") {} - - }; - - // C++ wrapper for surface_curve - struct surface_curve : curve, ObjectHelper { surface_curve() : Object("surface_curve") {} - Lazy< curve > curve_3d; - ListOf< pcurve_or_surface, 1, 2 >::Out associated_geometry; - preferred_surface_curve_representation::Out master_representation; - }; - - // C++ wrapper for intersection_curve - struct intersection_curve : surface_curve, ObjectHelper { intersection_curve() : Object("intersection_curve") {} - - }; - - // C++ wrapper for interval_expression - struct interval_expression : ObjectHelper { interval_expression() : Object("interval_expression") {} - - }; - - // C++ wrapper for iso4217_currency - struct iso4217_currency : currency, ObjectHelper { iso4217_currency() : Object("iso4217_currency") {} - - }; - - // C++ wrapper for known_source - struct known_source : ObjectHelper { known_source() : Object("known_source") {} - - }; - - // C++ wrapper for laid_defined_transformation - struct laid_defined_transformation : transformation_with_derived_angle, ObjectHelper { laid_defined_transformation() : Object("laid_defined_transformation") {} - - }; - - // C++ wrapper for language - struct language : group, ObjectHelper { language() : Object("language") {} - - }; - - // C++ wrapper for leader_curve - struct leader_curve : annotation_curve_occurrence, ObjectHelper { leader_curve() : Object("leader_curve") {} - - }; - - // C++ wrapper for leader_directed_callout - struct leader_directed_callout : draughting_callout, ObjectHelper { leader_directed_callout() : Object("leader_directed_callout") {} - - }; - - // C++ wrapper for leader_directed_dimension - struct leader_directed_dimension : leader_directed_callout, ObjectHelper { leader_directed_dimension() : Object("leader_directed_dimension") {} - - }; - - // C++ wrapper for leader_terminator - struct leader_terminator : terminator_symbol, ObjectHelper { leader_terminator() : Object("leader_terminator") {} - - }; - - // C++ wrapper for length_measure_with_unit - struct length_measure_with_unit : measure_with_unit, ObjectHelper { length_measure_with_unit() : Object("length_measure_with_unit") {} - - }; - - // C++ wrapper for length_unit - struct length_unit : named_unit, ObjectHelper { length_unit() : Object("length_unit") {} - - }; - - // C++ wrapper for light_source - struct light_source : geometric_representation_item, ObjectHelper { light_source() : Object("light_source") {} - Lazy< colour > light_colour; - }; - - // C++ wrapper for light_source_ambient - struct light_source_ambient : light_source, ObjectHelper { light_source_ambient() : Object("light_source_ambient") {} - - }; - - // C++ wrapper for light_source_directional - struct light_source_directional : light_source, ObjectHelper { light_source_directional() : Object("light_source_directional") {} - Lazy< direction > orientation; - }; - - // C++ wrapper for light_source_positional - struct light_source_positional : light_source, ObjectHelper { light_source_positional() : Object("light_source_positional") {} - Lazy< cartesian_point > position; - REAL::Out constant_attenuation; - REAL::Out distance_attenuation; - }; - - // C++ wrapper for light_source_spot - struct light_source_spot : light_source, ObjectHelper { light_source_spot() : Object("light_source_spot") {} - Lazy< cartesian_point > position; - Lazy< direction > orientation; - REAL::Out concentration_exponent; - REAL::Out constant_attenuation; - REAL::Out distance_attenuation; - positive_plane_angle_measure::Out spread_angle; - }; - - // C++ wrapper for line - struct line : curve, ObjectHelper { line() : Object("line") {} - Lazy< cartesian_point > pnt; - Lazy< vector > dir; - }; - - // C++ wrapper for line_profile_tolerance - struct line_profile_tolerance : geometric_tolerance, ObjectHelper { line_profile_tolerance() : Object("line_profile_tolerance") {} - - }; - - // C++ wrapper for linear_dimension - struct linear_dimension : dimension_curve_directed_callout, ObjectHelper { linear_dimension() : Object("linear_dimension") {} - - }; - - // C++ wrapper for simple_clause - struct simple_clause : compound_representation_item, ObjectHelper { simple_clause() : Object("simple_clause") {} - - }; - - // C++ wrapper for literal_conjunction - struct literal_conjunction : simple_clause, ObjectHelper { literal_conjunction() : Object("literal_conjunction") {} - - }; - - // C++ wrapper for literal_disjunction - struct literal_disjunction : simple_clause, ObjectHelper { literal_disjunction() : Object("literal_disjunction") {} - - }; - - // C++ wrapper for logical_literal - struct logical_literal : generic_literal, ObjectHelper { logical_literal() : Object("logical_literal") {} - LOGICAL::Out lit_value; - }; - - // C++ wrapper for logical_representation_item - struct logical_representation_item : ObjectHelper { logical_representation_item() : Object("logical_representation_item") {} - - }; - - // C++ wrapper for loop - struct loop : topological_representation_item, ObjectHelper { loop() : Object("loop") {} - - }; - - // C++ wrapper for loss_tangent_measure_with_unit - struct loss_tangent_measure_with_unit : ratio_measure_with_unit, ObjectHelper { loss_tangent_measure_with_unit() : Object("loss_tangent_measure_with_unit") {} - - }; - - // C++ wrapper for lot_effectivity - struct lot_effectivity : effectivity, ObjectHelper { lot_effectivity() : Object("lot_effectivity") {} - identifier::Out effectivity_lot_id; - Lazy< measure_with_unit > effectivity_lot_size; - }; - - // C++ wrapper for luminous_flux_measure_with_unit - struct luminous_flux_measure_with_unit : measure_with_unit, ObjectHelper { luminous_flux_measure_with_unit() : Object("luminous_flux_measure_with_unit") {} - - }; - - // C++ wrapper for luminous_flux_unit - struct luminous_flux_unit : named_unit, ObjectHelper { luminous_flux_unit() : Object("luminous_flux_unit") {} - - }; - - // C++ wrapper for luminous_intensity_measure_with_unit - struct luminous_intensity_measure_with_unit : measure_with_unit, ObjectHelper { luminous_intensity_measure_with_unit() : Object("luminous_intensity_measure_with_unit") {} - - }; - - // C++ wrapper for luminous_intensity_unit - struct luminous_intensity_unit : named_unit, ObjectHelper { luminous_intensity_unit() : Object("luminous_intensity_unit") {} - - }; - - // C++ wrapper for magnetic_flux_density_measure_with_unit - struct magnetic_flux_density_measure_with_unit : measure_with_unit, ObjectHelper { magnetic_flux_density_measure_with_unit() : Object("magnetic_flux_density_measure_with_unit") {} - - }; - - // C++ wrapper for magnetic_flux_density_unit - struct magnetic_flux_density_unit : derived_unit, ObjectHelper { magnetic_flux_density_unit() : Object("magnetic_flux_density_unit") {} - - }; - - // C++ wrapper for magnetic_flux_measure_with_unit - struct magnetic_flux_measure_with_unit : measure_with_unit, ObjectHelper { magnetic_flux_measure_with_unit() : Object("magnetic_flux_measure_with_unit") {} - - }; - - // C++ wrapper for magnetic_flux_unit - struct magnetic_flux_unit : derived_unit, ObjectHelper { magnetic_flux_unit() : Object("magnetic_flux_unit") {} - - }; - - // C++ wrapper for make_from_usage_option - struct make_from_usage_option : product_definition_usage, ObjectHelper { make_from_usage_option() : Object("make_from_usage_option") {} - INTEGER::Out ranking; - text::Out ranking_rationale; - Lazy< measure_with_unit > quantity; - }; - - // C++ wrapper for manifold_subsurface_shape_representation - struct manifold_subsurface_shape_representation : shape_representation, ObjectHelper { manifold_subsurface_shape_representation() : Object("manifold_subsurface_shape_representation") {} - - }; - - // C++ wrapper for manifold_surface_shape_representation - struct manifold_surface_shape_representation : shape_representation, ObjectHelper { manifold_surface_shape_representation() : Object("manifold_surface_shape_representation") {} - - }; - - // C++ wrapper for mass_measure_with_unit - struct mass_measure_with_unit : measure_with_unit, ObjectHelper { mass_measure_with_unit() : Object("mass_measure_with_unit") {} - - }; - - // C++ wrapper for mass_unit - struct mass_unit : named_unit, ObjectHelper { mass_unit() : Object("mass_unit") {} - - }; - - // C++ wrapper for material_property - struct material_property : property_definition, ObjectHelper { material_property() : Object("material_property") {} - - }; - - // C++ wrapper for property_definition_representation - struct property_definition_representation : ObjectHelper { property_definition_representation() : Object("property_definition_representation") {} - represented_definition::Out definition; - Lazy< representation > used_representation; - }; - - // C++ wrapper for material_property_representation - struct material_property_representation : property_definition_representation, ObjectHelper { material_property_representation() : Object("material_property_representation") {} - Lazy< NotImplemented > dependent_environment; - }; - - // C++ wrapper for measure_representation_item - struct measure_representation_item : ObjectHelper { measure_representation_item() : Object("measure_representation_item") {} - - }; - - // C++ wrapper for product_context - struct product_context : application_context_element, ObjectHelper { product_context() : Object("product_context") {} - label::Out discipline_type; - }; - - // C++ wrapper for mechanical_context - struct mechanical_context : product_context, ObjectHelper { mechanical_context() : Object("mechanical_context") {} - - }; - - // C++ wrapper for mechanical_design_and_draughting_relationship - struct mechanical_design_and_draughting_relationship : definitional_representation_relationship_with_same_context, ObjectHelper { mechanical_design_and_draughting_relationship() : Object("mechanical_design_and_draughting_relationship") {} - - }; - - // C++ wrapper for mechanical_design_geometric_presentation_area - struct mechanical_design_geometric_presentation_area : presentation_area, ObjectHelper { mechanical_design_geometric_presentation_area() : Object("mechanical_design_geometric_presentation_area") {} - - }; - - // C++ wrapper for mechanical_design_geometric_presentation_representation - struct mechanical_design_geometric_presentation_representation : representation, ObjectHelper { mechanical_design_geometric_presentation_representation() : Object("mechanical_design_geometric_presentation_representation") {} - - }; - - // C++ wrapper for mechanical_design_presentation_representation_with_draughting - struct mechanical_design_presentation_representation_with_draughting : representation, ObjectHelper { mechanical_design_presentation_representation_with_draughting() : Object("mechanical_design_presentation_representation_with_draughting") {} - - }; - - // C++ wrapper for mechanical_design_shaded_presentation_area - struct mechanical_design_shaded_presentation_area : presentation_area, ObjectHelper { mechanical_design_shaded_presentation_area() : Object("mechanical_design_shaded_presentation_area") {} - - }; - - // C++ wrapper for mechanical_design_shaded_presentation_representation - struct mechanical_design_shaded_presentation_representation : representation, ObjectHelper { mechanical_design_shaded_presentation_representation() : Object("mechanical_design_shaded_presentation_representation") {} - - }; - - // C++ wrapper for min_and_major_ply_orientation_basis - struct min_and_major_ply_orientation_basis : ObjectHelper { min_and_major_ply_orientation_basis() : Object("min_and_major_ply_orientation_basis") {} - - }; - - // C++ wrapper for modified_geometric_tolerance - struct modified_geometric_tolerance : geometric_tolerance, ObjectHelper { modified_geometric_tolerance() : Object("modified_geometric_tolerance") {} - limit_condition::Out modifier; - }; - - // C++ wrapper for modified_solid_with_placed_configuration - struct modified_solid_with_placed_configuration : modified_solid, ObjectHelper { modified_solid_with_placed_configuration() : Object("modified_solid_with_placed_configuration") {} - Lazy< axis2_placement_3d > placing; - }; - - // C++ wrapper for moments_of_inertia_representation - struct moments_of_inertia_representation : representation, ObjectHelper { moments_of_inertia_representation() : Object("moments_of_inertia_representation") {} - - }; - - // C++ wrapper for multi_language_attribute_assignment - struct multi_language_attribute_assignment : attribute_value_assignment, ObjectHelper { multi_language_attribute_assignment() : Object("multi_language_attribute_assignment") {} - ListOf< multi_language_attribute_item, 1, 0 >::Out items; - }; - - // C++ wrapper for multiple_arity_boolean_expression - struct multiple_arity_boolean_expression : ObjectHelper { multiple_arity_boolean_expression() : Object("multiple_arity_boolean_expression") {} - - }; - - // C++ wrapper for multiple_arity_generic_expression - struct multiple_arity_generic_expression : generic_expression, ObjectHelper { multiple_arity_generic_expression() : Object("multiple_arity_generic_expression") {} - ListOf< Lazy< generic_expression >, 2, 0 > operands; - }; - - // C++ wrapper for multiple_arity_numeric_expression - struct multiple_arity_numeric_expression : ObjectHelper { multiple_arity_numeric_expression() : Object("multiple_arity_numeric_expression") {} - - }; - - // C++ wrapper for next_assembly_usage_occurrence - struct next_assembly_usage_occurrence : assembly_component_usage, ObjectHelper { next_assembly_usage_occurrence() : Object("next_assembly_usage_occurrence") {} - - }; - - // C++ wrapper for non_manifold_surface_shape_representation - struct non_manifold_surface_shape_representation : shape_representation, ObjectHelper { non_manifold_surface_shape_representation() : Object("non_manifold_surface_shape_representation") {} - - }; - - // C++ wrapper for null_representation_item - struct null_representation_item : representation_item, ObjectHelper { null_representation_item() : Object("null_representation_item") {} - - }; - - // C++ wrapper for numeric_expression - struct numeric_expression : expression, ObjectHelper { numeric_expression() : Object("numeric_expression") {} - - }; - - // C++ wrapper for offset_curve_2d - struct offset_curve_2d : curve, ObjectHelper { offset_curve_2d() : Object("offset_curve_2d") {} - Lazy< curve > basis_curve; - length_measure::Out distance; - LOGICAL::Out self_intersect; - }; - - // C++ wrapper for offset_curve_3d - struct offset_curve_3d : curve, ObjectHelper { offset_curve_3d() : Object("offset_curve_3d") {} - Lazy< curve > basis_curve; - length_measure::Out distance; - LOGICAL::Out self_intersect; - Lazy< direction > ref_direction; - }; - - // C++ wrapper for offset_surface - struct offset_surface : surface, ObjectHelper { offset_surface() : Object("offset_surface") {} - Lazy< surface > basis_surface; - length_measure::Out distance; - LOGICAL::Out self_intersect; - }; - - // C++ wrapper for one_direction_repeat_factor - struct one_direction_repeat_factor : geometric_representation_item, ObjectHelper { one_direction_repeat_factor() : Object("one_direction_repeat_factor") {} - Lazy< vector > repeat_factor; - }; - - // C++ wrapper for open_shell - struct open_shell : connected_face_set, ObjectHelper { open_shell() : Object("open_shell") {} - - }; - - // C++ wrapper for ordinal_date - struct ordinal_date : date, ObjectHelper { ordinal_date() : Object("ordinal_date") {} - day_in_year_number::Out day_component; - }; - - // C++ wrapper for projection_directed_callout - struct projection_directed_callout : draughting_callout, ObjectHelper { projection_directed_callout() : Object("projection_directed_callout") {} - - }; - - // C++ wrapper for ordinate_dimension - struct ordinate_dimension : projection_directed_callout, ObjectHelper { ordinate_dimension() : Object("ordinate_dimension") {} - - }; - - // C++ wrapper for organizational_address - struct organizational_address : address, ObjectHelper { organizational_address() : Object("organizational_address") {} - ListOf< Lazy< NotImplemented >, 1, 0 > organizations; - Maybe< text::Out > description; - }; - - // C++ wrapper for oriented_closed_shell - struct oriented_closed_shell : closed_shell, ObjectHelper { oriented_closed_shell() : Object("oriented_closed_shell") {} - Lazy< closed_shell > closed_shell_element; - BOOLEAN::Out orientation; - }; - - // C++ wrapper for oriented_edge - struct oriented_edge : edge, ObjectHelper { oriented_edge() : Object("oriented_edge") {} - Lazy< edge > edge_element; - BOOLEAN::Out orientation; - }; - - // C++ wrapper for oriented_face - struct oriented_face : face, ObjectHelper { oriented_face() : Object("oriented_face") {} - Lazy< face > face_element; - BOOLEAN::Out orientation; - }; - - // C++ wrapper for oriented_open_shell - struct oriented_open_shell : open_shell, ObjectHelper { oriented_open_shell() : Object("oriented_open_shell") {} - Lazy< open_shell > open_shell_element; - BOOLEAN::Out orientation; - }; - - // C++ wrapper for path - struct path : topological_representation_item, ObjectHelper { path() : Object("path") {} - ListOf< Lazy< oriented_edge >, 1, 0 > edge_list; - }; - - // C++ wrapper for oriented_path - struct oriented_path : path, ObjectHelper { oriented_path() : Object("oriented_path") {} - Lazy< path > path_element; - BOOLEAN::Out orientation; - }; - - // C++ wrapper for oriented_surface - struct oriented_surface : surface, ObjectHelper { oriented_surface() : Object("oriented_surface") {} - BOOLEAN::Out orientation; - }; - - // C++ wrapper for outer_boundary_curve - struct outer_boundary_curve : boundary_curve, ObjectHelper { outer_boundary_curve() : Object("outer_boundary_curve") {} - - }; - - // C++ wrapper for package_product_concept_feature - struct package_product_concept_feature : product_concept_feature, ObjectHelper { package_product_concept_feature() : Object("package_product_concept_feature") {} - - }; - - // C++ wrapper for parabola - struct parabola : conic, ObjectHelper { parabola() : Object("parabola") {} - length_measure::Out focal_dist; - }; - - // C++ wrapper for parallel_offset - struct parallel_offset : derived_shape_aspect, ObjectHelper { parallel_offset() : Object("parallel_offset") {} - Lazy< measure_with_unit > offset; - }; - - // C++ wrapper for parallelism_tolerance - struct parallelism_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { parallelism_tolerance() : Object("parallelism_tolerance") {} - - }; - - // C++ wrapper for parametric_representation_context - struct parametric_representation_context : representation_context, ObjectHelper { parametric_representation_context() : Object("parametric_representation_context") {} - - }; - - // C++ wrapper for partial_document_with_structured_text_representation_assignment - struct partial_document_with_structured_text_representation_assignment : ObjectHelper { partial_document_with_structured_text_representation_assignment() : Object("partial_document_with_structured_text_representation_assignment") {} - - }; - - // C++ wrapper for pcurve - struct pcurve : curve, ObjectHelper { pcurve() : Object("pcurve") {} - Lazy< surface > basis_surface; - Lazy< definitional_representation > reference_to_curve; - }; - - // C++ wrapper for percentage_laminate_definition - struct percentage_laminate_definition : product_definition, ObjectHelper { percentage_laminate_definition() : Object("percentage_laminate_definition") {} - - }; - - // C++ wrapper for zone_structural_makeup - struct zone_structural_makeup : laminate_table, ObjectHelper { zone_structural_makeup() : Object("zone_structural_makeup") {} - - }; - - // C++ wrapper for percentage_laminate_table - struct percentage_laminate_table : zone_structural_makeup, ObjectHelper { percentage_laminate_table() : Object("percentage_laminate_table") {} - - }; - - // C++ wrapper for percentage_ply_definition - struct percentage_ply_definition : product_definition, ObjectHelper { percentage_ply_definition() : Object("percentage_ply_definition") {} - - }; - - // C++ wrapper for perpendicular_to - struct perpendicular_to : derived_shape_aspect, ObjectHelper { perpendicular_to() : Object("perpendicular_to") {} - - }; - - // C++ wrapper for perpendicularity_tolerance - struct perpendicularity_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { perpendicularity_tolerance() : Object("perpendicularity_tolerance") {} - - }; - - // C++ wrapper for person_and_organization_address - struct person_and_organization_address : ObjectHelper { person_and_organization_address() : Object("person_and_organization_address") {} - - }; - - // C++ wrapper for personal_address - struct personal_address : address, ObjectHelper { personal_address() : Object("personal_address") {} - ListOf< Lazy< NotImplemented >, 1, 0 > people; - Maybe< text::Out > description; - }; - - // C++ wrapper for physical_breakdown_context - struct physical_breakdown_context : breakdown_context, ObjectHelper { physical_breakdown_context() : Object("physical_breakdown_context") {} - - }; - - // C++ wrapper for physical_element_usage - struct physical_element_usage : breakdown_element_usage, ObjectHelper { physical_element_usage() : Object("physical_element_usage") {} - - }; - - // C++ wrapper for presentation_view - struct presentation_view : presentation_representation, ObjectHelper { presentation_view() : Object("presentation_view") {} - - }; - - // C++ wrapper for picture_representation - struct picture_representation : presentation_view, ObjectHelper { picture_representation() : Object("picture_representation") {} - - }; - - // C++ wrapper for placed_datum_target_feature - struct placed_datum_target_feature : datum_target, ObjectHelper { placed_datum_target_feature() : Object("placed_datum_target_feature") {} - - }; - - // C++ wrapper for placed_feature - struct placed_feature : shape_aspect, ObjectHelper { placed_feature() : Object("placed_feature") {} - - }; - - // C++ wrapper for planar_extent - struct planar_extent : geometric_representation_item, ObjectHelper { planar_extent() : Object("planar_extent") {} - length_measure::Out size_in_x; - length_measure::Out size_in_y; - }; - - // C++ wrapper for planar_box - struct planar_box : planar_extent, ObjectHelper { planar_box() : Object("planar_box") {} - axis2_placement::Out placement; - }; - - // C++ wrapper for plane - struct plane : elementary_surface, ObjectHelper { plane() : Object("plane") {} - - }; - - // C++ wrapper for plane_angle_measure_with_unit - struct plane_angle_measure_with_unit : measure_with_unit, ObjectHelper { plane_angle_measure_with_unit() : Object("plane_angle_measure_with_unit") {} - - }; - - // C++ wrapper for plane_angle_unit - struct plane_angle_unit : named_unit, ObjectHelper { plane_angle_unit() : Object("plane_angle_unit") {} - - }; - - // C++ wrapper for ply_laminate_definition - struct ply_laminate_definition : product_definition, ObjectHelper { ply_laminate_definition() : Object("ply_laminate_definition") {} - - }; - - // C++ wrapper for ply_laminate_sequence_definition - struct ply_laminate_sequence_definition : product_definition, ObjectHelper { ply_laminate_sequence_definition() : Object("ply_laminate_sequence_definition") {} - - }; - - // C++ wrapper for ply_laminate_table - struct ply_laminate_table : part_laminate_table, ObjectHelper { ply_laminate_table() : Object("ply_laminate_table") {} - - }; - - // C++ wrapper for point_and_vector - struct point_and_vector : ObjectHelper { point_and_vector() : Object("point_and_vector") {} - - }; - - // C++ wrapper for point_on_curve - struct point_on_curve : point, ObjectHelper { point_on_curve() : Object("point_on_curve") {} - Lazy< curve > basis_curve; - parameter_value::Out point_parameter; - }; - - // C++ wrapper for point_on_surface - struct point_on_surface : point, ObjectHelper { point_on_surface() : Object("point_on_surface") {} - Lazy< surface > basis_surface; - parameter_value::Out point_parameter_u; - parameter_value::Out point_parameter_v; - }; - - // C++ wrapper for point_path - struct point_path : ObjectHelper { point_path() : Object("point_path") {} - - }; - - // C++ wrapper for point_replica - struct point_replica : point, ObjectHelper { point_replica() : Object("point_replica") {} - Lazy< point > parent_pt; - Lazy< cartesian_transformation_operator > transformation; - }; - - // C++ wrapper for point_style - struct point_style : founded_item, ObjectHelper { point_style() : Object("point_style") {} - label::Out name; - marker_select::Out marker; - size_select::Out marker_size; - Lazy< colour > marker_colour; - }; - - // C++ wrapper for polar_complex_number_literal - struct polar_complex_number_literal : generic_literal, ObjectHelper { polar_complex_number_literal() : Object("polar_complex_number_literal") {} - REAL::Out radius; - REAL::Out angle; - }; - - // C++ wrapper for poly_loop - struct poly_loop : ObjectHelper { poly_loop() : Object("poly_loop") {} - ListOf< Lazy< cartesian_point >, 3, 0 > polygon; - }; - - // C++ wrapper for polyline - struct polyline : bounded_curve, ObjectHelper { polyline() : Object("polyline") {} - ListOf< Lazy< cartesian_point >, 2, 0 > points; - }; - - // C++ wrapper for position_tolerance - struct position_tolerance : geometric_tolerance, ObjectHelper { position_tolerance() : Object("position_tolerance") {} - - }; - - // C++ wrapper for positioned_sketch - struct positioned_sketch : geometric_representation_item, ObjectHelper { positioned_sketch() : Object("positioned_sketch") {} - sketch_basis_select::Out sketch_basis; - ListOf< Lazy< auxiliary_geometric_representation_item >, 0, 0 > auxiliary_elements; - }; - - // C++ wrapper for power_measure_with_unit - struct power_measure_with_unit : measure_with_unit, ObjectHelper { power_measure_with_unit() : Object("power_measure_with_unit") {} - - }; - - // C++ wrapper for power_unit - struct power_unit : derived_unit, ObjectHelper { power_unit() : Object("power_unit") {} - - }; - - // C++ wrapper for pre_defined_symbol - struct pre_defined_symbol : pre_defined_item, ObjectHelper { pre_defined_symbol() : Object("pre_defined_symbol") {} - - }; - - // C++ wrapper for pre_defined_dimension_symbol - struct pre_defined_dimension_symbol : pre_defined_symbol, ObjectHelper { pre_defined_dimension_symbol() : Object("pre_defined_dimension_symbol") {} - - }; - - // C++ wrapper for pre_defined_geometrical_tolerance_symbol - struct pre_defined_geometrical_tolerance_symbol : pre_defined_symbol, ObjectHelper { pre_defined_geometrical_tolerance_symbol() : Object("pre_defined_geometrical_tolerance_symbol") {} - - }; - - // C++ wrapper for pre_defined_marker - struct pre_defined_marker : pre_defined_item, ObjectHelper { pre_defined_marker() : Object("pre_defined_marker") {} - - }; - - // C++ wrapper for pre_defined_point_marker_symbol - struct pre_defined_point_marker_symbol : ObjectHelper { pre_defined_point_marker_symbol() : Object("pre_defined_point_marker_symbol") {} - - }; - - // C++ wrapper for pre_defined_surface_condition_symbol - struct pre_defined_surface_condition_symbol : pre_defined_symbol, ObjectHelper { pre_defined_surface_condition_symbol() : Object("pre_defined_surface_condition_symbol") {} - - }; - - // C++ wrapper for pre_defined_surface_side_style - struct pre_defined_surface_side_style : pre_defined_item, ObjectHelper { pre_defined_surface_side_style() : Object("pre_defined_surface_side_style") {} - - }; - - // C++ wrapper for pre_defined_terminator_symbol - struct pre_defined_terminator_symbol : pre_defined_symbol, ObjectHelper { pre_defined_terminator_symbol() : Object("pre_defined_terminator_symbol") {} - - }; - - // C++ wrapper for pre_defined_tile - struct pre_defined_tile : pre_defined_item, ObjectHelper { pre_defined_tile() : Object("pre_defined_tile") {} - - }; - - // C++ wrapper for predefined_picture_representation_item - struct predefined_picture_representation_item : picture_representation_item, ObjectHelper { predefined_picture_representation_item() : Object("predefined_picture_representation_item") {} - - }; - - // C++ wrapper for presentation_style_assignment - struct presentation_style_assignment : founded_item, ObjectHelper { presentation_style_assignment() : Object("presentation_style_assignment") {} - ListOf< presentation_style_select, 1, 0 >::Out styles; - }; - - // C++ wrapper for presentation_style_by_context - struct presentation_style_by_context : presentation_style_assignment, ObjectHelper { presentation_style_by_context() : Object("presentation_style_by_context") {} - style_context_select::Out style_context; - }; - - // C++ wrapper for pressure_measure_with_unit - struct pressure_measure_with_unit : measure_with_unit, ObjectHelper { pressure_measure_with_unit() : Object("pressure_measure_with_unit") {} - - }; - - // C++ wrapper for pressure_unit - struct pressure_unit : derived_unit, ObjectHelper { pressure_unit() : Object("pressure_unit") {} - - }; - - // C++ wrapper for procedural_representation - struct procedural_representation : representation, ObjectHelper { procedural_representation() : Object("procedural_representation") {} - - }; - - // C++ wrapper for procedural_representation_sequence - struct procedural_representation_sequence : representation_item, ObjectHelper { procedural_representation_sequence() : Object("procedural_representation_sequence") {} - ListOf< Lazy< representation_item >, 1, 0 > elements; - ListOf< Lazy< representation_item >, 0, 0 > suppressed_items; - text::Out rationale; - }; - - // C++ wrapper for procedural_shape_representation - struct procedural_shape_representation : ObjectHelper { procedural_shape_representation() : Object("procedural_shape_representation") {} - - }; - - // C++ wrapper for procedural_shape_representation_sequence - struct procedural_shape_representation_sequence : ObjectHelper { procedural_shape_representation_sequence() : Object("procedural_shape_representation_sequence") {} - - }; - - // C++ wrapper for product_category - struct product_category : ObjectHelper { product_category() : Object("product_category") {} - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for product_class - struct product_class : ObjectHelper { product_class() : Object("product_class") {} - - }; - - // C++ wrapper for product_concept_context - struct product_concept_context : application_context_element, ObjectHelper { product_concept_context() : Object("product_concept_context") {} - label::Out market_segment_type; - }; - - // C++ wrapper for product_concept_feature_category_usage - struct product_concept_feature_category_usage : group_assignment, ObjectHelper { product_concept_feature_category_usage() : Object("product_concept_feature_category_usage") {} - ListOf< category_usage_item, 1, 0 >::Out items; - }; - - // C++ wrapper for product_definition_element_relationship - struct product_definition_element_relationship : group, ObjectHelper { product_definition_element_relationship() : Object("product_definition_element_relationship") {} - - }; - - // C++ wrapper for product_definition_formation - struct product_definition_formation : ObjectHelper { product_definition_formation() : Object("product_definition_formation") {} - identifier::Out id; - Maybe< text::Out > description; - Lazy< NotImplemented > of_product; - }; - - // C++ wrapper for product_definition_formation_with_specified_source - struct product_definition_formation_with_specified_source : product_definition_formation, ObjectHelper { product_definition_formation_with_specified_source() : Object("product_definition_formation_with_specified_source") {} - source::Out make_or_buy; - }; - - // C++ wrapper for product_definition_group_assignment - struct product_definition_group_assignment : group_assignment, ObjectHelper { product_definition_group_assignment() : Object("product_definition_group_assignment") {} - ListOf< product_definition_or_product_definition_relationship, 1, 1 >::Out items; - }; - - // C++ wrapper for product_definition_shape - struct product_definition_shape : property_definition, ObjectHelper { product_definition_shape() : Object("product_definition_shape") {} - - }; - - // C++ wrapper for product_definition_with_associated_documents - struct product_definition_with_associated_documents : product_definition, ObjectHelper { product_definition_with_associated_documents() : Object("product_definition_with_associated_documents") {} - ListOf< Lazy< NotImplemented >, 1, 0 > documentation_ids; - }; - - // C++ wrapper for product_identification - struct product_identification : ObjectHelper { product_identification() : Object("product_identification") {} - - }; - - // C++ wrapper for product_material_composition_relationship - struct product_material_composition_relationship : product_definition_relationship, ObjectHelper { product_material_composition_relationship() : Object("product_material_composition_relationship") {} - label::Out class_; - ListOf< characterized_product_composition_value, 1, 0 >::Out constituent_amount; - label::Out composition_basis; - text::Out determination_method; - }; - - // C++ wrapper for product_related_product_category - struct product_related_product_category : product_category, ObjectHelper { product_related_product_category() : Object("product_related_product_category") {} - ListOf< Lazy< NotImplemented >, 1, 0 > products; - }; - - // C++ wrapper for product_specification - struct product_specification : ObjectHelper { product_specification() : Object("product_specification") {} - - }; - - // C++ wrapper for tolerance_zone_definition - struct tolerance_zone_definition : ObjectHelper { tolerance_zone_definition() : Object("tolerance_zone_definition") {} - Lazy< tolerance_zone > zone; - ListOf< Lazy< shape_aspect >, 1, 0 > boundaries; - }; - - // C++ wrapper for projected_zone_definition - struct projected_zone_definition : tolerance_zone_definition, ObjectHelper { projected_zone_definition() : Object("projected_zone_definition") {} - Lazy< shape_aspect > projection_end; - Lazy< measure_with_unit > projected_length; - }; - - // C++ wrapper for projection_curve - struct projection_curve : annotation_curve_occurrence, ObjectHelper { projection_curve() : Object("projection_curve") {} - - }; - - // C++ wrapper for promissory_usage_occurrence - struct promissory_usage_occurrence : assembly_component_usage, ObjectHelper { promissory_usage_occurrence() : Object("promissory_usage_occurrence") {} - - }; - - // C++ wrapper for qualified_representation_item - struct qualified_representation_item : representation_item, ObjectHelper { qualified_representation_item() : Object("qualified_representation_item") {} - ListOf< value_qualifier, 1, 0 >::Out qualifiers; - }; - - // C++ wrapper for qualitative_uncertainty - struct qualitative_uncertainty : uncertainty_qualifier, ObjectHelper { qualitative_uncertainty() : Object("qualitative_uncertainty") {} - text::Out uncertainty_value; - }; - - // C++ wrapper for quantified_assembly_component_usage - struct quantified_assembly_component_usage : assembly_component_usage, ObjectHelper { quantified_assembly_component_usage() : Object("quantified_assembly_component_usage") {} - Lazy< measure_with_unit > quantity; - }; - - // C++ wrapper for quasi_uniform_curve - struct quasi_uniform_curve : b_spline_curve, ObjectHelper { quasi_uniform_curve() : Object("quasi_uniform_curve") {} - - }; - - // C++ wrapper for quasi_uniform_surface - struct quasi_uniform_surface : b_spline_surface, ObjectHelper { quasi_uniform_surface() : Object("quasi_uniform_surface") {} - - }; - - // C++ wrapper for radioactivity_measure_with_unit - struct radioactivity_measure_with_unit : measure_with_unit, ObjectHelper { radioactivity_measure_with_unit() : Object("radioactivity_measure_with_unit") {} - - }; - - // C++ wrapper for radioactivity_unit - struct radioactivity_unit : derived_unit, ObjectHelper { radioactivity_unit() : Object("radioactivity_unit") {} - - }; - - // C++ wrapper for radius_dimension - struct radius_dimension : dimension_curve_directed_callout, ObjectHelper { radius_dimension() : Object("radius_dimension") {} - - }; - - // C++ wrapper for range_characteristic - struct range_characteristic : ObjectHelper { range_characteristic() : Object("range_characteristic") {} - - }; - - // C++ wrapper for ratio_unit - struct ratio_unit : named_unit, ObjectHelper { ratio_unit() : Object("ratio_unit") {} - - }; - - // C++ wrapper for rational_b_spline_curve - struct rational_b_spline_curve : b_spline_curve, ObjectHelper { rational_b_spline_curve() : Object("rational_b_spline_curve") {} - ListOf< REAL, 2, 0 >::Out weights_data; - }; - - // C++ wrapper for rational_b_spline_surface - struct rational_b_spline_surface : b_spline_surface, ObjectHelper { rational_b_spline_surface() : Object("rational_b_spline_surface") {} - - }; - - // C++ wrapper for rational_representation_item - struct rational_representation_item : ObjectHelper { rational_representation_item() : Object("rational_representation_item") {} - - }; - - // C++ wrapper for real_literal - struct real_literal : literal_number, ObjectHelper { real_literal() : Object("real_literal") {} - - }; - - // C++ wrapper for real_representation_item - struct real_representation_item : ObjectHelper { real_representation_item() : Object("real_representation_item") {} - - }; - - // C++ wrapper for rectangular_composite_surface - struct rectangular_composite_surface : bounded_surface, ObjectHelper { rectangular_composite_surface() : Object("rectangular_composite_surface") {} - - }; - - // C++ wrapper for rectangular_trimmed_surface - struct rectangular_trimmed_surface : bounded_surface, ObjectHelper { rectangular_trimmed_surface() : Object("rectangular_trimmed_surface") {} - Lazy< surface > basis_surface; - parameter_value::Out u1; - parameter_value::Out u2; - parameter_value::Out v1; - parameter_value::Out v2; - BOOLEAN::Out usense; - BOOLEAN::Out vsense; - }; - - // C++ wrapper for referenced_modified_datum - struct referenced_modified_datum : datum_reference, ObjectHelper { referenced_modified_datum() : Object("referenced_modified_datum") {} - limit_condition::Out modifier; - }; - - // C++ wrapper for relative_event_occurrence - struct relative_event_occurrence : event_occurrence, ObjectHelper { relative_event_occurrence() : Object("relative_event_occurrence") {} - Lazy< event_occurrence > base_event; - Lazy< time_measure_with_unit > offset; - }; - - // C++ wrapper for rep_item_group - struct rep_item_group : ObjectHelper { rep_item_group() : Object("rep_item_group") {} - - }; - - // C++ wrapper for reparametrised_composite_curve_segment - struct reparametrised_composite_curve_segment : composite_curve_segment, ObjectHelper { reparametrised_composite_curve_segment() : Object("reparametrised_composite_curve_segment") {} - parameter_value::Out param_length; - }; - - // C++ wrapper for representation_relationship_with_transformation - struct representation_relationship_with_transformation : representation_relationship, ObjectHelper { representation_relationship_with_transformation() : Object("representation_relationship_with_transformation") {} - transformation::Out transformation_operator; - }; - - // C++ wrapper for requirement_assigned_object - struct requirement_assigned_object : group_assignment, ObjectHelper { requirement_assigned_object() : Object("requirement_assigned_object") {} - ListOf< requirement_assigned_item, 1, 1 >::Out items; - }; - - // C++ wrapper for requirement_assignment - struct requirement_assignment : ObjectHelper { requirement_assignment() : Object("requirement_assignment") {} - - }; - - // C++ wrapper for requirement_source - struct requirement_source : group, ObjectHelper { requirement_source() : Object("requirement_source") {} - - }; - - // C++ wrapper for requirement_view_definition_relationship - struct requirement_view_definition_relationship : product_definition_relationship, ObjectHelper { requirement_view_definition_relationship() : Object("requirement_view_definition_relationship") {} - - }; - - // C++ wrapper for resistance_measure_with_unit - struct resistance_measure_with_unit : measure_with_unit, ObjectHelper { resistance_measure_with_unit() : Object("resistance_measure_with_unit") {} - - }; - - // C++ wrapper for resistance_unit - struct resistance_unit : derived_unit, ObjectHelper { resistance_unit() : Object("resistance_unit") {} - - }; - - // C++ wrapper for revolved_area_solid - struct revolved_area_solid : swept_area_solid, ObjectHelper { revolved_area_solid() : Object("revolved_area_solid") {} - Lazy< axis1_placement > axis; - plane_angle_measure::Out angle; - }; - - // C++ wrapper for revolved_face_solid - struct revolved_face_solid : swept_face_solid, ObjectHelper { revolved_face_solid() : Object("revolved_face_solid") {} - Lazy< axis1_placement > axis; - plane_angle_measure::Out angle; - }; - - // C++ wrapper for revolved_face_solid_with_trim_conditions - struct revolved_face_solid_with_trim_conditions : revolved_face_solid, ObjectHelper { revolved_face_solid_with_trim_conditions() : Object("revolved_face_solid_with_trim_conditions") {} - trim_condition_select::Out first_trim_condition; - trim_condition_select::Out second_trim_condition; - }; - - // C++ wrapper for right_angular_wedge - struct right_angular_wedge : geometric_representation_item, ObjectHelper { right_angular_wedge() : Object("right_angular_wedge") {} - Lazy< axis2_placement_3d > position; - positive_length_measure::Out x; - positive_length_measure::Out y; - positive_length_measure::Out z; - length_measure::Out ltx; - }; - - // C++ wrapper for right_circular_cone - struct right_circular_cone : geometric_representation_item, ObjectHelper { right_circular_cone() : Object("right_circular_cone") {} - Lazy< axis1_placement > position; - positive_length_measure::Out height; - length_measure::Out radius; - plane_angle_measure::Out semi_angle; - }; - - // C++ wrapper for right_circular_cylinder - struct right_circular_cylinder : geometric_representation_item, ObjectHelper { right_circular_cylinder() : Object("right_circular_cylinder") {} - Lazy< axis1_placement > position; - positive_length_measure::Out height; - positive_length_measure::Out radius; - }; - - // C++ wrapper for right_to_usage_association - struct right_to_usage_association : action_method_relationship, ObjectHelper { right_to_usage_association() : Object("right_to_usage_association") {} - - }; - - // C++ wrapper for roundness_tolerance - struct roundness_tolerance : geometric_tolerance, ObjectHelper { roundness_tolerance() : Object("roundness_tolerance") {} - - }; - - // C++ wrapper for row_representation_item - struct row_representation_item : compound_representation_item, ObjectHelper { row_representation_item() : Object("row_representation_item") {} - - }; - - // C++ wrapper for row_value - struct row_value : compound_representation_item, ObjectHelper { row_value() : Object("row_value") {} - - }; - - // C++ wrapper for row_variable - struct row_variable : abstract_variable, ObjectHelper { row_variable() : Object("row_variable") {} - - }; - - // C++ wrapper for rule_action - struct rule_action : action, ObjectHelper { rule_action() : Object("rule_action") {} - - }; - - // C++ wrapper for rule_condition - struct rule_condition : atomic_formula, ObjectHelper { rule_condition() : Object("rule_condition") {} - - }; - - // C++ wrapper for rule_set - struct rule_set : rule_software_definition, ObjectHelper { rule_set() : Object("rule_set") {} - - }; - - // C++ wrapper for rule_set_group - struct rule_set_group : rule_software_definition, ObjectHelper { rule_set_group() : Object("rule_set_group") {} - - }; - - // C++ wrapper for rule_superseded_assignment - struct rule_superseded_assignment : action_assignment, ObjectHelper { rule_superseded_assignment() : Object("rule_superseded_assignment") {} - ListOf< rule_superseded_item, 1, 0 >::Out items; - }; - - // C++ wrapper for rule_supersedence - struct rule_supersedence : rule_action, ObjectHelper { rule_supersedence() : Object("rule_supersedence") {} - - }; - - // C++ wrapper for surface_curve_swept_area_solid - struct surface_curve_swept_area_solid : swept_area_solid, ObjectHelper { surface_curve_swept_area_solid() : Object("surface_curve_swept_area_solid") {} - Lazy< curve > directrix; - REAL::Out start_param; - REAL::Out end_param; - Lazy< surface > reference_surface; - }; - - // C++ wrapper for ruled_surface_swept_area_solid - struct ruled_surface_swept_area_solid : surface_curve_swept_area_solid, ObjectHelper { ruled_surface_swept_area_solid() : Object("ruled_surface_swept_area_solid") {} - - }; - - // C++ wrapper for runout_zone_definition - struct runout_zone_definition : tolerance_zone_definition, ObjectHelper { runout_zone_definition() : Object("runout_zone_definition") {} - Lazy< runout_zone_orientation > orientation; - }; - - // C++ wrapper for runout_zone_orientation - struct runout_zone_orientation : ObjectHelper { runout_zone_orientation() : Object("runout_zone_orientation") {} - Lazy< measure_with_unit > angle; - }; - - // C++ wrapper for runout_zone_orientation_reference_direction - struct runout_zone_orientation_reference_direction : runout_zone_orientation, ObjectHelper { runout_zone_orientation_reference_direction() : Object("runout_zone_orientation_reference_direction") {} - Lazy< shape_aspect_relationship > orientation_defining_relationship; - }; - - // C++ wrapper for satisfied_requirement - struct satisfied_requirement : group_assignment, ObjectHelper { satisfied_requirement() : Object("satisfied_requirement") {} - ListOf< Lazy< product_definition >, 1, 1 > items; - }; - - // C++ wrapper for satisfies_requirement - struct satisfies_requirement : group, ObjectHelper { satisfies_requirement() : Object("satisfies_requirement") {} - - }; - - // C++ wrapper for satisfying_item - struct satisfying_item : group_assignment, ObjectHelper { satisfying_item() : Object("satisfying_item") {} - ListOf< requirement_satisfaction_item, 1, 1 >::Out items; - }; - - // C++ wrapper for scalar_variable - struct scalar_variable : abstract_variable, ObjectHelper { scalar_variable() : Object("scalar_variable") {} - - }; - - // C++ wrapper for scattering_parameter - struct scattering_parameter : polar_complex_number_literal, ObjectHelper { scattering_parameter() : Object("scattering_parameter") {} - - }; - - // C++ wrapper for sculptured_solid - struct sculptured_solid : modified_solid, ObjectHelper { sculptured_solid() : Object("sculptured_solid") {} - generalized_surface_select::Out sculpturing_element; - BOOLEAN::Out positive_side; - }; - - // C++ wrapper for seam_curve - struct seam_curve : surface_curve, ObjectHelper { seam_curve() : Object("seam_curve") {} - - }; - - // C++ wrapper for serial_numbered_effectivity - struct serial_numbered_effectivity : effectivity, ObjectHelper { serial_numbered_effectivity() : Object("serial_numbered_effectivity") {} - identifier::Out effectivity_start_id; - Maybe< identifier::Out > effectivity_end_id; - }; - - // C++ wrapper for shape_aspect_associativity - struct shape_aspect_associativity : shape_aspect_relationship, ObjectHelper { shape_aspect_associativity() : Object("shape_aspect_associativity") {} - - }; - - // C++ wrapper for shape_aspect_deriving_relationship - struct shape_aspect_deriving_relationship : shape_aspect_relationship, ObjectHelper { shape_aspect_deriving_relationship() : Object("shape_aspect_deriving_relationship") {} - - }; - - // C++ wrapper for shape_definition_representation - struct shape_definition_representation : property_definition_representation, ObjectHelper { shape_definition_representation() : Object("shape_definition_representation") {} - - }; - - // C++ wrapper for shape_dimension_representation - struct shape_dimension_representation : shape_representation, ObjectHelper { shape_dimension_representation() : Object("shape_dimension_representation") {} - - }; - - // C++ wrapper for shape_feature_definition - struct shape_feature_definition : characterized_object, ObjectHelper { shape_feature_definition() : Object("shape_feature_definition") {} - - }; - - // C++ wrapper for shape_representation_with_parameters - struct shape_representation_with_parameters : shape_representation, ObjectHelper { shape_representation_with_parameters() : Object("shape_representation_with_parameters") {} - - }; - - // C++ wrapper for shell_based_surface_model - struct shell_based_surface_model : geometric_representation_item, ObjectHelper { shell_based_surface_model() : Object("shell_based_surface_model") {} - ListOf< shell, 1, 0 >::Out sbsm_boundary; - }; - - // C++ wrapper for shell_based_wireframe_model - struct shell_based_wireframe_model : geometric_representation_item, ObjectHelper { shell_based_wireframe_model() : Object("shell_based_wireframe_model") {} - ListOf< shell, 1, 0 >::Out sbwm_boundary; - }; - - // C++ wrapper for shell_based_wireframe_shape_representation - struct shell_based_wireframe_shape_representation : shape_representation, ObjectHelper { shell_based_wireframe_shape_representation() : Object("shell_based_wireframe_shape_representation") {} - - }; - - // C++ wrapper for si_absorbed_dose_unit - struct si_absorbed_dose_unit : ObjectHelper { si_absorbed_dose_unit() : Object("si_absorbed_dose_unit") {} - - }; - - // C++ wrapper for si_capacitance_unit - struct si_capacitance_unit : ObjectHelper { si_capacitance_unit() : Object("si_capacitance_unit") {} - - }; - - // C++ wrapper for si_conductance_unit - struct si_conductance_unit : ObjectHelper { si_conductance_unit() : Object("si_conductance_unit") {} - - }; - - // C++ wrapper for si_dose_equivalent_unit - struct si_dose_equivalent_unit : ObjectHelper { si_dose_equivalent_unit() : Object("si_dose_equivalent_unit") {} - - }; - - // C++ wrapper for si_electric_charge_unit - struct si_electric_charge_unit : ObjectHelper { si_electric_charge_unit() : Object("si_electric_charge_unit") {} - - }; - - // C++ wrapper for si_electric_potential_unit - struct si_electric_potential_unit : ObjectHelper { si_electric_potential_unit() : Object("si_electric_potential_unit") {} - - }; - - // C++ wrapper for si_energy_unit - struct si_energy_unit : ObjectHelper { si_energy_unit() : Object("si_energy_unit") {} - - }; - - // C++ wrapper for si_force_unit - struct si_force_unit : ObjectHelper { si_force_unit() : Object("si_force_unit") {} - - }; - - // C++ wrapper for si_frequency_unit - struct si_frequency_unit : ObjectHelper { si_frequency_unit() : Object("si_frequency_unit") {} - - }; - - // C++ wrapper for si_illuminance_unit - struct si_illuminance_unit : ObjectHelper { si_illuminance_unit() : Object("si_illuminance_unit") {} - - }; - - // C++ wrapper for si_inductance_unit - struct si_inductance_unit : ObjectHelper { si_inductance_unit() : Object("si_inductance_unit") {} - - }; - - // C++ wrapper for si_magnetic_flux_density_unit - struct si_magnetic_flux_density_unit : ObjectHelper { si_magnetic_flux_density_unit() : Object("si_magnetic_flux_density_unit") {} - - }; - - // C++ wrapper for si_magnetic_flux_unit - struct si_magnetic_flux_unit : ObjectHelper { si_magnetic_flux_unit() : Object("si_magnetic_flux_unit") {} - - }; - - // C++ wrapper for si_power_unit - struct si_power_unit : ObjectHelper { si_power_unit() : Object("si_power_unit") {} - - }; - - // C++ wrapper for si_pressure_unit - struct si_pressure_unit : ObjectHelper { si_pressure_unit() : Object("si_pressure_unit") {} - - }; - - // C++ wrapper for si_radioactivity_unit - struct si_radioactivity_unit : ObjectHelper { si_radioactivity_unit() : Object("si_radioactivity_unit") {} - - }; - - // C++ wrapper for si_resistance_unit - struct si_resistance_unit : ObjectHelper { si_resistance_unit() : Object("si_resistance_unit") {} - - }; - - // C++ wrapper for si_unit - struct si_unit : named_unit, ObjectHelper { si_unit() : Object("si_unit") {} - Maybe< si_prefix::Out > prefix; - si_unit_name::Out name; - }; - - // C++ wrapper for simple_boolean_expression - struct simple_boolean_expression : ObjectHelper { simple_boolean_expression() : Object("simple_boolean_expression") {} - - }; - - // C++ wrapper for simple_numeric_expression - struct simple_numeric_expression : ObjectHelper { simple_numeric_expression() : Object("simple_numeric_expression") {} - - }; - - // C++ wrapper for slash_expression - struct slash_expression : binary_numeric_expression, ObjectHelper { slash_expression() : Object("slash_expression") {} - - }; - - // C++ wrapper for smeared_material_definition - struct smeared_material_definition : zone_structural_makeup, ObjectHelper { smeared_material_definition() : Object("smeared_material_definition") {} - - }; - - // C++ wrapper for solid_angle_measure_with_unit - struct solid_angle_measure_with_unit : measure_with_unit, ObjectHelper { solid_angle_measure_with_unit() : Object("solid_angle_measure_with_unit") {} - - }; - - // C++ wrapper for solid_angle_unit - struct solid_angle_unit : named_unit, ObjectHelper { solid_angle_unit() : Object("solid_angle_unit") {} - - }; - - // C++ wrapper for solid_curve_font - struct solid_curve_font : pre_defined_curve_font, ObjectHelper { solid_curve_font() : Object("solid_curve_font") {} - - }; - - // C++ wrapper for solid_replica - struct solid_replica : solid_model, ObjectHelper { solid_replica() : Object("solid_replica") {} - Lazy< solid_model > parent_solid; - Lazy< cartesian_transformation_operator_3d > transformation; - }; - - // C++ wrapper for solid_with_chamfered_edges - struct solid_with_chamfered_edges : edge_blended_solid, ObjectHelper { solid_with_chamfered_edges() : Object("solid_with_chamfered_edges") {} - - }; - - // C++ wrapper for solid_with_angle_based_chamfer - struct solid_with_angle_based_chamfer : solid_with_chamfered_edges, ObjectHelper { solid_with_angle_based_chamfer() : Object("solid_with_angle_based_chamfer") {} - positive_length_measure::Out offset_distance; - BOOLEAN::Out left_offset; - positive_plane_angle_measure::Out offset_angle; - }; - - // C++ wrapper for solid_with_shape_element_pattern - struct solid_with_shape_element_pattern : modified_solid_with_placed_configuration, ObjectHelper { solid_with_shape_element_pattern() : Object("solid_with_shape_element_pattern") {} - Lazy< modified_solid_with_placed_configuration > replicated_element; - }; - - // C++ wrapper for solid_with_circular_pattern - struct solid_with_circular_pattern : solid_with_shape_element_pattern, ObjectHelper { solid_with_circular_pattern() : Object("solid_with_circular_pattern") {} - positive_integer::Out replicate_count; - plane_angle_measure::Out angular_spacing; - BOOLEAN::Out radial_alignment; - Lazy< point > reference_point; - }; - - // C++ wrapper for solid_with_depression - struct solid_with_depression : modified_solid_with_placed_configuration, ObjectHelper { solid_with_depression() : Object("solid_with_depression") {} - positive_length_measure::Out depth; - }; - - // C++ wrapper for solid_with_pocket - struct solid_with_pocket : solid_with_depression, ObjectHelper { solid_with_pocket() : Object("solid_with_pocket") {} - non_negative_length_measure::Out floor_blend_radius; - plane_angle_measure::Out draft_angle; - }; - - // C++ wrapper for solid_with_circular_pocket - struct solid_with_circular_pocket : solid_with_pocket, ObjectHelper { solid_with_circular_pocket() : Object("solid_with_circular_pocket") {} - positive_length_measure::Out pocket_radius; - }; - - // C++ wrapper for solid_with_protrusion - struct solid_with_protrusion : modified_solid_with_placed_configuration, ObjectHelper { solid_with_protrusion() : Object("solid_with_protrusion") {} - positive_length_measure::Out protrusion_height; - plane_angle_measure::Out protrusion_draft_angle; - }; - - // C++ wrapper for solid_with_circular_protrusion - struct solid_with_circular_protrusion : solid_with_protrusion, ObjectHelper { solid_with_circular_protrusion() : Object("solid_with_circular_protrusion") {} - positive_length_measure::Out protrusion_radius; - }; - - // C++ wrapper for solid_with_hole - struct solid_with_hole : solid_with_depression, ObjectHelper { solid_with_hole() : Object("solid_with_hole") {} - - }; - - // C++ wrapper for solid_with_stepped_round_hole - struct solid_with_stepped_round_hole : solid_with_hole, ObjectHelper { solid_with_stepped_round_hole() : Object("solid_with_stepped_round_hole") {} - positive_integer::Out segments; - }; - - // C++ wrapper for solid_with_conical_bottom_round_hole - struct solid_with_conical_bottom_round_hole : solid_with_stepped_round_hole, ObjectHelper { solid_with_conical_bottom_round_hole() : Object("solid_with_conical_bottom_round_hole") {} - positive_plane_angle_measure::Out semi_apex_angle; - non_negative_length_measure::Out tip_radius; - }; - - // C++ wrapper for solid_with_constant_radius_edge_blend - struct solid_with_constant_radius_edge_blend : edge_blended_solid, ObjectHelper { solid_with_constant_radius_edge_blend() : Object("solid_with_constant_radius_edge_blend") {} - positive_length_measure::Out radius; - }; - - // C++ wrapper for solid_with_slot - struct solid_with_slot : solid_with_depression, ObjectHelper { solid_with_slot() : Object("solid_with_slot") {} - positive_length_measure::Out slot_width; - ListOf< LOGICAL, 2, 2 >::Out closed_ends; - }; - - // C++ wrapper for solid_with_curved_slot - struct solid_with_curved_slot : solid_with_slot, ObjectHelper { solid_with_curved_slot() : Object("solid_with_curved_slot") {} - Lazy< bounded_curve > slot_centreline; - }; - - // C++ wrapper for solid_with_double_offset_chamfer - struct solid_with_double_offset_chamfer : solid_with_chamfered_edges, ObjectHelper { solid_with_double_offset_chamfer() : Object("solid_with_double_offset_chamfer") {} - positive_length_measure::Out left_offset_distance; - positive_length_measure::Out right_offset_distance; - }; - - // C++ wrapper for solid_with_flat_bottom_round_hole - struct solid_with_flat_bottom_round_hole : solid_with_stepped_round_hole, ObjectHelper { solid_with_flat_bottom_round_hole() : Object("solid_with_flat_bottom_round_hole") {} - non_negative_length_measure::Out fillet_radius; - }; - - // C++ wrapper for solid_with_general_pocket - struct solid_with_general_pocket : solid_with_pocket, ObjectHelper { solid_with_general_pocket() : Object("solid_with_general_pocket") {} - Lazy< positioned_sketch > profile; - Lazy< point > reference_point; - }; - - // C++ wrapper for solid_with_general_protrusion - struct solid_with_general_protrusion : solid_with_protrusion, ObjectHelper { solid_with_general_protrusion() : Object("solid_with_general_protrusion") {} - Lazy< positioned_sketch > profile; - Lazy< point > reference_point; - }; - - // C++ wrapper for solid_with_groove - struct solid_with_groove : solid_with_depression, ObjectHelper { solid_with_groove() : Object("solid_with_groove") {} - positive_length_measure::Out groove_radius; - positive_length_measure::Out groove_width; - plane_angle_measure::Out draft_angle; - non_negative_length_measure::Out floor_fillet_radius; - BOOLEAN::Out external_groove; - }; - - // C++ wrapper for solid_with_incomplete_circular_pattern - struct solid_with_incomplete_circular_pattern : solid_with_circular_pattern, ObjectHelper { solid_with_incomplete_circular_pattern() : Object("solid_with_incomplete_circular_pattern") {} - ListOf< positive_integer, 1, 0 >::Out omitted_instances; - }; - - // C++ wrapper for solid_with_rectangular_pattern - struct solid_with_rectangular_pattern : solid_with_shape_element_pattern, ObjectHelper { solid_with_rectangular_pattern() : Object("solid_with_rectangular_pattern") {} - positive_integer::Out row_count; - positive_integer::Out column_count; - length_measure::Out row_spacing; - length_measure::Out column_spacing; - }; - - // C++ wrapper for solid_with_incomplete_rectangular_pattern - struct solid_with_incomplete_rectangular_pattern : solid_with_rectangular_pattern, ObjectHelper { solid_with_incomplete_rectangular_pattern() : Object("solid_with_incomplete_rectangular_pattern") {} - - }; - - // C++ wrapper for solid_with_rectangular_pocket - struct solid_with_rectangular_pocket : solid_with_pocket, ObjectHelper { solid_with_rectangular_pocket() : Object("solid_with_rectangular_pocket") {} - positive_length_measure::Out pocket_length; - positive_length_measure::Out pocket_width; - non_negative_length_measure::Out corner_radius; - }; - - // C++ wrapper for solid_with_rectangular_protrusion - struct solid_with_rectangular_protrusion : solid_with_protrusion, ObjectHelper { solid_with_rectangular_protrusion() : Object("solid_with_rectangular_protrusion") {} - positive_length_measure::Out protrusion_length; - positive_length_measure::Out protrusion_width; - non_negative_length_measure::Out protrusion_corner_radius; - }; - - // C++ wrapper for solid_with_single_offset_chamfer - struct solid_with_single_offset_chamfer : solid_with_chamfered_edges, ObjectHelper { solid_with_single_offset_chamfer() : Object("solid_with_single_offset_chamfer") {} - positive_length_measure::Out offset_distance; - }; - - // C++ wrapper for solid_with_spherical_bottom_round_hole - struct solid_with_spherical_bottom_round_hole : solid_with_stepped_round_hole, ObjectHelper { solid_with_spherical_bottom_round_hole() : Object("solid_with_spherical_bottom_round_hole") {} - positive_length_measure::Out sphere_radius; - }; - - // C++ wrapper for solid_with_stepped_round_hole_and_conical_transitions - struct solid_with_stepped_round_hole_and_conical_transitions : solid_with_stepped_round_hole, ObjectHelper { solid_with_stepped_round_hole_and_conical_transitions() : Object("solid_with_stepped_round_hole_and_conical_transitions") {} - ListOf< Lazy< conical_stepped_hole_transition >, 1, 0 > conical_transitions; - }; - - // C++ wrapper for solid_with_straight_slot - struct solid_with_straight_slot : solid_with_slot, ObjectHelper { solid_with_straight_slot() : Object("solid_with_straight_slot") {} - positive_length_measure::Out slot_length; - }; - - // C++ wrapper for solid_with_tee_section_slot - struct solid_with_tee_section_slot : solid_with_slot, ObjectHelper { solid_with_tee_section_slot() : Object("solid_with_tee_section_slot") {} - positive_length_measure::Out tee_section_width; - positive_length_measure::Out collar_depth; - }; - - // C++ wrapper for solid_with_through_depression - struct solid_with_through_depression : solid_with_depression, ObjectHelper { solid_with_through_depression() : Object("solid_with_through_depression") {} - ListOf< Lazy< face_surface >, 1, 0 > exit_faces; - }; - - // C++ wrapper for solid_with_trapezoidal_section_slot - struct solid_with_trapezoidal_section_slot : solid_with_slot, ObjectHelper { solid_with_trapezoidal_section_slot() : Object("solid_with_trapezoidal_section_slot") {} - plane_angle_measure::Out draft_angle; - non_negative_length_measure::Out floor_fillet_radius; - }; - - // C++ wrapper for solid_with_variable_radius_edge_blend - struct solid_with_variable_radius_edge_blend : ObjectHelper { solid_with_variable_radius_edge_blend() : Object("solid_with_variable_radius_edge_blend") {} - ListOf< Lazy< point >, 2, 0 > point_list; - ListOf< positive_length_measure, 2, 0 >::Out radius_list; - ListOf< blend_radius_variation_type, 1, 0 >::Out edge_function_list; - }; - - // C++ wrapper for source_for_requirement - struct source_for_requirement : group_assignment, ObjectHelper { source_for_requirement() : Object("source_for_requirement") {} - ListOf< requirement_source_item, 1, 1 >::Out items; - }; - - // C++ wrapper for sourced_requirement - struct sourced_requirement : group_assignment, ObjectHelper { sourced_requirement() : Object("sourced_requirement") {} - ListOf< Lazy< product_definition >, 1, 1 > items; - }; - - // C++ wrapper for specification_definition - struct specification_definition : product_definition, ObjectHelper { specification_definition() : Object("specification_definition") {} - - }; - - // C++ wrapper for specified_higher_usage_occurrence - struct specified_higher_usage_occurrence : assembly_component_usage, ObjectHelper { specified_higher_usage_occurrence() : Object("specified_higher_usage_occurrence") {} - Lazy< assembly_component_usage > upper_usage; - Lazy< next_assembly_usage_occurrence > next_usage; - }; - - // C++ wrapper for sphere - struct sphere : geometric_representation_item, ObjectHelper { sphere() : Object("sphere") {} - positive_length_measure::Out radius; - Lazy< point > centre; - }; - - // C++ wrapper for spherical_surface - struct spherical_surface : elementary_surface, ObjectHelper { spherical_surface() : Object("spherical_surface") {} - positive_length_measure::Out radius; - }; - - // C++ wrapper for start_request - struct start_request : action_request_assignment, ObjectHelper { start_request() : Object("start_request") {} - ListOf< start_request_item, 1, 0 >::Out items; - }; - - // C++ wrapper for start_work - struct start_work : action_assignment, ObjectHelper { start_work() : Object("start_work") {} - ListOf< work_item, 1, 0 >::Out items; - }; - - // C++ wrapper for straightness_tolerance - struct straightness_tolerance : geometric_tolerance, ObjectHelper { straightness_tolerance() : Object("straightness_tolerance") {} - - }; - - // C++ wrapper for structured_dimension_callout - struct structured_dimension_callout : draughting_callout, ObjectHelper { structured_dimension_callout() : Object("structured_dimension_callout") {} - - }; - - // C++ wrapper for structured_text_composition - struct structured_text_composition : compound_representation_item, ObjectHelper { structured_text_composition() : Object("structured_text_composition") {} - - }; - - // C++ wrapper for structured_text_representation - struct structured_text_representation : representation, ObjectHelper { structured_text_representation() : Object("structured_text_representation") {} - - }; - - // C++ wrapper for subedge - struct subedge : edge, ObjectHelper { subedge() : Object("subedge") {} - Lazy< edge > parent_edge; - }; - - // C++ wrapper for subface - struct subface : face, ObjectHelper { subface() : Object("subface") {} - Lazy< face > parent_face; - }; - - // C++ wrapper for supplied_part_relationship - struct supplied_part_relationship : product_definition_relationship, ObjectHelper { supplied_part_relationship() : Object("supplied_part_relationship") {} - - }; - - // C++ wrapper for surface_condition_callout - struct surface_condition_callout : draughting_callout, ObjectHelper { surface_condition_callout() : Object("surface_condition_callout") {} - - }; - - // C++ wrapper for swept_surface - struct swept_surface : surface, ObjectHelper { swept_surface() : Object("swept_surface") {} - Lazy< curve > swept_curve; - }; - - // C++ wrapper for surface_of_linear_extrusion - struct surface_of_linear_extrusion : swept_surface, ObjectHelper { surface_of_linear_extrusion() : Object("surface_of_linear_extrusion") {} - Lazy< vector > extrusion_axis; - }; - - // C++ wrapper for surface_of_revolution - struct surface_of_revolution : swept_surface, ObjectHelper { surface_of_revolution() : Object("surface_of_revolution") {} - Lazy< axis1_placement > axis_position; - }; - - // C++ wrapper for surface_patch - struct surface_patch : founded_item, ObjectHelper { surface_patch() : Object("surface_patch") {} - Lazy< bounded_surface > parent_surface; - transition_code::Out u_transition; - transition_code::Out v_transition; - BOOLEAN::Out u_sense; - BOOLEAN::Out v_sense; - }; - - // C++ wrapper for surface_profile_tolerance - struct surface_profile_tolerance : geometric_tolerance, ObjectHelper { surface_profile_tolerance() : Object("surface_profile_tolerance") {} - - }; - - // C++ wrapper for surface_replica - struct surface_replica : surface, ObjectHelper { surface_replica() : Object("surface_replica") {} - Lazy< surface > parent_surface; - Lazy< cartesian_transformation_operator_3d > transformation; - }; - - // C++ wrapper for surface_side_style - struct surface_side_style : founded_item, ObjectHelper { surface_side_style() : Object("surface_side_style") {} - label::Out name; - ListOf< surface_style_element_select, 1, 7 >::Out styles; - }; - - // C++ wrapper for surface_style_boundary - struct surface_style_boundary : founded_item, ObjectHelper { surface_style_boundary() : Object("surface_style_boundary") {} - curve_or_render::Out style_of_boundary; - }; - - // C++ wrapper for surface_style_control_grid - struct surface_style_control_grid : founded_item, ObjectHelper { surface_style_control_grid() : Object("surface_style_control_grid") {} - curve_or_render::Out style_of_control_grid; - }; - - // C++ wrapper for surface_style_fill_area - struct surface_style_fill_area : founded_item, ObjectHelper { surface_style_fill_area() : Object("surface_style_fill_area") {} - Lazy< fill_area_style > fill_area; - }; - - // C++ wrapper for surface_style_parameter_line - struct surface_style_parameter_line : founded_item, ObjectHelper { surface_style_parameter_line() : Object("surface_style_parameter_line") {} - curve_or_render::Out style_of_parameter_lines; - ListOf< direction_count_select, 1, 2 >::Out direction_counts; - }; - - // C++ wrapper for surface_style_reflectance_ambient - struct surface_style_reflectance_ambient : ObjectHelper { surface_style_reflectance_ambient() : Object("surface_style_reflectance_ambient") {} - REAL::Out ambient_reflectance; - }; - - // C++ wrapper for surface_style_reflectance_ambient_diffuse - struct surface_style_reflectance_ambient_diffuse : surface_style_reflectance_ambient, ObjectHelper { surface_style_reflectance_ambient_diffuse() : Object("surface_style_reflectance_ambient_diffuse") {} - REAL::Out diffuse_reflectance; - }; - - // C++ wrapper for surface_style_reflectance_ambient_diffuse_specular - struct surface_style_reflectance_ambient_diffuse_specular : surface_style_reflectance_ambient_diffuse, ObjectHelper { surface_style_reflectance_ambient_diffuse_specular() : Object("surface_style_reflectance_ambient_diffuse_specular") {} - REAL::Out specular_reflectance; - REAL::Out specular_exponent; - Lazy< colour > specular_colour; - }; - - // C++ wrapper for surface_style_rendering - struct surface_style_rendering : ObjectHelper { surface_style_rendering() : Object("surface_style_rendering") {} - shading_surface_method::Out rendering_method; - Lazy< colour > surface_colour; - }; - - // C++ wrapper for surface_style_rendering_with_properties - struct surface_style_rendering_with_properties : surface_style_rendering, ObjectHelper { surface_style_rendering_with_properties() : Object("surface_style_rendering_with_properties") {} - ListOf< rendering_properties_select, 1, 2 >::Out properties; - }; - - // C++ wrapper for surface_style_segmentation_curve - struct surface_style_segmentation_curve : founded_item, ObjectHelper { surface_style_segmentation_curve() : Object("surface_style_segmentation_curve") {} - curve_or_render::Out style_of_segmentation_curve; - }; - - // C++ wrapper for surface_style_silhouette - struct surface_style_silhouette : founded_item, ObjectHelper { surface_style_silhouette() : Object("surface_style_silhouette") {} - curve_or_render::Out style_of_silhouette; - }; - - // C++ wrapper for surface_style_usage - struct surface_style_usage : founded_item, ObjectHelper { surface_style_usage() : Object("surface_style_usage") {} - surface_side::Out side; - surface_side_style_select::Out style; - }; - - // C++ wrapper for surface_texture_representation - struct surface_texture_representation : representation, ObjectHelper { surface_texture_representation() : Object("surface_texture_representation") {} - - }; - - // C++ wrapper for surfaced_open_shell - struct surfaced_open_shell : open_shell, ObjectHelper { surfaced_open_shell() : Object("surfaced_open_shell") {} - - }; - - // C++ wrapper for swept_disk_solid - struct swept_disk_solid : solid_model, ObjectHelper { swept_disk_solid() : Object("swept_disk_solid") {} - Lazy< curve > directrix; - positive_length_measure::Out radius; - Maybe< positive_length_measure::Out > inner_radius; - REAL::Out start_param; - REAL::Out end_param; - }; - - // C++ wrapper for symbol - struct symbol : representation_item, ObjectHelper { symbol() : Object("symbol") {} - - }; - - // C++ wrapper for symbol_representation_map - struct symbol_representation_map : representation_map, ObjectHelper { symbol_representation_map() : Object("symbol_representation_map") {} - - }; - - // C++ wrapper for symbol_style - struct symbol_style : founded_item, ObjectHelper { symbol_style() : Object("symbol_style") {} - label::Out name; - symbol_style_select::Out style_of_symbol; - }; - - // C++ wrapper for symbol_target - struct symbol_target : geometric_representation_item, ObjectHelper { symbol_target() : Object("symbol_target") {} - axis2_placement::Out placement; - positive_ratio_measure::Out x_scale; - positive_ratio_measure::Out y_scale; - }; - - // C++ wrapper for symmetric_shape_aspect - struct symmetric_shape_aspect : shape_aspect, ObjectHelper { symmetric_shape_aspect() : Object("symmetric_shape_aspect") {} - - }; - - // C++ wrapper for symmetry_tolerance - struct symmetry_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { symmetry_tolerance() : Object("symmetry_tolerance") {} - - }; - - // C++ wrapper for table_representation_item - struct table_representation_item : compound_representation_item, ObjectHelper { table_representation_item() : Object("table_representation_item") {} - - }; - - // C++ wrapper for tactile_appearance_representation - struct tactile_appearance_representation : representation, ObjectHelper { tactile_appearance_representation() : Object("tactile_appearance_representation") {} - - }; - - // C++ wrapper for tagged_text_format - struct tagged_text_format : representation_context, ObjectHelper { tagged_text_format() : Object("tagged_text_format") {} - - }; - - // C++ wrapper for tagged_text_item - struct tagged_text_item : descriptive_representation_item, ObjectHelper { tagged_text_item() : Object("tagged_text_item") {} - - }; - - // C++ wrapper for tangent - struct tangent : derived_shape_aspect, ObjectHelper { tangent() : Object("tangent") {} - - }; - - // C++ wrapper for text_literal_with_associated_curves - struct text_literal_with_associated_curves : text_literal, ObjectHelper { text_literal_with_associated_curves() : Object("text_literal_with_associated_curves") {} - ListOf< Lazy< curve >, 1, 0 > associated_curves; - }; - - // C++ wrapper for text_literal_with_blanking_box - struct text_literal_with_blanking_box : text_literal, ObjectHelper { text_literal_with_blanking_box() : Object("text_literal_with_blanking_box") {} - Lazy< planar_box > blanking; - }; - - // C++ wrapper for text_literal_with_extent - struct text_literal_with_extent : text_literal, ObjectHelper { text_literal_with_extent() : Object("text_literal_with_extent") {} - Lazy< planar_extent > extent; - }; - - // C++ wrapper for text_string_representation - struct text_string_representation : representation, ObjectHelper { text_string_representation() : Object("text_string_representation") {} - - }; - - // C++ wrapper for text_style - struct text_style : founded_item, ObjectHelper { text_style() : Object("text_style") {} - label::Out name; - character_style_select::Out character_appearance; - }; - - // C++ wrapper for text_style_with_box_characteristics - struct text_style_with_box_characteristics : text_style, ObjectHelper { text_style_with_box_characteristics() : Object("text_style_with_box_characteristics") {} - ListOf< box_characteristic_select, 1, 4 >::Out characteristics; - }; - - // C++ wrapper for text_style_with_mirror - struct text_style_with_mirror : text_style, ObjectHelper { text_style_with_mirror() : Object("text_style_with_mirror") {} - axis2_placement::Out mirror_placement; - }; - - // C++ wrapper for text_style_with_spacing - struct text_style_with_spacing : text_style, ObjectHelper { text_style_with_spacing() : Object("text_style_with_spacing") {} - character_spacing_select::Out character_spacing; - }; - - // C++ wrapper for thermal_resistance_measure_with_unit - struct thermal_resistance_measure_with_unit : measure_with_unit, ObjectHelper { thermal_resistance_measure_with_unit() : Object("thermal_resistance_measure_with_unit") {} - - }; - - // C++ wrapper for thermal_resistance_unit - struct thermal_resistance_unit : derived_unit, ObjectHelper { thermal_resistance_unit() : Object("thermal_resistance_unit") {} - - }; - - // C++ wrapper for thermodynamic_temperature_measure_with_unit - struct thermodynamic_temperature_measure_with_unit : measure_with_unit, ObjectHelper { thermodynamic_temperature_measure_with_unit() : Object("thermodynamic_temperature_measure_with_unit") {} - - }; - - // C++ wrapper for thermodynamic_temperature_unit - struct thermodynamic_temperature_unit : named_unit, ObjectHelper { thermodynamic_temperature_unit() : Object("thermodynamic_temperature_unit") {} - - }; - - // C++ wrapper for thickened_face_solid - struct thickened_face_solid : solid_model, ObjectHelper { thickened_face_solid() : Object("thickened_face_solid") {} - generalized_surface_select::Out base_element; - length_measure::Out offset1; - length_measure::Out offset2; - }; - - // C++ wrapper for thickness_laminate_definition - struct thickness_laminate_definition : product_definition, ObjectHelper { thickness_laminate_definition() : Object("thickness_laminate_definition") {} - - }; - - // C++ wrapper for thickness_laminate_table - struct thickness_laminate_table : zone_structural_makeup, ObjectHelper { thickness_laminate_table() : Object("thickness_laminate_table") {} - - }; - - // C++ wrapper for time_interval - struct time_interval : ObjectHelper { time_interval() : Object("time_interval") {} - identifier::Out id; - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for time_interval_based_effectivity - struct time_interval_based_effectivity : effectivity, ObjectHelper { time_interval_based_effectivity() : Object("time_interval_based_effectivity") {} - Lazy< time_interval > effectivity_period; - }; - - // C++ wrapper for time_interval_with_bounds - struct time_interval_with_bounds : time_interval, ObjectHelper { time_interval_with_bounds() : Object("time_interval_with_bounds") {} - Maybe< date_time_or_event_occurrence::Out > primary_bound; - Maybe< date_time_or_event_occurrence::Out > secondary_bound; - Maybe< Lazy< time_measure_with_unit > > duration; - }; - - // C++ wrapper for time_measure_with_unit - struct time_measure_with_unit : measure_with_unit, ObjectHelper { time_measure_with_unit() : Object("time_measure_with_unit") {} - - }; - - // C++ wrapper for time_unit - struct time_unit : named_unit, ObjectHelper { time_unit() : Object("time_unit") {} - - }; - - // C++ wrapper for tolerance_zone - struct tolerance_zone : shape_aspect, ObjectHelper { tolerance_zone() : Object("tolerance_zone") {} - ListOf< Lazy< geometric_tolerance >, 1, 0 > defining_tolerance; - Lazy< NotImplemented > form; - }; - - // C++ wrapper for torus - struct torus : geometric_representation_item, ObjectHelper { torus() : Object("torus") {} - Lazy< axis1_placement > position; - positive_length_measure::Out major_radius; - positive_length_measure::Out minor_radius; - }; - - // C++ wrapper for total_runout_tolerance - struct total_runout_tolerance : geometric_tolerance_with_datum_reference, ObjectHelper { total_runout_tolerance() : Object("total_runout_tolerance") {} - - }; - - // C++ wrapper for track_blended_solid - struct track_blended_solid : edge_blended_solid, ObjectHelper { track_blended_solid() : Object("track_blended_solid") {} - - }; - - // C++ wrapper for track_blended_solid_with_end_conditions - struct track_blended_solid_with_end_conditions : track_blended_solid, ObjectHelper { track_blended_solid_with_end_conditions() : Object("track_blended_solid_with_end_conditions") {} - ListOf< blend_end_condition_select, 2, 2 >::Out end_conditions; - }; - - // C++ wrapper for trimmed_curve - struct trimmed_curve : bounded_curve, ObjectHelper { trimmed_curve() : Object("trimmed_curve") {} - Lazy< curve > basis_curve; - ListOf< trimming_select, 1, 2 >::Out trim_1; - ListOf< trimming_select, 1, 2 >::Out trim_2; - BOOLEAN::Out sense_agreement; - trimming_preference::Out master_representation; - }; - - // C++ wrapper for two_direction_repeat_factor - struct two_direction_repeat_factor : one_direction_repeat_factor, ObjectHelper { two_direction_repeat_factor() : Object("two_direction_repeat_factor") {} - Lazy< vector > second_repeat_factor; - }; - - // C++ wrapper for unary_generic_expression - struct unary_generic_expression : generic_expression, ObjectHelper { unary_generic_expression() : Object("unary_generic_expression") {} - Lazy< generic_expression > operand; - }; - - // C++ wrapper for unary_numeric_expression - struct unary_numeric_expression : ObjectHelper { unary_numeric_expression() : Object("unary_numeric_expression") {} - - }; - - // C++ wrapper for uncertainty_assigned_representation - struct uncertainty_assigned_representation : representation, ObjectHelper { uncertainty_assigned_representation() : Object("uncertainty_assigned_representation") {} - ListOf< Lazy< uncertainty_measure_with_unit >, 1, 0 > uncertainty; - }; - - // C++ wrapper for uncertainty_measure_with_unit - struct uncertainty_measure_with_unit : measure_with_unit, ObjectHelper { uncertainty_measure_with_unit() : Object("uncertainty_measure_with_unit") {} - label::Out name; - Maybe< text::Out > description; - }; - - // C++ wrapper for uniform_curve - struct uniform_curve : b_spline_curve, ObjectHelper { uniform_curve() : Object("uniform_curve") {} - - }; - - // C++ wrapper for uniform_resource_identifier - struct uniform_resource_identifier : descriptive_representation_item, ObjectHelper { uniform_resource_identifier() : Object("uniform_resource_identifier") {} - - }; - - // C++ wrapper for uniform_surface - struct uniform_surface : b_spline_surface, ObjectHelper { uniform_surface() : Object("uniform_surface") {} - - }; - - // C++ wrapper for usage_association - struct usage_association : action_method_relationship, ObjectHelper { usage_association() : Object("usage_association") {} - - }; - - // C++ wrapper for user_defined_curve_font - struct user_defined_curve_font : ObjectHelper { user_defined_curve_font() : Object("user_defined_curve_font") {} - - }; - - // C++ wrapper for user_defined_marker - struct user_defined_marker : ObjectHelper { user_defined_marker() : Object("user_defined_marker") {} - - }; - - // C++ wrapper for user_defined_terminator_symbol - struct user_defined_terminator_symbol : ObjectHelper { user_defined_terminator_symbol() : Object("user_defined_terminator_symbol") {} - - }; - - // C++ wrapper for user_selected_shape_elements - struct user_selected_shape_elements : user_selected_elements, ObjectHelper { user_selected_shape_elements() : Object("user_selected_shape_elements") {} - - }; - - // C++ wrapper for value_range - struct value_range : compound_representation_item, ObjectHelper { value_range() : Object("value_range") {} - - }; - - // C++ wrapper for value_representation_item - struct value_representation_item : representation_item, ObjectHelper { value_representation_item() : Object("value_representation_item") {} - measure_value::Out value_component; - }; - - // C++ wrapper for variable_semantics - struct variable_semantics : ObjectHelper { variable_semantics() : Object("variable_semantics") {} - - }; - - // C++ wrapper for variational_representation_item - struct variational_representation_item : representation_item, ObjectHelper { variational_representation_item() : Object("variational_representation_item") {} - - }; - - // C++ wrapper for vector - struct vector : geometric_representation_item, ObjectHelper { vector() : Object("vector") {} - Lazy< direction > orientation; - length_measure::Out magnitude; - }; - - // C++ wrapper for vector_style - struct vector_style : ObjectHelper { vector_style() : Object("vector_style") {} - - }; - - // C++ wrapper for velocity_measure_with_unit - struct velocity_measure_with_unit : measure_with_unit, ObjectHelper { velocity_measure_with_unit() : Object("velocity_measure_with_unit") {} - - }; - - // C++ wrapper for velocity_unit - struct velocity_unit : derived_unit, ObjectHelper { velocity_unit() : Object("velocity_unit") {} - - }; - - // C++ wrapper for vertex - struct vertex : topological_representation_item, ObjectHelper { vertex() : Object("vertex") {} - - }; - - // C++ wrapper for vertex_loop - struct vertex_loop : loop, ObjectHelper { vertex_loop() : Object("vertex_loop") {} - Lazy< vertex > loop_vertex; - }; - - // C++ wrapper for vertex_point - struct vertex_point : ObjectHelper { vertex_point() : Object("vertex_point") {} - Lazy< point > vertex_geometry; - }; - - // C++ wrapper for vertex_shell - struct vertex_shell : topological_representation_item, ObjectHelper { vertex_shell() : Object("vertex_shell") {} - Lazy< vertex_loop > vertex_shell_extent; - }; - - // C++ wrapper for view_volume - struct view_volume : founded_item, ObjectHelper { view_volume() : Object("view_volume") {} - central_or_parallel::Out projection_type; - Lazy< cartesian_point > projection_point; - length_measure::Out view_plane_distance; - length_measure::Out front_plane_distance; - BOOLEAN::Out front_plane_clipping; - length_measure::Out back_plane_distance; - BOOLEAN::Out back_plane_clipping; - BOOLEAN::Out view_volume_sides_clipping; - Lazy< planar_box > view_window; - }; - - // C++ wrapper for visual_appearance_representation - struct visual_appearance_representation : representation, ObjectHelper { visual_appearance_representation() : Object("visual_appearance_representation") {} - - }; - - // C++ wrapper for volume_measure_with_unit - struct volume_measure_with_unit : measure_with_unit, ObjectHelper { volume_measure_with_unit() : Object("volume_measure_with_unit") {} - - }; - - // C++ wrapper for volume_unit - struct volume_unit : derived_unit, ObjectHelper { volume_unit() : Object("volume_unit") {} - - }; - - // C++ wrapper for week_of_year_and_day_date - struct week_of_year_and_day_date : date, ObjectHelper { week_of_year_and_day_date() : Object("week_of_year_and_day_date") {} - week_in_year_number::Out week_component; - Maybe< day_in_week_number::Out > day_component; - }; - - // C++ wrapper for wire_shell - struct wire_shell : topological_representation_item, ObjectHelper { wire_shell() : Object("wire_shell") {} - ListOf< Lazy< loop >, 1, 0 > wire_shell_extent; - }; - - // C++ wrapper for year_month - struct year_month : date, ObjectHelper { year_month() : Object("year_month") {} - month_in_year_number::Out month_component; - }; - - void GetSchema(EXPRESS::ConversionSchema& out); - -} //! StepFile -namespace STEP { - - // ****************************************************************************** - // Converter stubs - // ****************************************************************************** - -#define DECL_CONV_STUB(type) template <> size_t GenericFill(const STEP::DB& db, const EXPRESS::LIST& params, StepFile::type* in) - - DECL_CONV_STUB(measure_with_unit); - DECL_CONV_STUB(absorbed_dose_measure_with_unit); - DECL_CONV_STUB(derived_unit); - DECL_CONV_STUB(absorbed_dose_unit); - DECL_CONV_STUB(abstract_variable); - DECL_CONV_STUB(acceleration_measure_with_unit); - DECL_CONV_STUB(acceleration_unit); - DECL_CONV_STUB(action); - DECL_CONV_STUB(action_assignment); - DECL_CONV_STUB(action_method); - DECL_CONV_STUB(action_method_assignment); - DECL_CONV_STUB(action_method_relationship); - DECL_CONV_STUB(action_request_assignment); - DECL_CONV_STUB(address); - DECL_CONV_STUB(representation); - DECL_CONV_STUB(shape_representation); - DECL_CONV_STUB(advanced_brep_shape_representation); - DECL_CONV_STUB(face_surface); - DECL_CONV_STUB(advanced_face); - DECL_CONV_STUB(amount_of_substance_measure_with_unit); - DECL_CONV_STUB(named_unit); - DECL_CONV_STUB(amount_of_substance_unit); - DECL_CONV_STUB(angle_direction_reference); - DECL_CONV_STUB(representation_item); - DECL_CONV_STUB(geometric_representation_item); - DECL_CONV_STUB(draughting_callout); - DECL_CONV_STUB(dimension_curve_directed_callout); - DECL_CONV_STUB(angular_dimension); - DECL_CONV_STUB(shape_aspect_relationship); - DECL_CONV_STUB(dimensional_location); - DECL_CONV_STUB(angular_location); - DECL_CONV_STUB(dimensional_size); - DECL_CONV_STUB(angular_size); - DECL_CONV_STUB(geometric_tolerance); - DECL_CONV_STUB(geometric_tolerance_with_datum_reference); - DECL_CONV_STUB(angularity_tolerance); - DECL_CONV_STUB(styled_item); - DECL_CONV_STUB(annotation_occurrence); - DECL_CONV_STUB(annotation_curve_occurrence); - DECL_CONV_STUB(annotation_fill_area); - DECL_CONV_STUB(annotation_fill_area_occurrence); - DECL_CONV_STUB(annotation_occurrence_relationship); - DECL_CONV_STUB(annotation_occurrence_associativity); - DECL_CONV_STUB(annotation_plane); - DECL_CONV_STUB(annotation_symbol_occurrence); - DECL_CONV_STUB(annotation_subfigure_occurrence); - DECL_CONV_STUB(mapped_item); - DECL_CONV_STUB(annotation_symbol); - DECL_CONV_STUB(annotation_text); - DECL_CONV_STUB(annotation_text_character); - DECL_CONV_STUB(annotation_text_occurrence); - DECL_CONV_STUB(shape_aspect); - DECL_CONV_STUB(derived_shape_aspect); - DECL_CONV_STUB(apex); - DECL_CONV_STUB(application_context_element); - DECL_CONV_STUB(applied_action_assignment); - DECL_CONV_STUB(applied_action_method_assignment); - DECL_CONV_STUB(applied_action_request_assignment); - DECL_CONV_STUB(approval_assignment); - DECL_CONV_STUB(applied_approval_assignment); - DECL_CONV_STUB(attribute_classification_assignment); - DECL_CONV_STUB(applied_attribute_classification_assignment); - DECL_CONV_STUB(certification_assignment); - DECL_CONV_STUB(applied_certification_assignment); - DECL_CONV_STUB(classification_assignment); - DECL_CONV_STUB(applied_classification_assignment); - DECL_CONV_STUB(contract_assignment); - DECL_CONV_STUB(applied_contract_assignment); - DECL_CONV_STUB(date_and_time_assignment); - DECL_CONV_STUB(applied_date_and_time_assignment); - DECL_CONV_STUB(date_assignment); - DECL_CONV_STUB(applied_date_assignment); - DECL_CONV_STUB(document_reference); - DECL_CONV_STUB(applied_document_reference); - DECL_CONV_STUB(document_usage_constraint_assignment); - DECL_CONV_STUB(applied_document_usage_constraint_assignment); - DECL_CONV_STUB(effectivity_assignment); - DECL_CONV_STUB(applied_effectivity_assignment); - DECL_CONV_STUB(event_occurrence_assignment); - DECL_CONV_STUB(applied_event_occurrence_assignment); - DECL_CONV_STUB(identification_assignment); - DECL_CONV_STUB(external_identification_assignment); - DECL_CONV_STUB(applied_external_identification_assignment); - DECL_CONV_STUB(group_assignment); - DECL_CONV_STUB(applied_group_assignment); - DECL_CONV_STUB(applied_identification_assignment); - DECL_CONV_STUB(name_assignment); - DECL_CONV_STUB(applied_name_assignment); - DECL_CONV_STUB(organization_assignment); - DECL_CONV_STUB(applied_organization_assignment); - DECL_CONV_STUB(organizational_project_assignment); - DECL_CONV_STUB(applied_organizational_project_assignment); - DECL_CONV_STUB(person_and_organization_assignment); - DECL_CONV_STUB(applied_person_and_organization_assignment); - DECL_CONV_STUB(presented_item); - DECL_CONV_STUB(applied_presented_item); - DECL_CONV_STUB(security_classification_assignment); - DECL_CONV_STUB(applied_security_classification_assignment); - DECL_CONV_STUB(time_interval_assignment); - DECL_CONV_STUB(applied_time_interval_assignment); - DECL_CONV_STUB(applied_usage_right); - DECL_CONV_STUB(area_in_set); - DECL_CONV_STUB(area_measure_with_unit); - DECL_CONV_STUB(area_unit); - DECL_CONV_STUB(product_definition_relationship); - DECL_CONV_STUB(product_definition_usage); - DECL_CONV_STUB(assembly_component_usage); - DECL_CONV_STUB(assigned_requirement); - DECL_CONV_STUB(compound_representation_item); - DECL_CONV_STUB(atomic_formula); - DECL_CONV_STUB(attribute_assertion); - DECL_CONV_STUB(attribute_language_assignment); - DECL_CONV_STUB(attribute_value_assignment); - DECL_CONV_STUB(auxiliary_geometric_representation_item); - DECL_CONV_STUB(placement); - DECL_CONV_STUB(axis1_placement); - DECL_CONV_STUB(axis2_placement_2d); - DECL_CONV_STUB(axis2_placement_3d); - DECL_CONV_STUB(curve); - DECL_CONV_STUB(bounded_curve); - DECL_CONV_STUB(b_spline_curve); - DECL_CONV_STUB(b_spline_curve_with_knots); - DECL_CONV_STUB(surface); - DECL_CONV_STUB(bounded_surface); - DECL_CONV_STUB(b_spline_surface); - DECL_CONV_STUB(b_spline_surface_with_knots); - DECL_CONV_STUB(product_definition); - DECL_CONV_STUB(rule_software_definition); - DECL_CONV_STUB(rule_definition); - DECL_CONV_STUB(back_chaining_rule); - DECL_CONV_STUB(back_chaining_rule_body); - DECL_CONV_STUB(colour); - DECL_CONV_STUB(background_colour); - DECL_CONV_STUB(beveled_sheet_representation); - DECL_CONV_STUB(bezier_curve); - DECL_CONV_STUB(bezier_surface); - DECL_CONV_STUB(generic_expression); - DECL_CONV_STUB(binary_generic_expression); - DECL_CONV_STUB(binary_numeric_expression); - DECL_CONV_STUB(binary_representation_item); - DECL_CONV_STUB(block); - DECL_CONV_STUB(expression); - DECL_CONV_STUB(boolean_expression); - DECL_CONV_STUB(boolean_literal); - DECL_CONV_STUB(boolean_representation_item); - DECL_CONV_STUB(boolean_result); - DECL_CONV_STUB(composite_curve); - DECL_CONV_STUB(composite_curve_on_surface); - DECL_CONV_STUB(boundary_curve); - DECL_CONV_STUB(bounded_pcurve); - DECL_CONV_STUB(bounded_surface_curve); - DECL_CONV_STUB(founded_item); - DECL_CONV_STUB(box_domain); - DECL_CONV_STUB(half_space_solid); - DECL_CONV_STUB(boxed_half_space); - DECL_CONV_STUB(breakdown_context); - DECL_CONV_STUB(breakdown_element_group_assignment); - DECL_CONV_STUB(breakdown_element_realization); - DECL_CONV_STUB(breakdown_element_usage); - DECL_CONV_STUB(breakdown_of); - DECL_CONV_STUB(solid_model); - DECL_CONV_STUB(manifold_solid_brep); - DECL_CONV_STUB(brep_with_voids); - DECL_CONV_STUB(bytes_representation_item); - DECL_CONV_STUB(date); - DECL_CONV_STUB(calendar_date); - DECL_CONV_STUB(camera_image); - DECL_CONV_STUB(camera_image_3d_with_scale); - DECL_CONV_STUB(camera_model); - DECL_CONV_STUB(camera_model_d3); - DECL_CONV_STUB(camera_model_d3_multi_clipping); - DECL_CONV_STUB(camera_model_d3_multi_clipping_intersection); - DECL_CONV_STUB(camera_model_d3_multi_clipping_union); - DECL_CONV_STUB(camera_model_d3_with_hlhsr); - DECL_CONV_STUB(camera_model_with_light_sources); - DECL_CONV_STUB(representation_map); - DECL_CONV_STUB(camera_usage); - DECL_CONV_STUB(capacitance_measure_with_unit); - DECL_CONV_STUB(capacitance_unit); - DECL_CONV_STUB(point); - DECL_CONV_STUB(cartesian_point); - DECL_CONV_STUB(cartesian_transformation_operator); - DECL_CONV_STUB(cartesian_transformation_operator_2d); - DECL_CONV_STUB(cartesian_transformation_operator_3d); - DECL_CONV_STUB(cc_design_approval); - DECL_CONV_STUB(cc_design_certification); - DECL_CONV_STUB(cc_design_contract); - DECL_CONV_STUB(cc_design_date_and_time_assignment); - DECL_CONV_STUB(cc_design_person_and_organization_assignment); - DECL_CONV_STUB(cc_design_security_classification); - DECL_CONV_STUB(cc_design_specification_reference); - DECL_CONV_STUB(celsius_temperature_measure_with_unit); - DECL_CONV_STUB(centre_of_symmetry); - DECL_CONV_STUB(change); - DECL_CONV_STUB(change_request); - DECL_CONV_STUB(character_glyph_style_outline); - DECL_CONV_STUB(character_glyph_style_stroke); - DECL_CONV_STUB(symbol_representation); - DECL_CONV_STUB(generic_character_glyph_symbol); - DECL_CONV_STUB(character_glyph_symbol); - DECL_CONV_STUB(character_glyph_symbol_outline); - DECL_CONV_STUB(character_glyph_symbol_stroke); - DECL_CONV_STUB(general_property); - DECL_CONV_STUB(characteristic_data_column_header); - DECL_CONV_STUB(general_property_relationship); - DECL_CONV_STUB(characteristic_data_column_header_link); - DECL_CONV_STUB(characteristic_data_table_header); - DECL_CONV_STUB(characteristic_data_table_header_decomposition); - DECL_CONV_STUB(group); - DECL_CONV_STUB(characteristic_type); - DECL_CONV_STUB(characterized_class); - DECL_CONV_STUB(characterized_object); - DECL_CONV_STUB(conic); - DECL_CONV_STUB(circle); - DECL_CONV_STUB(circular_runout_tolerance); - DECL_CONV_STUB(class_by_extension); - DECL_CONV_STUB(class_by_intension); - DECL_CONV_STUB(class_system); - DECL_CONV_STUB(effectivity_context_assignment); - DECL_CONV_STUB(class_usage_effectivity_context_assignment); - DECL_CONV_STUB(topological_representation_item); - DECL_CONV_STUB(connected_face_set); - DECL_CONV_STUB(closed_shell); - DECL_CONV_STUB(coaxiality_tolerance); - DECL_CONV_STUB(colour_specification); - DECL_CONV_STUB(colour_rgb); - DECL_CONV_STUB(common_datum); - DECL_CONV_STUB(comparison_expression); - DECL_CONV_STUB(complex_clause); - DECL_CONV_STUB(complex_conjunctive_clause); - DECL_CONV_STUB(complex_disjunctive_clause); - DECL_CONV_STUB(modified_solid); - DECL_CONV_STUB(shelled_solid); - DECL_CONV_STUB(complex_shelled_solid); - DECL_CONV_STUB(composite_assembly_definition); - DECL_CONV_STUB(composite_assembly_sequence_definition); - DECL_CONV_STUB(laminate_table); - DECL_CONV_STUB(part_laminate_table); - DECL_CONV_STUB(composite_assembly_table); - DECL_CONV_STUB(composite_curve_segment); - DECL_CONV_STUB(material_designation); - DECL_CONV_STUB(composite_material_designation); - DECL_CONV_STUB(composite_shape_aspect); - DECL_CONV_STUB(composite_sheet_representation); - DECL_CONV_STUB(composite_text); - DECL_CONV_STUB(composite_text_with_associated_curves); - DECL_CONV_STUB(composite_text_with_blanking_box); - DECL_CONV_STUB(composite_text_with_delineation); - DECL_CONV_STUB(composite_text_with_extent); - DECL_CONV_STUB(compound_shape_representation); - DECL_CONV_STUB(concentricity_tolerance); - DECL_CONV_STUB(concept_feature_relationship); - DECL_CONV_STUB(concept_feature_relationship_with_condition); - DECL_CONV_STUB(product_concept_feature); - DECL_CONV_STUB(conditional_concept_feature); - DECL_CONV_STUB(conductance_measure_with_unit); - DECL_CONV_STUB(conductance_unit); - DECL_CONV_STUB(configuration_item); - DECL_CONV_STUB(configurable_item); - DECL_CONV_STUB(effectivity); - DECL_CONV_STUB(product_definition_effectivity); - DECL_CONV_STUB(configuration_effectivity); - DECL_CONV_STUB(configuration_item_relationship); - DECL_CONV_STUB(configuration_item_hierarchical_relationship); - DECL_CONV_STUB(configuration_item_revision_sequence); - DECL_CONV_STUB(configured_effectivity_assignment); - DECL_CONV_STUB(configured_effectivity_context_assignment); - DECL_CONV_STUB(conical_stepped_hole_transition); - DECL_CONV_STUB(elementary_surface); - DECL_CONV_STUB(conical_surface); - DECL_CONV_STUB(connected_edge_set); - DECL_CONV_STUB(connected_face_sub_set); - DECL_CONV_STUB(constructive_geometry_representation); - DECL_CONV_STUB(representation_relationship); - DECL_CONV_STUB(constructive_geometry_representation_relationship); - DECL_CONV_STUB(contact_ratio_representation); - DECL_CONV_STUB(invisibility); - DECL_CONV_STUB(context_dependent_invisibility); - DECL_CONV_STUB(over_riding_styled_item); - DECL_CONV_STUB(context_dependent_over_riding_styled_item); - DECL_CONV_STUB(context_dependent_unit); - DECL_CONV_STUB(conversion_based_unit); - DECL_CONV_STUB(csg_shape_representation); - DECL_CONV_STUB(csg_solid); - DECL_CONV_STUB(currency); - DECL_CONV_STUB(currency_measure_with_unit); - DECL_CONV_STUB(curve_bounded_surface); - DECL_CONV_STUB(curve_dimension); - DECL_CONV_STUB(curve_replica); - DECL_CONV_STUB(curve_style); - DECL_CONV_STUB(curve_style_font); - DECL_CONV_STUB(curve_style_font_and_scaling); - DECL_CONV_STUB(curve_style_font_pattern); - DECL_CONV_STUB(curve_swept_solid_shape_representation); - DECL_CONV_STUB(cylindrical_surface); - DECL_CONV_STUB(cylindricity_tolerance); - DECL_CONV_STUB(date_representation_item); - DECL_CONV_STUB(date_time_representation_item); - DECL_CONV_STUB(dated_effectivity); - DECL_CONV_STUB(datum); - DECL_CONV_STUB(datum_feature); - DECL_CONV_STUB(datum_feature_callout); - DECL_CONV_STUB(datum_reference); - DECL_CONV_STUB(datum_target); - DECL_CONV_STUB(datum_target_callout); - DECL_CONV_STUB(default_tolerance_table); - DECL_CONV_STUB(default_tolerance_table_cell); - DECL_CONV_STUB(defined_symbol); - DECL_CONV_STUB(definitional_representation); - DECL_CONV_STUB(definitional_representation_relationship); - DECL_CONV_STUB(definitional_representation_relationship_with_same_context); - DECL_CONV_STUB(degenerate_pcurve); - DECL_CONV_STUB(toroidal_surface); - DECL_CONV_STUB(degenerate_toroidal_surface); - DECL_CONV_STUB(descriptive_representation_item); - DECL_CONV_STUB(product_definition_context); - DECL_CONV_STUB(design_context); - DECL_CONV_STUB(design_make_from_relationship); - DECL_CONV_STUB(diameter_dimension); - DECL_CONV_STUB(ratio_measure_with_unit); - DECL_CONV_STUB(dielectric_constant_measure_with_unit); - DECL_CONV_STUB(dimension_callout); - DECL_CONV_STUB(draughting_callout_relationship); - DECL_CONV_STUB(dimension_callout_component_relationship); - DECL_CONV_STUB(dimension_callout_relationship); - DECL_CONV_STUB(dimension_curve); - DECL_CONV_STUB(terminator_symbol); - DECL_CONV_STUB(dimension_curve_terminator); - DECL_CONV_STUB(dimension_curve_terminator_to_projection_curve_associativity); - DECL_CONV_STUB(dimension_pair); - DECL_CONV_STUB(dimension_text_associativity); - DECL_CONV_STUB(dimensional_location_with_path); - DECL_CONV_STUB(dimensional_size_with_path); - DECL_CONV_STUB(executed_action); - DECL_CONV_STUB(directed_action); - DECL_CONV_STUB(directed_dimensional_location); - DECL_CONV_STUB(direction); - DECL_CONV_STUB(document_file); - DECL_CONV_STUB(document_identifier); - DECL_CONV_STUB(document_identifier_assignment); - DECL_CONV_STUB(document_product_association); - DECL_CONV_STUB(document_product_equivalence); - DECL_CONV_STUB(dose_equivalent_measure_with_unit); - DECL_CONV_STUB(dose_equivalent_unit); - DECL_CONV_STUB(double_offset_shelled_solid); - DECL_CONV_STUB(item_defined_transformation); - DECL_CONV_STUB(transformation_with_derived_angle); - DECL_CONV_STUB(draped_defined_transformation); - DECL_CONV_STUB(draughting_annotation_occurrence); - DECL_CONV_STUB(draughting_elements); - DECL_CONV_STUB(draughting_model); - DECL_CONV_STUB(item_identified_representation_usage); - DECL_CONV_STUB(draughting_model_item_association); - DECL_CONV_STUB(pre_defined_colour); - DECL_CONV_STUB(draughting_pre_defined_colour); - DECL_CONV_STUB(pre_defined_item); - DECL_CONV_STUB(pre_defined_curve_font); - DECL_CONV_STUB(draughting_pre_defined_curve_font); - DECL_CONV_STUB(pre_defined_text_font); - DECL_CONV_STUB(draughting_pre_defined_text_font); - DECL_CONV_STUB(draughting_subfigure_representation); - DECL_CONV_STUB(draughting_symbol_representation); - DECL_CONV_STUB(text_literal); - DECL_CONV_STUB(text_literal_with_delineation); - DECL_CONV_STUB(draughting_text_literal_with_delineation); - DECL_CONV_STUB(presentation_set); - DECL_CONV_STUB(drawing_revision); - DECL_CONV_STUB(presentation_representation); - DECL_CONV_STUB(presentation_area); - DECL_CONV_STUB(drawing_sheet_revision); - DECL_CONV_STUB(drawing_sheet_revision_sequence); - DECL_CONV_STUB(drawing_sheet_revision_usage); - DECL_CONV_STUB(edge); - DECL_CONV_STUB(edge_based_wireframe_model); - DECL_CONV_STUB(edge_based_wireframe_shape_representation); - DECL_CONV_STUB(edge_blended_solid); - DECL_CONV_STUB(edge_curve); - DECL_CONV_STUB(edge_loop); - DECL_CONV_STUB(electric_charge_measure_with_unit); - DECL_CONV_STUB(electric_charge_unit); - DECL_CONV_STUB(electric_current_measure_with_unit); - DECL_CONV_STUB(electric_current_unit); - DECL_CONV_STUB(electric_potential_measure_with_unit); - DECL_CONV_STUB(electric_potential_unit); - DECL_CONV_STUB(elementary_brep_shape_representation); - DECL_CONV_STUB(ellipse); - DECL_CONV_STUB(energy_measure_with_unit); - DECL_CONV_STUB(energy_unit); - DECL_CONV_STUB(property_definition); - DECL_CONV_STUB(fact_type); - DECL_CONV_STUB(entity_assertion); - DECL_CONV_STUB(enum_reference_prefix); - DECL_CONV_STUB(evaluated_characteristic); - DECL_CONV_STUB(evaluated_degenerate_pcurve); - DECL_CONV_STUB(evaluation_product_definition); - DECL_CONV_STUB(event_occurrence); - DECL_CONV_STUB(product_concept_feature_category); - DECL_CONV_STUB(exclusive_product_concept_feature_category); - DECL_CONV_STUB(uncertainty_qualifier); - DECL_CONV_STUB(standard_uncertainty); - DECL_CONV_STUB(expanded_uncertainty); - DECL_CONV_STUB(representation_item_relationship); - DECL_CONV_STUB(explicit_procedural_representation_item_relationship); - DECL_CONV_STUB(explicit_procedural_geometric_representation_item_relationship); - DECL_CONV_STUB(explicit_procedural_representation_relationship); - DECL_CONV_STUB(explicit_procedural_shape_representation_relationship); - DECL_CONV_STUB(expression_conversion_based_unit); - DECL_CONV_STUB(extension); - DECL_CONV_STUB(extent); - DECL_CONV_STUB(external_source); - DECL_CONV_STUB(external_class_library); - DECL_CONV_STUB(externally_defined_class); - DECL_CONV_STUB(externally_defined_colour); - DECL_CONV_STUB(externally_defined_context_dependent_unit); - DECL_CONV_STUB(externally_defined_conversion_based_unit); - DECL_CONV_STUB(externally_defined_currency); - DECL_CONV_STUB(externally_defined_item); - DECL_CONV_STUB(externally_defined_curve_font); - DECL_CONV_STUB(externally_defined_dimension_definition); - DECL_CONV_STUB(externally_defined_general_property); - DECL_CONV_STUB(externally_defined_hatch_style); - DECL_CONV_STUB(externally_defined_marker); - DECL_CONV_STUB(picture_representation_item); - DECL_CONV_STUB(externally_defined_picture_representation_item); - DECL_CONV_STUB(externally_defined_representation_item); - DECL_CONV_STUB(externally_defined_string); - DECL_CONV_STUB(externally_defined_symbol); - DECL_CONV_STUB(externally_defined_terminator_symbol); - DECL_CONV_STUB(externally_defined_text_font); - DECL_CONV_STUB(externally_defined_tile); - DECL_CONV_STUB(externally_defined_tile_style); - DECL_CONV_STUB(swept_area_solid); - DECL_CONV_STUB(extruded_area_solid); - DECL_CONV_STUB(swept_face_solid); - DECL_CONV_STUB(extruded_face_solid); - DECL_CONV_STUB(extruded_face_solid_with_trim_conditions); - DECL_CONV_STUB(extruded_face_solid_with_draft_angle); - DECL_CONV_STUB(extruded_face_solid_with_multiple_draft_angles); - DECL_CONV_STUB(face); - DECL_CONV_STUB(face_based_surface_model); - DECL_CONV_STUB(face_bound); - DECL_CONV_STUB(face_outer_bound); - DECL_CONV_STUB(faceted_brep); - DECL_CONV_STUB(faceted_brep_shape_representation); - DECL_CONV_STUB(fill_area_style); - DECL_CONV_STUB(fill_area_style_hatching); - DECL_CONV_STUB(fill_area_style_tile_coloured_region); - DECL_CONV_STUB(fill_area_style_tile_curve_with_style); - DECL_CONV_STUB(fill_area_style_tile_symbol_with_style); - DECL_CONV_STUB(fill_area_style_tiles); - DECL_CONV_STUB(shape_representation_relationship); - DECL_CONV_STUB(flat_pattern_ply_representation_relationship); - DECL_CONV_STUB(flatness_tolerance); - DECL_CONV_STUB(force_measure_with_unit); - DECL_CONV_STUB(force_unit); - DECL_CONV_STUB(forward_chaining_rule); - DECL_CONV_STUB(forward_chaining_rule_premise); - DECL_CONV_STUB(frequency_measure_with_unit); - DECL_CONV_STUB(frequency_unit); - DECL_CONV_STUB(func); - DECL_CONV_STUB(functional_breakdown_context); - DECL_CONV_STUB(functional_element_usage); - DECL_CONV_STUB(general_material_property); - DECL_CONV_STUB(simple_generic_expression); - DECL_CONV_STUB(generic_literal); - DECL_CONV_STUB(generic_variable); - DECL_CONV_STUB(geometric_alignment); - DECL_CONV_STUB(geometric_set); - DECL_CONV_STUB(geometric_curve_set); - DECL_CONV_STUB(geometric_intersection); - DECL_CONV_STUB(geometric_item_specific_usage); - DECL_CONV_STUB(geometric_model_element_relationship); - DECL_CONV_STUB(representation_context); - DECL_CONV_STUB(geometric_representation_context); - DECL_CONV_STUB(geometric_tolerance_with_defined_unit); - DECL_CONV_STUB(geometrical_tolerance_callout); - DECL_CONV_STUB(geometrically_bounded_2d_wireframe_representation); - DECL_CONV_STUB(geometrically_bounded_surface_shape_representation); - DECL_CONV_STUB(geometrically_bounded_wireframe_shape_representation); - DECL_CONV_STUB(global_assignment); - DECL_CONV_STUB(global_uncertainty_assigned_context); - DECL_CONV_STUB(global_unit_assigned_context); - DECL_CONV_STUB(ground_fact); - DECL_CONV_STUB(hardness_representation); - DECL_CONV_STUB(hidden_element_over_riding_styled_item); - DECL_CONV_STUB(hyperbola); - DECL_CONV_STUB(illuminance_measure_with_unit); - DECL_CONV_STUB(illuminance_unit); - DECL_CONV_STUB(included_text_block); - DECL_CONV_STUB(inclusion_product_concept_feature); - DECL_CONV_STUB(user_selected_elements); - DECL_CONV_STUB(indirectly_selected_elements); - DECL_CONV_STUB(indirectly_selected_shape_elements); - DECL_CONV_STUB(inductance_measure_with_unit); - DECL_CONV_STUB(inductance_unit); - DECL_CONV_STUB(information_right); - DECL_CONV_STUB(information_usage_right); - DECL_CONV_STUB(instance_usage_context_assignment); - DECL_CONV_STUB(instanced_feature); - DECL_CONV_STUB(literal_number); - DECL_CONV_STUB(int_literal); - DECL_CONV_STUB(integer_representation_item); - DECL_CONV_STUB(surface_curve); - DECL_CONV_STUB(intersection_curve); - DECL_CONV_STUB(interval_expression); - DECL_CONV_STUB(iso4217_currency); - DECL_CONV_STUB(known_source); - DECL_CONV_STUB(laid_defined_transformation); - DECL_CONV_STUB(language); - DECL_CONV_STUB(leader_curve); - DECL_CONV_STUB(leader_directed_callout); - DECL_CONV_STUB(leader_directed_dimension); - DECL_CONV_STUB(leader_terminator); - DECL_CONV_STUB(length_measure_with_unit); - DECL_CONV_STUB(length_unit); - DECL_CONV_STUB(light_source); - DECL_CONV_STUB(light_source_ambient); - DECL_CONV_STUB(light_source_directional); - DECL_CONV_STUB(light_source_positional); - DECL_CONV_STUB(light_source_spot); - DECL_CONV_STUB(line); - DECL_CONV_STUB(line_profile_tolerance); - DECL_CONV_STUB(linear_dimension); - DECL_CONV_STUB(simple_clause); - DECL_CONV_STUB(literal_conjunction); - DECL_CONV_STUB(literal_disjunction); - DECL_CONV_STUB(logical_literal); - DECL_CONV_STUB(logical_representation_item); - DECL_CONV_STUB(loop); - DECL_CONV_STUB(loss_tangent_measure_with_unit); - DECL_CONV_STUB(lot_effectivity); - DECL_CONV_STUB(luminous_flux_measure_with_unit); - DECL_CONV_STUB(luminous_flux_unit); - DECL_CONV_STUB(luminous_intensity_measure_with_unit); - DECL_CONV_STUB(luminous_intensity_unit); - DECL_CONV_STUB(magnetic_flux_density_measure_with_unit); - DECL_CONV_STUB(magnetic_flux_density_unit); - DECL_CONV_STUB(magnetic_flux_measure_with_unit); - DECL_CONV_STUB(magnetic_flux_unit); - DECL_CONV_STUB(make_from_usage_option); - DECL_CONV_STUB(manifold_subsurface_shape_representation); - DECL_CONV_STUB(manifold_surface_shape_representation); - DECL_CONV_STUB(mass_measure_with_unit); - DECL_CONV_STUB(mass_unit); - DECL_CONV_STUB(material_property); - DECL_CONV_STUB(property_definition_representation); - DECL_CONV_STUB(material_property_representation); - DECL_CONV_STUB(measure_representation_item); - DECL_CONV_STUB(product_context); - DECL_CONV_STUB(mechanical_context); - DECL_CONV_STUB(mechanical_design_and_draughting_relationship); - DECL_CONV_STUB(mechanical_design_geometric_presentation_area); - DECL_CONV_STUB(mechanical_design_geometric_presentation_representation); - DECL_CONV_STUB(mechanical_design_presentation_representation_with_draughting); - DECL_CONV_STUB(mechanical_design_shaded_presentation_area); - DECL_CONV_STUB(mechanical_design_shaded_presentation_representation); - DECL_CONV_STUB(min_and_major_ply_orientation_basis); - DECL_CONV_STUB(modified_geometric_tolerance); - DECL_CONV_STUB(modified_solid_with_placed_configuration); - DECL_CONV_STUB(moments_of_inertia_representation); - DECL_CONV_STUB(multi_language_attribute_assignment); - DECL_CONV_STUB(multiple_arity_boolean_expression); - DECL_CONV_STUB(multiple_arity_generic_expression); - DECL_CONV_STUB(multiple_arity_numeric_expression); - DECL_CONV_STUB(next_assembly_usage_occurrence); - DECL_CONV_STUB(non_manifold_surface_shape_representation); - DECL_CONV_STUB(null_representation_item); - DECL_CONV_STUB(numeric_expression); - DECL_CONV_STUB(offset_curve_2d); - DECL_CONV_STUB(offset_curve_3d); - DECL_CONV_STUB(offset_surface); - DECL_CONV_STUB(one_direction_repeat_factor); - DECL_CONV_STUB(open_shell); - DECL_CONV_STUB(ordinal_date); - DECL_CONV_STUB(projection_directed_callout); - DECL_CONV_STUB(ordinate_dimension); - DECL_CONV_STUB(organizational_address); - DECL_CONV_STUB(oriented_closed_shell); - DECL_CONV_STUB(oriented_edge); - DECL_CONV_STUB(oriented_face); - DECL_CONV_STUB(oriented_open_shell); - DECL_CONV_STUB(path); - DECL_CONV_STUB(oriented_path); - DECL_CONV_STUB(oriented_surface); - DECL_CONV_STUB(outer_boundary_curve); - DECL_CONV_STUB(package_product_concept_feature); - DECL_CONV_STUB(parabola); - DECL_CONV_STUB(parallel_offset); - DECL_CONV_STUB(parallelism_tolerance); - DECL_CONV_STUB(parametric_representation_context); - DECL_CONV_STUB(partial_document_with_structured_text_representation_assignment); - DECL_CONV_STUB(pcurve); - DECL_CONV_STUB(percentage_laminate_definition); - DECL_CONV_STUB(zone_structural_makeup); - DECL_CONV_STUB(percentage_laminate_table); - DECL_CONV_STUB(percentage_ply_definition); - DECL_CONV_STUB(perpendicular_to); - DECL_CONV_STUB(perpendicularity_tolerance); - DECL_CONV_STUB(person_and_organization_address); - DECL_CONV_STUB(personal_address); - DECL_CONV_STUB(physical_breakdown_context); - DECL_CONV_STUB(physical_element_usage); - DECL_CONV_STUB(presentation_view); - DECL_CONV_STUB(picture_representation); - DECL_CONV_STUB(placed_datum_target_feature); - DECL_CONV_STUB(placed_feature); - DECL_CONV_STUB(planar_extent); - DECL_CONV_STUB(planar_box); - DECL_CONV_STUB(plane); - DECL_CONV_STUB(plane_angle_measure_with_unit); - DECL_CONV_STUB(plane_angle_unit); - DECL_CONV_STUB(ply_laminate_definition); - DECL_CONV_STUB(ply_laminate_sequence_definition); - DECL_CONV_STUB(ply_laminate_table); - DECL_CONV_STUB(point_and_vector); - DECL_CONV_STUB(point_on_curve); - DECL_CONV_STUB(point_on_surface); - DECL_CONV_STUB(point_path); - DECL_CONV_STUB(point_replica); - DECL_CONV_STUB(point_style); - DECL_CONV_STUB(polar_complex_number_literal); - DECL_CONV_STUB(poly_loop); - DECL_CONV_STUB(polyline); - DECL_CONV_STUB(position_tolerance); - DECL_CONV_STUB(positioned_sketch); - DECL_CONV_STUB(power_measure_with_unit); - DECL_CONV_STUB(power_unit); - DECL_CONV_STUB(pre_defined_symbol); - DECL_CONV_STUB(pre_defined_dimension_symbol); - DECL_CONV_STUB(pre_defined_geometrical_tolerance_symbol); - DECL_CONV_STUB(pre_defined_marker); - DECL_CONV_STUB(pre_defined_point_marker_symbol); - DECL_CONV_STUB(pre_defined_surface_condition_symbol); - DECL_CONV_STUB(pre_defined_surface_side_style); - DECL_CONV_STUB(pre_defined_terminator_symbol); - DECL_CONV_STUB(pre_defined_tile); - DECL_CONV_STUB(predefined_picture_representation_item); - DECL_CONV_STUB(presentation_style_assignment); - DECL_CONV_STUB(presentation_style_by_context); - DECL_CONV_STUB(pressure_measure_with_unit); - DECL_CONV_STUB(pressure_unit); - DECL_CONV_STUB(procedural_representation); - DECL_CONV_STUB(procedural_representation_sequence); - DECL_CONV_STUB(procedural_shape_representation); - DECL_CONV_STUB(procedural_shape_representation_sequence); - DECL_CONV_STUB(product_category); - DECL_CONV_STUB(product_class); - DECL_CONV_STUB(product_concept_context); - DECL_CONV_STUB(product_concept_feature_category_usage); - DECL_CONV_STUB(product_definition_element_relationship); - DECL_CONV_STUB(product_definition_formation); - DECL_CONV_STUB(product_definition_formation_with_specified_source); - DECL_CONV_STUB(product_definition_group_assignment); - DECL_CONV_STUB(product_definition_shape); - DECL_CONV_STUB(product_definition_with_associated_documents); - DECL_CONV_STUB(product_identification); - DECL_CONV_STUB(product_material_composition_relationship); - DECL_CONV_STUB(product_related_product_category); - DECL_CONV_STUB(product_specification); - DECL_CONV_STUB(tolerance_zone_definition); - DECL_CONV_STUB(projected_zone_definition); - DECL_CONV_STUB(projection_curve); - DECL_CONV_STUB(promissory_usage_occurrence); - DECL_CONV_STUB(qualified_representation_item); - DECL_CONV_STUB(qualitative_uncertainty); - DECL_CONV_STUB(quantified_assembly_component_usage); - DECL_CONV_STUB(quasi_uniform_curve); - DECL_CONV_STUB(quasi_uniform_surface); - DECL_CONV_STUB(radioactivity_measure_with_unit); - DECL_CONV_STUB(radioactivity_unit); - DECL_CONV_STUB(radius_dimension); - DECL_CONV_STUB(range_characteristic); - DECL_CONV_STUB(ratio_unit); - DECL_CONV_STUB(rational_b_spline_curve); - DECL_CONV_STUB(rational_b_spline_surface); - DECL_CONV_STUB(rational_representation_item); - DECL_CONV_STUB(real_literal); - DECL_CONV_STUB(real_representation_item); - DECL_CONV_STUB(rectangular_composite_surface); - DECL_CONV_STUB(rectangular_trimmed_surface); - DECL_CONV_STUB(referenced_modified_datum); - DECL_CONV_STUB(relative_event_occurrence); - DECL_CONV_STUB(rep_item_group); - DECL_CONV_STUB(reparametrised_composite_curve_segment); - DECL_CONV_STUB(representation_relationship_with_transformation); - DECL_CONV_STUB(requirement_assigned_object); - DECL_CONV_STUB(requirement_assignment); - DECL_CONV_STUB(requirement_source); - DECL_CONV_STUB(requirement_view_definition_relationship); - DECL_CONV_STUB(resistance_measure_with_unit); - DECL_CONV_STUB(resistance_unit); - DECL_CONV_STUB(revolved_area_solid); - DECL_CONV_STUB(revolved_face_solid); - DECL_CONV_STUB(revolved_face_solid_with_trim_conditions); - DECL_CONV_STUB(right_angular_wedge); - DECL_CONV_STUB(right_circular_cone); - DECL_CONV_STUB(right_circular_cylinder); - DECL_CONV_STUB(right_to_usage_association); - DECL_CONV_STUB(roundness_tolerance); - DECL_CONV_STUB(row_representation_item); - DECL_CONV_STUB(row_value); - DECL_CONV_STUB(row_variable); - DECL_CONV_STUB(rule_action); - DECL_CONV_STUB(rule_condition); - DECL_CONV_STUB(rule_set); - DECL_CONV_STUB(rule_set_group); - DECL_CONV_STUB(rule_superseded_assignment); - DECL_CONV_STUB(rule_supersedence); - DECL_CONV_STUB(surface_curve_swept_area_solid); - DECL_CONV_STUB(ruled_surface_swept_area_solid); - DECL_CONV_STUB(runout_zone_definition); - DECL_CONV_STUB(runout_zone_orientation); - DECL_CONV_STUB(runout_zone_orientation_reference_direction); - DECL_CONV_STUB(satisfied_requirement); - DECL_CONV_STUB(satisfies_requirement); - DECL_CONV_STUB(satisfying_item); - DECL_CONV_STUB(scalar_variable); - DECL_CONV_STUB(scattering_parameter); - DECL_CONV_STUB(sculptured_solid); - DECL_CONV_STUB(seam_curve); - DECL_CONV_STUB(serial_numbered_effectivity); - DECL_CONV_STUB(shape_aspect_associativity); - DECL_CONV_STUB(shape_aspect_deriving_relationship); - DECL_CONV_STUB(shape_definition_representation); - DECL_CONV_STUB(shape_dimension_representation); - DECL_CONV_STUB(shape_feature_definition); - DECL_CONV_STUB(shape_representation_with_parameters); - DECL_CONV_STUB(shell_based_surface_model); - DECL_CONV_STUB(shell_based_wireframe_model); - DECL_CONV_STUB(shell_based_wireframe_shape_representation); - DECL_CONV_STUB(si_absorbed_dose_unit); - DECL_CONV_STUB(si_capacitance_unit); - DECL_CONV_STUB(si_conductance_unit); - DECL_CONV_STUB(si_dose_equivalent_unit); - DECL_CONV_STUB(si_electric_charge_unit); - DECL_CONV_STUB(si_electric_potential_unit); - DECL_CONV_STUB(si_energy_unit); - DECL_CONV_STUB(si_force_unit); - DECL_CONV_STUB(si_frequency_unit); - DECL_CONV_STUB(si_illuminance_unit); - DECL_CONV_STUB(si_inductance_unit); - DECL_CONV_STUB(si_magnetic_flux_density_unit); - DECL_CONV_STUB(si_magnetic_flux_unit); - DECL_CONV_STUB(si_power_unit); - DECL_CONV_STUB(si_pressure_unit); - DECL_CONV_STUB(si_radioactivity_unit); - DECL_CONV_STUB(si_resistance_unit); - DECL_CONV_STUB(si_unit); - DECL_CONV_STUB(simple_boolean_expression); - DECL_CONV_STUB(simple_numeric_expression); - DECL_CONV_STUB(slash_expression); - DECL_CONV_STUB(smeared_material_definition); - DECL_CONV_STUB(solid_angle_measure_with_unit); - DECL_CONV_STUB(solid_angle_unit); - DECL_CONV_STUB(solid_curve_font); - DECL_CONV_STUB(solid_replica); - DECL_CONV_STUB(solid_with_chamfered_edges); - DECL_CONV_STUB(solid_with_angle_based_chamfer); - DECL_CONV_STUB(solid_with_shape_element_pattern); - DECL_CONV_STUB(solid_with_circular_pattern); - DECL_CONV_STUB(solid_with_depression); - DECL_CONV_STUB(solid_with_pocket); - DECL_CONV_STUB(solid_with_circular_pocket); - DECL_CONV_STUB(solid_with_protrusion); - DECL_CONV_STUB(solid_with_circular_protrusion); - DECL_CONV_STUB(solid_with_hole); - DECL_CONV_STUB(solid_with_stepped_round_hole); - DECL_CONV_STUB(solid_with_conical_bottom_round_hole); - DECL_CONV_STUB(solid_with_constant_radius_edge_blend); - DECL_CONV_STUB(solid_with_slot); - DECL_CONV_STUB(solid_with_curved_slot); - DECL_CONV_STUB(solid_with_double_offset_chamfer); - DECL_CONV_STUB(solid_with_flat_bottom_round_hole); - DECL_CONV_STUB(solid_with_general_pocket); - DECL_CONV_STUB(solid_with_general_protrusion); - DECL_CONV_STUB(solid_with_groove); - DECL_CONV_STUB(solid_with_incomplete_circular_pattern); - DECL_CONV_STUB(solid_with_rectangular_pattern); - DECL_CONV_STUB(solid_with_incomplete_rectangular_pattern); - DECL_CONV_STUB(solid_with_rectangular_pocket); - DECL_CONV_STUB(solid_with_rectangular_protrusion); - DECL_CONV_STUB(solid_with_single_offset_chamfer); - DECL_CONV_STUB(solid_with_spherical_bottom_round_hole); - DECL_CONV_STUB(solid_with_stepped_round_hole_and_conical_transitions); - DECL_CONV_STUB(solid_with_straight_slot); - DECL_CONV_STUB(solid_with_tee_section_slot); - DECL_CONV_STUB(solid_with_through_depression); - DECL_CONV_STUB(solid_with_trapezoidal_section_slot); - DECL_CONV_STUB(solid_with_variable_radius_edge_blend); - DECL_CONV_STUB(source_for_requirement); - DECL_CONV_STUB(sourced_requirement); - DECL_CONV_STUB(specification_definition); - DECL_CONV_STUB(specified_higher_usage_occurrence); - DECL_CONV_STUB(sphere); - DECL_CONV_STUB(spherical_surface); - DECL_CONV_STUB(start_request); - DECL_CONV_STUB(start_work); - DECL_CONV_STUB(straightness_tolerance); - DECL_CONV_STUB(structured_dimension_callout); - DECL_CONV_STUB(structured_text_composition); - DECL_CONV_STUB(structured_text_representation); - DECL_CONV_STUB(subedge); - DECL_CONV_STUB(subface); - DECL_CONV_STUB(supplied_part_relationship); - DECL_CONV_STUB(surface_condition_callout); - DECL_CONV_STUB(swept_surface); - DECL_CONV_STUB(surface_of_linear_extrusion); - DECL_CONV_STUB(surface_of_revolution); - DECL_CONV_STUB(surface_patch); - DECL_CONV_STUB(surface_profile_tolerance); - DECL_CONV_STUB(surface_replica); - DECL_CONV_STUB(surface_side_style); - DECL_CONV_STUB(surface_style_boundary); - DECL_CONV_STUB(surface_style_control_grid); - DECL_CONV_STUB(surface_style_fill_area); - DECL_CONV_STUB(surface_style_parameter_line); - DECL_CONV_STUB(surface_style_reflectance_ambient); - DECL_CONV_STUB(surface_style_reflectance_ambient_diffuse); - DECL_CONV_STUB(surface_style_reflectance_ambient_diffuse_specular); - DECL_CONV_STUB(surface_style_rendering); - DECL_CONV_STUB(surface_style_rendering_with_properties); - DECL_CONV_STUB(surface_style_segmentation_curve); - DECL_CONV_STUB(surface_style_silhouette); - DECL_CONV_STUB(surface_style_usage); - DECL_CONV_STUB(surface_texture_representation); - DECL_CONV_STUB(surfaced_open_shell); - DECL_CONV_STUB(swept_disk_solid); - DECL_CONV_STUB(symbol); - DECL_CONV_STUB(symbol_representation_map); - DECL_CONV_STUB(symbol_style); - DECL_CONV_STUB(symbol_target); - DECL_CONV_STUB(symmetric_shape_aspect); - DECL_CONV_STUB(symmetry_tolerance); - DECL_CONV_STUB(table_representation_item); - DECL_CONV_STUB(tactile_appearance_representation); - DECL_CONV_STUB(tagged_text_format); - DECL_CONV_STUB(tagged_text_item); - DECL_CONV_STUB(tangent); - DECL_CONV_STUB(text_literal_with_associated_curves); - DECL_CONV_STUB(text_literal_with_blanking_box); - DECL_CONV_STUB(text_literal_with_extent); - DECL_CONV_STUB(text_string_representation); - DECL_CONV_STUB(text_style); - DECL_CONV_STUB(text_style_with_box_characteristics); - DECL_CONV_STUB(text_style_with_mirror); - DECL_CONV_STUB(text_style_with_spacing); - DECL_CONV_STUB(thermal_resistance_measure_with_unit); - DECL_CONV_STUB(thermal_resistance_unit); - DECL_CONV_STUB(thermodynamic_temperature_measure_with_unit); - DECL_CONV_STUB(thermodynamic_temperature_unit); - DECL_CONV_STUB(thickened_face_solid); - DECL_CONV_STUB(thickness_laminate_definition); - DECL_CONV_STUB(thickness_laminate_table); - DECL_CONV_STUB(time_interval); - DECL_CONV_STUB(time_interval_based_effectivity); - DECL_CONV_STUB(time_interval_with_bounds); - DECL_CONV_STUB(time_measure_with_unit); - DECL_CONV_STUB(time_unit); - DECL_CONV_STUB(tolerance_zone); - DECL_CONV_STUB(torus); - DECL_CONV_STUB(total_runout_tolerance); - DECL_CONV_STUB(track_blended_solid); - DECL_CONV_STUB(track_blended_solid_with_end_conditions); - DECL_CONV_STUB(trimmed_curve); - DECL_CONV_STUB(two_direction_repeat_factor); - DECL_CONV_STUB(unary_generic_expression); - DECL_CONV_STUB(unary_numeric_expression); - DECL_CONV_STUB(uncertainty_assigned_representation); - DECL_CONV_STUB(uncertainty_measure_with_unit); - DECL_CONV_STUB(uniform_curve); - DECL_CONV_STUB(uniform_resource_identifier); - DECL_CONV_STUB(uniform_surface); - DECL_CONV_STUB(usage_association); - DECL_CONV_STUB(user_defined_curve_font); - DECL_CONV_STUB(user_defined_marker); - DECL_CONV_STUB(user_defined_terminator_symbol); - DECL_CONV_STUB(user_selected_shape_elements); - DECL_CONV_STUB(value_range); - DECL_CONV_STUB(value_representation_item); - DECL_CONV_STUB(variable_semantics); - DECL_CONV_STUB(variational_representation_item); - DECL_CONV_STUB(vector); - DECL_CONV_STUB(vector_style); - DECL_CONV_STUB(velocity_measure_with_unit); - DECL_CONV_STUB(velocity_unit); - DECL_CONV_STUB(vertex); - DECL_CONV_STUB(vertex_loop); - DECL_CONV_STUB(vertex_point); - DECL_CONV_STUB(vertex_shell); - DECL_CONV_STUB(view_volume); - DECL_CONV_STUB(visual_appearance_representation); - DECL_CONV_STUB(volume_measure_with_unit); - DECL_CONV_STUB(volume_unit); - DECL_CONV_STUB(week_of_year_and_day_date); - DECL_CONV_STUB(wire_shell); - DECL_CONV_STUB(year_month); - - -#undef DECL_CONV_STUB - -} //! STEP -} //! Assimp - -#endif // INCLUDED_STEPFILE_READER_GEN_H diff --git a/code/AssetLib/Terragen/TerragenLoader.cpp b/code/AssetLib/Terragen/TerragenLoader.cpp index 5f25c2455..0d0a140c3 100644 --- a/code/AssetLib/Terragen/TerragenLoader.cpp +++ b/code/AssetLib/Terragen/TerragenLoader.cpp @@ -87,12 +87,16 @@ bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, b if (!extension.length() || checkSig) { /* If CanRead() is called in order to check whether we * support a specific file extension in general pIOHandler - * might be NULL and it's our duty to return true here. + * might be nullptr and it's our duty to return true here. */ - if (!pIOHandler) return true; + if (!pIOHandler) { + return true; + } + const char *tokens[] = { "terragen" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); } + return false; } @@ -116,7 +120,7 @@ void TerragenImporter::InternReadFile(const std::string &pFile, IOStream *file = pIOHandler->Open(pFile, "rb"); // Check whether we can read from the file - if (file == NULL) + if (file == nullptr) throw DeadlyImportError("Failed to open TERRAGEN TERRAIN file " + pFile + "."); // Construct a stream reader to read all data in the correct endianness @@ -199,7 +203,7 @@ void TerragenImporter::InternReadFile(const std::string &pFile, aiFace *f = m->mFaces = new aiFace[m->mNumFaces = (x - 1) * (y - 1)]; aiVector3D *pv = m->mVertices = new aiVector3D[m->mNumVertices = m->mNumFaces * 4]; - aiVector3D *uv(NULL); + aiVector3D *uv(nullptr); float step_y(0.0f), step_x(0.0f); if (configComputeUVs) { uv = m->mTextureCoords[0] = new aiVector3D[m->mNumVertices]; diff --git a/code/AssetLib/X/XFileExporter.cpp b/code/AssetLib/X/XFileExporter.cpp index 41b58487e..2e4232fb9 100644 --- a/code/AssetLib/X/XFileExporter.cpp +++ b/code/AssetLib/X/XFileExporter.cpp @@ -89,7 +89,7 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pSce // we're still here - export successfully completed. Write result to the given IOSYstem std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); - if(outfile == NULL) { + if (outfile == nullptr) { throw DeadlyExportError("could not open output .x file: " + std::string(pFile)); } diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index 277948b08..6c57c9dd2 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -113,7 +113,7 @@ const aiImporterDesc* XFileImporter::GetInfo () const { void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { // read file into memory std::unique_ptr file( pIOHandler->Open( pFile)); - if ( file.get() == NULL ) { + if ( file.get() == nullptr ) { throw DeadlyImportError( "Failed to open file " + pFile + "." ); } diff --git a/code/AssetLib/X/XFileParser.cpp b/code/AssetLib/X/XFileParser.cpp index 8847119c4..f0b751498 100644 --- a/code/AssetLib/X/XFileParser.cpp +++ b/code/AssetLib/X/XFileParser.cpp @@ -43,30 +43,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Implementation of the XFile parser helper class */ - #ifndef ASSIMP_BUILD_NO_X_IMPORTER #include "XFileParser.h" #include "XFileHelper.h" -#include -#include -#include #include +#include #include +#include +#include #include - using namespace Assimp; using namespace Assimp::XFile; using namespace Assimp::Formatter; #ifndef ASSIMP_BUILD_NO_COMPRESSED_X -# ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -# else -# include "../contrib/zlib/zlib.h" -# endif +#ifdef ASSIMP_BUILD_NO_OWN_ZLIB +#include +#else +#include "../contrib/zlib/zlib.h" +#endif // Magic identifier for MSZIP compressed data #define MSZIP_MAGIC 0x4B43 @@ -74,11 +72,11 @@ using namespace Assimp::Formatter; // ------------------------------------------------------------------------------------------------ // Dummy memory wrappers for use with zlib -static void* dummy_alloc (void* /*opaque*/, unsigned int items, unsigned int size) { - return ::operator new(items*size); +static void *dummy_alloc(void * /*opaque*/, unsigned int items, unsigned int size) { + return ::operator new(items *size); } -static void dummy_free (void* /*opaque*/, void* address) { +static void dummy_free(void * /*opaque*/, void *address) { return ::operator delete(address); } @@ -86,15 +84,8 @@ static void dummy_free (void* /*opaque*/, void* address) { // ------------------------------------------------------------------------------------------------ // Constructor. Creates a data structure out of the XFile given in the memory block. -XFileParser::XFileParser( const std::vector& pBuffer) -: mMajorVersion( 0 ) -, mMinorVersion( 0 ) -, mIsBinaryFormat( false ) -, mBinaryNumCount( 0 ) -, mP( nullptr ) -, mEnd( nullptr ) -, mLineNumber( 0 ) -, mScene( nullptr ) { +XFileParser::XFileParser(const std::vector &pBuffer) : + mMajorVersion(0), mMinorVersion(0), mIsBinaryFormat(false), mBinaryNumCount(0), mP(nullptr), mEnd(nullptr), mLineNumber(0), mScene(nullptr) { // vector to store uncompressed file for INFLATE'd X files std::vector uncompressed; @@ -103,8 +94,8 @@ XFileParser::XFileParser( const std::vector& pBuffer) mEnd = mP + pBuffer.size() - 1; // check header - if ( 0 != strncmp( mP, "xof ", 4 ) ) { - throw DeadlyImportError( "Header mismatch, file is not an XFile." ); + if (0 != strncmp(mP, "xof ", 4)) { + throw DeadlyImportError("Header mismatch, file is not an XFile."); } // read version. It comes in a four byte format such as "0302" @@ -114,36 +105,30 @@ XFileParser::XFileParser( const std::vector& pBuffer) bool compressed = false; // txt - pure ASCII text format - if( strncmp( mP + 8, "txt ", 4) == 0) + if (strncmp(mP + 8, "txt ", 4) == 0) mIsBinaryFormat = false; // bin - Binary format - else if( strncmp( mP + 8, "bin ", 4) == 0) + else if (strncmp(mP + 8, "bin ", 4) == 0) mIsBinaryFormat = true; // tzip - Inflate compressed text format - else if( strncmp( mP + 8, "tzip", 4) == 0) - { + else if (strncmp(mP + 8, "tzip", 4) == 0) { mIsBinaryFormat = false; compressed = true; } // bzip - Inflate compressed binary format - else if( strncmp( mP + 8, "bzip", 4) == 0) - { + else if (strncmp(mP + 8, "bzip", 4) == 0) { mIsBinaryFormat = true; compressed = true; - } - else ThrowException( format() << "Unsupported xfile format '" << - mP[8] << mP[9] << mP[10] << mP[11] << "'"); + } else + ThrowException(format() << "Unsupported xfile format '" << mP[8] << mP[9] << mP[10] << mP[11] << "'"); // float size - mBinaryFloatSize = (unsigned int)(mP[12] - 48) * 1000 - + (unsigned int)(mP[13] - 48) * 100 - + (unsigned int)(mP[14] - 48) * 10 - + (unsigned int)(mP[15] - 48); + mBinaryFloatSize = (unsigned int)(mP[12] - 48) * 1000 + (unsigned int)(mP[13] - 48) * 100 + (unsigned int)(mP[14] - 48) * 10 + (unsigned int)(mP[15] - 48); - if( mBinaryFloatSize != 32 && mBinaryFloatSize != 64) - ThrowException( format() << "Unknown float size " << mBinaryFloatSize << " specified in xfile header." ); + if (mBinaryFloatSize != 32 && mBinaryFloatSize != 64) + ThrowException(format() << "Unknown float size " << mBinaryFloatSize << " specified in xfile header."); // The x format specifies size in bits, but we work in bytes mBinaryFloatSize /= 8; @@ -151,8 +136,7 @@ XFileParser::XFileParser( const std::vector& pBuffer) mP += 16; // If this is a compressed X file, apply the inflate algorithm to it - if (compressed) - { + if (compressed) { #ifdef ASSIMP_BUILD_NO_COMPRESSED_X throw DeadlyImportError("Assimp was built without compressed X support"); #else @@ -178,9 +162,9 @@ XFileParser::XFileParser( const std::vector& pBuffer) // build a zlib stream z_stream stream; - stream.opaque = NULL; + stream.opaque = nullptr; stream.zalloc = &dummy_alloc; - stream.zfree = &dummy_free; + stream.zfree = &dummy_free; stream.data_type = (mIsBinaryFormat ? Z_BINARY : Z_ASCII); // initialize the inflation algorithm @@ -190,21 +174,22 @@ XFileParser::XFileParser( const std::vector& pBuffer) mP += 6; // First find out how much storage we'll need. Count sections. - const char* P1 = mP; + const char *P1 = mP; unsigned int est_out = 0; - while (P1 + 3 < mEnd) - { + while (P1 + 3 < mEnd) { // read next offset - uint16_t ofs = *((uint16_t*)P1); - AI_SWAP2(ofs); P1 += 2; + uint16_t ofs = *((uint16_t *)P1); + AI_SWAP2(ofs); + P1 += 2; if (ofs >= MSZIP_BLOCK) throw DeadlyImportError("X: Invalid offset to next MSZIP compressed block"); // check magic word - uint16_t magic = *((uint16_t*)P1); - AI_SWAP2(magic); P1 += 2; + uint16_t magic = *((uint16_t *)P1); + AI_SWAP2(magic); + P1 += 2; if (magic != MSZIP_MAGIC) throw DeadlyImportError("X: Unsupported compressed format, expected MSZIP header"); @@ -216,10 +201,9 @@ XFileParser::XFileParser( const std::vector& pBuffer) // Allocate storage and terminating zero and do the actual uncompressing uncompressed.resize(est_out + 1); - char* out = &uncompressed.front(); - while (mP + 3 < mEnd) - { - uint16_t ofs = *((uint16_t*)mP); + char *out = &uncompressed.front(); + while (mP + 3 < mEnd) { + uint16_t ofs = *((uint16_t *)mP); AI_SWAP2(ofs); mP += 4; @@ -228,22 +212,22 @@ XFileParser::XFileParser( const std::vector& pBuffer) } // push data to the stream - stream.next_in = (Bytef*)mP; - stream.avail_in = ofs; - stream.next_out = (Bytef*)out; + stream.next_in = (Bytef *)mP; + stream.avail_in = ofs; + stream.next_out = (Bytef *)out; stream.avail_out = MSZIP_BLOCK; // and decompress the data .... - int ret = ::inflate( &stream, Z_SYNC_FLUSH ); + int ret = ::inflate(&stream, Z_SYNC_FLUSH); if (ret != Z_OK && ret != Z_STREAM_END) throw DeadlyImportError("X: Failed to decompress MSZIP-compressed data"); - ::inflateReset( &stream ); - ::inflateSetDictionary( &stream, (const Bytef*)out , MSZIP_BLOCK - stream.avail_out ); + ::inflateReset(&stream); + ::inflateSetDictionary(&stream, (const Bytef *)out, MSZIP_BLOCK - stream.avail_out); // and advance to the next offset - out += MSZIP_BLOCK - stream.avail_out; - mP += ofs; + out += MSZIP_BLOCK - stream.avail_out; + mP += ofs; } // terminate zlib @@ -257,9 +241,7 @@ XFileParser::XFileParser( const std::vector& pBuffer) // it already for better memory usage. Consider breaking const-co. ASSIMP_LOG_INFO("Successfully decompressed MSZIP-compressed file"); #endif // !! ASSIMP_BUILD_NO_COMPRESSED_X - } - else - { + } else { // start reading here ReadUntilEndOfLine(); } @@ -268,63 +250,50 @@ XFileParser::XFileParser( const std::vector& pBuffer) ParseFile(); // filter the imported hierarchy for some degenerated cases - if( mScene->mRootNode) { - FilterHierarchy( mScene->mRootNode); + if (mScene->mRootNode) { + FilterHierarchy(mScene->mRootNode); } } // ------------------------------------------------------------------------------------------------ // Destructor. Destroys all imported data along with it -XFileParser::~XFileParser() -{ +XFileParser::~XFileParser() { // kill everything we created delete mScene; } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseFile() -{ +void XFileParser::ParseFile() { bool running = true; - while( running ) - { + while (running) { // read name of next object std::string objectName = GetNextToken(); if (objectName.length() == 0) break; // parse specific object - if( objectName == "template") + if (objectName == "template") ParseDataObjectTemplate(); - else - if( objectName == "Frame") - ParseDataObjectFrame( NULL); - else - if( objectName == "Mesh") - { + else if (objectName == "Frame") + ParseDataObjectFrame(nullptr); + else if (objectName == "Mesh") { // some meshes have no frames at all - Mesh* mesh = new Mesh; - ParseDataObjectMesh( mesh); - mScene->mGlobalMeshes.push_back( mesh); - } else - if( objectName == "AnimTicksPerSecond") + Mesh *mesh = new Mesh; + ParseDataObjectMesh(mesh); + mScene->mGlobalMeshes.push_back(mesh); + } else if (objectName == "AnimTicksPerSecond") ParseDataObjectAnimTicksPerSecond(); - else - if( objectName == "AnimationSet") + else if (objectName == "AnimationSet") ParseDataObjectAnimationSet(); - else - if( objectName == "Material") - { + else if (objectName == "Material") { // Material outside of a mesh or node Material material; - ParseDataObjectMaterial( &material); - mScene->mGlobalMaterials.push_back( material); - } else - if( objectName == "}") - { + ParseDataObjectMaterial(&material); + mScene->mGlobalMaterials.push_back(material); + } else if (objectName == "}") { // whatever? ASSIMP_LOG_WARN("} found in dataObject"); - } else - { + } else { // unknown format ASSIMP_LOG_WARN("Unknown data object in animation of .x file"); ParseUnknownDataObject(); @@ -333,32 +302,29 @@ void XFileParser::ParseFile() } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectTemplate() -{ +void XFileParser::ParseDataObjectTemplate() { // parse a template data object. Currently not stored. std::string name; - readHeadOfDataObject( &name); + readHeadOfDataObject(&name); // read GUID std::string guid = GetNextToken(); // read and ignore data members bool running = true; - while ( running ) - { + while (running) { std::string s = GetNextToken(); - if( s == "}") + if (s == "}") break; - if( s.length() == 0) - ThrowException( "Unexpected end of file reached while parsing template definition"); + if (s.length() == 0) + ThrowException("Unexpected end of file reached while parsing template definition"); } } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectFrame( Node* pParent) -{ +void XFileParser::ParseDataObjectFrame(Node *pParent) { // A coordinate frame, or "frame of reference." The Frame template // is open and can contain any object. The Direct3D extensions (D3DX) // mesh-loading functions recognize Mesh, FrameTransformMatrix, and @@ -368,30 +334,25 @@ void XFileParser::ParseDataObjectFrame( Node* pParent) readHeadOfDataObject(&name); // create a named node and place it at its parent, if given - Node* node = new Node( pParent); + Node *node = new Node(pParent); node->mName = name; - if( pParent) - { - pParent->mChildren.push_back( node); - } else - { + if (pParent) { + pParent->mChildren.push_back(node); + } else { // there might be multiple root nodes - if( mScene->mRootNode != NULL) - { + if (mScene->mRootNode != nullptr) { // place a dummy root if not there - if( mScene->mRootNode->mName != "$dummy_root") - { - Node* exroot = mScene->mRootNode; - mScene->mRootNode = new Node( NULL); + if (mScene->mRootNode->mName != "$dummy_root") { + Node *exroot = mScene->mRootNode; + mScene->mRootNode = new Node(nullptr); mScene->mRootNode->mName = "$dummy_root"; - mScene->mRootNode->mChildren.push_back( exroot); + mScene->mRootNode->mChildren.push_back(exroot); exroot->mParent = mScene->mRootNode; } // put the new node as its child instead - mScene->mRootNode->mChildren.push_back( node); + mScene->mRootNode->mChildren.push_back(node); node->mParent = mScene->mRootNode; - } else - { + } else { // it's the first node imported. place it as root mScene->mRootNode = node; } @@ -400,28 +361,22 @@ void XFileParser::ParseDataObjectFrame( Node* pParent) // Now inside a frame. // read tokens until closing brace is reached. bool running = true; - while ( running ) - { + while (running) { std::string objectName = GetNextToken(); if (objectName.size() == 0) - ThrowException( "Unexpected end of file reached while parsing frame"); + ThrowException("Unexpected end of file reached while parsing frame"); - if( objectName == "}") + if (objectName == "}") break; // frame finished - else - if( objectName == "Frame") - ParseDataObjectFrame( node); // child frame - else - if( objectName == "FrameTransformMatrix") - ParseDataObjectTransformationMatrix( node->mTrafoMatrix); - else - if( objectName == "Mesh") - { - Mesh* mesh = new Mesh(name); - node->mMeshes.push_back( mesh); - ParseDataObjectMesh( mesh); - } else - { + else if (objectName == "Frame") + ParseDataObjectFrame(node); // child frame + else if (objectName == "FrameTransformMatrix") + ParseDataObjectTransformationMatrix(node->mTrafoMatrix); + else if (objectName == "Mesh") { + Mesh *mesh = new Mesh(name); + node->mMeshes.push_back(mesh); + ParseDataObjectMesh(mesh); + } else { ASSIMP_LOG_WARN("Unknown data object in frame in x file"); ParseUnknownDataObject(); } @@ -429,20 +384,27 @@ void XFileParser::ParseDataObjectFrame( Node* pParent) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectTransformationMatrix( aiMatrix4x4& pMatrix) -{ +void XFileParser::ParseDataObjectTransformationMatrix(aiMatrix4x4 &pMatrix) { // read header, we're not interested if it has a name readHeadOfDataObject(); // read its components - pMatrix.a1 = ReadFloat(); pMatrix.b1 = ReadFloat(); - pMatrix.c1 = ReadFloat(); pMatrix.d1 = ReadFloat(); - pMatrix.a2 = ReadFloat(); pMatrix.b2 = ReadFloat(); - pMatrix.c2 = ReadFloat(); pMatrix.d2 = ReadFloat(); - pMatrix.a3 = ReadFloat(); pMatrix.b3 = ReadFloat(); - pMatrix.c3 = ReadFloat(); pMatrix.d3 = ReadFloat(); - pMatrix.a4 = ReadFloat(); pMatrix.b4 = ReadFloat(); - pMatrix.c4 = ReadFloat(); pMatrix.d4 = ReadFloat(); + pMatrix.a1 = ReadFloat(); + pMatrix.b1 = ReadFloat(); + pMatrix.c1 = ReadFloat(); + pMatrix.d1 = ReadFloat(); + pMatrix.a2 = ReadFloat(); + pMatrix.b2 = ReadFloat(); + pMatrix.c2 = ReadFloat(); + pMatrix.d2 = ReadFloat(); + pMatrix.a3 = ReadFloat(); + pMatrix.b3 = ReadFloat(); + pMatrix.c3 = ReadFloat(); + pMatrix.d3 = ReadFloat(); + pMatrix.a4 = ReadFloat(); + pMatrix.b4 = ReadFloat(); + pMatrix.c4 = ReadFloat(); + pMatrix.d4 = ReadFloat(); // trailing symbols CheckForSemicolon(); @@ -450,30 +412,29 @@ void XFileParser::ParseDataObjectTransformationMatrix( aiMatrix4x4& pMatrix) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectMesh( Mesh* pMesh) -{ +void XFileParser::ParseDataObjectMesh(Mesh *pMesh) { std::string name; - readHeadOfDataObject( &name); + readHeadOfDataObject(&name); // read vertex count unsigned int numVertices = ReadInt(); - pMesh->mPositions.resize( numVertices); + pMesh->mPositions.resize(numVertices); // read vertices - for( unsigned int a = 0; a < numVertices; a++) + for (unsigned int a = 0; a < numVertices; a++) pMesh->mPositions[a] = ReadVector3(); // read position faces unsigned int numPosFaces = ReadInt(); - pMesh->mPosFaces.resize( numPosFaces); - for( unsigned int a = 0; a < numPosFaces; ++a) { + pMesh->mPosFaces.resize(numPosFaces); + for (unsigned int a = 0; a < numPosFaces; ++a) { // read indices unsigned int numIndices = ReadInt(); - Face& face = pMesh->mPosFaces[a]; + Face &face = pMesh->mPosFaces[a]; for (unsigned int b = 0; b < numIndices; ++b) { - const int idx( ReadInt() ); - if ( static_cast( idx ) <= numVertices ) { - face.mIndices.push_back( idx ); + const int idx(ReadInt()); + if (static_cast(idx) <= numVertices) { + face.mIndices.push_back(idx); } } TestForSeparator(); @@ -481,37 +442,28 @@ void XFileParser::ParseDataObjectMesh( Mesh* pMesh) // here, other data objects may follow bool running = true; - while ( running ) { + while (running) { std::string objectName = GetNextToken(); - if( objectName.empty() ) - ThrowException( "Unexpected end of file while parsing mesh structure"); - else - if( objectName == "}") + if (objectName.empty()) + ThrowException("Unexpected end of file while parsing mesh structure"); + else if (objectName == "}") break; // mesh finished - else - if( objectName == "MeshNormals") - ParseDataObjectMeshNormals( pMesh); - else - if( objectName == "MeshTextureCoords") - ParseDataObjectMeshTextureCoords( pMesh); - else - if( objectName == "MeshVertexColors") - ParseDataObjectMeshVertexColors( pMesh); - else - if( objectName == "MeshMaterialList") - ParseDataObjectMeshMaterialList( pMesh); - else - if( objectName == "VertexDuplicationIndices") + else if (objectName == "MeshNormals") + ParseDataObjectMeshNormals(pMesh); + else if (objectName == "MeshTextureCoords") + ParseDataObjectMeshTextureCoords(pMesh); + else if (objectName == "MeshVertexColors") + ParseDataObjectMeshVertexColors(pMesh); + else if (objectName == "MeshMaterialList") + ParseDataObjectMeshMaterialList(pMesh); + else if (objectName == "VertexDuplicationIndices") ParseUnknownDataObject(); // we'll ignore vertex duplication indices - else - if( objectName == "XSkinMeshHeader") - ParseDataObjectSkinMeshHeader( pMesh); - else - if( objectName == "SkinWeights") - ParseDataObjectSkinWeights( pMesh); - else - { + else if (objectName == "XSkinMeshHeader") + ParseDataObjectSkinMeshHeader(pMesh); + else if (objectName == "SkinWeights") + ParseDataObjectSkinWeights(pMesh); + else { ASSIMP_LOG_WARN("Unknown data object in mesh in x file"); ParseUnknownDataObject(); } @@ -519,90 +471,95 @@ void XFileParser::ParseDataObjectMesh( Mesh* pMesh) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectSkinWeights( Mesh *pMesh) { - if ( nullptr == pMesh ) { +void XFileParser::ParseDataObjectSkinWeights(Mesh *pMesh) { + if (nullptr == pMesh) { return; } readHeadOfDataObject(); std::string transformNodeName; - GetNextTokenAsString( transformNodeName); + GetNextTokenAsString(transformNodeName); - pMesh->mBones.push_back( Bone()); - Bone& bone = pMesh->mBones.back(); + pMesh->mBones.push_back(Bone()); + Bone &bone = pMesh->mBones.back(); bone.mName = transformNodeName; // read vertex weights unsigned int numWeights = ReadInt(); - bone.mWeights.reserve( numWeights); + bone.mWeights.reserve(numWeights); - for( unsigned int a = 0; a < numWeights; a++) - { + for (unsigned int a = 0; a < numWeights; a++) { BoneWeight weight; weight.mVertex = ReadInt(); - bone.mWeights.push_back( weight); + bone.mWeights.push_back(weight); } // read vertex weights - for( unsigned int a = 0; a < numWeights; a++) + for (unsigned int a = 0; a < numWeights; a++) bone.mWeights[a].mWeight = ReadFloat(); // read matrix offset - bone.mOffsetMatrix.a1 = ReadFloat(); bone.mOffsetMatrix.b1 = ReadFloat(); - bone.mOffsetMatrix.c1 = ReadFloat(); bone.mOffsetMatrix.d1 = ReadFloat(); - bone.mOffsetMatrix.a2 = ReadFloat(); bone.mOffsetMatrix.b2 = ReadFloat(); - bone.mOffsetMatrix.c2 = ReadFloat(); bone.mOffsetMatrix.d2 = ReadFloat(); - bone.mOffsetMatrix.a3 = ReadFloat(); bone.mOffsetMatrix.b3 = ReadFloat(); - bone.mOffsetMatrix.c3 = ReadFloat(); bone.mOffsetMatrix.d3 = ReadFloat(); - bone.mOffsetMatrix.a4 = ReadFloat(); bone.mOffsetMatrix.b4 = ReadFloat(); - bone.mOffsetMatrix.c4 = ReadFloat(); bone.mOffsetMatrix.d4 = ReadFloat(); + bone.mOffsetMatrix.a1 = ReadFloat(); + bone.mOffsetMatrix.b1 = ReadFloat(); + bone.mOffsetMatrix.c1 = ReadFloat(); + bone.mOffsetMatrix.d1 = ReadFloat(); + bone.mOffsetMatrix.a2 = ReadFloat(); + bone.mOffsetMatrix.b2 = ReadFloat(); + bone.mOffsetMatrix.c2 = ReadFloat(); + bone.mOffsetMatrix.d2 = ReadFloat(); + bone.mOffsetMatrix.a3 = ReadFloat(); + bone.mOffsetMatrix.b3 = ReadFloat(); + bone.mOffsetMatrix.c3 = ReadFloat(); + bone.mOffsetMatrix.d3 = ReadFloat(); + bone.mOffsetMatrix.a4 = ReadFloat(); + bone.mOffsetMatrix.b4 = ReadFloat(); + bone.mOffsetMatrix.c4 = ReadFloat(); + bone.mOffsetMatrix.d4 = ReadFloat(); CheckForSemicolon(); CheckForClosingBrace(); } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectSkinMeshHeader( Mesh* /*pMesh*/ ) -{ +void XFileParser::ParseDataObjectSkinMeshHeader(Mesh * /*pMesh*/) { readHeadOfDataObject(); - /*unsigned int maxSkinWeightsPerVertex =*/ ReadInt(); - /*unsigned int maxSkinWeightsPerFace =*/ ReadInt(); - /*unsigned int numBonesInMesh = */ReadInt(); + /*unsigned int maxSkinWeightsPerVertex =*/ReadInt(); + /*unsigned int maxSkinWeightsPerFace =*/ReadInt(); + /*unsigned int numBonesInMesh = */ ReadInt(); CheckForClosingBrace(); } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectMeshNormals( Mesh* pMesh) -{ +void XFileParser::ParseDataObjectMeshNormals(Mesh *pMesh) { readHeadOfDataObject(); // read count unsigned int numNormals = ReadInt(); - pMesh->mNormals.resize( numNormals); + pMesh->mNormals.resize(numNormals); // read normal vectors - for( unsigned int a = 0; a < numNormals; ++a) { + for (unsigned int a = 0; a < numNormals; ++a) { pMesh->mNormals[a] = ReadVector3(); } // read normal indices unsigned int numFaces = ReadInt(); - if( numFaces != pMesh->mPosFaces.size()) { - ThrowException( "Normal face count does not match vertex face count."); + if (numFaces != pMesh->mPosFaces.size()) { + ThrowException("Normal face count does not match vertex face count."); } // do not crah when no face definitions are there if (numFaces > 0) { // normal face creation - pMesh->mNormFaces.resize( numFaces ); - for( unsigned int a = 0; a < numFaces; ++a ) { + pMesh->mNormFaces.resize(numFaces); + for (unsigned int a = 0; a < numFaces; ++a) { unsigned int numIndices = ReadInt(); pMesh->mNormFaces[a] = Face(); - Face& face = pMesh->mNormFaces[a]; - for( unsigned int b = 0; b < numIndices; ++b ) { - face.mIndices.push_back( ReadInt()); + Face &face = pMesh->mNormFaces[a]; + for (unsigned int b = 0; b < numIndices; ++b) { + face.mIndices.push_back(ReadInt()); } TestForSeparator(); @@ -613,51 +570,47 @@ void XFileParser::ParseDataObjectMeshNormals( Mesh* pMesh) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectMeshTextureCoords( Mesh* pMesh) -{ +void XFileParser::ParseDataObjectMeshTextureCoords(Mesh *pMesh) { readHeadOfDataObject(); - if( pMesh->mNumTextures + 1 > AI_MAX_NUMBER_OF_TEXTURECOORDS) - ThrowException( "Too many sets of texture coordinates"); + if (pMesh->mNumTextures + 1 > AI_MAX_NUMBER_OF_TEXTURECOORDS) + ThrowException("Too many sets of texture coordinates"); - std::vector& coords = pMesh->mTexCoords[pMesh->mNumTextures++]; + std::vector &coords = pMesh->mTexCoords[pMesh->mNumTextures++]; unsigned int numCoords = ReadInt(); - if( numCoords != pMesh->mPositions.size()) - ThrowException( "Texture coord count does not match vertex count"); + if (numCoords != pMesh->mPositions.size()) + ThrowException("Texture coord count does not match vertex count"); - coords.resize( numCoords); - for( unsigned int a = 0; a < numCoords; a++) + coords.resize(numCoords); + for (unsigned int a = 0; a < numCoords; a++) coords[a] = ReadVector2(); CheckForClosingBrace(); } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectMeshVertexColors( Mesh* pMesh) -{ +void XFileParser::ParseDataObjectMeshVertexColors(Mesh *pMesh) { readHeadOfDataObject(); - if( pMesh->mNumColorSets + 1 > AI_MAX_NUMBER_OF_COLOR_SETS) - ThrowException( "Too many colorsets"); - std::vector& colors = pMesh->mColors[pMesh->mNumColorSets++]; + if (pMesh->mNumColorSets + 1 > AI_MAX_NUMBER_OF_COLOR_SETS) + ThrowException("Too many colorsets"); + std::vector &colors = pMesh->mColors[pMesh->mNumColorSets++]; unsigned int numColors = ReadInt(); - if( numColors != pMesh->mPositions.size()) - ThrowException( "Vertex color count does not match vertex count"); + if (numColors != pMesh->mPositions.size()) + ThrowException("Vertex color count does not match vertex count"); - colors.resize( numColors, aiColor4D( 0, 0, 0, 1)); - for( unsigned int a = 0; a < numColors; a++) - { + colors.resize(numColors, aiColor4D(0, 0, 0, 1)); + for (unsigned int a = 0; a < numColors; a++) { unsigned int index = ReadInt(); - if( index >= pMesh->mPositions.size()) - ThrowException( "Vertex color index out of bounds"); + if (index >= pMesh->mPositions.size()) + ThrowException("Vertex color index out of bounds"); colors[index] = ReadRGBA(); // HACK: (thom) Maxon Cinema XPort plugin puts a third separator here, kwxPort puts a comma. // Ignore gracefully. - if( !mIsBinaryFormat) - { + if (!mIsBinaryFormat) { FindNextNoneWhiteSpace(); - if( *mP == ';' || *mP == ',') + if (*mP == ';' || *mP == ',') mP++; } } @@ -666,68 +619,58 @@ void XFileParser::ParseDataObjectMeshVertexColors( Mesh* pMesh) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectMeshMaterialList( Mesh* pMesh) -{ +void XFileParser::ParseDataObjectMeshMaterialList(Mesh *pMesh) { readHeadOfDataObject(); // read material count - /*unsigned int numMaterials =*/ ReadInt(); + /*unsigned int numMaterials =*/ReadInt(); // read non triangulated face material index count unsigned int numMatIndices = ReadInt(); // some models have a material index count of 1... to be able to read them we // replicate this single material index on every face - if( numMatIndices != pMesh->mPosFaces.size() && numMatIndices != 1) - ThrowException( "Per-Face material index count does not match face count."); + if (numMatIndices != pMesh->mPosFaces.size() && numMatIndices != 1) + ThrowException("Per-Face material index count does not match face count."); // read per-face material indices - for( unsigned int a = 0; a < numMatIndices; a++) - pMesh->mFaceMaterials.push_back( ReadInt()); + for (unsigned int a = 0; a < numMatIndices; a++) + pMesh->mFaceMaterials.push_back(ReadInt()); // in version 03.02, the face indices end with two semicolons. // commented out version check, as version 03.03 exported from blender also has 2 semicolons - if( !mIsBinaryFormat) // && MajorVersion == 3 && MinorVersion <= 2) + if (!mIsBinaryFormat) // && MajorVersion == 3 && MinorVersion <= 2) { - if(mP < mEnd && *mP == ';') + if (mP < mEnd && *mP == ';') ++mP; } // if there was only a single material index, replicate it on all faces - while( pMesh->mFaceMaterials.size() < pMesh->mPosFaces.size()) - pMesh->mFaceMaterials.push_back( pMesh->mFaceMaterials.front()); + while (pMesh->mFaceMaterials.size() < pMesh->mPosFaces.size()) + pMesh->mFaceMaterials.push_back(pMesh->mFaceMaterials.front()); // read following data objects bool running = true; - while ( running ) - { + while (running) { std::string objectName = GetNextToken(); - if( objectName.size() == 0) - ThrowException( "Unexpected end of file while parsing mesh material list."); - else - if( objectName == "}") + if (objectName.size() == 0) + ThrowException("Unexpected end of file while parsing mesh material list."); + else if (objectName == "}") break; // material list finished - else - if( objectName == "{") - { + else if (objectName == "{") { // template materials std::string matName = GetNextToken(); Material material; material.mIsReference = true; material.mName = matName; - pMesh->mMaterials.push_back( material); + pMesh->mMaterials.push_back(material); CheckForClosingBrace(); // skip } - } else - if( objectName == "Material") - { - pMesh->mMaterials.push_back( Material()); - ParseDataObjectMaterial( &pMesh->mMaterials.back()); - } else - if( objectName == ";") - { + } else if (objectName == "Material") { + pMesh->mMaterials.push_back(Material()); + ParseDataObjectMaterial(&pMesh->mMaterials.back()); + } else if (objectName == ";") { // ignore - } else - { + } else { ASSIMP_LOG_WARN("Unknown data object in material list in x file"); ParseUnknownDataObject(); } @@ -735,12 +678,11 @@ void XFileParser::ParseDataObjectMeshMaterialList( Mesh* pMesh) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectMaterial( Material* pMaterial) -{ +void XFileParser::ParseDataObjectMaterial(Material *pMaterial) { std::string matName; - readHeadOfDataObject( &matName); - if( matName.empty()) - matName = std::string( "material") + to_string( mLineNumber ); + readHeadOfDataObject(&matName); + if (matName.empty()) + matName = std::string("material") + to_string(mLineNumber); pMaterial->mName = matName; pMaterial->mIsReference = false; @@ -752,30 +694,23 @@ void XFileParser::ParseDataObjectMaterial( Material* pMaterial) // read other data objects bool running = true; - while ( running ) - { + while (running) { std::string objectName = GetNextToken(); - if( objectName.size() == 0) - ThrowException( "Unexpected end of file while parsing mesh material"); - else - if( objectName == "}") + if (objectName.size() == 0) + ThrowException("Unexpected end of file while parsing mesh material"); + else if (objectName == "}") break; // material finished - else - if( objectName == "TextureFilename" || objectName == "TextureFileName") - { + else if (objectName == "TextureFilename" || objectName == "TextureFileName") { // some exporters write "TextureFileName" instead. std::string texname; - ParseDataObjectTextureFilename( texname); - pMaterial->mTextures.push_back( TexEntry( texname)); - } else - if( objectName == "NormalmapFilename" || objectName == "NormalmapFileName") - { + ParseDataObjectTextureFilename(texname); + pMaterial->mTextures.push_back(TexEntry(texname)); + } else if (objectName == "NormalmapFilename" || objectName == "NormalmapFileName") { // one exporter writes out the normal map in a separate filename tag std::string texname; - ParseDataObjectTextureFilename( texname); - pMaterial->mTextures.push_back( TexEntry( texname, true)); - } else - { + ParseDataObjectTextureFilename(texname); + pMaterial->mTextures.push_back(TexEntry(texname, true)); + } else { ASSIMP_LOG_WARN("Unknown data object in material in x file"); ParseUnknownDataObject(); } @@ -783,37 +718,31 @@ void XFileParser::ParseDataObjectMaterial( Material* pMaterial) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectAnimTicksPerSecond() -{ +void XFileParser::ParseDataObjectAnimTicksPerSecond() { readHeadOfDataObject(); mScene->mAnimTicksPerSecond = ReadInt(); CheckForClosingBrace(); } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectAnimationSet() -{ +void XFileParser::ParseDataObjectAnimationSet() { std::string animName; - readHeadOfDataObject( &animName); + readHeadOfDataObject(&animName); - Animation* anim = new Animation; - mScene->mAnims.push_back( anim); + Animation *anim = new Animation; + mScene->mAnims.push_back(anim); anim->mName = animName; bool running = true; - while ( running ) - { + while (running) { std::string objectName = GetNextToken(); - if( objectName.length() == 0) - ThrowException( "Unexpected end of file while parsing animation set."); - else - if( objectName == "}") + if (objectName.length() == 0) + ThrowException("Unexpected end of file while parsing animation set."); + else if (objectName == "}") break; // animation set finished - else - if( objectName == "Animation") - ParseDataObjectAnimation( anim); - else - { + else if (objectName == "Animation") + ParseDataObjectAnimation(anim); + else { ASSIMP_LOG_WARN("Unknown data object in animation set in x file"); ParseUnknownDataObject(); } @@ -821,36 +750,28 @@ void XFileParser::ParseDataObjectAnimationSet() } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectAnimation( Animation* pAnim) -{ +void XFileParser::ParseDataObjectAnimation(Animation *pAnim) { readHeadOfDataObject(); - AnimBone* banim = new AnimBone; - pAnim->mAnims.push_back( banim); + AnimBone *banim = new AnimBone; + pAnim->mAnims.push_back(banim); bool running = true; - while( running ) - { + while (running) { std::string objectName = GetNextToken(); - if( objectName.length() == 0) - ThrowException( "Unexpected end of file while parsing animation."); - else - if( objectName == "}") + if (objectName.length() == 0) + ThrowException("Unexpected end of file while parsing animation."); + else if (objectName == "}") break; // animation finished - else - if( objectName == "AnimationKey") - ParseDataObjectAnimationKey( banim); - else - if( objectName == "AnimationOptions") + else if (objectName == "AnimationKey") + ParseDataObjectAnimationKey(banim); + else if (objectName == "AnimationOptions") ParseUnknownDataObject(); // not interested - else - if( objectName == "{") - { + else if (objectName == "{") { // read frame name banim->mBoneName = GetNextToken(); CheckForClosingBrace(); - } else - { + } else { ASSIMP_LOG_WARN("Unknown data object in animation in x file"); ParseUnknownDataObject(); } @@ -858,8 +779,7 @@ void XFileParser::ParseDataObjectAnimation( Animation* pAnim) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectAnimationKey( AnimBone* pAnimBone) -{ +void XFileParser::ParseDataObjectAnimationKey(AnimBone *pAnimBone) { readHeadOfDataObject(); // read key type @@ -868,78 +788,84 @@ void XFileParser::ParseDataObjectAnimationKey( AnimBone* pAnimBone) // read number of keys unsigned int numKeys = ReadInt(); - for( unsigned int a = 0; a < numKeys; a++) - { + for (unsigned int a = 0; a < numKeys; a++) { // read time unsigned int time = ReadInt(); // read keys - switch( keyType) + switch (keyType) { + case 0: // rotation quaternion { - case 0: // rotation quaternion - { - // read count - if( ReadInt() != 4) - ThrowException( "Invalid number of arguments for quaternion key in animation"); + // read count + if (ReadInt() != 4) + ThrowException("Invalid number of arguments for quaternion key in animation"); - aiQuatKey key; - key.mTime = double( time); - key.mValue.w = ReadFloat(); - key.mValue.x = ReadFloat(); - key.mValue.y = ReadFloat(); - key.mValue.z = ReadFloat(); - pAnimBone->mRotKeys.push_back( key); + aiQuatKey key; + key.mTime = double(time); + key.mValue.w = ReadFloat(); + key.mValue.x = ReadFloat(); + key.mValue.y = ReadFloat(); + key.mValue.z = ReadFloat(); + pAnimBone->mRotKeys.push_back(key); - CheckForSemicolon(); - break; - } + CheckForSemicolon(); + break; + } - case 1: // scale vector - case 2: // position vector - { - // read count - if( ReadInt() != 3) - ThrowException( "Invalid number of arguments for vector key in animation"); + case 1: // scale vector + case 2: // position vector + { + // read count + if (ReadInt() != 3) + ThrowException("Invalid number of arguments for vector key in animation"); - aiVectorKey key; - key.mTime = double( time); - key.mValue = ReadVector3(); + aiVectorKey key; + key.mTime = double(time); + key.mValue = ReadVector3(); - if( keyType == 2) - pAnimBone->mPosKeys.push_back( key); - else - pAnimBone->mScaleKeys.push_back( key); + if (keyType == 2) + pAnimBone->mPosKeys.push_back(key); + else + pAnimBone->mScaleKeys.push_back(key); - break; - } + break; + } - case 3: // combined transformation matrix - case 4: // denoted both as 3 or as 4 - { - // read count - if( ReadInt() != 16) - ThrowException( "Invalid number of arguments for matrix key in animation"); + case 3: // combined transformation matrix + case 4: // denoted both as 3 or as 4 + { + // read count + if (ReadInt() != 16) + ThrowException("Invalid number of arguments for matrix key in animation"); - // read matrix - MatrixKey key; - key.mTime = double( time); - key.mMatrix.a1 = ReadFloat(); key.mMatrix.b1 = ReadFloat(); - key.mMatrix.c1 = ReadFloat(); key.mMatrix.d1 = ReadFloat(); - key.mMatrix.a2 = ReadFloat(); key.mMatrix.b2 = ReadFloat(); - key.mMatrix.c2 = ReadFloat(); key.mMatrix.d2 = ReadFloat(); - key.mMatrix.a3 = ReadFloat(); key.mMatrix.b3 = ReadFloat(); - key.mMatrix.c3 = ReadFloat(); key.mMatrix.d3 = ReadFloat(); - key.mMatrix.a4 = ReadFloat(); key.mMatrix.b4 = ReadFloat(); - key.mMatrix.c4 = ReadFloat(); key.mMatrix.d4 = ReadFloat(); - pAnimBone->mTrafoKeys.push_back( key); + // read matrix + MatrixKey key; + key.mTime = double(time); + key.mMatrix.a1 = ReadFloat(); + key.mMatrix.b1 = ReadFloat(); + key.mMatrix.c1 = ReadFloat(); + key.mMatrix.d1 = ReadFloat(); + key.mMatrix.a2 = ReadFloat(); + key.mMatrix.b2 = ReadFloat(); + key.mMatrix.c2 = ReadFloat(); + key.mMatrix.d2 = ReadFloat(); + key.mMatrix.a3 = ReadFloat(); + key.mMatrix.b3 = ReadFloat(); + key.mMatrix.c3 = ReadFloat(); + key.mMatrix.d3 = ReadFloat(); + key.mMatrix.a4 = ReadFloat(); + key.mMatrix.b4 = ReadFloat(); + key.mMatrix.c4 = ReadFloat(); + key.mMatrix.d4 = ReadFloat(); + pAnimBone->mTrafoKeys.push_back(key); - CheckForSemicolon(); - break; - } + CheckForSemicolon(); + break; + } - default: - ThrowException( format() << "Unknown key type " << keyType << " in animation." ); - break; + default: + ThrowException(format() << "Unknown key type " << keyType << " in animation."); + break; } // end switch // key separator @@ -950,115 +876,103 @@ void XFileParser::ParseDataObjectAnimationKey( AnimBone* pAnimBone) } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseDataObjectTextureFilename( std::string& pName) -{ +void XFileParser::ParseDataObjectTextureFilename(std::string &pName) { readHeadOfDataObject(); - GetNextTokenAsString( pName); + GetNextTokenAsString(pName); CheckForClosingBrace(); // FIX: some files (e.g. AnimationTest.x) have "" as texture file name - if (!pName.length()) - { + if (!pName.length()) { ASSIMP_LOG_WARN("Length of texture file name is zero. Skipping this texture."); } // some exporters write double backslash paths out. We simply replace them if we find them - while( pName.find( "\\\\") != std::string::npos) - pName.replace( pName.find( "\\\\"), 2, "\\"); + while (pName.find("\\\\") != std::string::npos) + pName.replace(pName.find("\\\\"), 2, "\\"); } // ------------------------------------------------------------------------------------------------ -void XFileParser::ParseUnknownDataObject() -{ +void XFileParser::ParseUnknownDataObject() { // find opening delimiter bool running = true; - while( running ) - { + while (running) { std::string t = GetNextToken(); - if( t.length() == 0) - ThrowException( "Unexpected end of file while parsing unknown segment."); + if (t.length() == 0) + ThrowException("Unexpected end of file while parsing unknown segment."); - if( t == "{") + if (t == "{") break; } unsigned int counter = 1; // parse until closing delimiter - while( counter > 0) - { + while (counter > 0) { std::string t = GetNextToken(); - if( t.length() == 0) - ThrowException( "Unexpected end of file while parsing unknown segment."); + if (t.length() == 0) + ThrowException("Unexpected end of file while parsing unknown segment."); - if( t == "{") + if (t == "{") ++counter; - else - if( t == "}") + else if (t == "}") --counter; } } // ------------------------------------------------------------------------------------------------ //! checks for closing curly brace -void XFileParser::CheckForClosingBrace() -{ - if( GetNextToken() != "}") - ThrowException( "Closing brace expected."); +void XFileParser::CheckForClosingBrace() { + if (GetNextToken() != "}") + ThrowException("Closing brace expected."); } // ------------------------------------------------------------------------------------------------ //! checks for one following semicolon -void XFileParser::CheckForSemicolon() -{ - if( mIsBinaryFormat) +void XFileParser::CheckForSemicolon() { + if (mIsBinaryFormat) return; - if( GetNextToken() != ";") - ThrowException( "Semicolon expected."); + if (GetNextToken() != ";") + ThrowException("Semicolon expected."); } // ------------------------------------------------------------------------------------------------ //! checks for a separator char, either a ',' or a ';' -void XFileParser::CheckForSeparator() -{ - if( mIsBinaryFormat) +void XFileParser::CheckForSeparator() { + if (mIsBinaryFormat) return; std::string token = GetNextToken(); - if( token != "," && token != ";") - ThrowException( "Separator character (';' or ',') expected."); + if (token != "," && token != ";") + ThrowException("Separator character (';' or ',') expected."); } // ------------------------------------------------------------------------------------------------ // tests and possibly consumes a separator char, but does nothing if there was no separator -void XFileParser::TestForSeparator() -{ - if( mIsBinaryFormat) - return; +void XFileParser::TestForSeparator() { + if (mIsBinaryFormat) + return; - FindNextNoneWhiteSpace(); - if( mP >= mEnd) - return; + FindNextNoneWhiteSpace(); + if (mP >= mEnd) + return; - // test and skip - if( *mP == ';' || *mP == ',') - mP++; + // test and skip + if (*mP == ';' || *mP == ',') + mP++; } // ------------------------------------------------------------------------------------------------ -void XFileParser::readHeadOfDataObject( std::string* poName) -{ +void XFileParser::readHeadOfDataObject(std::string *poName) { std::string nameOrBrace = GetNextToken(); - if( nameOrBrace != "{") - { - if( poName) + if (nameOrBrace != "{") { + if (poName) *poName = nameOrBrace; - if ( GetNextToken() != "{" ) { + if (GetNextToken() != "{") { delete mScene; - ThrowException( "Opening brace expected." ); + ThrowException("Opening brace expected."); } } } @@ -1068,157 +982,151 @@ std::string XFileParser::GetNextToken() { std::string s; // process binary-formatted file - if( mIsBinaryFormat) { + if (mIsBinaryFormat) { // in binary mode it will only return NAME and STRING token // and (correctly) skip over other tokens. - if ( mEnd - mP < 2 ) { + if (mEnd - mP < 2) { return s; } unsigned int tok = ReadBinWord(); unsigned int len; // standalone tokens - switch( tok ) { - case 1: { - // name token - if ( mEnd - mP < 4 ) { - return s; - } - len = ReadBinDWord(); - const int bounds = int( mEnd - mP ); - const int iLen = int( len ); - if ( iLen < 0 ) { - return s; - } - if ( bounds < iLen ) { - return s; - } - s = std::string( mP, len ); - mP += len; + switch (tok) { + case 1: { + // name token + if (mEnd - mP < 4) { + return s; } + len = ReadBinDWord(); + const int bounds = int(mEnd - mP); + const int iLen = int(len); + if (iLen < 0) { + return s; + } + if (bounds < iLen) { + return s; + } + s = std::string(mP, len); + mP += len; + } return s; - case 2: - // string token - if( mEnd - mP < 4) return s; - len = ReadBinDWord(); - if( mEnd - mP < int(len)) return s; - s = std::string(mP, len); - mP += (len + 2); - return s; - case 3: - // integer token - mP += 4; - return ""; - case 5: - // GUID token - mP += 16; - return ""; - case 6: - if( mEnd - mP < 4) return s; - len = ReadBinDWord(); - mP += (len * 4); - return ""; - case 7: - if( mEnd - mP < 4) return s; - len = ReadBinDWord(); - mP += (len * mBinaryFloatSize); - return ""; - case 0x0a: - return "{"; - case 0x0b: - return "}"; - case 0x0c: - return "("; - case 0x0d: - return ")"; - case 0x0e: - return "["; - case 0x0f: - return "]"; - case 0x10: - return "<"; - case 0x11: - return ">"; - case 0x12: - return "."; - case 0x13: - return ","; - case 0x14: - return ";"; - case 0x1f: - return "template"; - case 0x28: - return "WORD"; - case 0x29: - return "DWORD"; - case 0x2a: - return "FLOAT"; - case 0x2b: - return "DOUBLE"; - case 0x2c: - return "CHAR"; - case 0x2d: - return "UCHAR"; - case 0x2e: - return "SWORD"; - case 0x2f: - return "SDWORD"; - case 0x30: - return "void"; - case 0x31: - return "string"; - case 0x32: - return "unicode"; - case 0x33: - return "cstring"; - case 0x34: - return "array"; + case 2: + // string token + if (mEnd - mP < 4) return s; + len = ReadBinDWord(); + if (mEnd - mP < int(len)) return s; + s = std::string(mP, len); + mP += (len + 2); + return s; + case 3: + // integer token + mP += 4; + return ""; + case 5: + // GUID token + mP += 16; + return ""; + case 6: + if (mEnd - mP < 4) return s; + len = ReadBinDWord(); + mP += (len * 4); + return ""; + case 7: + if (mEnd - mP < 4) return s; + len = ReadBinDWord(); + mP += (len * mBinaryFloatSize); + return ""; + case 0x0a: + return "{"; + case 0x0b: + return "}"; + case 0x0c: + return "("; + case 0x0d: + return ")"; + case 0x0e: + return "["; + case 0x0f: + return "]"; + case 0x10: + return "<"; + case 0x11: + return ">"; + case 0x12: + return "."; + case 0x13: + return ","; + case 0x14: + return ";"; + case 0x1f: + return "template"; + case 0x28: + return "WORD"; + case 0x29: + return "DWORD"; + case 0x2a: + return "FLOAT"; + case 0x2b: + return "DOUBLE"; + case 0x2c: + return "CHAR"; + case 0x2d: + return "UCHAR"; + case 0x2e: + return "SWORD"; + case 0x2f: + return "SDWORD"; + case 0x30: + return "void"; + case 0x31: + return "string"; + case 0x32: + return "unicode"; + case 0x33: + return "cstring"; + case 0x34: + return "array"; } } // process text-formatted file - else - { + else { FindNextNoneWhiteSpace(); - if( mP >= mEnd) + if (mP >= mEnd) return s; - while( (mP < mEnd) && !isspace( (unsigned char) *mP)) - { + while ((mP < mEnd) && !isspace((unsigned char)*mP)) { // either keep token delimiters when already holding a token, or return if first valid char - if( *mP == ';' || *mP == '}' || *mP == '{' || *mP == ',') - { - if( !s.size()) - s.append( mP++, 1); + if (*mP == ';' || *mP == '}' || *mP == '{' || *mP == ',') { + if (!s.size()) + s.append(mP++, 1); break; // stop for delimiter } - s.append( mP++, 1); + s.append(mP++, 1); } } return s; } // ------------------------------------------------------------------------------------------------ -void XFileParser::FindNextNoneWhiteSpace() -{ - if( mIsBinaryFormat) +void XFileParser::FindNextNoneWhiteSpace() { + if (mIsBinaryFormat) return; bool running = true; - while( running ) - { - while( mP < mEnd && isspace( (unsigned char) *mP)) - { - if( *mP == '\n') + while (running) { + while (mP < mEnd && isspace((unsigned char)*mP)) { + if (*mP == '\n') mLineNumber++; ++mP; } - if( mP >= mEnd) + if (mP >= mEnd) return; // check if this is a comment - if( (mP[0] == '/' && mP[1] == '/') || mP[0] == '#') + if ((mP[0] == '/' && mP[1] == '/') || mP[0] == '#') ReadUntilEndOfLine(); else break; @@ -1226,52 +1134,48 @@ void XFileParser::FindNextNoneWhiteSpace() } // ------------------------------------------------------------------------------------------------ -void XFileParser::GetNextTokenAsString( std::string& poString) -{ - if( mIsBinaryFormat) - { +void XFileParser::GetNextTokenAsString(std::string &poString) { + if (mIsBinaryFormat) { poString = GetNextToken(); return; } FindNextNoneWhiteSpace(); - if ( mP >= mEnd ) { + if (mP >= mEnd) { delete mScene; - ThrowException( "Unexpected end of file while parsing string" ); + ThrowException("Unexpected end of file while parsing string"); } - if ( *mP != '"' ) { + if (*mP != '"') { delete mScene; - ThrowException( "Expected quotation mark." ); + ThrowException("Expected quotation mark."); } ++mP; - while( mP < mEnd && *mP != '"') - poString.append( mP++, 1); + while (mP < mEnd && *mP != '"') + poString.append(mP++, 1); - if ( mP >= mEnd - 1 ) { + if (mP >= mEnd - 1) { delete mScene; - ThrowException( "Unexpected end of file while parsing string" ); + ThrowException("Unexpected end of file while parsing string"); } - if ( mP[ 1 ] != ';' || mP[ 0 ] != '"' ) { + if (mP[1] != ';' || mP[0] != '"') { delete mScene; - ThrowException( "Expected quotation mark and semicolon at the end of a string." ); + ThrowException("Expected quotation mark and semicolon at the end of a string."); } - mP+=2; + mP += 2; } // ------------------------------------------------------------------------------------------------ -void XFileParser::ReadUntilEndOfLine() -{ - if( mIsBinaryFormat) +void XFileParser::ReadUntilEndOfLine() { + if (mIsBinaryFormat) return; - while( mP < mEnd) - { - if( *mP == '\n' || *mP == '\r') - { - ++mP; mLineNumber++; + while (mP < mEnd) { + if (*mP == '\n' || *mP == '\r') { + ++mP; + mLineNumber++; return; } @@ -1280,10 +1184,9 @@ void XFileParser::ReadUntilEndOfLine() } // ------------------------------------------------------------------------------------------------ -unsigned short XFileParser::ReadBinWord() -{ +unsigned short XFileParser::ReadBinWord() { ai_assert(mEnd - mP >= 2); - const unsigned char* q = (const unsigned char*) mP; + const unsigned char *q = (const unsigned char *)mP; unsigned short tmp = q[0] | (q[1] << 8); mP += 2; return tmp; @@ -1293,57 +1196,51 @@ unsigned short XFileParser::ReadBinWord() unsigned int XFileParser::ReadBinDWord() { ai_assert(mEnd - mP >= 4); - const unsigned char* q = (const unsigned char*) mP; + const unsigned char *q = (const unsigned char *)mP; unsigned int tmp = q[0] | (q[1] << 8) | (q[2] << 16) | (q[3] << 24); mP += 4; return tmp; } // ------------------------------------------------------------------------------------------------ -unsigned int XFileParser::ReadInt() -{ - if( mIsBinaryFormat) - { - if( mBinaryNumCount == 0 && mEnd - mP >= 2) - { +unsigned int XFileParser::ReadInt() { + if (mIsBinaryFormat) { + if (mBinaryNumCount == 0 && mEnd - mP >= 2) { unsigned short tmp = ReadBinWord(); // 0x06 or 0x03 - if( tmp == 0x06 && mEnd - mP >= 4) // array of ints follows + if (tmp == 0x06 && mEnd - mP >= 4) // array of ints follows mBinaryNumCount = ReadBinDWord(); else // single int follows mBinaryNumCount = 1; } --mBinaryNumCount; - const size_t len( mEnd - mP ); - if ( len >= 4) { + const size_t len(mEnd - mP); + if (len >= 4) { return ReadBinDWord(); } else { mP = mEnd; return 0; } - } else - { + } else { FindNextNoneWhiteSpace(); // TODO: consider using strtol10 instead??? // check preceding minus sign bool isNegative = false; - if( *mP == '-') - { + if (*mP == '-') { isNegative = true; mP++; } // at least one digit expected - if( !isdigit( *mP)) - ThrowException( "Number expected."); + if (!isdigit(*mP)) + ThrowException("Number expected."); // read digits unsigned int number = 0; - while( mP < mEnd) - { - if( !isdigit( *mP)) + while (mP < mEnd) { + if (!isdigit(*mP)) break; number = number * 10 + (*mP - 48); mP++; @@ -1351,40 +1248,37 @@ unsigned int XFileParser::ReadInt() CheckForSeparator(); - return isNegative ? ((unsigned int) -int( number)) : number; + return isNegative ? ((unsigned int)-int(number)) : number; } } // ------------------------------------------------------------------------------------------------ -ai_real XFileParser::ReadFloat() -{ - if( mIsBinaryFormat) - { - if( mBinaryNumCount == 0 && mEnd - mP >= 2) - { +ai_real XFileParser::ReadFloat() { + if (mIsBinaryFormat) { + if (mBinaryNumCount == 0 && mEnd - mP >= 2) { unsigned short tmp = ReadBinWord(); // 0x07 or 0x42 - if( tmp == 0x07 && mEnd - mP >= 4) // array of floats following + if (tmp == 0x07 && mEnd - mP >= 4) // array of floats following mBinaryNumCount = ReadBinDWord(); else // single float following mBinaryNumCount = 1; } --mBinaryNumCount; - if( mBinaryFloatSize == 8) { - if( mEnd - mP >= 8) { + if (mBinaryFloatSize == 8) { + if (mEnd - mP >= 8) { double res; - ::memcpy( &res, mP, 8 ); + ::memcpy(&res, mP, 8); mP += 8; - const ai_real result( static_cast( res ) ); + const ai_real result(static_cast(res)); return result; } else { mP = mEnd; return 0; } } else { - if( mEnd - mP >= 4) { + if (mEnd - mP >= 4) { ai_real result; - ::memcpy( &result, mP, 4 ); + ::memcpy(&result, mP, 4); mP += 4; return result; } else { @@ -1399,21 +1293,18 @@ ai_real XFileParser::ReadFloat() // check for various special strings to allow reading files from faulty exporters // I mean you, Blender! // Reading is safe because of the terminating zero - if( strncmp( mP, "-1.#IND00", 9) == 0 || strncmp( mP, "1.#IND00", 8) == 0) - { + if (strncmp(mP, "-1.#IND00", 9) == 0 || strncmp(mP, "1.#IND00", 8) == 0) { mP += 9; CheckForSeparator(); return 0.0; - } else - if( strncmp( mP, "1.#QNAN0", 8) == 0) - { + } else if (strncmp(mP, "1.#QNAN0", 8) == 0) { mP += 8; CheckForSeparator(); return 0.0; } ai_real result = 0.0; - mP = fast_atoreal_move( mP, result); + mP = fast_atoreal_move(mP, result); CheckForSeparator(); @@ -1421,8 +1312,7 @@ ai_real XFileParser::ReadFloat() } // ------------------------------------------------------------------------------------------------ -aiVector2D XFileParser::ReadVector2() -{ +aiVector2D XFileParser::ReadVector2() { aiVector2D vector; vector.x = ReadFloat(); vector.y = ReadFloat(); @@ -1432,8 +1322,7 @@ aiVector2D XFileParser::ReadVector2() } // ------------------------------------------------------------------------------------------------ -aiVector3D XFileParser::ReadVector3() -{ +aiVector3D XFileParser::ReadVector3() { aiVector3D vector; vector.x = ReadFloat(); vector.y = ReadFloat(); @@ -1444,8 +1333,7 @@ aiVector3D XFileParser::ReadVector3() } // ------------------------------------------------------------------------------------------------ -aiColor4D XFileParser::ReadRGBA() -{ +aiColor4D XFileParser::ReadRGBA() { aiColor4D color; color.r = ReadFloat(); color.g = ReadFloat(); @@ -1457,8 +1345,7 @@ aiColor4D XFileParser::ReadRGBA() } // ------------------------------------------------------------------------------------------------ -aiColor3D XFileParser::ReadRGB() -{ +aiColor3D XFileParser::ReadRGB() { aiColor3D color; color.r = ReadFloat(); color.g = ReadFloat(); @@ -1470,29 +1357,26 @@ aiColor3D XFileParser::ReadRGB() // ------------------------------------------------------------------------------------------------ // Throws an exception with a line number and the given text. -AI_WONT_RETURN void XFileParser::ThrowException( const std::string& pText) { - if ( mIsBinaryFormat ) { - throw DeadlyImportError( pText ); +AI_WONT_RETURN void XFileParser::ThrowException(const std::string &pText) { + if (mIsBinaryFormat) { + throw DeadlyImportError(pText); } else { - throw DeadlyImportError( format() << "Line " << mLineNumber << ": " << pText ); + throw DeadlyImportError(format() << "Line " << mLineNumber << ": " << pText); } } // ------------------------------------------------------------------------------------------------ // Filters the imported hierarchy for some degenerated cases that some exporters produce. -void XFileParser::FilterHierarchy( XFile::Node* pNode) -{ +void XFileParser::FilterHierarchy(XFile::Node *pNode) { // if the node has just a single unnamed child containing a mesh, remove // the anonymous node between. The 3DSMax kwXport plugin seems to produce this // mess in some cases - if( pNode->mChildren.size() == 1 && pNode->mMeshes.empty() ) - { - XFile::Node* child = pNode->mChildren.front(); - if( child->mName.length() == 0 && child->mMeshes.size() > 0) - { + if (pNode->mChildren.size() == 1 && pNode->mMeshes.empty()) { + XFile::Node *child = pNode->mChildren.front(); + if (child->mName.length() == 0 && child->mMeshes.size() > 0) { // transfer its meshes to us - for( unsigned int a = 0; a < child->mMeshes.size(); a++) - pNode->mMeshes.push_back( child->mMeshes[a]); + for (unsigned int a = 0; a < child->mMeshes.size(); a++) + pNode->mMeshes.push_back(child->mMeshes[a]); child->mMeshes.clear(); // transfer the transform as well @@ -1505,8 +1389,8 @@ void XFileParser::FilterHierarchy( XFile::Node* pNode) } // recurse - for( unsigned int a = 0; a < pNode->mChildren.size(); a++) - FilterHierarchy( pNode->mChildren[a]); + for (unsigned int a = 0; a < pNode->mChildren.size(); a++) + FilterHierarchy(pNode->mChildren[a]); } #endif // !! ASSIMP_BUILD_NO_X_IMPORTER diff --git a/code/AssetLib/X/XFileParser.h b/code/AssetLib/X/XFileParser.h index ea7aca266..41abe2286 100644 --- a/code/AssetLib/X/XFileParser.h +++ b/code/AssetLib/X/XFileParser.h @@ -104,7 +104,7 @@ protected: //! reads header of data object including the opening brace. //! returns false if error happened, and writes name of object //! if there is one - void readHeadOfDataObject( std::string* poName = NULL); + void readHeadOfDataObject(std::string *poName = nullptr); //! checks for closing curly brace, throws exception if not there void CheckForClosingBrace(); diff --git a/code/AssetLib/X3D/X3DImporter_Shape.cpp b/code/AssetLib/X3D/X3DImporter_Shape.cpp index 189ed145d..a77b0d20c 100644 --- a/code/AssetLib/X3D/X3DImporter_Shape.cpp +++ b/code/AssetLib/X3D/X3DImporter_Shape.cpp @@ -64,8 +64,8 @@ namespace Assimp // A ProtoInstance node (with the proper node type) can be substituted for any node in this content model." // // A Shape node is unlit if either of the following is true: -// The shape's appearance field is NULL (default). -// The material field in the Appearance node is NULL (default). +// The shape's appearance field is nullptr (default). +// The material field in the Appearance node is nullptr (default). // NOTE Geometry nodes that represent lines or points do not support lighting. void X3DImporter::ParseNode_Shape_Shape() { diff --git a/code/AssetLib/XGL/XGLLoader.cpp b/code/AssetLib/XGL/XGLLoader.cpp index 8e4d5c82a..938f2a321 100644 --- a/code/AssetLib/XGL/XGLLoader.cpp +++ b/code/AssetLib/XGL/XGLLoader.cpp @@ -43,18 +43,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Implementation of the XGL/ZGL importer class */ - #ifndef ASSIMP_BUILD_NO_XGL_IMPORTER #include "XGLLoader.h" #include #include -#include #include +#include +#include #include #include -#include #include #include @@ -64,21 +63,20 @@ using namespace irr::io; // zlib is needed for compressed XGL files #ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL -# ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -# else -# include -# endif +#ifdef ASSIMP_BUILD_NO_OWN_ZLIB +#include +#else +#include +#endif #endif - namespace Assimp { // this has to be in here because LogFunctions is in ::Assimp - template<> const char* LogFunctions::Prefix() - { - static auto prefix = "XGL: "; - return prefix; - } +template <> +const char *LogFunctions::Prefix() { + static auto prefix = "XGL: "; + return prefix; } +} // namespace Assimp static const aiImporterDesc desc = { "XGL Importer", @@ -93,12 +91,10 @@ static const aiImporterDesc desc = { "xgl zgl" }; - // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -XGLImporter::XGLImporter() -: m_reader( nullptr ) -, m_scene( nullptr ) { +XGLImporter::XGLImporter() : + m_reader(nullptr), m_scene(nullptr) { // empty } @@ -110,8 +106,7 @@ XGLImporter::~XGLImporter() { // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool XGLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ +bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { /* NOTE: A simple check for the file extension is not enough * here. XGL and ZGL are ok, but xml is too generic * and might be collada as well. So open the file and @@ -121,38 +116,35 @@ bool XGLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool if (extension == "xgl" || extension == "zgl") { return true; - } - else if (extension == "xml" || checkSig) { - ai_assert(pIOHandler != NULL); + } else if (extension == "xml" || checkSig) { + ai_assert(pIOHandler != nullptr); - const char* tokens[] = {"","",""}; - return SearchFileHeaderForToken(pIOHandler,pFile,tokens,3); + const char *tokens[] = { "", "", "" }; + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 3); } return false; } // ------------------------------------------------------------------------------------------------ // Get a list of all file extensions which are handled by this class -const aiImporterDesc* XGLImporter::GetInfo () const -{ +const aiImporterDesc *XGLImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void XGLImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ +void XGLImporter::InternReadFile(const std::string &pFile, + aiScene *pScene, IOSystem *pIOHandler) { #ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL std::vector uncompressed; #endif m_scene = pScene; - std::shared_ptr stream( pIOHandler->Open( pFile, "rb")); + std::shared_ptr stream(pIOHandler->Open(pFile, "rb")); // check whether we can read from the file - if( stream.get() == NULL) { - throw DeadlyImportError( "Failed to open XGL/ZGL file " + pFile + ""); + if (stream.get() == nullptr) { + throw DeadlyImportError("Failed to open XGL/ZGL file " + pFile + ""); } // see if its compressed, if so uncompress it @@ -166,7 +158,7 @@ void XGLImporter::InternReadFile( const std::string& pFile, z_stream zstream; zstream.opaque = Z_NULL; zstream.zalloc = Z_NULL; - zstream.zfree = Z_NULL; + zstream.zfree = Z_NULL; zstream.data_type = Z_BINARY; // raw decompression without a zlib or gzip header @@ -175,14 +167,14 @@ void XGLImporter::InternReadFile( const std::string& pFile, // skip two extra bytes, zgl files do carry a crc16 upfront (I think) raw_reader->IncPtr(2); - zstream.next_in = reinterpret_cast( raw_reader->GetPtr() ); - zstream.avail_in = (uInt) raw_reader->GetRemainingSize(); + zstream.next_in = reinterpret_cast(raw_reader->GetPtr()); + zstream.avail_in = (uInt)raw_reader->GetRemainingSize(); size_t total = 0l; // TODO: be smarter about this, decompress directly into heap buffer // and decompress the data .... do 1k chunks in the hope that we won't kill the stack - #define MYBLOCK 1024 +#define MYBLOCK 1024 Bytef block[MYBLOCK]; int ret; do { @@ -196,51 +188,49 @@ void XGLImporter::InternReadFile( const std::string& pFile, const size_t have = MYBLOCK - zstream.avail_out; total += have; uncompressed.resize(total); - memcpy(uncompressed.data() + total - have,block,have); - } - while (ret != Z_STREAM_END); + memcpy(uncompressed.data() + total - have, block, have); + } while (ret != Z_STREAM_END); // terminate zlib inflateEnd(&zstream); // replace the input stream with a memory stream - stream.reset(new MemoryIOStream(reinterpret_cast(uncompressed.data()),total)); + stream.reset(new MemoryIOStream(reinterpret_cast(uncompressed.data()), total)); #endif } // construct the irrXML parser CIrrXML_IOStreamReader st(stream.get()); - m_reader.reset( createIrrXMLReader( ( IFileReadCallBack* ) &st ) ); + m_reader.reset(createIrrXMLReader((IFileReadCallBack *)&st)); // parse the XML file TempScope scope; - while (ReadElement()) { - if (!ASSIMP_stricmp(m_reader->getNodeName(),"world")) { + while (ReadElement()) { + if (!ASSIMP_stricmp(m_reader->getNodeName(), "world")) { ReadWorld(scope); } } - - std::vector& meshes = scope.meshes_linear; - std::vector& materials = scope.materials_linear; - if(!meshes.size() || !materials.size()) { + std::vector &meshes = scope.meshes_linear; + std::vector &materials = scope.materials_linear; + if (!meshes.size() || !materials.size()) { ThrowException("failed to extract data from XGL file, no meshes loaded"); } // copy meshes m_scene->mNumMeshes = static_cast(meshes.size()); - m_scene->mMeshes = new aiMesh*[m_scene->mNumMeshes](); - std::copy(meshes.begin(),meshes.end(),m_scene->mMeshes); + m_scene->mMeshes = new aiMesh *[m_scene->mNumMeshes](); + std::copy(meshes.begin(), meshes.end(), m_scene->mMeshes); // copy materials m_scene->mNumMaterials = static_cast(materials.size()); - m_scene->mMaterials = new aiMaterial*[m_scene->mNumMaterials](); - std::copy(materials.begin(),materials.end(),m_scene->mMaterials); + m_scene->mMaterials = new aiMaterial *[m_scene->mNumMaterials](); + std::copy(materials.begin(), materials.end(), m_scene->mMaterials); if (scope.light) { m_scene->mNumLights = 1; - m_scene->mLights = new aiLight*[1]; + m_scene->mLights = new aiLight *[1]; m_scene->mLights[0] = scope.light; scope.light->mName = m_scene->mRootNode->mName; @@ -250,9 +240,8 @@ void XGLImporter::InternReadFile( const std::string& pFile, } // ------------------------------------------------------------------------------------------------ -bool XGLImporter::ReadElement() -{ - while(m_reader->read()) { +bool XGLImporter::ReadElement() { + while (m_reader->read()) { if (m_reader->getNodeType() == EXN_ELEMENT) { return true; } @@ -261,13 +250,11 @@ bool XGLImporter::ReadElement() } // ------------------------------------------------------------------------------------------------ -bool XGLImporter::ReadElementUpToClosing(const char* closetag) -{ - while(m_reader->read()) { +bool XGLImporter::ReadElementUpToClosing(const char *closetag) { + while (m_reader->read()) { if (m_reader->getNodeType() == EXN_ELEMENT) { return true; - } - else if (m_reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(m_reader->getNodeName(),closetag)) { + } else if (m_reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(m_reader->getNodeName(), closetag)) { return false; } } @@ -276,13 +263,11 @@ bool XGLImporter::ReadElementUpToClosing(const char* closetag) } // ------------------------------------------------------------------------------------------------ -bool XGLImporter::SkipToText() -{ - while(m_reader->read()) { +bool XGLImporter::SkipToText() { + while (m_reader->read()) { if (m_reader->getNodeType() == EXN_TEXT) { return true; - } - else if (m_reader->getNodeType() == EXN_ELEMENT || m_reader->getNodeType() == EXN_ELEMENT_END) { + } else if (m_reader->getNodeType() == EXN_ELEMENT || m_reader->getNodeType() == EXN_ELEMENT_END) { ThrowException("expected text contents but found another element (or element end)"); } } @@ -290,9 +275,8 @@ bool XGLImporter::SkipToText() } // ------------------------------------------------------------------------------------------------ -std::string XGLImporter::GetElementName() -{ - const char* s = m_reader->getNodeName(); +std::string XGLImporter::GetElementName() { + const char *s = m_reader->getNodeName(); size_t len = strlen(s); std::string ret; @@ -302,26 +286,23 @@ std::string XGLImporter::GetElementName() } // ------------------------------------------------------------------------------------------------ -void XGLImporter::ReadWorld(TempScope& scope) -{ +void XGLImporter::ReadWorld(TempScope &scope) { while (ReadElementUpToClosing("world")) { - const std::string& s = GetElementName(); + const std::string &s = GetElementName(); // XXX right now we'd skip if it comes after // or if (s == "lighting") { ReadLighting(scope); - } - else if (s == "object" || s == "mesh" || s == "mat") { + } else if (s == "object" || s == "mesh" || s == "mat") { break; } } - - aiNode* const nd = ReadObject(scope,true,"world"); - if(!nd) { + aiNode *const nd = ReadObject(scope, true, "world"); + if (!nd) { ThrowException("failure reading "); } - if(!nd->mName.length) { + if (!nd->mName.length) { nd->mName.Set("WORLD"); } @@ -329,37 +310,31 @@ void XGLImporter::ReadWorld(TempScope& scope) } // ------------------------------------------------------------------------------------------------ -void XGLImporter::ReadLighting(TempScope& scope) -{ - while (ReadElementUpToClosing("lighting")) { - const std::string& s = GetElementName(); +void XGLImporter::ReadLighting(TempScope &scope) { + while (ReadElementUpToClosing("lighting")) { + const std::string &s = GetElementName(); if (s == "directionallight") { scope.light = ReadDirectionalLight(); - } - else if (s == "ambient") { + } else if (s == "ambient") { LogWarn("ignoring tag"); - } - else if (s == "spheremap") { + } else if (s == "spheremap") { LogWarn("ignoring tag"); } } } // ------------------------------------------------------------------------------------------------ -aiLight* XGLImporter::ReadDirectionalLight() -{ +aiLight *XGLImporter::ReadDirectionalLight() { std::unique_ptr l(new aiLight()); l->mType = aiLightSource_DIRECTIONAL; - while (ReadElementUpToClosing("directionallight")) { - const std::string& s = GetElementName(); + while (ReadElementUpToClosing("directionallight")) { + const std::string &s = GetElementName(); if (s == "direction") { l->mDirection = ReadVec3(); - } - else if (s == "diffuse") { + } else if (s == "diffuse") { l->mColorDiffuse = ReadCol3(); - } - else if (s == "specular") { + } else if (s == "specular") { l->mColorSpecular = ReadCol3(); } } @@ -367,49 +342,44 @@ aiLight* XGLImporter::ReadDirectionalLight() } // ------------------------------------------------------------------------------------------------ -aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* closetag) -{ +aiNode *XGLImporter::ReadObject(TempScope &scope, bool skipFirst, const char *closetag) { aiNode *nd = new aiNode; - std::vector children; + std::vector children; std::vector meshes; try { - while (skipFirst || ReadElementUpToClosing(closetag)) { + while (skipFirst || ReadElementUpToClosing(closetag)) { skipFirst = false; - const std::string& s = GetElementName(); + const std::string &s = GetElementName(); if (s == "mesh") { const size_t prev = scope.meshes_linear.size(); - if(ReadMesh(scope)) { + if (ReadMesh(scope)) { const size_t newc = scope.meshes_linear.size(); - for(size_t i = 0; i < newc-prev; ++i) { - meshes.push_back(static_cast(i+prev)); + for (size_t i = 0; i < newc - prev; ++i) { + meshes.push_back(static_cast(i + prev)); } } - } - else if (s == "mat") { + } else if (s == "mat") { ReadMaterial(scope); - } - else if (s == "object") { + } else if (s == "object") { children.push_back(ReadObject(scope)); - } - else if (s == "objectref") { + } else if (s == "objectref") { // XXX - } - else if (s == "meshref") { - const unsigned int id = static_cast( ReadIndexFromText() ); + } else if (s == "meshref") { + const unsigned int id = static_cast(ReadIndexFromText()); - std::multimap::iterator it = scope.meshes.find(id), end = scope.meshes.end(); + std::multimap::iterator it = scope.meshes.find(id), end = scope.meshes.end(); if (it == end) { ThrowException(" index out of range"); } - for(; it != end && (*it).first == id; ++it) { + for (; it != end && (*it).first == id; ++it) { // ok, this is n^2 and should get optimized one day - aiMesh* const m = (*it).second; + aiMesh *const m = (*it).second; unsigned int i = 0, mcount = static_cast(scope.meshes_linear.size()); - for(; i < mcount; ++i) { + for (; i < mcount; ++i) { if (scope.meshes_linear[i] == m) { meshes.push_back(i); break; @@ -418,14 +388,13 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl ai_assert(i < mcount); } - } - else if (s == "transform") { + } else if (s == "transform") { nd->mTransformation = ReadTrafo(); } } - } catch(...) { - for(aiNode* ch : children) { + } catch (...) { + for (aiNode *ch : children) { delete ch; } throw; @@ -441,7 +410,7 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl nd->mNumMeshes = static_cast(meshes.size()); if (nd->mNumMeshes) { nd->mMeshes = new unsigned int[nd->mNumMeshes](); - for(unsigned int i = 0; i < nd->mNumMeshes; ++i) { + for (unsigned int i = 0; i < nd->mNumMeshes; ++i) { nd->mMeshes[i] = meshes[i]; } } @@ -449,8 +418,8 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl // link children to parent nd->mNumChildren = static_cast(children.size()); if (nd->mNumChildren) { - nd->mChildren = new aiNode*[nd->mNumChildren](); - for(unsigned int i = 0; i < nd->mNumChildren; ++i) { + nd->mChildren = new aiNode *[nd->mNumChildren](); + for (unsigned int i = 0; i < nd->mNumChildren; ++i) { nd->mChildren[i] = children[i]; children[i]->mParent = nd; } @@ -460,25 +429,22 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl } // ------------------------------------------------------------------------------------------------ -aiMatrix4x4 XGLImporter::ReadTrafo() -{ +aiMatrix4x4 XGLImporter::ReadTrafo() { aiVector3D forward, up, right, position; float scale = 1.0f; while (ReadElementUpToClosing("transform")) { - const std::string& s = GetElementName(); + const std::string &s = GetElementName(); if (s == "forward") { forward = ReadVec3(); - } - else if (s == "up") { + } else if (s == "up") { up = ReadVec3(); - } - else if (s == "position") { + } else if (s == "position") { position = ReadVec3(); } if (s == "scale") { scale = ReadFloat(); - if(scale < 0.f) { + if (scale < 0.f) { // this is wrong, but we can leave the value and pass it to the caller LogError("found negative scaling in , ignoring"); } @@ -486,7 +452,7 @@ aiMatrix4x4 XGLImporter::ReadTrafo() } aiMatrix4x4 m; - if(forward.SquareLength() < 1e-4 || up.SquareLength() < 1e-4) { + if (forward.SquareLength() < 1e-4 || up.SquareLength() < 1e-4) { LogError("A direction vector in is zero, ignoring trafo"); return m; } @@ -526,37 +492,36 @@ aiMatrix4x4 XGLImporter::ReadTrafo() } // ------------------------------------------------------------------------------------------------ -aiMesh* XGLImporter::ToOutputMesh(const TempMaterialMesh& m) -{ +aiMesh *XGLImporter::ToOutputMesh(const TempMaterialMesh &m) { std::unique_ptr mesh(new aiMesh()); mesh->mNumVertices = static_cast(m.positions.size()); mesh->mVertices = new aiVector3D[mesh->mNumVertices]; - std::copy(m.positions.begin(),m.positions.end(),mesh->mVertices); + std::copy(m.positions.begin(), m.positions.end(), mesh->mVertices); - if(m.normals.size()) { + if (m.normals.size()) { mesh->mNormals = new aiVector3D[mesh->mNumVertices]; - std::copy(m.normals.begin(),m.normals.end(),mesh->mNormals); + std::copy(m.normals.begin(), m.normals.end(), mesh->mNormals); } - if(m.uvs.size()) { + if (m.uvs.size()) { mesh->mNumUVComponents[0] = 2; mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices]; - for(unsigned int i = 0; i < mesh->mNumVertices; ++i) { - mesh->mTextureCoords[0][i] = aiVector3D(m.uvs[i].x,m.uvs[i].y,0.f); + for (unsigned int i = 0; i < mesh->mNumVertices; ++i) { + mesh->mTextureCoords[0][i] = aiVector3D(m.uvs[i].x, m.uvs[i].y, 0.f); } } - mesh->mNumFaces = static_cast(m.vcounts.size()); + mesh->mNumFaces = static_cast(m.vcounts.size()); mesh->mFaces = new aiFace[m.vcounts.size()]; unsigned int idx = 0; - for(unsigned int i = 0; i < mesh->mNumFaces; ++i) { - aiFace& f = mesh->mFaces[i]; + for (unsigned int i = 0; i < mesh->mNumFaces; ++i) { + aiFace &f = mesh->mFaces[i]; f.mNumIndices = m.vcounts[i]; f.mIndices = new unsigned int[f.mNumIndices]; - for(unsigned int c = 0; c < f.mNumIndices; ++c) { + for (unsigned int c = 0; c < f.mNumIndices; ++c) { f.mIndices[c] = idx++; } } @@ -569,57 +534,49 @@ aiMesh* XGLImporter::ToOutputMesh(const TempMaterialMesh& m) } // ------------------------------------------------------------------------------------------------ -bool XGLImporter::ReadMesh(TempScope& scope) -{ +bool XGLImporter::ReadMesh(TempScope &scope) { TempMesh t; std::map bymat; const unsigned int mesh_id = ReadIDAttr(); - while (ReadElementUpToClosing("mesh")) { - const std::string& s = GetElementName(); + while (ReadElementUpToClosing("mesh")) { + const std::string &s = GetElementName(); if (s == "mat") { ReadMaterial(scope); - } - else if (s == "p") { + } else if (s == "p") { if (!m_reader->getAttributeValue("ID")) { LogWarn("no ID attribute on

, ignoring"); - } - else { + } else { int id = m_reader->getAttributeValueAsInt("ID"); t.points[id] = ReadVec3(); } - } - else if (s == "n") { + } else if (s == "n") { if (!m_reader->getAttributeValue("ID")) { LogWarn("no ID attribute on , ignoring"); - } - else { + } else { int id = m_reader->getAttributeValueAsInt("ID"); t.normals[id] = ReadVec3(); } - } - else if (s == "tc") { + } else if (s == "tc") { if (!m_reader->getAttributeValue("ID")) { LogWarn("no ID attribute on , ignoring"); - } - else { + } else { int id = m_reader->getAttributeValueAsInt("ID"); t.uvs[id] = ReadVec2(); } - } - else if (s == "f" || s == "l" || s == "p") { + } else if (s == "f" || s == "l" || s == "p") { const unsigned int vcount = s == "f" ? 3 : (s == "l" ? 2 : 1); unsigned int mid = ~0u; TempFace tf[3]; - bool has[3] = {0}; + bool has[3] = { 0 }; - while (ReadElementUpToClosing(s.c_str())) { - const std::string& elemName = GetElementName(); + while (ReadElementUpToClosing(s.c_str())) { + const std::string &elemName = GetElementName(); if (elemName == "fv1" || elemName == "lv1" || elemName == "pv1") { - ReadFaceVertex(t,tf[0]); + ReadFaceVertex(t, tf[0]); has[0] = true; } else if (elemName == "fv2" || elemName == "lv2") { ReadFaceVertex(t, tf[1]); @@ -646,7 +603,7 @@ bool XGLImporter::ReadMesh(TempScope& scope) bool nor = false; bool uv = false; - for(unsigned int i = 0; i < vcount; ++i) { + for (unsigned int i = 0; i < vcount; ++i) { if (!has[i]) { ThrowException("missing face vertex data"); } @@ -655,24 +612,24 @@ bool XGLImporter::ReadMesh(TempScope& scope) uv = uv || tf[i].has_uv; } - if (mid >= (1<<30)) { + if (mid >= (1 << 30)) { LogWarn("material indices exhausted, this may cause errors in the output"); } - unsigned int meshId = mid | ((nor?1:0)<<31) | ((uv?1:0)<<30); + unsigned int meshId = mid | ((nor ? 1 : 0) << 31) | ((uv ? 1 : 0) << 30); - TempMaterialMesh& mesh = bymat[meshId]; + TempMaterialMesh &mesh = bymat[meshId]; mesh.matid = mid; - for(unsigned int i = 0; i < vcount; ++i) { + for (unsigned int i = 0; i < vcount; ++i) { mesh.positions.push_back(tf[i].pos); - if(nor) { + if (nor) { mesh.normals.push_back(tf[i].normal); } - if(uv) { + if (uv) { mesh.uvs.push_back(tf[i].uv); } - mesh.pflags |= 1 << (vcount-1); + mesh.pflags |= 1 << (vcount - 1); } mesh.vcounts.push_back(vcount); @@ -681,13 +638,13 @@ bool XGLImporter::ReadMesh(TempScope& scope) // finally extract output meshes and add them to the scope typedef std::pair pairt; - for(const pairt& p : bymat) { - aiMesh* const m = ToOutputMesh(p.second); + for (const pairt &p : bymat) { + aiMesh *const m = ToOutputMesh(p.second); scope.meshes_linear.push_back(m); // if this is a definition, keep it on the stack - if(mesh_id != ~0u) { - scope.meshes.insert(std::pair(mesh_id,m)); + if (mesh_id != ~0u) { + scope.meshes.insert(std::pair(mesh_id, m)); } } @@ -696,26 +653,25 @@ bool XGLImporter::ReadMesh(TempScope& scope) } // ---------------------------------------------------------------------------------------------- -unsigned int XGLImporter::ResolveMaterialRef(TempScope& scope) -{ - const std::string& s = GetElementName(); +unsigned int XGLImporter::ResolveMaterialRef(TempScope &scope) { + const std::string &s = GetElementName(); if (s == "mat") { ReadMaterial(scope); - return static_cast(scope.materials_linear.size()-1); + return static_cast(scope.materials_linear.size() - 1); } const int id = ReadIndexFromText(); - std::map::iterator it = scope.materials.find(id), end = scope.materials.end(); + std::map::iterator it = scope.materials.find(id), end = scope.materials.end(); if (it == end) { ThrowException(" index out of range"); } // ok, this is n^2 and should get optimized one day - aiMaterial* const m = (*it).second; + aiMaterial *const m = (*it).second; unsigned int i = 0, mcount = static_cast(scope.materials_linear.size()); - for(; i < mcount; ++i) { + for (; i < mcount; ++i) { if (scope.materials_linear[i] == m) { return i; } @@ -726,35 +682,30 @@ unsigned int XGLImporter::ResolveMaterialRef(TempScope& scope) } // ------------------------------------------------------------------------------------------------ -void XGLImporter::ReadMaterial(TempScope& scope) { +void XGLImporter::ReadMaterial(TempScope &scope) { const unsigned int mat_id = ReadIDAttr(); - aiMaterial *mat(new aiMaterial ); - while (ReadElementUpToClosing("mat")) { - const std::string& s = GetElementName(); + aiMaterial *mat(new aiMaterial); + while (ReadElementUpToClosing("mat")) { + const std::string &s = GetElementName(); if (s == "amb") { const aiColor3D c = ReadCol3(); - mat->AddProperty(&c,1,AI_MATKEY_COLOR_AMBIENT); - } - else if (s == "diff") { + mat->AddProperty(&c, 1, AI_MATKEY_COLOR_AMBIENT); + } else if (s == "diff") { const aiColor3D c = ReadCol3(); - mat->AddProperty(&c,1,AI_MATKEY_COLOR_DIFFUSE); - } - else if (s == "spec") { + mat->AddProperty(&c, 1, AI_MATKEY_COLOR_DIFFUSE); + } else if (s == "spec") { const aiColor3D c = ReadCol3(); - mat->AddProperty(&c,1,AI_MATKEY_COLOR_SPECULAR); - } - else if (s == "emiss") { + mat->AddProperty(&c, 1, AI_MATKEY_COLOR_SPECULAR); + } else if (s == "emiss") { const aiColor3D c = ReadCol3(); - mat->AddProperty(&c,1,AI_MATKEY_COLOR_EMISSIVE); - } - else if (s == "alpha") { + mat->AddProperty(&c, 1, AI_MATKEY_COLOR_EMISSIVE); + } else if (s == "alpha") { const float f = ReadFloat(); - mat->AddProperty(&f,1,AI_MATKEY_OPACITY); - } - else if (s == "shine") { + mat->AddProperty(&f, 1, AI_MATKEY_OPACITY); + } else if (s == "shine") { const float f = ReadFloat(); - mat->AddProperty(&f,1,AI_MATKEY_SHININESS); + mat->AddProperty(&f, 1, AI_MATKEY_SHININESS); } } @@ -763,13 +714,12 @@ void XGLImporter::ReadMaterial(TempScope& scope) { } // ---------------------------------------------------------------------------------------------- -void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out) -{ - const std::string& end = GetElementName(); +void XGLImporter::ReadFaceVertex(const TempMesh &t, TempFace &out) { + const std::string &end = GetElementName(); bool havep = false; - while (ReadElementUpToClosing(end.c_str())) { - const std::string& s = GetElementName(); + while (ReadElementUpToClosing(end.c_str())) { + const std::string &s = GetElementName(); if (s == "pref") { const unsigned int id = ReadIndexFromText(); std::map::const_iterator it = t.points.find(id); @@ -779,8 +729,7 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out) out.pos = (*it).second; havep = true; - } - else if (s == "nref") { + } else if (s == "nref") { const unsigned int id = ReadIndexFromText(); std::map::const_iterator it = t.normals.find(id); if (it == t.normals.end()) { @@ -789,8 +738,7 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out) out.normal = (*it).second; out.has_normal = true; - } - else if (s == "tcref") { + } else if (s == "tcref") { const unsigned int id = ReadIndexFromText(); std::map::const_iterator it = t.uvs.find(id); if (it == t.uvs.end()) { @@ -799,14 +747,11 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out) out.uv = (*it).second; out.has_uv = true; - } - else if (s == "p") { + } else if (s == "p") { out.pos = ReadVec3(); - } - else if (s == "n") { + } else if (s == "n") { out.normal = ReadVec3(); - } - else if (s == "tc") { + } else if (s == "tc") { out.uv = ReadVec2(); } } @@ -817,11 +762,10 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out) } // ------------------------------------------------------------------------------------------------ -unsigned int XGLImporter::ReadIDAttr() -{ - for(int i = 0, e = m_reader->getAttributeCount(); i < e; ++i) { +unsigned int XGLImporter::ReadIDAttr() { + for (int i = 0, e = m_reader->getAttributeCount(); i < e; ++i) { - if(!ASSIMP_stricmp(m_reader->getAttributeName(i),"id")) { + if (!ASSIMP_stricmp(m_reader->getAttributeName(i), "id")) { return m_reader->getAttributeValueAsInt(i); } } @@ -829,21 +773,20 @@ unsigned int XGLImporter::ReadIDAttr() } // ------------------------------------------------------------------------------------------------ -float XGLImporter::ReadFloat() -{ - if(!SkipToText()) { +float XGLImporter::ReadFloat() { + if (!SkipToText()) { LogError("unexpected EOF reading float element contents"); return 0.f; } - const char* s = m_reader->getNodeData(), *se; + const char *s = m_reader->getNodeData(), *se; - if(!SkipSpaces(&s)) { + if (!SkipSpaces(&s)) { LogError("unexpected EOL, failed to parse float"); return 0.f; } float t; - se = fast_atoreal_move(s,t); + se = fast_atoreal_move(s, t); if (se == s) { LogError("failed to read float text"); @@ -854,19 +797,18 @@ float XGLImporter::ReadFloat() } // ------------------------------------------------------------------------------------------------ -unsigned int XGLImporter::ReadIndexFromText() -{ - if(!SkipToText()) { +unsigned int XGLImporter::ReadIndexFromText() { + if (!SkipToText()) { LogError("unexpected EOF reading index element contents"); return ~0u; } - const char* s = m_reader->getNodeData(), *se; - if(!SkipSpaces(&s)) { + const char *s = m_reader->getNodeData(), *se; + if (!SkipSpaces(&s)) { LogError("unexpected EOL, failed to parse index element"); return ~0u; } - const unsigned int t = strtoul10(s,&se); + const unsigned int t = strtoul10(s, &se); if (se == s) { LogError("failed to read index"); @@ -877,23 +819,22 @@ unsigned int XGLImporter::ReadIndexFromText() } // ------------------------------------------------------------------------------------------------ -aiVector2D XGLImporter::ReadVec2() -{ +aiVector2D XGLImporter::ReadVec2() { aiVector2D vec; - if(!SkipToText()) { + if (!SkipToText()) { LogError("unexpected EOF reading vec2 contents"); return vec; } - const char* s = m_reader->getNodeData(); + const char *s = m_reader->getNodeData(); ai_real v[2]; - for(int i = 0; i < 2; ++i) { - if(!SkipSpaces(&s)) { + for (int i = 0; i < 2; ++i) { + if (!SkipSpaces(&s)) { LogError("unexpected EOL, failed to parse vec2"); return vec; } - + v[i] = fast_atof(&s); SkipSpaces(&s); @@ -903,25 +844,24 @@ aiVector2D XGLImporter::ReadVec2() } ++s; } - vec.x = v[0]; - vec.y = v[1]; + vec.x = v[0]; + vec.y = v[1]; return vec; } // ------------------------------------------------------------------------------------------------ -aiVector3D XGLImporter::ReadVec3() -{ +aiVector3D XGLImporter::ReadVec3() { aiVector3D vec; - if(!SkipToText()) { + if (!SkipToText()) { LogError("unexpected EOF reading vec3 contents"); return vec; } - const char* s = m_reader->getNodeData(); + const char *s = m_reader->getNodeData(); - for(int i = 0; i < 3; ++i) { - if(!SkipSpaces(&s)) { + for (int i = 0; i < 3; ++i) { + if (!SkipSpaces(&s)) { LogError("unexpected EOL, failed to parse vec3"); return vec; } @@ -939,13 +879,12 @@ aiVector3D XGLImporter::ReadVec3() } // ------------------------------------------------------------------------------------------------ -aiColor3D XGLImporter::ReadCol3() -{ - const aiVector3D& v = ReadVec3(); +aiColor3D XGLImporter::ReadCol3() { + const aiVector3D &v = ReadVec3(); if (v.x < 0.f || v.x > 1.0f || v.y < 0.f || v.y > 1.0f || v.z < 0.f || v.z > 1.0f) { LogWarn("color values out of range, ignoring"); } - return aiColor3D(v.x,v.y,v.z); + return aiColor3D(v.x, v.y, v.z); } #endif diff --git a/code/AssetLib/XGL/XGLLoader.h b/code/AssetLib/XGL/XGLLoader.h index f227c5f0f..bf699541f 100644 --- a/code/AssetLib/XGL/XGLLoader.h +++ b/code/AssetLib/XGL/XGLLoader.h @@ -47,69 +47,59 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_XGLLOADER_H_INCLUDED #include -#include #include -#include -#include -#include +#include #include -#include +#include +#include +#include #include +#include struct aiNode; -namespace Assimp { +namespace Assimp { // --------------------------------------------------------------------------- /** XGL/ZGL importer. * * Spec: http://vizstream.aveva.com/release/vsplatform/XGLSpec.htm */ -class XGLImporter : public BaseImporter, public LogFunctions -{ +class XGLImporter : public BaseImporter, public LogFunctions { public: - XGLImporter(); ~XGLImporter(); - public: - // ------------------------------------------------------------------- /** Returns whether the class can handle the format of the given file. * See BaseImporter::CanRead() for details. */ - bool CanRead( const std::string& pFile, IOSystem* pIOHandler, - bool checkSig) const; + bool CanRead(const std::string &pFile, IOSystem *pIOHandler, + bool checkSig) const; protected: - // ------------------------------------------------------------------- /** Return importer meta information. * See #BaseImporter::GetInfo for the details */ - const aiImporterDesc* GetInfo () const; + const aiImporterDesc *GetInfo() const; // ------------------------------------------------------------------- /** Imports the given file into the given scene structure. * See BaseImporter::InternReadFile() for details */ - void InternReadFile( const std::string& pFile, aiScene* pScene, - IOSystem* pIOHandler); + void InternReadFile(const std::string &pFile, aiScene *pScene, + IOSystem *pIOHandler); private: + struct TempScope { + TempScope() : + light() {} - - struct TempScope - { - TempScope() - : light() - {} - - ~TempScope() - { - for(aiMesh* m : meshes_linear) { + ~TempScope() { + for (aiMesh *m : meshes_linear) { delete m; } - for(aiMaterial* m : materials_linear) { + for (aiMaterial *m : materials_linear) { delete m; } @@ -117,45 +107,41 @@ private: } void dismiss() { - light = NULL; + light = nullptr; meshes_linear.clear(); materials_linear.clear(); meshes.clear(); materials.clear(); } - std::multimap meshes; - std::map materials; + std::multimap meshes; + std::map materials; - std::vector meshes_linear; - std::vector materials_linear; + std::vector meshes_linear; + std::vector materials_linear; - aiLight* light; + aiLight *light; }; - struct SortMeshByMaterialId { - SortMeshByMaterialId(const TempScope& scope) : scope(scope) {} + SortMeshByMaterialId(const TempScope &scope) : + scope(scope) {} bool operator()(unsigned int a, unsigned int b) const { return scope.meshes_linear[a]->mMaterialIndex < scope.meshes_linear[b]->mMaterialIndex; }; - const TempScope& scope; + const TempScope &scope; }; - struct TempMesh - { + struct TempMesh { std::map points; std::map normals; std::map uvs; }; - struct TempMaterialMesh - { - TempMaterialMesh() - : pflags() - , matid() - {} + struct TempMaterialMesh { + TempMaterialMesh() : + pflags(), matid() {} std::vector positions, normals; std::vector uvs; @@ -165,12 +151,9 @@ private: unsigned int matid; }; - struct TempFace - { - TempFace() - : has_uv() - , has_normal() - {} + struct TempFace { + TempFace() : + has_uv(), has_normal() {} aiVector3D pos; aiVector3D normal; @@ -180,21 +163,20 @@ private: }; private: - void Cleanup(); std::string GetElementName(); bool ReadElement(); - bool ReadElementUpToClosing(const char* closetag); + bool ReadElementUpToClosing(const char *closetag); bool SkipToText(); unsigned int ReadIDAttr(); - void ReadWorld(TempScope& scope); - void ReadLighting(TempScope& scope); - aiLight* ReadDirectionalLight(); - aiNode* ReadObject(TempScope& scope,bool skipFirst = false,const char* closetag = "object"); - bool ReadMesh(TempScope& scope); - void ReadMaterial(TempScope& scope); + void ReadWorld(TempScope &scope); + void ReadLighting(TempScope &scope); + aiLight *ReadDirectionalLight(); + aiNode *ReadObject(TempScope &scope, bool skipFirst = false, const char *closetag = "object"); + bool ReadMesh(TempScope &scope); + void ReadMaterial(TempScope &scope); aiVector2D ReadVec2(); aiVector3D ReadVec3(); aiColor3D ReadCol3(); @@ -202,13 +184,13 @@ private: unsigned int ReadIndexFromText(); float ReadFloat(); - aiMesh* ToOutputMesh(const TempMaterialMesh& m); - void ReadFaceVertex(const TempMesh& t, TempFace& out); - unsigned int ResolveMaterialRef(TempScope& scope); + aiMesh *ToOutputMesh(const TempMaterialMesh &m); + void ReadFaceVertex(const TempMesh &t, TempFace &out); + unsigned int ResolveMaterialRef(TempScope &scope); private: std::shared_ptr m_reader; - aiScene* m_scene; + aiScene *m_scene; }; } // end of namespace Assimp diff --git a/code/AssetLib/glTF/glTFAsset.h b/code/AssetLib/glTF/glTFAsset.h index f24e35a16..d6d1dd372 100644 --- a/code/AssetLib/glTF/glTFAsset.h +++ b/code/AssetLib/glTF/glTFAsset.h @@ -1,10 +1,9 @@ -/* +/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -61,11 +60,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifndef RAPIDJSON_HAS_STDSTRING #define RAPIDJSON_HAS_STDSTRING 1 +#endif + +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + +#ifndef RAPIDJSON_NOMEMBERITERATORCLASS +#define RAPIDJSON_NOMEMBERITERATORCLASS +#endif + #include #include #include +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic pop +#endif + #ifdef ASSIMP_API # include # include diff --git a/code/AssetLib/glTF/glTFAssetWriter.inl b/code/AssetLib/glTF/glTFAssetWriter.inl index 5e4416ee9..d8d2556fa 100644 --- a/code/AssetLib/glTF/glTFAssetWriter.inl +++ b/code/AssetLib/glTF/glTFAssetWriter.inl @@ -59,7 +59,7 @@ namespace glTF { namespace { template - inline + inline Value& MakeValue(Value& val, T(&r)[N], MemoryPoolAllocator<>& al) { val.SetArray(); val.Reserve(N, al); @@ -70,7 +70,7 @@ namespace glTF { } template - inline + inline Value& MakeValue(Value& val, const std::vector & r, MemoryPoolAllocator<>& al) { val.SetArray(); val.Reserve(static_cast(r.size()), al); @@ -530,7 +530,9 @@ namespace glTF { StringBuffer docBuffer; PrettyWriter writer(docBuffer); - mDoc.Accept(writer); + if (!mDoc.Accept(writer)) { + throw DeadlyExportError("Failed to write scene data!"); + } if (jsonOutFile->Write(docBuffer.GetString(), docBuffer.GetSize(), 1) != 1) { throw DeadlyExportError("Failed to write scene data!"); @@ -569,7 +571,9 @@ namespace glTF { StringBuffer docBuffer; Writer writer(docBuffer); - mDoc.Accept(writer); + if (!mDoc.Accept(writer)) { + throw DeadlyExportError("Failed to write scene data!"); + } if (outfile->Write(docBuffer.GetString(), docBuffer.GetSize(), 1) != 1) { throw DeadlyExportError("Failed to write scene data!"); diff --git a/code/AssetLib/glTF/glTFCommon.cpp b/code/AssetLib/glTF/glTFCommon.cpp index e0ce4fed8..2c46a46e3 100644 --- a/code/AssetLib/glTF/glTFCommon.cpp +++ b/code/AssetLib/glTF/glTFCommon.cpp @@ -145,13 +145,13 @@ bool ParseDataURI(const char *const_uri, size_t uriLen, DataURI &out) { size_t i = 5, j; if (uri[i] != ';' && uri[i] != ',') { // has media type? uri[1] = char(i); - for (; uri[i] != ';' && uri[i] != ',' && i < uriLen; ++i) { + for (;i < uriLen && uri[i] != ';' && uri[i] != ','; ++i) { // nothing to do! } } - while (uri[i] == ';' && i < uriLen) { + while (i < uriLen && uri[i] == ';') { uri[i++] = '\0'; - for (j = i; uri[i] != ';' && uri[i] != ',' && i < uriLen; ++i) { + for (j = i; i < uriLen && uri[i] != ';' && uri[i] != ','; ++i) { // nothing to do! } diff --git a/code/AssetLib/glTF/glTFCommon.h b/code/AssetLib/glTF/glTFCommon.h index d161e8cd6..b151918b6 100644 --- a/code/AssetLib/glTF/glTFCommon.h +++ b/code/AssetLib/glTF/glTFCommon.h @@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #define RAPIDJSON_HAS_STDSTRING 1 +#define RAPIDJSON_NOMEMBERITERATORCLASS #include #include #include diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp index 57207e8c7..b85affc08 100644 --- a/code/AssetLib/glTF/glTFExporter.cpp +++ b/code/AssetLib/glTF/glTFExporter.cpp @@ -1,4 +1,4 @@ -/* +/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- @@ -348,7 +348,7 @@ void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& pr if (path[0] == '*') { // embedded aiTexture* curTex = mScene->mTextures[atoi(&path[1])]; - + prop.texture->source->name = curTex->mFilename.C_Str(); uint8_t *data = reinterpret_cast(curTex->pcData); diff --git a/code/AssetLib/glTF/glTFImporter.cpp b/code/AssetLib/glTF/glTFImporter.cpp index 32ce8b227..b4ef9b06f 100644 --- a/code/AssetLib/glTF/glTFImporter.cpp +++ b/code/AssetLib/glTF/glTFImporter.cpp @@ -1,4 +1,4 @@ -/* +/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- @@ -48,12 +48,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include -#include #include -#include -#include #include +#include +#include +#include +#include #include @@ -69,8 +69,7 @@ static const aiImporterDesc desc = { "", "", "", - aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour - | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental, + aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental, 0, 0, 0, @@ -78,11 +77,8 @@ static const aiImporterDesc desc = { "gltf glb" }; -glTFImporter::glTFImporter() -: BaseImporter() -, meshOffsets() -, embeddedTexIdxs() -, mScene( nullptr ) { +glTFImporter::glTFImporter() : + BaseImporter(), meshOffsets(), embeddedTexIdxs(), mScene(nullptr) { // empty } @@ -90,11 +86,11 @@ glTFImporter::~glTFImporter() { // empty } -const aiImporterDesc* glTFImporter::GetInfo() const { +const aiImporterDesc *glTFImporter::GetInfo() const { return &desc; } -bool glTFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool /* checkSig */) const { +bool glTFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /* checkSig */) const { const std::string &extension = GetExtension(pFile); if (extension != "gltf" && extension != "glb") { @@ -115,9 +111,8 @@ bool glTFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool return false; } -inline -void SetMaterialColorProperty(std::vector& embeddedTexIdxs, Asset& /*r*/, glTF::TexProperty prop, aiMaterial* mat, - aiTextureType texType, const char* pKey, unsigned int type, unsigned int idx) { +inline void SetMaterialColorProperty(std::vector &embeddedTexIdxs, Asset & /*r*/, glTF::TexProperty prop, aiMaterial *mat, + aiTextureType texType, const char *pKey, unsigned int type, unsigned int idx) { if (prop.texture) { if (prop.texture->source) { aiString uri(prop.texture->source->uri); @@ -138,22 +133,22 @@ void SetMaterialColorProperty(std::vector& embeddedTexIdxs, Asset& /*r*/, g } } -void glTFImporter::ImportMaterials(glTF::Asset& r) { +void glTFImporter::ImportMaterials(glTF::Asset &r) { mScene->mNumMaterials = unsigned(r.materials.Size()); - mScene->mMaterials = new aiMaterial*[mScene->mNumMaterials]; + mScene->mMaterials = new aiMaterial *[mScene->mNumMaterials]; for (unsigned int i = 0; i < mScene->mNumMaterials; ++i) { - aiMaterial* aimat = mScene->mMaterials[i] = new aiMaterial(); + aiMaterial *aimat = mScene->mMaterials[i] = new aiMaterial(); - Material& mat = r.materials[i]; + Material &mat = r.materials[i]; /*if (!mat.name.empty())*/ { aiString str(mat.id /*mat.name*/); aimat->AddProperty(&str, AI_MATKEY_NAME); } - SetMaterialColorProperty(embeddedTexIdxs, r, mat.ambient, aimat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT ); - SetMaterialColorProperty(embeddedTexIdxs, r, mat.diffuse, aimat, aiTextureType_DIFFUSE, AI_MATKEY_COLOR_DIFFUSE ); + SetMaterialColorProperty(embeddedTexIdxs, r, mat.ambient, aimat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT); + SetMaterialColorProperty(embeddedTexIdxs, r, mat.diffuse, aimat, aiTextureType_DIFFUSE, AI_MATKEY_COLOR_DIFFUSE); SetMaterialColorProperty(embeddedTexIdxs, r, mat.specular, aimat, aiTextureType_SPECULAR, AI_MATKEY_COLOR_SPECULAR); SetMaterialColorProperty(embeddedTexIdxs, r, mat.emission, aimat, aiTextureType_EMISSIVE, AI_MATKEY_COLOR_EMISSIVE); @@ -172,29 +167,25 @@ void glTFImporter::ImportMaterials(glTF::Asset& r) { mScene->mNumMaterials = 1; // Delete the array of length zero created above. delete[] mScene->mMaterials; - mScene->mMaterials = new aiMaterial*[1]; + mScene->mMaterials = new aiMaterial *[1]; mScene->mMaterials[0] = new aiMaterial(); } } - -static inline void SetFace(aiFace& face, int a) -{ +static inline void SetFace(aiFace &face, int a) { face.mNumIndices = 1; face.mIndices = new unsigned int[1]; face.mIndices[0] = a; } -static inline void SetFace(aiFace& face, int a, int b) -{ +static inline void SetFace(aiFace &face, int a, int b) { face.mNumIndices = 2; face.mIndices = new unsigned int[2]; face.mIndices[0] = a; face.mIndices[1] = b; } -static inline void SetFace(aiFace& face, int a, int b, int c) -{ +static inline void SetFace(aiFace &face, int a, int b, int c) { face.mNumIndices = 3; face.mIndices = new unsigned int[3]; face.mIndices[0] = a; @@ -202,9 +193,7 @@ static inline void SetFace(aiFace& face, int a, int b, int c) face.mIndices[2] = c; } -#ifdef ASSIMP_BUILD_DEBUG -static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsigned nVerts) -{ +static inline bool CheckValidFacesIndices(aiFace *faces, unsigned nFaces, unsigned nVerts) { for (unsigned i = 0; i < nFaces; ++i) { for (unsigned j = 0; j < faces[i].mNumIndices; ++j) { unsigned idx = faces[i].mIndices[j]; @@ -214,105 +203,98 @@ static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsign } return true; } -#endif // ASSIMP_BUILD_DEBUG -void glTFImporter::ImportMeshes(glTF::Asset& r) -{ - std::vector meshes; +void glTFImporter::ImportMeshes(glTF::Asset &r) { + std::vector meshes; unsigned int k = 0; meshOffsets.clear(); for (unsigned int m = 0; m < r.meshes.Size(); ++m) { - Mesh& mesh = r.meshes[m]; + Mesh &mesh = r.meshes[m]; - // Check if mesh extensions is used - if(mesh.Extension.size() > 0) - { - for(Mesh::SExtension* cur_ext : mesh.Extension) - { + // Check if mesh extensions is used + if (mesh.Extension.size() > 0) { + for (Mesh::SExtension *cur_ext : mesh.Extension) { #ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC - if(cur_ext->Type == Mesh::SExtension::EType::Compression_Open3DGC) - { - // Limitations for meshes when using Open3DGC-compression. - // It's a current limitation of sp... Specification have not this part still - about mesh compression. Why only one primitive? - // Because glTF is very flexibly. But in fact it ugly flexible. Every primitive can has own set of accessors and accessors can - // point to a-a-a-a-any part of buffer (through bufferview of course) and even to another buffer. We know that "Open3DGC-compression" - // is applicable only to part of buffer. As we can't guaranty continuity of the data for decoder, we will limit quantity of primitives. - // Yes indices, coordinates etc. still can br stored in different buffers, but with current specification it's a exporter problem. - // Also primitive can has only one of "POSITION", "NORMAL" and less then "AI_MAX_NUMBER_OF_TEXTURECOORDS" of "TEXCOORD". All accessor - // of primitive must point to one continuous region of the buffer. - if(mesh.primitives.size() > 2) throw DeadlyImportError("GLTF: When using Open3DGC compression then only one primitive per mesh are allowed."); + if (cur_ext->Type == Mesh::SExtension::EType::Compression_Open3DGC) { + // Limitations for meshes when using Open3DGC-compression. + // It's a current limitation of sp... Specification have not this part still - about mesh compression. Why only one primitive? + // Because glTF is very flexibly. But in fact it ugly flexible. Every primitive can has own set of accessors and accessors can + // point to a-a-a-a-any part of buffer (through bufferview of course) and even to another buffer. We know that "Open3DGC-compression" + // is applicable only to part of buffer. As we can't guaranty continuity of the data for decoder, we will limit quantity of primitives. + // Yes indices, coordinates etc. still can br stored in different buffers, but with current specification it's a exporter problem. + // Also primitive can has only one of "POSITION", "NORMAL" and less then "AI_MAX_NUMBER_OF_TEXTURECOORDS" of "TEXCOORD". All accessor + // of primitive must point to one continuous region of the buffer. + if (mesh.primitives.size() > 2) throw DeadlyImportError("GLTF: When using Open3DGC compression then only one primitive per mesh are allowed."); - Mesh::SCompression_Open3DGC* o3dgc_ext = (Mesh::SCompression_Open3DGC*)cur_ext; - Ref buf = r.buffers.Get(o3dgc_ext->Buffer); + Mesh::SCompression_Open3DGC *o3dgc_ext = (Mesh::SCompression_Open3DGC *)cur_ext; + Ref buf = r.buffers.Get(o3dgc_ext->Buffer); - buf->EncodedRegion_SetCurrent(mesh.id); - } - else + buf->EncodedRegion_SetCurrent(mesh.id); + } else #endif - { - throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + to_string(cur_ext->Type) + - "\"), only Open3DGC is supported."); - } - } - }// if(mesh.Extension.size() > 0) + { + throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + to_string(cur_ext->Type) + + "\"), only Open3DGC is supported."); + } + } + } // if(mesh.Extension.size() > 0) - meshOffsets.push_back(k); + meshOffsets.push_back(k); k += unsigned(mesh.primitives.size()); for (unsigned int p = 0; p < mesh.primitives.size(); ++p) { - Mesh::Primitive& prim = mesh.primitives[p]; + Mesh::Primitive &prim = mesh.primitives[p]; - aiMesh* aim = new aiMesh(); + aiMesh *aim = new aiMesh(); meshes.push_back(aim); aim->mName = mesh.id; if (mesh.primitives.size() > 1) { - ai_uint32& len = aim->mName.length; + ai_uint32 &len = aim->mName.length; aim->mName.data[len] = '-'; len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(MAXLEN - len - 1), p); } switch (prim.mode) { - case PrimitiveMode_POINTS: - aim->mPrimitiveTypes |= aiPrimitiveType_POINT; - break; + case PrimitiveMode_POINTS: + aim->mPrimitiveTypes |= aiPrimitiveType_POINT; + break; - case PrimitiveMode_LINES: - case PrimitiveMode_LINE_LOOP: - case PrimitiveMode_LINE_STRIP: - aim->mPrimitiveTypes |= aiPrimitiveType_LINE; - break; + case PrimitiveMode_LINES: + case PrimitiveMode_LINE_LOOP: + case PrimitiveMode_LINE_STRIP: + aim->mPrimitiveTypes |= aiPrimitiveType_LINE; + break; - case PrimitiveMode_TRIANGLES: - case PrimitiveMode_TRIANGLE_STRIP: - case PrimitiveMode_TRIANGLE_FAN: - aim->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE; - break; + case PrimitiveMode_TRIANGLES: + case PrimitiveMode_TRIANGLE_STRIP: + case PrimitiveMode_TRIANGLE_FAN: + aim->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE; + break; } - Mesh::Primitive::Attributes& attr = prim.attributes; + Mesh::Primitive::Attributes &attr = prim.attributes; - if (attr.position.size() > 0 && attr.position[0]) { + if (attr.position.size() > 0 && attr.position[0]) { aim->mNumVertices = attr.position[0]->count; attr.position[0]->ExtractData(aim->mVertices); - } + } - if (attr.normal.size() > 0 && attr.normal[0]) attr.normal[0]->ExtractData(aim->mNormals); + if (attr.normal.size() > 0 && attr.normal[0]) attr.normal[0]->ExtractData(aim->mNormals); for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) { attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]); aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents(); - aiVector3D* values = aim->mTextureCoords[tc]; + aiVector3D *values = aim->mTextureCoords[tc]; for (unsigned int i = 0; i < aim->mNumVertices; ++i) { values[i].y = 1 - values[i].y; // Flip Y coords } } - - aiFace* faces = 0; + aiFace *faces = 0; unsigned int nFaces = 0; if (prim.indices) { @@ -322,76 +304,75 @@ void glTFImporter::ImportMeshes(glTF::Asset& r) ai_assert(data.IsValid()); switch (prim.mode) { - case PrimitiveMode_POINTS: { - nFaces = count; - faces = new aiFace[nFaces]; - for (unsigned int i = 0; i < count; ++i) { - SetFace(faces[i], data.GetUInt(i)); - } - break; + case PrimitiveMode_POINTS: { + nFaces = count; + faces = new aiFace[nFaces]; + for (unsigned int i = 0; i < count; ++i) { + SetFace(faces[i], data.GetUInt(i)); } - - case PrimitiveMode_LINES: { - nFaces = count / 2; - if (nFaces * 2 != count) { - ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped."); - count = nFaces * 2; - } - faces = new aiFace[nFaces]; - for (unsigned int i = 0; i < count; i += 2) { - SetFace(faces[i / 2], data.GetUInt(i), data.GetUInt(i + 1)); - } - break; - } - - case PrimitiveMode_LINE_LOOP: - case PrimitiveMode_LINE_STRIP: { - nFaces = count - ((prim.mode == PrimitiveMode_LINE_STRIP) ? 1 : 0); - faces = new aiFace[nFaces]; - SetFace(faces[0], data.GetUInt(0), data.GetUInt(1)); - for (unsigned int i = 2; i < count; ++i) { - SetFace(faces[i - 1], faces[i - 2].mIndices[1], data.GetUInt(i)); - } - if (prim.mode == PrimitiveMode_LINE_LOOP) { // close the loop - SetFace(faces[count - 1], faces[count - 2].mIndices[1], faces[0].mIndices[0]); - } - break; - } - - case PrimitiveMode_TRIANGLES: { - nFaces = count / 3; - if (nFaces * 3 != count) { - ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped."); - count = nFaces * 3; - } - faces = new aiFace[nFaces]; - for (unsigned int i = 0; i < count; i += 3) { - SetFace(faces[i / 3], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2)); - } - break; - } - case PrimitiveMode_TRIANGLE_STRIP: { - nFaces = count - 2; - faces = new aiFace[nFaces]; - SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2)); - for (unsigned int i = 3; i < count; ++i) { - SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], data.GetUInt(i)); - } - break; - } - case PrimitiveMode_TRIANGLE_FAN: - nFaces = count - 2; - faces = new aiFace[nFaces]; - SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2)); - for (unsigned int i = 3; i < count; ++i) { - SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i)); - } - break; + break; } - } - else { // no indices provided so directly generate from counts - // use the already determined count as it includes checks + case PrimitiveMode_LINES: { + nFaces = count / 2; + if (nFaces * 2 != count) { + ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped."); + count = nFaces * 2; + } + faces = new aiFace[nFaces]; + for (unsigned int i = 0; i < count; i += 2) { + SetFace(faces[i / 2], data.GetUInt(i), data.GetUInt(i + 1)); + } + break; + } + + case PrimitiveMode_LINE_LOOP: + case PrimitiveMode_LINE_STRIP: { + nFaces = count - ((prim.mode == PrimitiveMode_LINE_STRIP) ? 1 : 0); + faces = new aiFace[nFaces]; + SetFace(faces[0], data.GetUInt(0), data.GetUInt(1)); + for (unsigned int i = 2; i < count; ++i) { + SetFace(faces[i - 1], faces[i - 2].mIndices[1], data.GetUInt(i)); + } + if (prim.mode == PrimitiveMode_LINE_LOOP) { // close the loop + SetFace(faces[count - 1], faces[count - 2].mIndices[1], faces[0].mIndices[0]); + } + break; + } + + case PrimitiveMode_TRIANGLES: { + nFaces = count / 3; + if (nFaces * 3 != count) { + ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped."); + count = nFaces * 3; + } + faces = new aiFace[nFaces]; + for (unsigned int i = 0; i < count; i += 3) { + SetFace(faces[i / 3], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2)); + } + break; + } + case PrimitiveMode_TRIANGLE_STRIP: { + nFaces = count - 2; + faces = new aiFace[nFaces]; + SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2)); + for (unsigned int i = 3; i < count; ++i) { + SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], data.GetUInt(i)); + } + break; + } + case PrimitiveMode_TRIANGLE_FAN: + nFaces = count - 2; + faces = new aiFace[nFaces]; + SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2)); + for (unsigned int i = 3; i < count; ++i) { + SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i)); + } + break; + } + } else { // no indices provided so directly generate from counts + + // use the already determined count as it includes checks unsigned int count = aim->mNumVertices; switch (prim.mode) { @@ -466,7 +447,11 @@ void glTFImporter::ImportMeshes(glTF::Asset& r) if (faces) { aim->mFaces = faces; aim->mNumFaces = nFaces; - ai_assert(CheckValidFacesIndices(faces, nFaces, aim->mNumVertices)); + const bool validRes = CheckValidFacesIndices(faces, nFaces, aim->mNumVertices); + if (!validRes) { + ai_assert(validRes); + ASSIMP_LOG_WARN("Invalid number of faces detected."); + } } if (prim.material) { @@ -480,22 +465,22 @@ void glTFImporter::ImportMeshes(glTF::Asset& r) CopyVector(meshes, mScene->mMeshes, mScene->mNumMeshes); } -void glTFImporter::ImportCameras(glTF::Asset& r) { +void glTFImporter::ImportCameras(glTF::Asset &r) { if (!r.cameras.Size()) { return; } mScene->mNumCameras = r.cameras.Size(); - mScene->mCameras = new aiCamera*[r.cameras.Size()]; + mScene->mCameras = new aiCamera *[r.cameras.Size()]; for (size_t i = 0; i < r.cameras.Size(); ++i) { - Camera& cam = r.cameras[i]; + Camera &cam = r.cameras[i]; - aiCamera* aicam = mScene->mCameras[i] = new aiCamera(); + aiCamera *aicam = mScene->mCameras[i] = new aiCamera(); if (cam.type == Camera::Perspective) { - aicam->mAspect = cam.perspective.aspectRatio; + aicam->mAspect = cam.perspective.aspectRatio; aicam->mHorizontalFOV = cam.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect); - aicam->mClipPlaneFar = cam.perspective.zfar; + aicam->mClipPlaneFar = cam.perspective.zfar; aicam->mClipPlaneNear = cam.perspective.znear; } else { aicam->mClipPlaneFar = cam.ortographic.zfar; @@ -509,30 +494,33 @@ void glTFImporter::ImportCameras(glTF::Asset& r) { } } -void glTFImporter::ImportLights(glTF::Asset& r) -{ +void glTFImporter::ImportLights(glTF::Asset &r) { if (!r.lights.Size()) return; mScene->mNumLights = r.lights.Size(); - mScene->mLights = new aiLight*[r.lights.Size()]; + mScene->mLights = new aiLight *[r.lights.Size()]; for (size_t i = 0; i < r.lights.Size(); ++i) { - Light& l = r.lights[i]; + Light &l = r.lights[i]; - aiLight* ail = mScene->mLights[i] = new aiLight(); + aiLight *ail = mScene->mLights[i] = new aiLight(); switch (l.type) { - case Light::Type_directional: - ail->mType = aiLightSource_DIRECTIONAL; break; + case Light::Type_directional: + ail->mType = aiLightSource_DIRECTIONAL; + break; - case Light::Type_spot: - ail->mType = aiLightSource_SPOT; break; + case Light::Type_spot: + ail->mType = aiLightSource_SPOT; + break; - case Light::Type_ambient: - ail->mType = aiLightSource_AMBIENT; break; + case Light::Type_ambient: + ail->mType = aiLightSource_AMBIENT; + break; - default: // Light::Type_point - ail->mType = aiLightSource_POINT; break; + default: // Light::Type_point + ail->mType = aiLightSource_POINT; + break; } CopyValue(l.color, ail->mColorAmbient); @@ -542,35 +530,32 @@ void glTFImporter::ImportLights(glTF::Asset& r) ail->mAngleOuterCone = l.falloffAngle; ail->mAngleInnerCone = l.falloffExponent; // TODO fix this, it does not look right at all - ail->mAttenuationConstant = l.constantAttenuation; - ail->mAttenuationLinear = l.linearAttenuation; + ail->mAttenuationConstant = l.constantAttenuation; + ail->mAttenuationLinear = l.linearAttenuation; ail->mAttenuationQuadratic = l.quadraticAttenuation; } } +aiNode *ImportNode(aiScene *pScene, glTF::Asset &r, std::vector &meshOffsets, glTF::Ref &ptr) { + Node &node = *ptr; -aiNode* ImportNode(aiScene* pScene, glTF::Asset& r, std::vector& meshOffsets, glTF::Ref& ptr) -{ - Node& node = *ptr; - - aiNode* ainode = new aiNode(node.id); + aiNode *ainode = new aiNode(node.id); if (!node.children.empty()) { ainode->mNumChildren = unsigned(node.children.size()); - ainode->mChildren = new aiNode*[ainode->mNumChildren]; + ainode->mChildren = new aiNode *[ainode->mNumChildren]; for (unsigned int i = 0; i < ainode->mNumChildren; ++i) { - aiNode* child = ImportNode(pScene, r, meshOffsets, node.children[i]); + aiNode *child = ImportNode(pScene, r, meshOffsets, node.children[i]); child->mParent = ainode; ainode->mChildren[i] = child; } } - aiMatrix4x4& matrix = ainode->mTransformation; + aiMatrix4x4 &matrix = ainode->mTransformation; if (node.matrix.isPresent) { CopyValue(node.matrix.value, matrix); - } - else { + } else { if (node.translation.isPresent) { aiVector3D trans; CopyValue(node.translation.value, trans); @@ -587,7 +572,6 @@ aiNode* ImportNode(aiScene* pScene, glTF::Asset& r, std::vector& m matrix = s * matrix; } - if (node.rotation.isPresent) { aiQuaternion rot; CopyValue(node.rotation.value, rot); @@ -625,22 +609,20 @@ aiNode* ImportNode(aiScene* pScene, glTF::Asset& r, std::vector& m return ainode; } -void glTFImporter::ImportNodes(glTF::Asset& r) -{ +void glTFImporter::ImportNodes(glTF::Asset &r) { if (!r.scene) return; - std::vector< Ref > rootNodes = r.scene->nodes; + std::vector> rootNodes = r.scene->nodes; // The root nodes unsigned int numRootNodes = unsigned(rootNodes.size()); if (numRootNodes == 1) { // a single root node: use it mScene->mRootNode = ImportNode(mScene, r, meshOffsets, rootNodes[0]); - } - else if (numRootNodes > 1) { // more than one root node: create a fake root - aiNode* root = new aiNode("ROOT"); - root->mChildren = new aiNode*[numRootNodes]; + } else if (numRootNodes > 1) { // more than one root node: create a fake root + aiNode *root = new aiNode("ROOT"); + root->mChildren = new aiNode *[numRootNodes]; for (unsigned int i = 0; i < numRootNodes; ++i) { - aiNode* node = ImportNode(mScene, r, meshOffsets, rootNodes[i]); + aiNode *node = ImportNode(mScene, r, meshOffsets, rootNodes[i]); node->mParent = root; root->mChildren[root->mNumChildren++] = node; } @@ -652,8 +634,7 @@ void glTFImporter::ImportNodes(glTF::Asset& r) //} } -void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r) -{ +void glTFImporter::ImportEmbeddedTextures(glTF::Asset &r) { embeddedTexIdxs.resize(r.images.Size(), -1); int numEmbeddedTexs = 0; @@ -665,7 +646,7 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r) if (numEmbeddedTexs == 0) return; - mScene->mTextures = new aiTexture*[numEmbeddedTexs]; + mScene->mTextures = new aiTexture *[numEmbeddedTexs]; // Add the embedded textures for (size_t i = 0; i < r.images.Size(); ++i) { @@ -675,18 +656,18 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r) int idx = mScene->mNumTextures++; embeddedTexIdxs[i] = idx; - aiTexture* tex = mScene->mTextures[idx] = new aiTexture(); + aiTexture *tex = mScene->mTextures[idx] = new aiTexture(); size_t length = img.GetDataLength(); - void* data = img.StealData(); + void *data = img.StealData(); tex->mFilename = img.name; tex->mWidth = static_cast(length); tex->mHeight = 0; - tex->pcData = reinterpret_cast(data); + tex->pcData = reinterpret_cast(data); if (!img.mimeType.empty()) { - const char* ext = strchr(img.mimeType.c_str(), '/') + 1; + const char *ext = strchr(img.mimeType.c_str(), '/') + 1; if (ext) { if (strcmp(ext, "jpeg") == 0) ext = "jpg"; @@ -699,32 +680,26 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r) } } -void glTFImporter::ImportCommonMetadata(glTF::Asset& a) -{ +void glTFImporter::ImportCommonMetadata(glTF::Asset &a) { ai_assert(mScene->mMetaData == nullptr); const bool hasVersion = !a.asset.version.empty(); const bool hasGenerator = !a.asset.generator.empty(); const bool hasCopyright = !a.asset.copyright.empty(); - if (hasVersion || hasGenerator || hasCopyright) - { + if (hasVersion || hasGenerator || hasCopyright) { mScene->mMetaData = new aiMetadata; - if (hasVersion) - { + if (hasVersion) { mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version)); } - if (hasGenerator) - { + if (hasGenerator) { mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator)); } - if (hasCopyright) - { + if (hasCopyright) { mScene->mMetaData->Add(AI_METADATA_SOURCE_COPYRIGHT, aiString(a.asset.copyright)); } } } -void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) -{ +void glTFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { // clean all member arrays meshOffsets.clear(); embeddedTexIdxs.clear(); @@ -735,7 +710,6 @@ void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOS glTF::Asset asset(pIOHandler); asset.Load(pFile, GetExtension(pFile) == "glb"); - // // Copy the data out // @@ -757,4 +731,3 @@ void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOS } #endif // ASSIMP_BUILD_NO_GLTF_IMPORTER - diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index 48dab24a7..f79ddee87 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -63,11 +62,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifndef RAPIDJSON_HAS_STDSTRING #define RAPIDJSON_HAS_STDSTRING 1 +#endif + +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + +#ifndef RAPIDJSON_NOMEMBERITERATORCLASS +#define RAPIDJSON_NOMEMBERITERATORCLASS +#endif + #include #include #include +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic pop +#endif + #ifdef ASSIMP_API #include #include @@ -175,19 +190,19 @@ enum ComponentType { inline unsigned int ComponentTypeSize(ComponentType t) { switch (t) { - case ComponentType_SHORT: - case ComponentType_UNSIGNED_SHORT: - return 2; + case ComponentType_SHORT: + case ComponentType_UNSIGNED_SHORT: + return 2; - case ComponentType_UNSIGNED_INT: - case ComponentType_FLOAT: - return 4; + case ComponentType_UNSIGNED_INT: + case ComponentType_FLOAT: + return 4; - case ComponentType_BYTE: - case ComponentType_UNSIGNED_BYTE: - return 1; - default: - throw DeadlyImportError("GLTF: Unsupported Component Type " + to_string(t)); + case ComponentType_BYTE: + case ComponentType_UNSIGNED_BYTE: + return 1; + default: + throw DeadlyImportError("GLTF: Unsupported Component Type " + to_string(t)); } } @@ -318,9 +333,11 @@ class Ref { public: Ref() : - vector(0), index(0) {} + vector(0), + index(0) {} Ref(std::vector &vec, unsigned int idx) : - vector(&vec), index(idx) {} + vector(&vec), + index(idx) {} inline unsigned int GetIndex() const { return index; } @@ -340,7 +357,8 @@ struct Nullable { Nullable() : isPresent(false) {} Nullable(T &val) : - value(val), isPresent(true) {} + value(val), + isPresent(true) {} }; //! Base class for all glTF top-level objects @@ -367,6 +385,8 @@ struct Object { //! An accessor provides a typed view into a BufferView or a subset of a BufferView //! similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer. struct Accessor : public Object { + struct Sparse; + Ref bufferView; //!< The ID of the bufferView. (required) size_t byteOffset; //!< The offset relative to the start of the bufferView in bytes. (required) ComponentType componentType; //!< The datatype of components in the attribute. (required) @@ -374,6 +394,7 @@ struct Accessor : public Object { AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required) std::vector max; //!< Maximum value of each component in this attribute. std::vector min; //!< Minimum value of each component in this attribute. + std::unique_ptr sparse; unsigned int GetNumComponents(); unsigned int GetBytesPerComponent(); @@ -381,7 +402,7 @@ struct Accessor : public Object { inline uint8_t *GetPointer(); - template + template void ExtractData(T *&outData); void WriteData(size_t count, const void *src_buffer, size_t src_stride); @@ -390,8 +411,8 @@ struct Accessor : public Object { class Indexer { friend struct Accessor; - // This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is: - // ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field] + // This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is: + // ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field] protected: Accessor &accessor; @@ -400,8 +421,7 @@ struct Accessor : public Object { size_t elemSize, stride; Indexer(Accessor &acc); - - + public: //! Accesses the i-th value as defined by the accessor template @@ -423,6 +443,21 @@ struct Accessor : public Object { Accessor() {} void Read(Value &obj, Asset &r); + + //sparse + struct Sparse { + size_t count; + ComponentType indicesType; + Ref indices; + size_t indicesByteOffset; + Ref values; + size_t valuesByteOffset; + + std::vector data; //!< Actual data, which may be defaulted to an array of zeros or the original data, with the sparse buffer view applied on top of it. + + void PopulateData(size_t numBytes, uint8_t *bytes); + void PatchData(unsigned int elementSize); + }; }; //! A buffer points to binary geometry, animation, or skins. @@ -451,7 +486,11 @@ public: /// \param [in] pDecodedData_Length - size of encoded region, in bytes. /// \param [in] pID - ID of the region. SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string pID) : - Offset(pOffset), EncodedData_Length(pEncodedData_Length), DecodedData(pDecodedData), DecodedData_Length(pDecodedData_Length), ID(pID) {} + Offset(pOffset), + EncodedData_Length(pEncodedData_Length), + DecodedData(pDecodedData), + DecodedData_Length(pDecodedData_Length), + ID(pID) {} /// \fn ~SEncodedRegion() /// Destructor. @@ -555,6 +594,7 @@ struct BufferView : public Object { BufferViewTarget target; //! The target that the WebGL buffer should be bound to. void Read(Value &obj, Asset &r); + uint8_t *GetPointer(size_t accOffset); }; struct Camera : public Object { @@ -582,7 +622,8 @@ struct Camera : public Object { } cameraProperties; Camera() : - type(Perspective), cameraProperties() { + type(Perspective), + cameraProperties() { // empty } void Read(Value &obj, Asset &r); @@ -743,6 +784,50 @@ struct Mesh : public Object { void Read(Value &pJSON_Object, Asset &pAsset_Root); }; +struct CustomExtension : public Object { + // + // A struct containing custom extension data added to a glTF2 file + // Has to contain Object, Array, String, Double, Uint64, and Int64 at a minimum + // String, Double, Uint64, and Int64 are stored in the Nullables + // Object and Array are stored in the std::vector + // + + Nullable mStringValue; + Nullable mDoubleValue; + Nullable mUint64Value; + Nullable mInt64Value; + Nullable mBoolValue; + + // std::vector handles both Object and Array + Nullable> mValues; + + operator bool() const { + return Size(); + } + + size_t Size() const { + if (mValues.isPresent) { + return mValues.value.size(); + } else if (mStringValue.isPresent || mDoubleValue.isPresent || mUint64Value.isPresent || mInt64Value.isPresent || mBoolValue.isPresent) { + return 1; + } + return 0; + } + + CustomExtension() = default; + + CustomExtension(const CustomExtension& other) + : Object(other) + , mStringValue(other.mStringValue) + , mDoubleValue(other.mDoubleValue) + , mUint64Value(other.mUint64Value) + , mInt64Value(other.mInt64Value) + , mBoolValue(other.mBoolValue) + , mValues(other.mValues) + { + } +}; + struct Node : public Object { std::vector> children; std::vector> meshes; @@ -761,6 +846,8 @@ struct Node : public Object { Ref parent; //!< This is not part of the glTF specification. Used as a helper. + CustomExtension extensions; + Node() {} void Read(Value &obj, Asset &r); }; @@ -887,7 +974,7 @@ class LazyDict : public LazyDictBase { Value *mDict; //! JSON dictionary object Asset &mAsset; //! The asset instance - std::gltf_unordered_set mRecursiveReferenceCheck; //! Used by Retrieve to prevent recursive lookups + std::gltf_unordered_set mRecursiveReferenceCheck; //! Used by Retrieve to prevent recursive lookups void AttachToDocument(Document &doc); void DetachFromDocument(); @@ -1001,7 +1088,22 @@ public: public: Asset(IOSystem *io = 0) : - mIOSystem(io), asset(), accessors(*this, "accessors"), animations(*this, "animations"), buffers(*this, "buffers"), bufferViews(*this, "bufferViews"), cameras(*this, "cameras"), lights(*this, "lights", "KHR_lights_punctual"), images(*this, "images"), materials(*this, "materials"), meshes(*this, "meshes"), nodes(*this, "nodes"), samplers(*this, "samplers"), scenes(*this, "scenes"), skins(*this, "skins"), textures(*this, "textures") { + mIOSystem(io), + asset(), + accessors(*this, "accessors"), + animations(*this, "animations"), + buffers(*this, "buffers"), + bufferViews(*this, "bufferViews"), + cameras(*this, "cameras"), + lights(*this, "lights", "KHR_lights_punctual"), + images(*this, "images"), + materials(*this, "materials"), + meshes(*this, "meshes"), + nodes(*this, "nodes"), + samplers(*this, "samplers"), + scenes(*this, "scenes"), + skins(*this, "skins"), + textures(*this, "textures") { memset(&extensionsUsed, 0, sizeof(extensionsUsed)); memset(&extensionsRequired, 0, sizeof(extensionsRequired)); } diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index 0c99d059b..94f8d9ffa 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -180,7 +180,10 @@ inline Value *FindObject(Value &val, const char *id) { template inline LazyDict::LazyDict(Asset &asset, const char *dictId, const char *extId) : - mDictId(dictId), mExtId(extId), mDict(0), mAsset(asset) { + mDictId(dictId), + mExtId(extId), + mDict(0), + mAsset(asset) { asset.mDicts.push_back(this); // register to the list of dictionaries } @@ -342,7 +345,10 @@ Ref LazyDict::Create(const char *id) { // inline Buffer::Buffer() : - byteLength(0), type(Type_arraybuffer), EncodedRegion_Current(nullptr), mIsSpecial(false) {} + byteLength(0), + type(Type_arraybuffer), + EncodedRegion_Current(nullptr), + mIsSpecial(false) {} inline Buffer::~Buffer() { for (SEncodedRegion *reg : EncodedRegion_List) @@ -517,7 +523,7 @@ inline void Buffer::Grow(size_t amount) { if (amount <= 0) { return; } - + // Capacity is big enough if (capacity >= byteLength + amount) { byteLength += amount; @@ -550,9 +556,63 @@ inline void BufferView::Read(Value &obj, Asset &r) { byteStride = MemberOrDefault(obj, "byteStride", 0u); } +inline uint8_t *BufferView::GetPointer(size_t accOffset) { + if (!buffer) return 0; + uint8_t *basePtr = buffer->GetPointer(); + if (!basePtr) return 0; + + size_t offset = accOffset + byteOffset; + if (buffer->EncodedRegion_Current != nullptr) { + const size_t begin = buffer->EncodedRegion_Current->Offset; + const size_t end = begin + buffer->EncodedRegion_Current->DecodedData_Length; + if ((offset >= begin) && (offset < end)) + return &buffer->EncodedRegion_Current->DecodedData[offset - begin]; + } + + return basePtr + offset; +} + // // struct Accessor // +inline void Accessor::Sparse::PopulateData(size_t numBytes, uint8_t *bytes) { + if (bytes) { + data.assign(bytes, bytes + numBytes); + } else { + data.resize(numBytes, 0x00); + } +} + +inline void Accessor::Sparse::PatchData(unsigned int elementSize) { + uint8_t *pIndices = indices->GetPointer(indicesByteOffset); + const unsigned int indexSize = int(ComponentTypeSize(indicesType)); + uint8_t *indicesEnd = pIndices + count * indexSize; + + uint8_t *pValues = values->GetPointer(valuesByteOffset); + while (pIndices != indicesEnd) { + size_t offset; + switch (indicesType) { + case ComponentType_UNSIGNED_BYTE: + offset = *pIndices; + break; + case ComponentType_UNSIGNED_SHORT: + offset = *reinterpret_cast(pIndices); + break; + case ComponentType_UNSIGNED_INT: + offset = *reinterpret_cast(pIndices); + break; + default: + // have fun with float and negative values from signed types as indices. + throw DeadlyImportError("Unsupported component type in index."); + } + + offset *= elementSize; + std::memcpy(data.data() + offset, pValues, elementSize); + + pValues += elementSize; + pIndices += indexSize; + } +} inline void Accessor::Read(Value &obj, Asset &r) { @@ -566,6 +626,42 @@ inline void Accessor::Read(Value &obj, Asset &r) { const char *typestr; type = ReadMember(obj, "type", typestr) ? AttribType::FromString(typestr) : AttribType::SCALAR; + + if (Value *sparseValue = FindObject(obj, "sparse")) { + sparse.reset(new Sparse); + // count + ReadMember(*sparseValue, "count", sparse->count); + + // indices + if (Value *indicesValue = FindObject(*sparseValue, "indices")) { + //indices bufferView + Value *indiceViewID = FindUInt(*indicesValue, "bufferView"); + sparse->indices = r.bufferViews.Retrieve(indiceViewID->GetUint()); + //indices byteOffset + sparse->indicesByteOffset = MemberOrDefault(*indicesValue, "byteOffset", size_t(0)); + //indices componentType + sparse->indicesType = MemberOrDefault(*indicesValue, "componentType", ComponentType_BYTE); + //sparse->indices->Read(*indicesValue, r); + } + + // value + if (Value *valuesValue = FindObject(*sparseValue, "values")) { + //value bufferView + Value *valueViewID = FindUInt(*valuesValue, "bufferView"); + sparse->values = r.bufferViews.Retrieve(valueViewID->GetUint()); + //value byteOffset + sparse->valuesByteOffset = MemberOrDefault(*valuesValue, "byteOffset", size_t(0)); + //sparse->values->Read(*valuesValue, r); + } + + // indicesType + sparse->indicesType = MemberOrDefault(*sparseValue, "componentType", ComponentType_UNSIGNED_SHORT); + + const unsigned int elementSize = GetElementSize(); + const size_t dataSize = count * elementSize; + sparse->PopulateData(dataSize, bufferView ? bufferView->GetPointer(byteOffset) : 0); + sparse->PatchData(elementSize); + } } inline unsigned int Accessor::GetNumComponents() { @@ -581,6 +677,9 @@ inline unsigned int Accessor::GetElementSize() { } inline uint8_t *Accessor::GetPointer() { + if (sparse) + return sparse->data.data(); + if (!bufferView || !bufferView->buffer) return 0; uint8_t *basePtr = bufferView->buffer->GetPointer(); if (!basePtr) return 0; @@ -619,12 +718,11 @@ inline void CopyData(size_t count, } } // namespace -template -void Accessor::ExtractData(T *&outData) -{ - uint8_t* data = GetPointer(); +template +void Accessor::ExtractData(T *&outData) { + uint8_t *data = GetPointer(); if (!data) { - throw DeadlyImportError("GLTF: data is NULL"); + throw DeadlyImportError("GLTF2: data is nullptr."); } const size_t elemSize = GetElementSize(); @@ -634,8 +732,7 @@ void Accessor::ExtractData(T *&outData) const size_t targetElemSize = sizeof(T); ai_assert(elemSize <= targetElemSize); - - ai_assert(count * stride <= bufferView->byteLength); + ai_assert(count * stride <= (bufferView ? bufferView->byteLength : sparse->data.size())); outData = new T[count]; if (stride == elemSize && targetElemSize == elemSize) { @@ -661,7 +758,10 @@ inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t sr } inline Accessor::Indexer::Indexer(Accessor &acc) : - accessor(acc), data(acc.GetPointer()), elemSize(acc.GetElementSize()), stride(acc.bufferView && acc.bufferView->byteStride ? acc.bufferView->byteStride : elemSize) { + accessor(acc), + data(acc.GetPointer()), + elemSize(acc.GetElementSize()), + stride(acc.bufferView && acc.bufferView->byteStride ? acc.bufferView->byteStride : elemSize) { } //! Accesses the i-th value as defined by the accessor @@ -676,7 +776,9 @@ T Accessor::Indexer::GetValue(int i) { } inline Image::Image() : - width(0), height(0), mDataLength(0) { + width(0), + height(0), + mDataLength(0) { } inline void Image::Read(Value &obj, Asset &r) { @@ -914,8 +1016,8 @@ inline int Compare(const char *attr, const char (&str)[N]) { } #ifdef _WIN32 -# pragma warning(push) -# pragma warning(disable : 4706) +#pragma warning(push) +#pragma warning(disable : 4706) #endif // _WIN32 inline bool GetAttribVector(Mesh::Primitive &p, const char *attr, Mesh::AccessorList *&v, int &pos) { @@ -1002,7 +1104,7 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) { // Valid attribute semantics include POSITION, NORMAL, TANGENT int undPos = 0; Mesh::AccessorList *vec = 0; - if (GetAttribTargetVector(prim, i, attr, vec, undPos)) { + if (GetAttribTargetVector(prim, j, attr, vec, undPos)) { size_t idx = (attr[undPos] == '_') ? atoi(attr + undPos + 1) : 0; if ((*vec).size() <= idx) { (*vec).resize(idx + 1); @@ -1035,11 +1137,11 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) { } Value *extras = FindObject(pJSON_Object, "extras"); - if (nullptr != extras ) { - if (Value* curTargetNames = FindArray(*extras, "targetNames")) { + if (nullptr != extras) { + if (Value *curTargetNames = FindArray(*extras, "targetNames")) { this->targetNames.resize(curTargetNames->Size()); for (unsigned int i = 0; i < curTargetNames->Size(); ++i) { - Value& targetNameValue = (*curTargetNames)[i]; + Value &targetNameValue = (*curTargetNames)[i]; if (targetNameValue.IsString()) { this->targetNames[i] = targetNameValue.GetString(); } @@ -1067,10 +1169,10 @@ inline void Camera::Read(Value &obj, Asset & /*r*/) { cameraProperties.perspective.zfar = MemberOrDefault(*it, "zfar", 100.f); cameraProperties.perspective.znear = MemberOrDefault(*it, "znear", 0.01f); } else { - cameraProperties.ortographic.xmag = MemberOrDefault(obj, "xmag", 1.f); - cameraProperties.ortographic.ymag = MemberOrDefault(obj, "ymag", 1.f); - cameraProperties.ortographic.zfar = MemberOrDefault(obj, "zfar", 100.f); - cameraProperties.ortographic.znear = MemberOrDefault(obj, "znear", 0.01f); + cameraProperties.ortographic.xmag = MemberOrDefault(*it, "xmag", 1.f); + cameraProperties.ortographic.ymag = MemberOrDefault(*it, "ymag", 1.f); + cameraProperties.ortographic.zfar = MemberOrDefault(*it, "zfar", 100.f); + cameraProperties.ortographic.znear = MemberOrDefault(*it, "znear", 0.01f); } } @@ -1105,6 +1207,47 @@ inline void Light::Read(Value &obj, Asset & /*r*/) { } } +inline CustomExtension ReadExtensions(const char *name, Value& obj) { + CustomExtension ret; + ret.name = name; + if (obj.IsObject()) { + ret.mValues.isPresent = true; + for (auto it = obj.MemberBegin(); it != obj.MemberEnd(); ++it) { + auto& val = it->value; + ret.mValues.value.push_back(ReadExtensions(it->name.GetString(), val)); + } + } + else if (obj.IsArray()) { + ret.mValues.value.reserve(obj.Size()); + ret.mValues.isPresent = true; + for (unsigned int i = 0; i < obj.Size(); ++i) + { + ret.mValues.value.push_back(ReadExtensions(name, obj[i])); + } + } + else if (obj.IsNumber()) { + if (obj.IsUint64()) { + ret.mUint64Value.value = obj.GetUint64(); + ret.mUint64Value.isPresent = true; + } else if (obj.IsInt64()) { + ret.mInt64Value.value = obj.GetInt64(); + ret.mInt64Value.isPresent = true; + } else if (obj.IsDouble()) { + ret.mDoubleValue.value = obj.GetDouble(); + ret.mDoubleValue.isPresent = true; + } + } + else if (obj.IsString()) { + ReadValue(obj, ret.mStringValue); + ret.mStringValue.isPresent = true; + } + else if (obj.IsBool()) { + ret.mBoolValue.value = obj.GetBool(); + ret.mBoolValue.isPresent = true; + } + return ret; +} + inline void Node::Read(Value &obj, Asset &r) { if (name.empty()) { name = id; @@ -1146,7 +1289,7 @@ inline void Node::Read(Value &obj, Asset &r) { Value *curSkin = FindUInt(obj, "skin"); if (nullptr != curSkin) { - this->skin = r.skins.Retrieve(curSkin->GetUint()); + this->skin = r.skins.Get(curSkin->GetUint()); } Value *curCamera = FindUInt(obj, "camera"); @@ -1159,6 +1302,8 @@ inline void Node::Read(Value &obj, Asset &r) { Value *curExtensions = FindObject(obj, "extensions"); if (nullptr != curExtensions) { + this->extensions = ReadExtensions("extensions", *curExtensions); + if (r.extensionsUsed.KHR_lights_punctual) { if (Value *ext = FindObject(*curExtensions, "KHR_lights_punctual")) { Value *curLight = FindUInt(*ext, "light"); @@ -1293,6 +1438,7 @@ inline void AssetMetadata::Read(Document &doc) { // inline void Asset::ReadBinaryHeader(IOStream &stream, std::vector &sceneData) { + ASSIMP_LOG_DEBUG("Reading GLTF2 binary"); GLB_Header header; if (stream.Read(&header, sizeof(header), 1) != 1) { throw DeadlyImportError("GLTF: Unable to read the file header"); @@ -1356,6 +1502,7 @@ inline void Asset::ReadBinaryHeader(IOStream &stream, std::vector &sceneDa } inline void Asset::Load(const std::string &pFile, bool isBinary) { + ASSIMP_LOG_DEBUG("Loading GLTF2 asset"); mCurrentAssetDir.clear(); /*int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\'))); if (pos != int(std::string::npos)) */ @@ -1387,7 +1534,7 @@ inline void Asset::Load(const std::string &pFile, bool isBinary) { } // parse the JSON document - + ASSIMP_LOG_DEBUG("Parsing GLTF2 JSON"); Document doc; doc.ParseInsitu(&sceneData[0]); @@ -1437,7 +1584,7 @@ inline void Asset::Load(const std::string &pFile, bool isBinary) { } } - // Force reading of skins since they're not always directly referenced + // Read skins after nodes have been loaded to avoid infinite recursion if (Value *skinsArray = FindArray(doc, "skins")) { for (unsigned int i = 0; i < skinsArray->Size(); ++i) { skins.Retrieve(i); @@ -1549,7 +1696,7 @@ inline std::string Asset::FindUniqueID(const std::string &str, const char *suffi } #ifdef _WIN32 -# pragma warning(pop) +#pragma warning(pop) #endif // _WIN32 } // namespace glTF2 diff --git a/code/AssetLib/glTF2/glTF2AssetWriter.inl b/code/AssetLib/glTF2/glTF2AssetWriter.inl index 798f38c1c..d5b478e35 100644 --- a/code/AssetLib/glTF2/glTF2AssetWriter.inl +++ b/code/AssetLib/glTF2/glTF2AssetWriter.inl @@ -468,6 +468,22 @@ namespace glTF2 { } obj.AddMember("primitives", primitives, w.mAl); + // targetNames + if (m.targetNames.size() > 0) { + Value extras; + extras.SetObject(); + Value targetNames; + targetNames.SetArray(); + targetNames.Reserve(unsigned(m.targetNames.size()), w.mAl); + for (unsigned int n = 0; n < m.targetNames.size(); ++n) { + std::string name = m.targetNames[n]; + Value tname; + tname.SetString(name.c_str(), w.mAl); + targetNames.PushBack(tname, w.mAl); + } + extras.AddMember("targetNames", targetNames, w.mAl); + obj.AddMember("extras", extras, w.mAl); + } } inline void Write(Value& obj, Node& n, AssetWriter& w) @@ -613,7 +629,9 @@ namespace glTF2 { StringBuffer docBuffer; PrettyWriter writer(docBuffer); - mDoc.Accept(writer); + if (!mDoc.Accept(writer)) { + throw DeadlyExportError("Failed to write scene data!"); + } if (jsonOutFile->Write(docBuffer.GetString(), docBuffer.GetSize(), 1) != 1) { throw DeadlyExportError("Failed to write scene data!"); @@ -664,7 +682,9 @@ namespace glTF2 { StringBuffer docBuffer; Writer writer(docBuffer); - mDoc.Accept(writer); + if (!mDoc.Accept(writer)) { + throw DeadlyExportError("Failed to write scene data!"); + } uint32_t jsonChunkLength = (docBuffer.GetSize() + 3) & ~3; // Round up to next multiple of 4 auto paddingLength = jsonChunkLength - docBuffer.GetSize(); @@ -816,5 +836,3 @@ namespace glTF2 { } } - - diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index a6128b032..2359851f1 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -172,6 +172,13 @@ void SetAccessorRange(Ref acc, void* data, size_t count, for (unsigned int j = 0 ; j < numCompsOut ; j++) { double valueTmp = buffer_ptr[j]; + // Gracefully tolerate rogue NaN's in buffer data + // Any NaNs/Infs introduced in accessor bounds will end up in + // document and prevent rapidjson from writing out valid JSON + if (!std::isfinite(valueTmp)) { + continue; + } + if (valueTmp < acc->min[j]) { acc->min[j] = valueTmp; } @@ -348,7 +355,7 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref& texture, aiTe if (path[0] == '*') { // embedded aiTexture* curTex = mScene->mTextures[atoi(&path[1])]; - + texture->source->name = curTex->mFilename.C_Str(); // The asset has its own buffer, see Image::SetData @@ -751,7 +758,7 @@ void glTF2Exporter::ExportMeshes() // Normalize all normals as the validator can emit a warning otherwise if ( nullptr != aim->mNormals) { for ( auto i = 0u; i < aim->mNumVertices; ++i ) { - aim->mNormals[ i ].Normalize(); + aim->mNormals[ i ].NormalizeSafe(); } } @@ -762,7 +769,7 @@ void glTF2Exporter::ExportMeshes() for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { if (!aim->HasTextureCoords(i)) continue; - + // Flip UV y coords if (aim -> mNumUVComponents[i] > 1) { for (unsigned int j = 0; j < aim->mNumVertices; ++j) { @@ -817,9 +824,14 @@ void glTF2Exporter::ExportMeshes() /*************** Targets for blendshapes ****************/ if (aim->mNumAnimMeshes > 0) { + bool bExportTargetNames = this->mProperties->HasPropertyBool("GLTF2_TARGETNAMES_EXP") && + this->mProperties->GetPropertyBool("GLTF2_TARGETNAMES_EXP"); + p.targets.resize(aim->mNumAnimMeshes); for (unsigned int am = 0; am < aim->mNumAnimMeshes; ++am) { aiAnimMesh *pAnimMesh = aim->mAnimMeshes[am]; + if (bExportTargetNames) + m->targetNames.push_back(pAnimMesh->mName.data); // position if (pAnimMesh->HasPositions()) { diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 10d0bc83b..4d740d8c1 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -286,6 +286,7 @@ static aiMaterial *ImportMaterial(std::vector &embeddedTexIdxs, Asset &r, M void glTF2Importer::ImportMaterials(glTF2::Asset &r) { const unsigned int numImportedMaterials = unsigned(r.materials.Size()); + ASSIMP_LOG_DEBUG_F("Importing ", numImportedMaterials, " materials"); Material defaultMaterial; mScene->mNumMaterials = numImportedMaterials + 1; @@ -333,6 +334,7 @@ static inline bool CheckValidFacesIndices(aiFace *faces, unsigned nFaces, unsign #endif // ASSIMP_BUILD_DEBUG void glTF2Importer::ImportMeshes(glTF2::Asset &r) { + ASSIMP_LOG_DEBUG_F("Importing ", r.meshes.Size(), " meshes"); std::vector meshes; unsigned int k = 0; @@ -414,6 +416,11 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) { attr.color[c]->ExtractData(aim->mColors[c]); } for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) { + if (!attr.texcoord[tc]) { + DefaultLogger::get()->warn("Texture coordinate accessor not found or non-contiguous texture coordinate sets."); + continue; + } + if (attr.texcoord[tc]->count != aim->mNumVertices) { DefaultLogger::get()->warn("Texcoord stream size in mesh \"" + mesh.name + "\" does not match the vertex count"); @@ -662,10 +669,12 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) { void glTF2Importer::ImportCameras(glTF2::Asset &r) { if (!r.cameras.Size()) return; - mScene->mNumCameras = r.cameras.Size(); - mScene->mCameras = new aiCamera *[r.cameras.Size()]; + const unsigned int numCameras = r.cameras.Size(); + ASSIMP_LOG_DEBUG_F("Importing ", numCameras, " cameras"); + mScene->mNumCameras = numCameras; + mScene->mCameras = new aiCamera *[numCameras]; - for (size_t i = 0; i < r.cameras.Size(); ++i) { + for (size_t i = 0; i < numCameras; ++i) { Camera &cam = r.cameras[i]; aiCamera *aicam = mScene->mCameras[i] = new aiCamera(); @@ -696,10 +705,12 @@ void glTF2Importer::ImportLights(glTF2::Asset &r) { if (!r.lights.Size()) return; - mScene->mNumLights = r.lights.Size(); - mScene->mLights = new aiLight *[r.lights.Size()]; + const unsigned int numLights = r.lights.Size(); + ASSIMP_LOG_DEBUG_F("Importing ", numLights, " lights"); + mScene->mNumLights = numLights; + mScene->mLights = new aiLight *[numLights]; - for (size_t i = 0; i < r.lights.Size(); ++i) { + for (size_t i = 0; i < numLights; ++i) { Light &light = r.lights[i]; aiLight *ail = mScene->mLights[i] = new aiLight(); @@ -836,6 +847,26 @@ static std::string GetNodeName(const Node &node) { return node.name.empty() ? node.id : node.name; } +void ParseExtensions(aiMetadata *metadata, const CustomExtension &extension) { + if (extension.mStringValue.isPresent) { + metadata->Add(extension.name.c_str(), aiString(extension.mStringValue.value)); + } else if (extension.mDoubleValue.isPresent) { + metadata->Add(extension.name.c_str(), extension.mDoubleValue.value); + } else if (extension.mUint64Value.isPresent) { + metadata->Add(extension.name.c_str(), extension.mUint64Value.value); + } else if (extension.mInt64Value.isPresent) { + metadata->Add(extension.name.c_str(), static_cast(extension.mInt64Value.value)); + } else if (extension.mBoolValue.isPresent) { + metadata->Add(extension.name.c_str(), extension.mBoolValue.value); + } else if (extension.mValues.isPresent) { + aiMetadata val; + for (size_t i = 0; i < extension.mValues.value.size(); ++i) { + ParseExtensions(&val, extension.mValues.value[i]); + } + metadata->Add(extension.name.c_str(), val); + } +} + aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector &meshOffsets, glTF2::Ref &ptr) { Node &node = *ptr; @@ -852,6 +883,11 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector & } } + if (node.extensions) { + ainode->mMetaData = new aiMetadata; + ParseExtensions(ainode->mMetaData, node.extensions); + } + GetNodeTransform(ainode->mTransformation, node); if (!node.meshes.empty()) { @@ -946,8 +982,13 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector & //range is optional - see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual //it is added to meta data of parent node, because there is no other place to put it if (node.light->range.isPresent) { - ainode->mMetaData = aiMetadata::Alloc(1); - ainode->mMetaData->Set(0, "PBR_LightRange", node.light->range.value); + if (!ainode->mMetaData) { + ainode->mMetaData = aiMetadata::Alloc(1); + ainode->mMetaData->Set(0, "PBR_LightRange", node.light->range.value); + } + else { + ainode->mMetaData->Add("PBR_LightRange", node.light->range.value); + } } } @@ -958,6 +999,7 @@ void glTF2Importer::ImportNodes(glTF2::Asset &r) { if (!r.scene) { throw DeadlyImportError("GLTF: No scene"); } + ASSIMP_LOG_DEBUG("Importing nodes"); std::vector> rootNodes = r.scene->nodes; @@ -1137,13 +1179,15 @@ std::unordered_map GatherSamplers(Animation &an void glTF2Importer::ImportAnimations(glTF2::Asset &r) { if (!r.scene) return; - mScene->mNumAnimations = r.animations.Size(); + const unsigned numAnimations = r.animations.Size(); + ASSIMP_LOG_DEBUG_F("Importing ", numAnimations, " animations"); + mScene->mNumAnimations = numAnimations; if (mScene->mNumAnimations == 0) { return; } - mScene->mAnimations = new aiAnimation *[mScene->mNumAnimations]; - for (unsigned int i = 0; i < r.animations.Size(); ++i) { + mScene->mAnimations = new aiAnimation *[numAnimations]; + for (unsigned int i = 0; i < numAnimations; ++i) { Animation &anim = r.animations[i]; aiAnimation *ai_anim = new aiAnimation(); @@ -1249,6 +1293,8 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) { if (numEmbeddedTexs == 0) return; + ASSIMP_LOG_DEBUG_F("Importing ", numEmbeddedTexs, " embedded textures"); + mScene->mTextures = new aiTexture *[numEmbeddedTexs]; // Add the embedded textures @@ -1288,6 +1334,7 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) { } void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) { + ASSIMP_LOG_DEBUG("Importing metadata"); ai_assert(mScene->mMetaData == nullptr); const bool hasVersion = !a.asset.version.empty(); const bool hasGenerator = !a.asset.generator.empty(); @@ -1307,6 +1354,9 @@ void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) { } void glTF2Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { + + ASSIMP_LOG_DEBUG("Reading GLTF2 file"); + // clean all member arrays meshOffsets.clear(); embeddedTexIdxs.clear(); diff --git a/code/CApi/AssimpCExport.cpp b/code/CApi/AssimpCExport.cpp index a6e7a304f..620bd5948 100644 --- a/code/CApi/AssimpCExport.cpp +++ b/code/CApi/AssimpCExport.cpp @@ -48,108 +48,96 @@ Assimp C export interface. See Exporter.cpp for some notes. #ifndef ASSIMP_BUILD_NO_EXPORT #include "CInterfaceIOWrapper.h" -#include #include "Common/ScenePrivate.h" +#include #include using namespace Assimp; // ------------------------------------------------------------------------------------------------ -ASSIMP_API size_t aiGetExportFormatCount(void) -{ +ASSIMP_API size_t aiGetExportFormatCount(void) { return Exporter().GetExportFormatCount(); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index) -{ +ASSIMP_API const aiExportFormatDesc *aiGetExportFormatDescription(size_t index) { // Note: this is valid as the index always pertains to a built-in exporter, // for which the returned structure is guaranteed to be of static storage duration. Exporter exporter; - const aiExportFormatDesc* orig( exporter.GetExportFormatDescription( index ) ); - if (NULL == orig) { - return NULL; + const aiExportFormatDesc *orig(exporter.GetExportFormatDescription(index)); + if (nullptr == orig) { + return nullptr; } aiExportFormatDesc *desc = new aiExportFormatDesc; - desc->description = new char[ strlen( orig->description ) + 1 ](); - ::memcpy( (char*) desc->description, orig->description, strlen( orig->description ) ); - desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ](); - ::memcpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) ); - desc->id = new char[ strlen( orig->id ) + 1 ](); - ::memcpy( ( char* ) desc->id, orig->id, strlen( orig->id ) ); + desc->description = new char[strlen(orig->description) + 1](); + ::memcpy((char *)desc->description, orig->description, strlen(orig->description)); + desc->fileExtension = new char[strlen(orig->fileExtension) + 1](); + ::memcpy((char *)desc->fileExtension, orig->fileExtension, strlen(orig->fileExtension)); + desc->id = new char[strlen(orig->id) + 1](); + ::memcpy((char *)desc->id, orig->id, strlen(orig->id)); return desc; } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiReleaseExportFormatDescription( const aiExportFormatDesc *desc ) { - if (NULL == desc) { +ASSIMP_API void aiReleaseExportFormatDescription(const aiExportFormatDesc *desc) { + if (nullptr == desc) { return; } - delete [] desc->description; - delete [] desc->fileExtension; - delete [] desc->id; + delete[] desc->description; + delete[] desc->fileExtension; + delete[] desc->id; delete desc; } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) -{ +ASSIMP_API void aiCopyScene(const aiScene *pIn, aiScene **pOut) { if (!pOut || !pIn) { return; } - SceneCombiner::CopyScene(pOut,pIn,true); + SceneCombiner::CopyScene(pOut, pIn, true); ScenePriv(*pOut)->mIsCopy = true; } - // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn) -{ +ASSIMP_API void aiFreeScene(const C_STRUCT aiScene *pIn) { // note: aiReleaseImport() is also able to delete scene copies, but in addition // it also handles scenes with import metadata. delete pIn; } - // ------------------------------------------------------------------------------------------------ -ASSIMP_API aiReturn aiExportScene( const aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing ) -{ - return ::aiExportSceneEx(pScene,pFormatId,pFileName,NULL,pPreprocessing); +ASSIMP_API aiReturn aiExportScene(const aiScene *pScene, const char *pFormatId, const char *pFileName, unsigned int pPreprocessing) { + return ::aiExportSceneEx(pScene, pFormatId, pFileName, nullptr, pPreprocessing); } - // ------------------------------------------------------------------------------------------------ -ASSIMP_API aiReturn aiExportSceneEx( const aiScene* pScene, const char* pFormatId, const char* pFileName, aiFileIO* pIO, unsigned int pPreprocessing ) -{ +ASSIMP_API aiReturn aiExportSceneEx(const aiScene *pScene, const char *pFormatId, const char *pFileName, aiFileIO *pIO, unsigned int pPreprocessing) { Exporter exp; if (pIO) { exp.SetIOHandler(new CIOSystemWrapper(pIO)); } - return exp.Export(pScene,pFormatId,pFileName,pPreprocessing); + return exp.Export(pScene, pFormatId, pFileName, pPreprocessing); } - // ------------------------------------------------------------------------------------------------ -ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing ) -{ +ASSIMP_API const C_STRUCT aiExportDataBlob *aiExportSceneToBlob(const aiScene *pScene, const char *pFormatId, unsigned int pPreprocessing) { Exporter exp; - if (!exp.ExportToBlob(pScene,pFormatId,pPreprocessing)) { - return NULL; + if (!exp.ExportToBlob(pScene, pFormatId, pPreprocessing)) { + return nullptr; } - const aiExportDataBlob* blob = exp.GetOrphanedBlob(); + const aiExportDataBlob *blob = exp.GetOrphanedBlob(); ai_assert(blob); return blob; } // ------------------------------------------------------------------------------------------------ -ASSIMP_API C_STRUCT void aiReleaseExportBlob( const aiExportDataBlob* pData ) -{ +ASSIMP_API C_STRUCT void aiReleaseExportBlob(const aiExportDataBlob *pData) { delete pData; } diff --git a/code/CApi/CInterfaceIOWrapper.cpp b/code/CApi/CInterfaceIOWrapper.cpp index 91dd07f37..d5c6a2535 100644 --- a/code/CApi/CInterfaceIOWrapper.cpp +++ b/code/CApi/CInterfaceIOWrapper.cpp @@ -45,10 +45,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "CInterfaceIOWrapper.h" -namespace Assimp { +namespace Assimp { -CIOStreamWrapper::~CIOStreamWrapper(void) -{ +CIOStreamWrapper::~CIOStreamWrapper(void) { /* Various places depend on this destructor to close the file */ if (mFile) { mIO->mFileSystem->CloseProc(mIO->mFileSystem, mFile); @@ -57,28 +56,25 @@ CIOStreamWrapper::~CIOStreamWrapper(void) } // ................................................................... -size_t CIOStreamWrapper::Read(void* pvBuffer, - size_t pSize, - size_t pCount -){ +size_t CIOStreamWrapper::Read(void *pvBuffer, + size_t pSize, + size_t pCount) { // need to typecast here as C has no void* - return mFile->ReadProc(mFile,(char*)pvBuffer,pSize,pCount); + return mFile->ReadProc(mFile, (char *)pvBuffer, pSize, pCount); } // ................................................................... -size_t CIOStreamWrapper::Write(const void* pvBuffer, - size_t pSize, - size_t pCount -){ +size_t CIOStreamWrapper::Write(const void *pvBuffer, + size_t pSize, + size_t pCount) { // need to typecast here as C has no void* - return mFile->WriteProc(mFile,(const char*)pvBuffer,pSize,pCount); + return mFile->WriteProc(mFile, (const char *)pvBuffer, pSize, pCount); } // ................................................................... aiReturn CIOStreamWrapper::Seek(size_t pOffset, - aiOrigin pOrigin -){ - return mFile->SeekProc(mFile,pOffset,pOrigin); + aiOrigin pOrigin) { + return mFile->SeekProc(mFile, pOffset, pOrigin); } // ................................................................... @@ -92,16 +88,16 @@ size_t CIOStreamWrapper::FileSize() const { } // ................................................................... -void CIOStreamWrapper::Flush () { +void CIOStreamWrapper::Flush() { return mFile->FlushProc(mFile); } // ------------------------------------------------------------------------------------------------ // Custom IOStream implementation for the C-API -bool CIOSystemWrapper::Exists( const char* pFile) const { - aiFile* p = mFileSystem->OpenProc(mFileSystem,pFile,"rb"); - if (p){ - mFileSystem->CloseProc(mFileSystem,p); +bool CIOSystemWrapper::Exists(const char *pFile) const { + aiFile *p = mFileSystem->OpenProc(mFileSystem, pFile, "rb"); + if (p) { + mFileSystem->CloseProc(mFileSystem, p); return true; } return false; @@ -117,20 +113,20 @@ char CIOSystemWrapper::getOsSeparator() const { } // ................................................................... -IOStream* CIOSystemWrapper::Open(const char* pFile,const char* pMode) { - aiFile* p = mFileSystem->OpenProc(mFileSystem,pFile,pMode); +IOStream *CIOSystemWrapper::Open(const char *pFile, const char *pMode) { + aiFile *p = mFileSystem->OpenProc(mFileSystem, pFile, pMode); if (!p) { - return NULL; + return nullptr; } return new CIOStreamWrapper(p, this); } // ................................................................... -void CIOSystemWrapper::Close( IOStream* pFile) { +void CIOSystemWrapper::Close(IOStream *pFile) { if (!pFile) { return; } delete pFile; } -} +} // namespace Assimp diff --git a/code/CApi/CInterfaceIOWrapper.h b/code/CApi/CInterfaceIOWrapper.h index 298847494..c899840fc 100644 --- a/code/CApi/CInterfaceIOWrapper.h +++ b/code/CApi/CInterfaceIOWrapper.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -50,50 +48,47 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -namespace Assimp { +namespace Assimp { class CIOSystemWrapper; // ------------------------------------------------------------------------------------------------ // Custom IOStream implementation for the C-API -class CIOStreamWrapper : public IOStream -{ +class CIOStreamWrapper : public IOStream { public: - explicit CIOStreamWrapper(aiFile* pFile, CIOSystemWrapper* io) - : mFile(pFile), - mIO(io) - {} + explicit CIOStreamWrapper(aiFile *pFile, CIOSystemWrapper *io) : + mFile(pFile), + mIO(io) {} ~CIOStreamWrapper(void); - size_t Read(void* pvBuffer, size_t pSize, size_t pCount); - size_t Write(const void* pvBuffer, size_t pSize, size_t pCount); + size_t Read(void *pvBuffer, size_t pSize, size_t pCount); + size_t Write(const void *pvBuffer, size_t pSize, size_t pCount); aiReturn Seek(size_t pOffset, aiOrigin pOrigin); size_t Tell(void) const; size_t FileSize() const; void Flush(); private: - aiFile* mFile; - CIOSystemWrapper* mIO; + aiFile *mFile; + CIOSystemWrapper *mIO; }; -class CIOSystemWrapper : public IOSystem -{ +class CIOSystemWrapper : public IOSystem { friend class CIOStreamWrapper; -public: - explicit CIOSystemWrapper(aiFileIO* pFile) - : mFileSystem(pFile) - {} - bool Exists( const char* pFile) const; +public: + explicit CIOSystemWrapper(aiFileIO *pFile) : + mFileSystem(pFile) {} + + bool Exists(const char *pFile) const; char getOsSeparator() const; - IOStream* Open(const char* pFile,const char* pMode = "rb"); - void Close( IOStream* pFile); + IOStream *Open(const char *pFile, const char *pMode = "rb"); + void Close(IOStream *pFile); + private: - aiFileIO* mFileSystem; + aiFileIO *mFileSystem; }; -} +} // namespace Assimp #endif - diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index e6ed3fa88..9f8f519d9 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -66,6 +66,7 @@ SET( PUBLIC_HEADERS ${HEADER_PATH}/color4.h ${HEADER_PATH}/color4.inl ${CMAKE_CURRENT_BINARY_DIR}/../include/assimp/config.h + ${HEADER_PATH}/ColladaMetaData.h ${HEADER_PATH}/commonMetaData.h ${HEADER_PATH}/defs.h ${HEADER_PATH}/Defines.h @@ -198,6 +199,7 @@ SET( Common_SRCS Common/simd.h Common/simd.cpp Common/material.cpp + Common/AssertHandler.cpp ) SOURCE_GROUP(Common FILES ${Common_SRCS}) @@ -1232,7 +1234,7 @@ if (APPLE) # add ./Compiler/*.h to assimp.framework via copy command ADD_CUSTOM_COMMAND(TARGET assimp POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory - "../${HEADER_PATH}/Compiler" + "${HEADER_PATH}/Compiler" assimp.framework/Headers/Compiler COMMENT "Copying public ./Compiler/ header files to framework bundle's Headers/Compiler/") ENDIF() diff --git a/code/Common/AssertHandler.cpp b/code/Common/AssertHandler.cpp new file mode 100644 index 000000000..63b64f828 --- /dev/null +++ b/code/Common/AssertHandler.cpp @@ -0,0 +1,72 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +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 +OWNER 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. +--------------------------------------------------------------------------- +*/ + +/** @file AssertHandler.cpp + * @brief Implementation of assert handling logic. + */ + +#include "AssertHandler.h" + +#include +#include + +void Assimp::defaultAiAssertHandler(const char* failedExpression, const char* file, int line) +{ + std::cerr << "ai_assert failure in " << file << "(" << line << "): " << failedExpression << std::endl; + std::abort(); +} + +namespace +{ + Assimp::AiAssertHandler s_handler = Assimp::defaultAiAssertHandler; +} + +void Assimp::setAiAssertHandler(AiAssertHandler handler) +{ + s_handler = handler; +} + +void Assimp::aiAssertViolation(const char* failedExpression, const char* file, int line) +{ + s_handler(failedExpression, file, line); +} diff --git a/code/Common/AssertHandler.h b/code/Common/AssertHandler.h new file mode 100644 index 000000000..2515f0bf2 --- /dev/null +++ b/code/Common/AssertHandler.h @@ -0,0 +1,75 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +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 +OWNER 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. + +---------------------------------------------------------------------- +*/ + +/** @file Provides facilities to replace the default assert handler. */ + +#ifndef INCLUDED_AI_ASSERTHANDLER_H +#define INCLUDED_AI_ASSERTHANDLER_H + +#include +#include + +namespace Assimp +{ + // --------------------------------------------------------------------------- + /** Signature of functions which handle assert violations. + */ + using AiAssertHandler = void (*)(const char* failedExpression, const char* file, int line); + + // --------------------------------------------------------------------------- + /** Set the assert handler. + */ + ASSIMP_API void setAiAssertHandler(AiAssertHandler handler); + + // --------------------------------------------------------------------------- + /** The assert handler which is set by default. + * + * This issues a message to stderr and calls abort. + */ + ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line); + + // --------------------------------------------------------------------------- + /** Dispatches an assert violation to the assert handler. + */ + ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line); +} // end of namespace Assimp + +#endif // INCLUDED_AI_ASSERTHANDLER_H \ No newline at end of file diff --git a/code/Common/Assimp.cpp b/code/Common/Assimp.cpp index 67f1c3af2..26aa52300 100644 --- a/code/Common/Assimp.cpp +++ b/code/Common/Assimp.cpp @@ -113,7 +113,7 @@ class LogToCallbackRedirector : public LogStream { public: explicit LogToCallbackRedirector(const aiLogStream &s) : stream(s) { - ai_assert(NULL != s.callback); + ai_assert(nullptr != s.callback); } ~LogToCallbackRedirector() { @@ -154,20 +154,20 @@ void ReportSceneNotFoundError() { // ------------------------------------------------------------------------------------------------ // Reads the given file and returns its content. const aiScene *aiImportFile(const char *pFile, unsigned int pFlags) { - return aiImportFileEx(pFile, pFlags, NULL); + return aiImportFileEx(pFile, pFlags, nullptr); } // ------------------------------------------------------------------------------------------------ const aiScene *aiImportFileEx(const char *pFile, unsigned int pFlags, aiFileIO *pFS) { - return aiImportFileExWithProperties(pFile, pFlags, pFS, NULL); + return aiImportFileExWithProperties(pFile, pFlags, pFS, nullptr); } // ------------------------------------------------------------------------------------------------ const aiScene *aiImportFileExWithProperties(const char *pFile, unsigned int pFlags, aiFileIO *pFS, const aiPropertyStore *props) { - ai_assert(NULL != pFile); + ai_assert(nullptr != pFile); - const aiScene *scene = NULL; + const aiScene *scene = nullptr; ASSIMP_BEGIN_EXCEPTION_REGION(); // create an Importer for this file @@ -200,7 +200,7 @@ const aiScene *aiImportFileExWithProperties(const char *pFile, unsigned int pFla delete imp; } - // return imported data. If the import failed the pointer is NULL anyways + // return imported data. If the import failed the pointer is nullptr anyways ASSIMP_END_EXCEPTION_REGION(const aiScene *); return scene; @@ -212,7 +212,7 @@ const aiScene *aiImportFileFromMemory( unsigned int pLength, unsigned int pFlags, const char *pHint) { - return aiImportFileFromMemoryWithProperties(pBuffer, pLength, pFlags, pHint, NULL); + return aiImportFileFromMemoryWithProperties(pBuffer, pLength, pFlags, pHint, nullptr); } // ------------------------------------------------------------------------------------------------ @@ -222,10 +222,10 @@ const aiScene *aiImportFileFromMemoryWithProperties( unsigned int pFlags, const char *pHint, const aiPropertyStore *props) { - ai_assert(NULL != pBuffer); + ai_assert(nullptr != pBuffer); ai_assert(0 != pLength); - const aiScene *scene = NULL; + const aiScene *scene = nullptr; ASSIMP_BEGIN_EXCEPTION_REGION(); // create an Importer for this file @@ -253,7 +253,7 @@ const aiScene *aiImportFileFromMemoryWithProperties( gLastErrorString = imp->GetErrorString(); delete imp; } - // return imported data. If the import failed the pointer is NULL anyways + // return imported data. If the import failed the pointer is nullptr anyways ASSIMP_END_EXCEPTION_REGION(const aiScene *); return scene; } @@ -285,7 +285,7 @@ void aiReleaseImport(const aiScene *pScene) { // ------------------------------------------------------------------------------------------------ ASSIMP_API const aiScene *aiApplyPostProcessing(const aiScene *pScene, unsigned int pFlags) { - const aiScene *sc = NULL; + const aiScene *sc = nullptr; ASSIMP_BEGIN_EXCEPTION_REGION(); @@ -293,14 +293,14 @@ ASSIMP_API const aiScene *aiApplyPostProcessing(const aiScene *pScene, const ScenePrivateData *priv = ScenePriv(pScene); if (!priv || !priv->mOrigImporter) { ReportSceneNotFoundError(); - return NULL; + return nullptr; } sc = priv->mOrigImporter->ApplyPostProcessing(pFlags); if (!sc) { aiReleaseImport(pScene); - return NULL; + return nullptr; } ASSIMP_END_EXCEPTION_REGION(const aiScene *); @@ -311,22 +311,22 @@ ASSIMP_API const aiScene *aiApplyPostProcessing(const aiScene *pScene, ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing(const aiScene *scene, BaseProcess *process, bool requestValidation) { - const aiScene *sc(NULL); + const aiScene *sc(nullptr); ASSIMP_BEGIN_EXCEPTION_REGION(); // find the importer associated with this data const ScenePrivateData *priv = ScenePriv(scene); - if (NULL == priv || NULL == priv->mOrigImporter) { + if (nullptr == priv || nullptr == priv->mOrigImporter) { ReportSceneNotFoundError(); - return NULL; + return nullptr; } sc = priv->mOrigImporter->ApplyCustomizedPostProcessing(process, requestValidation); if (!sc) { aiReleaseImport(scene); - return NULL; + return nullptr; } ASSIMP_END_EXCEPTION_REGION(const aiScene *); @@ -336,8 +336,8 @@ ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing(const aiScene *scene, // ------------------------------------------------------------------------------------------------ void CallbackToLogRedirector(const char *msg, char *dt) { - ai_assert(NULL != msg); - ai_assert(NULL != dt); + ai_assert(nullptr != msg); + ai_assert(nullptr != dt); LogStream *s = (LogStream *)dt; s->write(msg); @@ -350,8 +350,8 @@ ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream, cons ASSIMP_BEGIN_EXCEPTION_REGION(); LogStream *stream = LogStream::createDefaultStream(pStream, file); if (!stream) { - sout.callback = NULL; - sout.user = NULL; + sout.callback = nullptr; + sout.user = nullptr; } else { sout.callback = &CallbackToLogRedirector; sout.user = (char *)stream; @@ -373,7 +373,7 @@ ASSIMP_API void aiAttachLogStream(const aiLogStream *stream) { gActiveLogStreams[*stream] = lg; if (DefaultLogger::isNullLogger()) { - DefaultLogger::create(NULL, (gVerboseLogging == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); + DefaultLogger::create(nullptr, (gVerboseLogging == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); } DefaultLogger::get()->attachStream(lg); ASSIMP_END_EXCEPTION_REGION(void); @@ -392,7 +392,7 @@ ASSIMP_API aiReturn aiDetachLogStream(const aiLogStream *stream) { if (it == gActiveLogStreams.end()) { return AI_FAILURE; } - DefaultLogger::get()->detatchStream(it->second); + DefaultLogger::get()->detachStream(it->second); delete it->second; gActiveLogStreams.erase(it); @@ -411,12 +411,12 @@ ASSIMP_API void aiDetachAllLogStreams(void) { std::lock_guard lock(gLogStreamMutex); #endif Logger *logger(DefaultLogger::get()); - if (NULL == logger) { + if (nullptr == logger) { return; } for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) { - logger->detatchStream(it->second); + logger->detachStream(it->second); delete it->second; } gActiveLogStreams.clear(); @@ -454,7 +454,7 @@ size_t aiGetImportFormatCount(void) { // ------------------------------------------------------------------------------------------------ // Returns the error text of the last failed import process. aiBool aiIsExtensionSupported(const char *szExtension) { - ai_assert(NULL != szExtension); + ai_assert(nullptr != szExtension); aiBool candoit = AI_FALSE; ASSIMP_BEGIN_EXCEPTION_REGION(); @@ -469,7 +469,7 @@ aiBool aiIsExtensionSupported(const char *szExtension) { // ------------------------------------------------------------------------------------------------ // Get a list of all file extensions supported by ASSIMP void aiGetExtensionList(aiString *szOut) { - ai_assert(NULL != szOut); + ai_assert(nullptr != szOut); ASSIMP_BEGIN_EXCEPTION_REGION(); // FIXME: no need to create a temporary Importer instance just for that .. @@ -553,8 +553,8 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore *p, const char *szName // ------------------------------------------------------------------------------------------------ // Rotation matrix to quaternion ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion *quat, const aiMatrix3x3 *mat) { - ai_assert(NULL != quat); - ai_assert(NULL != mat); + ai_assert(nullptr != quat); + ai_assert(nullptr != mat); *quat = aiQuaternion(*mat); } @@ -563,23 +563,23 @@ ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion *quat, const aiMatrix3 ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4 *mat, aiVector3D *scaling, aiQuaternion *rotation, aiVector3D *position) { - ai_assert(NULL != rotation); - ai_assert(NULL != position); - ai_assert(NULL != scaling); - ai_assert(NULL != mat); + ai_assert(nullptr != rotation); + ai_assert(nullptr != position); + ai_assert(nullptr != scaling); + ai_assert(nullptr != mat); mat->Decompose(*scaling, *rotation, *position); } // ------------------------------------------------------------------------------------------------ // Matrix transpose ASSIMP_API void aiTransposeMatrix3(aiMatrix3x3 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); mat->Transpose(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); mat->Transpose(); } @@ -587,16 +587,16 @@ ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4 *mat) { // Vector transformation ASSIMP_API void aiTransformVecByMatrix3(aiVector3D *vec, const aiMatrix3x3 *mat) { - ai_assert(NULL != mat); - ai_assert(NULL != vec); + ai_assert(nullptr != mat); + ai_assert(nullptr != vec); *vec *= (*mat); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiTransformVecByMatrix4(aiVector3D *vec, const aiMatrix4x4 *mat) { - ai_assert(NULL != mat); - ai_assert(NULL != vec); + ai_assert(nullptr != mat); + ai_assert(nullptr != vec); *vec *= (*mat); } @@ -606,8 +606,8 @@ ASSIMP_API void aiTransformVecByMatrix4(aiVector3D *vec, ASSIMP_API void aiMultiplyMatrix4( aiMatrix4x4 *dst, const aiMatrix4x4 *src) { - ai_assert(NULL != dst); - ai_assert(NULL != src); + ai_assert(nullptr != dst); + ai_assert(nullptr != src); *dst = (*dst) * (*src); } @@ -615,8 +615,8 @@ ASSIMP_API void aiMultiplyMatrix4( ASSIMP_API void aiMultiplyMatrix3( aiMatrix3x3 *dst, const aiMatrix3x3 *src) { - ai_assert(NULL != dst); - ai_assert(NULL != src); + ai_assert(nullptr != dst); + ai_assert(nullptr != src); *dst = (*dst) * (*src); } @@ -624,23 +624,23 @@ ASSIMP_API void aiMultiplyMatrix3( // Matrix identity ASSIMP_API void aiIdentityMatrix3( aiMatrix3x3 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); *mat = aiMatrix3x3(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiIdentityMatrix4( aiMatrix4x4 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); *mat = aiMatrix4x4(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API C_STRUCT const aiImporterDesc *aiGetImporterDesc(const char *extension) { - if (NULL == extension) { - return NULL; + if (nullptr == extension) { + return nullptr; } - const aiImporterDesc *desc(NULL); + const aiImporterDesc *desc(nullptr); std::vector out; GetImporterInstanceList(out); for (size_t i = 0; i < out.size(); ++i) { @@ -659,8 +659,8 @@ ASSIMP_API C_STRUCT const aiImporterDesc *aiGetImporterDesc(const char *extensio ASSIMP_API int aiVector2AreEqual( const C_STRUCT aiVector2D *a, const C_STRUCT aiVector2D *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return *a == *b; } @@ -669,8 +669,8 @@ ASSIMP_API int aiVector2AreEqualEpsilon( const C_STRUCT aiVector2D *a, const C_STRUCT aiVector2D *b, const float epsilon) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return a->Equal(*b, epsilon); } @@ -678,8 +678,8 @@ ASSIMP_API int aiVector2AreEqualEpsilon( ASSIMP_API void aiVector2Add( C_STRUCT aiVector2D *dst, const C_STRUCT aiVector2D *src) { - ai_assert(NULL != dst); - ai_assert(NULL != src); + ai_assert(nullptr != dst); + ai_assert(nullptr != src); *dst = *dst + *src; } @@ -687,8 +687,8 @@ ASSIMP_API void aiVector2Add( ASSIMP_API void aiVector2Subtract( C_STRUCT aiVector2D *dst, const C_STRUCT aiVector2D *src) { - ai_assert(NULL != dst); - ai_assert(NULL != src); + ai_assert(nullptr != dst); + ai_assert(nullptr != src); *dst = *dst - *src; } @@ -696,7 +696,7 @@ ASSIMP_API void aiVector2Subtract( ASSIMP_API void aiVector2Scale( C_STRUCT aiVector2D *dst, const float s) { - ai_assert(NULL != dst); + ai_assert(nullptr != dst); *dst *= s; } @@ -704,8 +704,8 @@ ASSIMP_API void aiVector2Scale( ASSIMP_API void aiVector2SymMul( C_STRUCT aiVector2D *dst, const C_STRUCT aiVector2D *other) { - ai_assert(NULL != dst); - ai_assert(NULL != other); + ai_assert(nullptr != dst); + ai_assert(nullptr != other); *dst = dst->SymMul(*other); } @@ -713,7 +713,7 @@ ASSIMP_API void aiVector2SymMul( ASSIMP_API void aiVector2DivideByScalar( C_STRUCT aiVector2D *dst, const float s) { - ai_assert(NULL != dst); + ai_assert(nullptr != dst); *dst /= s; } @@ -721,29 +721,29 @@ ASSIMP_API void aiVector2DivideByScalar( ASSIMP_API void aiVector2DivideByVector( C_STRUCT aiVector2D *dst, C_STRUCT aiVector2D *v) { - ai_assert(NULL != dst); - ai_assert(NULL != v); + ai_assert(nullptr != dst); + ai_assert(nullptr != v); *dst = *dst / *v; } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector2Length( const C_STRUCT aiVector2D *v) { - ai_assert(NULL != v); + ai_assert(nullptr != v); return v->Length(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector2SquareLength( const C_STRUCT aiVector2D *v) { - ai_assert(NULL != v); + ai_assert(nullptr != v); return v->SquareLength(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2Negate( C_STRUCT aiVector2D *dst) { - ai_assert(NULL != dst); + ai_assert(nullptr != dst); *dst = -(*dst); } @@ -751,15 +751,15 @@ ASSIMP_API void aiVector2Negate( ASSIMP_API float aiVector2DotProduct( const C_STRUCT aiVector2D *a, const C_STRUCT aiVector2D *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return (*a) * (*b); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2Normalize( C_STRUCT aiVector2D *v) { - ai_assert(NULL != v); + ai_assert(nullptr != v); v->Normalize(); } @@ -767,8 +767,8 @@ ASSIMP_API void aiVector2Normalize( ASSIMP_API int aiVector3AreEqual( const C_STRUCT aiVector3D *a, const C_STRUCT aiVector3D *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return *a == *b; } @@ -777,8 +777,8 @@ ASSIMP_API int aiVector3AreEqualEpsilon( const C_STRUCT aiVector3D *a, const C_STRUCT aiVector3D *b, const float epsilon) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return a->Equal(*b, epsilon); } @@ -786,8 +786,8 @@ ASSIMP_API int aiVector3AreEqualEpsilon( ASSIMP_API int aiVector3LessThan( const C_STRUCT aiVector3D *a, const C_STRUCT aiVector3D *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return *a < *b; } @@ -795,8 +795,8 @@ ASSIMP_API int aiVector3LessThan( ASSIMP_API void aiVector3Add( C_STRUCT aiVector3D *dst, const C_STRUCT aiVector3D *src) { - ai_assert(NULL != dst); - ai_assert(NULL != src); + ai_assert(nullptr != dst); + ai_assert(nullptr != src); *dst = *dst + *src; } @@ -804,8 +804,8 @@ ASSIMP_API void aiVector3Add( ASSIMP_API void aiVector3Subtract( C_STRUCT aiVector3D *dst, const C_STRUCT aiVector3D *src) { - ai_assert(NULL != dst); - ai_assert(NULL != src); + ai_assert(nullptr != dst); + ai_assert(nullptr != src); *dst = *dst - *src; } @@ -813,7 +813,7 @@ ASSIMP_API void aiVector3Subtract( ASSIMP_API void aiVector3Scale( C_STRUCT aiVector3D *dst, const float s) { - ai_assert(NULL != dst); + ai_assert(nullptr != dst); *dst *= s; } @@ -821,15 +821,15 @@ ASSIMP_API void aiVector3Scale( ASSIMP_API void aiVector3SymMul( C_STRUCT aiVector3D *dst, const C_STRUCT aiVector3D *other) { - ai_assert(NULL != dst); - ai_assert(NULL != other); + ai_assert(nullptr != dst); + ai_assert(nullptr != other); *dst = dst->SymMul(*other); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3DivideByScalar( C_STRUCT aiVector3D *dst, const float s) { - ai_assert(NULL != dst); + ai_assert(nullptr != dst); *dst /= s; } @@ -837,29 +837,29 @@ ASSIMP_API void aiVector3DivideByScalar( ASSIMP_API void aiVector3DivideByVector( C_STRUCT aiVector3D *dst, C_STRUCT aiVector3D *v) { - ai_assert(NULL != dst); - ai_assert(NULL != v); + ai_assert(nullptr != dst); + ai_assert(nullptr != v); *dst = *dst / *v; } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector3Length( const C_STRUCT aiVector3D *v) { - ai_assert(NULL != v); + ai_assert(nullptr != v); return v->Length(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector3SquareLength( const C_STRUCT aiVector3D *v) { - ai_assert(NULL != v); + ai_assert(nullptr != v); return v->SquareLength(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3Negate( C_STRUCT aiVector3D *dst) { - ai_assert(NULL != dst); + ai_assert(nullptr != dst); *dst = -(*dst); } @@ -867,8 +867,8 @@ ASSIMP_API void aiVector3Negate( ASSIMP_API float aiVector3DotProduct( const C_STRUCT aiVector3D *a, const C_STRUCT aiVector3D *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return (*a) * (*b); } @@ -877,23 +877,23 @@ ASSIMP_API void aiVector3CrossProduct( C_STRUCT aiVector3D *dst, const C_STRUCT aiVector3D *a, const C_STRUCT aiVector3D *b) { - ai_assert(NULL != dst); - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != dst); + ai_assert(nullptr != a); + ai_assert(nullptr != b); *dst = *a ^ *b; } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3Normalize( C_STRUCT aiVector3D *v) { - ai_assert(NULL != v); + ai_assert(nullptr != v); v->Normalize(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3NormalizeSafe( C_STRUCT aiVector3D *v) { - ai_assert(NULL != v); + ai_assert(nullptr != v); v->NormalizeSafe(); } @@ -901,8 +901,8 @@ ASSIMP_API void aiVector3NormalizeSafe( ASSIMP_API void aiVector3RotateByQuaternion( C_STRUCT aiVector3D *v, const C_STRUCT aiQuaternion *q) { - ai_assert(NULL != v); - ai_assert(NULL != q); + ai_assert(nullptr != v); + ai_assert(nullptr != q); *v = q->Rotate(*v); } @@ -910,8 +910,8 @@ ASSIMP_API void aiVector3RotateByQuaternion( ASSIMP_API void aiMatrix3FromMatrix4( C_STRUCT aiMatrix3x3 *dst, const C_STRUCT aiMatrix4x4 *mat) { - ai_assert(NULL != dst); - ai_assert(NULL != mat); + ai_assert(nullptr != dst); + ai_assert(nullptr != mat); *dst = aiMatrix3x3(*mat); } @@ -919,8 +919,8 @@ ASSIMP_API void aiMatrix3FromMatrix4( ASSIMP_API void aiMatrix3FromQuaternion( C_STRUCT aiMatrix3x3 *mat, const C_STRUCT aiQuaternion *q) { - ai_assert(NULL != mat); - ai_assert(NULL != q); + ai_assert(nullptr != mat); + ai_assert(nullptr != q); *mat = q->GetMatrix(); } @@ -928,8 +928,8 @@ ASSIMP_API void aiMatrix3FromQuaternion( ASSIMP_API int aiMatrix3AreEqual( const C_STRUCT aiMatrix3x3 *a, const C_STRUCT aiMatrix3x3 *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return *a == *b; } @@ -938,20 +938,20 @@ ASSIMP_API int aiMatrix3AreEqualEpsilon( const C_STRUCT aiMatrix3x3 *a, const C_STRUCT aiMatrix3x3 *b, const float epsilon) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return a->Equal(*b, epsilon); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix3Inverse(C_STRUCT aiMatrix3x3 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); mat->Inverse(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiMatrix3Determinant(const C_STRUCT aiMatrix3x3 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); return mat->Determinant(); } @@ -959,7 +959,7 @@ ASSIMP_API float aiMatrix3Determinant(const C_STRUCT aiMatrix3x3 *mat) { ASSIMP_API void aiMatrix3RotationZ( C_STRUCT aiMatrix3x3 *mat, const float angle) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); aiMatrix3x3::RotationZ(angle, *mat); } @@ -968,8 +968,8 @@ ASSIMP_API void aiMatrix3FromRotationAroundAxis( C_STRUCT aiMatrix3x3 *mat, const C_STRUCT aiVector3D *axis, const float angle) { - ai_assert(NULL != mat); - ai_assert(NULL != axis); + ai_assert(nullptr != mat); + ai_assert(nullptr != axis); aiMatrix3x3::Rotation(angle, *axis, *mat); } @@ -977,8 +977,8 @@ ASSIMP_API void aiMatrix3FromRotationAroundAxis( ASSIMP_API void aiMatrix3Translation( C_STRUCT aiMatrix3x3 *mat, const C_STRUCT aiVector2D *translation) { - ai_assert(NULL != mat); - ai_assert(NULL != translation); + ai_assert(nullptr != mat); + ai_assert(nullptr != translation); aiMatrix3x3::Translation(*translation, *mat); } @@ -987,9 +987,9 @@ ASSIMP_API void aiMatrix3FromTo( C_STRUCT aiMatrix3x3 *mat, const C_STRUCT aiVector3D *from, const C_STRUCT aiVector3D *to) { - ai_assert(NULL != mat); - ai_assert(NULL != from); - ai_assert(NULL != to); + ai_assert(nullptr != mat); + ai_assert(nullptr != from); + ai_assert(nullptr != to); aiMatrix3x3::FromToMatrix(*from, *to, *mat); } @@ -997,8 +997,8 @@ ASSIMP_API void aiMatrix3FromTo( ASSIMP_API void aiMatrix4FromMatrix3( C_STRUCT aiMatrix4x4 *dst, const C_STRUCT aiMatrix3x3 *mat) { - ai_assert(NULL != dst); - ai_assert(NULL != mat); + ai_assert(nullptr != dst); + ai_assert(nullptr != mat); *dst = aiMatrix4x4(*mat); } @@ -1008,10 +1008,10 @@ ASSIMP_API void aiMatrix4FromScalingQuaternionPosition( const C_STRUCT aiVector3D *scaling, const C_STRUCT aiQuaternion *rotation, const C_STRUCT aiVector3D *position) { - ai_assert(NULL != mat); - ai_assert(NULL != scaling); - ai_assert(NULL != rotation); - ai_assert(NULL != position); + ai_assert(nullptr != mat); + ai_assert(nullptr != scaling); + ai_assert(nullptr != rotation); + ai_assert(nullptr != position); *mat = aiMatrix4x4(*scaling, *rotation, *position); } @@ -1019,8 +1019,8 @@ ASSIMP_API void aiMatrix4FromScalingQuaternionPosition( ASSIMP_API void aiMatrix4Add( C_STRUCT aiMatrix4x4 *dst, const C_STRUCT aiMatrix4x4 *src) { - ai_assert(NULL != dst); - ai_assert(NULL != src); + ai_assert(nullptr != dst); + ai_assert(nullptr != src); *dst = *dst + *src; } @@ -1028,8 +1028,8 @@ ASSIMP_API void aiMatrix4Add( ASSIMP_API int aiMatrix4AreEqual( const C_STRUCT aiMatrix4x4 *a, const C_STRUCT aiMatrix4x4 *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return *a == *b; } @@ -1038,26 +1038,26 @@ ASSIMP_API int aiMatrix4AreEqualEpsilon( const C_STRUCT aiMatrix4x4 *a, const C_STRUCT aiMatrix4x4 *b, const float epsilon) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return a->Equal(*b, epsilon); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4Inverse(C_STRUCT aiMatrix4x4 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); mat->Inverse(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiMatrix4Determinant(const C_STRUCT aiMatrix4x4 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); return mat->Determinant(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiMatrix4IsIdentity(const C_STRUCT aiMatrix4x4 *mat) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); return mat->IsIdentity(); } @@ -1067,10 +1067,10 @@ ASSIMP_API void aiMatrix4DecomposeIntoScalingEulerAnglesPosition( C_STRUCT aiVector3D *scaling, C_STRUCT aiVector3D *rotation, C_STRUCT aiVector3D *position) { - ai_assert(NULL != mat); - ai_assert(NULL != scaling); - ai_assert(NULL != rotation); - ai_assert(NULL != position); + ai_assert(nullptr != mat); + ai_assert(nullptr != scaling); + ai_assert(nullptr != rotation); + ai_assert(nullptr != position); mat->Decompose(*scaling, *rotation, *position); } @@ -1079,13 +1079,13 @@ ASSIMP_API void aiMatrix4DecomposeIntoScalingAxisAnglePosition( const C_STRUCT aiMatrix4x4 *mat, C_STRUCT aiVector3D *scaling, C_STRUCT aiVector3D *axis, - float *angle, + ai_real *angle, C_STRUCT aiVector3D *position) { - ai_assert(NULL != mat); - ai_assert(NULL != scaling); - ai_assert(NULL != axis); - ai_assert(NULL != angle); - ai_assert(NULL != position); + ai_assert(nullptr != mat); + ai_assert(nullptr != scaling); + ai_assert(nullptr != axis); + ai_assert(nullptr != angle); + ai_assert(nullptr != position); mat->Decompose(*scaling, *axis, *angle, *position); } @@ -1094,9 +1094,9 @@ ASSIMP_API void aiMatrix4DecomposeNoScaling( const C_STRUCT aiMatrix4x4 *mat, C_STRUCT aiQuaternion *rotation, C_STRUCT aiVector3D *position) { - ai_assert(NULL != mat); - ai_assert(NULL != rotation); - ai_assert(NULL != position); + ai_assert(nullptr != mat); + ai_assert(nullptr != rotation); + ai_assert(nullptr != position); mat->DecomposeNoScaling(*rotation, *position); } @@ -1104,7 +1104,7 @@ ASSIMP_API void aiMatrix4DecomposeNoScaling( ASSIMP_API void aiMatrix4FromEulerAngles( C_STRUCT aiMatrix4x4 *mat, float x, float y, float z) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); mat->FromEulerAnglesXYZ(x, y, z); } @@ -1112,7 +1112,7 @@ ASSIMP_API void aiMatrix4FromEulerAngles( ASSIMP_API void aiMatrix4RotationX( C_STRUCT aiMatrix4x4 *mat, const float angle) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); aiMatrix4x4::RotationX(angle, *mat); } @@ -1128,7 +1128,7 @@ ASSIMP_API void aiMatrix4RotationY( ASSIMP_API void aiMatrix4RotationZ( C_STRUCT aiMatrix4x4 *mat, const float angle) { - ai_assert(NULL != mat); + ai_assert(nullptr != mat); aiMatrix4x4::RotationZ(angle, *mat); } @@ -1137,8 +1137,8 @@ ASSIMP_API void aiMatrix4FromRotationAroundAxis( C_STRUCT aiMatrix4x4 *mat, const C_STRUCT aiVector3D *axis, const float angle) { - ai_assert(NULL != mat); - ai_assert(NULL != axis); + ai_assert(nullptr != mat); + ai_assert(nullptr != axis); aiMatrix4x4::Rotation(angle, *axis, *mat); } @@ -1146,8 +1146,8 @@ ASSIMP_API void aiMatrix4FromRotationAroundAxis( ASSIMP_API void aiMatrix4Translation( C_STRUCT aiMatrix4x4 *mat, const C_STRUCT aiVector3D *translation) { - ai_assert(NULL != mat); - ai_assert(NULL != translation); + ai_assert(nullptr != mat); + ai_assert(nullptr != translation); aiMatrix4x4::Translation(*translation, *mat); } @@ -1155,8 +1155,8 @@ ASSIMP_API void aiMatrix4Translation( ASSIMP_API void aiMatrix4Scaling( C_STRUCT aiMatrix4x4 *mat, const C_STRUCT aiVector3D *scaling) { - ai_assert(NULL != mat); - ai_assert(NULL != scaling); + ai_assert(nullptr != mat); + ai_assert(nullptr != scaling); aiMatrix4x4::Scaling(*scaling, *mat); } @@ -1165,9 +1165,9 @@ ASSIMP_API void aiMatrix4FromTo( C_STRUCT aiMatrix4x4 *mat, const C_STRUCT aiVector3D *from, const C_STRUCT aiVector3D *to) { - ai_assert(NULL != mat); - ai_assert(NULL != from); - ai_assert(NULL != to); + ai_assert(nullptr != mat); + ai_assert(nullptr != from); + ai_assert(nullptr != to); aiMatrix4x4::FromToMatrix(*from, *to, *mat); } @@ -1175,7 +1175,7 @@ ASSIMP_API void aiMatrix4FromTo( ASSIMP_API void aiQuaternionFromEulerAngles( C_STRUCT aiQuaternion *q, float x, float y, float z) { - ai_assert(NULL != q); + ai_assert(nullptr != q); *q = aiQuaternion(x, y, z); } @@ -1184,8 +1184,8 @@ ASSIMP_API void aiQuaternionFromAxisAngle( C_STRUCT aiQuaternion *q, const C_STRUCT aiVector3D *axis, const float angle) { - ai_assert(NULL != q); - ai_assert(NULL != axis); + ai_assert(nullptr != q); + ai_assert(nullptr != axis); *q = aiQuaternion(*axis, angle); } @@ -1193,8 +1193,8 @@ ASSIMP_API void aiQuaternionFromAxisAngle( ASSIMP_API void aiQuaternionFromNormalizedQuaternion( C_STRUCT aiQuaternion *q, const C_STRUCT aiVector3D *normalized) { - ai_assert(NULL != q); - ai_assert(NULL != normalized); + ai_assert(nullptr != q); + ai_assert(nullptr != normalized); *q = aiQuaternion(*normalized); } @@ -1202,8 +1202,8 @@ ASSIMP_API void aiQuaternionFromNormalizedQuaternion( ASSIMP_API int aiQuaternionAreEqual( const C_STRUCT aiQuaternion *a, const C_STRUCT aiQuaternion *b) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return *a == *b; } @@ -1212,22 +1212,22 @@ ASSIMP_API int aiQuaternionAreEqualEpsilon( const C_STRUCT aiQuaternion *a, const C_STRUCT aiQuaternion *b, const float epsilon) { - ai_assert(NULL != a); - ai_assert(NULL != b); + ai_assert(nullptr != a); + ai_assert(nullptr != b); return a->Equal(*b, epsilon); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionNormalize( C_STRUCT aiQuaternion *q) { - ai_assert(NULL != q); + ai_assert(nullptr != q); q->Normalize(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionConjugate( C_STRUCT aiQuaternion *q) { - ai_assert(NULL != q); + ai_assert(nullptr != q); q->Conjugate(); } @@ -1235,8 +1235,8 @@ ASSIMP_API void aiQuaternionConjugate( ASSIMP_API void aiQuaternionMultiply( C_STRUCT aiQuaternion *dst, const C_STRUCT aiQuaternion *q) { - ai_assert(NULL != dst); - ai_assert(NULL != q); + ai_assert(nullptr != dst); + ai_assert(nullptr != q); *dst = (*dst) * (*q); } @@ -1246,8 +1246,8 @@ ASSIMP_API void aiQuaternionInterpolate( const C_STRUCT aiQuaternion *start, const C_STRUCT aiQuaternion *end, const float factor) { - ai_assert(NULL != dst); - ai_assert(NULL != start); - ai_assert(NULL != end); + ai_assert(nullptr != dst); + ai_assert(nullptr != start); + ai_assert(nullptr != end); aiQuaternion::Interpolate(*dst, *start, *end, factor); } diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 71049a996..47ff05f2f 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -45,28 +45,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of BaseImporter */ -#include -#include #include "FileSystemFilter.h" #include "Importer.h" +#include #include +#include +#include +#include #include #include -#include -#include +#include #include #include #include #include -#include using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer BaseImporter::BaseImporter() AI_NO_EXCEPT -: m_progress() { + : m_progress() { /** * Assimp Importer * unit conversions available @@ -89,8 +89,7 @@ BaseImporter::~BaseImporter() { // nothing to do here } -void BaseImporter::UpdateImporterScale( Importer* pImp ) -{ +void BaseImporter::UpdateImporterScale(Importer *pImp) { ai_assert(pImp != nullptr); ai_assert(importerScale != 0.0); ai_assert(fileScale != 0.0); @@ -98,15 +97,14 @@ void BaseImporter::UpdateImporterScale( Importer* pImp ) double activeScale = importerScale * fileScale; // Set active scaling - pImp->SetPropertyFloat( AI_CONFIG_APP_SCALE_KEY, static_cast( activeScale) ); + pImp->SetPropertyFloat(AI_CONFIG_APP_SCALE_KEY, static_cast(activeScale)); - ASSIMP_LOG_DEBUG_F("UpdateImporterScale scale set: %f", activeScale ); + ASSIMP_LOG_DEBUG_F("UpdateImporterScale scale set: %f", activeScale); } // ------------------------------------------------------------------------------------------------ // Imports the given file and returns the imported data. -aiScene* BaseImporter::ReadFile(Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) { - +aiScene *BaseImporter::ReadFile(Importer *pImp, const std::string &pFile, IOSystem *pIOHandler) { m_progress = pImp->GetProgressHandler(); if (nullptr == m_progress) { @@ -116,25 +114,23 @@ aiScene* BaseImporter::ReadFile(Importer* pImp, const std::string& pFile, IOSyst ai_assert(m_progress); // Gather configuration properties for this run - SetupProperties( pImp ); + SetupProperties(pImp); // Construct a file system filter to improve our success ratio at reading external files - FileSystemFilter filter(pFile,pIOHandler); + FileSystemFilter filter(pFile, pIOHandler); // create a scene object to hold the data std::unique_ptr sc(new aiScene()); // dispatch importing - try - { - InternReadFile( pFile, sc.get(), &filter); + try { + InternReadFile(pFile, sc.get(), &filter); // Calculate import scale hook - required because pImp not available anywhere else // passes scale into ScaleProcess UpdateImporterScale(pImp); - - } catch( const std::exception& err ) { + } catch (const std::exception &err) { // extract error description m_ErrorText = err.what(); ASSIMP_LOG_ERROR(m_ErrorText); @@ -146,69 +142,66 @@ aiScene* BaseImporter::ReadFile(Importer* pImp, const std::string& pFile, IOSyst } // ------------------------------------------------------------------------------------------------ -void BaseImporter::SetupProperties(const Importer* ) -{ +void BaseImporter::SetupProperties(const Importer *) { // the default implementation does nothing } // ------------------------------------------------------------------------------------------------ -void BaseImporter::GetExtensionList(std::set& extensions) { - const aiImporterDesc* desc = GetInfo(); +void BaseImporter::GetExtensionList(std::set &extensions) { + const aiImporterDesc *desc = GetInfo(); ai_assert(desc != nullptr); - const char* ext = desc->mFileExtensions; - ai_assert(ext != nullptr ); + const char *ext = desc->mFileExtensions; + ai_assert(ext != nullptr); - const char* last = ext; + const char *last = ext; do { if (!*ext || *ext == ' ') { - extensions.insert(std::string(last,ext-last)); - ai_assert(ext-last > 0); + extensions.insert(std::string(last, ext - last)); + ai_assert(ext - last > 0); last = ext; - while(*last == ' ') { + while (*last == ' ') { ++last; } } - } - while(*ext++); + } while (*ext++); } // ------------------------------------------------------------------------------------------------ -/*static*/ bool BaseImporter::SearchFileHeaderForToken( IOSystem* pIOHandler, - const std::string& pFile, - const char** tokens, - unsigned int numTokens, - unsigned int searchBytes /* = 200 */, - bool tokensSol /* false */, - bool noAlphaBeforeTokens /* false */) -{ - ai_assert( nullptr != tokens ); - ai_assert( 0 != numTokens ); - ai_assert( 0 != searchBytes); +/*static*/ bool BaseImporter::SearchFileHeaderForToken(IOSystem *pIOHandler, + const std::string &pFile, + const char **tokens, + unsigned int numTokens, + unsigned int searchBytes /* = 200 */, + bool tokensSol /* false */, + bool noAlphaBeforeTokens /* false */) { + ai_assert(nullptr != tokens); + ai_assert(0 != numTokens); + ai_assert(0 != searchBytes); - if ( nullptr == pIOHandler ) { + if (nullptr == pIOHandler) { return false; } - std::unique_ptr pStream (pIOHandler->Open(pFile)); + std::unique_ptr pStream(pIOHandler->Open(pFile)); if (pStream) { // read 200 characters from the file - std::unique_ptr _buffer (new char[searchBytes+1 /* for the '\0' */]); - char *buffer( _buffer.get() ); - const size_t read( pStream->Read(buffer,1,searchBytes) ); - if( 0 == read ) { + std::unique_ptr _buffer(new char[searchBytes + 1 /* for the '\0' */]); + char *buffer(_buffer.get()); + const size_t read(pStream->Read(buffer, 1, searchBytes)); + if (0 == read) { return false; } - for( size_t i = 0; i < read; ++i ) { - buffer[ i ] = static_cast( ::tolower( buffer[ i ] ) ); + for (size_t i = 0; i < read; ++i) { + buffer[i] = static_cast(::tolower(buffer[i])); } // It is not a proper handling of unicode files here ... // ehm ... but it works in most cases. - char* cur = buffer,*cur2 = buffer,*end = &buffer[read]; - while (cur != end) { - if( *cur ) { + char *cur = buffer, *cur2 = buffer, *end = &buffer[read]; + while (cur != end) { + if (*cur) { *cur2++ = *cur; } ++cur; @@ -216,17 +209,17 @@ void BaseImporter::GetExtensionList(std::set& extensions) { *cur2 = '\0'; std::string token; - for (unsigned int i = 0; i < numTokens; ++i ) { - ai_assert( nullptr != tokens[i] ); - const size_t len( strlen( tokens[ i ] ) ); + for (unsigned int i = 0; i < numTokens; ++i) { + ai_assert(nullptr != tokens[i]); + const size_t len(strlen(tokens[i])); token.clear(); - const char *ptr( tokens[ i ] ); - for ( size_t tokIdx = 0; tokIdx < len; ++tokIdx ) { - token.push_back( static_cast( tolower( *ptr ) ) ); + const char *ptr(tokens[i]); + for (size_t tokIdx = 0; tokIdx < len; ++tokIdx) { + token.push_back(static_cast(tolower(*ptr))); ++ptr; } - const char* r = strstr( buffer, token.c_str() ); - if( !r ) { + const char *r = strstr(buffer, token.c_str()); + if (!r) { continue; } // We need to make sure that we didn't accidentially identify the end of another token as our token, @@ -237,7 +230,7 @@ void BaseImporter::GetExtensionList(std::set& extensions) { // We got a match, either we don't care where it is, or it happens to // be in the beginning of the file / line if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { - ASSIMP_LOG_DEBUG_F( "Found positive match for header keyword: ", tokens[i] ); + ASSIMP_LOG_DEBUG_F("Found positive match for header keyword: ", tokens[i]); return true; } } @@ -248,26 +241,25 @@ void BaseImporter::GetExtensionList(std::set& extensions) { // ------------------------------------------------------------------------------------------------ // Simple check for file extension -/*static*/ bool BaseImporter::SimpleExtensionCheck (const std::string& pFile, - const char* ext0, - const char* ext1, - const char* ext2) -{ +/*static*/ bool BaseImporter::SimpleExtensionCheck(const std::string &pFile, + const char *ext0, + const char *ext1, + const char *ext2) { std::string::size_type pos = pFile.find_last_of('.'); // no file extension - can't read - if( pos == std::string::npos) + if (pos == std::string::npos) return false; - const char* ext_real = & pFile[ pos+1 ]; - if( !ASSIMP_stricmp(ext_real,ext0) ) + const char *ext_real = &pFile[pos + 1]; + if (!ASSIMP_stricmp(ext_real, ext0)) return true; // check for other, optional, file extensions - if (ext1 && !ASSIMP_stricmp(ext_real,ext1)) + if (ext1 && !ASSIMP_stricmp(ext_real, ext1)) return true; - if (ext2 && !ASSIMP_stricmp(ext_real,ext2)) + if (ext2 && !ASSIMP_stricmp(ext_real, ext2)) return true; return false; @@ -275,7 +267,7 @@ void BaseImporter::GetExtensionList(std::set& extensions) { // ------------------------------------------------------------------------------------------------ // Get file extension from path -std::string BaseImporter::GetExtension( const std::string& file ) { +std::string BaseImporter::GetExtension(const std::string &file) { std::string::size_type pos = file.find_last_of('.'); // no file extension at all @@ -284,34 +276,33 @@ std::string BaseImporter::GetExtension( const std::string& file ) { } // thanks to Andy Maloney for the hint - std::string ret = file.substr( pos + 1 ); - std::transform( ret.begin(), ret.end(), ret.begin(), ToLower); + std::string ret = file.substr(pos + 1); + std::transform(ret.begin(), ret.end(), ret.begin(), ToLower); return ret; } // ------------------------------------------------------------------------------------------------ // Check for magic bytes at the beginning of the file. -/* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile, - const void* _magic, unsigned int num, unsigned int offset, unsigned int size) -{ - ai_assert( size <= 16 ); - ai_assert( _magic ); +/* static */ bool BaseImporter::CheckMagicToken(IOSystem *pIOHandler, const std::string &pFile, + const void *_magic, unsigned int num, unsigned int offset, unsigned int size) { + ai_assert(size <= 16); + ai_assert(_magic); if (!pIOHandler) { return false; } union { - const char* magic; - const uint16_t* magic_u16; - const uint32_t* magic_u32; + const char *magic; + const uint16_t *magic_u16; + const uint32_t *magic_u32; }; - magic = reinterpret_cast(_magic); - std::unique_ptr pStream (pIOHandler->Open(pFile)); + magic = reinterpret_cast(_magic); + std::unique_ptr pStream(pIOHandler->Open(pFile)); if (pStream) { // skip to offset - pStream->Seek(offset,aiOrigin_SET); + pStream->Seek(offset, aiOrigin_SET); // read 'size' characters from the file union { @@ -319,7 +310,7 @@ std::string BaseImporter::GetExtension( const std::string& file ) { uint16_t data_u16[8]; uint32_t data_u32[4]; }; - if(size != pStream->Read(data,1,size)) { + if (size != pStream->Read(data, 1, size)) { return false; } @@ -333,17 +324,15 @@ std::string BaseImporter::GetExtension( const std::string& file ) { if (data_u16[0] == *magic_u16 || data_u16[0] == rev) { return true; } - } - else if (4 == size) { + } else if (4 == size) { uint32_t rev = *magic_u32; ByteSwap::Swap(&rev); if (data_u32[0] == *magic_u32 || data_u32[0] == rev) { return true; } - } - else { + } else { // any length ... just compare - if(!memcmp(magic,data,size)) { + if (!memcmp(magic, data, size)) { return true; } } @@ -354,61 +343,59 @@ std::string BaseImporter::GetExtension( const std::string& file ) { } #ifdef ASSIMP_USE_HUNTER -# include +#include #else -# include "../contrib/utf8cpp/source/utf8.h" +#include "../contrib/utf8cpp/source/utf8.h" #endif // ------------------------------------------------------------------------------------------------ // Convert to UTF8 data -void BaseImporter::ConvertToUTF8(std::vector& data) -{ +void BaseImporter::ConvertToUTF8(std::vector &data) { //ConversionResult result; - if(data.size() < 8) { + if (data.size() < 8) { throw DeadlyImportError("File is too small"); } // UTF 8 with BOM - if((uint8_t)data[0] == 0xEF && (uint8_t)data[1] == 0xBB && (uint8_t)data[2] == 0xBF) { + if ((uint8_t)data[0] == 0xEF && (uint8_t)data[1] == 0xBB && (uint8_t)data[2] == 0xBF) { ASSIMP_LOG_DEBUG("Found UTF-8 BOM ..."); - std::copy(data.begin()+3,data.end(),data.begin()); - data.resize(data.size()-3); + std::copy(data.begin() + 3, data.end(), data.begin()); + data.resize(data.size() - 3); return; } - - + // UTF 32 BE with BOM - if(*((uint32_t*)&data.front()) == 0xFFFE0000) { + if (*((uint32_t *)&data.front()) == 0xFFFE0000) { // swap the endianness .. - for(uint32_t* p = (uint32_t*)&data.front(), *end = (uint32_t*)&data.back(); p <= end; ++p) { + for (uint32_t *p = (uint32_t *)&data.front(), *end = (uint32_t *)&data.back(); p <= end; ++p) { AI_SWAP4P(p); } } // UTF 32 LE with BOM - if(*((uint32_t*)&data.front()) == 0x0000FFFE) { + if (*((uint32_t *)&data.front()) == 0x0000FFFE) { ASSIMP_LOG_DEBUG("Found UTF-32 BOM ..."); std::vector output; - int *ptr = (int*)&data[ 0 ]; - int *end = ptr + ( data.size() / sizeof(int) ) +1; - utf8::utf32to8( ptr, end, back_inserter(output)); + int *ptr = (int *)&data[0]; + int *end = ptr + (data.size() / sizeof(int)) + 1; + utf8::utf32to8(ptr, end, back_inserter(output)); return; } // UTF 16 BE with BOM - if(*((uint16_t*)&data.front()) == 0xFFFE) { + if (*((uint16_t *)&data.front()) == 0xFFFE) { // swap the endianness .. - for(uint16_t* p = (uint16_t*)&data.front(), *end = (uint16_t*)&data.back(); p <= end; ++p) { + for (uint16_t *p = (uint16_t *)&data.front(), *end = (uint16_t *)&data.back(); p <= end; ++p) { ByteSwap::Swap2(p); } } // UTF 16 LE with BOM - if(*((uint16_t*)&data.front()) == 0xFEFF) { + if (*((uint16_t *)&data.front()) == 0xFEFF) { ASSIMP_LOG_DEBUG("Found UTF-16 BOM ..."); std::vector output; @@ -419,23 +406,22 @@ void BaseImporter::ConvertToUTF8(std::vector& data) // ------------------------------------------------------------------------------------------------ // Convert to UTF8 data to ISO-8859-1 -void BaseImporter::ConvertUTF8toISO8859_1(std::string& data) -{ +void BaseImporter::ConvertUTF8toISO8859_1(std::string &data) { size_t size = data.size(); size_t i = 0, j = 0; - while(i < size) { - if ((unsigned char) data[i] < (size_t) 0x80) { + while (i < size) { + if ((unsigned char)data[i] < (size_t)0x80) { data[j] = data[i]; - } else if(i < size - 1) { - if((unsigned char) data[i] == 0xC2) { + } else if (i < size - 1) { + if ((unsigned char)data[i] == 0xC2) { data[j] = data[++i]; - } else if((unsigned char) data[i] == 0xC3) { - data[j] = ((unsigned char) data[++i] + 0x40); + } else if ((unsigned char)data[i] == 0xC3) { + data[j] = ((unsigned char)data[++i] + 0x40); } else { std::stringstream stream; stream << "UTF8 code " << std::hex << data[i] << data[i + 1] << " can not be converted into ISA-8859-1."; - ASSIMP_LOG_ERROR( stream.str() ); + ASSIMP_LOG_ERROR(stream.str()); data[j++] = data[i++]; data[j] = data[i]; @@ -446,30 +432,30 @@ void BaseImporter::ConvertUTF8toISO8859_1(std::string& data) data[j] = data[i]; } - i++; j++; + i++; + j++; } data.resize(j); } // ------------------------------------------------------------------------------------------------ -void BaseImporter::TextFileToBuffer(IOStream* stream, - std::vector& data, - TextFileMode mode) -{ +void BaseImporter::TextFileToBuffer(IOStream *stream, + std::vector &data, + TextFileMode mode) { ai_assert(nullptr != stream); const size_t fileSize = stream->FileSize(); if (mode == FORBID_EMPTY) { - if(!fileSize) { + if (!fileSize) { throw DeadlyImportError("File is empty"); } } - data.reserve(fileSize+1); + data.reserve(fileSize + 1); data.resize(fileSize); - if(fileSize > 0) { - if(fileSize != stream->Read( &data[0], 1, fileSize)) { + if (fileSize > 0) { + if (fileSize != stream->Read(&data[0], 1, fileSize)) { throw DeadlyImportError("File read error"); } @@ -482,58 +468,55 @@ void BaseImporter::TextFileToBuffer(IOStream* stream, // ------------------------------------------------------------------------------------------------ namespace Assimp { - // Represents an import request - struct LoadRequest { - LoadRequest(const std::string& _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id) - : file(_file) - , flags(_flags) - , refCnt(1) - , scene(NULL) - , loaded(false) - , id(_id) { - if ( _map ) { - map = *_map; - } +// Represents an import request +struct LoadRequest { + LoadRequest(const std::string &_file, unsigned int _flags, const BatchLoader::PropertyMap *_map, unsigned int _id) : + file(_file), + flags(_flags), + refCnt(1), + scene(nullptr), + loaded(false), + id(_id) { + if (_map) { + map = *_map; } + } - bool operator== ( const std::string& f ) const { - return file == f; - } + bool operator==(const std::string &f) const { + return file == f; + } - const std::string file; - unsigned int flags; - unsigned int refCnt; - aiScene *scene; - bool loaded; - BatchLoader::PropertyMap map; - unsigned int id; - }; -} + const std::string file; + unsigned int flags; + unsigned int refCnt; + aiScene *scene; + bool loaded; + BatchLoader::PropertyMap map; + unsigned int id; +}; +} // namespace Assimp // ------------------------------------------------------------------------------------------------ // BatchLoader::pimpl data structure struct Assimp::BatchData { - BatchData( IOSystem* pIO, bool validate ) - : pIOSystem( pIO ) - , pImporter( nullptr ) - , next_id(0xffff) - , validate( validate ) { - ai_assert( nullptr != pIO ); - + BatchData(IOSystem *pIO, bool validate) : + pIOSystem(pIO), pImporter(nullptr), next_id(0xffff), validate(validate) { + ai_assert(nullptr != pIO); + pImporter = new Importer(); - pImporter->SetIOHandler( pIO ); + pImporter->SetIOHandler(pIO); } ~BatchData() { - pImporter->SetIOHandler( nullptr ); /* get pointer back into our possession */ + pImporter->SetIOHandler(nullptr); /* get pointer back into our possession */ delete pImporter; } // IO system to be used for all imports - IOSystem* pIOSystem; + IOSystem *pIOSystem; // Importer used to load all meshes - Importer* pImporter; + Importer *pImporter; // List of all imports std::list requests; @@ -551,24 +534,23 @@ struct Assimp::BatchData { typedef std::list::iterator LoadReqIt; // ------------------------------------------------------------------------------------------------ -BatchLoader::BatchLoader(IOSystem* pIO, bool validate ) { +BatchLoader::BatchLoader(IOSystem *pIO, bool validate) { ai_assert(nullptr != pIO); - m_data = new BatchData( pIO, validate ); + m_data = new BatchData(pIO, validate); } // ------------------------------------------------------------------------------------------------ -BatchLoader::~BatchLoader() -{ +BatchLoader::~BatchLoader() { // delete all scenes what have not been polled by the user - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { + for (LoadReqIt it = m_data->requests.begin(); it != m_data->requests.end(); ++it) { delete (*it).scene; } delete m_data; } // ------------------------------------------------------------------------------------------------ -void BatchLoader::setValidation( bool enabled ) { +void BatchLoader::setValidation(bool enabled) { m_data->validate = enabled; } @@ -578,21 +560,19 @@ bool BatchLoader::getValidation() const { } // ------------------------------------------------------------------------------------------------ -unsigned int BatchLoader::AddLoadRequest(const std::string& file, - unsigned int steps /*= 0*/, const PropertyMap* map /*= NULL*/) -{ +unsigned int BatchLoader::AddLoadRequest(const std::string &file, + unsigned int steps /*= 0*/, const PropertyMap *map /*= nullptr*/) { ai_assert(!file.empty()); // check whether we have this loading request already - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { + for (LoadReqIt it = m_data->requests.begin(); it != m_data->requests.end(); ++it) { // Call IOSystem's path comparison function here - if ( m_data->pIOSystem->ComparePaths((*it).file,file)) { + if (m_data->pIOSystem->ComparePaths((*it).file, file)) { if (map) { - if ( !( ( *it ).map == *map ) ) { + if (!((*it).map == *map)) { continue; } - } - else if ( !( *it ).map.empty() ) { + } else if (!(*it).map.empty()) { continue; } @@ -607,12 +587,11 @@ unsigned int BatchLoader::AddLoadRequest(const std::string& file, } // ------------------------------------------------------------------------------------------------ -aiScene* BatchLoader::GetImport( unsigned int which ) -{ - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { - if ((*it).id == which && (*it).loaded) { - aiScene* sc = (*it).scene; - if (!(--(*it).refCnt)) { +aiScene *BatchLoader::GetImport(unsigned int which) { + for (LoadReqIt it = m_data->requests.begin(); it != m_data->requests.end(); ++it) { + if ((*it).id == which && (*it).loaded) { + aiScene *sc = (*it).scene; + if (!(--(*it).refCnt)) { m_data->requests.erase(it); } return sc; @@ -621,32 +600,28 @@ aiScene* BatchLoader::GetImport( unsigned int which ) return nullptr; } - - // ------------------------------------------------------------------------------------------------ -void BatchLoader::LoadAll() -{ +void BatchLoader::LoadAll() { // no threaded implementation for the moment - for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) { + for (LoadReqIt it = m_data->requests.begin(); it != m_data->requests.end(); ++it) { // force validation in debug builds unsigned int pp = (*it).flags; - if ( m_data->validate ) { + if (m_data->validate) { pp |= aiProcess_ValidateDataStructure; } // setup config properties if necessary - ImporterPimpl* pimpl = m_data->pImporter->Pimpl(); - pimpl->mFloatProperties = (*it).map.floats; - pimpl->mIntProperties = (*it).map.ints; + ImporterPimpl *pimpl = m_data->pImporter->Pimpl(); + pimpl->mFloatProperties = (*it).map.floats; + pimpl->mIntProperties = (*it).map.ints; pimpl->mStringProperties = (*it).map.strings; pimpl->mMatrixProperties = (*it).map.matrices; - if (!DefaultLogger::isNullLogger()) - { + if (!DefaultLogger::isNullLogger()) { ASSIMP_LOG_INFO("%%% BEGIN EXTERNAL FILE %%%"); ASSIMP_LOG_INFO_F("File: ", (*it).file); } - m_data->pImporter->ReadFile((*it).file,pp); + m_data->pImporter->ReadFile((*it).file, pp); (*it).scene = m_data->pImporter->GetOrphanedScene(); (*it).loaded = true; diff --git a/code/Common/BaseProcess.h b/code/Common/BaseProcess.h index bf1f2586f..b7a9b18fa 100644 --- a/code/Common/BaseProcess.h +++ b/code/Common/BaseProcess.h @@ -126,7 +126,7 @@ public: bool GetProperty(const char *name, T *&out) const { THeapData *t = (THeapData *)GetPropertyInternal(name); if (!t) { - out = NULL; + out = nullptr; return false; } out = t->data; @@ -202,7 +202,7 @@ public: // ------------------------------------------------------------------- /** Executes the post processing step on the given imported data. * The function deletes the scene if the postprocess step fails ( - * the object pointer will be set to NULL). + * the object pointer will be set to nullptr). * @param pImp Importer instance (pImp->mScene must be valid) */ void ExecuteOnScene(Importer *pImp); @@ -225,7 +225,7 @@ public: // ------------------------------------------------------------------- /** Assign a new SharedPostProcessInfo to the step. This object * allows multiple postprocess steps to share data. - * @param sh May be NULL + * @param sh May be nullptr */ inline void SetSharedData(SharedPostProcessInfo *sh) { shared = sh; diff --git a/code/Common/Bitmap.cpp b/code/Common/Bitmap.cpp index 7d8225704..772fd7455 100644 --- a/code/Common/Bitmap.cpp +++ b/code/Common/Bitmap.cpp @@ -47,109 +47,109 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Used for file formats which embed their textures into the model file. */ - #include +#include #include #include -#include namespace Assimp { - void Bitmap::Save(aiTexture* texture, IOStream* file) { - if(file != NULL) { - Header header; - DIB dib; +void Bitmap::Save(aiTexture *texture, IOStream *file) { + if (file != nullptr) { + Header header; + DIB dib; - dib.size = DIB::dib_size; - dib.width = texture->mWidth; - dib.height = texture->mHeight; - dib.planes = 1; - dib.bits_per_pixel = 8 * mBytesPerPixel; - dib.compression = 0; - dib.image_size = (((dib.width * mBytesPerPixel) + 3) & 0x0000FFFC) * dib.height; - dib.x_resolution = 0; - dib.y_resolution = 0; - dib.nb_colors = 0; - dib.nb_important_colors = 0; + dib.size = DIB::dib_size; + dib.width = texture->mWidth; + dib.height = texture->mHeight; + dib.planes = 1; + dib.bits_per_pixel = 8 * mBytesPerPixel; + dib.compression = 0; + dib.image_size = (((dib.width * mBytesPerPixel) + 3) & 0x0000FFFC) * dib.height; + dib.x_resolution = 0; + dib.y_resolution = 0; + dib.nb_colors = 0; + dib.nb_important_colors = 0; - header.type = 0x4D42; // 'BM' - header.offset = Header::header_size + DIB::dib_size; - header.size = header.offset + dib.image_size; - header.reserved1 = 0; - header.reserved2 = 0; + header.type = 0x4D42; // 'BM' + header.offset = Header::header_size + DIB::dib_size; + header.size = header.offset + dib.image_size; + header.reserved1 = 0; + header.reserved2 = 0; - WriteHeader(header, file); - WriteDIB(dib, file); - WriteData(texture, file); - } + WriteHeader(header, file); + WriteDIB(dib, file); + WriteData(texture, file); } - - template - inline - std::size_t Copy(uint8_t* data, const T &field) { -#ifdef AI_BUILD_BIG_ENDIAN - T field_swapped=AI_BE(field); - std::memcpy(data, &field_swapped, sizeof(field)); return sizeof(field); -#else - std::memcpy(data, &AI_BE(field), sizeof(field)); return sizeof(field); -#endif - } - - void Bitmap::WriteHeader(Header& header, IOStream* file) { - uint8_t data[Header::header_size]; - - std::size_t offset = 0; - - offset += Copy(&data[offset], header.type); - offset += Copy(&data[offset], header.size); - offset += Copy(&data[offset], header.reserved1); - offset += Copy(&data[offset], header.reserved2); - Copy(&data[offset], header.offset); - - file->Write(data, Header::header_size, 1); - } - - void Bitmap::WriteDIB(DIB& dib, IOStream* file) { - uint8_t data[DIB::dib_size]; - - std::size_t offset = 0; - - offset += Copy(&data[offset], dib.size); - offset += Copy(&data[offset], dib.width); - offset += Copy(&data[offset], dib.height); - offset += Copy(&data[offset], dib.planes); - offset += Copy(&data[offset], dib.bits_per_pixel); - offset += Copy(&data[offset], dib.compression); - offset += Copy(&data[offset], dib.image_size); - offset += Copy(&data[offset], dib.x_resolution); - offset += Copy(&data[offset], dib.y_resolution); - offset += Copy(&data[offset], dib.nb_colors); - Copy(&data[offset], dib.nb_important_colors); - - file->Write(data, DIB::dib_size, 1); - } - - void Bitmap::WriteData(aiTexture* texture, IOStream* file) { - static const std::size_t padding_offset = 4; - static const uint8_t padding_data[padding_offset] = {0x0, 0x0, 0x0, 0x0}; - - unsigned int padding = (padding_offset - ((mBytesPerPixel * texture->mWidth) % padding_offset)) % padding_offset; - uint8_t pixel[mBytesPerPixel]; - - for(std::size_t i = 0; i < texture->mHeight; ++i) { - for(std::size_t j = 0; j < texture->mWidth; ++j) { - const aiTexel& texel = texture->pcData[(texture->mHeight - i - 1) * texture->mWidth + j]; // Bitmap files are stored in bottom-up format - - pixel[0] = texel.r; - pixel[1] = texel.g; - pixel[2] = texel.b; - pixel[3] = texel.a; - - file->Write(pixel, mBytesPerPixel, 1); - } - - file->Write(padding_data, padding, 1); - } - } - } + +template +inline std::size_t Copy(uint8_t *data, const T &field) { +#ifdef AI_BUILD_BIG_ENDIAN + T field_swapped = AI_BE(field); + std::memcpy(data, &field_swapped, sizeof(field)); + return sizeof(field); +#else + std::memcpy(data, &AI_BE(field), sizeof(field)); + return sizeof(field); +#endif +} + +void Bitmap::WriteHeader(Header &header, IOStream *file) { + uint8_t data[Header::header_size]; + + std::size_t offset = 0; + + offset += Copy(&data[offset], header.type); + offset += Copy(&data[offset], header.size); + offset += Copy(&data[offset], header.reserved1); + offset += Copy(&data[offset], header.reserved2); + Copy(&data[offset], header.offset); + + file->Write(data, Header::header_size, 1); +} + +void Bitmap::WriteDIB(DIB &dib, IOStream *file) { + uint8_t data[DIB::dib_size]; + + std::size_t offset = 0; + + offset += Copy(&data[offset], dib.size); + offset += Copy(&data[offset], dib.width); + offset += Copy(&data[offset], dib.height); + offset += Copy(&data[offset], dib.planes); + offset += Copy(&data[offset], dib.bits_per_pixel); + offset += Copy(&data[offset], dib.compression); + offset += Copy(&data[offset], dib.image_size); + offset += Copy(&data[offset], dib.x_resolution); + offset += Copy(&data[offset], dib.y_resolution); + offset += Copy(&data[offset], dib.nb_colors); + Copy(&data[offset], dib.nb_important_colors); + + file->Write(data, DIB::dib_size, 1); +} + +void Bitmap::WriteData(aiTexture *texture, IOStream *file) { + static const std::size_t padding_offset = 4; + static const uint8_t padding_data[padding_offset] = { 0x0, 0x0, 0x0, 0x0 }; + + unsigned int padding = (padding_offset - ((mBytesPerPixel * texture->mWidth) % padding_offset)) % padding_offset; + uint8_t pixel[mBytesPerPixel]; + + for (std::size_t i = 0; i < texture->mHeight; ++i) { + for (std::size_t j = 0; j < texture->mWidth; ++j) { + const aiTexel &texel = texture->pcData[(texture->mHeight - i - 1) * texture->mWidth + j]; // Bitmap files are stored in bottom-up format + + pixel[0] = texel.r; + pixel[1] = texel.g; + pixel[2] = texel.b; + pixel[3] = texel.a; + + file->Write(pixel, mBytesPerPixel, 1); + } + + file->Write(padding_data, padding, 1); + } +} + +} // namespace Assimp diff --git a/code/Common/CreateAnimMesh.cpp b/code/Common/CreateAnimMesh.cpp index 7317dc45b..05472529d 100644 --- a/code/Common/CreateAnimMesh.cpp +++ b/code/Common/CreateAnimMesh.cpp @@ -70,7 +70,7 @@ aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh) animesh->mColors[i] = new aiColor4D[animesh->mNumVertices]; std::memcpy(animesh->mColors[i], mesh->mColors[i], mesh->mNumVertices * sizeof(aiColor4D)); } else { - animesh->mColors[i] = NULL; + animesh->mColors[i] = nullptr; } } @@ -79,7 +79,7 @@ aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh) animesh->mTextureCoords[i] = new aiVector3D[animesh->mNumVertices]; std::memcpy(animesh->mTextureCoords[i], mesh->mTextureCoords[i], mesh->mNumVertices * sizeof(aiVector3D)); } else { - animesh->mTextureCoords[i] = NULL; + animesh->mTextureCoords[i] = nullptr; } } return animesh; diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp index 63b44d861..65edd1bdd 100644 --- a/code/Common/DefaultIOStream.cpp +++ b/code/Common/DefaultIOStream.cpp @@ -44,46 +44,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Default File I/O implementation for #Importer */ - -#include #include -#include +#include #include +#include using namespace Assimp; -namespace -{ - template - size_t select_ftell(FILE* file) - { - return ::ftell(file); - } - - template - int select_fseek(FILE* file, int64_t offset, int origin) - { - return ::fseek(file, static_cast(offset), origin); - } - -#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) - template<> - size_t select_ftell<8>(FILE* file) - { - return (size_t)::_ftelli64(file); - } - - template<> - int select_fseek<8>(FILE* file, int64_t offset, int origin) - { - return ::_fseeki64(file, offset, origin); - } -#endif +namespace { +template +size_t select_ftell(FILE *file) { + return ::ftell(file); } +template +int select_fseek(FILE *file, int64_t offset, int origin) { + return ::fseek(file, static_cast(offset), origin); +} + +#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) +template <> +size_t select_ftell<8>(FILE *file) { + return (size_t)::_ftelli64(file); +} + +template <> +int select_fseek<8>(FILE *file, int64_t offset, int origin) { + return ::_fseeki64(file, offset, origin); +} +#endif +} // namespace + // ---------------------------------------------------------------------------------- -DefaultIOStream::~DefaultIOStream() -{ +DefaultIOStream::~DefaultIOStream() { if (mFile) { ::fclose(mFile); mFile = nullptr; @@ -91,57 +84,59 @@ DefaultIOStream::~DefaultIOStream() } // ---------------------------------------------------------------------------------- -size_t DefaultIOStream::Read(void* pvBuffer, - size_t pSize, - size_t pCount) -{ - ai_assert(NULL != pvBuffer && 0 != pSize && 0 != pCount); +size_t DefaultIOStream::Read(void *pvBuffer, + size_t pSize, + size_t pCount) { + ai_assert(nullptr != pvBuffer); + ai_assert(0 != pSize); + ai_assert(0 != pCount); + return (mFile ? ::fread(pvBuffer, pSize, pCount, mFile) : 0); } // ---------------------------------------------------------------------------------- -size_t DefaultIOStream::Write(const void* pvBuffer, - size_t pSize, - size_t pCount) -{ - ai_assert(NULL != pvBuffer && 0 != pSize && 0 != pCount); +size_t DefaultIOStream::Write(const void *pvBuffer, + size_t pSize, + size_t pCount) { + ai_assert(nullptr != pvBuffer); + ai_assert(0 != pSize); + ai_assert(0 != pCount); + return (mFile ? ::fwrite(pvBuffer, pSize, pCount, mFile) : 0); } // ---------------------------------------------------------------------------------- aiReturn DefaultIOStream::Seek(size_t pOffset, - aiOrigin pOrigin) -{ + aiOrigin pOrigin) { if (!mFile) { return AI_FAILURE; } // Just to check whether our enum maps one to one with the CRT constants static_assert(aiOrigin_CUR == SEEK_CUR && - aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET, "aiOrigin_CUR == SEEK_CUR && \ + aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET, + "aiOrigin_CUR == SEEK_CUR && \ aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET"); // do the seek - return (0 == select_fseek(mFile, (int64_t)pOffset,(int)pOrigin) ? AI_SUCCESS : AI_FAILURE); + return (0 == select_fseek(mFile, (int64_t)pOffset, (int)pOrigin) ? AI_SUCCESS : AI_FAILURE); } // ---------------------------------------------------------------------------------- -size_t DefaultIOStream::Tell() const -{ +size_t DefaultIOStream::Tell() const { if (!mFile) { return 0; } - return select_ftell(mFile); + return select_ftell(mFile); } // ---------------------------------------------------------------------------------- -size_t DefaultIOStream::FileSize() const -{ - if (! mFile || mFilename.empty()) { +size_t DefaultIOStream::FileSize() const { + if (!mFile || mFilename.empty()) { return 0; } - if (SIZE_MAX == mCachedSize ) { + if (SIZE_MAX == mCachedSize) { // Although fseek/ftell would allow us to reuse the existing file handle here, // it is generally unsafe because: @@ -154,27 +149,26 @@ size_t DefaultIOStream::FileSize() const #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) struct __stat64 fileStat; //using fileno + fstat avoids having to handle the filename - int err = _fstat64( _fileno(mFile), &fileStat ); + int err = _fstat64(_fileno(mFile), &fileStat); if (0 != err) return 0; - mCachedSize = (size_t) (fileStat.st_size); + mCachedSize = (size_t)(fileStat.st_size); #elif defined __GNUC__ || defined __APPLE__ || defined __MACH__ || defined __FreeBSD__ struct stat fileStat; - int err = stat(mFilename.c_str(), &fileStat ); + int err = stat(mFilename.c_str(), &fileStat); if (0 != err) return 0; const unsigned long long cachedSize = fileStat.st_size; - mCachedSize = static_cast< size_t >( cachedSize ); + mCachedSize = static_cast(cachedSize); #else -# error "Unknown platform" +#error "Unknown platform" #endif } return mCachedSize; } // ---------------------------------------------------------------------------------- -void DefaultIOStream::Flush() -{ +void DefaultIOStream::Flush() { if (mFile) { ::fflush(mFile); } diff --git a/code/Common/DefaultLogger.cpp b/code/Common/DefaultLogger.cpp index adb9ba160..8c946e8fd 100644 --- a/code/Common/DefaultLogger.cpp +++ b/code/Common/DefaultLogger.cpp @@ -46,25 +46,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Default log streams -#include "Win32DebugLogStream.h" -#include "StdOStreamLogStream.h" #include "FileLogStream.h" +#include "StdOStreamLogStream.h" +#include "Win32DebugLogStream.h" #include #include -#include -#include #include -#include #include +#include +#include +#include #ifndef ASSIMP_BUILD_SINGLETHREADED -# include -# include - std::mutex loggerMutex; +#include +#include +std::mutex loggerMutex; #endif -namespace Assimp { +namespace Assimp { // ---------------------------------------------------------------------------------- NullLogger DefaultLogger::s_pNullLogger; @@ -75,13 +75,13 @@ static const unsigned int SeverityAll = Logger::Info | Logger::Err | Logger::War // ---------------------------------------------------------------------------------- // Represents a log-stream + its error severity struct LogStreamInfo { - unsigned int m_uiErrorSeverity; - LogStream *m_pStream; + unsigned int m_uiErrorSeverity; + LogStream *m_pStream; // Constructor - LogStreamInfo( unsigned int uiErrorSev, LogStream *pStream ) : - m_uiErrorSeverity( uiErrorSev ), - m_pStream( pStream ) { + LogStreamInfo(unsigned int uiErrorSev, LogStream *pStream) : + m_uiErrorSeverity(uiErrorSev), + m_pStream(pStream) { // empty } @@ -93,12 +93,10 @@ struct LogStreamInfo { // ---------------------------------------------------------------------------------- // Construct a default log stream -LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams, - const char* name /*= "AssimpLog.txt"*/, - IOSystem* io /*= NULL*/) -{ - switch (streams) - { +LogStream *LogStream::createDefaultStream(aiDefaultLogStream streams, + const char *name /*= "AssimpLog.txt"*/, + IOSystem *io /*= nullptr*/) { + switch (streams) { // This is a platform-specific feature case aiDefaultLogStream_DEBUGGER: #ifdef WIN32 @@ -113,11 +111,10 @@ LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams, case aiDefaultLogStream_STDOUT: return new StdOStreamLogStream(std::cout); case aiDefaultLogStream_FILE: - return (name && *name ? new FileLogStream(name,io) : nullptr ); + return (name && *name ? new FileLogStream(name, io) : nullptr); default: // We don't know this default log stream, so raise an assertion ai_assert(false); - }; // For compilers without dead code path detection @@ -126,97 +123,109 @@ LogStream* LogStream::createDefaultStream(aiDefaultLogStream streams, // ---------------------------------------------------------------------------------- // Creates the only singleton instance -Logger *DefaultLogger::create(const char* name /*= "AssimpLog.txt"*/, - LogSeverity severity /*= NORMAL*/, - unsigned int defStreams /*= aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE*/, - IOSystem* io /*= NULL*/) { +Logger *DefaultLogger::create(const char *name /*= "AssimpLog.txt"*/, + LogSeverity severity /*= NORMAL*/, + unsigned int defStreams /*= aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE*/, + IOSystem *io /*= nullptr*/) { // enter the mutex here to avoid concurrency problems #ifndef ASSIMP_BUILD_SINGLETHREADED std::lock_guard lock(loggerMutex); #endif - if ( m_pLogger && !isNullLogger() ) { + if (m_pLogger && !isNullLogger()) { delete m_pLogger; } - m_pLogger = new DefaultLogger( severity ); + m_pLogger = new DefaultLogger(severity); // Attach default log streams // Stream the log to the MSVC debugger? - if ( defStreams & aiDefaultLogStream_DEBUGGER ) { - m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_DEBUGGER ) ); + if (defStreams & aiDefaultLogStream_DEBUGGER) { + m_pLogger->attachStream(LogStream::createDefaultStream(aiDefaultLogStream_DEBUGGER)); } // Stream the log to COUT? - if ( defStreams & aiDefaultLogStream_STDOUT ) { - m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_STDOUT ) ); + if (defStreams & aiDefaultLogStream_STDOUT) { + m_pLogger->attachStream(LogStream::createDefaultStream(aiDefaultLogStream_STDOUT)); } // Stream the log to CERR? - if ( defStreams & aiDefaultLogStream_STDERR ) { - m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_STDERR ) ); + if (defStreams & aiDefaultLogStream_STDERR) { + m_pLogger->attachStream(LogStream::createDefaultStream(aiDefaultLogStream_STDERR)); } // Stream the log to a file - if ( defStreams & aiDefaultLogStream_FILE && name && *name ) { - m_pLogger->attachStream( LogStream::createDefaultStream( aiDefaultLogStream_FILE, name, io ) ); + if (defStreams & aiDefaultLogStream_FILE && name && *name) { + m_pLogger->attachStream(LogStream::createDefaultStream(aiDefaultLogStream_FILE, name, io)); } return m_pLogger; } // ---------------------------------------------------------------------------------- -void Logger::debug(const char* message) { +void Logger::debug(const char *message) { // SECURITY FIX: otherwise it's easy to produce overruns since // sometimes importers will include data from the input file // (i.e. node names) in their messages. - if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { + if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { return; } return OnDebug(message); } // ---------------------------------------------------------------------------------- -void Logger::info(const char* message) { +void Logger::verboseDebug(const char *message) { + + // SECURITY FIX: otherwise it's easy to produce overruns since + // sometimes importers will include data from the input file + // (i.e. node names) in their messages. + if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { + return; + } + return OnVerboseDebug(message); +} + +// ---------------------------------------------------------------------------------- +void Logger::info(const char *message) { // SECURITY FIX: see above - if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { + if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { return; } return OnInfo(message); } // ---------------------------------------------------------------------------------- -void Logger::warn(const char* message) { +void Logger::warn(const char *message) { // SECURITY FIX: see above - if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { + if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { return; } return OnWarn(message); } // ---------------------------------------------------------------------------------- -void Logger::error(const char* message) { +void Logger::error(const char *message) { // SECURITY FIX: see above - if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) { + if (strlen(message) > MAX_LOG_MESSAGE_LENGTH) { return; } return OnError(message); } // ---------------------------------------------------------------------------------- -void DefaultLogger::set( Logger *logger ) { +void DefaultLogger::set(Logger *logger) { // enter the mutex here to avoid concurrency problems #ifndef ASSIMP_BUILD_SINGLETHREADED std::lock_guard lock(loggerMutex); #endif - if ( nullptr == logger ) { + if (nullptr == logger) { logger = &s_pNullLogger; } - if ( nullptr != m_pLogger && !isNullLogger() ) { + if (nullptr != m_pLogger && !isNullLogger()) { delete m_pLogger; } @@ -241,103 +250,115 @@ void DefaultLogger::kill() { std::lock_guard lock(loggerMutex); #endif - if ( m_pLogger == &s_pNullLogger ) { - return; - } + if (m_pLogger == &s_pNullLogger) { + return; + } delete m_pLogger; m_pLogger = &s_pNullLogger; } // ---------------------------------------------------------------------------------- // Debug message -void DefaultLogger::OnDebug( const char* message ) { - if ( m_Severity == Logger::NORMAL ) { +void DefaultLogger::OnDebug(const char *message) { + if (m_Severity < Logger::DEBUG) { return; } - static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; - char msg[Size]; - ai_snprintf(msg, Size, "Debug, T%u: %s", GetThreadID(), message); + static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; + char msg[Size]; + ai_snprintf(msg, Size, "Debug, T%u: %s", GetThreadID(), message); - WriteToStreams( msg, Logger::Debugging ); + WriteToStreams(msg, Logger::Debugging); +} + +// Verbose debug message +void DefaultLogger::OnVerboseDebug(const char *message) { + if (m_Severity < Logger::VERBOSE) { + return; + } + + static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; + char msg[Size]; + ai_snprintf(msg, Size, "Debug, T%u: %s", GetThreadID(), message); + + WriteToStreams(msg, Logger::Debugging); } // ---------------------------------------------------------------------------------- // Logs an info -void DefaultLogger::OnInfo( const char* message ){ - static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; - char msg[Size]; - ai_snprintf(msg, Size, "Info, T%u: %s", GetThreadID(), message ); +void DefaultLogger::OnInfo(const char *message) { + static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; + char msg[Size]; + ai_snprintf(msg, Size, "Info, T%u: %s", GetThreadID(), message); - WriteToStreams( msg , Logger::Info ); + WriteToStreams(msg, Logger::Info); } // ---------------------------------------------------------------------------------- // Logs a warning -void DefaultLogger::OnWarn( const char* message ) { - static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; - char msg[Size]; - ai_snprintf(msg, Size, "Warn, T%u: %s", GetThreadID(), message ); +void DefaultLogger::OnWarn(const char *message) { + static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; + char msg[Size]; + ai_snprintf(msg, Size, "Warn, T%u: %s", GetThreadID(), message); - WriteToStreams( msg, Logger::Warn ); + WriteToStreams(msg, Logger::Warn); } // ---------------------------------------------------------------------------------- // Logs an error -void DefaultLogger::OnError( const char* message ) { - static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; - char msg[ Size ]; - ai_snprintf(msg, Size, "Error, T%u: %s", GetThreadID(), message ); +void DefaultLogger::OnError(const char *message) { + static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16; + char msg[Size]; + ai_snprintf(msg, Size, "Error, T%u: %s", GetThreadID(), message); - WriteToStreams( msg, Logger::Err ); + WriteToStreams(msg, Logger::Err); } // ---------------------------------------------------------------------------------- // Will attach a new stream -bool DefaultLogger::attachStream( LogStream *pStream, unsigned int severity ) { - if ( nullptr == pStream ) { +bool DefaultLogger::attachStream(LogStream *pStream, unsigned int severity) { + if (nullptr == pStream) { return false; } - if (0 == severity) { + if (0 == severity) { severity = Logger::Info | Logger::Err | Logger::Warn | Logger::Debugging; } - for ( StreamIt it = m_StreamArray.begin(); - it != m_StreamArray.end(); - ++it ) - { - if ( (*it)->m_pStream == pStream ) { + for (StreamIt it = m_StreamArray.begin(); + it != m_StreamArray.end(); + ++it) { + if ((*it)->m_pStream == pStream) { (*it)->m_uiErrorSeverity |= severity; return true; } } - LogStreamInfo *pInfo = new LogStreamInfo( severity, pStream ); - m_StreamArray.push_back( pInfo ); + LogStreamInfo *pInfo = new LogStreamInfo(severity, pStream); + m_StreamArray.push_back(pInfo); return true; } // ---------------------------------------------------------------------------------- // Detach a stream -bool DefaultLogger::detatchStream( LogStream *pStream, unsigned int severity ) { - if ( nullptr == pStream ) { +bool DefaultLogger::detachStream(LogStream *pStream, unsigned int severity) { + if (nullptr == pStream) { return false; } - if (0 == severity) { + if (0 == severity) { severity = SeverityAll; } - bool res( false ); - for ( StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it ) { - if ( (*it)->m_pStream == pStream ) { + bool res(false); + for (StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it) { + if ((*it)->m_pStream == pStream) { (*it)->m_uiErrorSeverity &= ~severity; - if ( (*it)->m_uiErrorSeverity == 0 ) { + if ((*it)->m_uiErrorSeverity == 0) { // don't delete the underlying stream 'cause the caller gains ownership again (**it).m_pStream = nullptr; delete *it; - m_StreamArray.erase( it ); + m_StreamArray.erase(it); res = true; break; } @@ -349,17 +370,15 @@ bool DefaultLogger::detatchStream( LogStream *pStream, unsigned int severity ) { // ---------------------------------------------------------------------------------- // Constructor -DefaultLogger::DefaultLogger(LogSeverity severity) - : Logger ( severity ) - , noRepeatMsg (false) - , lastLen( 0 ) { +DefaultLogger::DefaultLogger(LogSeverity severity) : + Logger(severity), noRepeatMsg(false), lastLen(0) { lastMsg[0] = '\0'; } // ---------------------------------------------------------------------------------- // Destructor DefaultLogger::~DefaultLogger() { - for ( StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it ) { + for (StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it) { // also frees the underlying stream, we are its owner. delete *it; } @@ -367,43 +386,37 @@ DefaultLogger::~DefaultLogger() { // ---------------------------------------------------------------------------------- // Writes message to stream -void DefaultLogger::WriteToStreams(const char *message, ErrorSeverity ErrorSev ) { +void DefaultLogger::WriteToStreams(const char *message, ErrorSeverity ErrorSev) { ai_assert(nullptr != message); // Check whether this is a repeated message - if (! ::strncmp( message,lastMsg, lastLen-1)) - { - if (!noRepeatMsg) - { + if (!::strncmp(message, lastMsg, lastLen - 1)) { + if (!noRepeatMsg) { noRepeatMsg = true; message = "Skipping one or more lines with the same contents\n"; - } - else return; - } - else - { + } else + return; + } else { // append a new-line character to the message to be printed lastLen = ::strlen(message); - ::memcpy(lastMsg,message,lastLen+1); - ::strcat(lastMsg+lastLen,"\n"); + ::memcpy(lastMsg, message, lastLen + 1); + ::strcat(lastMsg + lastLen, "\n"); message = lastMsg; noRepeatMsg = false; ++lastLen; } - for ( ConstStreamIt it = m_StreamArray.begin(); - it != m_StreamArray.end(); - ++it) - { - if ( ErrorSev & (*it)->m_uiErrorSeverity ) - (*it)->m_pStream->write( message); + for (ConstStreamIt it = m_StreamArray.begin(); + it != m_StreamArray.end(); + ++it) { + if (ErrorSev & (*it)->m_uiErrorSeverity) + (*it)->m_pStream->write(message); } } // ---------------------------------------------------------------------------------- // Returns thread id, if not supported only a zero will be returned. -unsigned int DefaultLogger::GetThreadID() -{ +unsigned int DefaultLogger::GetThreadID() { // fixme: we can get this value via std::threads // std::this_thread::get_id().hash() returns a (big) size_t, not sure if this is useful in this case. #ifdef WIN32 @@ -415,4 +428,4 @@ unsigned int DefaultLogger::GetThreadID() // ---------------------------------------------------------------------------------- -} // !namespace Assimp +} // namespace Assimp diff --git a/code/Common/Exporter.cpp b/code/Common/Exporter.cpp index c34457be5..58fc01d91 100644 --- a/code/Common/Exporter.cpp +++ b/code/Common/Exporter.cpp @@ -475,7 +475,7 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c proc.Execute(scenecopy.get()); } - ExportProperties emptyProperties; // Never pass NULL ExportProperties so Exporters don't have to worry. + ExportProperties emptyProperties; // Never pass nullptr ExportProperties so Exporters don't have to worry. ExportProperties* pProp = pProperties ? (ExportProperties*)pProperties : &emptyProperties; pProp->SetPropertyBool("bJoinIdenticalVertices", pp & aiProcess_JoinIdenticalVertices); exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get(), pProp); diff --git a/code/Common/FileLogStream.h b/code/Common/FileLogStream.h index ecff03a7e..f6b4520ae 100644 --- a/code/Common/FileLogStream.h +++ b/code/Common/FileLogStream.h @@ -43,23 +43,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_FILELOGSTREAM_H_INC #define ASSIMP_FILELOGSTREAM_H_INC -#include -#include #include +#include +#include -namespace Assimp { +namespace Assimp { // ---------------------------------------------------------------------------------- /** @class FileLogStream * @brief Logstream to write into a file. */ -class FileLogStream : - public LogStream -{ +class FileLogStream : public LogStream { public: - FileLogStream( const char* file, IOSystem* io = NULL ); + FileLogStream(const char *file, IOSystem *io = nullptr); ~FileLogStream(); - void write( const char* message ); + void write(const char *message); private: IOStream *m_pStream; @@ -67,41 +65,36 @@ private: // ---------------------------------------------------------------------------------- // Constructor -inline FileLogStream::FileLogStream( const char* file, IOSystem* io ) : - m_pStream(NULL) -{ - if ( !file || 0 == *file ) +inline FileLogStream::FileLogStream(const char *file, IOSystem *io) : + m_pStream(nullptr) { + if (!file || 0 == *file) return; // If no IOSystem is specified: take a default one - if (!io) - { + if (!io) { DefaultIOSystem FileSystem; - m_pStream = FileSystem.Open( file, "wt"); - } - else m_pStream = io->Open( file, "wt" ); + m_pStream = FileSystem.Open(file, "wt"); + } else + m_pStream = io->Open(file, "wt"); } // ---------------------------------------------------------------------------------- // Destructor -inline FileLogStream::~FileLogStream() -{ +inline FileLogStream::~FileLogStream() { // The virtual d'tor should destroy the underlying file delete m_pStream; } // ---------------------------------------------------------------------------------- // Write method -inline void FileLogStream::write( const char* message ) -{ - if (m_pStream != NULL) - { +inline void FileLogStream::write(const char *message) { + if (m_pStream != nullptr) { m_pStream->Write(message, sizeof(char), ::strlen(message)); m_pStream->Flush(); } } // ---------------------------------------------------------------------------------- -} // !Namespace Assimp +} // namespace Assimp #endif // !! ASSIMP_FILELOGSTREAM_H_INC diff --git a/code/Common/Importer.cpp b/code/Common/Importer.cpp index a59ec9812..a46d39b48 100644 --- a/code/Common/Importer.cpp +++ b/code/Common/Importer.cpp @@ -249,7 +249,7 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp) { // Unregister a custom loader plugin aiReturn Importer::UnregisterLoader(BaseImporter* pImp) { if(!pImp) { - // unregistering a NULL importer is no problem for us ... really! + // unregistering a nullptr importer is no problem for us ... really! return AI_SUCCESS; } @@ -272,7 +272,7 @@ aiReturn Importer::UnregisterLoader(BaseImporter* pImp) { // Unregister a custom loader plugin aiReturn Importer::UnregisterPPStep(BaseProcess* pImp) { if(!pImp) { - // unregistering a NULL ppstep is no problem for us ... really! + // unregistering a nullptr ppstep is no problem for us ... really! return AI_SUCCESS; } @@ -593,7 +593,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) { return nullptr; } - std::unique_ptr profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL); + std::unique_ptr profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME, 0) ? new Profiler() : nullptr); if (profiler) { profiler->BeginRegion("total"); } @@ -775,7 +775,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) { } #endif // ! DEBUG - std::unique_ptr profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL); + std::unique_ptr profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME, 0) ? new Profiler() : nullptr); for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) { BaseProcess* process = pimpl->mPostProcessingSteps[a]; pimpl->mProgressHandler->UpdatePostProcess(static_cast(a), static_cast(pimpl->mPostProcessingSteps.size()) ); @@ -841,7 +841,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess } // If no flags are given, return the current scene with no further action - if ( NULL == rootProcess ) { + if (nullptr == rootProcess) { return pimpl->mScene; } @@ -873,7 +873,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess } #endif // ! DEBUG - std::unique_ptr profiler( GetPropertyInteger( AI_CONFIG_GLOB_MEASURE_TIME, 0 ) ? new Profiler() : NULL ); + std::unique_ptr profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME, 0) ? new Profiler() : nullptr); if ( profiler ) { profiler->BeginRegion( "postprocess" ); diff --git a/code/Common/Importer.h b/code/Common/Importer.h index c31f67caa..eaf42e9c5 100644 --- a/code/Common/Importer.h +++ b/code/Common/Importer.h @@ -94,7 +94,7 @@ public: /** Post processing steps we can apply at the imported data. */ std::vector< BaseProcess* > mPostProcessingSteps; - /** The imported data, if ReadFile() was successful, NULL otherwise. */ + /** The imported data, if ReadFile() was successful, nullptr otherwise. */ aiScene* mScene; /** The error description, if there was one. */ @@ -216,7 +216,7 @@ public: unsigned int AddLoadRequest ( const std::string& file, unsigned int steps = 0, - const PropertyMap* map = NULL + const PropertyMap *map = nullptr ); // ------------------------------------------------------------------- @@ -226,7 +226,7 @@ public: * can be called several times, too. * * @param which LRWC returned by AddLoadRequest(). - * @return NULL if there is no scene with this file name + * @return nullptr if there is no scene with this file name * in the queue of the scene hasn't been loaded yet. */ aiScene* GetImport( unsigned int which diff --git a/code/Common/ImporterRegistry.cpp b/code/Common/ImporterRegistry.cpp index d66d7de8d..da51696bc 100644 --- a/code/Common/ImporterRegistry.cpp +++ b/code/Common/ImporterRegistry.cpp @@ -1,4 +1,4 @@ -/* +/* --------------------------------------------------------------------------- Open Asset Import Library (assimp) --------------------------------------------------------------------------- diff --git a/code/Common/RemoveComments.cpp b/code/Common/RemoveComments.cpp index f7e735c16..0e3e0f564 100644 --- a/code/Common/RemoveComments.cpp +++ b/code/Common/RemoveComments.cpp @@ -55,7 +55,9 @@ void CommentRemover::RemoveLineComments(const char* szComment, char* szBuffer, char chReplacement /* = ' ' */) { // validate parameters - ai_assert(NULL != szComment && NULL != szBuffer && *szComment); + ai_assert(nullptr != szComment); + ai_assert(nullptr != szBuffer); + ai_assert(*szComment); const size_t len = strlen(szComment); while (*szBuffer) { @@ -83,8 +85,11 @@ void CommentRemover::RemoveMultiLineComments(const char* szCommentStart, char chReplacement) { // validate parameters - ai_assert(NULL != szCommentStart && NULL != szCommentEnd && - NULL != szBuffer && *szCommentStart && *szCommentEnd); + ai_assert(nullptr != szCommentStart); + ai_assert(nullptr != szCommentEnd); + ai_assert(nullptr != szBuffer); + ai_assert(*szCommentStart); + ai_assert(*szCommentEnd); const size_t len = strlen(szCommentEnd); const size_t len2 = strlen(szCommentStart); diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index 4d2a411f2..bfc4899a1 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -52,37 +52,41 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OptimizeGraph step. */ // ---------------------------------------------------------------------------- +#include "ScenePrivate.h" +#include "time.h" +#include #include #include #include -#include -#include -#include "time.h" -#include -#include #include +#include +#include #include -#include "ScenePrivate.h" +#include namespace Assimp { +#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + // ------------------------------------------------------------------------------------------------ // Add a prefix to a string -inline -void PrefixString(aiString& string,const char* prefix, unsigned int len) { +inline void PrefixString(aiString &string, const char *prefix, unsigned int len) { // If the string is already prefixed, we won't prefix it a second time if (string.length >= 1 && string.data[0] == '$') return; - if (len+string.length>=MAXLEN-1) { - ASSIMP_LOG_DEBUG("Can't add an unique prefix because the string is too long"); + if (len + string.length >= MAXLEN - 1) { + ASSIMP_LOG_VERBOSE_DEBUG("Can't add an unique prefix because the string is too long"); ai_assert(false); return; } // Add the prefix - ::memmove(string.data+len,string.data,string.length+1); - ::memcpy (string.data, prefix, len); + ::memmove(string.data + len, string.data, string.length + 1); + ::memcpy(string.data, prefix, len); // And update the string's length string.length += len; @@ -90,33 +94,35 @@ void PrefixString(aiString& string,const char* prefix, unsigned int len) { // ------------------------------------------------------------------------------------------------ // Add node identifiers to a hashing set -void SceneCombiner::AddNodeHashes(aiNode* node, std::set& hashes) { +void SceneCombiner::AddNodeHashes(aiNode *node, std::set &hashes) { // Add node name to hashing set if it is non-empty - empty nodes are allowed // and they can't have any anims assigned so its absolutely safe to duplicate them. if (node->mName.length) { - hashes.insert( SuperFastHash(node->mName.data, static_cast(node->mName.length)) ); + hashes.insert(SuperFastHash(node->mName.data, static_cast(node->mName.length))); } // Process all children recursively - for (unsigned int i = 0; i < node->mNumChildren;++i) - AddNodeHashes(node->mChildren[i],hashes); + for (unsigned int i = 0; i < node->mNumChildren; ++i) { + AddNodeHashes(node->mChildren[i], hashes); + } } // ------------------------------------------------------------------------------------------------ // Add a name prefix to all nodes in a hierarchy -void SceneCombiner::AddNodePrefixes(aiNode* node, const char* prefix, unsigned int len) { - ai_assert(NULL != prefix); - PrefixString(node->mName,prefix,len); +void SceneCombiner::AddNodePrefixes(aiNode *node, const char *prefix, unsigned int len) { + ai_assert(nullptr != prefix); + + PrefixString(node->mName, prefix, len); // Process all children recursively - for ( unsigned int i = 0; i < node->mNumChildren; ++i ) { - AddNodePrefixes( node->mChildren[ i ], prefix, len ); + for (unsigned int i = 0; i < node->mNumChildren; ++i) { + AddNodePrefixes(node->mChildren[i], prefix, len); } } // ------------------------------------------------------------------------------------------------ // Search for matching names -bool SceneCombiner::FindNameMatch(const aiString& name, std::vector& input, unsigned int cur) { +bool SceneCombiner::FindNameMatch(const aiString &name, std::vector &input, unsigned int cur) { const unsigned int hash = SuperFastHash(name.data, static_cast(name.length)); // Check whether we find a positive match in one of the given sets @@ -130,87 +136,90 @@ bool SceneCombiner::FindNameMatch(const aiString& name, std::vector // ------------------------------------------------------------------------------------------------ // Add a name prefix to all nodes in a hierarchy if a hash match is found -void SceneCombiner::AddNodePrefixesChecked(aiNode* node, const char* prefix, unsigned int len, - std::vector& input, unsigned int cur) { - ai_assert(NULL != prefix); +void SceneCombiner::AddNodePrefixesChecked(aiNode *node, const char *prefix, unsigned int len, + std::vector &input, unsigned int cur) { + ai_assert(nullptr != prefix); + const unsigned int hash = SuperFastHash(node->mName.data, static_cast(node->mName.length)); // Check whether we find a positive match in one of the given sets for (unsigned int i = 0; i < input.size(); ++i) { if (cur != i && input[i].hashes.find(hash) != input[i].hashes.end()) { - PrefixString(node->mName,prefix,len); + PrefixString(node->mName, prefix, len); break; } } // Process all children recursively - for (unsigned int i = 0; i < node->mNumChildren;++i) - AddNodePrefixesChecked(node->mChildren[i],prefix,len,input,cur); + for (unsigned int i = 0; i < node->mNumChildren; ++i) { + AddNodePrefixesChecked(node->mChildren[i], prefix, len, input, cur); + } } // ------------------------------------------------------------------------------------------------ // Add an offset to all mesh indices in a node graph -void SceneCombiner::OffsetNodeMeshIndices (aiNode* node, unsigned int offset) { - for (unsigned int i = 0; i < node->mNumMeshes;++i) +void SceneCombiner::OffsetNodeMeshIndices(aiNode *node, unsigned int offset) { + for (unsigned int i = 0; i < node->mNumMeshes; ++i) node->mMeshes[i] += offset; - for ( unsigned int i = 0; i < node->mNumChildren; ++i ) { - OffsetNodeMeshIndices( node->mChildren[ i ], offset ); + for (unsigned int i = 0; i < node->mNumChildren; ++i) { + OffsetNodeMeshIndices(node->mChildren[i], offset); } } // ------------------------------------------------------------------------------------------------ // Merges two scenes. Currently only used by the LWS loader. -void SceneCombiner::MergeScenes(aiScene** _dest,std::vector& src, unsigned int flags) { - if ( nullptr == _dest ) { +void SceneCombiner::MergeScenes(aiScene **_dest, std::vector &src, unsigned int flags) { + if (nullptr == _dest) { return; } - // if _dest points to NULL allocate a new scene. Otherwise clear the old and reuse it + // if _dest points to nullptr allocate a new scene. Otherwise clear the old and reuse it if (src.empty()) { if (*_dest) { (*_dest)->~aiScene(); - SceneCombiner::CopySceneFlat(_dest,src[0]); - } - else *_dest = src[0]; + SceneCombiner::CopySceneFlat(_dest, src[0]); + } else + *_dest = src[0]; return; } - if (*_dest)(*_dest)->~aiScene(); - else *_dest = new aiScene(); + if (*_dest) + (*_dest)->~aiScene(); + else + *_dest = new aiScene(); // Create a dummy scene to serve as master for the others - aiScene* master = new aiScene(); + aiScene *master = new aiScene(); master->mRootNode = new aiNode(); master->mRootNode->mName.Set(""); - std::vector srcList (src.size()); - for (unsigned int i = 0; i < srcList.size();++i) { - srcList[i] = AttachmentInfo(src[i],master->mRootNode); + std::vector srcList(src.size()); + for (unsigned int i = 0; i < srcList.size(); ++i) { + srcList[i] = AttachmentInfo(src[i], master->mRootNode); } // 'master' will be deleted afterwards - MergeScenes (_dest, master, srcList, flags); + MergeScenes(_dest, master, srcList, flags); } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::AttachToGraph (aiNode* attach, std::vector& srcList) { +void SceneCombiner::AttachToGraph(aiNode *attach, std::vector &srcList) { unsigned int cnt; - for ( cnt = 0; cnt < attach->mNumChildren; ++cnt ) { - AttachToGraph( attach->mChildren[ cnt ], srcList ); + for (cnt = 0; cnt < attach->mNumChildren; ++cnt) { + AttachToGraph(attach->mChildren[cnt], srcList); } cnt = 0; for (std::vector::iterator it = srcList.begin(); - it != srcList.end(); ++it) - { + it != srcList.end(); ++it) { if ((*it).attachToNode == attach && !(*it).resolved) ++cnt; } - if (cnt) { - aiNode** n = new aiNode*[cnt+attach->mNumChildren]; - if (attach->mNumChildren) { - ::memcpy(n,attach->mChildren,sizeof(void*)*attach->mNumChildren); + if (cnt) { + aiNode **n = new aiNode *[cnt + attach->mNumChildren]; + if (attach->mNumChildren) { + ::memcpy(n, attach->mChildren, sizeof(void *) * attach->mNumChildren); delete[] attach->mChildren; } attach->mChildren = n; @@ -218,9 +227,9 @@ void SceneCombiner::AttachToGraph (aiNode* attach, std::vectormNumChildren; attach->mNumChildren += cnt; - for (unsigned int i = 0; i < srcList.size();++i) { - NodeAttachmentInfo& att = srcList[i]; - if (att.attachToNode == attach && !att.resolved) { + for (unsigned int i = 0; i < srcList.size(); ++i) { + NodeAttachmentInfo &att = srcList[i]; + if (att.attachToNode == attach && !att.resolved) { *n = att.node; (**n).mParent = attach; ++n; @@ -233,53 +242,54 @@ void SceneCombiner::AttachToGraph (aiNode* attach, std::vector& src) { - ai_assert(NULL != master); - AttachToGraph(master->mRootNode,src); +void SceneCombiner::AttachToGraph(aiScene *master, std::vector &src) { + ai_assert(nullptr != master); + + AttachToGraph(master->mRootNode, src); } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vector& srcList, unsigned int flags) { - if ( nullptr == _dest ) { +void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector &srcList, unsigned int flags) { + if (nullptr == _dest) { return; } - // if _dest points to NULL allocate a new scene. Otherwise clear the old and reuse it - if (srcList.empty()) { + // if _dest points to nullptr allocate a new scene. Otherwise clear the old and reuse it + if (srcList.empty()) { if (*_dest) { - SceneCombiner::CopySceneFlat(_dest,master); - } - else *_dest = master; + SceneCombiner::CopySceneFlat(_dest, master); + } else + *_dest = master; return; } if (*_dest) { (*_dest)->~aiScene(); new (*_dest) aiScene(); - } - else *_dest = new aiScene(); + } else + *_dest = new aiScene(); - aiScene* dest = *_dest; + aiScene *dest = *_dest; - std::vector src (srcList.size()+1); + std::vector src(srcList.size() + 1); src[0].scene = master; - for (unsigned int i = 0; i < srcList.size();++i) { - src[i+1] = SceneHelper( srcList[i].scene ); + for (unsigned int i = 0; i < srcList.size(); ++i) { + src[i + 1] = SceneHelper(srcList[i].scene); } // this helper array specifies which scenes are duplicates of others - std::vector duplicates(src.size(),UINT_MAX); + std::vector duplicates(src.size(), UINT_MAX); // this helper array is used as lookup table several times std::vector offset(src.size()); // Find duplicate scenes - for (unsigned int i = 0; i < src.size();++i) { + for (unsigned int i = 0; i < src.size(); ++i) { if (duplicates[i] != i && duplicates[i] != UINT_MAX) { continue; } duplicates[i] = i; - for ( unsigned int a = i+1; a < src.size(); ++a) { + for (unsigned int a = i + 1; a < src.size(); ++a) { if (src[i].scene == src[a].scene) { duplicates[a] = i; } @@ -287,16 +297,14 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vector dist(1u,1 << 24u); boost::variate_generator > rndGen(rng, dist); #endif - for (unsigned int i = 1; i < src.size();++i) - { + for (unsigned int i = 1; i < src.size(); ++i) { //if (i != duplicates[i]) //{ // // duplicate scenes share the same UID @@ -306,7 +314,7 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vectormRootNode,src[i].hashes); + AddNodeHashes(src[i]->mRootNode, src[i].hashes); - for (unsigned int a = 0; a < src[i]->mNumAnimations;++a) { - aiAnimation* anim = src[i]->mAnimations[a]; - src[i].hashes.insert(SuperFastHash(anim->mName.data,static_cast(anim->mName.length))); + for (unsigned int a = 0; a < src[i]->mNumAnimations; ++a) { + aiAnimation *anim = src[i]->mAnimations[a]; + src[i].hashes.insert(SuperFastHash(anim->mName.data, static_cast(anim->mName.length))); } } } @@ -327,18 +335,17 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vectormNumTextures += (*cur)->mNumTextures; - dest->mNumMaterials += (*cur)->mNumMaterials; - dest->mNumMeshes += (*cur)->mNumMeshes; + if (n == duplicates[n] || flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) { + dest->mNumTextures += (*cur)->mNumTextures; + dest->mNumMaterials += (*cur)->mNumMaterials; + dest->mNumMeshes += (*cur)->mNumMeshes; } - dest->mNumLights += (*cur)->mNumLights; - dest->mNumCameras += (*cur)->mNumCameras; + dest->mNumLights += (*cur)->mNumLights; + dest->mNumCameras += (*cur)->mNumCameras; dest->mNumAnimations += (*cur)->mNumAnimations; // Combine the flags of all scenes @@ -350,23 +357,20 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vectormNumTextures) - { - aiTexture** pip = dest->mTextures = new aiTexture*[dest->mNumMaterials]; + if (dest->mNumTextures) { + aiTexture **pip = dest->mTextures = new aiTexture *[dest->mNumMaterials]; cnt = 0; - for ( unsigned int n = 0; n < src.size();++n ) - { - SceneHelper* cur = &src[n]; - for (unsigned int i = 0; i < (*cur)->mNumTextures;++i) - { - if (n != duplicates[n]) - { - if ( flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) - Copy(pip,(*cur)->mTextures[i]); + for (unsigned int n = 0; n < src.size(); ++n) { + SceneHelper *cur = &src[n]; + for (unsigned int i = 0; i < (*cur)->mNumTextures; ++i) { + if (n != duplicates[n]) { + if (flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) + Copy(pip, (*cur)->mTextures[i]); - else continue; - } - else *pip = (*cur)->mTextures[i]; + else + continue; + } else + *pip = (*cur)->mTextures[i]; ++pip; } @@ -376,47 +380,42 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vectormNumMaterials) - { - aiMaterial** pip = dest->mMaterials = new aiMaterial*[dest->mNumMaterials]; + if (dest->mNumMaterials) { + aiMaterial **pip = dest->mMaterials = new aiMaterial *[dest->mNumMaterials]; cnt = 0; - for ( unsigned int n = 0; n < src.size();++n ) { - SceneHelper* cur = &src[n]; - for (unsigned int i = 0; i < (*cur)->mNumMaterials;++i) - { - if (n != duplicates[n]) - { - if ( flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) - Copy(pip,(*cur)->mMaterials[i]); + for (unsigned int n = 0; n < src.size(); ++n) { + SceneHelper *cur = &src[n]; + for (unsigned int i = 0; i < (*cur)->mNumMaterials; ++i) { + if (n != duplicates[n]) { + if (flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) + Copy(pip, (*cur)->mMaterials[i]); - else continue; - } - else *pip = (*cur)->mMaterials[i]; + else + continue; + } else + *pip = (*cur)->mMaterials[i]; - if ((*cur)->mNumTextures != dest->mNumTextures) { + if ((*cur)->mNumTextures != dest->mNumTextures) { // We need to update all texture indices of the mesh. So we need to search for // a material property called '$tex.file' - for (unsigned int a = 0; a < (*pip)->mNumProperties;++a) - { - aiMaterialProperty* prop = (*pip)->mProperties[a]; - if (!strncmp(prop->mKey.data,"$tex.file",9)) - { + for (unsigned int a = 0; a < (*pip)->mNumProperties; ++a) { + aiMaterialProperty *prop = (*pip)->mProperties[a]; + if (!strncmp(prop->mKey.data, "$tex.file", 9)) { // Check whether this texture is an embedded texture. // In this case the property looks like this: *, // where n is the index of the texture. - aiString& s = *((aiString*)prop->mData); - if ('*' == s.data[0]) { + aiString &s = *((aiString *)prop->mData); + if ('*' == s.data[0]) { // Offset the index and write it back .. const unsigned int idx = strtoul10(&s.data[1]) + offset[n]; - ASSIMP_itoa10(&s.data[1],sizeof(s.data)-1,idx); + ASSIMP_itoa10(&s.data[1], sizeof(s.data) - 1, idx); } } // Need to generate new, unique material names? - else if (!::strcmp( prop->mKey.data,"$mat.name" ) && flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES) - { - aiString* pcSrc = (aiString*) prop->mData; + else if (!::strcmp(prop->mKey.data, "$mat.name") && flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES) { + aiString *pcSrc = (aiString *)prop->mData; PrefixString(*pcSrc, (*cur).id, (*cur).idlen); } } @@ -430,25 +429,23 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vectormNumMeshes) - { - aiMesh** pip = dest->mMeshes = new aiMesh*[dest->mNumMeshes]; + if (dest->mNumMeshes) { + aiMesh **pip = dest->mMeshes = new aiMesh *[dest->mNumMeshes]; cnt = 0; - for ( unsigned int n = 0; n < src.size();++n ) - { - SceneHelper* cur = &src[n]; - for (unsigned int i = 0; i < (*cur)->mNumMeshes;++i) - { + for (unsigned int n = 0; n < src.size(); ++n) { + SceneHelper *cur = &src[n]; + for (unsigned int i = 0; i < (*cur)->mNumMeshes; ++i) { if (n != duplicates[n]) { - if ( flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) + if (flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) Copy(pip, (*cur)->mMeshes[i]); - else continue; - } - else *pip = (*cur)->mMeshes[i]; + else + continue; + } else + *pip = (*cur)->mMeshes[i]; // update the material index of the mesh - (*pip)->mMaterialIndex += offset[n]; + (*pip)->mMaterialIndex += offset[n]; ++pip; } @@ -458,7 +455,7 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vector nodes; + std::vector nodes; nodes.reserve(srcList.size()); // ---------------------------------------------------------------------------- @@ -471,180 +468,177 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vectormLights = (dest->mNumLights - ? new aiLight*[dest->mNumLights] : NULL); + aiLight **ppLights = dest->mLights = (dest->mNumLights ? new aiLight *[dest->mNumLights] : nullptr); - aiCamera** ppCameras = dest->mCameras = (dest->mNumCameras - ? new aiCamera*[dest->mNumCameras] : NULL); + aiCamera **ppCameras = dest->mCameras = (dest->mNumCameras ? new aiCamera *[dest->mNumCameras] : nullptr); - aiAnimation** ppAnims = dest->mAnimations = (dest->mNumAnimations - ? new aiAnimation*[dest->mNumAnimations] : NULL); + aiAnimation **ppAnims = dest->mAnimations = (dest->mNumAnimations ? new aiAnimation *[dest->mNumAnimations] : nullptr); - for ( int n = static_cast(src.size()-1); n >= 0 ;--n ) /* !!! important !!! */ + for (int n = static_cast(src.size() - 1); n >= 0; --n) /* !!! important !!! */ { - SceneHelper* cur = &src[n]; - aiNode* node; + SceneHelper *cur = &src[n]; + aiNode *node; // To offset or not to offset, this is the question - if (n != (int)duplicates[n]) - { + if (n != (int)duplicates[n]) { // Get full scene-graph copy - Copy( &node, (*cur)->mRootNode ); - OffsetNodeMeshIndices(node,offset[duplicates[n]]); + Copy(&node, (*cur)->mRootNode); + OffsetNodeMeshIndices(node, offset[duplicates[n]]); if (flags & AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY) { // (note:) they are already 'offseted' by offset[duplicates[n]] - OffsetNodeMeshIndices(node,offset[n] - offset[duplicates[n]]); + OffsetNodeMeshIndices(node, offset[n] - offset[duplicates[n]]); } - } - else // if (n == duplicates[n]) + } else // if (n == duplicates[n]) { node = (*cur)->mRootNode; - OffsetNodeMeshIndices(node,offset[n]); + OffsetNodeMeshIndices(node, offset[n]); } if (n) // src[0] is the master node - nodes.push_back(NodeAttachmentInfo( node,srcList[n-1].attachToNode,n )); + nodes.push_back(NodeAttachmentInfo(node, srcList[n - 1].attachToNode, n)); // add name prefixes? if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES) { // or the whole scenegraph if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) { - AddNodePrefixesChecked(node,(*cur).id,(*cur).idlen,src,n); - } - else AddNodePrefixes(node,(*cur).id,(*cur).idlen); + AddNodePrefixesChecked(node, (*cur).id, (*cur).idlen, src, n); + } else + AddNodePrefixes(node, (*cur).id, (*cur).idlen); // meshes - for (unsigned int i = 0; i < (*cur)->mNumMeshes;++i) { - aiMesh* mesh = (*cur)->mMeshes[i]; + for (unsigned int i = 0; i < (*cur)->mNumMeshes; ++i) { + aiMesh *mesh = (*cur)->mMeshes[i]; // rename all bones - for (unsigned int a = 0; a < mesh->mNumBones;++a) { + for (unsigned int a = 0; a < mesh->mNumBones; ++a) { if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) { - if (!FindNameMatch(mesh->mBones[a]->mName,src,n)) + if (!FindNameMatch(mesh->mBones[a]->mName, src, n)) continue; } - PrefixString(mesh->mBones[a]->mName,(*cur).id,(*cur).idlen); + PrefixString(mesh->mBones[a]->mName, (*cur).id, (*cur).idlen); } } } // -------------------------------------------------------------------- // Copy light sources - for (unsigned int i = 0; i < (*cur)->mNumLights;++i,++ppLights) - { + for (unsigned int i = 0; i < (*cur)->mNumLights; ++i, ++ppLights) { if (n != (int)duplicates[n]) // duplicate scene? { Copy(ppLights, (*cur)->mLights[i]); - } - else *ppLights = (*cur)->mLights[i]; - + } else + *ppLights = (*cur)->mLights[i]; // Add name prefixes? if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES) { if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) { - if (!FindNameMatch((*ppLights)->mName,src,n)) + if (!FindNameMatch((*ppLights)->mName, src, n)) continue; } - PrefixString((*ppLights)->mName,(*cur).id,(*cur).idlen); + PrefixString((*ppLights)->mName, (*cur).id, (*cur).idlen); } } // -------------------------------------------------------------------- // Copy cameras - for (unsigned int i = 0; i < (*cur)->mNumCameras;++i,++ppCameras) { + for (unsigned int i = 0; i < (*cur)->mNumCameras; ++i, ++ppCameras) { if (n != (int)duplicates[n]) // duplicate scene? { Copy(ppCameras, (*cur)->mCameras[i]); - } - else *ppCameras = (*cur)->mCameras[i]; + } else + *ppCameras = (*cur)->mCameras[i]; // Add name prefixes? if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES) { if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) { - if (!FindNameMatch((*ppCameras)->mName,src,n)) + if (!FindNameMatch((*ppCameras)->mName, src, n)) continue; } - PrefixString((*ppCameras)->mName,(*cur).id,(*cur).idlen); + PrefixString((*ppCameras)->mName, (*cur).id, (*cur).idlen); } } // -------------------------------------------------------------------- // Copy animations - for (unsigned int i = 0; i < (*cur)->mNumAnimations;++i,++ppAnims) { + for (unsigned int i = 0; i < (*cur)->mNumAnimations; ++i, ++ppAnims) { if (n != (int)duplicates[n]) // duplicate scene? { Copy(ppAnims, (*cur)->mAnimations[i]); - } - else *ppAnims = (*cur)->mAnimations[i]; + } else + *ppAnims = (*cur)->mAnimations[i]; // Add name prefixes? if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES) { if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) { - if (!FindNameMatch((*ppAnims)->mName,src,n)) + if (!FindNameMatch((*ppAnims)->mName, src, n)) continue; } - PrefixString((*ppAnims)->mName,(*cur).id,(*cur).idlen); + PrefixString((*ppAnims)->mName, (*cur).id, (*cur).idlen); // don't forget to update all node animation channels - for (unsigned int a = 0; a < (*ppAnims)->mNumChannels;++a) { + for (unsigned int a = 0; a < (*ppAnims)->mNumChannels; ++a) { if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) { - if (!FindNameMatch((*ppAnims)->mChannels[a]->mNodeName,src,n)) + if (!FindNameMatch((*ppAnims)->mChannels[a]->mNodeName, src, n)) continue; } - PrefixString((*ppAnims)->mChannels[a]->mNodeName,(*cur).id,(*cur).idlen); + PrefixString((*ppAnims)->mChannels[a]->mNodeName, (*cur).id, (*cur).idlen); } } } } // Now build the output graph - AttachToGraph ( master, nodes); + AttachToGraph(master, nodes); dest->mRootNode = master->mRootNode; // Check whether we succeeded at building the output graph - for (std::vector ::iterator it = nodes.begin(); - it != nodes.end(); ++it) - { + for (std::vector::iterator it = nodes.begin(); + it != nodes.end(); ++it) { if (!(*it).resolved) { if (flags & AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS) { // search for this attachment point in all other imported scenes, too. - for ( unsigned int n = 0; n < src.size();++n ) { + for (unsigned int n = 0; n < src.size(); ++n) { if (n != (*it).src_idx) { - AttachToGraph(src[n].scene,nodes); + AttachToGraph(src[n].scene, nodes); if ((*it).resolved) break; } } } if (!(*it).resolved) { - ASSIMP_LOG_ERROR_F( "SceneCombiner: Failed to resolve attachment ", (*it).node->mName.data, - " ", (*it).attachToNode->mName.data ); + ASSIMP_LOG_ERROR_F("SceneCombiner: Failed to resolve attachment ", (*it).node->mName.data, + " ", (*it).attachToNode->mName.data); } } } // now delete all input scenes. Make sure duplicate scenes aren't // deleted more than one time - for ( unsigned int n = 0; n < src.size();++n ) { + for (unsigned int n = 0; n < src.size(); ++n) { if (n != duplicates[n]) // duplicate scene? continue; - aiScene* deleteMe = src[n].scene; + aiScene *deleteMe = src[n].scene; // We need to delete the arrays before the destructor is called - // we are reusing the array members - delete[] deleteMe->mMeshes; deleteMe->mMeshes = NULL; - delete[] deleteMe->mCameras; deleteMe->mCameras = NULL; - delete[] deleteMe->mLights; deleteMe->mLights = NULL; - delete[] deleteMe->mMaterials; deleteMe->mMaterials = NULL; - delete[] deleteMe->mAnimations; deleteMe->mAnimations = NULL; + delete[] deleteMe->mMeshes; + deleteMe->mMeshes = nullptr; + delete[] deleteMe->mCameras; + deleteMe->mCameras = nullptr; + delete[] deleteMe->mLights; + deleteMe->mLights = nullptr; + delete[] deleteMe->mMaterials; + deleteMe->mMaterials = nullptr; + delete[] deleteMe->mAnimations; + deleteMe->mAnimations = nullptr; - deleteMe->mRootNode = NULL; + deleteMe->mRootNode = nullptr; // Now we can safely delete the scene delete deleteMe; @@ -660,34 +654,33 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vector& asBones, - std::vector::const_iterator it, - std::vector::const_iterator end) -{ +void SceneCombiner::BuildUniqueBoneList(std::list &asBones, + std::vector::const_iterator it, + std::vector::const_iterator end) { unsigned int iOffset = 0; - for (; it != end;++it) { - for (unsigned int l = 0; l < (*it)->mNumBones;++l) { - aiBone* p = (*it)->mBones[l]; - uint32_t itml = SuperFastHash(p->mName.data,(unsigned int)p->mName.length); + for (; it != end; ++it) { + for (unsigned int l = 0; l < (*it)->mNumBones; ++l) { + aiBone *p = (*it)->mBones[l]; + uint32_t itml = SuperFastHash(p->mName.data, (unsigned int)p->mName.length); - std::list::iterator it2 = asBones.begin(); + std::list::iterator it2 = asBones.begin(); std::list::iterator end2 = asBones.end(); - for (;it2 != end2;++it2) { - if ((*it2).first == itml) { - (*it2).pSrcBones.push_back(BoneSrcIndex(p,iOffset)); + for (; it2 != end2; ++it2) { + if ((*it2).first == itml) { + (*it2).pSrcBones.push_back(BoneSrcIndex(p, iOffset)); break; } } - if (end2 == it2) { + if (end2 == it2) { // need to begin a new bone entry asBones.push_back(BoneWithHash()); - BoneWithHash& btz = asBones.back(); + BoneWithHash &btz = asBones.back(); // setup members btz.first = itml; btz.second = &p->mName; - btz.pSrcBones.push_back(BoneSrcIndex(p,iOffset)); + btz.pSrcBones.push_back(BoneSrcIndex(p, iOffset)); } } iOffset += (*it)->mNumVertices; @@ -696,10 +689,9 @@ void SceneCombiner::BuildUniqueBoneList(std::list& asBones, // ------------------------------------------------------------------------------------------------ // Merge a list of bones -void SceneCombiner::MergeBones(aiMesh* out,std::vector::const_iterator it, - std::vector::const_iterator end) -{ - if ( nullptr == out || out->mNumBones == 0 ) { +void SceneCombiner::MergeBones(aiMesh *out, std::vector::const_iterator it, + std::vector::const_iterator end) { + if (nullptr == out || out->mNumBones == 0) { return; } @@ -707,21 +699,21 @@ void SceneCombiner::MergeBones(aiMesh* out,std::vector::const_iterator // we work with hashes to make the comparisons MUCH faster, // at least if we have many bones. std::list asBones; - BuildUniqueBoneList( asBones, it, end ); + BuildUniqueBoneList(asBones, it, end); // now create the output bones out->mNumBones = 0; - out->mBones = new aiBone*[asBones.size()]; + out->mBones = new aiBone *[asBones.size()]; - for (std::list::const_iterator boneIt = asBones.begin(),boneEnd = asBones.end(); boneIt != boneEnd; ++boneIt ) { + for (std::list::const_iterator boneIt = asBones.begin(), boneEnd = asBones.end(); boneIt != boneEnd; ++boneIt) { // Allocate a bone and setup it's name - aiBone* pc = out->mBones[out->mNumBones++] = new aiBone(); - pc->mName = aiString( *( boneIt->second )); + aiBone *pc = out->mBones[out->mNumBones++] = new aiBone(); + pc->mName = aiString(*(boneIt->second)); - std::vector< BoneSrcIndex >::const_iterator wend = boneIt->pSrcBones.end(); + std::vector::const_iterator wend = boneIt->pSrcBones.end(); // Loop through all bones to be joined for this bone - for (std::vector< BoneSrcIndex >::const_iterator wmit = boneIt->pSrcBones.begin(); wmit != wend; ++wmit) { + for (std::vector::const_iterator wmit = boneIt->pSrcBones.begin(); wmit != wend; ++wmit) { pc->mNumWeights += (*wmit).first->mNumWeights; // NOTE: different offset matrices for bones with equal names @@ -734,18 +726,18 @@ void SceneCombiner::MergeBones(aiMesh* out,std::vector::const_iterator } // Allocate the vertex weight array - aiVertexWeight* avw = pc->mWeights = new aiVertexWeight[pc->mNumWeights]; + aiVertexWeight *avw = pc->mWeights = new aiVertexWeight[pc->mNumWeights]; // And copy the final weights - adjust the vertex IDs by the // face index offset of the corresponding mesh. - for (std::vector< BoneSrcIndex >::const_iterator wmit = (*boneIt).pSrcBones.begin(); wmit != (*boneIt).pSrcBones.end(); ++wmit) { + for (std::vector::const_iterator wmit = (*boneIt).pSrcBones.begin(); wmit != (*boneIt).pSrcBones.end(); ++wmit) { if (wmit == wend) { break; } - aiBone* pip = (*wmit).first; - for (unsigned int mp = 0; mp < pip->mNumWeights;++mp,++avw) { - const aiVertexWeight& vfi = pip->mWeights[mp]; + aiBone *pip = (*wmit).first; + for (unsigned int mp = 0; mp < pip->mNumWeights; ++mp, ++avw) { + const aiVertexWeight &vfi = pip->mWeights[mp]; avw->mWeight = vfi.mWeight; avw->mVertexId = vfi.mVertexId + (*wmit).second; } @@ -755,52 +747,51 @@ void SceneCombiner::MergeBones(aiMesh* out,std::vector::const_iterator // ------------------------------------------------------------------------------------------------ // Merge a list of meshes -void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, - std::vector::const_iterator begin, - std::vector::const_iterator end) -{ - if ( nullptr == _out ) { +void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/, + std::vector::const_iterator begin, + std::vector::const_iterator end) { + if (nullptr == _out) { return; } - if (begin == end) { - *_out = NULL; // no meshes ... + if (begin == end) { + *_out = nullptr; // no meshes ... return; } // Allocate the output mesh - aiMesh* out = *_out = new aiMesh(); + aiMesh *out = *_out = new aiMesh(); out->mMaterialIndex = (*begin)->mMaterialIndex; std::string name; // Find out how much output storage we'll need - for (std::vector::const_iterator it = begin; it != end; ++it) { - const char *meshName( (*it)->mName.C_Str() ); - name += std::string( meshName ); - if ( it != end - 1 ) { + for (std::vector::const_iterator it = begin; it != end; ++it) { + const char *meshName((*it)->mName.C_Str()); + name += std::string(meshName); + if (it != end - 1) { name += "."; } - out->mNumVertices += (*it)->mNumVertices; - out->mNumFaces += (*it)->mNumFaces; - out->mNumBones += (*it)->mNumBones; + out->mNumVertices += (*it)->mNumVertices; + out->mNumFaces += (*it)->mNumFaces; + out->mNumBones += (*it)->mNumBones; // combine primitive type flags out->mPrimitiveTypes |= (*it)->mPrimitiveTypes; } - out->mName.Set( name.c_str() ); + out->mName.Set(name.c_str()); if (out->mNumVertices) { - aiVector3D* pv2; + aiVector3D *pv2; // copy vertex positions - if ((**begin).HasPositions()) { + if ((**begin).HasPositions()) { pv2 = out->mVertices = new aiVector3D[out->mNumVertices]; - for (std::vector::const_iterator it = begin; it != end; ++it) { - if ((*it)->mVertices) { - ::memcpy(pv2,(*it)->mVertices,(*it)->mNumVertices*sizeof(aiVector3D)); - } - else ASSIMP_LOG_WARN("JoinMeshes: Positions expected but input mesh contains no positions"); + for (std::vector::const_iterator it = begin; it != end; ++it) { + if ((*it)->mVertices) { + ::memcpy(pv2, (*it)->mVertices, (*it)->mNumVertices * sizeof(aiVector3D)); + } else + ASSIMP_LOG_WARN("JoinMeshes: Positions expected but input mesh contains no positions"); pv2 += (*it)->mNumVertices; } } @@ -808,29 +799,29 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, if ((**begin).HasNormals()) { pv2 = out->mNormals = new aiVector3D[out->mNumVertices]; - for (std::vector::const_iterator it = begin; it != end;++it) { - if ((*it)->mNormals) { - ::memcpy(pv2,(*it)->mNormals,(*it)->mNumVertices*sizeof(aiVector3D)); + for (std::vector::const_iterator it = begin; it != end; ++it) { + if ((*it)->mNormals) { + ::memcpy(pv2, (*it)->mNormals, (*it)->mNumVertices * sizeof(aiVector3D)); } else { - ASSIMP_LOG_WARN( "JoinMeshes: Normals expected but input mesh contains no normals" ); + ASSIMP_LOG_WARN("JoinMeshes: Normals expected but input mesh contains no normals"); } pv2 += (*it)->mNumVertices; } } // copy tangents and bi-tangents - if ((**begin).HasTangentsAndBitangents()) { + if ((**begin).HasTangentsAndBitangents()) { pv2 = out->mTangents = new aiVector3D[out->mNumVertices]; - aiVector3D* pv2b = out->mBitangents = new aiVector3D[out->mNumVertices]; + aiVector3D *pv2b = out->mBitangents = new aiVector3D[out->mNumVertices]; - for (std::vector::const_iterator it = begin; it != end;++it) { - if ((*it)->mTangents) { - ::memcpy(pv2, (*it)->mTangents, (*it)->mNumVertices*sizeof(aiVector3D)); - ::memcpy(pv2b,(*it)->mBitangents,(*it)->mNumVertices*sizeof(aiVector3D)); + for (std::vector::const_iterator it = begin; it != end; ++it) { + if ((*it)->mTangents) { + ::memcpy(pv2, (*it)->mTangents, (*it)->mNumVertices * sizeof(aiVector3D)); + ::memcpy(pv2b, (*it)->mBitangents, (*it)->mNumVertices * sizeof(aiVector3D)); } else { - ASSIMP_LOG_WARN( "JoinMeshes: Tangents expected but input mesh contains no tangents" ); + ASSIMP_LOG_WARN("JoinMeshes: Tangents expected but input mesh contains no tangents"); } - pv2 += (*it)->mNumVertices; + pv2 += (*it)->mNumVertices; pv2b += (*it)->mNumVertices; } } @@ -840,11 +831,11 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, out->mNumUVComponents[n] = (*begin)->mNumUVComponents[n]; pv2 = out->mTextureCoords[n] = new aiVector3D[out->mNumVertices]; - for (std::vector::const_iterator it = begin; it != end;++it) { - if ((*it)->mTextureCoords[n]) { - ::memcpy(pv2,(*it)->mTextureCoords[n],(*it)->mNumVertices*sizeof(aiVector3D)); + for (std::vector::const_iterator it = begin; it != end; ++it) { + if ((*it)->mTextureCoords[n]) { + ::memcpy(pv2, (*it)->mTextureCoords[n], (*it)->mNumVertices * sizeof(aiVector3D)); } else { - ASSIMP_LOG_WARN( "JoinMeshes: UVs expected but input mesh contains no UVs" ); + ASSIMP_LOG_WARN("JoinMeshes: UVs expected but input mesh contains no UVs"); } pv2 += (*it)->mNumVertices; } @@ -852,13 +843,13 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, } // copy vertex colors n = 0; - while ((**begin).HasVertexColors(n)) { + while ((**begin).HasVertexColors(n)) { aiColor4D *pVec2 = out->mColors[n] = new aiColor4D[out->mNumVertices]; - for ( std::vector::const_iterator it = begin; it != end; ++it ) { - if ((*it)->mColors[n]) { - ::memcpy( pVec2, (*it)->mColors[ n ], (*it)->mNumVertices * sizeof( aiColor4D ) ) ; + for (std::vector::const_iterator it = begin; it != end; ++it) { + if ((*it)->mColors[n]) { + ::memcpy(pVec2, (*it)->mColors[n], (*it)->mNumVertices * sizeof(aiColor4D)); } else { - ASSIMP_LOG_WARN( "JoinMeshes: VCs expected but input mesh contains no VCs" ); + ASSIMP_LOG_WARN("JoinMeshes: VCs expected but input mesh contains no VCs"); } pVec2 += (*it)->mNumVertices; } @@ -870,21 +861,22 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, { // copy faces out->mFaces = new aiFace[out->mNumFaces]; - aiFace* pf2 = out->mFaces; + aiFace *pf2 = out->mFaces; unsigned int ofs = 0; - for (std::vector::const_iterator it = begin; it != end;++it) { - for (unsigned int m = 0; m < (*it)->mNumFaces;++m,++pf2) { - aiFace& face = (*it)->mFaces[m]; + for (std::vector::const_iterator it = begin; it != end; ++it) { + for (unsigned int m = 0; m < (*it)->mNumFaces; ++m, ++pf2) { + aiFace &face = (*it)->mFaces[m]; pf2->mNumIndices = face.mNumIndices; pf2->mIndices = face.mIndices; - if (ofs) { + if (ofs) { // add the offset to the vertex - for (unsigned int q = 0; q < face.mNumIndices; ++q) + for (unsigned int q = 0; q < face.mNumIndices; ++q) { face.mIndices[q] += ofs; + } } - face.mIndices = NULL; + face.mIndices = nullptr; } ofs += (*it)->mNumVertices; } @@ -892,33 +884,32 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, // bones - as this is quite lengthy, I moved the code to a separate function if (out->mNumBones) - MergeBones(out,begin,end); + MergeBones(out, begin, end); // delete all source meshes - for (std::vector::const_iterator it = begin; it != end;++it) + for (std::vector::const_iterator it = begin; it != end; ++it) delete *it; } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::MergeMaterials(aiMaterial** dest, - std::vector::const_iterator begin, - std::vector::const_iterator end) -{ - if ( nullptr == dest ) { +void SceneCombiner::MergeMaterials(aiMaterial **dest, + std::vector::const_iterator begin, + std::vector::const_iterator end) { + if (nullptr == dest) { return; } - if (begin == end) { - *dest = NULL; // no materials ... + if (begin == end) { + *dest = nullptr; // no materials ... return; } // Allocate the output material - aiMaterial* out = *dest = new aiMaterial(); + aiMaterial *out = *dest = new aiMaterial(); // Get the maximal number of properties unsigned int size = 0; - for (std::vector::const_iterator it = begin; it != end; ++it) { + for (std::vector::const_iterator it = begin; it != end; ++it) { size += (*it)->mNumProperties; } @@ -927,26 +918,26 @@ void SceneCombiner::MergeMaterials(aiMaterial** dest, out->mNumAllocated = size; out->mNumProperties = 0; - out->mProperties = new aiMaterialProperty*[out->mNumAllocated]; + out->mProperties = new aiMaterialProperty *[out->mNumAllocated]; - for (std::vector::const_iterator it = begin; it != end; ++it) { - for(unsigned int i = 0; i < (*it)->mNumProperties; ++i) { - aiMaterialProperty* sprop = (*it)->mProperties[i]; + for (std::vector::const_iterator it = begin; it != end; ++it) { + for (unsigned int i = 0; i < (*it)->mNumProperties; ++i) { + aiMaterialProperty *sprop = (*it)->mProperties[i]; // Test if we already have a matching property - const aiMaterialProperty* prop_exist; - if(aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mSemantic, sprop->mIndex, &prop_exist) != AI_SUCCESS) { + const aiMaterialProperty *prop_exist; + if (aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mSemantic, sprop->mIndex, &prop_exist) != AI_SUCCESS) { // If not, we add it to the new material - aiMaterialProperty* prop = out->mProperties[out->mNumProperties] = new aiMaterialProperty(); + aiMaterialProperty *prop = out->mProperties[out->mNumProperties] = new aiMaterialProperty(); prop->mDataLength = sprop->mDataLength; prop->mData = new char[prop->mDataLength]; ::memcpy(prop->mData, sprop->mData, prop->mDataLength); - prop->mIndex = sprop->mIndex; + prop->mIndex = sprop->mIndex; prop->mSemantic = sprop->mSemantic; - prop->mKey = sprop->mKey; - prop->mType = sprop->mType; + prop->mKey = sprop->mKey; + prop->mType = sprop->mType; out->mNumProperties++; } @@ -956,34 +947,32 @@ void SceneCombiner::MergeMaterials(aiMaterial** dest, // ------------------------------------------------------------------------------------------------ template -inline -void CopyPtrArray (Type**& dest, const Type* const * src, ai_uint num) { +inline void CopyPtrArray(Type **&dest, const Type *const *src, ai_uint num) { if (!num) { - dest = NULL; + dest = nullptr; return; } - dest = new Type*[num]; - for (ai_uint i = 0; i < num;++i) { - SceneCombiner::Copy(&dest[i],src[i]); + dest = new Type *[num]; + for (ai_uint i = 0; i < num; ++i) { + SceneCombiner::Copy(&dest[i], src[i]); } } // ------------------------------------------------------------------------------------------------ template -inline -void GetArrayCopy(Type*& dest, ai_uint num ) { - if ( !dest ) { +inline void GetArrayCopy(Type *&dest, ai_uint num) { + if (!dest) { return; } - Type* old = dest; + Type *old = dest; dest = new Type[num]; ::memcpy(dest, old, sizeof(Type) * num); } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::CopySceneFlat(aiScene** _dest,const aiScene* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::CopySceneFlat(aiScene **_dest, const aiScene *src) { + if (nullptr == _dest || nullptr == src) { return; } @@ -998,97 +987,99 @@ void SceneCombiner::CopySceneFlat(aiScene** _dest,const aiScene* src) { } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::CopyScene(aiScene** _dest,const aiScene* src,bool allocate) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::CopyScene(aiScene **_dest, const aiScene *src, bool allocate) { + if (nullptr == _dest || nullptr == src) { return; } if (allocate) { *_dest = new aiScene(); } - aiScene* dest = *_dest; + aiScene *dest = *_dest; ai_assert(nullptr != dest); // copy metadata - if ( nullptr != src->mMetaData ) { - dest->mMetaData = new aiMetadata( *src->mMetaData ); + if (nullptr != src->mMetaData) { + dest->mMetaData = new aiMetadata(*src->mMetaData); } // copy animations dest->mNumAnimations = src->mNumAnimations; - CopyPtrArray(dest->mAnimations,src->mAnimations, - dest->mNumAnimations); + CopyPtrArray(dest->mAnimations, src->mAnimations, + dest->mNumAnimations); // copy textures dest->mNumTextures = src->mNumTextures; - CopyPtrArray(dest->mTextures,src->mTextures, - dest->mNumTextures); + CopyPtrArray(dest->mTextures, src->mTextures, + dest->mNumTextures); // copy materials dest->mNumMaterials = src->mNumMaterials; - CopyPtrArray(dest->mMaterials,src->mMaterials, - dest->mNumMaterials); + CopyPtrArray(dest->mMaterials, src->mMaterials, + dest->mNumMaterials); // copy lights dest->mNumLights = src->mNumLights; - CopyPtrArray(dest->mLights,src->mLights, - dest->mNumLights); + CopyPtrArray(dest->mLights, src->mLights, + dest->mNumLights); // copy cameras dest->mNumCameras = src->mNumCameras; - CopyPtrArray(dest->mCameras,src->mCameras, - dest->mNumCameras); + CopyPtrArray(dest->mCameras, src->mCameras, + dest->mNumCameras); // copy meshes dest->mNumMeshes = src->mNumMeshes; - CopyPtrArray(dest->mMeshes,src->mMeshes, - dest->mNumMeshes); + CopyPtrArray(dest->mMeshes, src->mMeshes, + dest->mNumMeshes); // now - copy the root node of the scene (deep copy, too) - Copy( &dest->mRootNode, src->mRootNode); + Copy(&dest->mRootNode, src->mRootNode); // and keep the flags ... dest->mFlags = src->mFlags; - // source private data might be NULL if the scene is user-allocated (i.e. for use with the export API) - if (dest->mPrivate != NULL) { + // source private data might be nullptr if the scene is user-allocated (i.e. for use with the export API) + if (dest->mPrivate != nullptr) { ScenePriv(dest)->mPPStepsApplied = ScenePriv(src) ? ScenePriv(src)->mPPStepsApplied : 0; } } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiMesh **_dest, const aiMesh *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiMesh* dest = *_dest = new aiMesh(); + aiMesh *dest = *_dest = new aiMesh(); // get a flat copy *dest = *src; // and reallocate all arrays - GetArrayCopy( dest->mVertices, dest->mNumVertices ); - GetArrayCopy( dest->mNormals , dest->mNumVertices ); - GetArrayCopy( dest->mTangents, dest->mNumVertices ); - GetArrayCopy( dest->mBitangents, dest->mNumVertices ); + GetArrayCopy(dest->mVertices, dest->mNumVertices); + GetArrayCopy(dest->mNormals, dest->mNumVertices); + GetArrayCopy(dest->mTangents, dest->mNumVertices); + GetArrayCopy(dest->mBitangents, dest->mNumVertices); unsigned int n = 0; - while (dest->HasTextureCoords(n)) - GetArrayCopy( dest->mTextureCoords[n++], dest->mNumVertices ); + while (dest->HasTextureCoords(n)) { + GetArrayCopy(dest->mTextureCoords[n++], dest->mNumVertices); + } n = 0; - while (dest->HasVertexColors(n)) - GetArrayCopy( dest->mColors[n++], dest->mNumVertices ); + while (dest->HasVertexColors(n)) { + GetArrayCopy(dest->mColors[n++], dest->mNumVertices); + } // make a deep copy of all bones - CopyPtrArray(dest->mBones,dest->mBones,dest->mNumBones); + CopyPtrArray(dest->mBones, dest->mBones, dest->mNumBones); // make a deep copy of all faces - GetArrayCopy(dest->mFaces,dest->mNumFaces); - for (unsigned int i = 0; i < dest->mNumFaces;++i) { - aiFace& f = dest->mFaces[i]; - GetArrayCopy(f.mIndices,f.mNumIndices); + GetArrayCopy(dest->mFaces, dest->mNumFaces); + for (unsigned int i = 0; i < dest->mNumFaces; ++i) { + aiFace &f = dest->mFaces[i]; + GetArrayCopy(f.mIndices, f.mNumIndices); } // make a deep copy of all blend shapes @@ -1096,12 +1087,12 @@ void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) { } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy(aiAnimMesh** _dest, const aiAnimMesh* src) { +void SceneCombiner::Copy(aiAnimMesh **_dest, const aiAnimMesh *src) { if (nullptr == _dest || nullptr == src) { return; } - aiAnimMesh* dest = *_dest = new aiAnimMesh(); + aiAnimMesh *dest = *_dest = new aiAnimMesh(); // get a flat copy *dest = *src; @@ -1122,112 +1113,111 @@ void SceneCombiner::Copy(aiAnimMesh** _dest, const aiAnimMesh* src) { } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy (aiMaterial** _dest, const aiMaterial* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiMaterial **_dest, const aiMaterial *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiMaterial* dest = (aiMaterial*) ( *_dest = new aiMaterial() ); + aiMaterial *dest = (aiMaterial *)(*_dest = new aiMaterial()); dest->Clear(); delete[] dest->mProperties; - dest->mNumAllocated = src->mNumAllocated; - dest->mNumProperties = src->mNumProperties; - dest->mProperties = new aiMaterialProperty* [dest->mNumAllocated]; + dest->mNumAllocated = src->mNumAllocated; + dest->mNumProperties = src->mNumProperties; + dest->mProperties = new aiMaterialProperty *[dest->mNumAllocated]; - for (unsigned int i = 0; i < dest->mNumProperties;++i) - { - aiMaterialProperty* prop = dest->mProperties[i] = new aiMaterialProperty(); - aiMaterialProperty* sprop = src->mProperties[i]; + for (unsigned int i = 0; i < dest->mNumProperties; ++i) { + aiMaterialProperty *prop = dest->mProperties[i] = new aiMaterialProperty(); + aiMaterialProperty *sprop = src->mProperties[i]; prop->mDataLength = sprop->mDataLength; prop->mData = new char[prop->mDataLength]; - ::memcpy(prop->mData,sprop->mData,prop->mDataLength); + ::memcpy(prop->mData, sprop->mData, prop->mDataLength); - prop->mIndex = sprop->mIndex; + prop->mIndex = sprop->mIndex; prop->mSemantic = sprop->mSemantic; - prop->mKey = sprop->mKey; - prop->mType = sprop->mType; + prop->mKey = sprop->mKey; + prop->mType = sprop->mType; } } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy(aiTexture** _dest, const aiTexture* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiTexture **_dest, const aiTexture *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiTexture* dest = *_dest = new aiTexture(); + aiTexture *dest = *_dest = new aiTexture(); // get a flat copy *dest = *src; // and reallocate all arrays. We must do it manually here - const char* old = (const char*)dest->pcData; - if (old) - { + const char *old = (const char *)dest->pcData; + if (old) { unsigned int cpy; - if (!dest->mHeight)cpy = dest->mWidth; - else cpy = dest->mHeight * dest->mWidth * sizeof(aiTexel); + if (!dest->mHeight) + cpy = dest->mWidth; + else + cpy = dest->mHeight * dest->mWidth * sizeof(aiTexel); - if (!cpy) - { - dest->pcData = NULL; + if (!cpy) { + dest->pcData = nullptr; return; } // the cast is legal, the aiTexel c'tor does nothing important - dest->pcData = (aiTexel*) new char[cpy]; + dest->pcData = (aiTexel *)new char[cpy]; ::memcpy(dest->pcData, old, cpy); } } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy( aiAnimation** _dest, const aiAnimation* src ) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiAnimation **_dest, const aiAnimation *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiAnimation* dest = *_dest = new aiAnimation(); + aiAnimation *dest = *_dest = new aiAnimation(); // get a flat copy *dest = *src; // and reallocate all arrays - CopyPtrArray( dest->mChannels, src->mChannels, dest->mNumChannels ); - CopyPtrArray( dest->mMorphMeshChannels, src->mMorphMeshChannels, dest->mNumMorphMeshChannels ); + CopyPtrArray(dest->mChannels, src->mChannels, dest->mNumChannels); + CopyPtrArray(dest->mMorphMeshChannels, src->mMorphMeshChannels, dest->mNumMorphMeshChannels); } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy(aiNodeAnim** _dest, const aiNodeAnim* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiNodeAnim **_dest, const aiNodeAnim *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiNodeAnim* dest = *_dest = new aiNodeAnim(); + aiNodeAnim *dest = *_dest = new aiNodeAnim(); // get a flat copy *dest = *src; // and reallocate all arrays - GetArrayCopy( dest->mPositionKeys, dest->mNumPositionKeys ); - GetArrayCopy( dest->mScalingKeys, dest->mNumScalingKeys ); - GetArrayCopy( dest->mRotationKeys, dest->mNumRotationKeys ); + GetArrayCopy(dest->mPositionKeys, dest->mNumPositionKeys); + GetArrayCopy(dest->mScalingKeys, dest->mNumScalingKeys); + GetArrayCopy(dest->mRotationKeys, dest->mNumRotationKeys); } -void SceneCombiner::Copy(aiMeshMorphAnim** _dest, const aiMeshMorphAnim* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiMeshMorphAnim **_dest, const aiMeshMorphAnim *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiMeshMorphAnim* dest = *_dest = new aiMeshMorphAnim(); + aiMeshMorphAnim *dest = *_dest = new aiMeshMorphAnim(); // get a flat copy *dest = *src; // and reallocate all arrays - GetArrayCopy( dest->mKeys, dest->mNumKeys ); - for (ai_uint i = 0; i < dest->mNumKeys;++i) { + GetArrayCopy(dest->mKeys, dest->mNumKeys); + for (ai_uint i = 0; i < dest->mNumKeys; ++i) { dest->mKeys[i].mValues = new unsigned int[dest->mKeys[i].mNumValuesAndWeights]; dest->mKeys[i].mWeights = new double[dest->mKeys[i].mNumValuesAndWeights]; ::memcpy(dest->mKeys[i].mValues, src->mKeys[i].mValues, dest->mKeys[i].mNumValuesAndWeights * sizeof(unsigned int)); @@ -1236,47 +1226,47 @@ void SceneCombiner::Copy(aiMeshMorphAnim** _dest, const aiMeshMorphAnim* src) { } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy( aiCamera** _dest,const aiCamera* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiCamera **_dest, const aiCamera *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiCamera* dest = *_dest = new aiCamera(); + aiCamera *dest = *_dest = new aiCamera(); // get a flat copy, that's already OK *dest = *src; } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy(aiLight** _dest, const aiLight* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiLight **_dest, const aiLight *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiLight* dest = *_dest = new aiLight(); + aiLight *dest = *_dest = new aiLight(); // get a flat copy, that's already OK *dest = *src; } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy(aiBone** _dest, const aiBone* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiBone **_dest, const aiBone *src) { + if (nullptr == _dest || nullptr == src) { return; } - aiBone* dest = *_dest = new aiBone(); + aiBone *dest = *_dest = new aiBone(); // get a flat copy *dest = *src; } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy (aiNode** _dest, const aiNode* src) -{ - ai_assert(NULL != _dest && NULL != src); +void SceneCombiner::Copy(aiNode **_dest, const aiNode *src) { + ai_assert(nullptr != _dest); + ai_assert(nullptr != src); - aiNode* dest = *_dest = new aiNode(); + aiNode *dest = *_dest = new aiNode(); // get a flat copy *dest = *src; @@ -1286,60 +1276,63 @@ void SceneCombiner::Copy (aiNode** _dest, const aiNode* src) } // and reallocate all arrays - GetArrayCopy( dest->mMeshes, dest->mNumMeshes ); - CopyPtrArray( dest->mChildren, src->mChildren,dest->mNumChildren); + GetArrayCopy(dest->mMeshes, dest->mNumMeshes); + CopyPtrArray(dest->mChildren, src->mChildren, dest->mNumChildren); - // need to set the mParent fields to the created aiNode. - for( unsigned int i = 0; i < dest->mNumChildren; i ++ ) { - dest->mChildren[i]->mParent = dest; - } + // need to set the mParent fields to the created aiNode. + for (unsigned int i = 0; i < dest->mNumChildren; i++) { + dest->mChildren[i]->mParent = dest; + } } // ------------------------------------------------------------------------------------------------ -void SceneCombiner::Copy(aiMetadata** _dest, const aiMetadata* src) { - if ( nullptr == _dest || nullptr == src ) { +void SceneCombiner::Copy(aiMetadata **_dest, const aiMetadata *src) { + if (nullptr == _dest || nullptr == src) { return; } - if ( 0 == src->mNumProperties ) { + if (0 == src->mNumProperties) { return; } - aiMetadata* dest = *_dest = aiMetadata::Alloc( src->mNumProperties ); + aiMetadata *dest = *_dest = aiMetadata::Alloc(src->mNumProperties); std::copy(src->mKeys, src->mKeys + src->mNumProperties, dest->mKeys); for (unsigned int i = 0; i < src->mNumProperties; ++i) { - aiMetadataEntry& in = src->mValues[i]; - aiMetadataEntry& out = dest->mValues[i]; + aiMetadataEntry &in = src->mValues[i]; + aiMetadataEntry &out = dest->mValues[i]; out.mType = in.mType; switch (dest->mValues[i].mType) { - case AI_BOOL: - out.mData = new bool(*static_cast(in.mData)); - break; - case AI_INT32: - out.mData = new int32_t(*static_cast(in.mData)); - break; - case AI_UINT64: - out.mData = new uint64_t(*static_cast(in.mData)); - break; - case AI_FLOAT: - out.mData = new float(*static_cast(in.mData)); - break; - case AI_DOUBLE: - out.mData = new double(*static_cast(in.mData)); - break; - case AI_AISTRING: - out.mData = new aiString(*static_cast(in.mData)); - break; - case AI_AIVECTOR3D: - out.mData = new aiVector3D(*static_cast(in.mData)); - break; - default: - ai_assert(false); - break; + case AI_BOOL: + out.mData = new bool(*static_cast(in.mData)); + break; + case AI_INT32: + out.mData = new int32_t(*static_cast(in.mData)); + break; + case AI_UINT64: + out.mData = new uint64_t(*static_cast(in.mData)); + break; + case AI_FLOAT: + out.mData = new float(*static_cast(in.mData)); + break; + case AI_DOUBLE: + out.mData = new double(*static_cast(in.mData)); + break; + case AI_AISTRING: + out.mData = new aiString(*static_cast(in.mData)); + break; + case AI_AIVECTOR3D: + out.mData = new aiVector3D(*static_cast(in.mData)); + break; + default: + ai_assert(false); + break; } } } -} // Namespace Assimp +#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic pop +#endif +} // Namespace Assimp diff --git a/code/Common/ScenePreprocessor.cpp b/code/Common/ScenePreprocessor.cpp index 606590519..55aa04ad2 100644 --- a/code/Common/ScenePreprocessor.cpp +++ b/code/Common/ScenePreprocessor.cpp @@ -45,16 +45,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include - using namespace Assimp; // --------------------------------------------------------------------------------------------- -void ScenePreprocessor::ProcessScene () -{ - ai_assert(scene != NULL); +void ScenePreprocessor::ProcessScene() { + ai_assert(scene != nullptr); // Process all meshes - for (unsigned int i = 0; i < scene->mNumMeshes;++i) + for (unsigned int i = 0; i < scene->mNumMeshes; ++i) ProcessMesh(scene->mMeshes[i]); // - nothing to do for nodes for the moment @@ -63,27 +61,27 @@ void ScenePreprocessor::ProcessScene () // - nothing to do for cameras for the moment // Process all animations - for (unsigned int i = 0; i < scene->mNumAnimations;++i) + for (unsigned int i = 0; i < scene->mNumAnimations; ++i) ProcessAnimation(scene->mAnimations[i]); // Generate a default material if none was specified if (!scene->mNumMaterials && scene->mNumMeshes) { - scene->mMaterials = new aiMaterial*[2]; - aiMaterial* helper; + scene->mMaterials = new aiMaterial *[2]; + aiMaterial *helper; aiString name; scene->mMaterials[scene->mNumMaterials] = helper = new aiMaterial(); - aiColor3D clr(0.6f,0.6f,0.6f); - helper->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE); + aiColor3D clr(0.6f, 0.6f, 0.6f); + helper->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE); // setup the default name to make this material identifiable name.Set(AI_DEFAULT_MATERIAL_NAME); - helper->AddProperty(&name,AI_MATKEY_NAME); + helper->AddProperty(&name, AI_MATKEY_NAME); - ASSIMP_LOG_DEBUG("ScenePreprocessor: Adding default material \'" AI_DEFAULT_MATERIAL_NAME "\'"); + ASSIMP_LOG_DEBUG("ScenePreprocessor: Adding default material \'" AI_DEFAULT_MATERIAL_NAME "\'"); - for (unsigned int i = 0; i < scene->mNumMeshes;++i) { + for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { scene->mMeshes[i]->mMaterialIndex = scene->mNumMaterials; } @@ -92,17 +90,16 @@ void ScenePreprocessor::ProcessScene () } // --------------------------------------------------------------------------------------------- -void ScenePreprocessor::ProcessMesh (aiMesh* mesh) -{ +void ScenePreprocessor::ProcessMesh(aiMesh *mesh) { // If aiMesh::mNumUVComponents is *not* set assign the default value of 2 - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { + for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { if (!mesh->mTextureCoords[i]) { mesh->mNumUVComponents[i] = 0; } else { if (!mesh->mNumUVComponents[i]) mesh->mNumUVComponents[i] = 2; - aiVector3D* p = mesh->mTextureCoords[i], *end = p+mesh->mNumVertices; + aiVector3D *p = mesh->mTextureCoords[i], *end = p + mesh->mNumVertices; // Ensure unused components are zeroed. This will make 1D texture channels work // as if they were 2D channels .. just in case an application doesn't handle @@ -110,12 +107,10 @@ void ScenePreprocessor::ProcessMesh (aiMesh* mesh) if (2 == mesh->mNumUVComponents[i]) { for (; p != end; ++p) p->z = 0.f; - } - else if (1 == mesh->mNumUVComponents[i]) { + } else if (1 == mesh->mNumUVComponents[i]) { for (; p != end; ++p) p->z = p->y = 0.f; - } - else if (3 == mesh->mNumUVComponents[i]) { + } else if (3 == mesh->mNumUVComponents[i]) { // Really 3D coordinates? Check whether the third coordinate is != 0 for at least one element for (; p != end; ++p) { if (p->z != 0) @@ -132,10 +127,9 @@ void ScenePreprocessor::ProcessMesh (aiMesh* mesh) // If the information which primitive types are there in the // mesh is currently not available, compute it. if (!mesh->mPrimitiveTypes) { - for (unsigned int a = 0; a < mesh->mNumFaces; ++a) { - aiFace& face = mesh->mFaces[a]; - switch (face.mNumIndices) - { + for (unsigned int a = 0; a < mesh->mNumFaces; ++a) { + aiFace &face = mesh->mFaces[a]; + switch (face.mNumIndices) { case 3u: mesh->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE; break; @@ -156,21 +150,20 @@ void ScenePreprocessor::ProcessMesh (aiMesh* mesh) } // If tangents and normals are given but no bitangents compute them - if (mesh->mTangents && mesh->mNormals && !mesh->mBitangents) { + if (mesh->mTangents && mesh->mNormals && !mesh->mBitangents) { mesh->mBitangents = new aiVector3D[mesh->mNumVertices]; - for (unsigned int i = 0; i < mesh->mNumVertices;++i) { + for (unsigned int i = 0; i < mesh->mNumVertices; ++i) { mesh->mBitangents[i] = mesh->mNormals[i] ^ mesh->mTangents[i]; } } } // --------------------------------------------------------------------------------------------- -void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) -{ +void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) { double first = 10e10, last = -10e10; - for (unsigned int i = 0; i < anim->mNumChannels;++i) { - aiNodeAnim* channel = anim->mChannels[i]; + for (unsigned int i = 0; i < anim->mNumChannels; ++i) { + aiNodeAnim *channel = anim->mChannels[i]; /* If the exact duration of the animation is not given * compute it now. @@ -178,24 +171,24 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) if (anim->mDuration == -1.) { // Position keys - for (unsigned int j = 0; j < channel->mNumPositionKeys;++j) { - aiVectorKey& key = channel->mPositionKeys[j]; - first = std::min (first, key.mTime); - last = std::max (last, key.mTime); + for (unsigned int j = 0; j < channel->mNumPositionKeys; ++j) { + aiVectorKey &key = channel->mPositionKeys[j]; + first = std::min(first, key.mTime); + last = std::max(last, key.mTime); } // Scaling keys - for (unsigned int j = 0; j < channel->mNumScalingKeys;++j ) { - aiVectorKey& key = channel->mScalingKeys[j]; - first = std::min (first, key.mTime); - last = std::max (last, key.mTime); + for (unsigned int j = 0; j < channel->mNumScalingKeys; ++j) { + aiVectorKey &key = channel->mScalingKeys[j]; + first = std::min(first, key.mTime); + last = std::max(last, key.mTime); } // Rotation keys - for (unsigned int j = 0; j < channel->mNumRotationKeys;++j ) { - aiQuatKey& key = channel->mRotationKeys[ j ]; - first = std::min (first, key.mTime); - last = std::max (last, key.mTime); + for (unsigned int j = 0; j < channel->mNumRotationKeys; ++j) { + aiQuatKey &key = channel->mRotationKeys[j]; + first = std::min(first, key.mTime); + last = std::max(last, key.mTime); } } @@ -204,43 +197,43 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) * track from the information we have in the transformation * matrix of the corresponding node. */ - if (!channel->mNumRotationKeys || !channel->mNumPositionKeys || !channel->mNumScalingKeys) { + if (!channel->mNumRotationKeys || !channel->mNumPositionKeys || !channel->mNumScalingKeys) { // Find the node that belongs to this animation - aiNode* node = scene->mRootNode->FindNode(channel->mNodeName); - if (node) // ValidateDS will complain later if 'node' is NULL + aiNode *node = scene->mRootNode->FindNode(channel->mNodeName); + if (node) // ValidateDS will complain later if 'node' is nullptr { // Decompose the transformation matrix of the node aiVector3D scaling, position; aiQuaternion rotation; - node->mTransformation.Decompose(scaling, rotation,position); + node->mTransformation.Decompose(scaling, rotation, position); // No rotation keys? Generate a dummy track if (!channel->mNumRotationKeys) { ai_assert(!channel->mRotationKeys); channel->mNumRotationKeys = 1; channel->mRotationKeys = new aiQuatKey[1]; - aiQuatKey& q = channel->mRotationKeys[0]; + aiQuatKey &q = channel->mRotationKeys[0]; - q.mTime = 0.; + q.mTime = 0.; q.mValue = rotation; - ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy rotation track has been generated"); + ASSIMP_LOG_VERBOSE_DEBUG("ScenePreprocessor: Dummy rotation track has been generated"); } else { ai_assert(channel->mRotationKeys); } // No scaling keys? Generate a dummy track - if (!channel->mNumScalingKeys) { + if (!channel->mNumScalingKeys) { ai_assert(!channel->mScalingKeys); channel->mNumScalingKeys = 1; channel->mScalingKeys = new aiVectorKey[1]; - aiVectorKey& q = channel->mScalingKeys[0]; + aiVectorKey &q = channel->mScalingKeys[0]; - q.mTime = 0.; + q.mTime = 0.; q.mValue = scaling; - ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy scaling track has been generated"); + ASSIMP_LOG_VERBOSE_DEBUG("ScenePreprocessor: Dummy scaling track has been generated"); } else { ai_assert(channel->mScalingKeys); } @@ -250,12 +243,12 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) ai_assert(!channel->mPositionKeys); channel->mNumPositionKeys = 1; channel->mPositionKeys = new aiVectorKey[1]; - aiVectorKey& q = channel->mPositionKeys[0]; + aiVectorKey &q = channel->mPositionKeys[0]; - q.mTime = 0.; + q.mTime = 0.; q.mValue = position; - ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy position track has been generated"); + ASSIMP_LOG_VERBOSE_DEBUG("ScenePreprocessor: Dummy position track has been generated"); } else { ai_assert(channel->mPositionKeys); } @@ -263,8 +256,8 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) } } - if (anim->mDuration == -1.) { - ASSIMP_LOG_DEBUG("ScenePreprocessor: Setting animation duration"); - anim->mDuration = last - std::min( first, 0. ); + if (anim->mDuration == -1.) { + ASSIMP_LOG_VERBOSE_DEBUG("ScenePreprocessor: Setting animation duration"); + anim->mDuration = last - std::min(first, 0.); } } diff --git a/code/Common/ScenePreprocessor.h b/code/Common/ScenePreprocessor.h index e059d1c95..2ec67f20b 100644 --- a/code/Common/ScenePreprocessor.h +++ b/code/Common/ScenePreprocessor.h @@ -53,7 +53,7 @@ struct aiAnimation; struct aiMesh; class ScenePreprocessorTest; -namespace Assimp { +namespace Assimp { // ---------------------------------------------------------------------------------- /** ScenePreprocessor: Preprocess a scene before any post-processing @@ -63,24 +63,21 @@ namespace Assimp { * importer, such as aiMesh::mPrimitiveTypes. */ // ---------------------------------------------------------------------------------- -class ASSIMP_API ScenePreprocessor -{ +class ASSIMP_API ScenePreprocessor { // Make ourselves a friend of the corresponding test unit. friend class ::ScenePreprocessorTest; -public: +public: // ---------------------------------------------------------------- /** Default c'tpr. Use SetScene() to assign a scene to the object. */ - ScenePreprocessor() - : scene (NULL) - {} + ScenePreprocessor() : + scene(nullptr) {} /** Constructs the object and assigns a specific scene to it */ - ScenePreprocessor(aiScene* _scene) - : scene (_scene) - {} + ScenePreprocessor(aiScene *_scene) : + scene(_scene) {} // ---------------------------------------------------------------- /** Assign a (new) scene to the object. @@ -89,37 +86,33 @@ public: * Call ProcessScene to have the scene preprocessed. * @param sc Scene to be processed. */ - void SetScene (aiScene* sc) { + void SetScene(aiScene *sc) { scene = sc; } // ---------------------------------------------------------------- /** Preprocess the current scene */ - void ProcessScene (); + void ProcessScene(); protected: - // ---------------------------------------------------------------- /** Preprocess an animation in the scene * @param anim Anim to be preprocessed. */ - void ProcessAnimation (aiAnimation* anim); - + void ProcessAnimation(aiAnimation *anim); // ---------------------------------------------------------------- /** Preprocess a mesh in the scene * @param mesh Mesh to be preprocessed. */ - void ProcessMesh (aiMesh* mesh); + void ProcessMesh(aiMesh *mesh); protected: - //! Scene we're currently working on - aiScene* scene; + aiScene *scene; }; - -} // ! end namespace Assimp +} // namespace Assimp #endif // include guard diff --git a/code/Common/SkeletonMeshBuilder.cpp b/code/Common/SkeletonMeshBuilder.cpp index 724359f99..7387744bf 100644 --- a/code/Common/SkeletonMeshBuilder.cpp +++ b/code/Common/SkeletonMeshBuilder.cpp @@ -44,30 +44,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of a little class to construct a dummy mesh for a skeleton */ -#include #include +#include using namespace Assimp; // ------------------------------------------------------------------------------------------------ // The constructor processes the given scene and adds a mesh there. -SkeletonMeshBuilder::SkeletonMeshBuilder( aiScene* pScene, aiNode* root, bool bKnobsOnly) -{ +SkeletonMeshBuilder::SkeletonMeshBuilder(aiScene *pScene, aiNode *root, bool bKnobsOnly) { // nothing to do if there's mesh data already present at the scene - if( pScene->mNumMeshes > 0 || pScene->mRootNode == NULL) + if (pScene->mNumMeshes > 0 || pScene->mRootNode == nullptr) { return; + } - if (!root) + if (!root) { root = pScene->mRootNode; + } mKnobsOnly = bKnobsOnly; // build some faces around each node - CreateGeometry( root ); + CreateGeometry(root); // create a mesh to hold all the generated faces pScene->mNumMeshes = 1; - pScene->mMeshes = new aiMesh*[1]; + pScene->mMeshes = new aiMesh *[1]; pScene->mMeshes[0] = CreateMesh(); // and install it at the root node root->mNumMeshes = 1; @@ -75,154 +76,146 @@ SkeletonMeshBuilder::SkeletonMeshBuilder( aiScene* pScene, aiNode* root, bool bK root->mMeshes[0] = 0; // create a dummy material for the mesh - if(pScene->mNumMaterials==0){ - pScene->mNumMaterials = 1; - pScene->mMaterials = new aiMaterial*[1]; - pScene->mMaterials[0] = CreateMaterial(); + if (pScene->mNumMaterials == 0) { + pScene->mNumMaterials = 1; + pScene->mMaterials = new aiMaterial *[1]; + pScene->mMaterials[0] = CreateMaterial(); } } // ------------------------------------------------------------------------------------------------ // Recursively builds a simple mesh representation for the given node -void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode) -{ +void SkeletonMeshBuilder::CreateGeometry(const aiNode *pNode) { // add a joint entry for the node. const unsigned int vertexStartIndex = static_cast(mVertices.size()); // now build the geometry. - if( pNode->mNumChildren > 0 && !mKnobsOnly) - { + if (pNode->mNumChildren > 0 && !mKnobsOnly) { // If the node has children, we build little pointers to each of them - for( unsigned int a = 0; a < pNode->mNumChildren; a++) - { + for (unsigned int a = 0; a < pNode->mNumChildren; a++) { // find a suitable coordinate system - const aiMatrix4x4& childTransform = pNode->mChildren[a]->mTransformation; - aiVector3D childpos( childTransform.a4, childTransform.b4, childTransform.c4); + const aiMatrix4x4 &childTransform = pNode->mChildren[a]->mTransformation; + aiVector3D childpos(childTransform.a4, childTransform.b4, childTransform.c4); ai_real distanceToChild = childpos.Length(); - if( distanceToChild < 0.0001) + if (distanceToChild < 0.0001) continue; - aiVector3D up = aiVector3D( childpos).Normalize(); + aiVector3D up = aiVector3D(childpos).Normalize(); - aiVector3D orth( 1.0, 0.0, 0.0); - if( std::fabs( orth * up) > 0.99) - orth.Set( 0.0, 1.0, 0.0); + aiVector3D orth(1.0, 0.0, 0.0); + if (std::fabs(orth * up) > 0.99) + orth.Set(0.0, 1.0, 0.0); aiVector3D front = (up ^ orth).Normalize(); aiVector3D side = (front ^ up).Normalize(); unsigned int localVertexStart = static_cast(mVertices.size()); - mVertices.push_back( -front * distanceToChild * (ai_real)0.1); - mVertices.push_back( childpos); - mVertices.push_back( -side * distanceToChild * (ai_real)0.1); - mVertices.push_back( -side * distanceToChild * (ai_real)0.1); - mVertices.push_back( childpos); - mVertices.push_back( front * distanceToChild * (ai_real)0.1); - mVertices.push_back( front * distanceToChild * (ai_real)0.1); - mVertices.push_back( childpos); - mVertices.push_back( side * distanceToChild * (ai_real)0.1); - mVertices.push_back( side * distanceToChild * (ai_real)0.1); - mVertices.push_back( childpos); - mVertices.push_back( -front * distanceToChild * (ai_real)0.1); + mVertices.push_back(-front * distanceToChild * (ai_real)0.1); + mVertices.push_back(childpos); + mVertices.push_back(-side * distanceToChild * (ai_real)0.1); + mVertices.push_back(-side * distanceToChild * (ai_real)0.1); + mVertices.push_back(childpos); + mVertices.push_back(front * distanceToChild * (ai_real)0.1); + mVertices.push_back(front * distanceToChild * (ai_real)0.1); + mVertices.push_back(childpos); + mVertices.push_back(side * distanceToChild * (ai_real)0.1); + mVertices.push_back(side * distanceToChild * (ai_real)0.1); + mVertices.push_back(childpos); + mVertices.push_back(-front * distanceToChild * (ai_real)0.1); - mFaces.push_back( Face( localVertexStart + 0, localVertexStart + 1, localVertexStart + 2)); - mFaces.push_back( Face( localVertexStart + 3, localVertexStart + 4, localVertexStart + 5)); - mFaces.push_back( Face( localVertexStart + 6, localVertexStart + 7, localVertexStart + 8)); - mFaces.push_back( Face( localVertexStart + 9, localVertexStart + 10, localVertexStart + 11)); + mFaces.push_back(Face(localVertexStart + 0, localVertexStart + 1, localVertexStart + 2)); + mFaces.push_back(Face(localVertexStart + 3, localVertexStart + 4, localVertexStart + 5)); + mFaces.push_back(Face(localVertexStart + 6, localVertexStart + 7, localVertexStart + 8)); + mFaces.push_back(Face(localVertexStart + 9, localVertexStart + 10, localVertexStart + 11)); } - } - else - { + } else { // if the node has no children, it's an end node. Put a little knob there instead - aiVector3D ownpos( pNode->mTransformation.a4, pNode->mTransformation.b4, pNode->mTransformation.c4); - ai_real sizeEstimate = ownpos.Length() * ai_real( 0.18 ); + aiVector3D ownpos(pNode->mTransformation.a4, pNode->mTransformation.b4, pNode->mTransformation.c4); + ai_real sizeEstimate = ownpos.Length() * ai_real(0.18); - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); - mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); - mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); + mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); + mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); + mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); + mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); - mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); + mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); + mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); + mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); + mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); + mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); - mFaces.push_back( Face( vertexStartIndex + 0, vertexStartIndex + 1, vertexStartIndex + 2)); - mFaces.push_back( Face( vertexStartIndex + 3, vertexStartIndex + 4, vertexStartIndex + 5)); - mFaces.push_back( Face( vertexStartIndex + 6, vertexStartIndex + 7, vertexStartIndex + 8)); - mFaces.push_back( Face( vertexStartIndex + 9, vertexStartIndex + 10, vertexStartIndex + 11)); - mFaces.push_back( Face( vertexStartIndex + 12, vertexStartIndex + 13, vertexStartIndex + 14)); - mFaces.push_back( Face( vertexStartIndex + 15, vertexStartIndex + 16, vertexStartIndex + 17)); - mFaces.push_back( Face( vertexStartIndex + 18, vertexStartIndex + 19, vertexStartIndex + 20)); - mFaces.push_back( Face( vertexStartIndex + 21, vertexStartIndex + 22, vertexStartIndex + 23)); + mFaces.push_back(Face(vertexStartIndex + 0, vertexStartIndex + 1, vertexStartIndex + 2)); + mFaces.push_back(Face(vertexStartIndex + 3, vertexStartIndex + 4, vertexStartIndex + 5)); + mFaces.push_back(Face(vertexStartIndex + 6, vertexStartIndex + 7, vertexStartIndex + 8)); + mFaces.push_back(Face(vertexStartIndex + 9, vertexStartIndex + 10, vertexStartIndex + 11)); + mFaces.push_back(Face(vertexStartIndex + 12, vertexStartIndex + 13, vertexStartIndex + 14)); + mFaces.push_back(Face(vertexStartIndex + 15, vertexStartIndex + 16, vertexStartIndex + 17)); + mFaces.push_back(Face(vertexStartIndex + 18, vertexStartIndex + 19, vertexStartIndex + 20)); + mFaces.push_back(Face(vertexStartIndex + 21, vertexStartIndex + 22, vertexStartIndex + 23)); } unsigned int numVertices = static_cast(mVertices.size() - vertexStartIndex); - if( numVertices > 0) - { + if (numVertices > 0) { // create a bone affecting all the newly created vertices - aiBone* bone = new aiBone; - mBones.push_back( bone); + aiBone *bone = new aiBone; + mBones.push_back(bone); bone->mName = pNode->mName; // calculate the bone offset matrix by concatenating the inverse transformations of all parents - bone->mOffsetMatrix = aiMatrix4x4( pNode->mTransformation).Inverse(); - for( aiNode* parent = pNode->mParent; parent != NULL; parent = parent->mParent) - bone->mOffsetMatrix = aiMatrix4x4( parent->mTransformation).Inverse() * bone->mOffsetMatrix; + bone->mOffsetMatrix = aiMatrix4x4(pNode->mTransformation).Inverse(); + for (aiNode *parent = pNode->mParent; parent != nullptr; parent = parent->mParent) + bone->mOffsetMatrix = aiMatrix4x4(parent->mTransformation).Inverse() * bone->mOffsetMatrix; // add all the vertices to the bone's influences bone->mNumWeights = numVertices; bone->mWeights = new aiVertexWeight[numVertices]; - for( unsigned int a = 0; a < numVertices; a++) - bone->mWeights[a] = aiVertexWeight( vertexStartIndex + a, 1.0); + for (unsigned int a = 0; a < numVertices; a++) + bone->mWeights[a] = aiVertexWeight(vertexStartIndex + a, 1.0); // HACK: (thom) transform all vertices to the bone's local space. Should be done before adding // them to the array, but I'm tired now and I'm annoyed. - aiMatrix4x4 boneToMeshTransform = aiMatrix4x4( bone->mOffsetMatrix).Inverse(); - for( unsigned int a = vertexStartIndex; a < mVertices.size(); a++) + aiMatrix4x4 boneToMeshTransform = aiMatrix4x4(bone->mOffsetMatrix).Inverse(); + for (unsigned int a = vertexStartIndex; a < mVertices.size(); a++) mVertices[a] = boneToMeshTransform * mVertices[a]; } // and finally recurse into the children list - for( unsigned int a = 0; a < pNode->mNumChildren; a++) - CreateGeometry( pNode->mChildren[a]); + for (unsigned int a = 0; a < pNode->mNumChildren; a++) + CreateGeometry(pNode->mChildren[a]); } // ------------------------------------------------------------------------------------------------ // Creates the mesh from the internally accumulated stuff and returns it. -aiMesh* SkeletonMeshBuilder::CreateMesh() -{ - aiMesh* mesh = new aiMesh(); +aiMesh *SkeletonMeshBuilder::CreateMesh() { + aiMesh *mesh = new aiMesh(); // add points mesh->mNumVertices = static_cast(mVertices.size()); mesh->mVertices = new aiVector3D[mesh->mNumVertices]; - std::copy( mVertices.begin(), mVertices.end(), mesh->mVertices); + std::copy(mVertices.begin(), mVertices.end(), mesh->mVertices); mesh->mNormals = new aiVector3D[mesh->mNumVertices]; // add faces mesh->mNumFaces = static_cast(mFaces.size()); mesh->mFaces = new aiFace[mesh->mNumFaces]; - for( unsigned int a = 0; a < mesh->mNumFaces; a++) - { - const Face& inface = mFaces[a]; - aiFace& outface = mesh->mFaces[a]; + for (unsigned int a = 0; a < mesh->mNumFaces; a++) { + const Face &inface = mFaces[a]; + aiFace &outface = mesh->mFaces[a]; outface.mNumIndices = 3; outface.mIndices = new unsigned int[3]; outface.mIndices[0] = inface.mIndices[0]; @@ -232,10 +225,10 @@ aiMesh* SkeletonMeshBuilder::CreateMesh() // Compute per-face normals ... we don't want the bones to be smoothed ... they're built to visualize // the skeleton, so it's good if there's a visual difference to the rest of the geometry aiVector3D nor = ((mVertices[inface.mIndices[2]] - mVertices[inface.mIndices[0]]) ^ - (mVertices[inface.mIndices[1]] - mVertices[inface.mIndices[0]])); + (mVertices[inface.mIndices[1]] - mVertices[inface.mIndices[0]])); if (nor.Length() < 1e-5) /* ensure that FindInvalidData won't remove us ...*/ - nor = aiVector3D(1.0,0.0,0.0); + nor = aiVector3D(1.0, 0.0, 0.0); for (unsigned int n = 0; n < 3; ++n) mesh->mNormals[inface.mIndices[n]] = nor; @@ -243,8 +236,8 @@ aiMesh* SkeletonMeshBuilder::CreateMesh() // add the bones mesh->mNumBones = static_cast(mBones.size()); - mesh->mBones = new aiBone*[mesh->mNumBones]; - std::copy( mBones.begin(), mBones.end(), mesh->mBones); + mesh->mBones = new aiBone *[mesh->mNumBones]; + std::copy(mBones.begin(), mBones.end(), mesh->mBones); // default mesh->mMaterialIndex = 0; @@ -254,17 +247,16 @@ aiMesh* SkeletonMeshBuilder::CreateMesh() // ------------------------------------------------------------------------------------------------ // Creates a dummy material and returns it. -aiMaterial* SkeletonMeshBuilder::CreateMaterial() -{ - aiMaterial* matHelper = new aiMaterial; +aiMaterial *SkeletonMeshBuilder::CreateMaterial() { + aiMaterial *matHelper = new aiMaterial; // Name - aiString matName( std::string( "SkeletonMaterial")); - matHelper->AddProperty( &matName, AI_MATKEY_NAME); + aiString matName(std::string("SkeletonMaterial")); + matHelper->AddProperty(&matName, AI_MATKEY_NAME); // Prevent backface culling const int no_cull = 1; - matHelper->AddProperty(&no_cull,1,AI_MATKEY_TWOSIDED); + matHelper->AddProperty(&no_cull, 1, AI_MATKEY_TWOSIDED); return matHelper; } diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index 2bf6ce2e2..3b8a64606 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.cpp @@ -210,20 +210,16 @@ BinFloat ToBinary(const ai_real &pValue) { // See http://en.wikipedia.org/wiki/Signed_number_representations. // Two's complement? - bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000)); - bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000)); - bool SignedMagnitude = ((-42 == (42 | (-0))) && (binValue & 0x80000000)); + const bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000)); + const bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000)); if (DefaultValue) - return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue; + return BinFloat(BinFloat(1) << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue; // One's complement? else if (OneComplement) return BinFloat(-0) - binValue; - // Sign-magnitude? - else if (SignedMagnitude) // -0 = 1000... binary - return binValue; - else - return binValue; + // Sign-magnitude? -0 = 1000... binary + return binValue; } } // namespace diff --git a/code/Common/StandardShapes.cpp b/code/Common/StandardShapes.cpp index d474c6129..b30fa2e25 100644 --- a/code/Common/StandardShapes.cpp +++ b/code/Common/StandardShapes.cpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -48,70 +47,61 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include -#include #include +#include #include -namespace Assimp { +namespace Assimp { - -# define ADD_TRIANGLE(n0,n1,n2) \ - positions.push_back(n0); \ - positions.push_back(n1); \ +#define ADD_TRIANGLE(n0, n1, n2) \ + positions.push_back(n0); \ + positions.push_back(n1); \ positions.push_back(n2); -# define ADD_PENTAGON(n0,n1,n2,n3,n4) \ - if (polygons) \ - { \ +#define ADD_PENTAGON(n0, n1, n2, n3, n4) \ + if (polygons) { \ + positions.push_back(n0); \ + positions.push_back(n1); \ + positions.push_back(n2); \ + positions.push_back(n3); \ + positions.push_back(n4); \ + } else { \ + ADD_TRIANGLE(n0, n1, n2) \ + ADD_TRIANGLE(n0, n2, n3) \ + ADD_TRIANGLE(n0, n3, n4) \ + } + +#define ADD_QUAD(n0, n1, n2, n3) \ + if (polygons) { \ positions.push_back(n0); \ positions.push_back(n1); \ positions.push_back(n2); \ positions.push_back(n3); \ - positions.push_back(n4); \ - } \ - else \ - { \ - ADD_TRIANGLE(n0, n1, n2) \ - ADD_TRIANGLE(n0, n2, n3) \ - ADD_TRIANGLE(n0, n3, n4) \ - } - -# define ADD_QUAD(n0,n1,n2,n3) \ - if (polygons) \ - { \ - positions.push_back(n0); \ - positions.push_back(n1); \ - positions.push_back(n2); \ - positions.push_back(n3); \ - } \ - else \ - { \ + } else { \ ADD_TRIANGLE(n0, n1, n2) \ ADD_TRIANGLE(n0, n2, n3) \ } - // ------------------------------------------------------------------------------------------------ // Fast subdivision for a mesh whose verts have a magnitude of 1 -void Subdivide(std::vector& positions) -{ +void Subdivide(std::vector &positions) { // assume this to be constant - (fixme: must be 1.0? I think so) const ai_real fl1 = positions[0].Length(); unsigned int origSize = (unsigned int)positions.size(); - for (unsigned int i = 0 ; i < origSize ; i+=3) - { - aiVector3D& tv0 = positions[i]; - aiVector3D& tv1 = positions[i+1]; - aiVector3D& tv2 = positions[i+2]; + for (unsigned int i = 0; i < origSize; i += 3) { + aiVector3D &tv0 = positions[i]; + aiVector3D &tv1 = positions[i + 1]; + aiVector3D &tv2 = positions[i + 2]; aiVector3D a = tv0, b = tv1, c = tv2; - aiVector3D v1 = aiVector3D(a.x+b.x, a.y+b.y, a.z+b.z).Normalize()*fl1; - aiVector3D v2 = aiVector3D(a.x+c.x, a.y+c.y, a.z+c.z).Normalize()*fl1; - aiVector3D v3 = aiVector3D(b.x+c.x, b.y+c.y, b.z+c.z).Normalize()*fl1; + aiVector3D v1 = aiVector3D(a.x + b.x, a.y + b.y, a.z + b.z).Normalize() * fl1; + aiVector3D v2 = aiVector3D(a.x + c.x, a.y + c.y, a.z + c.z).Normalize() * fl1; + aiVector3D v3 = aiVector3D(b.x + c.x, b.y + c.y, b.z + c.z).Normalize() * fl1; - tv0 = v1; tv1 = v3; tv2 = v2; // overwrite the original + tv0 = v1; + tv1 = v3; + tv2 = v2; // overwrite the original ADD_TRIANGLE(v1, v2, a); ADD_TRIANGLE(v2, v3, c); ADD_TRIANGLE(v3, v1, b); @@ -120,32 +110,33 @@ void Subdivide(std::vector& positions) // ------------------------------------------------------------------------------------------------ // Construct a mesh from given vertex positions -aiMesh* StandardShapes::MakeMesh(const std::vector& positions, - unsigned int numIndices) -{ - if (positions.empty() || !numIndices) return NULL; +aiMesh *StandardShapes::MakeMesh(const std::vector &positions, + unsigned int numIndices) { + if (positions.empty() || !numIndices) { + return nullptr; + } // Determine which kinds of primitives the mesh consists of - aiMesh* out = new aiMesh(); + aiMesh *out = new aiMesh(); switch (numIndices) { - case 1: - out->mPrimitiveTypes = aiPrimitiveType_POINT; - break; - case 2: - out->mPrimitiveTypes = aiPrimitiveType_LINE; - break; - case 3: - out->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - break; - default: - out->mPrimitiveTypes = aiPrimitiveType_POLYGON; - break; + case 1: + out->mPrimitiveTypes = aiPrimitiveType_POINT; + break; + case 2: + out->mPrimitiveTypes = aiPrimitiveType_LINE; + break; + case 3: + out->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; + break; + default: + out->mPrimitiveTypes = aiPrimitiveType_POLYGON; + break; }; out->mNumFaces = (unsigned int)positions.size() / numIndices; out->mFaces = new aiFace[out->mNumFaces]; - for (unsigned int i = 0, a = 0; i < out->mNumFaces;++i) { - aiFace& f = out->mFaces[i]; + for (unsigned int i = 0, a = 0; i < out->mNumFaces; ++i) { + aiFace &f = out->mFaces[i]; f.mNumIndices = numIndices; f.mIndices = new unsigned int[numIndices]; for (unsigned int j = 0; i < numIndices; ++i, ++a) { @@ -154,113 +145,108 @@ aiMesh* StandardShapes::MakeMesh(const std::vector& positions, } out->mNumVertices = (unsigned int)positions.size(); out->mVertices = new aiVector3D[out->mNumVertices]; - ::memcpy(out->mVertices,&positions[0],out->mNumVertices*sizeof(aiVector3D)); + ::memcpy(out->mVertices, &positions[0], out->mNumVertices * sizeof(aiVector3D)); return out; } // ------------------------------------------------------------------------------------------------ // Construct a mesh with a specific shape (callback) -aiMesh* StandardShapes::MakeMesh ( unsigned int (*GenerateFunc)( - std::vector&)) -{ +aiMesh *StandardShapes::MakeMesh(unsigned int (*GenerateFunc)( + std::vector &)) { std::vector temp; unsigned num = (*GenerateFunc)(temp); - return MakeMesh(temp,num); + return MakeMesh(temp, num); } // ------------------------------------------------------------------------------------------------ // Construct a mesh with a specific shape (callback) -aiMesh* StandardShapes::MakeMesh ( unsigned int (*GenerateFunc)( - std::vector&, bool)) -{ +aiMesh *StandardShapes::MakeMesh(unsigned int (*GenerateFunc)( + std::vector &, bool)) { std::vector temp; - unsigned num = (*GenerateFunc)(temp,true); - return MakeMesh(temp,num); + unsigned num = (*GenerateFunc)(temp, true); + return MakeMesh(temp, num); } // ------------------------------------------------------------------------------------------------ // Construct a mesh with a specific shape (callback) -aiMesh* StandardShapes::MakeMesh (unsigned int num, void (*GenerateFunc)( - unsigned int,std::vector&)) -{ +aiMesh *StandardShapes::MakeMesh(unsigned int num, void (*GenerateFunc)( + unsigned int, std::vector &)) { std::vector temp; - (*GenerateFunc)(num,temp); - return MakeMesh(temp,3); + (*GenerateFunc)(num, temp); + return MakeMesh(temp, 3); } // ------------------------------------------------------------------------------------------------ // Build an incosahedron with points.magnitude == 1 -unsigned int StandardShapes::MakeIcosahedron(std::vector& positions) -{ - positions.reserve(positions.size()+60); +unsigned int StandardShapes::MakeIcosahedron(std::vector &positions) { + positions.reserve(positions.size() + 60); - const ai_real t = ( ai_real( 1.0 )+ ai_real( 2.236067977 ) ) / ai_real( 2.0 ); - const ai_real s = std::sqrt(ai_real(1.0) + t*t); + const ai_real t = (ai_real(1.0) + ai_real(2.236067977)) / ai_real(2.0); + const ai_real s = std::sqrt(ai_real(1.0) + t * t); - const aiVector3D v0 = aiVector3D(t,1.0, 0.0)/s; - const aiVector3D v1 = aiVector3D(-t,1.0, 0.0)/s; - const aiVector3D v2 = aiVector3D(t,-1.0, 0.0)/s; - const aiVector3D v3 = aiVector3D(-t,-1.0, 0.0)/s; - const aiVector3D v4 = aiVector3D(1.0, 0.0, t)/s; - const aiVector3D v5 = aiVector3D(1.0, 0.0,-t)/s; - const aiVector3D v6 = aiVector3D(-1.0, 0.0,t)/s; - const aiVector3D v7 = aiVector3D(-1.0, 0.0,-t)/s; - const aiVector3D v8 = aiVector3D(0.0, t, 1.0)/s; - const aiVector3D v9 = aiVector3D(0.0,-t, 1.0)/s; - const aiVector3D v10 = aiVector3D(0.0, t,-1.0)/s; - const aiVector3D v11 = aiVector3D(0.0,-t,-1.0)/s; + const aiVector3D v0 = aiVector3D(t, 1.0, 0.0) / s; + const aiVector3D v1 = aiVector3D(-t, 1.0, 0.0) / s; + const aiVector3D v2 = aiVector3D(t, -1.0, 0.0) / s; + const aiVector3D v3 = aiVector3D(-t, -1.0, 0.0) / s; + const aiVector3D v4 = aiVector3D(1.0, 0.0, t) / s; + const aiVector3D v5 = aiVector3D(1.0, 0.0, -t) / s; + const aiVector3D v6 = aiVector3D(-1.0, 0.0, t) / s; + const aiVector3D v7 = aiVector3D(-1.0, 0.0, -t) / s; + const aiVector3D v8 = aiVector3D(0.0, t, 1.0) / s; + const aiVector3D v9 = aiVector3D(0.0, -t, 1.0) / s; + const aiVector3D v10 = aiVector3D(0.0, t, -1.0) / s; + const aiVector3D v11 = aiVector3D(0.0, -t, -1.0) / s; - ADD_TRIANGLE(v0,v8,v4); - ADD_TRIANGLE(v0,v5,v10); - ADD_TRIANGLE(v2,v4,v9); - ADD_TRIANGLE(v2,v11,v5); + ADD_TRIANGLE(v0, v8, v4); + ADD_TRIANGLE(v0, v5, v10); + ADD_TRIANGLE(v2, v4, v9); + ADD_TRIANGLE(v2, v11, v5); - ADD_TRIANGLE(v1,v6,v8); - ADD_TRIANGLE(v1,v10,v7); - ADD_TRIANGLE(v3,v9,v6); - ADD_TRIANGLE(v3,v7,v11); + ADD_TRIANGLE(v1, v6, v8); + ADD_TRIANGLE(v1, v10, v7); + ADD_TRIANGLE(v3, v9, v6); + ADD_TRIANGLE(v3, v7, v11); - ADD_TRIANGLE(v0,v10,v8); - ADD_TRIANGLE(v1,v8,v10); - ADD_TRIANGLE(v2,v9,v11); - ADD_TRIANGLE(v3,v11,v9); + ADD_TRIANGLE(v0, v10, v8); + ADD_TRIANGLE(v1, v8, v10); + ADD_TRIANGLE(v2, v9, v11); + ADD_TRIANGLE(v3, v11, v9); - ADD_TRIANGLE(v4,v2,v0); - ADD_TRIANGLE(v5,v0,v2); - ADD_TRIANGLE(v6,v1,v3); - ADD_TRIANGLE(v7,v3,v1); + ADD_TRIANGLE(v4, v2, v0); + ADD_TRIANGLE(v5, v0, v2); + ADD_TRIANGLE(v6, v1, v3); + ADD_TRIANGLE(v7, v3, v1); - ADD_TRIANGLE(v8,v6,v4); - ADD_TRIANGLE(v9,v4,v6); - ADD_TRIANGLE(v10,v5,v7); - ADD_TRIANGLE(v11,v7,v5); + ADD_TRIANGLE(v8, v6, v4); + ADD_TRIANGLE(v9, v4, v6); + ADD_TRIANGLE(v10, v5, v7); + ADD_TRIANGLE(v11, v7, v5); return 3; } // ------------------------------------------------------------------------------------------------ // Build a dodecahedron with points.magnitude == 1 -unsigned int StandardShapes::MakeDodecahedron(std::vector& positions, - bool polygons /*= false*/) -{ - positions.reserve(positions.size()+108); +unsigned int StandardShapes::MakeDodecahedron(std::vector &positions, + bool polygons /*= false*/) { + positions.reserve(positions.size() + 108); - const ai_real a = ai_real( 1.0 ) / ai_real(1.7320508); - const ai_real b = std::sqrt(( ai_real( 3.0 )- ai_real( 2.23606797))/ ai_real( 6.0) ); - const ai_real c = std::sqrt(( ai_real( 3.0 )+ ai_real( 2.23606797f))/ ai_real( 6.0) ); + const ai_real a = ai_real(1.0) / ai_real(1.7320508); + const ai_real b = std::sqrt((ai_real(3.0) - ai_real(2.23606797)) / ai_real(6.0)); + const ai_real c = std::sqrt((ai_real(3.0) + ai_real(2.23606797f)) / ai_real(6.0)); - const aiVector3D v0 = aiVector3D(a,a,a); - const aiVector3D v1 = aiVector3D(a,a,-a); - const aiVector3D v2 = aiVector3D(a,-a,a); - const aiVector3D v3 = aiVector3D(a,-a,-a); - const aiVector3D v4 = aiVector3D(-a,a,a); - const aiVector3D v5 = aiVector3D(-a,a,-a); - const aiVector3D v6 = aiVector3D(-a,-a,a); - const aiVector3D v7 = aiVector3D(-a,-a,-a); - const aiVector3D v8 = aiVector3D(b,c,0.0); - const aiVector3D v9 = aiVector3D(-b,c,0.0); - const aiVector3D v10 = aiVector3D(b,-c,0.0); - const aiVector3D v11 = aiVector3D(-b,-c,0.0); + const aiVector3D v0 = aiVector3D(a, a, a); + const aiVector3D v1 = aiVector3D(a, a, -a); + const aiVector3D v2 = aiVector3D(a, -a, a); + const aiVector3D v3 = aiVector3D(a, -a, -a); + const aiVector3D v4 = aiVector3D(-a, a, a); + const aiVector3D v5 = aiVector3D(-a, a, -a); + const aiVector3D v6 = aiVector3D(-a, -a, a); + const aiVector3D v7 = aiVector3D(-a, -a, -a); + const aiVector3D v8 = aiVector3D(b, c, 0.0); + const aiVector3D v9 = aiVector3D(-b, c, 0.0); + const aiVector3D v10 = aiVector3D(b, -c, 0.0); + const aiVector3D v11 = aiVector3D(-b, -c, 0.0); const aiVector3D v12 = aiVector3D(c, 0.0, b); const aiVector3D v13 = aiVector3D(c, 0.0, -b); const aiVector3D v14 = aiVector3D(-c, 0.0, b); @@ -288,74 +274,71 @@ unsigned int StandardShapes::MakeDodecahedron(std::vector& positions // ------------------------------------------------------------------------------------------------ // Build an octahedron with points.magnitude == 1 -unsigned int StandardShapes::MakeOctahedron(std::vector& positions) -{ - positions.reserve(positions.size()+24); +unsigned int StandardShapes::MakeOctahedron(std::vector &positions) { + positions.reserve(positions.size() + 24); - const aiVector3D v0 = aiVector3D(1.0, 0.0, 0.0) ; - const aiVector3D v1 = aiVector3D(-1.0, 0.0, 0.0); - const aiVector3D v2 = aiVector3D(0.0, 1.0, 0.0); - const aiVector3D v3 = aiVector3D(0.0, -1.0, 0.0); - const aiVector3D v4 = aiVector3D(0.0, 0.0, 1.0); - const aiVector3D v5 = aiVector3D(0.0, 0.0, -1.0); + const aiVector3D v0 = aiVector3D(1.0, 0.0, 0.0); + const aiVector3D v1 = aiVector3D(-1.0, 0.0, 0.0); + const aiVector3D v2 = aiVector3D(0.0, 1.0, 0.0); + const aiVector3D v3 = aiVector3D(0.0, -1.0, 0.0); + const aiVector3D v4 = aiVector3D(0.0, 0.0, 1.0); + const aiVector3D v5 = aiVector3D(0.0, 0.0, -1.0); - ADD_TRIANGLE(v4,v0,v2); - ADD_TRIANGLE(v4,v2,v1); - ADD_TRIANGLE(v4,v1,v3); - ADD_TRIANGLE(v4,v3,v0); + ADD_TRIANGLE(v4, v0, v2); + ADD_TRIANGLE(v4, v2, v1); + ADD_TRIANGLE(v4, v1, v3); + ADD_TRIANGLE(v4, v3, v0); - ADD_TRIANGLE(v5,v2,v0); - ADD_TRIANGLE(v5,v1,v2); - ADD_TRIANGLE(v5,v3,v1); - ADD_TRIANGLE(v5,v0,v3); + ADD_TRIANGLE(v5, v2, v0); + ADD_TRIANGLE(v5, v1, v2); + ADD_TRIANGLE(v5, v3, v1); + ADD_TRIANGLE(v5, v0, v3); return 3; } // ------------------------------------------------------------------------------------------------ // Build a tetrahedron with points.magnitude == 1 -unsigned int StandardShapes::MakeTetrahedron(std::vector& positions) -{ - positions.reserve(positions.size()+9); +unsigned int StandardShapes::MakeTetrahedron(std::vector &positions) { + positions.reserve(positions.size() + 9); - const ai_real invThree = ai_real( 1.0 ) / ai_real( 3.0 ); - const ai_real a = ai_real( 1.41421 ) * invThree; - const ai_real b = ai_real( 2.4494 ) * invThree; + const ai_real invThree = ai_real(1.0) / ai_real(3.0); + const ai_real a = ai_real(1.41421) * invThree; + const ai_real b = ai_real(2.4494) * invThree; - const aiVector3D v0 = aiVector3D(0.0,0.0,1.0); - const aiVector3D v1 = aiVector3D(2*a,0,-invThree ); - const aiVector3D v2 = aiVector3D(-a,b,-invThree ); - const aiVector3D v3 = aiVector3D(-a,-b,-invThree ); + const aiVector3D v0 = aiVector3D(0.0, 0.0, 1.0); + const aiVector3D v1 = aiVector3D(2 * a, 0, -invThree); + const aiVector3D v2 = aiVector3D(-a, b, -invThree); + const aiVector3D v3 = aiVector3D(-a, -b, -invThree); - ADD_TRIANGLE(v0,v1,v2); - ADD_TRIANGLE(v0,v2,v3); - ADD_TRIANGLE(v0,v3,v1); - ADD_TRIANGLE(v1,v3,v2); + ADD_TRIANGLE(v0, v1, v2); + ADD_TRIANGLE(v0, v2, v3); + ADD_TRIANGLE(v0, v3, v1); + ADD_TRIANGLE(v1, v3, v2); return 3; } // ------------------------------------------------------------------------------------------------ // Build a hexahedron with points.magnitude == 1 -unsigned int StandardShapes::MakeHexahedron(std::vector& positions, - bool polygons /*= false*/) -{ - positions.reserve(positions.size()+36); - const ai_real length = ai_real(1.0)/ai_real(1.73205080); +unsigned int StandardShapes::MakeHexahedron(std::vector &positions, + bool polygons /*= false*/) { + positions.reserve(positions.size() + 36); + const ai_real length = ai_real(1.0) / ai_real(1.73205080); - const aiVector3D v0 = aiVector3D(-1.0,-1.0,-1.0)*length; - const aiVector3D v1 = aiVector3D(1.0,-1.0,-1.0)*length; - const aiVector3D v2 = aiVector3D(1.0,1.0,-1.0)*length; - const aiVector3D v3 = aiVector3D(-1.0,1.0,-1.0)*length; - const aiVector3D v4 = aiVector3D(-1.0,-1.0,1.0)*length; - const aiVector3D v5 = aiVector3D(1.0,-1.0,1.0)*length; - const aiVector3D v6 = aiVector3D(1.0,1.0,1.0)*length; - const aiVector3D v7 = aiVector3D(-1.0,1.0,1.0)*length; + const aiVector3D v0 = aiVector3D(-1.0, -1.0, -1.0) * length; + const aiVector3D v1 = aiVector3D(1.0, -1.0, -1.0) * length; + const aiVector3D v2 = aiVector3D(1.0, 1.0, -1.0) * length; + const aiVector3D v3 = aiVector3D(-1.0, 1.0, -1.0) * length; + const aiVector3D v4 = aiVector3D(-1.0, -1.0, 1.0) * length; + const aiVector3D v5 = aiVector3D(1.0, -1.0, 1.0) * length; + const aiVector3D v6 = aiVector3D(1.0, 1.0, 1.0) * length; + const aiVector3D v7 = aiVector3D(-1.0, 1.0, 1.0) * length; - ADD_QUAD(v0,v3,v2,v1); - ADD_QUAD(v0,v1,v5,v4); - ADD_QUAD(v0,v4,v7,v3); - ADD_QUAD(v6,v5,v1,v2); - ADD_QUAD(v6,v2,v3,v7); - ADD_QUAD(v6,v7,v4,v5); + ADD_QUAD(v0, v3, v2, v1); + ADD_QUAD(v0, v1, v5, v4); + ADD_QUAD(v0, v4, v7, v3); + ADD_QUAD(v6, v5, v1, v2); + ADD_QUAD(v6, v2, v3, v7); + ADD_QUAD(v6, v7, v4, v5); return (polygons ? 4 : 3); } @@ -366,28 +349,26 @@ unsigned int StandardShapes::MakeHexahedron(std::vector& positions, // ------------------------------------------------------------------------------------------------ // Create a subdivision sphere -void StandardShapes::MakeSphere(unsigned int tess, - std::vector& positions) -{ +void StandardShapes::MakeSphere(unsigned int tess, + std::vector &positions) { // Reserve enough storage. Every subdivision // splits each triangle in 4, the icosahedron consists of 60 verts - positions.reserve(positions.size()+60 * integer_pow(4, tess)); + positions.reserve(positions.size() + 60 * integer_pow(4, tess)); // Construct an icosahedron to start with MakeIcosahedron(positions); // ... and subdivide it until the requested output // tessellation is reached - for (unsigned int i = 0; i& positions,bool bOpen /*= false */) -{ +void StandardShapes::MakeCone(ai_real height, ai_real radius1, + ai_real radius2, unsigned int tess, + std::vector &positions, bool bOpen /*= false */) { // Sorry, a cone with less than 3 segments makes ABSOLUTELY NO SENSE if (tess < 3 || !height) return; @@ -401,39 +382,37 @@ void StandardShapes::MakeCone(ai_real height,ai_real radius1, ai_real halfHeight = height / ai_real(2.0); // radius1 is always the smaller one - if (radius2 > radius1) - { - std::swap(radius2,radius1); + if (radius2 > radius1) { + std::swap(radius2, radius1); halfHeight = -halfHeight; - } - else old = SIZE_MAX; + } else + old = SIZE_MAX; // Use a large epsilon to check whether the cone is pointy - if (radius1 < (radius2-radius1)*10e-3)radius1 = 0.0; + if (radius1 < (radius2 - radius1) * 10e-3) radius1 = 0.0; // We will need 3*2 verts per segment + 3*2 verts per segment // if the cone is closed - const unsigned int mem = tess*6 + (!bOpen ? tess*3 * (radius1 ? 2 : 1) : 0); - positions.reserve(positions.size () + mem); + const unsigned int mem = tess * 6 + (!bOpen ? tess * 3 * (radius1 ? 2 : 1) : 0); + positions.reserve(positions.size() + mem); // Now construct all segments const ai_real angle_delta = (ai_real)AI_MATH_TWO_PI / tess; - const ai_real angle_max = (ai_real)AI_MATH_TWO_PI; + const ai_real angle_max = (ai_real)AI_MATH_TWO_PI; ai_real s = 1.0; // std::cos(angle == 0); ai_real t = 0.0; // std::sin(angle == 0); - for (ai_real angle = 0.0; angle < angle_max; ) - { - const aiVector3D v1 = aiVector3D (s * radius1, -halfHeight, t * radius1 ); - const aiVector3D v2 = aiVector3D (s * radius2, halfHeight, t * radius2 ); + for (ai_real angle = 0.0; angle < angle_max;) { + const aiVector3D v1 = aiVector3D(s * radius1, -halfHeight, t * radius1); + const aiVector3D v2 = aiVector3D(s * radius2, halfHeight, t * radius2); const ai_real next = angle + angle_delta; ai_real s2 = std::cos(next); ai_real t2 = std::sin(next); - const aiVector3D v3 = aiVector3D (s2 * radius2, halfHeight, t2 * radius2 ); - const aiVector3D v4 = aiVector3D (s2 * radius1, -halfHeight, t2 * radius1 ); + const aiVector3D v3 = aiVector3D(s2 * radius2, halfHeight, t2 * radius2); + const aiVector3D v4 = aiVector3D(s2 * radius1, -halfHeight, t2 * radius1); positions.push_back(v1); positions.push_back(v2); @@ -442,21 +421,17 @@ void StandardShapes::MakeCone(ai_real height,ai_real radius1, positions.push_back(v1); positions.push_back(v3); - if (!bOpen) - { + if (!bOpen) { // generate the end 'cap' - positions.push_back(aiVector3D(s * radius2, halfHeight, t * radius2 )); - positions.push_back(aiVector3D(s2 * radius2, halfHeight, t2 * radius2 )); + positions.push_back(aiVector3D(s * radius2, halfHeight, t * radius2)); + positions.push_back(aiVector3D(s2 * radius2, halfHeight, t2 * radius2)); positions.push_back(aiVector3D(0.0, halfHeight, 0.0)); - - if (radius1) - { + if (radius1) { // generate the other end 'cap' - positions.push_back(aiVector3D(s * radius1, -halfHeight, t * radius1 )); - positions.push_back(aiVector3D(s2 * radius1, -halfHeight, t2 * radius1 )); + positions.push_back(aiVector3D(s * radius1, -halfHeight, t * radius1)); + positions.push_back(aiVector3D(s2 * radius1, -halfHeight, t2 * radius1)); positions.push_back(aiVector3D(0.0, -halfHeight, 0.0)); - } } s = s2; @@ -465,9 +440,9 @@ void StandardShapes::MakeCone(ai_real height,ai_real radius1, } // Need to flip face order? - if ( SIZE_MAX != old ) { - for (size_t p = old; p < positions.size();p += 3) { - std::swap(positions[p],positions[p+1]); + if (SIZE_MAX != old) { + for (size_t p = old; p < positions.size(); p += 3) { + std::swap(positions[p], positions[p + 1]); } } } @@ -475,8 +450,7 @@ void StandardShapes::MakeCone(ai_real height,ai_real radius1, // ------------------------------------------------------------------------------------------------ // Build a circle void StandardShapes::MakeCircle(ai_real radius, unsigned int tess, - std::vector& positions) -{ + std::vector &positions) { // Sorry, a circle with less than 3 segments makes ABSOLUTELY NO SENSE if (tess < 3 || !radius) return; @@ -484,24 +458,23 @@ void StandardShapes::MakeCircle(ai_real radius, unsigned int tess, radius = std::fabs(radius); // We will need 3 vertices per segment - positions.reserve(positions.size()+tess*3); + positions.reserve(positions.size() + tess * 3); const ai_real angle_delta = (ai_real)AI_MATH_TWO_PI / tess; - const ai_real angle_max = (ai_real)AI_MATH_TWO_PI; + const ai_real angle_max = (ai_real)AI_MATH_TWO_PI; ai_real s = 1.0; // std::cos(angle == 0); ai_real t = 0.0; // std::sin(angle == 0); - for (ai_real angle = 0.0; angle < angle_max; ) - { - positions.push_back(aiVector3D(s * radius,0.0,t * radius)); + for (ai_real angle = 0.0; angle < angle_max;) { + positions.push_back(aiVector3D(s * radius, 0.0, t * radius)); angle += angle_delta; s = std::cos(angle); t = std::sin(angle); - positions.push_back(aiVector3D(s * radius,0.0,t * radius)); + positions.push_back(aiVector3D(s * radius, 0.0, t * radius)); - positions.push_back(aiVector3D(0.0,0.0,0.0)); + positions.push_back(aiVector3D(0.0, 0.0, 0.0)); } } -} // ! Assimp +} // namespace Assimp diff --git a/code/Common/Subdivision.cpp b/code/Common/Subdivision.cpp index 2b376695e..b1f07c9f5 100644 --- a/code/Common/Subdivision.cpp +++ b/code/Common/Subdivision.cpp @@ -54,7 +54,7 @@ using namespace Assimp; void mydummy() {} #ifdef _WIN32 -# pragma warning( disable : 4709 ) +#pragma warning(disable : 4709) #endif // _WIN32 // ------------------------------------------------------------------------------------------------ /** Subdivider stub class to implement the Catmull-Clarke subdivision algorithm. The @@ -63,24 +63,22 @@ void mydummy() {} // ------------------------------------------------------------------------------------------------ class CatmullClarkSubdivider : public Subdivider { public: - void Subdivide (aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input); - void Subdivide (aiMesh** smesh, size_t nmesh, - aiMesh** out, unsigned int num, bool discard_input); + void Subdivide(aiMesh *mesh, aiMesh *&out, unsigned int num, bool discard_input); + void Subdivide(aiMesh **smesh, size_t nmesh, + aiMesh **out, unsigned int num, bool discard_input); // --------------------------------------------------------------------------- /** Intermediate description of an edge between two corners of a polygon*/ // --------------------------------------------------------------------------- - struct Edge - { - Edge() - : ref(0) - {} + struct Edge { + Edge() : + ref(0) {} Vertex edge_point, midpoint; unsigned int ref; }; typedef std::vector UIntVector; - typedef std::map EdgeMap; + typedef std::map EdgeMap; // --------------------------------------------------------------------------- // Hashing function to derive an index into an #EdgeMap from two given @@ -94,80 +92,72 @@ public: // invariant id0out+nmesh); + ai_assert(smesh < out || smesh + nmesh > out + nmesh); if (!num) { // No subdivision at all. Need to copy all the meshes .. argh. if (discard_input) { for (size_t s = 0; s < nmesh; ++s) { out[s] = smesh[s]; - smesh[s] = NULL; + smesh[s] = nullptr; } - } - else { + } else { for (size_t s = 0; s < nmesh; ++s) { - SceneCombiner::Copy(out+s,smesh[s]); + SceneCombiner::Copy(out + s, smesh[s]); } } return; } - std::vector inmeshes; - std::vector outmeshes; + std::vector inmeshes; + std::vector outmeshes; std::vector maptbl; inmeshes.reserve(nmesh); @@ -178,34 +168,35 @@ void CatmullClarkSubdivider::Subdivide ( // number of edge cases the subdivider is forced to deal with. Line and // point meshes are simply passed through. for (size_t s = 0; s < nmesh; ++s) { - aiMesh* i = smesh[s]; + aiMesh *i = smesh[s]; // FIX - mPrimitiveTypes might not yet be initialized - if (i->mPrimitiveTypes && (i->mPrimitiveTypes & (aiPrimitiveType_LINE|aiPrimitiveType_POINT))==i->mPrimitiveTypes) { - ASSIMP_LOG_DEBUG("Catmull-Clark Subdivider: Skipping pure line/point mesh"); + if (i->mPrimitiveTypes && (i->mPrimitiveTypes & (aiPrimitiveType_LINE | aiPrimitiveType_POINT)) == i->mPrimitiveTypes) { + ASSIMP_LOG_VERBOSE_DEBUG("Catmull-Clark Subdivider: Skipping pure line/point mesh"); if (discard_input) { out[s] = i; - smesh[s] = NULL; - } - else { - SceneCombiner::Copy(out+s,i); + smesh[s] = nullptr; + } else { + SceneCombiner::Copy(out + s, i); } continue; } - outmeshes.push_back(NULL);inmeshes.push_back(i); + outmeshes.push_back(nullptr); + inmeshes.push_back(i); maptbl.push_back(static_cast(s)); } // Do the actual subdivision on the preallocated storage. InternSubdivide // *always* assumes that enough storage is available, it does not bother // checking any ranges. - ai_assert(inmeshes.size()==outmeshes.size()&&inmeshes.size()==maptbl.size()); + ai_assert(inmeshes.size() == outmeshes.size()); + ai_assert(inmeshes.size() == maptbl.size()); if (inmeshes.empty()) { ASSIMP_LOG_WARN("Catmull-Clark Subdivider: Pure point/line scene, I can't do anything"); return; } - InternSubdivide(&inmeshes.front(),inmeshes.size(),&outmeshes.front(),num); + InternSubdivide(&inmeshes.front(), inmeshes.size(), &outmeshes.front(), num); for (unsigned int i = 0; i < maptbl.size(); ++i) { ai_assert(nullptr != outmeshes[i]); out[maptbl[i]] = outmeshes[i]; @@ -229,14 +220,14 @@ void CatmullClarkSubdivider::Subdivide ( // in-place unless 'smesh' and 'out' are equal (no strange overlaps or reorderings). // Previous data is replaced/deleted then. // ------------------------------------------------------------------------------------------------ -void CatmullClarkSubdivider::InternSubdivide ( - const aiMesh* const * smesh, - size_t nmesh, - aiMesh** out, - unsigned int num - ) -{ - ai_assert(NULL != smesh && NULL != out); +void CatmullClarkSubdivider::InternSubdivide( + const aiMesh *const *smesh, + size_t nmesh, + aiMesh **out, + unsigned int num) { + ai_assert(nullptr != smesh); + ai_assert(nullptr != out); + INIT_EDGE_HASH_TEMPORARIES(); // no subdivision requested or end of recursive refinement @@ -251,25 +242,24 @@ void CatmullClarkSubdivider::InternSubdivide ( // 0. Offset table to index all meshes continuously, generate a spatially // sorted representation of all vertices in all meshes. // --------------------------------------------------------------------- - typedef std::pair IntPair; + typedef std::pair IntPair; std::vector moffsets(nmesh); unsigned int totfaces = 0, totvert = 0; for (size_t t = 0; t < nmesh; ++t) { - const aiMesh* mesh = smesh[t]; + const aiMesh *mesh = smesh[t]; - spatial.Append(mesh->mVertices,mesh->mNumVertices,sizeof(aiVector3D),false); - moffsets[t] = IntPair(totfaces,totvert); + spatial.Append(mesh->mVertices, mesh->mNumVertices, sizeof(aiVector3D), false); + moffsets[t] = IntPair(totfaces, totvert); totfaces += mesh->mNumFaces; - totvert += mesh->mNumVertices; + totvert += mesh->mNumVertices; } spatial.Finalize(); - const unsigned int num_unique = spatial.GenerateMappingTable(maptbl,ComputePositionEpsilon(smesh,nmesh)); + const unsigned int num_unique = spatial.GenerateMappingTable(maptbl, ComputePositionEpsilon(smesh, nmesh)); - -#define FLATTEN_VERTEX_IDX(mesh_idx, vert_idx) (moffsets[mesh_idx].second+vert_idx) -#define FLATTEN_FACE_IDX(mesh_idx, face_idx) (moffsets[mesh_idx].first+face_idx) +#define FLATTEN_VERTEX_IDX(mesh_idx, vert_idx) (moffsets[mesh_idx].second + vert_idx) +#define FLATTEN_FACE_IDX(mesh_idx, face_idx) (moffsets[mesh_idx].first + face_idx) // --------------------------------------------------------------------- // 1. Compute the centroid point for all faces @@ -277,14 +267,13 @@ void CatmullClarkSubdivider::InternSubdivide ( std::vector centroids(totfaces); unsigned int nfacesout = 0; for (size_t t = 0, n = 0; t < nmesh; ++t) { - const aiMesh* mesh = smesh[t]; - for (unsigned int i = 0; i < mesh->mNumFaces;++i,++n) - { - const aiFace& face = mesh->mFaces[i]; - Vertex& c = centroids[n]; + const aiMesh *mesh = smesh[t]; + for (unsigned int i = 0; i < mesh->mNumFaces; ++i, ++n) { + const aiFace &face = mesh->mFaces[i]; + Vertex &c = centroids[n]; - for (unsigned int a = 0; a < face.mNumIndices;++a) { - c += Vertex(mesh,face.mIndices[a]); + for (unsigned int a = 0; a < face.mNumIndices; ++a) { + c += Vertex(mesh, face.mIndices[a]); } c /= static_cast(face.mNumIndices); @@ -293,297 +282,297 @@ void CatmullClarkSubdivider::InternSubdivide ( } { - // we want edges to go away before the recursive calls so begin a new scope - EdgeMap edges; + // we want edges to go away before the recursive calls so begin a new scope + EdgeMap edges; - // --------------------------------------------------------------------- - // 2. Set each edge point to be the average of all neighbouring - // face points and original points. Every edge exists twice - // if there is a neighboring face. - // --------------------------------------------------------------------- - for (size_t t = 0; t < nmesh; ++t) { - const aiMesh* mesh = smesh[t]; + // --------------------------------------------------------------------- + // 2. Set each edge point to be the average of all neighbouring + // face points and original points. Every edge exists twice + // if there is a neighboring face. + // --------------------------------------------------------------------- + for (size_t t = 0; t < nmesh; ++t) { + const aiMesh *mesh = smesh[t]; - for (unsigned int i = 0; i < mesh->mNumFaces;++i) { - const aiFace& face = mesh->mFaces[i]; + for (unsigned int i = 0; i < mesh->mNumFaces; ++i) { + const aiFace &face = mesh->mFaces[i]; - for (unsigned int p =0; p< face.mNumIndices; ++p) { - const unsigned int id[] = { - face.mIndices[p], - face.mIndices[p==face.mNumIndices-1?0:p+1] - }; - const unsigned int mp[] = { - maptbl[FLATTEN_VERTEX_IDX(t,id[0])], - maptbl[FLATTEN_VERTEX_IDX(t,id[1])] - }; + for (unsigned int p = 0; p < face.mNumIndices; ++p) { + const unsigned int id[] = { + face.mIndices[p], + face.mIndices[p == face.mNumIndices - 1 ? 0 : p + 1] + }; + const unsigned int mp[] = { + maptbl[FLATTEN_VERTEX_IDX(t, id[0])], + maptbl[FLATTEN_VERTEX_IDX(t, id[1])] + }; - Edge& e = edges[MAKE_EDGE_HASH(mp[0],mp[1])]; - e.ref++; - if (e.ref<=2) { - if (e.ref==1) { // original points (end points) - add only once - e.edge_point = e.midpoint = Vertex(mesh,id[0])+Vertex(mesh,id[1]); - e.midpoint *= 0.5f; + Edge &e = edges[MAKE_EDGE_HASH(mp[0], mp[1])]; + e.ref++; + if (e.ref <= 2) { + if (e.ref == 1) { // original points (end points) - add only once + e.edge_point = e.midpoint = Vertex(mesh, id[0]) + Vertex(mesh, id[1]); + e.midpoint *= 0.5f; + } + e.edge_point += centroids[FLATTEN_FACE_IDX(t, i)]; } - e.edge_point += centroids[FLATTEN_FACE_IDX(t,i)]; } } } - } - // --------------------------------------------------------------------- - // 3. Normalize edge points - // --------------------------------------------------------------------- - {unsigned int bad_cnt = 0; - for (EdgeMap::iterator it = edges.begin(); it != edges.end(); ++it) { - if ((*it).second.ref < 2) { - ai_assert((*it).second.ref); - ++bad_cnt; - } - (*it).second.edge_point *= 1.f/((*it).second.ref+2.f); - } + // --------------------------------------------------------------------- + // 3. Normalize edge points + // --------------------------------------------------------------------- + { + unsigned int bad_cnt = 0; + for (EdgeMap::iterator it = edges.begin(); it != edges.end(); ++it) { + if ((*it).second.ref < 2) { + ai_assert((*it).second.ref); + ++bad_cnt; + } + (*it).second.edge_point *= 1.f / ((*it).second.ref + 2.f); + } - if (bad_cnt) { - // Report the number of bad edges. bad edges are referenced by less than two - // faces in the mesh. They occur at outer model boundaries in non-closed - // shapes. - ASSIMP_LOG_DEBUG_F("Catmull-Clark Subdivider: got ", bad_cnt, " bad edges touching only one face (totally ", - static_cast(edges.size()), " edges). "); - }} - - // --------------------------------------------------------------------- - // 4. Compute a vertex-face adjacency table. We can't reuse the code - // from VertexTriangleAdjacency because we need the table for multiple - // meshes and out vertex indices need to be mapped to distinct values - // first. - // --------------------------------------------------------------------- - UIntVector faceadjac(nfacesout), cntadjfac(maptbl.size(),0), ofsadjvec(maptbl.size()+1,0); { - for (size_t t = 0; t < nmesh; ++t) { - const aiMesh* const minp = smesh[t]; - for (unsigned int i = 0; i < minp->mNumFaces; ++i) { - - const aiFace& f = minp->mFaces[i]; - for (unsigned int n = 0; n < f.mNumIndices; ++n) { - ++cntadjfac[maptbl[FLATTEN_VERTEX_IDX(t,f.mIndices[n])]]; + if (bad_cnt) { + // Report the number of bad edges. bad edges are referenced by less than two + // faces in the mesh. They occur at outer model boundaries in non-closed + // shapes. + ASSIMP_LOG_VERBOSE_DEBUG_F("Catmull-Clark Subdivider: got ", bad_cnt, " bad edges touching only one face (totally ", + static_cast(edges.size()), " edges). "); } } - } - unsigned int cur = 0; - for (size_t i = 0; i < cntadjfac.size(); ++i) { - ofsadjvec[i+1] = cur; - cur += cntadjfac[i]; - } - for (size_t t = 0; t < nmesh; ++t) { - const aiMesh* const minp = smesh[t]; - for (unsigned int i = 0; i < minp->mNumFaces; ++i) { - const aiFace& f = minp->mFaces[i]; - for (unsigned int n = 0; n < f.mNumIndices; ++n) { - faceadjac[ofsadjvec[1+maptbl[FLATTEN_VERTEX_IDX(t,f.mIndices[n])]]++] = FLATTEN_FACE_IDX(t,i); + // --------------------------------------------------------------------- + // 4. Compute a vertex-face adjacency table. We can't reuse the code + // from VertexTriangleAdjacency because we need the table for multiple + // meshes and out vertex indices need to be mapped to distinct values + // first. + // --------------------------------------------------------------------- + UIntVector faceadjac(nfacesout), cntadjfac(maptbl.size(), 0), ofsadjvec(maptbl.size() + 1, 0); + { + for (size_t t = 0; t < nmesh; ++t) { + const aiMesh *const minp = smesh[t]; + for (unsigned int i = 0; i < minp->mNumFaces; ++i) { + + const aiFace &f = minp->mFaces[i]; + for (unsigned int n = 0; n < f.mNumIndices; ++n) { + ++cntadjfac[maptbl[FLATTEN_VERTEX_IDX(t, f.mIndices[n])]]; + } + } } - } - } + unsigned int cur = 0; + for (size_t i = 0; i < cntadjfac.size(); ++i) { + ofsadjvec[i + 1] = cur; + cur += cntadjfac[i]; + } + for (size_t t = 0; t < nmesh; ++t) { + const aiMesh *const minp = smesh[t]; + for (unsigned int i = 0; i < minp->mNumFaces; ++i) { - // check the other way round for consistency + const aiFace &f = minp->mFaces[i]; + for (unsigned int n = 0; n < f.mNumIndices; ++n) { + faceadjac[ofsadjvec[1 + maptbl[FLATTEN_VERTEX_IDX(t, f.mIndices[n])]]++] = FLATTEN_FACE_IDX(t, i); + } + } + } + + // check the other way round for consistency #ifdef ASSIMP_BUILD_DEBUG - for (size_t t = 0; t < ofsadjvec.size()-1; ++t) { - for (unsigned int m = 0; m < cntadjfac[t]; ++m) { - const unsigned int fidx = faceadjac[ofsadjvec[t]+m]; - ai_assert(fidx < totfaces); - for (size_t n = 1; n < nmesh; ++n) { + for (size_t t = 0; t < ofsadjvec.size() - 1; ++t) { + for (unsigned int m = 0; m < cntadjfac[t]; ++m) { + const unsigned int fidx = faceadjac[ofsadjvec[t] + m]; + ai_assert(fidx < totfaces); + for (size_t n = 1; n < nmesh; ++n) { - if (moffsets[n].first > fidx) { - const aiMesh* msh = smesh[--n]; - const aiFace& f = msh->mFaces[fidx-moffsets[n].first]; + if (moffsets[n].first > fidx) { + const aiMesh *msh = smesh[--n]; + const aiFace &f = msh->mFaces[fidx - moffsets[n].first]; - bool haveit = false; - for (unsigned int i = 0; i < f.mNumIndices; ++i) { - if (maptbl[FLATTEN_VERTEX_IDX(n,f.mIndices[i])]==(unsigned int)t) { - haveit = true; - break; - } - } - ai_assert(haveit); - if (!haveit) { - ASSIMP_LOG_DEBUG("Catmull-Clark Subdivider: Index not used"); - } - break; - } - } - } - } - -#endif - } - -#define GET_ADJACENT_FACES_AND_CNT(vidx,fstartout,numout) \ - fstartout = &faceadjac[ofsadjvec[vidx]], numout = cntadjfac[vidx] - - typedef std::pair TouchedOVertex; - std::vector new_points(num_unique,TouchedOVertex(false,Vertex())); - // --------------------------------------------------------------------- - // 5. Spawn a quad from each face point to the corresponding edge points - // the original points being the fourth quad points. - // --------------------------------------------------------------------- - for (size_t t = 0; t < nmesh; ++t) { - const aiMesh* const minp = smesh[t]; - aiMesh* const mout = out[t] = new aiMesh(); - - for (unsigned int a = 0; a < minp->mNumFaces; ++a) { - mout->mNumFaces += minp->mFaces[a].mNumIndices; - } - - // We need random access to the old face buffer, so reuse is not possible. - mout->mFaces = new aiFace[mout->mNumFaces]; - - mout->mNumVertices = mout->mNumFaces*4; - mout->mVertices = new aiVector3D[mout->mNumVertices]; - - // quads only, keep material index - mout->mPrimitiveTypes = aiPrimitiveType_POLYGON; - mout->mMaterialIndex = minp->mMaterialIndex; - - if (minp->HasNormals()) { - mout->mNormals = new aiVector3D[mout->mNumVertices]; - } - - if (minp->HasTangentsAndBitangents()) { - mout->mTangents = new aiVector3D[mout->mNumVertices]; - mout->mBitangents = new aiVector3D[mout->mNumVertices]; - } - - for(unsigned int i = 0; minp->HasTextureCoords(i); ++i) { - mout->mTextureCoords[i] = new aiVector3D[mout->mNumVertices]; - mout->mNumUVComponents[i] = minp->mNumUVComponents[i]; - } - - for(unsigned int i = 0; minp->HasVertexColors(i); ++i) { - mout->mColors[i] = new aiColor4D[mout->mNumVertices]; - } - - mout->mNumVertices = mout->mNumFaces<<2u; - for (unsigned int i = 0, v = 0, n = 0; i < minp->mNumFaces;++i) { - - const aiFace& face = minp->mFaces[i]; - for (unsigned int a = 0; a < face.mNumIndices;++a) { - - // Get a clean new face. - aiFace& faceOut = mout->mFaces[n++]; - faceOut.mIndices = new unsigned int [faceOut.mNumIndices = 4]; - - // Spawn a new quadrilateral (ccw winding) for this original point between: - // a) face centroid - centroids[FLATTEN_FACE_IDX(t,i)].SortBack(mout,faceOut.mIndices[0]=v++); - - // b) adjacent edge on the left, seen from the centroid - const Edge& e0 = edges[MAKE_EDGE_HASH(maptbl[FLATTEN_VERTEX_IDX(t,face.mIndices[a])], - maptbl[FLATTEN_VERTEX_IDX(t,face.mIndices[a==face.mNumIndices-1?0:a+1]) - ])]; // fixme: replace with mod face.mNumIndices? - - // c) adjacent edge on the right, seen from the centroid - const Edge& e1 = edges[MAKE_EDGE_HASH(maptbl[FLATTEN_VERTEX_IDX(t,face.mIndices[a])], - maptbl[FLATTEN_VERTEX_IDX(t,face.mIndices[!a?face.mNumIndices-1:a-1]) - ])]; // fixme: replace with mod face.mNumIndices? - - e0.edge_point.SortBack(mout,faceOut.mIndices[3]=v++); - e1.edge_point.SortBack(mout,faceOut.mIndices[1]=v++); - - // d= original point P with distinct index i - // F := 0 - // R := 0 - // n := 0 - // for each face f containing i - // F := F+ centroid of f - // R := R+ midpoint of edge of f from i to i+1 - // n := n+1 - // - // (F+2R+(n-3)P)/n - const unsigned int org = maptbl[FLATTEN_VERTEX_IDX(t,face.mIndices[a])]; - TouchedOVertex& ov = new_points[org]; - - if (!ov.first) { - ov.first = true; - - const unsigned int* adj; unsigned int cnt; - GET_ADJACENT_FACES_AND_CNT(org,adj,cnt); - - if (cnt < 3) { - ov.second = Vertex(minp,face.mIndices[a]); - } - else { - - Vertex F,R; - for (unsigned int o = 0; o < cnt; ++o) { - ai_assert(adj[o] < totfaces); - F += centroids[adj[o]]; - - // adj[0] is a global face index - search the face in the mesh list - const aiMesh* mp = NULL; - size_t nidx; - - if (adj[o] < moffsets[0].first) { - mp = smesh[nidx=0]; - } - else { - for (nidx = 1; nidx<= nmesh; ++nidx) { - if (nidx == nmesh ||moffsets[nidx].first > adj[o]) { - mp = smesh[--nidx]; - break; - } - } - } - - ai_assert(adj[o]-moffsets[nidx].first < mp->mNumFaces); - const aiFace& f = mp->mFaces[adj[o]-moffsets[nidx].first]; bool haveit = false; - - // find our original point in the face - for (unsigned int m = 0; m < f.mNumIndices; ++m) { - if (maptbl[FLATTEN_VERTEX_IDX(nidx,f.mIndices[m])] == org) { - - // add *both* edges. this way, we can be sure that we add - // *all* adjacent edges to R. In a closed shape, every - // edge is added twice - so we simply leave out the - // factor 2.f in the amove formula and get the right - // result. - - const Edge& c0 = edges[MAKE_EDGE_HASH(org,maptbl[FLATTEN_VERTEX_IDX( - nidx,f.mIndices[!m?f.mNumIndices-1:m-1])])]; - // fixme: replace with mod face.mNumIndices? - - const Edge& c1 = edges[MAKE_EDGE_HASH(org,maptbl[FLATTEN_VERTEX_IDX( - nidx,f.mIndices[m==f.mNumIndices-1?0:m+1])])]; - // fixme: replace with mod face.mNumIndices? - R += c0.midpoint+c1.midpoint; - + for (unsigned int i = 0; i < f.mNumIndices; ++i) { + if (maptbl[FLATTEN_VERTEX_IDX(n, f.mIndices[i])] == (unsigned int)t) { haveit = true; break; } } - - // this invariant *must* hold if the vertex-to-face adjacency table is valid ai_assert(haveit); - if ( !haveit ) { - ASSIMP_LOG_WARN( "OBJ: no name for material library specified." ); + if (!haveit) { + ASSIMP_LOG_VERBOSE_DEBUG("Catmull-Clark Subdivider: Index not used"); } + break; } - - const float div = static_cast(cnt), divsq = 1.f/(div*div); - ov.second = Vertex(minp,face.mIndices[a])*((div-3.f) / div) + R*divsq + F*divsq; } } - ov.second.SortBack(mout,faceOut.mIndices[2]=v++); + } + +#endif + } + +#define GET_ADJACENT_FACES_AND_CNT(vidx, fstartout, numout) \ + fstartout = &faceadjac[ofsadjvec[vidx]], numout = cntadjfac[vidx] + + typedef std::pair TouchedOVertex; + std::vector new_points(num_unique, TouchedOVertex(false, Vertex())); + // --------------------------------------------------------------------- + // 5. Spawn a quad from each face point to the corresponding edge points + // the original points being the fourth quad points. + // --------------------------------------------------------------------- + for (size_t t = 0; t < nmesh; ++t) { + const aiMesh *const minp = smesh[t]; + aiMesh *const mout = out[t] = new aiMesh(); + + for (unsigned int a = 0; a < minp->mNumFaces; ++a) { + mout->mNumFaces += minp->mFaces[a].mNumIndices; + } + + // We need random access to the old face buffer, so reuse is not possible. + mout->mFaces = new aiFace[mout->mNumFaces]; + + mout->mNumVertices = mout->mNumFaces * 4; + mout->mVertices = new aiVector3D[mout->mNumVertices]; + + // quads only, keep material index + mout->mPrimitiveTypes = aiPrimitiveType_POLYGON; + mout->mMaterialIndex = minp->mMaterialIndex; + + if (minp->HasNormals()) { + mout->mNormals = new aiVector3D[mout->mNumVertices]; + } + + if (minp->HasTangentsAndBitangents()) { + mout->mTangents = new aiVector3D[mout->mNumVertices]; + mout->mBitangents = new aiVector3D[mout->mNumVertices]; + } + + for (unsigned int i = 0; minp->HasTextureCoords(i); ++i) { + mout->mTextureCoords[i] = new aiVector3D[mout->mNumVertices]; + mout->mNumUVComponents[i] = minp->mNumUVComponents[i]; + } + + for (unsigned int i = 0; minp->HasVertexColors(i); ++i) { + mout->mColors[i] = new aiColor4D[mout->mNumVertices]; + } + + mout->mNumVertices = mout->mNumFaces << 2u; + for (unsigned int i = 0, v = 0, n = 0; i < minp->mNumFaces; ++i) { + + const aiFace &face = minp->mFaces[i]; + for (unsigned int a = 0; a < face.mNumIndices; ++a) { + + // Get a clean new face. + aiFace &faceOut = mout->mFaces[n++]; + faceOut.mIndices = new unsigned int[faceOut.mNumIndices = 4]; + + // Spawn a new quadrilateral (ccw winding) for this original point between: + // a) face centroid + centroids[FLATTEN_FACE_IDX(t, i)].SortBack(mout, faceOut.mIndices[0] = v++); + + // b) adjacent edge on the left, seen from the centroid + const Edge &e0 = edges[MAKE_EDGE_HASH(maptbl[FLATTEN_VERTEX_IDX(t, face.mIndices[a])], + maptbl[FLATTEN_VERTEX_IDX(t, face.mIndices[a == face.mNumIndices - 1 ? 0 : a + 1])])]; // fixme: replace with mod face.mNumIndices? + + // c) adjacent edge on the right, seen from the centroid + const Edge &e1 = edges[MAKE_EDGE_HASH(maptbl[FLATTEN_VERTEX_IDX(t, face.mIndices[a])], + maptbl[FLATTEN_VERTEX_IDX(t, face.mIndices[!a ? face.mNumIndices - 1 : a - 1])])]; // fixme: replace with mod face.mNumIndices? + + e0.edge_point.SortBack(mout, faceOut.mIndices[3] = v++); + e1.edge_point.SortBack(mout, faceOut.mIndices[1] = v++); + + // d= original point P with distinct index i + // F := 0 + // R := 0 + // n := 0 + // for each face f containing i + // F := F+ centroid of f + // R := R+ midpoint of edge of f from i to i+1 + // n := n+1 + // + // (F+2R+(n-3)P)/n + const unsigned int org = maptbl[FLATTEN_VERTEX_IDX(t, face.mIndices[a])]; + TouchedOVertex &ov = new_points[org]; + + if (!ov.first) { + ov.first = true; + + const unsigned int *adj; + unsigned int cnt; + GET_ADJACENT_FACES_AND_CNT(org, adj, cnt); + + if (cnt < 3) { + ov.second = Vertex(minp, face.mIndices[a]); + } else { + + Vertex F, R; + for (unsigned int o = 0; o < cnt; ++o) { + ai_assert(adj[o] < totfaces); + F += centroids[adj[o]]; + + // adj[0] is a global face index - search the face in the mesh list + const aiMesh *mp = nullptr; + size_t nidx; + + if (adj[o] < moffsets[0].first) { + mp = smesh[nidx = 0]; + } else { + for (nidx = 1; nidx <= nmesh; ++nidx) { + if (nidx == nmesh || moffsets[nidx].first > adj[o]) { + mp = smesh[--nidx]; + break; + } + } + } + + ai_assert(adj[o] - moffsets[nidx].first < mp->mNumFaces); + const aiFace &f = mp->mFaces[adj[o] - moffsets[nidx].first]; + bool haveit = false; + + // find our original point in the face + for (unsigned int m = 0; m < f.mNumIndices; ++m) { + if (maptbl[FLATTEN_VERTEX_IDX(nidx, f.mIndices[m])] == org) { + + // add *both* edges. this way, we can be sure that we add + // *all* adjacent edges to R. In a closed shape, every + // edge is added twice - so we simply leave out the + // factor 2.f in the amove formula and get the right + // result. + + const Edge &c0 = edges[MAKE_EDGE_HASH(org, maptbl[FLATTEN_VERTEX_IDX( + nidx, f.mIndices[!m ? f.mNumIndices - 1 : m - 1])])]; + // fixme: replace with mod face.mNumIndices? + + const Edge &c1 = edges[MAKE_EDGE_HASH(org, maptbl[FLATTEN_VERTEX_IDX( + nidx, f.mIndices[m == f.mNumIndices - 1 ? 0 : m + 1])])]; + // fixme: replace with mod face.mNumIndices? + R += c0.midpoint + c1.midpoint; + + haveit = true; + break; + } + } + + // this invariant *must* hold if the vertex-to-face adjacency table is valid + ai_assert(haveit); + if (!haveit) { + ASSIMP_LOG_WARN("OBJ: no name for material library specified."); + } + } + + const float div = static_cast(cnt), divsq = 1.f / (div * div); + ov.second = Vertex(minp, face.mIndices[a]) * ((div - 3.f) / div) + R * divsq + F * divsq; + } + } + ov.second.SortBack(mout, faceOut.mIndices[2] = v++); + } } } - } - } // end of scope for edges, freeing its memory + } // end of scope for edges, freeing its memory // --------------------------------------------------------------------- // 7. Apply the next subdivision step. // --------------------------------------------------------------------- if (num != 1) { - std::vector tmp(nmesh); - InternSubdivide (out,nmesh,&tmp.front(),num-1); + std::vector tmp(nmesh); + InternSubdivide(out, nmesh, &tmp.front(), num - 1); for (size_t i = 0; i < nmesh; ++i) { delete out[i]; out[i] = tmp[i]; diff --git a/code/Common/TargetAnimation.cpp b/code/Common/TargetAnimation.cpp index 3c61d2176..05fd334c4 100644 --- a/code/Common/TargetAnimation.cpp +++ b/code/Common/TargetAnimation.cpp @@ -41,58 +41,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "TargetAnimation.h" -#include #include +#include using namespace Assimp; - // ------------------------------------------------------------------------------------------------ -KeyIterator::KeyIterator(const std::vector* _objPos, - const std::vector* _targetObjPos, - const aiVector3D* defaultObjectPos /*= NULL*/, - const aiVector3D* defaultTargetPos /*= NULL*/) - - : reachedEnd (false) - , curTime (-1.) - , objPos (_objPos) - , targetObjPos (_targetObjPos) - , nextObjPos (0) - , nextTargetObjPos(0) -{ +KeyIterator::KeyIterator(const std::vector *_objPos, + const std::vector *_targetObjPos, + const aiVector3D *defaultObjectPos /*= nullptr*/, + const aiVector3D *defaultTargetPos /*= nullptr*/) : + reachedEnd(false), + curTime(-1.), + objPos(_objPos), + targetObjPos(_targetObjPos), + nextObjPos(0), + nextTargetObjPos(0) { // Generate default transformation tracks if necessary - if (!objPos || objPos->empty()) - { + if (!objPos || objPos->empty()) { defaultObjPos.resize(1); - defaultObjPos.front().mTime = 10e10; + defaultObjPos.front().mTime = 10e10; if (defaultObjectPos) defaultObjPos.front().mValue = *defaultObjectPos; - objPos = & defaultObjPos; + objPos = &defaultObjPos; } - if (!targetObjPos || targetObjPos->empty()) - { + if (!targetObjPos || targetObjPos->empty()) { defaultTargetObjPos.resize(1); - defaultTargetObjPos.front().mTime = 10e10; + defaultTargetObjPos.front().mTime = 10e10; if (defaultTargetPos) defaultTargetObjPos.front().mValue = *defaultTargetPos; - targetObjPos = & defaultTargetObjPos; + targetObjPos = &defaultTargetObjPos; } } // ------------------------------------------------------------------------------------------------ template -inline T Interpolate(const T& one, const T& two, ai_real val) -{ - return one + (two-one)*val; +inline T Interpolate(const T &one, const T &two, ai_real val) { + return one + (two - one) * val; } // ------------------------------------------------------------------------------------------------ -void KeyIterator::operator ++() -{ +void KeyIterator::operator++() { // If we are already at the end of all keyframes, return if (reachedEnd) { return; @@ -100,113 +93,102 @@ void KeyIterator::operator ++() // Now search in all arrays for the time value closest // to our current position on the time line - double d0,d1; + double d0, d1; - d0 = objPos->at ( std::min ( nextObjPos, static_cast(objPos->size()-1)) ).mTime; - d1 = targetObjPos->at( std::min ( nextTargetObjPos, static_cast(targetObjPos->size()-1)) ).mTime; + d0 = objPos->at(std::min(nextObjPos, static_cast(objPos->size() - 1))).mTime; + d1 = targetObjPos->at(std::min(nextTargetObjPos, static_cast(targetObjPos->size() - 1))).mTime; // Easiest case - all are identical. In this // case we don't need to interpolate so we can // return earlier - if ( d0 == d1 ) - { + if (d0 == d1) { curTime = d0; curPosition = objPos->at(nextObjPos).mValue; curTargetPosition = targetObjPos->at(nextTargetObjPos).mValue; // increment counters - if (objPos->size() != nextObjPos-1) + if (objPos->size() != nextObjPos - 1) ++nextObjPos; - if (targetObjPos->size() != nextTargetObjPos-1) + if (targetObjPos->size() != nextTargetObjPos - 1) ++nextTargetObjPos; } // An object position key is closest to us - else if (d0 < d1) - { + else if (d0 < d1) { curTime = d0; // interpolate the other if (1 == targetObjPos->size() || !nextTargetObjPos) { curTargetPosition = targetObjPos->at(0).mValue; - } - else - { - const aiVectorKey& last = targetObjPos->at(nextTargetObjPos); - const aiVectorKey& first = targetObjPos->at(nextTargetObjPos-1); + } else { + const aiVectorKey &last = targetObjPos->at(nextTargetObjPos); + const aiVectorKey &first = targetObjPos->at(nextTargetObjPos - 1); - curTargetPosition = Interpolate(first.mValue, last.mValue, (ai_real) ( - (curTime-first.mTime) / (last.mTime-first.mTime) )); + curTargetPosition = Interpolate(first.mValue, last.mValue, (ai_real)((curTime - first.mTime) / (last.mTime - first.mTime))); } - if (objPos->size() != nextObjPos-1) + if (objPos->size() != nextObjPos - 1) ++nextObjPos; } // A target position key is closest to us - else - { + else { curTime = d1; // interpolate the other if (1 == objPos->size() || !nextObjPos) { curPosition = objPos->at(0).mValue; - } - else - { - const aiVectorKey& last = objPos->at(nextObjPos); - const aiVectorKey& first = objPos->at(nextObjPos-1); + } else { + const aiVectorKey &last = objPos->at(nextObjPos); + const aiVectorKey &first = objPos->at(nextObjPos - 1); - curPosition = Interpolate(first.mValue, last.mValue, (ai_real) ( - (curTime-first.mTime) / (last.mTime-first.mTime))); + curPosition = Interpolate(first.mValue, last.mValue, (ai_real)((curTime - first.mTime) / (last.mTime - first.mTime))); } - if (targetObjPos->size() != nextTargetObjPos-1) + if (targetObjPos->size() != nextTargetObjPos - 1) ++nextTargetObjPos; } - if (nextObjPos >= objPos->size()-1 && - nextTargetObjPos >= targetObjPos->size()-1) - { + if (nextObjPos >= objPos->size() - 1 && + nextTargetObjPos >= targetObjPos->size() - 1) { // We reached the very last keyframe reachedEnd = true; } } // ------------------------------------------------------------------------------------------------ -void TargetAnimationHelper::SetTargetAnimationChannel ( - const std::vector* _targetPositions) -{ - ai_assert(NULL != _targetPositions); +void TargetAnimationHelper::SetTargetAnimationChannel( + const std::vector *_targetPositions) { + ai_assert(nullptr != _targetPositions); + targetPositions = _targetPositions; } // ------------------------------------------------------------------------------------------------ -void TargetAnimationHelper::SetMainAnimationChannel ( - const std::vector* _objectPositions) -{ - ai_assert(NULL != _objectPositions); +void TargetAnimationHelper::SetMainAnimationChannel( + const std::vector *_objectPositions) { + ai_assert(nullptr != _objectPositions); + objectPositions = _objectPositions; } // ------------------------------------------------------------------------------------------------ void TargetAnimationHelper::SetFixedMainAnimationChannel( - const aiVector3D& fixed) -{ - objectPositions = NULL; // just to avoid confusion + const aiVector3D &fixed) { + objectPositions = nullptr; // just to avoid confusion fixedMain = fixed; } // ------------------------------------------------------------------------------------------------ -void TargetAnimationHelper::Process(std::vector* distanceTrack) -{ - ai_assert(NULL != targetPositions && NULL != distanceTrack); +void TargetAnimationHelper::Process(std::vector *distanceTrack) { + ai_assert(nullptr != targetPositions); + ai_assert(nullptr != distanceTrack); // TODO: in most cases we won't need the extra array - std::vector real; + std::vector real; - std::vector* fill = (distanceTrack == objectPositions ? &real : distanceTrack); - fill->reserve(std::max( objectPositions->size(), targetPositions->size() )); + std::vector *fill = (distanceTrack == objectPositions ? &real : distanceTrack); + fill->reserve(std::max(objectPositions->size(), targetPositions->size())); // Iterate through all object keys and interpolate their values if necessary. // Then get the corresponding target position, compute the difference @@ -214,28 +196,24 @@ void TargetAnimationHelper::Process(std::vector* distanceTrack) // that rotates the base vector of the object coordinate system at that time // to match the diff vector. - KeyIterator iter(objectPositions,targetPositions,&fixedMain); - for (;!iter.Finished();++iter) - { - const aiVector3D& position = iter.GetCurPosition(); - const aiVector3D& tposition = iter.GetCurTargetPosition(); + KeyIterator iter(objectPositions, targetPositions, &fixedMain); + for (; !iter.Finished(); ++iter) { + const aiVector3D &position = iter.GetCurPosition(); + const aiVector3D &tposition = iter.GetCurTargetPosition(); // diff vector aiVector3D diff = tposition - position; ai_real f = diff.Length(); // output distance vector - if (f) - { + if (f) { fill->push_back(aiVectorKey()); - aiVectorKey& v = fill->back(); - v.mTime = iter.GetCurTime(); + aiVectorKey &v = fill->back(); + v.mTime = iter.GetCurTime(); v.mValue = diff; diff /= f; - } - else - { + } else { // FIXME: handle this } diff --git a/code/Common/TargetAnimation.h b/code/Common/TargetAnimation.h index 5b9c1881d..0854450bf 100644 --- a/code/Common/TargetAnimation.h +++ b/code/Common/TargetAnimation.h @@ -48,9 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -namespace Assimp { - - +namespace Assimp { // --------------------------------------------------------------------------- /** Helper class to iterate through all keys in an animation channel. @@ -58,55 +56,44 @@ namespace Assimp { * Missing tracks are interpolated. This is a helper class for * TargetAnimationHelper, but it can be freely used for other purposes. */ -class KeyIterator -{ +class KeyIterator { public: - - // ------------------------------------------------------------------ /** Constructs a new key iterator * - * @param _objPos Object position track. May be NULL. - * @param _targetObjPos Target object position track. May be NULL. + * @param _objPos Object position track. May be nullptr. + * @param _targetObjPos Target object position track. May be nullptr. * @param defaultObjectPos Default object position to be used if - * no animated track is available. May be NULL. + * no animated track is available. May be nullptr. * @param defaultTargetPos Default target position to be used if - * no animated track is available. May be NULL. + * no animated track is available. May be nullptr. */ - KeyIterator(const std::vector* _objPos, - const std::vector* _targetObjPos, - const aiVector3D* defaultObjectPos = NULL, - const aiVector3D* defaultTargetPos = NULL); + KeyIterator(const std::vector *_objPos, + const std::vector *_targetObjPos, + const aiVector3D *defaultObjectPos = nullptr, + const aiVector3D *defaultTargetPos = nullptr); // ------------------------------------------------------------------ /** Returns true if all keys have been processed */ - bool Finished() const - {return reachedEnd;} + bool Finished() const { return reachedEnd; } // ------------------------------------------------------------------ /** Increment the iterator */ void operator++(); - inline void operator++(int) - {return ++(*this);} - - + inline void operator++(int) { return ++(*this); } // ------------------------------------------------------------------ /** Getters to retrieve the current state of the iterator */ - inline const aiVector3D& GetCurPosition() const - {return curPosition;} + inline const aiVector3D &GetCurPosition() const { return curPosition; } - inline const aiVector3D& GetCurTargetPosition() const - {return curTargetPosition;} + inline const aiVector3D &GetCurTargetPosition() const { return curTargetPosition; } - inline double GetCurTime() const - {return curTime;} + inline double GetCurTime() const { return curTime; } private: - //! Did we reach the end? bool reachedEnd; @@ -116,10 +103,10 @@ private: double curTime; //! Input tracks and the next key to process - const std::vector* objPos,*targetObjPos; + const std::vector *objPos, *targetObjPos; unsigned int nextObjPos, nextTargetObjPos; - std::vector defaultObjPos,defaultTargetObjPos; + std::vector defaultObjPos, defaultTargetObjPos; }; // --------------------------------------------------------------------------- @@ -130,15 +117,13 @@ private: * channel for the camera/spot light itself and a separate position * animation channels specifying the position of the camera/spot light * look-at target */ -class TargetAnimationHelper -{ +class TargetAnimationHelper { public: - - TargetAnimationHelper() - : targetPositions (NULL) - , objectPositions (NULL) - {} - + TargetAnimationHelper() : + targetPositions(nullptr), + objectPositions(nullptr) { + // empty + } // ------------------------------------------------------------------ /** Sets the target animation channel @@ -147,37 +132,30 @@ public: * target at a specific position. * * @param targetPositions Translation channel*/ - void SetTargetAnimationChannel (const - std::vector* targetPositions); - + void SetTargetAnimationChannel(const std::vector *targetPositions); // ------------------------------------------------------------------ /** Sets the main animation channel * * @param objectPositions Translation channel */ - void SetMainAnimationChannel ( const - std::vector* objectPositions); + void SetMainAnimationChannel(const std::vector *objectPositions); // ------------------------------------------------------------------ /** Sets the main animation channel to a fixed value * * @param fixed Fixed value for the main animation channel*/ - void SetFixedMainAnimationChannel(const aiVector3D& fixed); - + void SetFixedMainAnimationChannel(const aiVector3D &fixed); // ------------------------------------------------------------------ /** Computes final animation channels - * @param distanceTrack Receive camera translation keys ... != NULL. */ - void Process( std::vector* distanceTrack ); - + * @param distanceTrack Receive camera translation keys ... != nullptr. */ + void Process(std::vector *distanceTrack); private: - - const std::vector* targetPositions,*objectPositions; + const std::vector *targetPositions, *objectPositions; aiVector3D fixedMain; }; - -} // ! end namespace Assimp +} // namespace Assimp #endif // include guard diff --git a/code/Common/VertexTriangleAdjacency.cpp b/code/Common/VertexTriangleAdjacency.cpp index e588dc2a4..591c8b584 100644 --- a/code/Common/VertexTriangleAdjacency.cpp +++ b/code/Common/VertexTriangleAdjacency.cpp @@ -52,46 +52,44 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces, - unsigned int iNumFaces, - unsigned int iNumVertices /*= 0*/, - bool bComputeNumTriangles /*= false*/) -{ + unsigned int iNumFaces, + unsigned int iNumVertices /*= 0*/, + bool bComputeNumTriangles /*= false*/) { // compute the number of referenced vertices if it wasn't specified by the caller - const aiFace* const pcFaceEnd = pcFaces + iNumFaces; - if (0 == iNumVertices) { - for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace) { - ai_assert( nullptr != pcFace ); + const aiFace *const pcFaceEnd = pcFaces + iNumFaces; + if (0 == iNumVertices) { + for (aiFace *pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace) { + ai_assert(nullptr != pcFace); ai_assert(3 == pcFace->mNumIndices); - iNumVertices = std::max(iNumVertices,pcFace->mIndices[0]); - iNumVertices = std::max(iNumVertices,pcFace->mIndices[1]); - iNumVertices = std::max(iNumVertices,pcFace->mIndices[2]); + iNumVertices = std::max(iNumVertices, pcFace->mIndices[0]); + iNumVertices = std::max(iNumVertices, pcFace->mIndices[1]); + iNumVertices = std::max(iNumVertices, pcFace->mIndices[2]); } } mNumVertices = iNumVertices + 1; - unsigned int* pi; + unsigned int *pi; // allocate storage - if (bComputeNumTriangles) { - pi = mLiveTriangles = new unsigned int[iNumVertices+1]; - ::memset(mLiveTriangles,0,sizeof(unsigned int)*(iNumVertices+1)); - mOffsetTable = new unsigned int[iNumVertices+2]+1; + if (bComputeNumTriangles) { + pi = mLiveTriangles = new unsigned int[iNumVertices + 1]; + ::memset(mLiveTriangles, 0, sizeof(unsigned int) * (iNumVertices + 1)); + mOffsetTable = new unsigned int[iNumVertices + 2] + 1; } else { - pi = mOffsetTable = new unsigned int[iNumVertices+2]+1; - ::memset(mOffsetTable,0,sizeof(unsigned int)*(iNumVertices+1)); - mLiveTriangles = NULL; // important, otherwise the d'tor would crash + pi = mOffsetTable = new unsigned int[iNumVertices + 2] + 1; + ::memset(mOffsetTable, 0, sizeof(unsigned int) * (iNumVertices + 1)); + mLiveTriangles = nullptr; // important, otherwise the d'tor would crash } // get a pointer to the end of the buffer - unsigned int* piEnd = pi+iNumVertices; + unsigned int *piEnd = pi + iNumVertices; *piEnd++ = 0u; // first pass: compute the number of faces referencing each vertex - for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace) - { + for (aiFace *pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace) { unsigned nind = pcFace->mNumIndices; - unsigned * ind = pcFace->mIndices; + unsigned *ind = pcFace->mIndices; if (nind > 0) pi[ind[0]]++; if (nind > 1) pi[ind[1]]++; if (nind > 2) pi[ind[2]]++; @@ -99,8 +97,8 @@ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces, // second pass: compute the final offset table unsigned int iSum = 0; - unsigned int* piCurOut = this->mOffsetTable; - for (unsigned int* piCur = pi; piCur != piEnd;++piCur,++piCurOut) { + unsigned int *piCurOut = this->mOffsetTable; + for (unsigned int *piCur = pi; piCur != piEnd; ++piCur, ++piCurOut) { unsigned int iLastSum = iSum; iSum += *piCur; @@ -111,9 +109,9 @@ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces, // third pass: compute the final table this->mAdjacencyTable = new unsigned int[iSum]; iSum = 0; - for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace,++iSum) { + for (aiFace *pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace, ++iSum) { unsigned nind = pcFace->mNumIndices; - unsigned * ind = pcFace->mIndices; + unsigned *ind = pcFace->mIndices; if (nind > 0) mAdjacencyTable[pi[ind[0]]++] = iSum; if (nind > 1) mAdjacencyTable[pi[ind[1]]++] = iSum; @@ -125,8 +123,7 @@ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces, *mOffsetTable = 0u; } // ------------------------------------------------------------------------------------------------ -VertexTriangleAdjacency::~VertexTriangleAdjacency() -{ +VertexTriangleAdjacency::~VertexTriangleAdjacency() { // delete allocated storage delete[] mOffsetTable; delete[] mAdjacencyTable; diff --git a/code/Common/ZipArchiveIOSystem.cpp b/code/Common/ZipArchiveIOSystem.cpp index 6ad10e54a..f55f9ff53 100644 --- a/code/Common/ZipArchiveIOSystem.cpp +++ b/code/Common/ZipArchiveIOSystem.cpp @@ -248,15 +248,18 @@ ZipFile::~ZipFile() { size_t ZipFile::Read(void *pvBuffer, size_t pSize, size_t pCount) { // Should be impossible ai_assert(m_Buffer != nullptr); - ai_assert(NULL != pvBuffer && 0 != pSize && 0 != pCount); + ai_assert(nullptr != pvBuffer); + ai_assert(0 != pSize); + ai_assert(0 != pCount); // Clip down to file size size_t byteSize = pSize * pCount; if ((byteSize + m_SeekPtr) > m_Size) { pCount = (m_Size - m_SeekPtr) / pSize; byteSize = pSize * pCount; - if (byteSize == 0) + if (byteSize == 0) { return 0; + } } std::memcpy(pvBuffer, m_Buffer.get() + m_SeekPtr, byteSize); diff --git a/code/Material/MaterialSystem.cpp b/code/Material/MaterialSystem.cpp index f75fa0126..e83ab97af 100644 --- a/code/Material/MaterialSystem.cpp +++ b/code/Material/MaterialSystem.cpp @@ -44,76 +44,73 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of the material system of the library */ -#include -#include -#include #include "MaterialSystem.h" -#include +#include +#include +#include #include +#include #include using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Get a specific property from a material -aiReturn aiGetMaterialProperty(const aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - const aiMaterialProperty** pPropOut) -{ - ai_assert( pMat != NULL ); - ai_assert( pKey != NULL ); - ai_assert( pPropOut != NULL ); +aiReturn aiGetMaterialProperty(const aiMaterial *pMat, + const char *pKey, + unsigned int type, + unsigned int index, + const aiMaterialProperty **pPropOut) { + ai_assert(pMat != nullptr); + ai_assert(pKey != nullptr); + ai_assert(pPropOut != nullptr); /* Just search for a property with exactly this name .. * could be improved by hashing, but it's possibly * no worth the effort (we're bound to C structures, * thus std::map or derivates are not applicable. */ - for ( unsigned int i = 0; i < pMat->mNumProperties; ++i ) { - aiMaterialProperty* prop = pMat->mProperties[i]; + for (unsigned int i = 0; i < pMat->mNumProperties; ++i) { + aiMaterialProperty *prop = pMat->mProperties[i]; if (prop /* just for safety ... */ - && 0 == strcmp( prop->mKey.data, pKey ) - && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wild-card, but this is undocumented :-) */ - && (UINT_MAX == index || prop->mIndex == index)) - { + && 0 == strcmp(prop->mKey.data, pKey) && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wild-card, but this is undocumented :-) */ + && (UINT_MAX == index || prop->mIndex == index)) { *pPropOut = pMat->mProperties[i]; return AI_SUCCESS; } } - *pPropOut = NULL; + *pPropOut = nullptr; return AI_FAILURE; } // ------------------------------------------------------------------------------------------------ // Get an array of floating-point values from the material. -aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - ai_real* pOut, - unsigned int* pMax) -{ - ai_assert( pOut != nullptr ); - ai_assert( pMat != nullptr ); +aiReturn aiGetMaterialFloatArray(const aiMaterial *pMat, + const char *pKey, + unsigned int type, + unsigned int index, + ai_real *pOut, + unsigned int *pMax) { + ai_assert(pOut != nullptr); + ai_assert(pMat != nullptr); - const aiMaterialProperty* prop; - aiGetMaterialProperty(pMat,pKey,type,index, (const aiMaterialProperty**) &prop); - if ( nullptr == prop) { + const aiMaterialProperty *prop; + aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop); + if (nullptr == prop) { return AI_FAILURE; } // data is given in floats, convert to ai_real unsigned int iWrite = 0; - if( aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) { + if (aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) { iWrite = prop->mDataLength / sizeof(float); if (pMax) { - iWrite = std::min(*pMax,iWrite); ; + iWrite = std::min(*pMax, iWrite); + ; } for (unsigned int a = 0; a < iWrite; ++a) { - pOut[ a ] = static_cast ( reinterpret_cast(prop->mData)[a] ); + pOut[a] = static_cast(reinterpret_cast(prop->mData)[a]); } if (pMax) { @@ -121,26 +118,28 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, } } // data is given in doubles, convert to float - else if( aiPTI_Double == prop->mType) { + else if (aiPTI_Double == prop->mType) { iWrite = prop->mDataLength / sizeof(double); if (pMax) { - iWrite = std::min(*pMax,iWrite); ; + iWrite = std::min(*pMax, iWrite); + ; } - for (unsigned int a = 0; a < iWrite;++a) { - pOut[a] = static_cast ( reinterpret_cast(prop->mData)[a] ); + for (unsigned int a = 0; a < iWrite; ++a) { + pOut[a] = static_cast(reinterpret_cast(prop->mData)[a]); } if (pMax) { *pMax = iWrite; } } // data is given in ints, convert to float - else if( aiPTI_Integer == prop->mType) { + else if (aiPTI_Integer == prop->mType) { iWrite = prop->mDataLength / sizeof(int32_t); if (pMax) { - iWrite = std::min(*pMax,iWrite); ; + iWrite = std::min(*pMax, iWrite); + ; } - for (unsigned int a = 0; a < iWrite;++a) { - pOut[a] = static_cast ( reinterpret_cast(prop->mData)[a] ); + for (unsigned int a = 0; a < iWrite; ++a) { + pOut[a] = static_cast(reinterpret_cast(prop->mData)[a]); } if (pMax) { *pMax = iWrite; @@ -153,16 +152,16 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, } // strings are zero-terminated with a 32 bit length prefix, so this is safe const char *cur = prop->mData + 4; - ai_assert( prop->mDataLength >= 5 ); - ai_assert( !prop->mData[ prop->mDataLength - 1 ] ); - for ( unsigned int a = 0; ;++a) { - cur = fast_atoreal_move(cur,pOut[a]); - if ( a==iWrite-1 ) { + ai_assert(prop->mDataLength >= 5); + ai_assert(!prop->mData[prop->mDataLength - 1]); + for (unsigned int a = 0;; ++a) { + cur = fast_atoreal_move(cur, pOut[a]); + if (a == iWrite - 1) { break; } - if ( !IsSpace(*cur) ) { + if (!IsSpace(*cur)) { ASSIMP_LOG_ERROR("Material property" + std::string(pKey) + - " is a string; failed to parse a float array out of it."); + " is a string; failed to parse a float array out of it."); return AI_FAILURE; } } @@ -176,36 +175,34 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, // ------------------------------------------------------------------------------------------------ // Get an array if integers from the material -aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - int* pOut, - unsigned int* pMax) -{ - ai_assert( pOut != NULL ); - ai_assert( pMat != NULL ); +aiReturn aiGetMaterialIntegerArray(const aiMaterial *pMat, + const char *pKey, + unsigned int type, + unsigned int index, + int *pOut, + unsigned int *pMax) { + ai_assert(pOut != nullptr); + ai_assert(pMat != nullptr); - const aiMaterialProperty* prop; - aiGetMaterialProperty(pMat,pKey,type,index,(const aiMaterialProperty**) &prop); + const aiMaterialProperty *prop; + aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop); if (!prop) { return AI_FAILURE; } // data is given in ints, simply copy it unsigned int iWrite = 0; - if( aiPTI_Integer == prop->mType || aiPTI_Buffer == prop->mType) { + if (aiPTI_Integer == prop->mType || aiPTI_Buffer == prop->mType) { iWrite = std::max(static_cast(prop->mDataLength / sizeof(int32_t)), 1u); if (pMax) { - iWrite = std::min(*pMax,iWrite); + iWrite = std::min(*pMax, iWrite); } if (1 == prop->mDataLength) { // bool type, 1 byte *pOut = static_cast(*prop->mData); - } - else { - for (unsigned int a = 0; a < iWrite;++a) { - pOut[a] = static_cast(reinterpret_cast(prop->mData)[a]); + } else { + for (unsigned int a = 0; a < iWrite; ++a) { + pOut[a] = static_cast(reinterpret_cast(prop->mData)[a]); } } if (pMax) { @@ -213,35 +210,36 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat, } } // data is given in floats convert to int - else if( aiPTI_Float == prop->mType) { + else if (aiPTI_Float == prop->mType) { iWrite = prop->mDataLength / sizeof(float); if (pMax) { - iWrite = std::min(*pMax,iWrite); ; + iWrite = std::min(*pMax, iWrite); + ; } - for (unsigned int a = 0; a < iWrite;++a) { - pOut[a] = static_cast(reinterpret_cast(prop->mData)[a]); + for (unsigned int a = 0; a < iWrite; ++a) { + pOut[a] = static_cast(reinterpret_cast(prop->mData)[a]); } if (pMax) { *pMax = iWrite; } } // it is a string ... no way to read something out of this - else { + else { if (pMax) { iWrite = *pMax; } // strings are zero-terminated with a 32 bit length prefix, so this is safe - const char *cur = prop->mData+4; - ai_assert( prop->mDataLength >= 5 ); - ai_assert( !prop->mData[ prop->mDataLength - 1 ] ); - for (unsigned int a = 0; ;++a) { - pOut[a] = strtol10(cur,&cur); - if(a==iWrite-1) { + const char *cur = prop->mData + 4; + ai_assert(prop->mDataLength >= 5); + ai_assert(!prop->mData[prop->mDataLength - 1]); + for (unsigned int a = 0;; ++a) { + pOut[a] = strtol10(cur, &cur); + if (a == iWrite - 1) { break; } - if(!IsSpace(*cur)) { + if (!IsSpace(*cur)) { ASSIMP_LOG_ERROR("Material property" + std::string(pKey) + - " is a string; failed to parse an integer array out of it."); + " is a string; failed to parse an integer array out of it."); return AI_FAILURE; } } @@ -255,14 +253,13 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat, // ------------------------------------------------------------------------------------------------ // Get a color (3 or 4 floats) from the material -aiReturn aiGetMaterialColor(const aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - aiColor4D* pOut) -{ +aiReturn aiGetMaterialColor(const aiMaterial *pMat, + const char *pKey, + unsigned int type, + unsigned int index, + aiColor4D *pOut) { unsigned int iMax = 4; - const aiReturn eRet = aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax); + const aiReturn eRet = aiGetMaterialFloatArray(pMat, pKey, type, index, (ai_real *)pOut, &iMax); // if no alpha channel is defined: set it to 1.0 if (3 == iMax) { @@ -274,46 +271,43 @@ aiReturn aiGetMaterialColor(const aiMaterial* pMat, // ------------------------------------------------------------------------------------------------ // Get a aiUVTransform (5 floats) from the material -aiReturn aiGetMaterialUVTransform(const aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - aiUVTransform* pOut) -{ +aiReturn aiGetMaterialUVTransform(const aiMaterial *pMat, + const char *pKey, + unsigned int type, + unsigned int index, + aiUVTransform *pOut) { unsigned int iMax = 5; - return aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax); + return aiGetMaterialFloatArray(pMat, pKey, type, index, (ai_real *)pOut, &iMax); } // ------------------------------------------------------------------------------------------------ // Get a string from the material -aiReturn aiGetMaterialString(const aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - aiString* pOut) -{ - ai_assert (pOut != NULL); +aiReturn aiGetMaterialString(const aiMaterial *pMat, + const char *pKey, + unsigned int type, + unsigned int index, + aiString *pOut) { + ai_assert(pOut != nullptr); - const aiMaterialProperty* prop; - aiGetMaterialProperty(pMat,pKey,type,index,(const aiMaterialProperty**)&prop); + const aiMaterialProperty *prop; + aiGetMaterialProperty(pMat, pKey, type, index, (const aiMaterialProperty **)&prop); if (!prop) { return AI_FAILURE; } - if( aiPTI_String == prop->mType) { - ai_assert(prop->mDataLength>=5); + if (aiPTI_String == prop->mType) { + ai_assert(prop->mDataLength >= 5); // The string is stored as 32 but length prefix followed by zero-terminated UTF8 data - pOut->length = static_cast(*reinterpret_cast(prop->mData)); + pOut->length = static_cast(*reinterpret_cast(prop->mData)); - ai_assert( pOut->length+1+4==prop->mDataLength ); - ai_assert( !prop->mData[ prop->mDataLength - 1 ] ); - memcpy(pOut->data,prop->mData+4,pOut->length+1); - } - else { + ai_assert(pOut->length + 1 + 4 == prop->mDataLength); + ai_assert(!prop->mData[prop->mDataLength - 1]); + memcpy(pOut->data, prop->mData + 4, pOut->length + 1); + } else { // TODO - implement lexical cast as well ASSIMP_LOG_ERROR("Material property" + std::string(pKey) + - " was found, but is no string" ); + " was found, but is no string"); return AI_FAILURE; } return AI_SUCCESS; @@ -321,94 +315,87 @@ aiReturn aiGetMaterialString(const aiMaterial* pMat, // ------------------------------------------------------------------------------------------------ // Get the number of textures on a particular texture stack -unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat, - C_ENUM aiTextureType type) -{ - ai_assert (pMat != NULL); +unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial *pMat, C_ENUM aiTextureType type) { + ai_assert(pMat != nullptr); // Textures are always stored with ascending indices (ValidateDS provides a check, so we don't need to do it again) unsigned int max = 0; - for (unsigned int i = 0; i < pMat->mNumProperties;++i) { - aiMaterialProperty* prop = pMat->mProperties[i]; + for (unsigned int i = 0; i < pMat->mNumProperties; ++i) { + aiMaterialProperty *prop = pMat->mProperties[i]; - if ( prop /* just a sanity check ... */ - && 0 == strcmp(prop->mKey.data, _AI_MATKEY_TEXTURE_BASE) && static_cast < aiTextureType>(prop->mSemantic) == type) { + if (prop /* just a sanity check ... */ + && 0 == strcmp(prop->mKey.data, _AI_MATKEY_TEXTURE_BASE) && static_cast(prop->mSemantic) == type) { - max = std::max(max,prop->mIndex+1); + max = std::max(max, prop->mIndex + 1); } } return max; } // ------------------------------------------------------------------------------------------------ -aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat, - aiTextureType type, - unsigned int index, - C_STRUCT aiString* path, - aiTextureMapping* _mapping /*= NULL*/, - unsigned int* uvindex /*= NULL*/, - ai_real* blend /*= NULL*/, - aiTextureOp* op /*= NULL*/, - aiTextureMapMode* mapmode /*= NULL*/, - unsigned int* flags /*= NULL*/ - ) -{ - ai_assert( NULL != mat ); - ai_assert( NULL != path ); +aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial *mat, + aiTextureType type, + unsigned int index, + C_STRUCT aiString *path, + aiTextureMapping *_mapping /*= nullptr*/, + unsigned int *uvindex /*= nullptr*/, + ai_real *blend /*= nullptr*/, + aiTextureOp *op /*= nullptr*/, + aiTextureMapMode *mapmode /*= nullptr*/, + unsigned int *flags /*= nullptr*/ +) { + ai_assert(nullptr != mat); + ai_assert(nullptr != path); // Get the path to the texture - if (AI_SUCCESS != aiGetMaterialString(mat,AI_MATKEY_TEXTURE(type,index),path)) { + if (AI_SUCCESS != aiGetMaterialString(mat, AI_MATKEY_TEXTURE(type, index), path)) { return AI_FAILURE; } // Determine mapping type int mapping_ = static_cast(aiTextureMapping_UV); - aiGetMaterialInteger(mat,AI_MATKEY_MAPPING(type,index), &mapping_); + aiGetMaterialInteger(mat, AI_MATKEY_MAPPING(type, index), &mapping_); aiTextureMapping mapping = static_cast(mapping_); if (_mapping) *_mapping = mapping; // Get UV index - if (aiTextureMapping_UV == mapping && uvindex) { - aiGetMaterialInteger(mat,AI_MATKEY_UVWSRC(type,index),(int*)uvindex); + if (aiTextureMapping_UV == mapping && uvindex) { + aiGetMaterialInteger(mat, AI_MATKEY_UVWSRC(type, index), (int *)uvindex); } // Get blend factor - if (blend) { - aiGetMaterialFloat(mat,AI_MATKEY_TEXBLEND(type,index),blend); + if (blend) { + aiGetMaterialFloat(mat, AI_MATKEY_TEXBLEND(type, index), blend); } // Get texture operation - if (op){ - aiGetMaterialInteger(mat,AI_MATKEY_TEXOP(type,index),(int*)op); + if (op) { + aiGetMaterialInteger(mat, AI_MATKEY_TEXOP(type, index), (int *)op); } // Get texture mapping modes - if (mapmode) { - aiGetMaterialInteger(mat,AI_MATKEY_MAPPINGMODE_U(type,index),(int*)&mapmode[0]); - aiGetMaterialInteger(mat,AI_MATKEY_MAPPINGMODE_V(type,index),(int*)&mapmode[1]); + if (mapmode) { + aiGetMaterialInteger(mat, AI_MATKEY_MAPPINGMODE_U(type, index), (int *)&mapmode[0]); + aiGetMaterialInteger(mat, AI_MATKEY_MAPPINGMODE_V(type, index), (int *)&mapmode[1]); } // Get texture flags - if (flags){ - aiGetMaterialInteger(mat,AI_MATKEY_TEXFLAGS(type,index),(int*)flags); + if (flags) { + aiGetMaterialInteger(mat, AI_MATKEY_TEXFLAGS(type, index), (int *)flags); } return AI_SUCCESS; } - static const unsigned int DefaultNumAllocated = 5; // ------------------------------------------------------------------------------------------------ // Construction. Actually the one and only way to get an aiMaterial instance -aiMaterial::aiMaterial() -: mProperties( nullptr ) -, mNumProperties( 0 ) -, mNumAllocated( DefaultNumAllocated ) { +aiMaterial::aiMaterial() : + mProperties(nullptr), mNumProperties(0), mNumAllocated(DefaultNumAllocated) { // Allocate 5 entries by default - mProperties = new aiMaterialProperty*[ DefaultNumAllocated ]; + mProperties = new aiMaterialProperty *[DefaultNumAllocated]; } // ------------------------------------------------------------------------------------------------ -aiMaterial::~aiMaterial() -{ +aiMaterial::~aiMaterial() { Clear(); delete[] mProperties; @@ -423,11 +410,10 @@ aiString aiMaterial::GetName() { } // ------------------------------------------------------------------------------------------------ -void aiMaterial::Clear() -{ - for ( unsigned int i = 0; i < mNumProperties; ++i ) { +void aiMaterial::Clear() { + for (unsigned int i = 0; i < mNumProperties; ++i) { // delete this entry - delete mProperties[ i ]; + delete mProperties[i]; AI_DEBUG_INVALIDATE_PTR(mProperties[i]); } mNumProperties = 0; @@ -436,23 +422,21 @@ void aiMaterial::Clear() } // ------------------------------------------------------------------------------------------------ -aiReturn aiMaterial::RemoveProperty ( const char* pKey,unsigned int type, unsigned int index ) -{ - ai_assert( nullptr != pKey ); +aiReturn aiMaterial::RemoveProperty(const char *pKey, unsigned int type, unsigned int index) { + ai_assert(nullptr != pKey); - for (unsigned int i = 0; i < mNumProperties;++i) { - aiMaterialProperty* prop = mProperties[i]; + for (unsigned int i = 0; i < mNumProperties; ++i) { + aiMaterialProperty *prop = mProperties[i]; - if (prop && !strcmp( prop->mKey.data, pKey ) && - prop->mSemantic == type && prop->mIndex == index) - { + if (prop && !strcmp(prop->mKey.data, pKey) && + prop->mSemantic == type && prop->mIndex == index) { // Delete this entry delete mProperties[i]; // collapse the array behind --. --mNumProperties; - for (unsigned int a = i; a < mNumProperties;++a) { - mProperties[a] = mProperties[a+1]; + for (unsigned int a = i; a < mNumProperties; ++a) { + mProperties[a] = mProperties[a + 1]; } return AI_SUCCESS; } @@ -462,29 +446,27 @@ aiReturn aiMaterial::RemoveProperty ( const char* pKey,unsigned int type, unsign } // ------------------------------------------------------------------------------------------------ -aiReturn aiMaterial::AddBinaryProperty (const void* pInput, - unsigned int pSizeInBytes, - const char* pKey, - unsigned int type, - unsigned int index, - aiPropertyTypeInfo pType - ) -{ - ai_assert( pInput != nullptr ); - ai_assert(pKey != nullptr ); - ai_assert( 0 != pSizeInBytes ); +aiReturn aiMaterial::AddBinaryProperty(const void *pInput, + unsigned int pSizeInBytes, + const char *pKey, + unsigned int type, + unsigned int index, + aiPropertyTypeInfo pType) { + ai_assert(pInput != nullptr); + ai_assert(pKey != nullptr); + ai_assert(0 != pSizeInBytes); - if ( 0 == pSizeInBytes ) { - return AI_FAILURE; + if (0 == pSizeInBytes) { + return AI_FAILURE; } // first search the list whether there is already an entry with this key - unsigned int iOutIndex( UINT_MAX ); - for ( unsigned int i = 0; i < mNumProperties; ++i ) { - aiMaterialProperty *prop( mProperties[ i ] ); + unsigned int iOutIndex(UINT_MAX); + for (unsigned int i = 0; i < mNumProperties; ++i) { + aiMaterialProperty *prop(mProperties[i]); - if (prop /* just for safety */ && !strcmp( prop->mKey.data, pKey ) && - prop->mSemantic == type && prop->mIndex == index){ + if (prop /* just for safety */ && !strcmp(prop->mKey.data, pKey) && + prop->mSemantic == type && prop->mIndex == index) { delete mProperties[i]; iOutIndex = i; @@ -492,7 +474,7 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput, } // Allocate a new material property - aiMaterialProperty* pcNew = new aiMaterialProperty(); + aiMaterialProperty *pcNew = new aiMaterialProperty(); // .. and fill it pcNew->mType = pType; @@ -501,32 +483,32 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput, pcNew->mDataLength = pSizeInBytes; pcNew->mData = new char[pSizeInBytes]; - memcpy (pcNew->mData,pInput,pSizeInBytes); + memcpy(pcNew->mData, pInput, pSizeInBytes); - pcNew->mKey.length = static_cast( ::strlen(pKey) ); - ai_assert ( MAXLEN > pcNew->mKey.length); - strcpy( pcNew->mKey.data, pKey ); + pcNew->mKey.length = static_cast(::strlen(pKey)); + ai_assert(MAXLEN > pcNew->mKey.length); + strcpy(pcNew->mKey.data, pKey); - if (UINT_MAX != iOutIndex) { + if (UINT_MAX != iOutIndex) { mProperties[iOutIndex] = pcNew; return AI_SUCCESS; } // resize the array ... double the storage allocated - if (mNumProperties == mNumAllocated) { + if (mNumProperties == mNumAllocated) { const unsigned int iOld = mNumAllocated; mNumAllocated *= 2; - aiMaterialProperty** ppTemp; + aiMaterialProperty **ppTemp; try { - ppTemp = new aiMaterialProperty*[mNumAllocated]; - } catch (std::bad_alloc&) { + ppTemp = new aiMaterialProperty *[mNumAllocated]; + } catch (std::bad_alloc &) { delete pcNew; return AI_OUTOFMEMORY; } // just copy all items over; then replace the old array - memcpy (ppTemp,mProperties,iOld * sizeof(void*)); + memcpy(ppTemp, mProperties, iOld * sizeof(void *)); delete[] mProperties; mProperties = ppTemp; @@ -538,81 +520,76 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput, } // ------------------------------------------------------------------------------------------------ -aiReturn aiMaterial::AddProperty (const aiString* pInput, - const char* pKey, - unsigned int type, - unsigned int index) -{ - ai_assert(sizeof(ai_uint32)==4); +aiReturn aiMaterial::AddProperty(const aiString *pInput, + const char *pKey, + unsigned int type, + unsigned int index) { + ai_assert(sizeof(ai_uint32) == 4); return AddBinaryProperty(pInput, - static_cast(pInput->length+1+4), - pKey, - type, - index, - aiPTI_String); + static_cast(pInput->length + 1 + 4), + pKey, + type, + index, + aiPTI_String); } // ------------------------------------------------------------------------------------------------ -uint32_t Assimp::ComputeMaterialHash(const aiMaterial* mat, bool includeMatName /*= false*/) -{ +uint32_t Assimp::ComputeMaterialHash(const aiMaterial *mat, bool includeMatName /*= false*/) { uint32_t hash = 1503; // magic start value, chosen to be my birthday :-) - for ( unsigned int i = 0; i < mat->mNumProperties; ++i ) { - aiMaterialProperty* prop; + for (unsigned int i = 0; i < mat->mNumProperties; ++i) { + aiMaterialProperty *prop; // Exclude all properties whose first character is '?' from the hash // See doc for aiMaterialProperty. - prop = mat->mProperties[ i ]; - if ( nullptr != prop && (includeMatName || prop->mKey.data[0] != '?')) { + prop = mat->mProperties[i]; + if (nullptr != prop && (includeMatName || prop->mKey.data[0] != '?')) { - hash = SuperFastHash(prop->mKey.data,(unsigned int)prop->mKey.length,hash); - hash = SuperFastHash(prop->mData,prop->mDataLength,hash); + hash = SuperFastHash(prop->mKey.data, (unsigned int)prop->mKey.length, hash); + hash = SuperFastHash(prop->mData, prop->mDataLength, hash); // Combine the semantic and the index with the hash - hash = SuperFastHash((const char*)&prop->mSemantic,sizeof(unsigned int),hash); - hash = SuperFastHash((const char*)&prop->mIndex,sizeof(unsigned int),hash); + hash = SuperFastHash((const char *)&prop->mSemantic, sizeof(unsigned int), hash); + hash = SuperFastHash((const char *)&prop->mIndex, sizeof(unsigned int), hash); } } return hash; } // ------------------------------------------------------------------------------------------------ -void aiMaterial::CopyPropertyList(aiMaterial* pcDest, - const aiMaterial* pcSrc - ) -{ - ai_assert(NULL != pcDest); - ai_assert(NULL != pcSrc); +void aiMaterial::CopyPropertyList(aiMaterial *pcDest, + const aiMaterial *pcSrc) { + ai_assert(nullptr != pcDest); + ai_assert(nullptr != pcSrc); unsigned int iOldNum = pcDest->mNumProperties; pcDest->mNumAllocated += pcSrc->mNumAllocated; pcDest->mNumProperties += pcSrc->mNumProperties; - aiMaterialProperty** pcOld = pcDest->mProperties; - pcDest->mProperties = new aiMaterialProperty*[pcDest->mNumAllocated]; + aiMaterialProperty **pcOld = pcDest->mProperties; + pcDest->mProperties = new aiMaterialProperty *[pcDest->mNumAllocated]; - if (iOldNum && pcOld) { - for (unsigned int i = 0; i < iOldNum;++i) { + if (iOldNum && pcOld) { + for (unsigned int i = 0; i < iOldNum; ++i) { pcDest->mProperties[i] = pcOld[i]; } } - if ( pcOld ) { + if (pcOld) { delete[] pcOld; } - for (unsigned int i = iOldNum; i< pcDest->mNumProperties;++i) { - aiMaterialProperty* propSrc = pcSrc->mProperties[i]; + for (unsigned int i = iOldNum; i < pcDest->mNumProperties; ++i) { + aiMaterialProperty *propSrc = pcSrc->mProperties[i]; // search whether we have already a property with this name -> if yes, overwrite it - aiMaterialProperty* prop; - for ( unsigned int q = 0; q < iOldNum; ++q ) { + aiMaterialProperty *prop; + for (unsigned int q = 0; q < iOldNum; ++q) { prop = pcDest->mProperties[q]; - if (prop /* just for safety */ && prop->mKey == propSrc->mKey && prop->mSemantic == propSrc->mSemantic - && prop->mIndex == propSrc->mIndex) { + if (prop /* just for safety */ && prop->mKey == propSrc->mKey && prop->mSemantic == propSrc->mSemantic && prop->mIndex == propSrc->mIndex) { delete prop; // collapse the whole array ... - memmove(&pcDest->mProperties[q],&pcDest->mProperties[q+1],i-q); + memmove(&pcDest->mProperties[q], &pcDest->mProperties[q + 1], i - q); i--; pcDest->mNumProperties--; } @@ -627,6 +604,6 @@ void aiMaterial::CopyPropertyList(aiMaterial* pcDest, prop->mIndex = propSrc->mIndex; prop->mData = new char[propSrc->mDataLength]; - memcpy(prop->mData,propSrc->mData,prop->mDataLength); + memcpy(prop->mData, propSrc->mData, prop->mDataLength); } } diff --git a/code/PostProcessing/ArmaturePopulate.cpp b/code/PostProcessing/ArmaturePopulate.cpp index 9065177b6..97feca31c 100644 --- a/code/PostProcessing/ArmaturePopulate.cpp +++ b/code/PostProcessing/ArmaturePopulate.cpp @@ -82,7 +82,7 @@ void ArmaturePopulate::Execute(aiScene *out) { for (std::pair kvp : bone_stack) { aiBone *bone = kvp.first; aiNode *bone_node = kvp.second; - ASSIMP_LOG_DEBUG_F("active node lookup: ", bone->mName.C_Str()); + ASSIMP_LOG_VERBOSE_DEBUG_F("active node lookup: ", bone->mName.C_Str()); // lcl transform grab - done in generate_nodes :) // bone->mOffsetMatrix = bone_node->mTransformation; @@ -178,7 +178,7 @@ void ArmaturePopulate::BuildBoneStack(aiNode *, if (node == nullptr) { node_stack.clear(); BuildNodeList(root_node, node_stack); - ASSIMP_LOG_DEBUG_F("Resetting bone stack: nullptr element ", bone->mName.C_Str()); + ASSIMP_LOG_VERBOSE_DEBUG_F("Resetting bone stack: nullptr element ", bone->mName.C_Str()); node = GetNodeFromStack(bone->mName, node_stack); @@ -188,7 +188,7 @@ void ArmaturePopulate::BuildBoneStack(aiNode *, } } - ASSIMP_LOG_DEBUG_F("Successfully added bone[", bone->mName.C_Str(), "] to stack and bone node is: ", node->mName.C_Str()); + ASSIMP_LOG_VERBOSE_DEBUG_F("Successfully added bone[", bone->mName.C_Str(), "] to stack and bone node is: ", node->mName.C_Str()); bone_stack.insert(std::pair(bone, node)); } @@ -202,7 +202,7 @@ aiNode *ArmaturePopulate::GetArmatureRoot(aiNode *bone_node, std::vector &bone_list) { while (bone_node) { if (!IsBoneNode(bone_node->mName, bone_list)) { - ASSIMP_LOG_DEBUG_F("GetArmatureRoot() Found valid armature: ", bone_node->mName.C_Str()); + ASSIMP_LOG_VERBOSE_DEBUG_F("GetArmatureRoot() Found valid armature: ", bone_node->mName.C_Str()); return bone_node; } diff --git a/code/PostProcessing/ArmaturePopulate.h b/code/PostProcessing/ArmaturePopulate.h index 8985e1d1d..877d8b0d1 100644 --- a/code/PostProcessing/ArmaturePopulate.h +++ b/code/PostProcessing/ArmaturePopulate.h @@ -109,4 +109,4 @@ public: } // Namespace Assimp -#endif // SCALE_PROCESS_H_ \ No newline at end of file +#endif // SCALE_PROCESS_H_ diff --git a/code/PostProcessing/CalcTangentsProcess.cpp b/code/PostProcessing/CalcTangentsProcess.cpp index 291205bd8..3ad88972d 100644 --- a/code/PostProcessing/CalcTangentsProcess.cpp +++ b/code/PostProcessing/CalcTangentsProcess.cpp @@ -55,54 +55,49 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -CalcTangentsProcess::CalcTangentsProcess() -: configMaxAngle( AI_DEG_TO_RAD(45.f) ) -, configSourceUV( 0 ) { +CalcTangentsProcess::CalcTangentsProcess() : + configMaxAngle(AI_DEG_TO_RAD(45.f)), configSourceUV(0) { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -CalcTangentsProcess::~CalcTangentsProcess() -{ +CalcTangentsProcess::~CalcTangentsProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool CalcTangentsProcess::IsActive( unsigned int pFlags) const -{ +bool CalcTangentsProcess::IsActive(unsigned int pFlags) const { return (pFlags & aiProcess_CalcTangentSpace) != 0; } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void CalcTangentsProcess::SetupProperties(const Importer* pImp) -{ - ai_assert( NULL != pImp ); +void CalcTangentsProcess::SetupProperties(const Importer *pImp) { + ai_assert(nullptr != pImp); // get the current value of the property - configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE,45.f); - configMaxAngle = std::max(std::min(configMaxAngle,45.0f),0.0f); + configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE, 45.f); + configMaxAngle = std::max(std::min(configMaxAngle, 45.0f), 0.0f); configMaxAngle = AI_DEG_TO_RAD(configMaxAngle); - configSourceUV = pImp->GetPropertyInteger(AI_CONFIG_PP_CT_TEXTURE_CHANNEL_INDEX,0); + configSourceUV = pImp->GetPropertyInteger(AI_CONFIG_PP_CT_TEXTURE_CHANNEL_INDEX, 0); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void CalcTangentsProcess::Execute( aiScene* pScene) -{ - ai_assert( NULL != pScene ); +void CalcTangentsProcess::Execute(aiScene *pScene) { + ai_assert(nullptr != pScene); ASSIMP_LOG_DEBUG("CalcTangentsProcess begin"); bool bHas = false; - for ( unsigned int a = 0; a < pScene->mNumMeshes; a++ ) { - if(ProcessMesh( pScene->mMeshes[a],a))bHas = true; + for (unsigned int a = 0; a < pScene->mNumMeshes; a++) { + if (ProcessMesh(pScene->mMeshes[a], a)) bHas = true; } - if ( bHas ) { + if (bHas) { ASSIMP_LOG_INFO("CalcTangentsProcess finished. Tangents have been calculated"); } else { ASSIMP_LOG_DEBUG("CalcTangentsProcess finished"); @@ -111,8 +106,7 @@ void CalcTangentsProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Calculates tangents and bi-tangents for the given mesh -bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) -{ +bool CalcTangentsProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshIndex) { // we assume that the mesh is still in the verbose vertex format where each face has its own set // of vertices and no vertices are shared between faces. Sadly I don't know any quick test to // assert() it here. @@ -124,54 +118,48 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // If the mesh consists of lines and/or points but not of // triangles or higher-order polygons the normal vectors // are undefined. - if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) - { + if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) { ASSIMP_LOG_INFO("Tangents are undefined for line and point meshes"); return false; } // what we can check, though, is if the mesh has normals and texture coordinates. That's a requirement - if( pMesh->mNormals == NULL) - { + if (pMesh->mNormals == nullptr) { ASSIMP_LOG_ERROR("Failed to compute tangents; need normals"); return false; } - if( configSourceUV >= AI_MAX_NUMBER_OF_TEXTURECOORDS || !pMesh->mTextureCoords[configSourceUV] ) - { - ASSIMP_LOG_ERROR((Formatter::format("Failed to compute tangents; need UV data in channel"),configSourceUV)); + if (configSourceUV >= AI_MAX_NUMBER_OF_TEXTURECOORDS || !pMesh->mTextureCoords[configSourceUV]) { + ASSIMP_LOG_ERROR((Formatter::format("Failed to compute tangents; need UV data in channel"), configSourceUV)); return false; } const float angleEpsilon = 0.9999f; - std::vector vertexDone( pMesh->mNumVertices, false); + std::vector vertexDone(pMesh->mNumVertices, false); const float qnan = get_qnan(); // create space for the tangents and bitangents pMesh->mTangents = new aiVector3D[pMesh->mNumVertices]; pMesh->mBitangents = new aiVector3D[pMesh->mNumVertices]; - const aiVector3D* meshPos = pMesh->mVertices; - const aiVector3D* meshNorm = pMesh->mNormals; - const aiVector3D* meshTex = pMesh->mTextureCoords[configSourceUV]; - aiVector3D* meshTang = pMesh->mTangents; - aiVector3D* meshBitang = pMesh->mBitangents; + const aiVector3D *meshPos = pMesh->mVertices; + const aiVector3D *meshNorm = pMesh->mNormals; + const aiVector3D *meshTex = pMesh->mTextureCoords[configSourceUV]; + aiVector3D *meshTang = pMesh->mTangents; + aiVector3D *meshBitang = pMesh->mBitangents; // calculate the tangent and bitangent for every face - for( unsigned int a = 0; a < pMesh->mNumFaces; a++) - { - const aiFace& face = pMesh->mFaces[a]; - if (face.mNumIndices < 3) - { + for (unsigned int a = 0; a < pMesh->mNumFaces; a++) { + const aiFace &face = pMesh->mFaces[a]; + if (face.mNumIndices < 3) { // There are less than three indices, thus the tangent vector // is not defined. We are finished with these vertices now, // their tangent vectors are set to qnan. - for (unsigned int i = 0; i < face.mNumIndices;++i) - { + for (unsigned int i = 0; i < face.mNumIndices; ++i) { unsigned int idx = face.mIndices[i]; - vertexDone [idx] = true; - meshTang [idx] = aiVector3D(qnan); - meshBitang [idx] = aiVector3D(qnan); + vertexDone[idx] = true; + meshTang[idx] = aiVector3D(qnan); + meshBitang[idx] = aiVector3D(qnan); } continue; @@ -190,9 +178,11 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) float tx = meshTex[p2].x - meshTex[p0].x, ty = meshTex[p2].y - meshTex[p0].y; float dirCorrection = (tx * sy - ty * sx) < 0.0f ? -1.0f : 1.0f; // when t1, t2, t3 in same position in UV space, just use default UV direction. - if ( sx * ty == sy * tx ) { - sx = 0.0; sy = 1.0; - tx = 1.0; ty = 0.0; + if (sx * ty == sy * tx) { + sx = 0.0; + sy = 1.0; + tx = 1.0; + ty = 0.0; } // tangent points in the direction where to positive X axis of the texture coord's would point in model space @@ -206,13 +196,14 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) bitangent.z = (w.z * sx - v.z * tx) * dirCorrection; // store for every vertex of that face - for( unsigned int b = 0; b < face.mNumIndices; ++b ) { + for (unsigned int b = 0; b < face.mNumIndices; ++b) { unsigned int p = face.mIndices[b]; // project tangent and bitangent into the plane formed by the vertex' normal aiVector3D localTangent = tangent - meshNorm[p] * (tangent * meshNorm[p]); aiVector3D localBitangent = bitangent - meshNorm[p] * (bitangent * meshNorm[p]); - localTangent.NormalizeSafe(); localBitangent.NormalizeSafe(); + localTangent.NormalizeSafe(); + localBitangent.NormalizeSafe(); // reconstruct tangent/bitangent according to normal and bitangent/tangent when it's infinite or NaN. bool invalid_tangent = is_special_float(localTangent.x) || is_special_float(localTangent.y) || is_special_float(localTangent.z); @@ -228,31 +219,28 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } // and write it into the mesh. - meshTang[ p ] = localTangent; - meshBitang[ p ] = localBitangent; + meshTang[p] = localTangent; + meshBitang[p] = localBitangent; } } - // create a helper to quickly find locally close vertices among the vertex array // FIX: check whether we can reuse the SpatialSort of a previous step - SpatialSort* vertexFinder = NULL; - SpatialSort _vertexFinder; + SpatialSort *vertexFinder = nullptr; + SpatialSort _vertexFinder; float posEpsilon = 10e-6f; - if (shared) - { - std::vector >* avf; - shared->GetProperty(AI_SPP_SPATIAL_SORT,avf); - if (avf) - { - std::pair& blubb = avf->operator [] (meshIndex); + if (shared) { + std::vector> *avf; + shared->GetProperty(AI_SPP_SPATIAL_SORT, avf); + if (avf) { + std::pair &blubb = avf->operator[](meshIndex); vertexFinder = &blubb.first; - posEpsilon = blubb.second;; + posEpsilon = blubb.second; + ; } } - if (!vertexFinder) - { - _vertexFinder.Fill(pMesh->mVertices, pMesh->mNumVertices, sizeof( aiVector3D)); + if (!vertexFinder) { + _vertexFinder.Fill(pMesh->mVertices, pMesh->mNumVertices, sizeof(aiVector3D)); vertexFinder = &_vertexFinder; posEpsilon = ComputePositionEpsilon(pMesh); } @@ -263,56 +251,52 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // in the second pass we now smooth out all tangents and bitangents at the same local position // if they are not too far off. - for( unsigned int a = 0; a < pMesh->mNumVertices; a++) - { - if( vertexDone[a]) + for (unsigned int a = 0; a < pMesh->mNumVertices; a++) { + if (vertexDone[a]) continue; - const aiVector3D& origPos = pMesh->mVertices[a]; - const aiVector3D& origNorm = pMesh->mNormals[a]; - const aiVector3D& origTang = pMesh->mTangents[a]; - const aiVector3D& origBitang = pMesh->mBitangents[a]; - closeVertices.resize( 0 ); + const aiVector3D &origPos = pMesh->mVertices[a]; + const aiVector3D &origNorm = pMesh->mNormals[a]; + const aiVector3D &origTang = pMesh->mTangents[a]; + const aiVector3D &origBitang = pMesh->mBitangents[a]; + closeVertices.resize(0); // find all vertices close to that position - vertexFinder->FindPositions( origPos, posEpsilon, verticesFound); + vertexFinder->FindPositions(origPos, posEpsilon, verticesFound); - closeVertices.reserve (verticesFound.size()+5); - closeVertices.push_back( a); + closeVertices.reserve(verticesFound.size() + 5); + closeVertices.push_back(a); // look among them for other vertices sharing the same normal and a close-enough tangent/bitangent - for( unsigned int b = 0; b < verticesFound.size(); b++) - { + for (unsigned int b = 0; b < verticesFound.size(); b++) { unsigned int idx = verticesFound[b]; - if( vertexDone[idx]) + if (vertexDone[idx]) continue; - if( meshNorm[idx] * origNorm < angleEpsilon) + if (meshNorm[idx] * origNorm < angleEpsilon) continue; - if( meshTang[idx] * origTang < fLimit) + if (meshTang[idx] * origTang < fLimit) continue; - if( meshBitang[idx] * origBitang < fLimit) + if (meshBitang[idx] * origBitang < fLimit) continue; // it's similar enough -> add it to the smoothing group - closeVertices.push_back( idx); + closeVertices.push_back(idx); vertexDone[idx] = true; } // smooth the tangents and bitangents of all vertices that were found to be close enough - aiVector3D smoothTangent( 0, 0, 0), smoothBitangent( 0, 0, 0); - for( unsigned int b = 0; b < closeVertices.size(); ++b) - { - smoothTangent += meshTang[ closeVertices[b] ]; - smoothBitangent += meshBitang[ closeVertices[b] ]; + aiVector3D smoothTangent(0, 0, 0), smoothBitangent(0, 0, 0); + for (unsigned int b = 0; b < closeVertices.size(); ++b) { + smoothTangent += meshTang[closeVertices[b]]; + smoothBitangent += meshBitang[closeVertices[b]]; } smoothTangent.Normalize(); smoothBitangent.Normalize(); // and write it back into all affected tangents - for( unsigned int b = 0; b < closeVertices.size(); ++b) - { - meshTang[ closeVertices[b] ] = smoothTangent; - meshBitang[ closeVertices[b] ] = smoothBitangent; + for (unsigned int b = 0; b < closeVertices.size(); ++b) { + meshTang[closeVertices[b]] = smoothTangent; + meshBitang[closeVertices[b]] = smoothBitangent; } } return true; diff --git a/code/PostProcessing/ConvertToLHProcess.cpp b/code/PostProcessing/ConvertToLHProcess.cpp index 6ca73f10e..47d4eb565 100644 --- a/code/PostProcessing/ConvertToLHProcess.cpp +++ b/code/PostProcessing/ConvertToLHProcess.cpp @@ -49,10 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * better location. */ - #include "ConvertToLHProcess.h" -#include #include +#include #include using namespace Assimp; @@ -62,8 +61,10 @@ using namespace Assimp; namespace { template -void flipUVs(aiMeshType* pMesh) { - if (pMesh == nullptr) { return; } +void flipUVs(aiMeshType *pMesh) { + if (pMesh == nullptr) { + return; + } // mirror texture y coordinate for (unsigned int tcIdx = 0; tcIdx < AI_MAX_NUMBER_OF_TEXTURECOORDS; tcIdx++) { if (!pMesh->HasTextureCoords(tcIdx)) { @@ -80,8 +81,8 @@ void flipUVs(aiMeshType* pMesh) { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -MakeLeftHandedProcess::MakeLeftHandedProcess() -: BaseProcess() { +MakeLeftHandedProcess::MakeLeftHandedProcess() : + BaseProcess() { // empty } @@ -93,40 +94,36 @@ MakeLeftHandedProcess::~MakeLeftHandedProcess() { // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool MakeLeftHandedProcess::IsActive( unsigned int pFlags) const -{ +bool MakeLeftHandedProcess::IsActive(unsigned int pFlags) const { return 0 != (pFlags & aiProcess_MakeLeftHanded); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void MakeLeftHandedProcess::Execute( aiScene* pScene) -{ +void MakeLeftHandedProcess::Execute(aiScene *pScene) { // Check for an existent root node to proceed - ai_assert(pScene->mRootNode != NULL); + ai_assert(pScene->mRootNode != nullptr); ASSIMP_LOG_DEBUG("MakeLeftHandedProcess begin"); // recursively convert all the nodes - ProcessNode( pScene->mRootNode, aiMatrix4x4()); + ProcessNode(pScene->mRootNode, aiMatrix4x4()); // process the meshes accordingly - for ( unsigned int a = 0; a < pScene->mNumMeshes; ++a ) { - ProcessMesh( pScene->mMeshes[ a ] ); + for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) { + ProcessMesh(pScene->mMeshes[a]); } // process the materials accordingly - for ( unsigned int a = 0; a < pScene->mNumMaterials; ++a ) { - ProcessMaterial( pScene->mMaterials[ a ] ); + for (unsigned int a = 0; a < pScene->mNumMaterials; ++a) { + ProcessMaterial(pScene->mMaterials[a]); } // transform all animation channels as well - for( unsigned int a = 0; a < pScene->mNumAnimations; a++) - { - aiAnimation* anim = pScene->mAnimations[a]; - for( unsigned int b = 0; b < anim->mNumChannels; b++) - { - aiNodeAnim* nodeAnim = anim->mChannels[b]; - ProcessAnimation( nodeAnim); + for (unsigned int a = 0; a < pScene->mNumAnimations; a++) { + aiAnimation *anim = pScene->mAnimations[a]; + for (unsigned int b = 0; b < anim->mNumChannels; b++) { + aiNodeAnim *nodeAnim = anim->mChannels[b]; + ProcessAnimation(nodeAnim); } } ASSIMP_LOG_DEBUG("MakeLeftHandedProcess finished"); @@ -134,8 +131,7 @@ void MakeLeftHandedProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Recursively converts a node, all of its children and all of its meshes -void MakeLeftHandedProcess::ProcessNode( aiNode* pNode, const aiMatrix4x4& pParentGlobalRotation) -{ +void MakeLeftHandedProcess::ProcessNode(aiNode *pNode, const aiMatrix4x4 &pParentGlobalRotation) { // mirror all base vectors at the local Z axis pNode->mTransformation.c1 = -pNode->mTransformation.c1; pNode->mTransformation.c2 = -pNode->mTransformation.c2; @@ -150,43 +146,38 @@ void MakeLeftHandedProcess::ProcessNode( aiNode* pNode, const aiMatrix4x4& pPare pNode->mTransformation.d3 = -pNode->mTransformation.d3; // useless, but anyways... // continue for all children - for( size_t a = 0; a < pNode->mNumChildren; ++a ) { - ProcessNode( pNode->mChildren[ a ], pParentGlobalRotation * pNode->mTransformation ); + for (size_t a = 0; a < pNode->mNumChildren; ++a) { + ProcessNode(pNode->mChildren[a], pParentGlobalRotation * pNode->mTransformation); } } // ------------------------------------------------------------------------------------------------ // Converts a single mesh to left handed coordinates. -void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) { - if ( nullptr == pMesh ) { - ASSIMP_LOG_ERROR( "Nullptr to mesh found." ); +void MakeLeftHandedProcess::ProcessMesh(aiMesh *pMesh) { + if (nullptr == pMesh) { + ASSIMP_LOG_ERROR("Nullptr to mesh found."); return; } // mirror positions, normals and stuff along the Z axis - for( size_t a = 0; a < pMesh->mNumVertices; ++a) - { + for (size_t a = 0; a < pMesh->mNumVertices; ++a) { pMesh->mVertices[a].z *= -1.0f; if (pMesh->HasNormals()) { pMesh->mNormals[a].z *= -1.0f; } - if( pMesh->HasTangentsAndBitangents()) - { + if (pMesh->HasTangentsAndBitangents()) { pMesh->mTangents[a].z *= -1.0f; pMesh->mBitangents[a].z *= -1.0f; } } // mirror anim meshes positions, normals and stuff along the Z axis - for (size_t m = 0; m < pMesh->mNumAnimMeshes; ++m) - { - for (size_t a = 0; a < pMesh->mAnimMeshes[m]->mNumVertices; ++a) - { + for (size_t m = 0; m < pMesh->mNumAnimMeshes; ++m) { + for (size_t a = 0; a < pMesh->mAnimMeshes[m]->mNumVertices; ++a) { pMesh->mAnimMeshes[m]->mVertices[a].z *= -1.0f; if (pMesh->mAnimMeshes[m]->HasNormals()) { pMesh->mAnimMeshes[m]->mNormals[a].z *= -1.0f; } - if (pMesh->mAnimMeshes[m]->HasTangentsAndBitangents()) - { + if (pMesh->mAnimMeshes[m]->HasTangentsAndBitangents()) { pMesh->mAnimMeshes[m]->mTangents[a].z *= -1.0f; pMesh->mAnimMeshes[m]->mBitangents[a].z *= -1.0f; } @@ -194,9 +185,8 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) { } // mirror offset matrices of all bones - for( size_t a = 0; a < pMesh->mNumBones; ++a) - { - aiBone* bone = pMesh->mBones[a]; + for (size_t a = 0; a < pMesh->mNumBones; ++a) { + aiBone *bone = pMesh->mBones[a]; bone->mOffsetMatrix.a3 = -bone->mOffsetMatrix.a3; bone->mOffsetMatrix.b3 = -bone->mOffsetMatrix.b3; bone->mOffsetMatrix.d3 = -bone->mOffsetMatrix.d3; @@ -206,29 +196,28 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) { } // mirror bitangents as well as they're derived from the texture coords - if( pMesh->HasTangentsAndBitangents()) - { - for( unsigned int a = 0; a < pMesh->mNumVertices; a++) + if (pMesh->HasTangentsAndBitangents()) { + for (unsigned int a = 0; a < pMesh->mNumVertices; a++) pMesh->mBitangents[a] *= -1.0f; } } // ------------------------------------------------------------------------------------------------ // Converts a single material to left handed coordinates. -void MakeLeftHandedProcess::ProcessMaterial( aiMaterial* _mat) { - if ( nullptr == _mat ) { - ASSIMP_LOG_ERROR( "Nullptr to aiMaterial found." ); +void MakeLeftHandedProcess::ProcessMaterial(aiMaterial *_mat) { + if (nullptr == _mat) { + ASSIMP_LOG_ERROR("Nullptr to aiMaterial found."); return; } - aiMaterial* mat = (aiMaterial*)_mat; - for (unsigned int a = 0; a < mat->mNumProperties;++a) { - aiMaterialProperty* prop = mat->mProperties[a]; + aiMaterial *mat = (aiMaterial *)_mat; + for (unsigned int a = 0; a < mat->mNumProperties; ++a) { + aiMaterialProperty *prop = mat->mProperties[a]; // Mapping axis for UV mappings? - if (!::strcmp( prop->mKey.data, "$tex.mapaxis")) { - ai_assert( prop->mDataLength >= sizeof(aiVector3D)); /* something is wrong with the validation if we end up here */ - aiVector3D* pff = (aiVector3D*)prop->mData; + if (!::strcmp(prop->mKey.data, "$tex.mapaxis")) { + ai_assert(prop->mDataLength >= sizeof(aiVector3D)); // something is wrong with the validation if we end up here + aiVector3D *pff = (aiVector3D *)prop->mData; pff->z *= -1.f; } } @@ -236,15 +225,13 @@ void MakeLeftHandedProcess::ProcessMaterial( aiMaterial* _mat) { // ------------------------------------------------------------------------------------------------ // Converts the given animation to LH coordinates. -void MakeLeftHandedProcess::ProcessAnimation( aiNodeAnim* pAnim) -{ +void MakeLeftHandedProcess::ProcessAnimation(aiNodeAnim *pAnim) { // position keys - for( unsigned int a = 0; a < pAnim->mNumPositionKeys; a++) + for (unsigned int a = 0; a < pAnim->mNumPositionKeys; a++) pAnim->mPositionKeys[a].mValue.z *= -1.0f; // rotation keys - for( unsigned int a = 0; a < pAnim->mNumRotationKeys; a++) - { + for (unsigned int a = 0; a < pAnim->mNumRotationKeys; a++) { /* That's the safe version, but the float errors add up. So we try the short version instead aiMatrix3x3 rotmat = pAnim->mRotationKeys[a].mValue.GetMatrix(); rotmat.a3 = -rotmat.a3; rotmat.b3 = -rotmat.b3; @@ -258,55 +245,50 @@ void MakeLeftHandedProcess::ProcessAnimation( aiNodeAnim* pAnim) } #endif // !! ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS -#ifndef ASSIMP_BUILD_NO_FLIPUVS_PROCESS +#ifndef ASSIMP_BUILD_NO_FLIPUVS_PROCESS // # FlipUVsProcess // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -FlipUVsProcess::FlipUVsProcess() -{} +FlipUVsProcess::FlipUVsProcess() {} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FlipUVsProcess::~FlipUVsProcess() -{} +FlipUVsProcess::~FlipUVsProcess() {} // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool FlipUVsProcess::IsActive( unsigned int pFlags) const -{ +bool FlipUVsProcess::IsActive(unsigned int pFlags) const { return 0 != (pFlags & aiProcess_FlipUVs); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void FlipUVsProcess::Execute( aiScene* pScene) -{ +void FlipUVsProcess::Execute(aiScene *pScene) { ASSIMP_LOG_DEBUG("FlipUVsProcess begin"); - for (unsigned int i = 0; i < pScene->mNumMeshes;++i) + for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) ProcessMesh(pScene->mMeshes[i]); - for (unsigned int i = 0; i < pScene->mNumMaterials;++i) + for (unsigned int i = 0; i < pScene->mNumMaterials; ++i) ProcessMaterial(pScene->mMaterials[i]); ASSIMP_LOG_DEBUG("FlipUVsProcess finished"); } // ------------------------------------------------------------------------------------------------ // Converts a single material -void FlipUVsProcess::ProcessMaterial (aiMaterial* _mat) -{ - aiMaterial* mat = (aiMaterial*)_mat; - for (unsigned int a = 0; a < mat->mNumProperties;++a) { - aiMaterialProperty* prop = mat->mProperties[a]; - if( !prop ) { - ASSIMP_LOG_DEBUG( "Property is null" ); +void FlipUVsProcess::ProcessMaterial(aiMaterial *_mat) { + aiMaterial *mat = (aiMaterial *)_mat; + for (unsigned int a = 0; a < mat->mNumProperties; ++a) { + aiMaterialProperty *prop = mat->mProperties[a]; + if (!prop) { + ASSIMP_LOG_VERBOSE_DEBUG("Property is null"); continue; } // UV transformation key? - if (!::strcmp( prop->mKey.data, "$tex.uvtrafo")) { - ai_assert( prop->mDataLength >= sizeof(aiUVTransform)); /* something is wrong with the validation if we end up here */ - aiUVTransform* uv = (aiUVTransform*)prop->mData; + if (!::strcmp(prop->mKey.data, "$tex.uvtrafo")) { + ai_assert(prop->mDataLength >= sizeof(aiUVTransform)); // something is wrong with the validation if we end up here + aiUVTransform *uv = (aiUVTransform *)prop->mData; // just flip it, that's everything uv->mTranslation.y *= -1.f; @@ -317,8 +299,7 @@ void FlipUVsProcess::ProcessMaterial (aiMaterial* _mat) // ------------------------------------------------------------------------------------------------ // Converts a single mesh -void FlipUVsProcess::ProcessMesh( aiMesh* pMesh) -{ +void FlipUVsProcess::ProcessMesh(aiMesh *pMesh) { flipUVs(pMesh); for (unsigned int idx = 0; idx < pMesh->mNumAnimMeshes; idx++) { flipUVs(pMesh->mAnimMeshes[idx]); @@ -326,44 +307,38 @@ void FlipUVsProcess::ProcessMesh( aiMesh* pMesh) } #endif // !ASSIMP_BUILD_NO_FLIPUVS_PROCESS -#ifndef ASSIMP_BUILD_NO_FLIPWINDING_PROCESS +#ifndef ASSIMP_BUILD_NO_FLIPWINDING_PROCESS // # FlipWindingOrderProcess // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -FlipWindingOrderProcess::FlipWindingOrderProcess() -{} +FlipWindingOrderProcess::FlipWindingOrderProcess() {} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FlipWindingOrderProcess::~FlipWindingOrderProcess() -{} +FlipWindingOrderProcess::~FlipWindingOrderProcess() {} // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool FlipWindingOrderProcess::IsActive( unsigned int pFlags) const -{ +bool FlipWindingOrderProcess::IsActive(unsigned int pFlags) const { return 0 != (pFlags & aiProcess_FlipWindingOrder); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void FlipWindingOrderProcess::Execute( aiScene* pScene) -{ +void FlipWindingOrderProcess::Execute(aiScene *pScene) { ASSIMP_LOG_DEBUG("FlipWindingOrderProcess begin"); - for (unsigned int i = 0; i < pScene->mNumMeshes;++i) + for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) ProcessMesh(pScene->mMeshes[i]); ASSIMP_LOG_DEBUG("FlipWindingOrderProcess finished"); } // ------------------------------------------------------------------------------------------------ // Converts a single mesh -void FlipWindingOrderProcess::ProcessMesh( aiMesh* pMesh) -{ +void FlipWindingOrderProcess::ProcessMesh(aiMesh *pMesh) { // invert the order of all faces in this mesh - for( unsigned int a = 0; a < pMesh->mNumFaces; a++) - { - aiFace& face = pMesh->mFaces[a]; + for (unsigned int a = 0; a < pMesh->mNumFaces; a++) { + aiFace &face = pMesh->mFaces[a]; for (unsigned int b = 0; b < face.mNumIndices / 2; b++) { std::swap(face.mIndices[b], face.mIndices[face.mNumIndices - 1 - b]); } @@ -371,39 +346,34 @@ void FlipWindingOrderProcess::ProcessMesh( aiMesh* pMesh) // invert the order of all components in this mesh anim meshes for (unsigned int m = 0; m < pMesh->mNumAnimMeshes; m++) { - aiAnimMesh* animMesh = pMesh->mAnimMeshes[m]; + aiAnimMesh *animMesh = pMesh->mAnimMeshes[m]; unsigned int numVertices = animMesh->mNumVertices; if (animMesh->HasPositions()) { - for (unsigned int a = 0; a < numVertices; a++) - { + for (unsigned int a = 0; a < numVertices; a++) { std::swap(animMesh->mVertices[a], animMesh->mVertices[numVertices - 1 - a]); } } if (animMesh->HasNormals()) { - for (unsigned int a = 0; a < numVertices; a++) - { + for (unsigned int a = 0; a < numVertices; a++) { std::swap(animMesh->mNormals[a], animMesh->mNormals[numVertices - 1 - a]); } } for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) { if (animMesh->HasTextureCoords(i)) { - for (unsigned int a = 0; a < numVertices; a++) - { + for (unsigned int a = 0; a < numVertices; a++) { std::swap(animMesh->mTextureCoords[i][a], animMesh->mTextureCoords[i][numVertices - 1 - a]); } } } if (animMesh->HasTangentsAndBitangents()) { - for (unsigned int a = 0; a < numVertices; a++) - { + for (unsigned int a = 0; a < numVertices; a++) { std::swap(animMesh->mTangents[a], animMesh->mTangents[numVertices - 1 - a]); std::swap(animMesh->mBitangents[a], animMesh->mBitangents[numVertices - 1 - a]); } } for (unsigned int v = 0; v < AI_MAX_NUMBER_OF_COLOR_SETS; v++) { if (animMesh->HasVertexColors(v)) { - for (unsigned int a = 0; a < numVertices; a++) - { + for (unsigned int a = 0; a < numVertices; a++) { std::swap(animMesh->mColors[v][a], animMesh->mColors[v][numVertices - 1 - a]); } } diff --git a/code/PostProcessing/DeboneProcess.cpp b/code/PostProcessing/DeboneProcess.cpp index 9d6313f71..4d9cb6ab6 100644 --- a/code/PostProcessing/DeboneProcess.cpp +++ b/code/PostProcessing/DeboneProcess.cpp @@ -414,7 +414,8 @@ void DeboneProcess::UpdateNode(aiNode* pNode) const } if( pNode->mNumMeshes > 0 ) { - delete [] pNode->mMeshes; pNode->mMeshes = NULL; + delete[] pNode->mMeshes; + pNode->mMeshes = nullptr; } pNode->mNumMeshes = static_cast(newMeshList.size()); diff --git a/code/PostProcessing/DropFaceNormalsProcess.cpp b/code/PostProcessing/DropFaceNormalsProcess.cpp index 1d7cf33b0..170dedb29 100644 --- a/code/PostProcessing/DropFaceNormalsProcess.cpp +++ b/code/PostProcessing/DropFaceNormalsProcess.cpp @@ -98,12 +98,14 @@ void DropFaceNormalsProcess::Execute( aiScene* pScene) { // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -bool DropFaceNormalsProcess::DropMeshFaceNormals (aiMesh* pMesh) { - if (NULL == pMesh->mNormals) { +bool DropFaceNormalsProcess::DropMeshFaceNormals (aiMesh* mesh) { + ai_assert(nullptr != mesh); + + if (nullptr == mesh->mNormals) { return false; } - delete[] pMesh->mNormals; - pMesh->mNormals = nullptr; + delete[] mesh->mNormals; + mesh->mNormals = nullptr; return true; } diff --git a/code/PostProcessing/FindDegenerates.cpp b/code/PostProcessing/FindDegenerates.cpp index dfdfec6cc..e5defdeb0 100644 --- a/code/PostProcessing/FindDegenerates.cpp +++ b/code/PostProcessing/FindDegenerates.cpp @@ -289,7 +289,7 @@ evil_jump_outside: if (!mesh->mNumFaces) { //The whole mesh consists of degenerated faces //signal upward, that this mesh should be deleted. - ASSIMP_LOG_DEBUG("FindDegeneratesProcess removed a mesh full of degenerated primitives"); + ASSIMP_LOG_VERBOSE_DEBUG("FindDegeneratesProcess removed a mesh full of degenerated primitives"); return true; } } diff --git a/code/PostProcessing/FindInstancesProcess.cpp b/code/PostProcessing/FindInstancesProcess.cpp index 9a4c6f53b..41f78a9eb 100644 --- a/code/PostProcessing/FindInstancesProcess.cpp +++ b/code/PostProcessing/FindInstancesProcess.cpp @@ -243,7 +243,7 @@ void FindInstancesProcess::Execute( aiScene* pScene) // Delete the instanced mesh, we don't need it anymore delete inst; - pScene->mMeshes[i] = NULL; + pScene->mMeshes[i] = nullptr; break; } } @@ -256,7 +256,7 @@ void FindInstancesProcess::Execute( aiScene* pScene) ai_assert(0 != numMeshesOut); if (numMeshesOut != pScene->mNumMeshes) { - // Collapse the meshes array by removing all NULL entries + // Collapse the meshes array by removing all nullptr entries for (unsigned int real = 0, i = 0; real < numMeshesOut; ++i) { if (pScene->mMeshes[i]) pScene->mMeshes[real++] = pScene->mMeshes[i]; diff --git a/code/PostProcessing/FindInvalidDataProcess.cpp b/code/PostProcessing/FindInvalidDataProcess.cpp index 99be52fa4..dc2b3c548 100644 --- a/code/PostProcessing/FindInvalidDataProcess.cpp +++ b/code/PostProcessing/FindInvalidDataProcess.cpp @@ -45,11 +45,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS // internal headers -# include "FindInvalidDataProcess.h" -# include "ProcessHelper.h" +#include "FindInvalidDataProcess.h" +#include "ProcessHelper.h" -# include -# include +#include +#include using namespace Assimp; @@ -97,7 +97,7 @@ void UpdateMeshReferences(aiNode *node, const std::vector &meshMap node->mNumMeshes = out; if (0 == out) { delete[] node->mMeshes; - node->mMeshes = NULL; + node->mMeshes = nullptr; } } // recursively update all children @@ -124,9 +124,10 @@ void FindInvalidDataProcess::Execute(aiScene *pScene) { if (2 == result) { // remove this mesh delete pScene->mMeshes[a]; - AI_DEBUG_INVALIDATE_PTR(pScene->mMeshes[a]); + pScene->mMeshes[a] = nullptr; meshMapping[a] = UINT_MAX; + out = true; continue; } @@ -201,7 +202,7 @@ inline bool ProcessArray(T *&in, unsigned int num, const char *name, if (err) { ASSIMP_LOG_ERROR_F("FindInvalidDataProcess fails on mesh ", name, ": ", err); delete[] in; - in = NULL; + in = nullptr; return true; } return false; @@ -345,7 +346,7 @@ int FindInvalidDataProcess::ProcessMesh(aiMesh *pMesh) { // delete all subsequent texture coordinate sets. for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { delete[] pMesh->mTextureCoords[a]; - pMesh->mTextureCoords[a] = NULL; + pMesh->mTextureCoords[a] = nullptr; pMesh->mNumUVComponents[a] = 0; } @@ -391,14 +392,14 @@ int FindInvalidDataProcess::ProcessMesh(aiMesh *pMesh) { // Process mesh tangents if (pMesh->mTangents && ProcessArray(pMesh->mTangents, pMesh->mNumVertices, "tangents", dirtyMask)) { delete[] pMesh->mBitangents; - pMesh->mBitangents = NULL; + pMesh->mBitangents = nullptr; ret = true; } // Process mesh bitangents if (pMesh->mBitangents && ProcessArray(pMesh->mBitangents, pMesh->mNumVertices, "bitangents", dirtyMask)) { delete[] pMesh->mTangents; - pMesh->mTangents = NULL; + pMesh->mTangents = nullptr; ret = true; } } diff --git a/code/PostProcessing/GenFaceNormalsProcess.cpp b/code/PostProcessing/GenFaceNormalsProcess.cpp index 08a1d9aae..b610ef830 100644 --- a/code/PostProcessing/GenFaceNormalsProcess.cpp +++ b/code/PostProcessing/GenFaceNormalsProcess.cpp @@ -45,41 +45,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * normals for all imported faces. */ - #include "GenFaceNormalsProcess.h" +#include #include +#include #include #include -#include -#include - using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -GenFaceNormalsProcess::GenFaceNormalsProcess() -{ +GenFaceNormalsProcess::GenFaceNormalsProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -GenFaceNormalsProcess::~GenFaceNormalsProcess() -{ +GenFaceNormalsProcess::~GenFaceNormalsProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool GenFaceNormalsProcess::IsActive( unsigned int pFlags) const { +bool GenFaceNormalsProcess::IsActive(unsigned int pFlags) const { force_ = (pFlags & aiProcess_ForceGenNormals) != 0; - return (pFlags & aiProcess_GenNormals) != 0; + return (pFlags & aiProcess_GenNormals) != 0; } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void GenFaceNormalsProcess::Execute( aiScene* pScene) { +void GenFaceNormalsProcess::Execute(aiScene *pScene) { ASSIMP_LOG_DEBUG("GenFaceNormalsProcess begin"); if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) { @@ -87,33 +83,35 @@ void GenFaceNormalsProcess::Execute( aiScene* pScene) { } bool bHas = false; - for( unsigned int a = 0; a < pScene->mNumMeshes; a++) { - if(this->GenMeshFaceNormals( pScene->mMeshes[a])) { + for (unsigned int a = 0; a < pScene->mNumMeshes; a++) { + if (this->GenMeshFaceNormals(pScene->mMeshes[a])) { bHas = true; } } - if (bHas) { + if (bHas) { ASSIMP_LOG_INFO("GenFaceNormalsProcess finished. " - "Face normals have been calculated"); + "Face normals have been calculated"); } else { ASSIMP_LOG_DEBUG("GenFaceNormalsProcess finished. " - "Normals are already there"); + "Normals are already there"); } } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh) -{ - if (NULL != pMesh->mNormals) { - if (force_) delete[] pMesh->mNormals; - else return false; +bool GenFaceNormalsProcess::GenMeshFaceNormals(aiMesh *pMesh) { + if (nullptr != pMesh->mNormals) { + if (force_) { + delete[] pMesh->mNormals; + } else { + return false; + } } // If the mesh consists of lines and/or points but not of // triangles or higher-order polygons the normal vectors // are undefined. - if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) { + if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) { ASSIMP_LOG_INFO("Normal vectors are undefined for line and point meshes"); return false; } @@ -123,22 +121,22 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh) const float qnan = get_qnan(); // iterate through all faces and compute per-face normals but store them per-vertex. - for( unsigned int a = 0; a < pMesh->mNumFaces; a++) { - const aiFace& face = pMesh->mFaces[a]; - if (face.mNumIndices < 3) { + for (unsigned int a = 0; a < pMesh->mNumFaces; a++) { + const aiFace &face = pMesh->mFaces[a]; + if (face.mNumIndices < 3) { // either a point or a line -> no well-defined normal vector - for (unsigned int i = 0;i < face.mNumIndices;++i) { + for (unsigned int i = 0; i < face.mNumIndices; ++i) { pMesh->mNormals[face.mIndices[i]] = aiVector3D(qnan); } continue; } - const aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]]; - const aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]]; - const aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices-1]]; + const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]]; + const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]]; + const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]]; const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe(); - for (unsigned int i = 0;i < face.mNumIndices;++i) { + for (unsigned int i = 0; i < face.mNumIndices; ++i) { pMesh->mNormals[face.mIndices[i]] = vNor; } } diff --git a/code/PostProcessing/GenVertexNormalsProcess.cpp b/code/PostProcessing/GenVertexNormalsProcess.cpp index 1df333410..72031153b 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.cpp +++ b/code/PostProcessing/GenVertexNormalsProcess.cpp @@ -45,8 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * normals for all imported faces. */ - - // internal headers #include "GenVertexNormalsProcess.h" #include "ProcessHelper.h" @@ -57,8 +55,8 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -GenVertexNormalsProcess::GenVertexNormalsProcess() -: configMaxAngle( AI_DEG_TO_RAD( 175.f ) ) { +GenVertexNormalsProcess::GenVertexNormalsProcess() : + configMaxAngle(AI_DEG_TO_RAD(175.f)) { // empty } @@ -70,25 +68,22 @@ GenVertexNormalsProcess::~GenVertexNormalsProcess() { // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool GenVertexNormalsProcess::IsActive( unsigned int pFlags) const -{ +bool GenVertexNormalsProcess::IsActive(unsigned int pFlags) const { force_ = (pFlags & aiProcess_ForceGenNormals) != 0; return (pFlags & aiProcess_GenSmoothNormals) != 0; } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void GenVertexNormalsProcess::SetupProperties(const Importer* pImp) -{ +void GenVertexNormalsProcess::SetupProperties(const Importer *pImp) { // Get the current value of the AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE property - configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,(ai_real)175.0); - configMaxAngle = AI_DEG_TO_RAD(std::max(std::min(configMaxAngle,(ai_real)175.0),(ai_real)0.0)); + configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, (ai_real)175.0); + configMaxAngle = AI_DEG_TO_RAD(std::max(std::min(configMaxAngle, (ai_real)175.0), (ai_real)0.0)); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void GenVertexNormalsProcess::Execute( aiScene* pScene) -{ +void GenVertexNormalsProcess::Execute(aiScene *pScene) { ASSIMP_LOG_DEBUG("GenVertexNormalsProcess begin"); if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) { @@ -96,34 +91,34 @@ void GenVertexNormalsProcess::Execute( aiScene* pScene) } bool bHas = false; - for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) { - if(GenMeshVertexNormals( pScene->mMeshes[a],a)) + for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) { + if (GenMeshVertexNormals(pScene->mMeshes[a], a)) bHas = true; } - if (bHas) { + if (bHas) { ASSIMP_LOG_INFO("GenVertexNormalsProcess finished. " - "Vertex normals have been calculated"); + "Vertex normals have been calculated"); } else { ASSIMP_LOG_DEBUG("GenVertexNormalsProcess finished. " - "Normals are already there"); + "Normals are already there"); } } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int meshIndex) -{ - if (NULL != pMesh->mNormals) { - if (force_) delete[] pMesh->mNormals; - else return false; +bool GenVertexNormalsProcess::GenMeshVertexNormals(aiMesh *pMesh, unsigned int meshIndex) { + if (nullptr != pMesh->mNormals) { + if (force_) + delete[] pMesh->mNormals; + else + return false; } // If the mesh consists of lines and/or points but not of // triangles or higher-order polygons the normal vectors // are undefined. - if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) - { + if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) { ASSIMP_LOG_INFO("Normal vectors are undefined for line and point meshes"); return false; } @@ -133,75 +128,71 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; // Compute per-face normals but store them per-vertex - for( unsigned int a = 0; a < pMesh->mNumFaces; a++) - { - const aiFace& face = pMesh->mFaces[a]; - if (face.mNumIndices < 3) - { + for (unsigned int a = 0; a < pMesh->mNumFaces; a++) { + const aiFace &face = pMesh->mFaces[a]; + if (face.mNumIndices < 3) { // either a point or a line -> no normal vector - for (unsigned int i = 0;i < face.mNumIndices;++i) { + for (unsigned int i = 0; i < face.mNumIndices; ++i) { pMesh->mNormals[face.mIndices[i]] = aiVector3D(qnan); } continue; } - const aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]]; - const aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]]; - const aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices-1]]; + const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]]; + const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]]; + const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]]; const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe(); - for (unsigned int i = 0;i < face.mNumIndices;++i) { + for (unsigned int i = 0; i < face.mNumIndices; ++i) { pMesh->mNormals[face.mIndices[i]] = vNor; } } // Set up a SpatialSort to quickly find all vertices close to a given position // check whether we can reuse the SpatialSort of a previous step. - SpatialSort* vertexFinder = NULL; - SpatialSort _vertexFinder; - ai_real posEpsilon = ai_real( 1e-5 ); + SpatialSort *vertexFinder = nullptr; + SpatialSort _vertexFinder; + ai_real posEpsilon = ai_real(1e-5); if (shared) { - std::vector >* avf; - shared->GetProperty(AI_SPP_SPATIAL_SORT,avf); - if (avf) - { - std::pair& blubb = avf->operator [] (meshIndex); + std::vector> *avf; + shared->GetProperty(AI_SPP_SPATIAL_SORT, avf); + if (avf) { + std::pair &blubb = avf->operator[](meshIndex); vertexFinder = &blubb.first; posEpsilon = blubb.second; } } - if (!vertexFinder) { - _vertexFinder.Fill(pMesh->mVertices, pMesh->mNumVertices, sizeof( aiVector3D)); + if (!vertexFinder) { + _vertexFinder.Fill(pMesh->mVertices, pMesh->mNumVertices, sizeof(aiVector3D)); vertexFinder = &_vertexFinder; posEpsilon = ComputePositionEpsilon(pMesh); } std::vector verticesFound; - aiVector3D* pcNew = new aiVector3D[pMesh->mNumVertices]; + aiVector3D *pcNew = new aiVector3D[pMesh->mNumVertices]; - if (configMaxAngle >= AI_DEG_TO_RAD( 175.f )) { + if (configMaxAngle >= AI_DEG_TO_RAD(175.f)) { // There is no angle limit. Thus all vertices with positions close // to each other will receive the same vertex normal. This allows us // to optimize the whole algorithm a little bit ... - std::vector abHad(pMesh->mNumVertices,false); - for (unsigned int i = 0; i < pMesh->mNumVertices;++i) { + std::vector abHad(pMesh->mNumVertices, false); + for (unsigned int i = 0; i < pMesh->mNumVertices; ++i) { if (abHad[i]) { continue; } // Get all vertices that share this one ... - vertexFinder->FindPositions( pMesh->mVertices[i], posEpsilon, verticesFound); + vertexFinder->FindPositions(pMesh->mVertices[i], posEpsilon, verticesFound); aiVector3D pcNor; for (unsigned int a = 0; a < verticesFound.size(); ++a) { - const aiVector3D& v = pMesh->mNormals[verticesFound[a]]; - if (is_not_qnan(v.x))pcNor += v; + const aiVector3D &v = pMesh->mNormals[verticesFound[a]]; + if (is_not_qnan(v.x)) pcNor += v; } pcNor.NormalizeSafe(); // Write the smoothed normal back to all affected normals - for (unsigned int a = 0; a < verticesFound.size(); ++a) - { + for (unsigned int a = 0; a < verticesFound.size(); ++a) { unsigned int vidx = verticesFound[a]; pcNew[vidx] = pcNor; abHad[vidx] = true; @@ -210,11 +201,11 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int } // Slower code path if a smooth angle is set. There are many ways to achieve // the effect, this one is the most straightforward one. - else { + else { const ai_real fLimit = std::cos(configMaxAngle); - for (unsigned int i = 0; i < pMesh->mNumVertices;++i) { + for (unsigned int i = 0; i < pMesh->mNumVertices; ++i) { // Get all vertices that share this one ... - vertexFinder->FindPositions( pMesh->mVertices[i] , posEpsilon, verticesFound); + vertexFinder->FindPositions(pMesh->mVertices[i], posEpsilon, verticesFound); aiVector3D vr = pMesh->mNormals[i]; diff --git a/code/PostProcessing/ImproveCacheLocality.cpp b/code/PostProcessing/ImproveCacheLocality.cpp index d72d15d3a..bab1754cd 100644 --- a/code/PostProcessing/ImproveCacheLocality.cpp +++ b/code/PostProcessing/ImproveCacheLocality.cpp @@ -355,7 +355,7 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me // very intense verbose logging ... prepare for much text if there are many meshes if ( DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) { - ASSIMP_LOG_DEBUG_F("Mesh %u | ACMR in: ", meshNum, " out: ", fACMR, " | ~", fACMR2, ((fACMR - fACMR2) / fACMR) * 100.f); + ASSIMP_LOG_VERBOSE_DEBUG_F("Mesh %u | ACMR in: ", meshNum, " out: ", fACMR, " | ~", fACMR2, ((fACMR - fACMR2) / fACMR) * 100.f); } fACMR2 *= pMesh->mNumFaces; diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 070c9636f..5f8139536 100644 --- a/code/PostProcessing/JoinVerticesProcess.cpp +++ b/code/PostProcessing/JoinVerticesProcess.cpp @@ -266,7 +266,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) std::vector replaceIndex( pMesh->mNumVertices, 0xffffffff); // float posEpsilonSqr; - SpatialSort* vertexFinder = NULL; + SpatialSort *vertexFinder = nullptr; SpatialSort _vertexFinder; typedef std::pair SpatPair; @@ -373,7 +373,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } if (!DefaultLogger::isNullLogger() && DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) { - ASSIMP_LOG_DEBUG_F( + ASSIMP_LOG_VERBOSE_DEBUG_F( "Mesh ",meshIndex, " (", (pMesh->mName.length ? pMesh->mName.data : "unnamed"), @@ -408,7 +408,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) std::vector newWeights; newWeights.reserve( bone->mNumWeights); - if ( NULL != bone->mWeights ) { + if (nullptr != bone->mWeights) { for ( unsigned int b = 0; b < bone->mNumWeights; b++ ) { const aiVertexWeight& ow = bone->mWeights[ b ]; // if the vertex is a unique one, translate it @@ -420,7 +420,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } } } else { - ASSIMP_LOG_ERROR( "X-Export: aiBone shall contain weights, but pointer to them is NULL." ); + ASSIMP_LOG_ERROR( "X-Export: aiBone shall contain weights, but pointer to them is nullptr." ); } if (newWeights.size() > 0) { diff --git a/code/PostProcessing/LimitBoneWeightsProcess.cpp b/code/PostProcessing/LimitBoneWeightsProcess.cpp index 5b8934159..b4f0b48d8 100644 --- a/code/PostProcessing/LimitBoneWeightsProcess.cpp +++ b/code/PostProcessing/LimitBoneWeightsProcess.cpp @@ -114,6 +114,10 @@ void LimitBoneWeightsProcess::ProcessMesh(aiMesh* pMesh) for (unsigned int w = 0; w < bone->mNumWeights; ++w) { const aiVertexWeight& vw = bone->mWeights[w]; + + if (vertexWeights.size() <= vw.mVertexId) + continue; + vertexWeights[vw.mVertexId].push_back(Weight(b, vw.mWeight)); maxVertexWeights = std::max(maxVertexWeights, vertexWeights[vw.mVertexId].size()); } diff --git a/code/PostProcessing/MakeVerboseFormat.cpp b/code/PostProcessing/MakeVerboseFormat.cpp index 3928a5b27..cff5ed5e5 100644 --- a/code/PostProcessing/MakeVerboseFormat.cpp +++ b/code/PostProcessing/MakeVerboseFormat.cpp @@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Implementation of the post processing step "MakeVerboseFormat" */ - #include "MakeVerboseFormat.h" #include #include @@ -51,26 +50,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; // ------------------------------------------------------------------------------------------------ -MakeVerboseFormatProcess::MakeVerboseFormatProcess() -{ +MakeVerboseFormatProcess::MakeVerboseFormatProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ -MakeVerboseFormatProcess::~MakeVerboseFormatProcess() -{ +MakeVerboseFormatProcess::~MakeVerboseFormatProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void MakeVerboseFormatProcess::Execute( aiScene* pScene) -{ - ai_assert(NULL != pScene); +void MakeVerboseFormatProcess::Execute(aiScene *pScene) { + ai_assert(nullptr != pScene); ASSIMP_LOG_DEBUG("MakeVerboseFormatProcess begin"); bool bHas = false; - for( unsigned int a = 0; a < pScene->mNumMeshes; a++) - { - if( MakeVerboseFormat( pScene->mMeshes[a])) + for (unsigned int a = 0; a < pScene->mNumMeshes; a++) { + if (MakeVerboseFormat(pScene->mMeshes[a])) bHas = true; } if (bHas) { @@ -84,29 +79,26 @@ void MakeVerboseFormatProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) -{ - ai_assert(NULL != pcMesh); +bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh *pcMesh) { + ai_assert(nullptr != pcMesh); unsigned int iOldNumVertices = pcMesh->mNumVertices; - const unsigned int iNumVerts = pcMesh->mNumFaces*3; + const unsigned int iNumVerts = pcMesh->mNumFaces * 3; - aiVector3D* pvPositions = new aiVector3D[ iNumVerts ]; + aiVector3D *pvPositions = new aiVector3D[iNumVerts]; - aiVector3D* pvNormals = NULL; - if (pcMesh->HasNormals()) - { + aiVector3D *pvNormals = nullptr; + if (pcMesh->HasNormals()) { pvNormals = new aiVector3D[iNumVerts]; } - aiVector3D* pvTangents = NULL, *pvBitangents = NULL; - if (pcMesh->HasTangentsAndBitangents()) - { + aiVector3D *pvTangents = nullptr, *pvBitangents = nullptr; + if (pcMesh->HasTangentsAndBitangents()) { pvTangents = new aiVector3D[iNumVerts]; pvBitangents = new aiVector3D[iNumVerts]; } - aiVector3D* apvTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS] = {0}; - aiColor4D* apvColorSets[AI_MAX_NUMBER_OF_COLOR_SETS] = {0}; + aiVector3D *apvTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS] = { 0 }; + aiColor4D *apvColorSets[AI_MAX_NUMBER_OF_COLOR_SETS] = { 0 }; unsigned int p = 0; while (pcMesh->HasTextureCoords(p)) @@ -117,24 +109,21 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) apvColorSets[p++] = new aiColor4D[iNumVerts]; // allocate enough memory to hold output bones and vertex weights ... - std::vector* newWeights = new std::vector[pcMesh->mNumBones]; - for (unsigned int i = 0;i < pcMesh->mNumBones;++i) { - newWeights[i].reserve(pcMesh->mBones[i]->mNumWeights*3); + std::vector *newWeights = new std::vector[pcMesh->mNumBones]; + for (unsigned int i = 0; i < pcMesh->mNumBones; ++i) { + newWeights[i].reserve(pcMesh->mBones[i]->mNumWeights * 3); } // iterate through all faces and build a clean list unsigned int iIndex = 0; - for (unsigned int a = 0; a< pcMesh->mNumFaces;++a) - { - aiFace* pcFace = &pcMesh->mFaces[a]; - for (unsigned int q = 0; q < pcFace->mNumIndices;++q,++iIndex) - { + for (unsigned int a = 0; a < pcMesh->mNumFaces; ++a) { + aiFace *pcFace = &pcMesh->mFaces[a]; + for (unsigned int q = 0; q < pcFace->mNumIndices; ++q, ++iIndex) { // need to build a clean list of bones, too - for (unsigned int i = 0;i < pcMesh->mNumBones;++i) - { - for (unsigned int boneIdx = 0; boneIdx < pcMesh->mBones[i]->mNumWeights; ++boneIdx) { - const aiVertexWeight &w = pcMesh->mBones[i]->mWeights[boneIdx]; - if(pcFace->mIndices[q] == w.mVertexId) { + for (unsigned int i = 0; i < pcMesh->mNumBones; ++i) { + for (unsigned int boneIdx = 0; boneIdx < pcMesh->mBones[i]->mNumWeights; ++boneIdx) { + const aiVertexWeight &w = pcMesh->mBones[i]->mWeights[boneIdx]; + if (pcFace->mIndices[q] == w.mVertexId) { aiVertexWeight wNew; wNew.mVertexId = iIndex; wNew.mWeight = w.mWeight; @@ -145,45 +134,38 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) pvPositions[iIndex] = pcMesh->mVertices[pcFace->mIndices[q]]; - if (pcMesh->HasNormals()) - { + if (pcMesh->HasNormals()) { pvNormals[iIndex] = pcMesh->mNormals[pcFace->mIndices[q]]; } - if (pcMesh->HasTangentsAndBitangents()) - { + if (pcMesh->HasTangentsAndBitangents()) { pvTangents[iIndex] = pcMesh->mTangents[pcFace->mIndices[q]]; pvBitangents[iIndex] = pcMesh->mBitangents[pcFace->mIndices[q]]; } unsigned int pp = 0; - while (pcMesh->HasTextureCoords(pp)) - { - apvTextureCoords[pp][iIndex] = pcMesh->mTextureCoords[pp][pcFace->mIndices[q]]; - ++pp; + while (pcMesh->HasTextureCoords(pp)) { + apvTextureCoords[pp][iIndex] = pcMesh->mTextureCoords[pp][pcFace->mIndices[q]]; + ++pp; } - pp = 0; - while (pcMesh->HasVertexColors(pp)) - { - apvColorSets[pp][iIndex] = pcMesh->mColors[pp][pcFace->mIndices[q]]; - ++pp; + pp = 0; + while (pcMesh->HasVertexColors(pp)) { + apvColorSets[pp][iIndex] = pcMesh->mColors[pp][pcFace->mIndices[q]]; + ++pp; } pcFace->mIndices[q] = iIndex; } } - - // build output vertex weights - for (unsigned int i = 0;i < pcMesh->mNumBones;++i) - { - delete [] pcMesh->mBones[i]->mWeights; + for (unsigned int i = 0; i < pcMesh->mNumBones; ++i) { + delete[] pcMesh->mBones[i]->mWeights; if (!newWeights[i].empty()) { pcMesh->mBones[i]->mWeights = new aiVertexWeight[newWeights[i].size()]; - aiVertexWeight *weightToCopy = &( newWeights[i][0] ); + aiVertexWeight *weightToCopy = &(newWeights[i][0]); memcpy(pcMesh->mBones[i]->mWeights, weightToCopy, - sizeof(aiVertexWeight) * newWeights[i].size()); + sizeof(aiVertexWeight) * newWeights[i].size()); } else { - pcMesh->mBones[i]->mWeights = NULL; + pcMesh->mBones[i]->mWeights = nullptr; } } delete[] newWeights; @@ -193,28 +175,24 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) pcMesh->mVertices = pvPositions; p = 0; - while (pcMesh->HasTextureCoords(p)) - { + while (pcMesh->HasTextureCoords(p)) { delete[] pcMesh->mTextureCoords[p]; pcMesh->mTextureCoords[p] = apvTextureCoords[p]; ++p; } p = 0; - while (pcMesh->HasVertexColors(p)) - { + while (pcMesh->HasVertexColors(p)) { delete[] pcMesh->mColors[p]; pcMesh->mColors[p] = apvColorSets[p]; ++p; } pcMesh->mNumVertices = iNumVerts; - if (pcMesh->HasNormals()) - { + if (pcMesh->HasNormals()) { delete[] pcMesh->mNormals; pcMesh->mNormals = pvNormals; } - if (pcMesh->HasTangentsAndBitangents()) - { + if (pcMesh->HasTangentsAndBitangents()) { delete[] pcMesh->mTangents; pcMesh->mTangents = pvTangents; delete[] pcMesh->mBitangents; @@ -223,15 +201,14 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) return (pcMesh->mNumVertices != iOldNumVertices); } - // ------------------------------------------------------------------------------------------------ -bool IsMeshInVerboseFormat(const aiMesh* mesh) { +bool IsMeshInVerboseFormat(const aiMesh *mesh) { // avoid slow vector specialization - std::vector seen(mesh->mNumVertices,0); - for(unsigned int i = 0; i < mesh->mNumFaces; ++i) { - const aiFace& f = mesh->mFaces[i]; - for(unsigned int j = 0; j < f.mNumIndices; ++j) { - if(++seen[f.mIndices[j]] == 2) { + std::vector seen(mesh->mNumVertices, 0); + for (unsigned int i = 0; i < mesh->mNumFaces; ++i) { + const aiFace &f = mesh->mFaces[i]; + for (unsigned int j = 0; j < f.mNumIndices; ++j) { + if (++seen[f.mIndices[j]] == 2) { // found a duplicate index return false; } @@ -242,9 +219,9 @@ bool IsMeshInVerboseFormat(const aiMesh* mesh) { } // ------------------------------------------------------------------------------------------------ -bool MakeVerboseFormatProcess::IsVerboseFormat(const aiScene* pScene) { - for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { - if(!IsMeshInVerboseFormat(pScene->mMeshes[i])) { +bool MakeVerboseFormatProcess::IsVerboseFormat(const aiScene *pScene) { + for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { + if (!IsMeshInVerboseFormat(pScene->mMeshes[i])) { return false; } } diff --git a/code/PostProcessing/PretransformVertices.cpp b/code/PostProcessing/PretransformVertices.cpp index 293a5c0ea..790ab086e 100644 --- a/code/PostProcessing/PretransformVertices.cpp +++ b/code/PostProcessing/PretransformVertices.cpp @@ -445,7 +445,7 @@ void PretransformVertices::Execute(aiScene *pScene) { delete mesh->mBones[a]; delete[] mesh->mBones; - mesh->mBones = NULL; + mesh->mBones = nullptr; } // now build a list of output meshes @@ -472,12 +472,12 @@ void PretransformVertices::Execute(aiScene *pScene) { pScene->mMeshes = npp; } - // now iterate through all meshes and transform them to worldspace + // now iterate through all meshes and transform them to world-space for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { ApplyTransform(pScene->mMeshes[i], *reinterpret_cast(pScene->mMeshes[i]->mBones)); // prevent improper destruction - pScene->mMeshes[i]->mBones = NULL; + pScene->mMeshes[i]->mBones = nullptr; pScene->mMeshes[i]->mNumBones = 0; } } else { @@ -539,22 +539,22 @@ void PretransformVertices::Execute(aiScene *pScene) { for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { aiMesh *mesh = pScene->mMeshes[i]; mesh->mNumBones = 0; - mesh->mBones = NULL; + mesh->mBones = nullptr; // we're reusing the face index arrays. avoid destruction for (unsigned int a = 0; a < mesh->mNumFaces; ++a) { mesh->mFaces[a].mNumIndices = 0; - mesh->mFaces[a].mIndices = NULL; + mesh->mFaces[a].mIndices = nullptr; } delete mesh; // Invalidate the contents of the old mesh array. We will most // likely have less output meshes now, so the last entries of - // the mesh array are not overridden. We set them to NULL to + // the mesh array are not overridden. We set them to nullptr to // make sure the developer gets notified when his application // attempts to access these fields ... - mesh = NULL; + mesh = nullptr; } // It is impossible that we have more output meshes than @@ -571,14 +571,14 @@ void PretransformVertices::Execute(aiScene *pScene) { delete pScene->mAnimations[i]; delete[] pScene->mAnimations; - pScene->mAnimations = NULL; + pScene->mAnimations = nullptr; pScene->mNumAnimations = 0; // --- we need to keep all cameras and lights for (unsigned int i = 0; i < pScene->mNumCameras; ++i) { aiCamera *cam = pScene->mCameras[i]; const aiNode *nd = pScene->mRootNode->FindNode(cam->mName); - ai_assert(NULL != nd); + ai_assert(nullptr != nd); // multiply all properties of the camera with the absolute // transformation of the corresponding node @@ -590,7 +590,7 @@ void PretransformVertices::Execute(aiScene *pScene) { for (unsigned int i = 0; i < pScene->mNumLights; ++i) { aiLight *l = pScene->mLights[i]; const aiNode *nd = pScene->mRootNode->FindNode(l->mName); - ai_assert(NULL != nd); + ai_assert(nullptr != nd); // multiply all properties of the camera with the absolute // transformation of the corresponding node diff --git a/code/PostProcessing/ProcessHelper.cpp b/code/PostProcessing/ProcessHelper.cpp index 123986438..e3a8aab8a 100644 --- a/code/PostProcessing/ProcessHelper.cpp +++ b/code/PostProcessing/ProcessHelper.cpp @@ -43,22 +43,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /// @file ProcessHelper.cpp /** Implement shared utility functions for postprocessing steps */ - #include "ProcessHelper.h" - #include namespace Assimp { // ------------------------------------------------------------------------------- -void ConvertListToStrings(const std::string& in, std::list& out) -{ - const char* s = in.c_str(); +void ConvertListToStrings(const std::string &in, std::list &out) { + const char *s = in.c_str(); while (*s) { SkipSpacesAndLineEnd(&s); if (*s == '\'') { - const char* base = ++s; + const char *base = ++s; while (*s != '\'') { ++s; if (*s == '\0') { @@ -66,43 +63,39 @@ void ConvertListToStrings(const std::string& in, std::list& out) return; } } - out.push_back(std::string(base,(size_t)(s-base))); + out.push_back(std::string(base, (size_t)(s - base))); ++s; - } - else { + } else { out.push_back(GetNextToken(s)); } } } // ------------------------------------------------------------------------------- -void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D& max, - const aiMatrix4x4& m) -{ - min = aiVector3D ( ai_real( 10e10 ), ai_real( 10e10 ), ai_real( 10e10 ) ); - max = aiVector3D ( ai_real( -10e10 ), ai_real( -10e10 ), ai_real( -10e10 ) ); - for (unsigned int i = 0;i < mesh->mNumVertices;++i) - { +void FindAABBTransformed(const aiMesh *mesh, aiVector3D &min, aiVector3D &max, + const aiMatrix4x4 &m) { + min = aiVector3D(ai_real(10e10), ai_real(10e10), ai_real(10e10)); + max = aiVector3D(ai_real(-10e10), ai_real(-10e10), ai_real(-10e10)); + for (unsigned int i = 0; i < mesh->mNumVertices; ++i) { const aiVector3D v = m * mesh->mVertices[i]; - min = std::min(v,min); - max = std::max(v,max); + min = std::min(v, min); + max = std::max(v, max); } } // ------------------------------------------------------------------------------- -void FindMeshCenter (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& max) -{ - ArrayBounds(mesh->mVertices,mesh->mNumVertices, min,max); - out = min + (max-min)*(ai_real)0.5; +void FindMeshCenter(aiMesh *mesh, aiVector3D &out, aiVector3D &min, aiVector3D &max) { + ArrayBounds(mesh->mVertices, mesh->mNumVertices, min, max); + out = min + (max - min) * (ai_real)0.5; } // ------------------------------------------------------------------------------- -void FindSceneCenter (aiScene* scene, aiVector3D& out, aiVector3D& min, aiVector3D& max) { - if ( NULL == scene ) { +void FindSceneCenter(aiScene *scene, aiVector3D &out, aiVector3D &min, aiVector3D &max) { + if (nullptr == scene) { return; } - if ( 0 == scene->mNumMeshes ) { + if (0 == scene->mNumMeshes) { return; } FindMeshCenter(scene->mMeshes[0], out, min, max); @@ -116,79 +109,71 @@ void FindSceneCenter (aiScene* scene, aiVector3D& out, aiVector3D& min, aiVector if (max[1] < tmax[1]) max[1] = tmax[1]; if (max[2] < tmax[2]) max[2] = tmax[2]; } - out = min + (max-min)*(ai_real)0.5; -} - - -// ------------------------------------------------------------------------------- -void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out, aiVector3D& min, - aiVector3D& max, const aiMatrix4x4& m) -{ - FindAABBTransformed(mesh,min,max,m); - out = min + (max-min)*(ai_real)0.5; + out = min + (max - min) * (ai_real)0.5; } // ------------------------------------------------------------------------------- -void FindMeshCenter (aiMesh* mesh, aiVector3D& out) -{ - aiVector3D min,max; - FindMeshCenter(mesh,out,min,max); +void FindMeshCenterTransformed(aiMesh *mesh, aiVector3D &out, aiVector3D &min, + aiVector3D &max, const aiMatrix4x4 &m) { + FindAABBTransformed(mesh, min, max, m); + out = min + (max - min) * (ai_real)0.5; } // ------------------------------------------------------------------------------- -void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out, - const aiMatrix4x4& m) -{ - aiVector3D min,max; - FindMeshCenterTransformed(mesh,out,min,max,m); +void FindMeshCenter(aiMesh *mesh, aiVector3D &out) { + aiVector3D min, max; + FindMeshCenter(mesh, out, min, max); } // ------------------------------------------------------------------------------- -ai_real ComputePositionEpsilon(const aiMesh* pMesh) -{ - const ai_real epsilon = ai_real( 1e-4 ); +void FindMeshCenterTransformed(aiMesh *mesh, aiVector3D &out, + const aiMatrix4x4 &m) { + aiVector3D min, max; + FindMeshCenterTransformed(mesh, out, min, max, m); +} + +// ------------------------------------------------------------------------------- +ai_real ComputePositionEpsilon(const aiMesh *pMesh) { + const ai_real epsilon = ai_real(1e-4); // calculate the position bounds so we have a reliable epsilon to check position differences against aiVector3D minVec, maxVec; - ArrayBounds(pMesh->mVertices,pMesh->mNumVertices,minVec,maxVec); + ArrayBounds(pMesh->mVertices, pMesh->mNumVertices, minVec, maxVec); return (maxVec - minVec).Length() * epsilon; } // ------------------------------------------------------------------------------- -ai_real ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num) -{ - ai_assert( NULL != pMeshes ); +ai_real ComputePositionEpsilon(const aiMesh *const *pMeshes, size_t num) { + ai_assert(nullptr != pMeshes); - const ai_real epsilon = ai_real( 1e-4 ); + const ai_real epsilon = ai_real(1e-4); // calculate the position bounds so we have a reliable epsilon to check position differences against aiVector3D minVec, maxVec, mi, ma; - MinMaxChooser()(minVec,maxVec); + MinMaxChooser()(minVec, maxVec); for (size_t a = 0; a < num; ++a) { - const aiMesh* pMesh = pMeshes[a]; - ArrayBounds(pMesh->mVertices,pMesh->mNumVertices,mi,ma); + const aiMesh *pMesh = pMeshes[a]; + ArrayBounds(pMesh->mVertices, pMesh->mNumVertices, mi, ma); - minVec = std::min(minVec,mi); - maxVec = std::max(maxVec,ma); + minVec = std::min(minVec, mi); + maxVec = std::max(maxVec, ma); } return (maxVec - minVec).Length() * epsilon; } - // ------------------------------------------------------------------------------- -unsigned int GetMeshVFormatUnique(const aiMesh* pcMesh) -{ - ai_assert(NULL != pcMesh); +unsigned int GetMeshVFormatUnique(const aiMesh *pcMesh) { + ai_assert(nullptr != pcMesh); // FIX: the hash may never be 0. Otherwise a comparison against // nullptr could be successful unsigned int iRet = 1; // normals - if (pcMesh->HasNormals())iRet |= 0x2; + if (pcMesh->HasNormals()) iRet |= 0x2; // tangents and bitangents - if (pcMesh->HasTangentsAndBitangents())iRet |= 0x4; + if (pcMesh->HasTangentsAndBitangents()) iRet |= 0x4; #ifdef BOOST_STATIC_ASSERT BOOST_STATIC_ASSERT(8 >= AI_MAX_NUMBER_OF_COLOR_SETS); @@ -197,8 +182,7 @@ unsigned int GetMeshVFormatUnique(const aiMesh* pcMesh) // texture coordinates unsigned int p = 0; - while (pcMesh->HasTextureCoords(p)) - { + while (pcMesh->HasTextureCoords(p)) { iRet |= (0x100 << p); if (3 == pcMesh->mNumUVComponents[p]) iRet |= (0x10000 << p); @@ -207,34 +191,32 @@ unsigned int GetMeshVFormatUnique(const aiMesh* pcMesh) } // vertex colors p = 0; - while (pcMesh->HasVertexColors(p))iRet |= (0x1000000 << p++); + while (pcMesh->HasVertexColors(p)) + iRet |= (0x1000000 << p++); return iRet; } // ------------------------------------------------------------------------------- -VertexWeightTable* ComputeVertexBoneWeightTable(const aiMesh* pMesh) -{ +VertexWeightTable *ComputeVertexBoneWeightTable(const aiMesh *pMesh) { if (!pMesh || !pMesh->mNumVertices || !pMesh->mNumBones) { - return NULL; + return nullptr; } - VertexWeightTable* avPerVertexWeights = new VertexWeightTable[pMesh->mNumVertices]; - for (unsigned int i = 0; i < pMesh->mNumBones;++i) { + VertexWeightTable *avPerVertexWeights = new VertexWeightTable[pMesh->mNumVertices]; + for (unsigned int i = 0; i < pMesh->mNumBones; ++i) { - aiBone* bone = pMesh->mBones[i]; - for (unsigned int a = 0; a < bone->mNumWeights;++a) { - const aiVertexWeight& weight = bone->mWeights[a]; - avPerVertexWeights[weight.mVertexId].push_back( std::pair(i,weight.mWeight) ); + aiBone *bone = pMesh->mBones[i]; + for (unsigned int a = 0; a < bone->mNumWeights; ++a) { + const aiVertexWeight &weight = bone->mWeights[a]; + avPerVertexWeights[weight.mVertexId].push_back(std::pair(i, weight.mWeight)); } } return avPerVertexWeights; } // ------------------------------------------------------------------------------- -const char* MappingTypeToString(aiTextureMapping in) -{ - switch (in) - { +const char *MappingTypeToString(aiTextureMapping in) { + switch (in) { case aiTextureMapping_UV: return "UV"; case aiTextureMapping_BOX: @@ -252,24 +234,22 @@ const char* MappingTypeToString(aiTextureMapping in) } ai_assert(false); - return "BUG"; + return "BUG"; } - // ------------------------------------------------------------------------------- -aiMesh* MakeSubmesh(const aiMesh *pMesh, const std::vector &subMeshFaces, unsigned int subFlags) -{ +aiMesh *MakeSubmesh(const aiMesh *pMesh, const std::vector &subMeshFaces, unsigned int subFlags) { aiMesh *oMesh = new aiMesh(); - std::vector vMap(pMesh->mNumVertices,UINT_MAX); + std::vector vMap(pMesh->mNumVertices, UINT_MAX); size_t numSubVerts = 0; size_t numSubFaces = subMeshFaces.size(); - for(unsigned int i=0;imFaces[subMeshFaces[i]]; - for(unsigned int j=0;j(numSubVerts++); } } @@ -285,114 +265,114 @@ aiMesh* MakeSubmesh(const aiMesh *pMesh, const std::vector &subMes oMesh->mNumFaces = static_cast(subMeshFaces.size()); oMesh->mNumVertices = static_cast(numSubVerts); oMesh->mVertices = new aiVector3D[numSubVerts]; - if( pMesh->HasNormals() ) { + if (pMesh->HasNormals()) { oMesh->mNormals = new aiVector3D[numSubVerts]; } - if( pMesh->HasTangentsAndBitangents() ) { + if (pMesh->HasTangentsAndBitangents()) { oMesh->mTangents = new aiVector3D[numSubVerts]; oMesh->mBitangents = new aiVector3D[numSubVerts]; } - for( size_t a = 0; pMesh->HasTextureCoords(static_cast(a)) ; ++a ) { + for (size_t a = 0; pMesh->HasTextureCoords(static_cast(a)); ++a) { oMesh->mTextureCoords[a] = new aiVector3D[numSubVerts]; oMesh->mNumUVComponents[a] = pMesh->mNumUVComponents[a]; } - for( size_t a = 0; pMesh->HasVertexColors( static_cast(a)); ++a ) { + for (size_t a = 0; pMesh->HasVertexColors(static_cast(a)); ++a) { oMesh->mColors[a] = new aiColor4D[numSubVerts]; } // and copy over the data, generating faces with linear indices along the way oMesh->mFaces = new aiFace[numSubFaces]; - for(unsigned int a = 0; a < numSubFaces; ++a ) { + for (unsigned int a = 0; a < numSubFaces; ++a) { - const aiFace& srcFace = pMesh->mFaces[subMeshFaces[a]]; - aiFace& dstFace = oMesh->mFaces[a]; + const aiFace &srcFace = pMesh->mFaces[subMeshFaces[a]]; + aiFace &dstFace = oMesh->mFaces[a]; dstFace.mNumIndices = srcFace.mNumIndices; dstFace.mIndices = new unsigned int[dstFace.mNumIndices]; // accumulate linearly all the vertices of the source face - for( size_t b = 0; b < dstFace.mNumIndices; ++b ) { + for (size_t b = 0; b < dstFace.mNumIndices; ++b) { dstFace.mIndices[b] = vMap[srcFace.mIndices[b]]; } } - for(unsigned int srcIndex = 0; srcIndex < pMesh->mNumVertices; ++srcIndex ) { + for (unsigned int srcIndex = 0; srcIndex < pMesh->mNumVertices; ++srcIndex) { unsigned int nvi = vMap[srcIndex]; - if(nvi==UINT_MAX) { + if (nvi == UINT_MAX) { continue; } oMesh->mVertices[nvi] = pMesh->mVertices[srcIndex]; - if( pMesh->HasNormals() ) { + if (pMesh->HasNormals()) { oMesh->mNormals[nvi] = pMesh->mNormals[srcIndex]; } - if( pMesh->HasTangentsAndBitangents() ) { + if (pMesh->HasTangentsAndBitangents()) { oMesh->mTangents[nvi] = pMesh->mTangents[srcIndex]; oMesh->mBitangents[nvi] = pMesh->mBitangents[srcIndex]; } - for( size_t c = 0, cc = pMesh->GetNumUVChannels(); c < cc; ++c ) { - oMesh->mTextureCoords[c][nvi] = pMesh->mTextureCoords[c][srcIndex]; + for (size_t c = 0, cc = pMesh->GetNumUVChannels(); c < cc; ++c) { + oMesh->mTextureCoords[c][nvi] = pMesh->mTextureCoords[c][srcIndex]; } - for( size_t c = 0, cc = pMesh->GetNumColorChannels(); c < cc; ++c ) { + for (size_t c = 0, cc = pMesh->GetNumColorChannels(); c < cc; ++c) { oMesh->mColors[c][nvi] = pMesh->mColors[c][srcIndex]; } } - if(~subFlags&AI_SUBMESH_FLAGS_SANS_BONES) { - std::vector subBones(pMesh->mNumBones,0); + if (~subFlags & AI_SUBMESH_FLAGS_SANS_BONES) { + std::vector subBones(pMesh->mNumBones, 0); - for(unsigned int a=0;amNumBones;++a) { - const aiBone* bone = pMesh->mBones[a]; + for (unsigned int a = 0; a < pMesh->mNumBones; ++a) { + const aiBone *bone = pMesh->mBones[a]; - for(unsigned int b=0;bmNumWeights;b++) { + for (unsigned int b = 0; b < bone->mNumWeights; b++) { unsigned int v = vMap[bone->mWeights[b].mVertexId]; - if(v!=UINT_MAX) { + if (v != UINT_MAX) { subBones[a]++; } } } - for(unsigned int a=0;amNumBones;++a) { - if(subBones[a]>0) { + for (unsigned int a = 0; a < pMesh->mNumBones; ++a) { + if (subBones[a] > 0) { oMesh->mNumBones++; } } - if(oMesh->mNumBones) { - oMesh->mBones = new aiBone*[oMesh->mNumBones](); + if (oMesh->mNumBones) { + oMesh->mBones = new aiBone *[oMesh->mNumBones](); unsigned int nbParanoia = oMesh->mNumBones; oMesh->mNumBones = 0; //rewind - for(unsigned int a=0;amNumBones;++a) { - if(subBones[a]==0) { + for (unsigned int a = 0; a < pMesh->mNumBones; ++a) { + if (subBones[a] == 0) { continue; } aiBone *newBone = new aiBone; oMesh->mBones[oMesh->mNumBones++] = newBone; - const aiBone* bone = pMesh->mBones[a]; + const aiBone *bone = pMesh->mBones[a]; newBone->mName = bone->mName; newBone->mOffsetMatrix = bone->mOffsetMatrix; newBone->mWeights = new aiVertexWeight[subBones[a]]; - for(unsigned int b=0;bmNumWeights;b++) { + for (unsigned int b = 0; b < bone->mNumWeights; b++) { const unsigned int v = vMap[bone->mWeights[b].mVertexId]; - if(v!=UINT_MAX) { - aiVertexWeight w(v,bone->mWeights[b].mWeight); + if (v != UINT_MAX) { + aiVertexWeight w(v, bone->mWeights[b].mWeight); newBone->mWeights[newBone->mNumWeights++] = w; } } } - ai_assert(nbParanoia==oMesh->mNumBones); + ai_assert(nbParanoia == oMesh->mNumBones); (void)nbParanoia; // remove compiler warning on release build } } diff --git a/code/PostProcessing/ProcessHelper.h b/code/PostProcessing/ProcessHelper.h index 5762fbb35..8520b21ec 100644 --- a/code/PostProcessing/ProcessHelper.h +++ b/code/PostProcessing/ProcessHelper.h @@ -43,16 +43,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_PROCESS_HELPER_H_INCLUDED #define AI_PROCESS_HELPER_H_INCLUDED -#include #include -#include #include -#include +#include +#include #include +#include -#include #include "Common/BaseProcess.h" #include +#include #include @@ -63,86 +63,83 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef __cplusplus namespace std { - // std::min for aiVector3D - template - inline ::aiVector3t min (const ::aiVector3t& a, const ::aiVector3t& b) { - return ::aiVector3t (min(a.x,b.x),min(a.y,b.y),min(a.z,b.z)); - } +// std::min for aiVector3D +template +inline ::aiVector3t min(const ::aiVector3t &a, const ::aiVector3t &b) { + return ::aiVector3t(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); +} - // std::max for aiVector3t - template - inline ::aiVector3t max (const ::aiVector3t& a, const ::aiVector3t& b) { - return ::aiVector3t (max(a.x,b.x),max(a.y,b.y),max(a.z,b.z)); - } +// std::max for aiVector3t +template +inline ::aiVector3t max(const ::aiVector3t &a, const ::aiVector3t &b) { + return ::aiVector3t(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); +} - // std::min for aiVector2t - template - inline ::aiVector2t min (const ::aiVector2t& a, const ::aiVector2t& b) { - return ::aiVector2t (min(a.x,b.x),min(a.y,b.y)); - } +// std::min for aiVector2t +template +inline ::aiVector2t min(const ::aiVector2t &a, const ::aiVector2t &b) { + return ::aiVector2t(min(a.x, b.x), min(a.y, b.y)); +} - // std::max for aiVector2t - template - inline ::aiVector2t max (const ::aiVector2t& a, const ::aiVector2t& b) { - return ::aiVector2t (max(a.x,b.x),max(a.y,b.y)); - } +// std::max for aiVector2t +template +inline ::aiVector2t max(const ::aiVector2t &a, const ::aiVector2t &b) { + return ::aiVector2t(max(a.x, b.x), max(a.y, b.y)); +} - // std::min for aiColor4D - template - inline ::aiColor4t min (const ::aiColor4t& a, const ::aiColor4t& b) { - return ::aiColor4t (min(a.r,b.r),min(a.g,b.g),min(a.b,b.b),min(a.a,b.a)); - } +// std::min for aiColor4D +template +inline ::aiColor4t min(const ::aiColor4t &a, const ::aiColor4t &b) { + return ::aiColor4t(min(a.r, b.r), min(a.g, b.g), min(a.b, b.b), min(a.a, b.a)); +} - // std::max for aiColor4D - template - inline ::aiColor4t max (const ::aiColor4t& a, const ::aiColor4t& b) { - return ::aiColor4t (max(a.r,b.r),max(a.g,b.g),max(a.b,b.b),max(a.a,b.a)); - } +// std::max for aiColor4D +template +inline ::aiColor4t max(const ::aiColor4t &a, const ::aiColor4t &b) { + return ::aiColor4t(max(a.r, b.r), max(a.g, b.g), max(a.b, b.b), max(a.a, b.a)); +} +// std::min for aiQuaterniont +template +inline ::aiQuaterniont min(const ::aiQuaterniont &a, const ::aiQuaterniont &b) { + return ::aiQuaterniont(min(a.w, b.w), min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); +} - // std::min for aiQuaterniont - template - inline ::aiQuaterniont min (const ::aiQuaterniont& a, const ::aiQuaterniont& b) { - return ::aiQuaterniont (min(a.w,b.w),min(a.x,b.x),min(a.y,b.y),min(a.z,b.z)); - } +// std::max for aiQuaterniont +template +inline ::aiQuaterniont max(const ::aiQuaterniont &a, const ::aiQuaterniont &b) { + return ::aiQuaterniont(max(a.w, b.w), max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); +} - // std::max for aiQuaterniont - template - inline ::aiQuaterniont max (const ::aiQuaterniont& a, const ::aiQuaterniont& b) { - return ::aiQuaterniont (max(a.w,b.w),max(a.x,b.x),max(a.y,b.y),max(a.z,b.z)); - } +// std::min for aiVectorKey +inline ::aiVectorKey min(const ::aiVectorKey &a, const ::aiVectorKey &b) { + return ::aiVectorKey(min(a.mTime, b.mTime), min(a.mValue, b.mValue)); +} +// std::max for aiVectorKey +inline ::aiVectorKey max(const ::aiVectorKey &a, const ::aiVectorKey &b) { + return ::aiVectorKey(max(a.mTime, b.mTime), max(a.mValue, b.mValue)); +} +// std::min for aiQuatKey +inline ::aiQuatKey min(const ::aiQuatKey &a, const ::aiQuatKey &b) { + return ::aiQuatKey(min(a.mTime, b.mTime), min(a.mValue, b.mValue)); +} - // std::min for aiVectorKey - inline ::aiVectorKey min (const ::aiVectorKey& a, const ::aiVectorKey& b) { - return ::aiVectorKey (min(a.mTime,b.mTime),min(a.mValue,b.mValue)); - } +// std::max for aiQuatKey +inline ::aiQuatKey max(const ::aiQuatKey &a, const ::aiQuatKey &b) { + return ::aiQuatKey(max(a.mTime, b.mTime), max(a.mValue, b.mValue)); +} - // std::max for aiVectorKey - inline ::aiVectorKey max (const ::aiVectorKey& a, const ::aiVectorKey& b) { - return ::aiVectorKey (max(a.mTime,b.mTime),max(a.mValue,b.mValue)); - } +// std::min for aiVertexWeight +inline ::aiVertexWeight min(const ::aiVertexWeight &a, const ::aiVertexWeight &b) { + return ::aiVertexWeight(min(a.mVertexId, b.mVertexId), min(a.mWeight, b.mWeight)); +} - // std::min for aiQuatKey - inline ::aiQuatKey min (const ::aiQuatKey& a, const ::aiQuatKey& b) { - return ::aiQuatKey (min(a.mTime,b.mTime),min(a.mValue,b.mValue)); - } - - // std::max for aiQuatKey - inline ::aiQuatKey max (const ::aiQuatKey& a, const ::aiQuatKey& b) { - return ::aiQuatKey (max(a.mTime,b.mTime),max(a.mValue,b.mValue)); - } - - // std::min for aiVertexWeight - inline ::aiVertexWeight min (const ::aiVertexWeight& a, const ::aiVertexWeight& b) { - return ::aiVertexWeight (min(a.mVertexId,b.mVertexId),min(a.mWeight,b.mWeight)); - } - - // std::max for aiVertexWeight - inline ::aiVertexWeight max (const ::aiVertexWeight& a, const ::aiVertexWeight& b) { - return ::aiVertexWeight (max(a.mVertexId,b.mVertexId),max(a.mWeight,b.mWeight)); - } +// std::max for aiVertexWeight +inline ::aiVertexWeight max(const ::aiVertexWeight &a, const ::aiVertexWeight &b) { + return ::aiVertexWeight(max(a.mVertexId, b.mVertexId), max(a.mWeight, b.mWeight)); +} } // end namespace std #endif // !! C++ @@ -154,60 +151,80 @@ namespace Assimp { template struct MinMaxChooser; -template <> struct MinMaxChooser { - void operator ()(float& min,float& max) { +template <> +struct MinMaxChooser { + void operator()(float &min, float &max) { max = -1e10f; - min = 1e10f; -}}; -template <> struct MinMaxChooser { - void operator ()(double& min,double& max) { + min = 1e10f; + } +}; +template <> +struct MinMaxChooser { + void operator()(double &min, double &max) { max = -1e10; - min = 1e10; -}}; -template <> struct MinMaxChooser { - void operator ()(unsigned int& min,unsigned int& max) { + min = 1e10; + } +}; +template <> +struct MinMaxChooser { + void operator()(unsigned int &min, unsigned int &max) { max = 0; - min = (1u<<(sizeof(unsigned int)*8-1)); -}}; + min = (1u << (sizeof(unsigned int) * 8 - 1)); + } +}; -template struct MinMaxChooser< aiVector3t > { - void operator ()(aiVector3t& min,aiVector3t& max) { - max = aiVector3t(-1e10f,-1e10f,-1e10f); - min = aiVector3t( 1e10f, 1e10f, 1e10f); -}}; -template struct MinMaxChooser< aiVector2t > { - void operator ()(aiVector2t& min,aiVector2t& max) { - max = aiVector2t(-1e10f,-1e10f); - min = aiVector2t( 1e10f, 1e10f); - }}; -template struct MinMaxChooser< aiColor4t > { - void operator ()(aiColor4t& min,aiColor4t& max) { - max = aiColor4t(-1e10f,-1e10f,-1e10f,-1e10f); - min = aiColor4t( 1e10f, 1e10f, 1e10f, 1e10f); -}}; +template +struct MinMaxChooser> { + void operator()(aiVector3t &min, aiVector3t &max) { + max = aiVector3t(-1e10f, -1e10f, -1e10f); + min = aiVector3t(1e10f, 1e10f, 1e10f); + } +}; +template +struct MinMaxChooser> { + void operator()(aiVector2t &min, aiVector2t &max) { + max = aiVector2t(-1e10f, -1e10f); + min = aiVector2t(1e10f, 1e10f); + } +}; +template +struct MinMaxChooser> { + void operator()(aiColor4t &min, aiColor4t &max) { + max = aiColor4t(-1e10f, -1e10f, -1e10f, -1e10f); + min = aiColor4t(1e10f, 1e10f, 1e10f, 1e10f); + } +}; -template struct MinMaxChooser< aiQuaterniont > { - void operator ()(aiQuaterniont& min,aiQuaterniont& max) { - max = aiQuaterniont(-1e10f,-1e10f,-1e10f,-1e10f); - min = aiQuaterniont( 1e10f, 1e10f, 1e10f, 1e10f); -}}; +template +struct MinMaxChooser> { + void operator()(aiQuaterniont &min, aiQuaterniont &max) { + max = aiQuaterniont(-1e10f, -1e10f, -1e10f, -1e10f); + min = aiQuaterniont(1e10f, 1e10f, 1e10f, 1e10f); + } +}; -template <> struct MinMaxChooser { - void operator ()(aiVectorKey& min,aiVectorKey& max) { - MinMaxChooser()(min.mTime,max.mTime); - MinMaxChooser()(min.mValue,max.mValue); -}}; -template <> struct MinMaxChooser { - void operator ()(aiQuatKey& min,aiQuatKey& max) { - MinMaxChooser()(min.mTime,max.mTime); - MinMaxChooser()(min.mValue,max.mValue); -}}; +template <> +struct MinMaxChooser { + void operator()(aiVectorKey &min, aiVectorKey &max) { + MinMaxChooser()(min.mTime, max.mTime); + MinMaxChooser()(min.mValue, max.mValue); + } +}; +template <> +struct MinMaxChooser { + void operator()(aiQuatKey &min, aiQuatKey &max) { + MinMaxChooser()(min.mTime, max.mTime); + MinMaxChooser()(min.mValue, max.mValue); + } +}; -template <> struct MinMaxChooser { - void operator ()(aiVertexWeight& min,aiVertexWeight& max) { - MinMaxChooser()(min.mVertexId,max.mVertexId); - MinMaxChooser()(min.mWeight,max.mWeight); -}}; +template <> +struct MinMaxChooser { + void operator()(aiVertexWeight &min, aiVertexWeight &max) { + MinMaxChooser()(min.mVertexId, max.mVertexId); + MinMaxChooser()(min.mWeight, max.mWeight); + } +}; // ------------------------------------------------------------------------------- /** @brief Find the min/max values of an array of Ts @@ -217,36 +234,31 @@ template <> struct MinMaxChooser { * @param[out] max maximum value */ template -inline void ArrayBounds(const T* in, unsigned int size, T& min, T& max) -{ - MinMaxChooser ()(min,max); - for (unsigned int i = 0; i < size;++i) { - min = std::min(in[i],min); - max = std::max(in[i],max); +inline void ArrayBounds(const T *in, unsigned int size, T &min, T &max) { + MinMaxChooser()(min, max); + for (unsigned int i = 0; i < size; ++i) { + min = std::min(in[i], min); + max = std::max(in[i], max); } } - // ------------------------------------------------------------------------------- /** Little helper function to calculate the quadratic difference * of two colours. * @param pColor1 First color * @param pColor2 second color * @return Quadratic color difference */ -inline ai_real GetColorDifference( const aiColor4D& pColor1, const aiColor4D& pColor2) -{ - const aiColor4D c (pColor1.r - pColor2.r, pColor1.g - pColor2.g, pColor1.b - pColor2.b, pColor1.a - pColor2.a); - return c.r*c.r + c.g*c.g + c.b*c.b + c.a*c.a; +inline ai_real GetColorDifference(const aiColor4D &pColor1, const aiColor4D &pColor2) { + const aiColor4D c(pColor1.r - pColor2.r, pColor1.g - pColor2.g, pColor1.b - pColor2.b, pColor1.a - pColor2.a); + return c.r * c.r + c.g * c.g + c.b * c.b + c.a * c.a; } - // ------------------------------------------------------------------------------- /** @brief Extract single strings from a list of identifiers * @param in Input string list. * @param out Receives a list of clean output strings * @sdee #AI_CONFIG_PP_OG_EXCLUDE_LIST */ -void ConvertListToStrings(const std::string& in, std::list& out); - +void ConvertListToStrings(const std::string &in, std::list &out); // ------------------------------------------------------------------------------- /** @brief Compute the AABB of a mesh after applying a given transform @@ -254,8 +266,7 @@ void ConvertListToStrings(const std::string& in, std::list& out); * @param[out] min Receives minimum transformed vertex * @param[out] max Receives maximum transformed vertex * @param m Transformation matrix to be applied */ -void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D& max, const aiMatrix4x4& m); - +void FindAABBTransformed(const aiMesh *mesh, aiVector3D &min, aiVector3D &max, const aiMatrix4x4 &m); // ------------------------------------------------------------------------------- /** @brief Helper function to determine the 'real' center of a mesh @@ -265,7 +276,7 @@ void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D& max, * @param[out] min Minimum vertex of the mesh * @param[out] max maximum vertex of the mesh * @param[out] out Center point */ -void FindMeshCenter (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& max); +void FindMeshCenter(aiMesh *mesh, aiVector3D &out, aiVector3D &min, aiVector3D &max); // ------------------------------------------------------------------------------- /** @brief Helper function to determine the 'real' center of a scene @@ -275,106 +286,90 @@ void FindMeshCenter (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& * @param[out] min Minimum vertex of the scene * @param[out] max maximum vertex of the scene * @param[out] out Center point */ -void FindSceneCenter (aiScene* scene, aiVector3D& out, aiVector3D& min, aiVector3D& max); - +void FindSceneCenter(aiScene *scene, aiVector3D &out, aiVector3D &min, aiVector3D &max); // ------------------------------------------------------------------------------- // Helper function to determine the 'real' center of a mesh after applying a given transform -void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out, aiVector3D& min,aiVector3D& max, const aiMatrix4x4& m); - +void FindMeshCenterTransformed(aiMesh *mesh, aiVector3D &out, aiVector3D &min, aiVector3D &max, const aiMatrix4x4 &m); // ------------------------------------------------------------------------------- // Helper function to determine the 'real' center of a mesh -void FindMeshCenter (aiMesh* mesh, aiVector3D& out); - +void FindMeshCenter(aiMesh *mesh, aiVector3D &out); // ------------------------------------------------------------------------------- // Helper function to determine the 'real' center of a mesh after applying a given transform -void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out,const aiMatrix4x4& m); - +void FindMeshCenterTransformed(aiMesh *mesh, aiVector3D &out, const aiMatrix4x4 &m); // ------------------------------------------------------------------------------- // Compute a good epsilon value for position comparisons on a mesh -ai_real ComputePositionEpsilon(const aiMesh* pMesh); - +ai_real ComputePositionEpsilon(const aiMesh *pMesh); // ------------------------------------------------------------------------------- // Compute a good epsilon value for position comparisons on a array of meshes -ai_real ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num); - +ai_real ComputePositionEpsilon(const aiMesh *const *pMeshes, size_t num); // ------------------------------------------------------------------------------- // Compute an unique value for the vertex format of a mesh -unsigned int GetMeshVFormatUnique(const aiMesh* pcMesh); - +unsigned int GetMeshVFormatUnique(const aiMesh *pcMesh); // defs for ComputeVertexBoneWeightTable() -typedef std::pair PerVertexWeight; -typedef std::vector VertexWeightTable; +typedef std::pair PerVertexWeight; +typedef std::vector VertexWeightTable; // ------------------------------------------------------------------------------- // Compute a per-vertex bone weight table -VertexWeightTable* ComputeVertexBoneWeightTable(const aiMesh* pMesh); +VertexWeightTable *ComputeVertexBoneWeightTable(const aiMesh *pMesh); // ------------------------------------------------------------------------------- // Get a string for a given aiTextureMapping -const char* MappingTypeToString(aiTextureMapping in); - +const char *MappingTypeToString(aiTextureMapping in); // flags for MakeSubmesh() #define AI_SUBMESH_FLAGS_SANS_BONES 0x1 // ------------------------------------------------------------------------------- // Split a mesh given a list of faces to be contained in the sub mesh -aiMesh* MakeSubmesh(const aiMesh *superMesh, const std::vector &subMeshFaces, unsigned int subFlags); +aiMesh *MakeSubmesh(const aiMesh *superMesh, const std::vector &subMeshFaces, unsigned int subFlags); // ------------------------------------------------------------------------------- // Utility postprocess step to share the spatial sort tree between // all steps which use it to speedup its computations. -class ComputeSpatialSortProcess : public BaseProcess -{ - bool IsActive( unsigned int pFlags) const - { - return NULL != shared && 0 != (pFlags & (aiProcess_CalcTangentSpace | - aiProcess_GenNormals | aiProcess_JoinIdenticalVertices)); +class ComputeSpatialSortProcess : public BaseProcess { + bool IsActive(unsigned int pFlags) const { + return nullptr != shared && 0 != (pFlags & (aiProcess_CalcTangentSpace | + aiProcess_GenNormals | aiProcess_JoinIdenticalVertices)); } - void Execute( aiScene* pScene) - { + void Execute(aiScene *pScene) { typedef std::pair _Type; ASSIMP_LOG_DEBUG("Generate spatially-sorted vertex cache"); - std::vector<_Type>* p = new std::vector<_Type>(pScene->mNumMeshes); + std::vector<_Type> *p = new std::vector<_Type>(pScene->mNumMeshes); std::vector<_Type>::iterator it = p->begin(); for (unsigned int i = 0; i < pScene->mNumMeshes; ++i, ++it) { - aiMesh* mesh = pScene->mMeshes[i]; - _Type& blubb = *it; - blubb.first.Fill(mesh->mVertices,mesh->mNumVertices,sizeof(aiVector3D)); + aiMesh *mesh = pScene->mMeshes[i]; + _Type &blubb = *it; + blubb.first.Fill(mesh->mVertices, mesh->mNumVertices, sizeof(aiVector3D)); blubb.second = ComputePositionEpsilon(mesh); } - shared->AddProperty(AI_SPP_SPATIAL_SORT,p); + shared->AddProperty(AI_SPP_SPATIAL_SORT, p); } }; // ------------------------------------------------------------------------------- // ... and the same again to cleanup the whole stuff -class DestroySpatialSortProcess : public BaseProcess -{ - bool IsActive( unsigned int pFlags) const - { - return NULL != shared && 0 != (pFlags & (aiProcess_CalcTangentSpace | - aiProcess_GenNormals | aiProcess_JoinIdenticalVertices)); +class DestroySpatialSortProcess : public BaseProcess { + bool IsActive(unsigned int pFlags) const { + return nullptr != shared && 0 != (pFlags & (aiProcess_CalcTangentSpace | + aiProcess_GenNormals | aiProcess_JoinIdenticalVertices)); } - void Execute( aiScene* /*pScene*/) - { + void Execute(aiScene * /*pScene*/) { shared->RemoveProperty(AI_SPP_SPATIAL_SORT); } }; - - -} // ! namespace Assimp +} // namespace Assimp #endif // !! AI_PROCESS_HELPER_H_INCLUDED diff --git a/code/PostProcessing/RemoveRedundantMaterials.cpp b/code/PostProcessing/RemoveRedundantMaterials.cpp index 0c4280410..498b40a34 100644 --- a/code/PostProcessing/RemoveRedundantMaterials.cpp +++ b/code/PostProcessing/RemoveRedundantMaterials.cpp @@ -122,7 +122,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) // Keep this material even if no mesh references it abReferenced[i] = true; - ASSIMP_LOG_DEBUG_F( "Found positive match in exclusion list: \'", name.data, "\'"); + ASSIMP_LOG_VERBOSE_DEBUG_F( "Found positive match in exclusion list: \'", name.data, "\'"); } } } @@ -197,7 +197,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) // update all material indices for (unsigned int p = 0; p < pScene->mNumMeshes;++p) { aiMesh* mesh = pScene->mMeshes[p]; - ai_assert( NULL!=mesh ); + ai_assert(nullptr != mesh); mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex]; } // delete the old material list diff --git a/code/PostProcessing/RemoveVCProcess.cpp b/code/PostProcessing/RemoveVCProcess.cpp index 5ff5b55fa..82540996e 100644 --- a/code/PostProcessing/RemoveVCProcess.cpp +++ b/code/PostProcessing/RemoveVCProcess.cpp @@ -44,43 +44,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * any parts of the mesh structure from the imported data. */ - #include "RemoveVCProcess.h" #include -#include #include +#include using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer RemoveVCProcess::RemoveVCProcess() : - configDeleteFlags() - , mScene() -{} + configDeleteFlags(), mScene() {} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -RemoveVCProcess::~RemoveVCProcess() -{} +RemoveVCProcess::~RemoveVCProcess() {} // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool RemoveVCProcess::IsActive( unsigned int pFlags) const -{ +bool RemoveVCProcess::IsActive(unsigned int pFlags) const { return (pFlags & aiProcess_RemoveComponent) != 0; } // ------------------------------------------------------------------------------------------------ // Small helper function to delete all elements in a T** aray using delete template -inline void ArrayDelete(T**& in, unsigned int& num) -{ +inline void ArrayDelete(T **&in, unsigned int &num) { for (unsigned int i = 0; i < num; ++i) delete in[i]; delete[] in; - in = NULL; + in = nullptr; num = 0; } @@ -108,9 +102,9 @@ bool UpdateNodeGraph(aiNode* node,std::list& childsOfParent,bool root) { childsOfParent.insert(childsOfParent.end(),mine.begin(),mine.end()); - // set all children to NULL to make sure they are not deleted when we delete ourself + // set all children to nullptr to make sure they are not deleted when we delete ourself for (unsigned int i = 0; i < node->mNumChildren;++i) - node->mChildren[i] = NULL; + node->mChildren[i] = nullptr; } b = true; delete node; @@ -143,86 +137,74 @@ bool UpdateNodeGraph(aiNode* node,std::list& childsOfParent,bool root) // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void RemoveVCProcess::Execute( aiScene* pScene) -{ +void RemoveVCProcess::Execute(aiScene *pScene) { ASSIMP_LOG_DEBUG("RemoveVCProcess begin"); bool bHas = false; //,bMasked = false; mScene = pScene; // handle animations - if ( configDeleteFlags & aiComponent_ANIMATIONS) - { + if (configDeleteFlags & aiComponent_ANIMATIONS) { bHas = true; - ArrayDelete(pScene->mAnimations,pScene->mNumAnimations); + ArrayDelete(pScene->mAnimations, pScene->mNumAnimations); } // handle textures - if ( configDeleteFlags & aiComponent_TEXTURES) - { + if (configDeleteFlags & aiComponent_TEXTURES) { bHas = true; - ArrayDelete(pScene->mTextures,pScene->mNumTextures); + ArrayDelete(pScene->mTextures, pScene->mNumTextures); } // handle materials - if ( configDeleteFlags & aiComponent_MATERIALS && pScene->mNumMaterials) - { + if (configDeleteFlags & aiComponent_MATERIALS && pScene->mNumMaterials) { bHas = true; - for (unsigned int i = 1;i < pScene->mNumMaterials;++i) + for (unsigned int i = 1; i < pScene->mNumMaterials; ++i) delete pScene->mMaterials[i]; pScene->mNumMaterials = 1; - aiMaterial* helper = (aiMaterial*) pScene->mMaterials[0]; - ai_assert(NULL != helper); + aiMaterial *helper = (aiMaterial *)pScene->mMaterials[0]; + ai_assert(nullptr != helper); helper->Clear(); // gray - aiColor3D clr(0.6f,0.6f,0.6f); - helper->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE); + aiColor3D clr(0.6f, 0.6f, 0.6f); + helper->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE); // add a small ambient color value - clr = aiColor3D(0.05f,0.05f,0.05f); - helper->AddProperty(&clr,1,AI_MATKEY_COLOR_AMBIENT); + clr = aiColor3D(0.05f, 0.05f, 0.05f); + helper->AddProperty(&clr, 1, AI_MATKEY_COLOR_AMBIENT); aiString s; s.Set("Dummy_MaterialsRemoved"); - helper->AddProperty(&s,AI_MATKEY_NAME); + helper->AddProperty(&s, AI_MATKEY_NAME); } // handle light sources - if ( configDeleteFlags & aiComponent_LIGHTS) - { - bHas = true; - ArrayDelete(pScene->mLights,pScene->mNumLights); + if (configDeleteFlags & aiComponent_LIGHTS) { + bHas = true; + ArrayDelete(pScene->mLights, pScene->mNumLights); } // handle camneras - if ( configDeleteFlags & aiComponent_CAMERAS) - { + if (configDeleteFlags & aiComponent_CAMERAS) { bHas = true; - ArrayDelete(pScene->mCameras,pScene->mNumCameras); + ArrayDelete(pScene->mCameras, pScene->mNumCameras); } // handle meshes - if (configDeleteFlags & aiComponent_MESHES) - { + if (configDeleteFlags & aiComponent_MESHES) { bHas = true; - ArrayDelete(pScene->mMeshes,pScene->mNumMeshes); - } - else - { - for( unsigned int a = 0; a < pScene->mNumMeshes; a++) - { - if( ProcessMesh( pScene->mMeshes[a])) + ArrayDelete(pScene->mMeshes, pScene->mNumMeshes); + } else { + for (unsigned int a = 0; a < pScene->mNumMeshes; a++) { + if (ProcessMesh(pScene->mMeshes[a])) bHas = true; } } - // now check whether the result is still a full scene - if (!pScene->mNumMeshes || !pScene->mNumMaterials) - { + if (!pScene->mNumMeshes || !pScene->mNumMaterials) { pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; ASSIMP_LOG_DEBUG("Setting AI_SCENE_FLAGS_INCOMPLETE flag"); @@ -240,63 +222,55 @@ void RemoveVCProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Setup configuration properties for the step -void RemoveVCProcess::SetupProperties(const Importer* pImp) -{ - configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,0x0); - if (!configDeleteFlags) - { +void RemoveVCProcess::SetupProperties(const Importer *pImp) { + configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, 0x0); + if (!configDeleteFlags) { ASSIMP_LOG_WARN("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero."); } } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh) -{ +bool RemoveVCProcess::ProcessMesh(aiMesh *pMesh) { bool ret = false; // if all materials have been deleted let the material // index of the mesh point to the created default material - if ( configDeleteFlags & aiComponent_MATERIALS) + if (configDeleteFlags & aiComponent_MATERIALS) pMesh->mMaterialIndex = 0; // handle normals - if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals) - { + if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals) { delete[] pMesh->mNormals; - pMesh->mNormals = NULL; + pMesh->mNormals = nullptr; ret = true; } // handle tangents and bitangents - if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents) - { + if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents) { delete[] pMesh->mTangents; - pMesh->mTangents = NULL; + pMesh->mTangents = nullptr; delete[] pMesh->mBitangents; - pMesh->mBitangents = NULL; + pMesh->mBitangents = nullptr; ret = true; } // handle texture coordinates bool b = (0 != (configDeleteFlags & aiComponent_TEXCOORDS)); - for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++real) - { - if (!pMesh->mTextureCoords[i])break; - if (configDeleteFlags & aiComponent_TEXCOORDSn(real) || b) - { - delete [] pMesh->mTextureCoords[i]; - pMesh->mTextureCoords[i] = NULL; + for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++real) { + if (!pMesh->mTextureCoords[i]) break; + if (configDeleteFlags & aiComponent_TEXCOORDSn(real) || b) { + delete[] pMesh->mTextureCoords[i]; + pMesh->mTextureCoords[i] = nullptr; ret = true; - if (!b) - { + if (!b) { // collapse the rest of the array - for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a) - pMesh->mTextureCoords[a-1] = pMesh->mTextureCoords[a]; + for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) + pMesh->mTextureCoords[a - 1] = pMesh->mTextureCoords[a]; - pMesh->mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS-1] = NULL; + pMesh->mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS - 1] = nullptr; continue; } } @@ -305,22 +279,19 @@ bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh) // handle vertex colors b = (0 != (configDeleteFlags & aiComponent_COLORS)); - for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_COLOR_SETS; ++real) - { - if (!pMesh->mColors[i])break; - if (configDeleteFlags & aiComponent_COLORSn(i) || b) - { - delete [] pMesh->mColors[i]; - pMesh->mColors[i] = NULL; + for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_COLOR_SETS; ++real) { + if (!pMesh->mColors[i]) break; + if (configDeleteFlags & aiComponent_COLORSn(i) || b) { + delete[] pMesh->mColors[i]; + pMesh->mColors[i] = nullptr; ret = true; - if (!b) - { + if (!b) { // collapse the rest of the array - for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a) - pMesh->mColors[a-1] = pMesh->mColors[a]; + for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) + pMesh->mColors[a - 1] = pMesh->mColors[a]; - pMesh->mColors[AI_MAX_NUMBER_OF_COLOR_SETS-1] = NULL; + pMesh->mColors[AI_MAX_NUMBER_OF_COLOR_SETS - 1] = nullptr; continue; } } @@ -328,9 +299,8 @@ bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh) } // handle bones - if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones) - { - ArrayDelete(pMesh->mBones,pMesh->mNumBones); + if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones) { + ArrayDelete(pMesh->mBones, pMesh->mNumBones); ret = true; } return ret; diff --git a/code/PostProcessing/ScaleProcess.h b/code/PostProcessing/ScaleProcess.h index 9cc664c6a..5799dd22c 100644 --- a/code/PostProcessing/ScaleProcess.h +++ b/code/PostProcessing/ScaleProcess.h @@ -94,4 +94,4 @@ private: } // Namespace Assimp -#endif // SCALE_PROCESS_H_ \ No newline at end of file +#endif // SCALE_PROCESS_H_ diff --git a/code/PostProcessing/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp index 87d34c162..c4f9c7e4d 100644 --- a/code/PostProcessing/SortByPTypeProcess.cpp +++ b/code/PostProcessing/SortByPTypeProcess.cpp @@ -45,111 +45,96 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SortByPTypeProcess post-process steps. */ - - // internal headers -#include "ProcessHelper.h" #include "SortByPTypeProcess.h" +#include "ProcessHelper.h" #include using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -SortByPTypeProcess::SortByPTypeProcess() -: mConfigRemoveMeshes( 0 ) { +SortByPTypeProcess::SortByPTypeProcess() : + mConfigRemoveMeshes(0) { // empty } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -SortByPTypeProcess::~SortByPTypeProcess() -{ +SortByPTypeProcess::~SortByPTypeProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool SortByPTypeProcess::IsActive( unsigned int pFlags) const -{ - return (pFlags & aiProcess_SortByPType) != 0; +bool SortByPTypeProcess::IsActive(unsigned int pFlags) const { + return (pFlags & aiProcess_SortByPType) != 0; } // ------------------------------------------------------------------------------------------------ -void SortByPTypeProcess::SetupProperties(const Importer* pImp) -{ - mConfigRemoveMeshes = pImp->GetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE,0); +void SortByPTypeProcess::SetupProperties(const Importer *pImp) { + mConfigRemoveMeshes = pImp->GetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, 0); } // ------------------------------------------------------------------------------------------------ // Update changed meshes in all nodes -void UpdateNodes(const std::vector& replaceMeshIndex, aiNode* node) -{ - if (node->mNumMeshes) - { +void UpdateNodes(const std::vector &replaceMeshIndex, aiNode *node) { + if (node->mNumMeshes) { unsigned int newSize = 0; - for (unsigned int m = 0; m< node->mNumMeshes; ++m) - { - unsigned int add = node->mMeshes[m]<<2; - for (unsigned int i = 0; i < 4;++i) - { - if (UINT_MAX != replaceMeshIndex[add+i])++newSize; + for (unsigned int m = 0; m < node->mNumMeshes; ++m) { + unsigned int add = node->mMeshes[m] << 2; + for (unsigned int i = 0; i < 4; ++i) { + if (UINT_MAX != replaceMeshIndex[add + i]) ++newSize; } } - if (!newSize) - { + if (!newSize) { delete[] node->mMeshes; node->mNumMeshes = 0; - node->mMeshes = NULL; - } - else - { + node->mMeshes = nullptr; + } else { // Try to reuse the old array if possible - unsigned int* newMeshes = (newSize > node->mNumMeshes - ? new unsigned int[newSize] : node->mMeshes); + unsigned int *newMeshes = (newSize > node->mNumMeshes ? new unsigned int[newSize] : node->mMeshes); - for (unsigned int m = 0; m< node->mNumMeshes; ++m) - { - unsigned int add = node->mMeshes[m]<<2; - for (unsigned int i = 0; i < 4;++i) - { - if (UINT_MAX != replaceMeshIndex[add+i]) - *newMeshes++ = replaceMeshIndex[add+i]; + for (unsigned int m = 0; m < node->mNumMeshes; ++m) { + unsigned int add = node->mMeshes[m] << 2; + for (unsigned int i = 0; i < 4; ++i) { + if (UINT_MAX != replaceMeshIndex[add + i]) + *newMeshes++ = replaceMeshIndex[add + i]; } } if (newSize > node->mNumMeshes) delete[] node->mMeshes; - node->mMeshes = newMeshes-(node->mNumMeshes = newSize); + node->mMeshes = newMeshes - (node->mNumMeshes = newSize); } } // call all subnodes recursively for (unsigned int m = 0; m < node->mNumChildren; ++m) - UpdateNodes(replaceMeshIndex,node->mChildren[m]); + UpdateNodes(replaceMeshIndex, node->mChildren[m]); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void SortByPTypeProcess::Execute( aiScene* pScene) { - if ( 0 == pScene->mNumMeshes) { +void SortByPTypeProcess::Execute(aiScene *pScene) { + if (0 == pScene->mNumMeshes) { ASSIMP_LOG_DEBUG("SortByPTypeProcess skipped, there are no meshes"); return; } ASSIMP_LOG_DEBUG("SortByPTypeProcess begin"); - unsigned int aiNumMeshesPerPType[4] = {0,0,0,0}; + unsigned int aiNumMeshesPerPType[4] = { 0, 0, 0, 0 }; - std::vector outMeshes; - outMeshes.reserve(pScene->mNumMeshes<<1u); + std::vector outMeshes; + outMeshes.reserve(pScene->mNumMeshes << 1u); bool bAnyChanges = false; - std::vector replaceMeshIndex(pScene->mNumMeshes*4,UINT_MAX); + std::vector replaceMeshIndex(pScene->mNumMeshes * 4, UINT_MAX); std::vector::iterator meshIdx = replaceMeshIndex.begin(); for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { - aiMesh* const mesh = pScene->mMeshes[i]; + aiMesh *const mesh = pScene->mMeshes[i]; ai_assert(0 != mesh->mPrimitiveTypes); // if there's just one primitive type in the mesh there's nothing to do for us @@ -173,11 +158,11 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { if (1 == num) { if (!(mConfigRemoveMeshes & mesh->mPrimitiveTypes)) { - *meshIdx = static_cast( outMeshes.size() ); + *meshIdx = static_cast(outMeshes.size()); outMeshes.push_back(mesh); } else { delete mesh; - pScene->mMeshes[ i ] = nullptr; + pScene->mMeshes[i] = nullptr; bAnyChanges = true; } @@ -188,32 +173,29 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { // reuse our current mesh arrays for the submesh // with the largest number of primitives - unsigned int aiNumPerPType[4] = {0,0,0,0}; - aiFace* pFirstFace = mesh->mFaces; - aiFace* const pLastFace = pFirstFace + mesh->mNumFaces; + unsigned int aiNumPerPType[4] = { 0, 0, 0, 0 }; + aiFace *pFirstFace = mesh->mFaces; + aiFace *const pLastFace = pFirstFace + mesh->mNumFaces; unsigned int numPolyVerts = 0; - for (;pFirstFace != pLastFace; ++pFirstFace) { + for (; pFirstFace != pLastFace; ++pFirstFace) { if (pFirstFace->mNumIndices <= 3) - ++aiNumPerPType[pFirstFace->mNumIndices-1]; - else - { + ++aiNumPerPType[pFirstFace->mNumIndices - 1]; + else { ++aiNumPerPType[3]; - numPolyVerts += pFirstFace-> mNumIndices; + numPolyVerts += pFirstFace->mNumIndices; } } - VertexWeightTable* avw = ComputeVertexBoneWeightTable(mesh); - for (unsigned int real = 0; real < 4; ++real,++meshIdx) - { - if ( !aiNumPerPType[real] || mConfigRemoveMeshes & (1u << real)) - { + VertexWeightTable *avw = ComputeVertexBoneWeightTable(mesh); + for (unsigned int real = 0; real < 4; ++real, ++meshIdx) { + if (!aiNumPerPType[real] || mConfigRemoveMeshes & (1u << real)) { continue; } - *meshIdx = (unsigned int) outMeshes.size(); + *meshIdx = (unsigned int)outMeshes.size(); outMeshes.push_back(new aiMesh()); - aiMesh* out = outMeshes.back(); + aiMesh *out = outMeshes.back(); // the name carries the adjacency information between the meshes out->mName = mesh->mName; @@ -224,13 +206,13 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { // allocate output storage out->mNumFaces = aiNumPerPType[real]; - aiFace* outFaces = out->mFaces = new aiFace[out->mNumFaces]; + aiFace *outFaces = out->mFaces = new aiFace[out->mNumFaces]; - out->mNumVertices = (3 == real ? numPolyVerts : out->mNumFaces * (real+1)); + out->mNumVertices = (3 == real ? numPolyVerts : out->mNumFaces * (real + 1)); aiVector3D *vert(nullptr), *nor(nullptr), *tan(nullptr), *bit(nullptr); - aiVector3D *uv [AI_MAX_NUMBER_OF_TEXTURECOORDS]; - aiColor4D *cols [AI_MAX_NUMBER_OF_COLOR_SETS]; + aiVector3D *uv[AI_MAX_NUMBER_OF_TEXTURECOORDS]; + aiColor4D *cols[AI_MAX_NUMBER_OF_COLOR_SETS]; if (mesh->mVertices) { vert = out->mVertices = new aiVector3D[out->mNumVertices]; @@ -241,11 +223,11 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { } if (mesh->mTangents) { - tan = out->mTangents = new aiVector3D[out->mNumVertices]; + tan = out->mTangents = new aiVector3D[out->mNumVertices]; bit = out->mBitangents = new aiVector3D[out->mNumVertices]; } - for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_TEXTURECOORDS;++j) { + for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++j) { uv[j] = nullptr; if (mesh->mTextureCoords[j]) { uv[j] = out->mTextureCoords[j] = new aiVector3D[out->mNumVertices]; @@ -254,70 +236,60 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { out->mNumUVComponents[j] = mesh->mNumUVComponents[j]; } - for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_COLOR_SETS;++j) { + for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_COLOR_SETS; ++j) { cols[j] = nullptr; if (mesh->mColors[j]) { cols[j] = out->mColors[j] = new aiColor4D[out->mNumVertices]; } } - typedef std::vector< aiVertexWeight > TempBoneInfo; - std::vector< TempBoneInfo > tempBones(mesh->mNumBones); + typedef std::vector TempBoneInfo; + std::vector tempBones(mesh->mNumBones); // try to guess how much storage we'll need - for (unsigned int q = 0; q < mesh->mNumBones;++q) - { - tempBones[q].reserve(mesh->mBones[q]->mNumWeights / (num-1)); + for (unsigned int q = 0; q < mesh->mNumBones; ++q) { + tempBones[q].reserve(mesh->mBones[q]->mNumWeights / (num - 1)); } unsigned int outIdx = 0; - for (unsigned int m = 0; m < mesh->mNumFaces; ++m) - { - aiFace& in = mesh->mFaces[m]; - if ((real == 3 && in.mNumIndices <= 3) || (real != 3 && in.mNumIndices != real+1)) - { + for (unsigned int m = 0; m < mesh->mNumFaces; ++m) { + aiFace &in = mesh->mFaces[m]; + if ((real == 3 && in.mNumIndices <= 3) || (real != 3 && in.mNumIndices != real + 1)) { continue; } outFaces->mNumIndices = in.mNumIndices; - outFaces->mIndices = in.mIndices; + outFaces->mIndices = in.mIndices; - for (unsigned int q = 0; q < in.mNumIndices; ++q) - { + for (unsigned int q = 0; q < in.mNumIndices; ++q) { unsigned int idx = in.mIndices[q]; // process all bones of this index - if (avw) - { - VertexWeightTable& tbl = avw[idx]; + if (avw) { + VertexWeightTable &tbl = avw[idx]; for (VertexWeightTable::const_iterator it = tbl.begin(), end = tbl.end(); - it != end; ++it) - { - tempBones[ (*it).first ].push_back( aiVertexWeight(outIdx, (*it).second) ); + it != end; ++it) { + tempBones[(*it).first].push_back(aiVertexWeight(outIdx, (*it).second)); } } - if (vert) - { + if (vert) { *vert++ = mesh->mVertices[idx]; //mesh->mVertices[idx].x = get_qnan(); } - if (nor )*nor++ = mesh->mNormals[idx]; - if (tan ) - { - *tan++ = mesh->mTangents[idx]; - *bit++ = mesh->mBitangents[idx]; + if (nor) *nor++ = mesh->mNormals[idx]; + if (tan) { + *tan++ = mesh->mTangents[idx]; + *bit++ = mesh->mBitangents[idx]; } - for (unsigned int pp = 0; pp < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++pp) - { - if (!uv[pp])break; + for (unsigned int pp = 0; pp < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++pp) { + if (!uv[pp]) break; *uv[pp]++ = mesh->mTextureCoords[pp][idx]; } - for (unsigned int pp = 0; pp < AI_MAX_NUMBER_OF_COLOR_SETS; ++pp) - { - if (!cols[pp])break; + for (unsigned int pp = 0; pp < AI_MAX_NUMBER_OF_COLOR_SETS; ++pp) { + if (!cols[pp]) break; *cols[pp]++ = mesh->mColors[pp][idx]; } @@ -330,23 +302,22 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { ai_assert(outFaces == out->mFaces + out->mNumFaces); // now generate output bones - for (unsigned int q = 0; q < mesh->mNumBones; ++q) { - if (!tempBones[q].empty()) { - ++out->mNumBones; - } - } + for (unsigned int q = 0; q < mesh->mNumBones; ++q) { + if (!tempBones[q].empty()) { + ++out->mNumBones; + } + } if (out->mNumBones) { - out->mBones = new aiBone*[out->mNumBones]; - for (unsigned int q = 0, boneIdx = 0; q < mesh->mNumBones;++q) - { - TempBoneInfo& in = tempBones[q]; - if (in.empty()) { - continue; - } + out->mBones = new aiBone *[out->mNumBones]; + for (unsigned int q = 0, boneIdx = 0; q < mesh->mNumBones; ++q) { + TempBoneInfo &in = tempBones[q]; + if (in.empty()) { + continue; + } - aiBone* srcBone = mesh->mBones[q]; - aiBone *bone = out->mBones[boneIdx] = new aiBone(); + aiBone *srcBone = mesh->mBones[q]; + aiBone *bone = out->mBones[boneIdx] = new aiBone(); bone->mName = srcBone->mName; bone->mOffsetMatrix = srcBone->mOffsetMatrix; @@ -354,7 +325,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { bone->mNumWeights = (unsigned int)in.size(); bone->mWeights = new aiVertexWeight[bone->mNumWeights]; - ::memcpy(bone->mWeights,&in[0],bone->mNumWeights*sizeof(aiVertexWeight)); + ::memcpy(bone->mWeights, &in[0], bone->mNumWeights * sizeof(aiVertexWeight)); ++boneIdx; } @@ -371,37 +342,32 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { pScene->mMeshes[i] = nullptr; } - if (outMeshes.empty()) - { + if (outMeshes.empty()) { // This should not occur throw DeadlyImportError("No meshes remaining"); } // If we added at least one mesh process all nodes in the node // graph and update their respective mesh indices. - if (bAnyChanges) - { - UpdateNodes(replaceMeshIndex,pScene->mRootNode); + if (bAnyChanges) { + UpdateNodes(replaceMeshIndex, pScene->mRootNode); } - if (outMeshes.size() != pScene->mNumMeshes) - { + if (outMeshes.size() != pScene->mNumMeshes) { delete[] pScene->mMeshes; pScene->mNumMeshes = (unsigned int)outMeshes.size(); - pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; + pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]; } - ::memcpy(pScene->mMeshes,&outMeshes[0],pScene->mNumMeshes*sizeof(void*)); + ::memcpy(pScene->mMeshes, &outMeshes[0], pScene->mNumMeshes * sizeof(void *)); - if (!DefaultLogger::isNullLogger()) - { + if (!DefaultLogger::isNullLogger()) { char buffer[1024]; - ::ai_snprintf(buffer,1024,"Points: %u%s, Lines: %u%s, Triangles: %u%s, Polygons: %u%s (Meshes, X = removed)", - aiNumMeshesPerPType[0], ((mConfigRemoveMeshes & aiPrimitiveType_POINT) ? "X" : ""), - aiNumMeshesPerPType[1], ((mConfigRemoveMeshes & aiPrimitiveType_LINE) ? "X" : ""), - aiNumMeshesPerPType[2], ((mConfigRemoveMeshes & aiPrimitiveType_TRIANGLE) ? "X" : ""), - aiNumMeshesPerPType[3], ((mConfigRemoveMeshes & aiPrimitiveType_POLYGON) ? "X" : "")); + ::ai_snprintf(buffer, 1024, "Points: %u%s, Lines: %u%s, Triangles: %u%s, Polygons: %u%s (Meshes, X = removed)", + aiNumMeshesPerPType[0], ((mConfigRemoveMeshes & aiPrimitiveType_POINT) ? "X" : ""), + aiNumMeshesPerPType[1], ((mConfigRemoveMeshes & aiPrimitiveType_LINE) ? "X" : ""), + aiNumMeshesPerPType[2], ((mConfigRemoveMeshes & aiPrimitiveType_TRIANGLE) ? "X" : ""), + aiNumMeshesPerPType[3], ((mConfigRemoveMeshes & aiPrimitiveType_POLYGON) ? "X" : "")); ASSIMP_LOG_INFO(buffer); ASSIMP_LOG_DEBUG("SortByPTypeProcess finished"); } } - diff --git a/code/PostProcessing/SplitByBoneCountProcess.cpp b/code/PostProcessing/SplitByBoneCountProcess.cpp index ab7a1fe00..1fd26c757 100644 --- a/code/PostProcessing/SplitByBoneCountProcess.cpp +++ b/code/PostProcessing/SplitByBoneCountProcess.cpp @@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include using namespace Assimp; using namespace Assimp::Formatter; @@ -172,7 +173,15 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormBones[a]; for( unsigned int b = 0; b < bone->mNumWeights; ++b) { - vertexBones[ bone->mWeights[b].mVertexId ].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); + if (bone->mWeights[b].mWeight > 0.0f) + { + int vertexId = bone->mWeights[b].mVertexId; + vertexBones[vertexId].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); + if (vertexBones[vertexId].size() > mMaxBoneCount) + { + throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!"); + } + } } } @@ -188,9 +197,6 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumFaces); // accumulated vertex count of all the faces in this submesh unsigned int numSubMeshVertices = 0; - // a small local array of new bones for the current face. State of all used bones for that face - // can only be updated AFTER the face is completely analysed. Thanks to imre for the fix. - std::vector newBonesAtCurrentFace; // add faces to the new submesh as long as all bones affecting the faces' vertices fit in the limit for( unsigned int a = 0; a < pMesh->mNumFaces; ++a) @@ -200,33 +206,25 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector newBonesAtCurrentFace; + const aiFace& face = pMesh->mFaces[a]; // check every vertex if its bones would still fit into the current submesh for( unsigned int b = 0; b < face.mNumIndices; ++b ) { - const std::vector& vb = vertexBones[face.mIndices[b]]; - for( unsigned int c = 0; c < vb.size(); ++c) + const std::vector& vb = vertexBones[face.mIndices[b]]; + for( unsigned int c = 0; c < vb.size(); ++c) + { + unsigned int boneIndex = vb[c].first; + if( !isBoneUsed[boneIndex] ) { - unsigned int boneIndex = vb[c].first; - // if the bone is already used in this submesh, it's ok - if( isBoneUsed[boneIndex] ) - { - continue; - } - - // if it's not used, yet, we would need to add it. Store its bone index - if( std::find( newBonesAtCurrentFace.begin(), newBonesAtCurrentFace.end(), boneIndex) == newBonesAtCurrentFace.end() ) - { - newBonesAtCurrentFace.push_back( boneIndex); - } - } + newBonesAtCurrentFace.insert(boneIndex); + } + } } - if (newBonesAtCurrentFace.size() > mMaxBoneCount) - { - throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!"); - } // leave out the face if the new bones required for this face don't fit the bone count limit anymore if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount ) { @@ -234,17 +232,13 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector::iterator it = newBonesAtCurrentFace.begin(); it != newBonesAtCurrentFace.end(); ++it) { - unsigned int newIndex = newBonesAtCurrentFace.back(); - newBonesAtCurrentFace.pop_back(); // this also avoids the deallocation which comes with a clear() - if( isBoneUsed[newIndex] ) - { - continue; - } - - isBoneUsed[newIndex] = true; + if (!isBoneUsed[*it]) + { + isBoneUsed[*it] = true; numBones++; + } } // store the face index and the vertex count diff --git a/code/PostProcessing/TextureTransform.cpp b/code/PostProcessing/TextureTransform.cpp index 654586111..e3683763a 100644 --- a/code/PostProcessing/TextureTransform.cpp +++ b/code/PostProcessing/TextureTransform.cpp @@ -508,7 +508,7 @@ void TextureTransformStep::Execute( aiScene* pScene) aiVector3D* dest, *end; dest = mesh->mTextureCoords[n]; - ai_assert(NULL != src); + ai_assert(nullptr != src); // Copy the data to the destination array if (dest != src) diff --git a/code/PostProcessing/TriangulateProcess.cpp b/code/PostProcessing/TriangulateProcess.cpp index 3fd7eea21..8035b34f4 100644 --- a/code/PostProcessing/TriangulateProcess.cpp +++ b/code/PostProcessing/TriangulateProcess.cpp @@ -161,7 +161,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) // Just another check whether aiMesh::mPrimitiveTypes is correct ai_assert(numOut != pMesh->mNumFaces); - aiVector3D* nor_out = NULL; + aiVector3D *nor_out = nullptr; // if we don't have normals yet, but expect them to be a cheap side // product of triangulation anyway, allocate storage for them. @@ -220,7 +220,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) nface.mNumIndices = face.mNumIndices; nface.mIndices = face.mIndices; - face.mIndices = NULL; + face.mIndices = nullptr; continue; } // optimized code for quadrilaterals @@ -272,7 +272,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) sface.mIndices[2] = temp[(start_vertex + 3) % 4]; // prevent double deletion of the indices field - face.mIndices = NULL; + face.mIndices = nullptr; continue; } else @@ -490,7 +490,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) // drop dumb 0-area triangles - deactivated for now: //FindDegenerates post processing step can do the same thing //if (std::fabs(GetArea2D(temp_verts[i[0]],temp_verts[i[1]],temp_verts[i[2]])) < 1e-5f) { - // ASSIMP_LOG_DEBUG("Dropping triangle with area 0"); + // ASSIMP_LOG_VERBOSE_DEBUG("Dropping triangle with area 0"); // --curOut; // delete[] f->mIndices; @@ -511,7 +511,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) } delete[] face.mIndices; - face.mIndices = NULL; + face.mIndices = nullptr; } #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index ba31f36d6..a288e397d 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -1,4 +1,4 @@ -/* +/* --------------------------------------------------------------------------- Open Asset Import Library (assimp) --------------------------------------------------------------------------- @@ -48,9 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers #include "ValidateDataStructure.h" +#include "ProcessHelper.h" #include #include -#include "ProcessHelper.h" #include // CRT headers @@ -61,80 +61,69 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ValidateDSProcess::ValidateDSProcess() : - mScene() -{} + mScene() {} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -ValidateDSProcess::~ValidateDSProcess() -{} +ValidateDSProcess::~ValidateDSProcess() {} // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool ValidateDSProcess::IsActive( unsigned int pFlags) const -{ +bool ValidateDSProcess::IsActive(unsigned int pFlags) const { return (pFlags & aiProcess_ValidateDataStructure) != 0; } // ------------------------------------------------------------------------------------------------ -AI_WONT_RETURN void ValidateDSProcess::ReportError(const char* msg,...) -{ - ai_assert(NULL != msg); +AI_WONT_RETURN void ValidateDSProcess::ReportError(const char *msg, ...) { + ai_assert(nullptr != msg); va_list args; - va_start(args,msg); + va_start(args, msg); char szBuffer[3000]; - const int iLen = vsprintf(szBuffer,msg,args); + const int iLen = vsprintf(szBuffer, msg, args); ai_assert(iLen > 0); va_end(args); - throw DeadlyImportError("Validation failed: " + std::string(szBuffer,iLen)); + throw DeadlyImportError("Validation failed: " + std::string(szBuffer, iLen)); } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::ReportWarning(const char* msg,...) -{ - ai_assert(NULL != msg); +void ValidateDSProcess::ReportWarning(const char *msg, ...) { + ai_assert(nullptr != msg); va_list args; - va_start(args,msg); + va_start(args, msg); char szBuffer[3000]; - const int iLen = vsprintf(szBuffer,msg,args); + const int iLen = vsprintf(szBuffer, msg, args); ai_assert(iLen > 0); va_end(args); - ASSIMP_LOG_WARN("Validation warning: " + std::string(szBuffer,iLen)); + ASSIMP_LOG_WARN("Validation warning: " + std::string(szBuffer, iLen)); } // ------------------------------------------------------------------------------------------------ -inline -int HasNameMatch(const aiString& in, aiNode* node) { - int result = (node->mName == in ? 1 : 0 ); - for (unsigned int i = 0; i < node->mNumChildren;++i) { - result += HasNameMatch(in,node->mChildren[i]); +inline int HasNameMatch(const aiString &in, aiNode *node) { + int result = (node->mName == in ? 1 : 0); + for (unsigned int i = 0; i < node->mNumChildren; ++i) { + result += HasNameMatch(in, node->mChildren[i]); } return result; } // ------------------------------------------------------------------------------------------------ template -inline -void ValidateDSProcess::DoValidation(T** parray, unsigned int size, const char* firstName, const char* secondName) { +inline void ValidateDSProcess::DoValidation(T **parray, unsigned int size, const char *firstName, const char *secondName) { // validate all entries - if (size) - { - if (!parray) - { - ReportError("aiScene::%s is NULL (aiScene::%s is %i)", - firstName, secondName, size); + if (size) { + if (!parray) { + ReportError("aiScene::%s is nullptr (aiScene::%s is %i)", + firstName, secondName, size); } - for (unsigned int i = 0; i < size;++i) - { - if (!parray[i]) - { - ReportError("aiScene::%s[%i] is NULL (aiScene::%s is %i)", - firstName,i,secondName,size); + for (unsigned int i = 0; i < size; ++i) { + if (!parray[i]) { + ReportError("aiScene::%s[%i] is nullptr (aiScene::%s is %i)", + firstName, i, secondName, size); } Validate(parray[i]); } @@ -143,32 +132,27 @@ void ValidateDSProcess::DoValidation(T** parray, unsigned int size, const char* // ------------------------------------------------------------------------------------------------ template -inline void ValidateDSProcess::DoValidationEx(T** parray, unsigned int size, - const char* firstName, const char* secondName) -{ +inline void ValidateDSProcess::DoValidationEx(T **parray, unsigned int size, + const char *firstName, const char *secondName) { // validate all entries - if (size) - { - if (!parray) { - ReportError("aiScene::%s is NULL (aiScene::%s is %i)", - firstName, secondName, size); + if (size) { + if (!parray) { + ReportError("aiScene::%s is nullptr (aiScene::%s is %i)", + firstName, secondName, size); } - for (unsigned int i = 0; i < size;++i) - { - if (!parray[i]) - { - ReportError("aiScene::%s[%u] is NULL (aiScene::%s is %u)", - firstName,i,secondName,size); + for (unsigned int i = 0; i < size; ++i) { + if (!parray[i]) { + ReportError("aiScene::%s[%u] is nullptr (aiScene::%s is %u)", + firstName, i, secondName, size); } Validate(parray[i]); // check whether there are duplicate names - for (unsigned int a = i+1; a < size;++a) - { - if (parray[i]->mName == parray[a]->mName) - { - ReportError("aiScene::%s[%u] has the same name as " - "aiScene::%s[%u]",firstName, i,secondName, a); + for (unsigned int a = i + 1; a < size; ++a) { + if (parray[i]->mName == parray[a]->mName) { + ReportError("aiScene::%s[%u] has the same name as " + "aiScene::%s[%u]", + firstName, i, secondName, a); } } } @@ -177,29 +161,28 @@ inline void ValidateDSProcess::DoValidationEx(T** parray, unsigned int size, // ------------------------------------------------------------------------------------------------ template -inline -void ValidateDSProcess::DoValidationWithNameCheck(T** array, unsigned int size, const char* firstName, - const char* secondName) { +inline void ValidateDSProcess::DoValidationWithNameCheck(T **array, unsigned int size, const char *firstName, + const char *secondName) { // validate all entries - DoValidationEx(array,size,firstName,secondName); + DoValidationEx(array, size, firstName, secondName); - for (unsigned int i = 0; i < size;++i) { - int res = HasNameMatch(array[i]->mName,mScene->mRootNode); - if (0 == res) { - const std::string name = static_cast(array[i]->mName.data); + for (unsigned int i = 0; i < size; ++i) { + int res = HasNameMatch(array[i]->mName, mScene->mRootNode); + if (0 == res) { + const std::string name = static_cast(array[i]->mName.data); ReportError("aiScene::%s[%i] has no corresponding node in the scene graph (%s)", - firstName,i, name.c_str()); - } else if (1 != res) { - const std::string name = static_cast(array[i]->mName.data); + firstName, i, name.c_str()); + } else if (1 != res) { + const std::string name = static_cast(array[i]->mName.data); ReportError("aiScene::%s[%i]: there are more than one nodes with %s as name", - firstName,i, name.c_str()); + firstName, i, name.c_str()); } } } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void ValidateDSProcess::Execute( aiScene* pScene) { +void ValidateDSProcess::Execute(aiScene *pScene) { mScene = pScene; ASSIMP_LOG_DEBUG("ValidateDataStructureProcess begin"); @@ -208,54 +191,48 @@ void ValidateDSProcess::Execute( aiScene* pScene) { // validate all meshes if (pScene->mNumMeshes) { - DoValidation(pScene->mMeshes,pScene->mNumMeshes,"mMeshes","mNumMeshes"); - } - else if (!(mScene->mFlags & AI_SCENE_FLAGS_INCOMPLETE)) { + DoValidation(pScene->mMeshes, pScene->mNumMeshes, "mMeshes", "mNumMeshes"); + } else if (!(mScene->mFlags & AI_SCENE_FLAGS_INCOMPLETE)) { ReportError("aiScene::mNumMeshes is 0. At least one mesh must be there"); - } - else if (pScene->mMeshes) { + } else if (pScene->mMeshes) { ReportError("aiScene::mMeshes is non-null although there are no meshes"); } // validate all animations if (pScene->mNumAnimations) { - DoValidation(pScene->mAnimations,pScene->mNumAnimations, - "mAnimations","mNumAnimations"); - } - else if (pScene->mAnimations) { + DoValidation(pScene->mAnimations, pScene->mNumAnimations, + "mAnimations", "mNumAnimations"); + } else if (pScene->mAnimations) { ReportError("aiScene::mAnimations is non-null although there are no animations"); } // validate all cameras if (pScene->mNumCameras) { - DoValidationWithNameCheck(pScene->mCameras,pScene->mNumCameras, - "mCameras","mNumCameras"); - } - else if (pScene->mCameras) { + DoValidationWithNameCheck(pScene->mCameras, pScene->mNumCameras, + "mCameras", "mNumCameras"); + } else if (pScene->mCameras) { ReportError("aiScene::mCameras is non-null although there are no cameras"); } // validate all lights if (pScene->mNumLights) { - DoValidationWithNameCheck(pScene->mLights,pScene->mNumLights, - "mLights","mNumLights"); - } - else if (pScene->mLights) { + DoValidationWithNameCheck(pScene->mLights, pScene->mNumLights, + "mLights", "mNumLights"); + } else if (pScene->mLights) { ReportError("aiScene::mLights is non-null although there are no lights"); } // validate all textures if (pScene->mNumTextures) { - DoValidation(pScene->mTextures,pScene->mNumTextures, - "mTextures","mNumTextures"); - } - else if (pScene->mTextures) { + DoValidation(pScene->mTextures, pScene->mNumTextures, + "mTextures", "mNumTextures"); + } else if (pScene->mTextures) { ReportError("aiScene::mTextures is non-null although there are no textures"); } // validate all materials if (pScene->mNumMaterials) { - DoValidation(pScene->mMaterials,pScene->mNumMaterials,"mMaterials","mNumMaterials"); + DoValidation(pScene->mMaterials, pScene->mNumMaterials, "mMaterials", "mNumMaterials"); } #if 0 // NOTE: ScenePreprocessor generates a default material if none is there @@ -263,104 +240,95 @@ void ValidateDSProcess::Execute( aiScene* pScene) { ReportError("aiScene::mNumMaterials is 0. At least one material must be there"); } #endif - else if (pScene->mMaterials) { + else if (pScene->mMaterials) { ReportError("aiScene::mMaterials is non-null although there are no materials"); } -// if (!has)ReportError("The aiScene data structure is empty"); + // if (!has)ReportError("The aiScene data structure is empty"); ASSIMP_LOG_DEBUG("ValidateDataStructureProcess end"); } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiLight* pLight) -{ +void ValidateDSProcess::Validate(const aiLight *pLight) { if (pLight->mType == aiLightSource_UNDEFINED) ReportWarning("aiLight::mType is aiLightSource_UNDEFINED"); if (!pLight->mAttenuationConstant && - !pLight->mAttenuationLinear && - !pLight->mAttenuationQuadratic) { + !pLight->mAttenuationLinear && + !pLight->mAttenuationQuadratic) { ReportWarning("aiLight::mAttenuationXXX - all are zero"); } if (pLight->mAngleInnerCone > pLight->mAngleOuterCone) ReportError("aiLight::mAngleInnerCone is larger than aiLight::mAngleOuterCone"); - if (pLight->mColorDiffuse.IsBlack() && pLight->mColorAmbient.IsBlack() - && pLight->mColorSpecular.IsBlack()) - { + if (pLight->mColorDiffuse.IsBlack() && pLight->mColorAmbient.IsBlack() && pLight->mColorSpecular.IsBlack()) { ReportWarning("aiLight::mColorXXX - all are black and won't have any influence"); } } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiCamera* pCamera) -{ +void ValidateDSProcess::Validate(const aiCamera *pCamera) { if (pCamera->mClipPlaneFar <= pCamera->mClipPlaneNear) ReportError("aiCamera::mClipPlaneFar must be >= aiCamera::mClipPlaneNear"); // FIX: there are many 3ds files with invalid FOVs. No reason to // reject them at all ... a warning is appropriate. if (!pCamera->mHorizontalFOV || pCamera->mHorizontalFOV >= (float)AI_MATH_PI) - ReportWarning("%f is not a valid value for aiCamera::mHorizontalFOV",pCamera->mHorizontalFOV); + ReportWarning("%f is not a valid value for aiCamera::mHorizontalFOV", pCamera->mHorizontalFOV); } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiMesh* pMesh) -{ +void ValidateDSProcess::Validate(const aiMesh *pMesh) { // validate the material index of the mesh - if (mScene->mNumMaterials && pMesh->mMaterialIndex >= mScene->mNumMaterials) - { + if (mScene->mNumMaterials && pMesh->mMaterialIndex >= mScene->mNumMaterials) { ReportError("aiMesh::mMaterialIndex is invalid (value: %i maximum: %i)", - pMesh->mMaterialIndex,mScene->mNumMaterials-1); + pMesh->mMaterialIndex, mScene->mNumMaterials - 1); } Validate(&pMesh->mName); - for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) - { - aiFace& face = pMesh->mFaces[i]; + for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) { + aiFace &face = pMesh->mFaces[i]; - if (pMesh->mPrimitiveTypes) - { - switch (face.mNumIndices) - { + if (pMesh->mPrimitiveTypes) { + switch (face.mNumIndices) { case 0: - ReportError("aiMesh::mFaces[%i].mNumIndices is 0",i); + ReportError("aiMesh::mFaces[%i].mNumIndices is 0", i); break; case 1: - if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT)) - { + if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT)) { ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimitiveTypes " - "does not report the POINT flag",i); + "does not report the POINT flag", + i); } break; case 2: - if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_LINE)) - { + if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_LINE)) { ReportError("aiMesh::mFaces[%i] is a LINE but aiMesh::mPrimitiveTypes " - "does not report the LINE flag",i); + "does not report the LINE flag", + i); } break; case 3: - if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE)) - { + if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE)) { ReportError("aiMesh::mFaces[%i] is a TRIANGLE but aiMesh::mPrimitiveTypes " - "does not report the TRIANGLE flag",i); + "does not report the TRIANGLE flag", + i); } break; default: - if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) - { + if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) { this->ReportError("aiMesh::mFaces[%i] is a POLYGON but aiMesh::mPrimitiveTypes " - "does not report the POLYGON flag",i); + "does not report the POLYGON flag", + i); } break; }; } if (!face.mIndices) - ReportError("aiMesh::mFaces[%i].mIndices is NULL",i); + ReportError("aiMesh::mFaces[%i].mIndices is nullptr", i); } // positions must always be there ... @@ -369,42 +337,40 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh) } if (pMesh->mNumVertices > AI_MAX_VERTICES) { - ReportError("Mesh has too many vertices: %u, but the limit is %u",pMesh->mNumVertices,AI_MAX_VERTICES); + ReportError("Mesh has too many vertices: %u, but the limit is %u", pMesh->mNumVertices, AI_MAX_VERTICES); } if (pMesh->mNumFaces > AI_MAX_FACES) { - ReportError("Mesh has too many faces: %u, but the limit is %u",pMesh->mNumFaces,AI_MAX_FACES); + ReportError("Mesh has too many faces: %u, but the limit is %u", pMesh->mNumFaces, AI_MAX_FACES); } // if tangents are there there must also be bitangent vectors ... - if ((pMesh->mTangents != NULL) != (pMesh->mBitangents != NULL)) { + if ((pMesh->mTangents != nullptr) != (pMesh->mBitangents != nullptr)) { ReportError("If there are tangents, bitangent vectors must be present as well"); } // faces, too - if (!pMesh->mNumFaces || (!pMesh->mFaces && !mScene->mFlags)) { + if (!pMesh->mNumFaces || (!pMesh->mFaces && !mScene->mFlags)) { ReportError("Mesh %s contains no faces", pMesh->mName.C_Str()); } // now check whether the face indexing layout is correct: // unique vertices, pseudo-indexed. std::vector abRefList; - abRefList.resize(pMesh->mNumVertices,false); - for (unsigned int i = 0; i < pMesh->mNumFaces;++i) - { - aiFace& face = pMesh->mFaces[i]; + abRefList.resize(pMesh->mNumVertices, false); + for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) { + aiFace &face = pMesh->mFaces[i]; if (face.mNumIndices > AI_MAX_FACE_INDICES) { - ReportError("Face %u has too many faces: %u, but the limit is %u",i,face.mNumIndices,AI_MAX_FACE_INDICES); + ReportError("Face %u has too many faces: %u, but the limit is %u", i, face.mNumIndices, AI_MAX_FACE_INDICES); } - for (unsigned int a = 0; a < face.mNumIndices;++a) - { - if (face.mIndices[a] >= pMesh->mNumVertices) { - ReportError("aiMesh::mFaces[%i]::mIndices[%i] is out of range",i,a); + for (unsigned int a = 0; a < face.mNumIndices; ++a) { + if (face.mIndices[a] >= pMesh->mNumVertices) { + ReportError("aiMesh::mFaces[%i]::mIndices[%i] is out of range", i, a); } // the MSB flag is temporarily used by the extra verbose // mode to tell us that the JoinVerticesProcess might have // been executed already. - /*if ( !(this->mScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT ) && !(this->mScene->mFlags & AI_SCENE_FLAGS_ALLOW_SHARED) && + /*if ( !(this->mScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT ) && !(this->mScene->mFlags & AI_SCENE_FLAGS_ALLOW_SHARED) && abRefList[face.mIndices[a]]) { ReportError("aiMesh::mVertices[%i] is referenced twice - second " @@ -416,168 +382,146 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh) // check whether there are vertices that aren't referenced by a face bool b = false; - for (unsigned int i = 0; i < pMesh->mNumVertices;++i) { - if (!abRefList[i])b = true; + for (unsigned int i = 0; i < pMesh->mNumVertices; ++i) { + if (!abRefList[i]) b = true; } abRefList.clear(); if (b) { - ReportWarning("There are unreferenced vertices"); + ReportWarning("There are unreferenced vertices"); } // texture channel 2 may not be set if channel 1 is zero ... { unsigned int i = 0; - for (;i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) - { - if (!pMesh->HasTextureCoords(i))break; + for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { + if (!pMesh->HasTextureCoords(i)) break; } - for (;i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) - if (pMesh->HasTextureCoords(i)) - { + for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) + if (pMesh->HasTextureCoords(i)) { ReportError("Texture coordinate channel %i exists " - "although the previous channel was NULL.",i); + "although the previous channel was nullptr.", + i); } } // the same for the vertex colors { unsigned int i = 0; - for (;i < AI_MAX_NUMBER_OF_COLOR_SETS;++i) - { - if (!pMesh->HasVertexColors(i))break; + for (; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) { + if (!pMesh->HasVertexColors(i)) break; } - for (;i < AI_MAX_NUMBER_OF_COLOR_SETS;++i) - if (pMesh->HasVertexColors(i)) - { + for (; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) + if (pMesh->HasVertexColors(i)) { ReportError("Vertex color channel %i is exists " - "although the previous channel was NULL.",i); + "although the previous channel was nullptr.", + i); } } - // now validate all bones - if (pMesh->mNumBones) - { - if (!pMesh->mBones) - { - ReportError("aiMesh::mBones is NULL (aiMesh::mNumBones is %i)", - pMesh->mNumBones); + if (pMesh->mNumBones) { + if (!pMesh->mBones) { + ReportError("aiMesh::mBones is nullptr (aiMesh::mNumBones is %i)", + pMesh->mNumBones); } std::unique_ptr afSum(nullptr); - if (pMesh->mNumVertices) - { + if (pMesh->mNumVertices) { afSum.reset(new float[pMesh->mNumVertices]); - for (unsigned int i = 0; i < pMesh->mNumVertices;++i) + for (unsigned int i = 0; i < pMesh->mNumVertices; ++i) afSum[i] = 0.0f; } // check whether there are duplicate bone names - for (unsigned int i = 0; i < pMesh->mNumBones;++i) - { - const aiBone* bone = pMesh->mBones[i]; + for (unsigned int i = 0; i < pMesh->mNumBones; ++i) { + const aiBone *bone = pMesh->mBones[i]; if (bone->mNumWeights > AI_MAX_BONE_WEIGHTS) { - ReportError("Bone %u has too many weights: %u, but the limit is %u",i,bone->mNumWeights,AI_MAX_BONE_WEIGHTS); + ReportError("Bone %u has too many weights: %u, but the limit is %u", i, bone->mNumWeights, AI_MAX_BONE_WEIGHTS); } - if (!pMesh->mBones[i]) - { - ReportError("aiMesh::mBones[%i] is NULL (aiMesh::mNumBones is %i)", - i,pMesh->mNumBones); + if (!pMesh->mBones[i]) { + ReportError("aiMesh::mBones[%i] is nullptr (aiMesh::mNumBones is %i)", + i, pMesh->mNumBones); } - Validate(pMesh,pMesh->mBones[i],afSum.get()); + Validate(pMesh, pMesh->mBones[i], afSum.get()); - for (unsigned int a = i+1; a < pMesh->mNumBones;++a) - { - if (pMesh->mBones[i]->mName == pMesh->mBones[a]->mName) - { + for (unsigned int a = i + 1; a < pMesh->mNumBones; ++a) { + if (pMesh->mBones[i]->mName == pMesh->mBones[a]->mName) { const char *name = "unknown"; - if (nullptr != pMesh->mBones[ i ]->mName.C_Str()) { - name = pMesh->mBones[ i ]->mName.C_Str(); + if (nullptr != pMesh->mBones[i]->mName.C_Str()) { + name = pMesh->mBones[i]->mName.C_Str(); } ReportError("aiMesh::mBones[%i], name = \"%s\" has the same name as " - "aiMesh::mBones[%i]", i, name, a ); + "aiMesh::mBones[%i]", + i, name, a); } } } // check whether all bone weights for a vertex sum to 1.0 ... - for (unsigned int i = 0; i < pMesh->mNumVertices;++i) - { + for (unsigned int i = 0; i < pMesh->mNumVertices; ++i) { if (afSum[i] && (afSum[i] <= 0.94 || afSum[i] >= 1.05)) { - ReportWarning("aiMesh::mVertices[%i]: bone weight sum != 1.0 (sum is %f)",i,afSum[i]); + ReportWarning("aiMesh::mVertices[%i]: bone weight sum != 1.0 (sum is %f)", i, afSum[i]); } } - } - else if (pMesh->mBones) - { + } else if (pMesh->mBones) { ReportError("aiMesh::mBones is non-null although there are no bones"); } } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiMesh* pMesh, const aiBone* pBone,float* afSum) { +void ValidateDSProcess::Validate(const aiMesh *pMesh, const aiBone *pBone, float *afSum) { this->Validate(&pBone->mName); - if (!pBone->mNumWeights) { + if (!pBone->mNumWeights) { //ReportError("aiBone::mNumWeights is zero"); } // check whether all vertices affected by this bone are valid - for (unsigned int i = 0; i < pBone->mNumWeights;++i) - { - if (pBone->mWeights[i].mVertexId >= pMesh->mNumVertices) { - ReportError("aiBone::mWeights[%i].mVertexId is out of range",i); - } - else if (!pBone->mWeights[i].mWeight || pBone->mWeights[i].mWeight > 1.0f) { - ReportWarning("aiBone::mWeights[%i].mWeight has an invalid value",i); + for (unsigned int i = 0; i < pBone->mNumWeights; ++i) { + if (pBone->mWeights[i].mVertexId >= pMesh->mNumVertices) { + ReportError("aiBone::mWeights[%i].mVertexId is out of range", i); + } else if (!pBone->mWeights[i].mWeight || pBone->mWeights[i].mWeight > 1.0f) { + ReportWarning("aiBone::mWeights[%i].mWeight has an invalid value", i); } afSum[pBone->mWeights[i].mVertexId] += pBone->mWeights[i].mWeight; } } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiAnimation* pAnimation) -{ +void ValidateDSProcess::Validate(const aiAnimation *pAnimation) { Validate(&pAnimation->mName); // validate all animations - if (pAnimation->mNumChannels || pAnimation->mNumMorphMeshChannels) - { + if (pAnimation->mNumChannels || pAnimation->mNumMorphMeshChannels) { if (!pAnimation->mChannels && pAnimation->mNumChannels) { - ReportError("aiAnimation::mChannels is NULL (aiAnimation::mNumChannels is %i)", - pAnimation->mNumChannels); + ReportError("aiAnimation::mChannels is nullptr (aiAnimation::mNumChannels is %i)", + pAnimation->mNumChannels); } if (!pAnimation->mMorphMeshChannels && pAnimation->mNumMorphMeshChannels) { - ReportError("aiAnimation::mMorphMeshChannels is NULL (aiAnimation::mNumMorphMeshChannels is %i)", - pAnimation->mNumMorphMeshChannels); + ReportError("aiAnimation::mMorphMeshChannels is nullptr (aiAnimation::mNumMorphMeshChannels is %i)", + pAnimation->mNumMorphMeshChannels); } - for (unsigned int i = 0; i < pAnimation->mNumChannels;++i) - { - if (!pAnimation->mChannels[i]) - { - ReportError("aiAnimation::mChannels[%i] is NULL (aiAnimation::mNumChannels is %i)", - i, pAnimation->mNumChannels); + for (unsigned int i = 0; i < pAnimation->mNumChannels; ++i) { + if (!pAnimation->mChannels[i]) { + ReportError("aiAnimation::mChannels[%i] is nullptr (aiAnimation::mNumChannels is %i)", + i, pAnimation->mNumChannels); } Validate(pAnimation, pAnimation->mChannels[i]); } - for (unsigned int i = 0; i < pAnimation->mNumMorphMeshChannels;++i) - { - if (!pAnimation->mMorphMeshChannels[i]) - { - ReportError("aiAnimation::mMorphMeshChannels[%i] is NULL (aiAnimation::mNumMorphMeshChannels is %i)", - i, pAnimation->mNumMorphMeshChannels); + for (unsigned int i = 0; i < pAnimation->mNumMorphMeshChannels; ++i) { + if (!pAnimation->mMorphMeshChannels[i]) { + ReportError("aiAnimation::mMorphMeshChannels[%i] is nullptr (aiAnimation::mNumMorphMeshChannels is %i)", + i, pAnimation->mNumMorphMeshChannels); } Validate(pAnimation, pAnimation->mMorphMeshChannels[i]); } - } - else { - ReportError("aiAnimation::mNumChannels is 0. At least one node animation channel must be there."); + } else { + ReportError("aiAnimation::mNumChannels is 0. At least one node animation channel must be there."); } } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial, - aiTextureType type) -{ - const char* szType = TextureTypeToString(type); +void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial *pMaterial, + aiTextureType type) { + const char *szType = TextureTypeToString(type); // **************************************************************************** // Search all keys of the material ... @@ -587,11 +531,11 @@ void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial, int iNumIndices = 0; int iIndex = -1; - for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) { - aiMaterialProperty* prop = pMaterial->mProperties[ i ]; + for (unsigned int i = 0; i < pMaterial->mNumProperties; ++i) { + aiMaterialProperty *prop = pMaterial->mProperties[i]; ai_assert(nullptr != prop); - if ( !::strcmp(prop->mKey.data,"$tex.file") && prop->mSemantic == static_cast(type)) { - iIndex = std::max(iIndex, (int) prop->mIndex); + if (!::strcmp(prop->mKey.data, "$tex.file") && prop->mSemantic == static_cast(type)) { + iIndex = std::max(iIndex, (int)prop->mIndex); ++iNumIndices; if (aiPTI_String != prop->mType) { @@ -599,87 +543,75 @@ void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial, } } } - if (iIndex +1 != iNumIndices) { + if (iIndex + 1 != iNumIndices) { ReportError("%s #%i is set, but there are only %i %s textures", - szType,iIndex,iNumIndices,szType); + szType, iIndex, iNumIndices, szType); + } + if (!iNumIndices) { + return; } - if (!iNumIndices) { - return; - } std::vector mappings(iNumIndices); // Now check whether all UV indices are valid ... bool bNoSpecified = true; - for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) { - aiMaterialProperty* prop = pMaterial->mProperties[i]; - if (static_cast(prop->mSemantic) != type) { - continue; - } + for (unsigned int i = 0; i < pMaterial->mNumProperties; ++i) { + aiMaterialProperty *prop = pMaterial->mProperties[i]; + if (static_cast(prop->mSemantic) != type) { + continue; + } - if ((int)prop->mIndex >= iNumIndices) - { + if ((int)prop->mIndex >= iNumIndices) { ReportError("Found texture property with index %i, although there " - "are only %i textures of type %s", - prop->mIndex, iNumIndices, szType); + "are only %i textures of type %s", + prop->mIndex, iNumIndices, szType); } - if (!::strcmp(prop->mKey.data,"$tex.mapping")) { - if (aiPTI_Integer != prop->mType || prop->mDataLength < sizeof(aiTextureMapping)) - { + if (!::strcmp(prop->mKey.data, "$tex.mapping")) { + if (aiPTI_Integer != prop->mType || prop->mDataLength < sizeof(aiTextureMapping)) { ReportError("Material property %s%i is expected to be an integer (size is %i)", - prop->mKey.data,prop->mIndex,prop->mDataLength); + prop->mKey.data, prop->mIndex, prop->mDataLength); } - mappings[prop->mIndex] = *((aiTextureMapping*)prop->mData); - } - else if (!::strcmp(prop->mKey.data,"$tex.uvtrafo")) { - if (aiPTI_Float != prop->mType || prop->mDataLength < sizeof(aiUVTransform)) - { + mappings[prop->mIndex] = *((aiTextureMapping *)prop->mData); + } else if (!::strcmp(prop->mKey.data, "$tex.uvtrafo")) { + if (aiPTI_Float != prop->mType || prop->mDataLength < sizeof(aiUVTransform)) { ReportError("Material property %s%i is expected to be 5 floats large (size is %i)", - prop->mKey.data,prop->mIndex, prop->mDataLength); + prop->mKey.data, prop->mIndex, prop->mDataLength); } - //mappings[prop->mIndex] = ((aiUVTransform*)prop->mData); - } - else if (!::strcmp(prop->mKey.data,"$tex.uvwsrc")) { - if (aiPTI_Integer != prop->mType || sizeof(int) > prop->mDataLength) - { + //mappings[prop->mIndex] = ((aiUVTransform*)prop->mData); + } else if (!::strcmp(prop->mKey.data, "$tex.uvwsrc")) { + if (aiPTI_Integer != prop->mType || sizeof(int) > prop->mDataLength) { ReportError("Material property %s%i is expected to be an integer (size is %i)", - prop->mKey.data,prop->mIndex,prop->mDataLength); + prop->mKey.data, prop->mIndex, prop->mDataLength); } bNoSpecified = false; // Ignore UV indices for texture channels that are not there ... // Get the value - iIndex = *((unsigned int*)prop->mData); + iIndex = *((unsigned int *)prop->mData); // Check whether there is a mesh using this material // which has not enough UV channels ... - for (unsigned int a = 0; a < mScene->mNumMeshes;++a) - { - aiMesh* mesh = this->mScene->mMeshes[a]; - if(mesh->mMaterialIndex == (unsigned int)i) - { + for (unsigned int a = 0; a < mScene->mNumMeshes; ++a) { + aiMesh *mesh = this->mScene->mMeshes[a]; + if (mesh->mMaterialIndex == (unsigned int)i) { int iChannels = 0; - while (mesh->HasTextureCoords(iChannels))++iChannels; - if (iIndex >= iChannels) - { + while (mesh->HasTextureCoords(iChannels)) + ++iChannels; + if (iIndex >= iChannels) { ReportWarning("Invalid UV index: %i (key %s). Mesh %i has only %i UV channels", - iIndex,prop->mKey.data,a,iChannels); + iIndex, prop->mKey.data, a, iChannels); } } } } } - if (bNoSpecified) - { + if (bNoSpecified) { // Assume that all textures are using the first UV channel - for (unsigned int a = 0; a < mScene->mNumMeshes;++a) - { - aiMesh* mesh = mScene->mMeshes[a]; - if(mesh->mMaterialIndex == (unsigned int)iIndex && mappings[0] == aiTextureMapping_UV) - { - if (!mesh->mTextureCoords[0]) - { + for (unsigned int a = 0; a < mScene->mNumMeshes; ++a) { + aiMesh *mesh = mScene->mMeshes[a]; + if (mesh->mMaterialIndex == (unsigned int)iIndex && mappings[0] == aiTextureMapping_UV) { + if (!mesh->mTextureCoords[0]) { // This is a special case ... it could be that the // original mesh format intended the use of a special // mapping here. @@ -690,46 +622,43 @@ void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial, } } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiMaterial* pMaterial) -{ +void ValidateDSProcess::Validate(const aiMaterial *pMaterial) { // check whether there are material keys that are obviously not legal - for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) - { - const aiMaterialProperty* prop = pMaterial->mProperties[i]; - if (!prop) { - ReportError("aiMaterial::mProperties[%i] is NULL (aiMaterial::mNumProperties is %i)", - i,pMaterial->mNumProperties); + for (unsigned int i = 0; i < pMaterial->mNumProperties; ++i) { + const aiMaterialProperty *prop = pMaterial->mProperties[i]; + if (!prop) { + ReportError("aiMaterial::mProperties[%i] is nullptr (aiMaterial::mNumProperties is %i)", + i, pMaterial->mNumProperties); } if (!prop->mDataLength || !prop->mData) { ReportError("aiMaterial::mProperties[%i].mDataLength or " - "aiMaterial::mProperties[%i].mData is 0",i,i); + "aiMaterial::mProperties[%i].mData is 0", + i, i); } // check all predefined types - if (aiPTI_String == prop->mType) { + if (aiPTI_String == prop->mType) { // FIX: strings are now stored in a less expensive way, but we can't use the // validation routine for 'normal' aiStrings - if (prop->mDataLength < 5 || prop->mDataLength < 4 + (*reinterpret_cast(prop->mData)) + 1) { + if (prop->mDataLength < 5 || prop->mDataLength < 4 + (*reinterpret_cast(prop->mData)) + 1) { ReportError("aiMaterial::mProperties[%i].mDataLength is " - "too small to contain a string (%i, needed: %i)", - i,prop->mDataLength,static_cast(sizeof(aiString))); + "too small to contain a string (%i, needed: %i)", + i, prop->mDataLength, static_cast(sizeof(aiString))); } - if(prop->mData[prop->mDataLength-1]) { + if (prop->mData[prop->mDataLength - 1]) { ReportError("Missing null-terminator in string material property"); } - // Validate((const aiString*)prop->mData); - } - else if (aiPTI_Float == prop->mType) { - if (prop->mDataLength < sizeof(float)) { + // Validate((const aiString*)prop->mData); + } else if (aiPTI_Float == prop->mType) { + if (prop->mDataLength < sizeof(float)) { ReportError("aiMaterial::mProperties[%i].mDataLength is " - "too small to contain a float (%i, needed: %i)", - i,prop->mDataLength, static_cast(sizeof(float))); + "too small to contain a float (%i, needed: %i)", + i, prop->mDataLength, static_cast(sizeof(float))); } - } - else if (aiPTI_Integer == prop->mType) { - if (prop->mDataLength < sizeof(int)) { + } else if (aiPTI_Integer == prop->mType) { + if (prop->mDataLength < sizeof(int)) { ReportError("aiMaterial::mProperties[%i].mDataLength is " - "too small to contain an integer (%i, needed: %i)", - i,prop->mDataLength, static_cast(sizeof(int))); + "too small to contain an integer (%i, needed: %i)", + i, prop->mDataLength, static_cast(sizeof(int))); } } // TODO: check whether there is a key with an unknown name ... @@ -738,20 +667,19 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial) // make some more specific tests ai_real fTemp; int iShading; - if (AI_SUCCESS == aiGetMaterialInteger( pMaterial,AI_MATKEY_SHADING_MODEL,&iShading)) { - switch ((aiShadingMode)iShading) - { + if (AI_SUCCESS == aiGetMaterialInteger(pMaterial, AI_MATKEY_SHADING_MODEL, &iShading)) { + switch ((aiShadingMode)iShading) { case aiShadingMode_Blinn: case aiShadingMode_CookTorrance: case aiShadingMode_Phong: - if (AI_SUCCESS != aiGetMaterialFloat(pMaterial,AI_MATKEY_SHININESS,&fTemp)) { + if (AI_SUCCESS != aiGetMaterialFloat(pMaterial, AI_MATKEY_SHININESS, &fTemp)) { ReportWarning("A specular shading model is specified but there is no " - "AI_MATKEY_SHININESS key"); + "AI_MATKEY_SHININESS key"); } - if (AI_SUCCESS == aiGetMaterialFloat(pMaterial,AI_MATKEY_SHININESS_STRENGTH,&fTemp) && !fTemp) { + if (AI_SUCCESS == aiGetMaterialFloat(pMaterial, AI_MATKEY_SHININESS_STRENGTH, &fTemp) && !fTemp) { ReportWarning("A specular shading model is specified but the value of the " - "AI_MATKEY_SHININESS_STRENGTH key is 0.0"); + "AI_MATKEY_SHININESS_STRENGTH key is 0.0"); } break; default: @@ -759,175 +687,160 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial) } } - if (AI_SUCCESS == aiGetMaterialFloat( pMaterial,AI_MATKEY_OPACITY,&fTemp) && (!fTemp || fTemp > 1.01)) { + if (AI_SUCCESS == aiGetMaterialFloat(pMaterial, AI_MATKEY_OPACITY, &fTemp) && (!fTemp || fTemp > 1.01)) { ReportWarning("Invalid opacity value (must be 0 < opacity < 1.0)"); } // Check whether there are invalid texture keys // TODO: that's a relict of the past, where texture type and index were baked // into the material string ... we could do that in one single pass. - SearchForInvalidTextures(pMaterial,aiTextureType_DIFFUSE); - SearchForInvalidTextures(pMaterial,aiTextureType_SPECULAR); - SearchForInvalidTextures(pMaterial,aiTextureType_AMBIENT); - SearchForInvalidTextures(pMaterial,aiTextureType_EMISSIVE); - SearchForInvalidTextures(pMaterial,aiTextureType_OPACITY); - SearchForInvalidTextures(pMaterial,aiTextureType_SHININESS); - SearchForInvalidTextures(pMaterial,aiTextureType_HEIGHT); - SearchForInvalidTextures(pMaterial,aiTextureType_NORMALS); - SearchForInvalidTextures(pMaterial,aiTextureType_DISPLACEMENT); - SearchForInvalidTextures(pMaterial,aiTextureType_LIGHTMAP); - SearchForInvalidTextures(pMaterial,aiTextureType_REFLECTION); - SearchForInvalidTextures(pMaterial,aiTextureType_BASE_COLOR); - SearchForInvalidTextures(pMaterial,aiTextureType_NORMAL_CAMERA); - SearchForInvalidTextures(pMaterial,aiTextureType_EMISSION_COLOR); - SearchForInvalidTextures(pMaterial,aiTextureType_METALNESS); - SearchForInvalidTextures(pMaterial,aiTextureType_DIFFUSE_ROUGHNESS); - SearchForInvalidTextures(pMaterial,aiTextureType_AMBIENT_OCCLUSION); + SearchForInvalidTextures(pMaterial, aiTextureType_DIFFUSE); + SearchForInvalidTextures(pMaterial, aiTextureType_SPECULAR); + SearchForInvalidTextures(pMaterial, aiTextureType_AMBIENT); + SearchForInvalidTextures(pMaterial, aiTextureType_EMISSIVE); + SearchForInvalidTextures(pMaterial, aiTextureType_OPACITY); + SearchForInvalidTextures(pMaterial, aiTextureType_SHININESS); + SearchForInvalidTextures(pMaterial, aiTextureType_HEIGHT); + SearchForInvalidTextures(pMaterial, aiTextureType_NORMALS); + SearchForInvalidTextures(pMaterial, aiTextureType_DISPLACEMENT); + SearchForInvalidTextures(pMaterial, aiTextureType_LIGHTMAP); + SearchForInvalidTextures(pMaterial, aiTextureType_REFLECTION); + SearchForInvalidTextures(pMaterial, aiTextureType_BASE_COLOR); + SearchForInvalidTextures(pMaterial, aiTextureType_NORMAL_CAMERA); + SearchForInvalidTextures(pMaterial, aiTextureType_EMISSION_COLOR); + SearchForInvalidTextures(pMaterial, aiTextureType_METALNESS); + SearchForInvalidTextures(pMaterial, aiTextureType_DIFFUSE_ROUGHNESS); + SearchForInvalidTextures(pMaterial, aiTextureType_AMBIENT_OCCLUSION); } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiTexture* pTexture) -{ - // the data section may NEVER be NULL - if (!pTexture->pcData) { - ReportError("aiTexture::pcData is NULL"); +void ValidateDSProcess::Validate(const aiTexture *pTexture) { + // the data section may NEVER be nullptr + if (nullptr == pTexture->pcData) { + ReportError("aiTexture::pcData is nullptr"); } - if (pTexture->mHeight) - { - if (!pTexture->mWidth){ - ReportError("aiTexture::mWidth is zero (aiTexture::mHeight is %i, uncompressed texture)", - pTexture->mHeight); + if (pTexture->mHeight) { + if (!pTexture->mWidth) { + ReportError("aiTexture::mWidth is zero (aiTexture::mHeight is %i, uncompressed texture)", + pTexture->mHeight); } - } - else - { + } else { if (!pTexture->mWidth) { ReportError("aiTexture::mWidth is zero (compressed texture)"); } if ('\0' != pTexture->achFormatHint[HINTMAXTEXTURELEN - 1]) { ReportWarning("aiTexture::achFormatHint must be zero-terminated"); - } - else if ('.' == pTexture->achFormatHint[0]) { + } else if ('.' == pTexture->achFormatHint[0]) { ReportWarning("aiTexture::achFormatHint should contain a file extension " - "without a leading dot (format hint: %s).",pTexture->achFormatHint); + "without a leading dot (format hint: %s).", + pTexture->achFormatHint); } } - const char* sz = pTexture->achFormatHint; + const char *sz = pTexture->achFormatHint; if ((sz[0] >= 'A' && sz[0] <= 'Z') || - (sz[1] >= 'A' && sz[1] <= 'Z') || - (sz[2] >= 'A' && sz[2] <= 'Z') || - (sz[3] >= 'A' && sz[3] <= 'Z')) { + (sz[1] >= 'A' && sz[1] <= 'Z') || + (sz[2] >= 'A' && sz[2] <= 'Z') || + (sz[3] >= 'A' && sz[3] <= 'Z')) { ReportError("aiTexture::achFormatHint contains non-lowercase letters"); } } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiAnimation* pAnimation, - const aiNodeAnim* pNodeAnim) -{ +void ValidateDSProcess::Validate(const aiAnimation *pAnimation, + const aiNodeAnim *pNodeAnim) { Validate(&pNodeAnim->mNodeName); if (!pNodeAnim->mNumPositionKeys && !pNodeAnim->mScalingKeys && !pNodeAnim->mNumRotationKeys) { ReportError("Empty node animation channel"); } // otherwise check whether one of the keys exceeds the total duration of the animation - if (pNodeAnim->mNumPositionKeys) - { - if (!pNodeAnim->mPositionKeys) - { - ReportError("aiNodeAnim::mPositionKeys is NULL (aiNodeAnim::mNumPositionKeys is %i)", - pNodeAnim->mNumPositionKeys); + if (pNodeAnim->mNumPositionKeys) { + if (!pNodeAnim->mPositionKeys) { + ReportError("aiNodeAnim::mPositionKeys is nullptr (aiNodeAnim::mNumPositionKeys is %i)", + pNodeAnim->mNumPositionKeys); } double dLast = -10e10; - for (unsigned int i = 0; i < pNodeAnim->mNumPositionKeys;++i) - { + for (unsigned int i = 0; i < pNodeAnim->mNumPositionKeys; ++i) { // ScenePreprocessor will compute the duration if still the default value // (Aramis) Add small epsilon, comparison tended to fail if max_time == duration, // seems to be due the compilers register usage/width. - if (pAnimation->mDuration > 0. && pNodeAnim->mPositionKeys[i].mTime > pAnimation->mDuration+0.001) - { + if (pAnimation->mDuration > 0. && pNodeAnim->mPositionKeys[i].mTime > pAnimation->mDuration + 0.001) { ReportError("aiNodeAnim::mPositionKeys[%i].mTime (%.5f) is larger " - "than aiAnimation::mDuration (which is %.5f)",i, - (float)pNodeAnim->mPositionKeys[i].mTime, - (float)pAnimation->mDuration); + "than aiAnimation::mDuration (which is %.5f)", + i, + (float)pNodeAnim->mPositionKeys[i].mTime, + (float)pAnimation->mDuration); } - if (i && pNodeAnim->mPositionKeys[i].mTime <= dLast) - { + if (i && pNodeAnim->mPositionKeys[i].mTime <= dLast) { ReportWarning("aiNodeAnim::mPositionKeys[%i].mTime (%.5f) is smaller " - "than aiAnimation::mPositionKeys[%i] (which is %.5f)",i, - (float)pNodeAnim->mPositionKeys[i].mTime, - i-1, (float)dLast); + "than aiAnimation::mPositionKeys[%i] (which is %.5f)", + i, + (float)pNodeAnim->mPositionKeys[i].mTime, + i - 1, (float)dLast); } dLast = pNodeAnim->mPositionKeys[i].mTime; } } // rotation keys - if (pNodeAnim->mNumRotationKeys) - { - if (!pNodeAnim->mRotationKeys) - { - ReportError("aiNodeAnim::mRotationKeys is NULL (aiNodeAnim::mNumRotationKeys is %i)", - pNodeAnim->mNumRotationKeys); + if (pNodeAnim->mNumRotationKeys) { + if (!pNodeAnim->mRotationKeys) { + ReportError("aiNodeAnim::mRotationKeys is nullptr (aiNodeAnim::mNumRotationKeys is %i)", + pNodeAnim->mNumRotationKeys); } double dLast = -10e10; - for (unsigned int i = 0; i < pNodeAnim->mNumRotationKeys;++i) - { - if (pAnimation->mDuration > 0. && pNodeAnim->mRotationKeys[i].mTime > pAnimation->mDuration+0.001) - { + for (unsigned int i = 0; i < pNodeAnim->mNumRotationKeys; ++i) { + if (pAnimation->mDuration > 0. && pNodeAnim->mRotationKeys[i].mTime > pAnimation->mDuration + 0.001) { ReportError("aiNodeAnim::mRotationKeys[%i].mTime (%.5f) is larger " - "than aiAnimation::mDuration (which is %.5f)",i, - (float)pNodeAnim->mRotationKeys[i].mTime, - (float)pAnimation->mDuration); + "than aiAnimation::mDuration (which is %.5f)", + i, + (float)pNodeAnim->mRotationKeys[i].mTime, + (float)pAnimation->mDuration); } - if (i && pNodeAnim->mRotationKeys[i].mTime <= dLast) - { + if (i && pNodeAnim->mRotationKeys[i].mTime <= dLast) { ReportWarning("aiNodeAnim::mRotationKeys[%i].mTime (%.5f) is smaller " - "than aiAnimation::mRotationKeys[%i] (which is %.5f)",i, - (float)pNodeAnim->mRotationKeys[i].mTime, - i-1, (float)dLast); + "than aiAnimation::mRotationKeys[%i] (which is %.5f)", + i, + (float)pNodeAnim->mRotationKeys[i].mTime, + i - 1, (float)dLast); } dLast = pNodeAnim->mRotationKeys[i].mTime; } } // scaling keys - if (pNodeAnim->mNumScalingKeys) - { - if (!pNodeAnim->mScalingKeys) { - ReportError("aiNodeAnim::mScalingKeys is NULL (aiNodeAnim::mNumScalingKeys is %i)", - pNodeAnim->mNumScalingKeys); + if (pNodeAnim->mNumScalingKeys) { + if (!pNodeAnim->mScalingKeys) { + ReportError("aiNodeAnim::mScalingKeys is nullptr (aiNodeAnim::mNumScalingKeys is %i)", + pNodeAnim->mNumScalingKeys); } double dLast = -10e10; - for (unsigned int i = 0; i < pNodeAnim->mNumScalingKeys;++i) - { - if (pAnimation->mDuration > 0. && pNodeAnim->mScalingKeys[i].mTime > pAnimation->mDuration+0.001) - { + for (unsigned int i = 0; i < pNodeAnim->mNumScalingKeys; ++i) { + if (pAnimation->mDuration > 0. && pNodeAnim->mScalingKeys[i].mTime > pAnimation->mDuration + 0.001) { ReportError("aiNodeAnim::mScalingKeys[%i].mTime (%.5f) is larger " - "than aiAnimation::mDuration (which is %.5f)",i, - (float)pNodeAnim->mScalingKeys[i].mTime, - (float)pAnimation->mDuration); + "than aiAnimation::mDuration (which is %.5f)", + i, + (float)pNodeAnim->mScalingKeys[i].mTime, + (float)pAnimation->mDuration); } - if (i && pNodeAnim->mScalingKeys[i].mTime <= dLast) - { + if (i && pNodeAnim->mScalingKeys[i].mTime <= dLast) { ReportWarning("aiNodeAnim::mScalingKeys[%i].mTime (%.5f) is smaller " - "than aiAnimation::mScalingKeys[%i] (which is %.5f)",i, - (float)pNodeAnim->mScalingKeys[i].mTime, - i-1, (float)dLast); + "than aiAnimation::mScalingKeys[%i] (which is %.5f)", + i, + (float)pNodeAnim->mScalingKeys[i].mTime, + i - 1, (float)dLast); } dLast = pNodeAnim->mScalingKeys[i].mTime; } } if (!pNodeAnim->mNumScalingKeys && !pNodeAnim->mNumRotationKeys && - !pNodeAnim->mNumPositionKeys) - { + !pNodeAnim->mNumPositionKeys) { ReportError("A node animation channel must have at least one subtrack"); } } -void ValidateDSProcess::Validate( const aiAnimation* pAnimation, - const aiMeshMorphAnim* pMeshMorphAnim) -{ +void ValidateDSProcess::Validate(const aiAnimation *pAnimation, + const aiMeshMorphAnim *pMeshMorphAnim) { Validate(&pMeshMorphAnim->mName); if (!pMeshMorphAnim->mNumKeys) { @@ -935,32 +848,29 @@ void ValidateDSProcess::Validate( const aiAnimation* pAnimation, } // otherwise check whether one of the keys exceeds the total duration of the animation - if (pMeshMorphAnim->mNumKeys) - { - if (!pMeshMorphAnim->mKeys) - { - ReportError("aiMeshMorphAnim::mKeys is NULL (aiMeshMorphAnim::mNumKeys is %i)", - pMeshMorphAnim->mNumKeys); + if (pMeshMorphAnim->mNumKeys) { + if (!pMeshMorphAnim->mKeys) { + ReportError("aiMeshMorphAnim::mKeys is nullptr (aiMeshMorphAnim::mNumKeys is %i)", + pMeshMorphAnim->mNumKeys); } double dLast = -10e10; - for (unsigned int i = 0; i < pMeshMorphAnim->mNumKeys;++i) - { + for (unsigned int i = 0; i < pMeshMorphAnim->mNumKeys; ++i) { // ScenePreprocessor will compute the duration if still the default value // (Aramis) Add small epsilon, comparison tended to fail if max_time == duration, // seems to be due the compilers register usage/width. - if (pAnimation->mDuration > 0. && pMeshMorphAnim->mKeys[i].mTime > pAnimation->mDuration+0.001) - { + if (pAnimation->mDuration > 0. && pMeshMorphAnim->mKeys[i].mTime > pAnimation->mDuration + 0.001) { ReportError("aiMeshMorphAnim::mKeys[%i].mTime (%.5f) is larger " - "than aiAnimation::mDuration (which is %.5f)",i, - (float)pMeshMorphAnim->mKeys[i].mTime, - (float)pAnimation->mDuration); + "than aiAnimation::mDuration (which is %.5f)", + i, + (float)pMeshMorphAnim->mKeys[i].mTime, + (float)pAnimation->mDuration); } - if (i && pMeshMorphAnim->mKeys[i].mTime <= dLast) - { + if (i && pMeshMorphAnim->mKeys[i].mTime <= dLast) { ReportWarning("aiMeshMorphAnim::mKeys[%i].mTime (%.5f) is smaller " - "than aiMeshMorphAnim::mKeys[%i] (which is %.5f)",i, - (float)pMeshMorphAnim->mKeys[i].mTime, - i-1, (float)dLast); + "than aiMeshMorphAnim::mKeys[%i] (which is %.5f)", + i, + (float)pMeshMorphAnim->mKeys[i].mTime, + i - 1, (float)dLast); } dLast = pMeshMorphAnim->mKeys[i].mTime; } @@ -968,74 +878,62 @@ void ValidateDSProcess::Validate( const aiAnimation* pAnimation, } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiNode* pNode) -{ +void ValidateDSProcess::Validate(const aiNode *pNode) { if (!pNode) { - ReportError("A node of the scenegraph is NULL"); + ReportError("A node of the scene-graph is nullptr"); } // Validate node name string first so that it's safe to use in below expressions this->Validate(&pNode->mName); - const char* nodeName = (&pNode->mName)->C_Str(); - if (pNode != mScene->mRootNode && !pNode->mParent){ - ReportError("Non-root node %s lacks a valid parent (aiNode::mParent is NULL) ", nodeName); + const char *nodeName = (&pNode->mName)->C_Str(); + if (pNode != mScene->mRootNode && !pNode->mParent) { + ReportError("Non-root node %s lacks a valid parent (aiNode::mParent is nullptr) ", nodeName); } // validate all meshes - if (pNode->mNumMeshes) - { - if (!pNode->mMeshes) - { - ReportError("aiNode::mMeshes is NULL for node %s (aiNode::mNumMeshes is %i)", - nodeName, pNode->mNumMeshes); + if (pNode->mNumMeshes) { + if (!pNode->mMeshes) { + ReportError("aiNode::mMeshes is nullptr for node %s (aiNode::mNumMeshes is %i)", + nodeName, pNode->mNumMeshes); } std::vector abHadMesh; - abHadMesh.resize(mScene->mNumMeshes,false); - for (unsigned int i = 0; i < pNode->mNumMeshes;++i) - { - if (pNode->mMeshes[i] >= mScene->mNumMeshes) - { + abHadMesh.resize(mScene->mNumMeshes, false); + for (unsigned int i = 0; i < pNode->mNumMeshes; ++i) { + if (pNode->mMeshes[i] >= mScene->mNumMeshes) { ReportError("aiNode::mMeshes[%i] is out of range for node %s (maximum is %i)", - pNode->mMeshes[i], nodeName, mScene->mNumMeshes-1); + pNode->mMeshes[i], nodeName, mScene->mNumMeshes - 1); } - if (abHadMesh[pNode->mMeshes[i]]) - { + if (abHadMesh[pNode->mMeshes[i]]) { ReportError("aiNode::mMeshes[%i] is already referenced by this node %s (value: %i)", - i, nodeName, pNode->mMeshes[i]); + i, nodeName, pNode->mMeshes[i]); } abHadMesh[pNode->mMeshes[i]] = true; } } - if (pNode->mNumChildren) - { - if (!pNode->mChildren) { - ReportError("aiNode::mChildren is NULL for node %s (aiNode::mNumChildren is %i)", - nodeName, pNode->mNumChildren); + if (pNode->mNumChildren) { + if (!pNode->mChildren) { + ReportError("aiNode::mChildren is nullptr for node %s (aiNode::mNumChildren is %i)", + nodeName, pNode->mNumChildren); } - for (unsigned int i = 0; i < pNode->mNumChildren;++i) { + for (unsigned int i = 0; i < pNode->mNumChildren; ++i) { Validate(pNode->mChildren[i]); } } } // ------------------------------------------------------------------------------------------------ -void ValidateDSProcess::Validate( const aiString* pString) -{ - if (pString->length > MAXLEN) - { +void ValidateDSProcess::Validate(const aiString *pString) { + if (pString->length > MAXLEN) { ReportError("aiString::length is too large (%u, maximum is %lu)", - pString->length,MAXLEN); + pString->length, MAXLEN); } - const char* sz = pString->data; - while (true) - { - if ('\0' == *sz) - { - if (pString->length != (unsigned int)(sz-pString->data)) { + const char *sz = pString->data; + while (true) { + if ('\0' == *sz) { + if (pString->length != (unsigned int)(sz - pString->data)) { ReportError("aiString::data is invalid: the terminal zero is at a wrong offset"); } break; - } - else if (sz >= &pString->data[MAXLEN]) { + } else if (sz >= &pString->data[MAXLEN]) { ReportError("aiString::data is invalid. There is no terminal character"); } ++sz; diff --git a/contrib/Open3DGC/o3dgcSC3DMCDecoder.h b/contrib/Open3DGC/o3dgcSC3DMCDecoder.h index f3f1617c4..e6f803b94 100644 --- a/contrib/Open3DGC/o3dgcSC3DMCDecoder.h +++ b/contrib/Open3DGC/o3dgcSC3DMCDecoder.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013 Khaled Mammou - Advanced Micro Devices, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl b/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl index 326297426..c965fcd50 100644 --- a/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl +++ b/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl @@ -72,9 +72,12 @@ namespace o3dgc unsigned char mask = bstream.ReadUChar(m_iterator, m_streamType); ifs.SetCCW ((mask & 1) == 1); - ifs.SetSolid ((mask & 2) == 1); - ifs.SetConvex ((mask & 4) == 1); - ifs.SetIsTriangularMesh((mask & 8) == 1); + // (mask & 2) == 1 + ifs.SetSolid (false); + // (mask & 4) == 1 + ifs.SetConvex (false); + // (mask & 8) == 1 + ifs.SetIsTriangularMesh(false); //bool markerBit0 = (mask & 16 ) == 1; //bool markerBit1 = (mask & 32 ) == 1; //bool markerBit2 = (mask & 64 ) == 1; diff --git a/contrib/android-cmake/README.md b/contrib/android-cmake/README.md index ee6302128..395131daf 100644 --- a/contrib/android-cmake/README.md +++ b/contrib/android-cmake/README.md @@ -237,4 +237,4 @@ The _android-cmake_ should correctly handle projects with assembler sources (`*. ## Copying -_android-cmake_ is distributed under the terms of [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) \ No newline at end of file +_android-cmake_ is distributed under the terms of [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) diff --git a/contrib/gtest/docs/Documentation.md b/contrib/gtest/docs/Documentation.md index 8ca1aac75..e5d041f3a 100644 --- a/contrib/gtest/docs/Documentation.md +++ b/contrib/gtest/docs/Documentation.md @@ -11,4 +11,4 @@ documentation for that specific version instead.** To contribute code to Google Test, read: * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. - * [PumpManual](PumpManual.md) -- how we generate some of Google Test's source files. \ No newline at end of file + * [PumpManual](PumpManual.md) -- how we generate some of Google Test's source files. diff --git a/contrib/gtest/docs/V1_5_Documentation.md b/contrib/gtest/docs/V1_5_Documentation.md index 46bba2ec8..6febc65c9 100644 --- a/contrib/gtest/docs/V1_5_Documentation.md +++ b/contrib/gtest/docs/V1_5_Documentation.md @@ -9,4 +9,4 @@ This page lists all official documentation wiki pages for Google Test **1.5.0** To contribute code to Google Test, read: * DevGuide -- read this _before_ writing your first patch. - * [PumpManual](V1_5_PumpManual.md) -- how we generate some of Google Test's source files. \ No newline at end of file + * [PumpManual](V1_5_PumpManual.md) -- how we generate some of Google Test's source files. diff --git a/contrib/gtest/docs/V1_5_PumpManual.md b/contrib/gtest/docs/V1_5_PumpManual.md index 15710789d..e6485a01d 100644 --- a/contrib/gtest/docs/V1_5_PumpManual.md +++ b/contrib/gtest/docs/V1_5_PumpManual.md @@ -174,4 +174,4 @@ You can find real-world applications of Pump in [Google Test](http://www.google. ## Tips ## * If a meta variable is followed by a letter or digit, you can separate them using `[[]]`, which inserts an empty string. For example `Foo$j[[]]Helper` generate `Foo1Helper` when `j` is 1. - * To avoid extra-long Pump source lines, you can break a line anywhere you want by inserting `[[]]` followed by a new line. Since any new-line character next to `[[` or `]]` is ignored, the generated code won't contain this new line. \ No newline at end of file + * To avoid extra-long Pump source lines, you can break a line anywhere you want by inserting `[[]]` followed by a new line. Since any new-line character next to `[[` or `]]` is ignored, the generated code won't contain this new line. diff --git a/contrib/gtest/docs/V1_5_XcodeGuide.md b/contrib/gtest/docs/V1_5_XcodeGuide.md index bf24bf51b..21d7f5c05 100644 --- a/contrib/gtest/docs/V1_5_XcodeGuide.md +++ b/contrib/gtest/docs/V1_5_XcodeGuide.md @@ -90,4 +90,4 @@ The Debugger has exited with status 0. # Summary # -Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. \ No newline at end of file +Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. diff --git a/contrib/gtest/docs/V1_6_Documentation.md b/contrib/gtest/docs/V1_6_Documentation.md index ca924660a..1085673d1 100644 --- a/contrib/gtest/docs/V1_6_Documentation.md +++ b/contrib/gtest/docs/V1_6_Documentation.md @@ -11,4 +11,4 @@ documentation for that specific version instead.** To contribute code to Google Test, read: * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. - * [PumpManual](V1_6_PumpManual.md) -- how we generate some of Google Test's source files. \ No newline at end of file + * [PumpManual](V1_6_PumpManual.md) -- how we generate some of Google Test's source files. diff --git a/contrib/gtest/docs/V1_6_XcodeGuide.md b/contrib/gtest/docs/V1_6_XcodeGuide.md index bf24bf51b..21d7f5c05 100644 --- a/contrib/gtest/docs/V1_6_XcodeGuide.md +++ b/contrib/gtest/docs/V1_6_XcodeGuide.md @@ -90,4 +90,4 @@ The Debugger has exited with status 0. # Summary # -Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. \ No newline at end of file +Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. diff --git a/contrib/gtest/docs/V1_7_Documentation.md b/contrib/gtest/docs/V1_7_Documentation.md index 282697a50..6dc7d05b4 100644 --- a/contrib/gtest/docs/V1_7_Documentation.md +++ b/contrib/gtest/docs/V1_7_Documentation.md @@ -11,4 +11,4 @@ documentation for that specific version instead.** To contribute code to Google Test, read: * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. - * [PumpManual](V1_7_PumpManual.md) -- how we generate some of Google Test's source files. \ No newline at end of file + * [PumpManual](V1_7_PumpManual.md) -- how we generate some of Google Test's source files. diff --git a/contrib/gtest/docs/V1_7_XcodeGuide.md b/contrib/gtest/docs/V1_7_XcodeGuide.md index bf24bf51b..21d7f5c05 100644 --- a/contrib/gtest/docs/V1_7_XcodeGuide.md +++ b/contrib/gtest/docs/V1_7_XcodeGuide.md @@ -90,4 +90,4 @@ The Debugger has exited with status 0. # Summary # -Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. \ No newline at end of file +Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. diff --git a/contrib/gtest/docs/XcodeGuide.md b/contrib/gtest/docs/XcodeGuide.md index bf24bf51b..21d7f5c05 100644 --- a/contrib/gtest/docs/XcodeGuide.md +++ b/contrib/gtest/docs/XcodeGuide.md @@ -90,4 +90,4 @@ The Debugger has exited with status 0. # Summary # -Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. \ No newline at end of file +Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment. diff --git a/contrib/poly2tri/README b/contrib/poly2tri/README index 2857e2983..883e9a581 100644 --- a/contrib/poly2tri/README +++ b/contrib/poly2tri/README @@ -1,4 +1,4 @@ -================== +================== INSTALLATION GUIDE ================== @@ -48,4 +48,4 @@ Examples: ./p2t nazca_monkey.dat 0 0 9 ./p2t random 10 100 5.0 - ./p2t random 1000 20000 0.025 \ No newline at end of file + ./p2t random 1000 20000 0.025 diff --git a/contrib/poly2tri/poly2tri/common/shapes.cc b/contrib/poly2tri/poly2tri/common/shapes.cc index d0de13e64..c94e11c03 100644 --- a/contrib/poly2tri/poly2tri/common/shapes.cc +++ b/contrib/poly2tri/poly2tri/common/shapes.cc @@ -362,4 +362,4 @@ void Triangle::DebugPrint() cout << points_[2]->x << "," << points_[2]->y << endl; } -} \ No newline at end of file +} diff --git a/contrib/poly2tri/poly2tri/common/shapes.h b/contrib/poly2tri/poly2tri/common/shapes.h index ac7389a2d..d3660f716 100644 --- a/contrib/poly2tri/poly2tri/common/shapes.h +++ b/contrib/poly2tri/poly2tri/common/shapes.h @@ -324,4 +324,4 @@ inline void Triangle::IsInterior(bool b) } -#endif \ No newline at end of file +#endif diff --git a/contrib/poly2tri/poly2tri/poly2tri.h b/contrib/poly2tri/poly2tri/poly2tri.h index 29a08d052..ba5cc159e 100644 --- a/contrib/poly2tri/poly2tri/poly2tri.h +++ b/contrib/poly2tri/poly2tri/poly2tri.h @@ -35,4 +35,4 @@ #include "common/shapes.h" #include "sweep/cdt.h" -#endif \ No newline at end of file +#endif diff --git a/contrib/poly2tri/poly2tri/sweep/advancing_front.cc b/contrib/poly2tri/poly2tri/sweep/advancing_front.cc index 38723beef..9739babce 100644 --- a/contrib/poly2tri/poly2tri/sweep/advancing_front.cc +++ b/contrib/poly2tri/poly2tri/sweep/advancing_front.cc @@ -105,4 +105,4 @@ AdvancingFront::~AdvancingFront() { } -} \ No newline at end of file +} diff --git a/contrib/poly2tri/poly2tri/sweep/advancing_front.h b/contrib/poly2tri/poly2tri/sweep/advancing_front.h index 645dcec97..3bfec5368 100644 --- a/contrib/poly2tri/poly2tri/sweep/advancing_front.h +++ b/contrib/poly2tri/poly2tri/sweep/advancing_front.h @@ -115,4 +115,4 @@ inline void AdvancingFront::set_search(Node* node) } -#endif \ No newline at end of file +#endif diff --git a/contrib/poly2tri/poly2tri/sweep/cdt.cc b/contrib/poly2tri/poly2tri/sweep/cdt.cc index 09d088ae3..b79f5a8de 100644 --- a/contrib/poly2tri/poly2tri/sweep/cdt.cc +++ b/contrib/poly2tri/poly2tri/sweep/cdt.cc @@ -68,4 +68,4 @@ CDT::~CDT() delete sweep_; } -} \ No newline at end of file +} diff --git a/contrib/poly2tri/poly2tri/sweep/cdt.h b/contrib/poly2tri/poly2tri/sweep/cdt.h index ea3286d9a..4a9a292d3 100644 --- a/contrib/poly2tri/poly2tri/sweep/cdt.h +++ b/contrib/poly2tri/poly2tri/sweep/cdt.h @@ -102,4 +102,4 @@ public: } -#endif \ No newline at end of file +#endif diff --git a/contrib/poly2tri/poly2tri/sweep/sweep.h b/contrib/poly2tri/poly2tri/sweep/sweep.h index 33e34a714..ad429fd96 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep.h +++ b/contrib/poly2tri/poly2tri/sweep/sweep.h @@ -282,4 +282,4 @@ private: } -#endif \ No newline at end of file +#endif diff --git a/contrib/rapidjson/include/rapidjson/document.h b/contrib/rapidjson/include/rapidjson/document.h index 93b091f64..473d846e3 100644 --- a/contrib/rapidjson/include/rapidjson/document.h +++ b/contrib/rapidjson/include/rapidjson/document.h @@ -17,6 +17,11 @@ /*! \file document.h */ +#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + #include "reader.h" #include "internal/meta.h" #include "internal/strfunc.h" @@ -2610,4 +2615,8 @@ private: RAPIDJSON_NAMESPACE_END RAPIDJSON_DIAG_POP +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic pop +#endif + #endif // RAPIDJSON_DOCUMENT_H_ diff --git a/contrib/stb_image/stb_image.h b/contrib/stb_image/stb_image.h index 571b0dcea..d9c21bc81 100644 --- a/contrib/stb_image/stb_image.h +++ b/contrib/stb_image/stb_image.h @@ -7459,4 +7459,4 @@ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ -*/ \ No newline at end of file +*/ diff --git a/contrib/zip/.travis.sh b/contrib/zip/.travis.sh index 22974b1ff..9cb03ee87 100755 --- a/contrib/zip/.travis.sh +++ b/contrib/zip/.travis.sh @@ -15,4 +15,4 @@ else make -j 8 make install ASAN_OPTIONS=detect_leaks=0 LSAN_OPTIONS=verbosity=1:log_threads=1 ctest -V -fi \ No newline at end of file +fi diff --git a/contrib/zip/.travis.yml b/contrib/zip/.travis.yml index 86bac1cca..42f84dd25 100644 --- a/contrib/zip/.travis.yml +++ b/contrib/zip/.travis.yml @@ -19,4 +19,4 @@ after_success: - make - make test # Uploading report to CodeCov - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) diff --git a/contrib/zlib/CMakeLists.txt b/contrib/zlib/CMakeLists.txt index c90996c0b..664c83a71 100644 --- a/contrib/zlib/CMakeLists.txt +++ b/contrib/zlib/CMakeLists.txt @@ -196,10 +196,7 @@ if(MINGW) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) endif(MINGW) -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) -set_target_properties(zlib PROPERTIES SOVERSION 1) INSTALL( TARGETS zlibstatic LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} diff --git a/contrib/zlib/contrib/blast/test.txt b/contrib/zlib/contrib/blast/test.txt index bfdf1c5dc..159002de5 100644 --- a/contrib/zlib/contrib/blast/test.txt +++ b/contrib/zlib/contrib/blast/test.txt @@ -1 +1 @@ -AIAIAIAIAIAIA \ No newline at end of file +AIAIAIAIAIAIA diff --git a/contrib/zlib/contrib/dotzlib/LICENSE_1_0.txt b/contrib/zlib/contrib/dotzlib/LICENSE_1_0.txt index 127a5bc39..36b7cd93c 100644 --- a/contrib/zlib/contrib/dotzlib/LICENSE_1_0.txt +++ b/contrib/zlib/contrib/dotzlib/LICENSE_1_0.txt @@ -20,4 +20,4 @@ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. \ No newline at end of file +DEALINGS IN THE SOFTWARE. diff --git a/contrib/zlib/contrib/testzlib/testzlib.txt b/contrib/zlib/contrib/testzlib/testzlib.txt index e508bb22f..ba1bb3db6 100644 --- a/contrib/zlib/contrib/testzlib/testzlib.txt +++ b/contrib/zlib/contrib/testzlib/testzlib.txt @@ -7,4 +7,4 @@ copy to a directory file from : - contrib/masmx64 - contrib/vstudio/vc7 -and open testzlib8.sln \ No newline at end of file +and open testzlib8.sln diff --git a/contrib/zlib_note.txt b/contrib/zlib_note.txt index cc274f0bf..a7ca98634 100644 --- a/contrib/zlib_note.txt +++ b/contrib/zlib_note.txt @@ -8,4 +8,4 @@ This is a heavily modified and shrinked version of zlib 1.2.3 Assimp itself does not use the compression part yet, so it needn't be compiled (trees.c, deflate.c, compress.c). -Currently these units are just used by assimp_cmd. \ No newline at end of file +Currently these units are just used by assimp_cmd. diff --git a/doc/Fileformats.md b/doc/Fileformats.md new file mode 100644 index 000000000..c9116e2e7 --- /dev/null +++ b/doc/Fileformats.md @@ -0,0 +1,87 @@ +#### Supported file formats #### + +__Importers__: + +- 3D +- [3DS](https://en.wikipedia.org/wiki/.3ds) +- [3MF](https://en.wikipedia.org/wiki/3D_Manufacturing_Format) +- AC +- [AC3D](https://en.wikipedia.org/wiki/AC3D) +- ACC +- AMJ +- ASE +- ASK +- B3D +- [BLEND](https://en.wikipedia.org/wiki/.blend_(file_format)) +- [BVH](https://en.wikipedia.org/wiki/Biovision_Hierarchy) +- CMS +- COB +- [DAE/Collada](https://en.wikipedia.org/wiki/COLLADA) +- [DXF](https://en.wikipedia.org/wiki/AutoCAD_DXF) +- ENFF +- [FBX](https://en.wikipedia.org/wiki/FBX) +- [glTF 1.0](https://en.wikipedia.org/wiki/GlTF#glTF_1.0) + GLB +- [glTF 2.0](https://en.wikipedia.org/wiki/GlTF#glTF_2.0): + At the moment for glTF2.0 the following extensions are supported: + + KHR_lights_punctual ( 5.0 ) + + KHR_materials_pbrSpecularGlossiness ( 5.0 ) + + KHR_materials_unlit ( 5.0 ) + + KHR_texture_transform ( 5.1 under test ) +- HMB +- IFC-STEP +- IRR / IRRMESH +- [LWO](https://en.wikipedia.org/wiki/LightWave_3D) +- LWS +- LXO +- [M3D](https://bztsrc.gitlab.io/model3d) +- MD2 +- MD3 +- MD5 +- MDC +- MDL +- MESH / MESH.XML +- MOT +- MS3D +- NDO +- NFF +- [OBJ](https://en.wikipedia.org/wiki/Wavefront_.obj_file) +- [OFF](https://en.wikipedia.org/wiki/OFF_(file_format)) +- [OGEX](https://en.wikipedia.org/wiki/Open_Game_Engine_Exchange) +- [PLY](https://en.wikipedia.org/wiki/PLY_(file_format)) +- PMX +- PRJ +- Q3O +- Q3S +- RAW +- SCN +- SIB +- SMD +- [STP](https://en.wikipedia.org/wiki/ISO_10303-21) +- [STL](https://en.wikipedia.org/wiki/STL_(file_format)) +- TER +- UC +- VTA +- X +- [X3D](https://en.wikipedia.org/wiki/X3D) +- XGL +- ZGL + +Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default): + +- [C4D](https://en.wikipedia.org/wiki/Cinema_4D) (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange) IMporting geometry + node hierarchy are currently supported + +__Exporters__: + +- DAE (Collada) +- STL +- OBJ +- PLY +- X +- 3DS +- JSON (for WebGl, via https://github.com/acgessler/assimp2json) +- ASSBIN +- STEP +- glTF 1.0 (partial) +- glTF 2.0 (partial) +- 3MF ( experimental ) +- FBX ( experimental ) diff --git a/doc/architecture/Assimp_Arch_Import.class.violet.html b/doc/architecture/Assimp_Arch_Import.class.violet.html index 264468f98..b4e3a9a6e 100644 --- a/doc/architecture/Assimp_Arch_Import.class.violet.html +++ b/doc/architecture/Assimp_Arch_Import.class.violet.html @@ -351,4 +351,4 @@ BI8AxOURXedNEuG6jMiRPHKQsuuS4BGAuDzS0NCQlZV18JFlRI7qkRRdlwSPAHzCIynKaa5LgkcA ETwCgEfwCAAewSMAeASP4BEAPIJHAPAIHgFItrEBsYNHAD7BK4gZPAKAR/AIAB7BIwCQBvwfU/j0 jy2hMWgAAAAASUVORK5C" /> - \ No newline at end of file + diff --git a/doc/architecture/Assimp_Arch_export.class.violet.html b/doc/architecture/Assimp_Arch_export.class.violet.html index 85f68d68d..ee567caaa 100644 --- a/doc/architecture/Assimp_Arch_export.class.violet.html +++ b/doc/architecture/Assimp_Arch_export.class.violet.html @@ -645,4 +645,4 @@ tQ2gtkFtg9oGQG2jtkFtA6C2UduA2gZQ26C2QW0DoLZR26C2AVDbqG1AbQMoKg8CahvUNgBqG7UN ahsAtY3aBtQ2AGobtQ1qGwC1jdoGtQ2A2kZtA2obALWN2ga1DUA1igr2o7ZBbQPw0/wD+/DsALUN gNpGbYPaBkBto7ZBbQMAAD/R/wDNluGGIxSgmAAAAABJRU5ErkJg" /> - \ No newline at end of file + diff --git a/doc/architecture/assimp.object.violet.html b/doc/architecture/assimp.object.violet.html index 1d82fa05f..dee9d2208 100644 --- a/doc/architecture/assimp.object.violet.html +++ b/doc/architecture/assimp.object.violet.html @@ -104,4 +104,4 @@ tfMWuhaZfgHUw0Q32sDAwIcPH4I/C1fbaJVKRX0GBwft4RA5hXdkNepJqndpKD2R7TlrjeqmxkKh oLOf5O8VrfC7XlrtOvYCO77PYocddthhhx122GGHHXbYYYcddthhhx122GGHHXbYYYdd29q1c83s I9m5B21Yuxg77FJtRzQV/wEjVLA5JUDyfgAAAABJRU5ErkJg" /> - \ No newline at end of file + diff --git a/doc/architecture/assimp_usecase.ucase.violet.html b/doc/architecture/assimp_usecase.ucase.violet.html index 3045add42..c4df02533 100644 --- a/doc/architecture/assimp_usecase.ucase.violet.html +++ b/doc/architecture/assimp_usecase.ucase.violet.html @@ -872,4 +872,4 @@ DYMQQgghNAxCCCGEEBoGIYQQQmgYhBBCCKFhEEIIIYTQMAghhBBCwyCEEEIIDYMQQgghNAxCCCGE EBoGIYQQQmgYhBBCCKFhEEIIIYTQMAghhBBCwyCEEEJI/PP/A0zci3P89Qf2AAAAAElFTkSuQmCC " /> - \ No newline at end of file + diff --git a/doc/architecture/process.class.violet.html b/doc/architecture/process.class.violet.html index d4f77d909..662daf4a8 100644 --- a/doc/architecture/process.class.violet.html +++ b/doc/architecture/process.class.violet.html @@ -334,4 +334,4 @@ CQCsyZpgTQCsyZpgTQCsyZpgTQCsyZpgTQCsCdZkTQBgTdZkTQBgTdZkTQBgTdYEawJgTdYEawJg TdYEawJgTbAmawIAa7ImawIAa7ImawIAa7ImWBMAa7ImWBMAa7ImWBPAvDIByoc1WRMA/uU3lI1q YU0ArAnWZE0AYE3WZE0AABY4/wVVY1WTrOVxIAAAAABJRU5ErkJg" /> - \ No newline at end of file + diff --git a/code/AssetLib/StepFile/StepFileImporter.h b/fuzz/assimp_fuzzer.cc similarity index 75% rename from code/AssetLib/StepFile/StepFileImporter.h rename to fuzz/assimp_fuzzer.cc index c6ac08bb6..86ffe18ed 100644 --- a/code/AssetLib/StepFile/StepFileImporter.h +++ b/fuzz/assimp_fuzzer.cc @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -40,30 +38,19 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------- */ +#include +#include +#include -#pragma once +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) { + aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL); + aiAttachLogStream(&stream); -#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER + Importer importer; + const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, + aiProcessPreset_TargetRealtime_Quality, nullptr ); -#include - -namespace Assimp { -namespace StepFile { - -class StepFileImporter : public BaseImporter { -public: - StepFileImporter(); - ~StepFileImporter(); - bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override; - const aiImporterDesc* GetInfo() const override; - -protected: - void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler ) override; - -private: -}; - -} // Namespace StepFile -} // Namespace Assimp - -#endif // ASSIMP_BUILD_NO_STEP_IMPORTER + aiDetachLogStream(&stream); + + return 0; +} diff --git a/include/assimp/BaseImporter.h b/include/assimp/BaseImporter.h index 7cf835174..ed146168d 100644 --- a/include/assimp/BaseImporter.h +++ b/include/assimp/BaseImporter.h @@ -46,22 +46,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_BASEIMPORTER_H #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #include "Exceptional.h" -#include -#include -#include +#include #include #include -#include +#include +#include +#include struct aiScene; struct aiImporterDesc; -namespace Assimp { +namespace Assimp { class Importer; class IOSystem; @@ -71,8 +71,7 @@ class IOStream; // utility to do char4 to uint32 in a portable manner #define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \ - (string[1] << 16) + (string[2] << 8) + string[3])) - + (string[1] << 16) + (string[2] << 8) + string[3])) // --------------------------------------------------------------------------- /** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface @@ -89,10 +88,9 @@ class ASSIMP_API BaseImporter { private: /* Pushes state into importer for the importer scale */ - virtual void UpdateImporterScale( Importer* pImp ); + virtual void UpdateImporterScale(Importer *pImp); public: - /** Constructor to be privately used by #Importer */ BaseImporter() AI_NO_EXCEPT; @@ -118,22 +116,21 @@ public: * @return true if the class can read this file, false if not. */ virtual bool CanRead( - const std::string& pFile, - IOSystem* pIOHandler, - bool checkSig - ) const = 0; + const std::string &pFile, + IOSystem *pIOHandler, + bool checkSig) const = 0; // ------------------------------------------------------------------- /** Imports the given file and returns the imported data. * If the import succeeds, ownership of the data is transferred to - * the caller. If the import fails, NULL is returned. The function + * the caller. If the import fails, nullptr is returned. The function * takes care that any partially constructed data is destroyed * beforehand. * * @param pImp #Importer object hosting this loader. * @param pFile Path of the file to be imported. * @param pIOHandler IO-Handler used to open this and possible other files. - * @return The imported data or NULL if failed. If it failed a + * @return The imported data or nullptr if failed. If it failed a * human-readable error description can be retrieved by calling * GetErrorText() * @@ -142,18 +139,17 @@ public: * in InternReadFile(), this function will catch it and transform it into * a suitable response to the caller. */ - aiScene* ReadFile( - Importer* pImp, - const std::string& pFile, - IOSystem* pIOHandler - ); + aiScene *ReadFile( + Importer *pImp, + const std::string &pFile, + IOSystem *pIOHandler); // ------------------------------------------------------------------- /** Returns the error description of the last error that occurred. * @return A description of the last error that occurred. An empty * string if there was no error. */ - const std::string& GetErrorText() const { + const std::string &GetErrorText() const { return m_ErrorText; } @@ -164,24 +160,21 @@ public: * @param pImp Importer instance */ virtual void SetupProperties( - const Importer* pImp - ); + const Importer *pImp); // ------------------------------------------------------------------- /** Called by #Importer::GetImporterInfo to get a description of * some loader features. Importers must provide this information. */ - virtual const aiImporterDesc* GetInfo() const = 0; + virtual const aiImporterDesc *GetInfo() const = 0; /** * Will be called only by scale process when scaling is requested. */ - virtual void SetFileScale(double scale) - { + virtual void SetFileScale(double scale) { fileScale = scale; } - virtual double GetFileScale() const - { + virtual double GetFileScale() const { return fileScale; } @@ -204,14 +197,12 @@ public: * */ std::map importerUnits; - virtual void SetApplicationUnits( const ImporterUnits& unit ) - { + virtual void SetApplicationUnits(const ImporterUnits &unit) { importerScale = importerUnits[unit]; applicationUnits = unit; } - virtual const ImporterUnits& GetApplicationUnits() - { + virtual const ImporterUnits &GetApplicationUnits() { return applicationUnits; } @@ -220,15 +211,13 @@ public: * Take the extension list contained in the structure returned by * #GetInfo and insert all file extensions into the given set. * @param extension set to collect file extensions in*/ - void GetExtensionList(std::set& extensions); - -protected: + void GetExtensionList(std::set &extensions); + +protected: ImporterUnits applicationUnits = ImporterUnits::M; double importerScale = 1.0; double fileScale = 1.0; - - // ------------------------------------------------------------------- /** Imports the given file into the given scene structure. The * function is expected to throw an ImportErrorException if there is @@ -249,7 +238,7 @@ protected: *

  • aiAnimation::mDuration may be -1. Assimp determines the length * of the animation automatically in this case as the length of * the longest animation channel.
  • - *
  • aiMesh::mBitangents may be NULL if tangents and normals are + *
  • aiMesh::mBitangents may be nullptr if tangents and normals are * given. In this case bitangents are computed as the cross product * between normal and tangent.
  • *
  • There needn't be a material. If none is there a default material @@ -270,17 +259,15 @@ protected: * * @param pFile Path of the file to be imported. * @param pScene The scene object to hold the imported data. - * NULL is not a valid parameter. + * nullptr is not a valid parameter. * @param pIOHandler The IO handler to use for any file access. - * NULL is not a valid parameter. */ + * nullptr is not a valid parameter. */ virtual void InternReadFile( - const std::string& pFile, - aiScene* pScene, - IOSystem* pIOHandler - ) = 0; + const std::string &pFile, + aiScene *pScene, + IOSystem *pIOHandler) = 0; public: // static utilities - // ------------------------------------------------------------------- /** A utility for CanRead(). * @@ -296,13 +283,13 @@ public: // static utilities * @param searchBytes Number of bytes to be searched for the tokens. */ static bool SearchFileHeaderForToken( - IOSystem* pIOSystem, - const std::string& file, - const char** tokens, - unsigned int numTokens, - unsigned int searchBytes = 200, - bool tokensSol = false, - bool noAlphaBeforeTokens = false); + IOSystem *pIOSystem, + const std::string &file, + const char **tokens, + unsigned int numTokens, + unsigned int searchBytes = 200, + bool tokensSol = false, + bool noAlphaBeforeTokens = false); // ------------------------------------------------------------------- /** @brief Check whether a file has a specific file extension @@ -312,19 +299,19 @@ public: // static utilities * @param ext2 Optional third extension * @note Case-insensitive */ - static bool SimpleExtensionCheck ( - const std::string& pFile, - const char* ext0, - const char* ext1 = NULL, - const char* ext2 = NULL); + static bool SimpleExtensionCheck( + const std::string &pFile, + const char *ext0, + const char *ext1 = nullptr, + const char *ext2 = nullptr); // ------------------------------------------------------------------- /** @brief Extract file extension from a string * @param pFile Input file * @return Extension without trailing dot, all lowercase */ - static std::string GetExtension ( - const std::string& pFile); + static std::string GetExtension( + const std::string &pFile); // ------------------------------------------------------------------- /** @brief Check whether a file starts with one or more magic tokens @@ -341,12 +328,12 @@ public: // static utilities * tokens of size 2,4. */ static bool CheckMagicToken( - IOSystem* pIOHandler, - const std::string& pFile, - const void* magic, - unsigned int num, - unsigned int offset = 0, - unsigned int size = 4); + IOSystem *pIOHandler, + const std::string &pFile, + const void *magic, + unsigned int num, + unsigned int offset = 0, + unsigned int size = 4); // ------------------------------------------------------------------- /** An utility for all text file loaders. It converts a file to our @@ -355,7 +342,7 @@ public: // static utilities * @param data File buffer to be converted to UTF8 data. The buffer * is resized as appropriate. */ static void ConvertToUTF8( - std::vector& data); + std::vector &data); // ------------------------------------------------------------------- /** An utility for all text file loaders. It converts a file from our @@ -364,13 +351,13 @@ public: // static utilities * @param data File buffer to be converted from UTF8 to ISO-8859-1. The buffer * is resized as appropriate. */ static void ConvertUTF8toISO8859_1( - std::string& data); + std::string &data); // ------------------------------------------------------------------- /// @brief Enum to define, if empty files are ok or not. - enum TextFileMode { + enum TextFileMode { ALLOW_EMPTY, - FORBID_EMPTY + FORBID_EMPTY }; // ------------------------------------------------------------------- @@ -383,22 +370,20 @@ public: // static utilities * a binary 0. * @param mode Whether it is OK to load empty text files. */ static void TextFileToBuffer( - IOStream* stream, - std::vector& data, - TextFileMode mode = FORBID_EMPTY); + IOStream *stream, + std::vector &data, + TextFileMode mode = FORBID_EMPTY); // ------------------------------------------------------------------- /** Utility function to move a std::vector into a aiScene array * @param vec The vector to be moved * @param out The output pointer to the allocated array. * @param numOut The output count of elements copied. */ - template - AI_FORCE_INLINE - static void CopyVector( - std::vector& vec, - T*& out, - unsigned int& outLength) - { + template + AI_FORCE_INLINE static void CopyVector( + std::vector &vec, + T *&out, + unsigned int &outLength) { outLength = unsigned(vec.size()); if (outLength) { out = new T[outLength]; @@ -410,11 +395,9 @@ protected: /// Error description in case there was one. std::string m_ErrorText; /// Currently set progress handler. - ProgressHandler* m_progress; + ProgressHandler *m_progress; }; - - } // end of namespace Assimp #endif // AI_BASEIMPORTER_H_INC diff --git a/include/assimp/BlobIOSystem.h b/include/assimp/BlobIOSystem.h index 30d9b1ac3..2bcc2074b 100644 --- a/include/assimp/BlobIOSystem.h +++ b/include/assimp/BlobIOSystem.h @@ -47,87 +47,74 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_BLOBIOSYSTEM_H_INCLUDED #define AI_BLOBIOSYSTEM_H_INCLUDED -#include #include -#include -#include #include +#include +#include +#include #include #include -namespace Assimp { - class BlobIOSystem; +namespace Assimp { +class BlobIOSystem; // -------------------------------------------------------------------------------------------- /** Redirect IOStream to a blob */ // -------------------------------------------------------------------------------------------- -class BlobIOStream : public IOStream -{ +class BlobIOStream : public IOStream { public: - - BlobIOStream(BlobIOSystem* creator, const std::string& file, size_t initial = 4096) - : buffer() - , cur_size() - , file_size() - , cursor() - , initial(initial) - , file(file) - , creator(creator) - { + BlobIOStream(BlobIOSystem *creator, const std::string &file, size_t initial = 4096) : + buffer(), + cur_size(), + file_size(), + cursor(), + initial(initial), + file(file), + creator(creator) { + // empty } - virtual ~BlobIOStream(); public: - // ------------------------------------------------------------------- - aiExportDataBlob* GetBlob() - { - aiExportDataBlob* blob = new aiExportDataBlob(); + aiExportDataBlob *GetBlob() { + aiExportDataBlob *blob = new aiExportDataBlob(); blob->size = file_size; blob->data = buffer; - buffer = NULL; + buffer = nullptr; return blob; } - -public: - - // ------------------------------------------------------------------- - virtual size_t Read( void *, - size_t, - size_t ) - { + virtual size_t Read(void *, + size_t, + size_t) { return 0; } // ------------------------------------------------------------------- - virtual size_t Write(const void* pvBuffer, - size_t pSize, - size_t pCount) - { + virtual size_t Write(const void *pvBuffer, + size_t pSize, + size_t pCount) { pSize *= pCount; if (cursor + pSize > cur_size) { Grow(cursor + pSize); } - memcpy(buffer+cursor, pvBuffer, pSize); + memcpy(buffer + cursor, pvBuffer, pSize); cursor += pSize; - file_size = std::max(file_size,cursor); + file_size = std::max(file_size, cursor); return pCount; } // ------------------------------------------------------------------- virtual aiReturn Seek(size_t pOffset, - aiOrigin pOrigin) - { - switch(pOrigin) - { + aiOrigin pOrigin) { + switch (pOrigin) { case aiOrigin_CUR: cursor += pOffset; break; @@ -148,48 +135,41 @@ public: Grow(cursor); } - file_size = std::max(cursor,file_size); + file_size = std::max(cursor, file_size); return AI_SUCCESS; } // ------------------------------------------------------------------- - virtual size_t Tell() const - { + virtual size_t Tell() const { return cursor; } // ------------------------------------------------------------------- - virtual size_t FileSize() const - { + virtual size_t FileSize() const { return file_size; } // ------------------------------------------------------------------- - virtual void Flush() - { + virtual void Flush() { // ignore } - - private: - // ------------------------------------------------------------------- - void Grow(size_t need = 0) - { + void Grow(size_t need = 0) { // 1.5 and phi are very heap-friendly growth factors (the first // allows for frequent re-use of heap blocks, the second // forms a fibonacci sequence with similar characteristics - // since this heavily depends on the heap implementation // and other factors as well, i'll just go with 1.5 since // it is quicker to compute). - size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) )); + size_t new_size = std::max(initial, std::max(need, cur_size + (cur_size >> 1))); - const uint8_t* const old = buffer; + const uint8_t *const old = buffer; buffer = new uint8_t[new_size]; if (old) { - memcpy(buffer,old,cur_size); + memcpy(buffer, old, cur_size); delete[] old; } @@ -197,54 +177,44 @@ private: } private: - - uint8_t* buffer; - size_t cur_size,file_size, cursor, initial; + uint8_t *buffer; + size_t cur_size, file_size, cursor, initial; const std::string file; - BlobIOSystem* const creator; + BlobIOSystem *const creator; }; - #define AI_BLOBIO_MAGIC "$blobfile" // -------------------------------------------------------------------------------------------- /** Redirect IOSystem to a blob */ // -------------------------------------------------------------------------------------------- -class BlobIOSystem : public IOSystem -{ +class BlobIOSystem : public IOSystem { friend class BlobIOStream; - typedef std::pair BlobEntry; + typedef std::pair BlobEntry; public: - - BlobIOSystem() - { + BlobIOSystem() { } - virtual ~BlobIOSystem() - { - for(BlobEntry& blobby : blobs) { + virtual ~BlobIOSystem() { + for (BlobEntry &blobby : blobs) { delete blobby.second; } } public: - // ------------------------------------------------------------------- - const char* GetMagicFileName() const - { + const char *GetMagicFileName() const { return AI_BLOBIO_MAGIC; } - // ------------------------------------------------------------------- - aiExportDataBlob* GetBlobChain() - { + aiExportDataBlob *GetBlobChain() { // one must be the master - aiExportDataBlob* master = NULL, *cur; - for(const BlobEntry& blobby : blobs) { + aiExportDataBlob *master = nullptr, *cur; + for (const BlobEntry &blobby : blobs) { if (blobby.first == AI_BLOBIO_MAGIC) { master = blobby.second; break; @@ -252,13 +222,13 @@ public: } if (!master) { ASSIMP_LOG_ERROR("BlobIOSystem: no data written or master file was not closed properly."); - return NULL; + return nullptr; } master->name.Set(""); cur = master; - for(const BlobEntry& blobby : blobs) { + for (const BlobEntry &blobby : blobs) { if (blobby.second == master) { continue; } @@ -268,7 +238,7 @@ public: // extract the file extension from the file written const std::string::size_type s = blobby.first.find_first_of('.'); - cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s+1)); + cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s + 1)); } // give up blob ownership @@ -277,62 +247,52 @@ public: } public: - // ------------------------------------------------------------------- - virtual bool Exists( const char* pFile) const { + virtual bool Exists(const char *pFile) const { return created.find(std::string(pFile)) != created.end(); } - // ------------------------------------------------------------------- virtual char getOsSeparator() const { return '/'; } - // ------------------------------------------------------------------- - virtual IOStream* Open(const char* pFile, - const char* pMode) - { + virtual IOStream *Open(const char *pFile, + const char *pMode) { if (pMode[0] != 'w') { - return NULL; + return nullptr; } created.insert(std::string(pFile)); - return new BlobIOStream(this,std::string(pFile)); + return new BlobIOStream(this, std::string(pFile)); } // ------------------------------------------------------------------- - virtual void Close( IOStream* pFile) - { + virtual void Close(IOStream *pFile) { delete pFile; } private: - // ------------------------------------------------------------------- - void OnDestruct(const std::string& filename, BlobIOStream* child) - { + void OnDestruct(const std::string &filename, BlobIOStream *child) { // we don't know in which the files are closed, so we // can't reliably say that the first must be the master // file ... - blobs.push_back( BlobEntry(filename,child->GetBlob()) ); + blobs.push_back(BlobEntry(filename, child->GetBlob())); } private: std::set created; - std::vector< BlobEntry > blobs; + std::vector blobs; }; - // -------------------------------------------------------------------------------------------- -BlobIOStream :: ~BlobIOStream() -{ - creator->OnDestruct(file,this); +BlobIOStream ::~BlobIOStream() { + creator->OnDestruct(file, this); delete[] buffer; } - -} // end Assimp +} // namespace Assimp #endif diff --git a/include/assimp/ColladaMetaData.h b/include/assimp/ColladaMetaData.h new file mode 100644 index 000000000..82aee78d0 --- /dev/null +++ b/include/assimp/ColladaMetaData.h @@ -0,0 +1,53 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +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 +OWNER 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. + +---------------------------------------------------------------------- +*/ + +/** @file ColladaMetaData.h + * Declares common metadata constants used by Collada files + */ +#pragma once +#ifndef AI_COLLADAMETADATA_H_INC +#define AI_COLLADAMETADATA_H_INC + +#define AI_METADATA_COLLADA_ID "Collada_id" +#define AI_METADATA_COLLADA_SID "Collada_sid" + +#endif diff --git a/include/assimp/DefaultLogger.hpp b/include/assimp/DefaultLogger.hpp index 789072a7c..fac40c7bf 100644 --- a/include/assimp/DefaultLogger.hpp +++ b/include/assimp/DefaultLogger.hpp @@ -45,12 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDED_AI_DEFAULTLOGGER #define INCLUDED_AI_DEFAULTLOGGER -#include "Logger.hpp" #include "LogStream.hpp" +#include "Logger.hpp" #include "NullLogger.hpp" #include -namespace Assimp { +namespace Assimp { // ------------------------------------------------------------------------------------ class IOStream; struct LogStreamInfo; @@ -71,27 +71,25 @@ struct LogStreamInfo; * If you wish to customize the logging at an even deeper level supply your own * implementation of #Logger to #set(). * @note The whole logging stuff causes a small extra overhead for all imports. */ -class ASSIMP_API DefaultLogger : - public Logger { +class ASSIMP_API DefaultLogger : public Logger { public: - // ---------------------------------------------------------------------- /** @brief Creates a logging instance. * @param name Name for log file. Only valid in combination * with the aiDefaultLogStream_FILE flag. - * @param severity Log severity, VERBOSE turns on debug messages + * @param severity Log severity, DEBUG turns on debug messages and VERBOSE turns on all messages. * @param defStreams Default log streams to be attached. Any bitwise * combination of the aiDefaultLogStream enumerated values. * If #aiDefaultLogStream_FILE is specified but an empty string is * passed for 'name', no log file is created at all. * @param io IOSystem to be used to open external files (such as the - * log file). Pass NULL to rely on the default implementation. + * log file). Pass nullptr to rely on the default implementation. * This replaces the default #NullLogger with a #DefaultLogger instance. */ - static Logger *create(const char* name = ASSIMP_DEFAULT_LOG_NAME, - LogSeverity severity = NORMAL, - unsigned int defStreams = aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE, - IOSystem* io = NULL); + static Logger *create(const char *name = ASSIMP_DEFAULT_LOG_NAME, + LogSeverity severity = NORMAL, + unsigned int defStreams = aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE, + IOSystem *io = nullptr); // ---------------------------------------------------------------------- /** @brief Setup a custom #Logger implementation. @@ -101,7 +99,7 @@ public: * it's much easier to use #create() and to attach your own custom * output streams to it. * @param logger Pass NULL to setup a default NullLogger*/ - static void set (Logger *logger); + static void set(Logger *logger); // ---------------------------------------------------------------------- /** @brief Getter for singleton instance @@ -124,12 +122,12 @@ public: // ---------------------------------------------------------------------- /** @copydoc Logger::attachStream */ bool attachStream(LogStream *pStream, - unsigned int severity); + unsigned int severity); // ---------------------------------------------------------------------- - /** @copydoc Logger::detatchStream */ - bool detatchStream(LogStream *pStream, - unsigned int severity); + /** @copydoc Logger::detachStream */ + bool detachStream(LogStream *pStream, + unsigned int severity); private: // ---------------------------------------------------------------------- @@ -141,21 +139,24 @@ private: /** @briefDestructor */ ~DefaultLogger(); + /** @brief Logs debug infos, only been written when severity level DEBUG or higher is set */ + void OnDebug(const char *message); + /** @brief Logs debug infos, only been written when severity level VERBOSE is set */ - void OnDebug(const char* message); + void OnVerboseDebug(const char *message); /** @brief Logs an info message */ - void OnInfo(const char* message); + void OnInfo(const char *message); /** @brief Logs a warning message */ - void OnWarn(const char* message); + void OnWarn(const char *message); /** @brief Logs an error message */ - void OnError(const char* message); + void OnError(const char *message); // ---------------------------------------------------------------------- /** @brief Writes a message to all streams */ - void WriteToStreams(const char* message, ErrorSeverity ErrorSev ); + void WriteToStreams(const char *message, ErrorSeverity ErrorSev); // ---------------------------------------------------------------------- /** @brief Returns the thread id. @@ -166,9 +167,9 @@ private: private: // Aliases for stream container - typedef std::vector StreamArray; - typedef std::vector::iterator StreamIt; - typedef std::vector::const_iterator ConstStreamIt; + typedef std::vector StreamArray; + typedef std::vector::iterator StreamIt; + typedef std::vector::const_iterator ConstStreamIt; //! only logging instance static Logger *m_pLogger; @@ -178,7 +179,7 @@ private: StreamArray m_StreamArray; bool noRepeatMsg; - char lastMsg[MAX_LOG_MESSAGE_LENGTH*2]; + char lastMsg[MAX_LOG_MESSAGE_LENGTH * 2]; size_t lastLen; }; // ------------------------------------------------------------------------------------ diff --git a/include/assimp/Exceptional.h b/include/assimp/Exceptional.h index 8970ade7c..c10b2f982 100644 --- a/include/assimp/Exceptional.h +++ b/include/assimp/Exceptional.h @@ -43,27 +43,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_INCLUDED_EXCEPTIONAL_H #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif -#include #include +#include using std::runtime_error; #ifdef _MSC_VER -# pragma warning(disable : 4275) +#pragma warning(disable : 4275) #endif // --------------------------------------------------------------------------- /** FOR IMPORTER PLUGINS ONLY: Simple exception class to be thrown if an * unrecoverable error occurs while importing. Loading APIs return - * NULL instead of a valid aiScene then. */ + * nullptr instead of a valid aiScene then. */ class DeadlyImportError : public runtime_error { public: /** Constructor with arguments */ - explicit DeadlyImportError( const std::string& errorText) - : runtime_error(errorText) { + explicit DeadlyImportError(const std::string &errorText) : + runtime_error(errorText) { // empty } }; @@ -78,21 +78,21 @@ public: }; #ifdef _MSC_VER -# pragma warning(default : 4275) +#pragma warning(default : 4275) #endif // --------------------------------------------------------------------------- template -struct ExceptionSwallower { - T operator ()() const { +struct ExceptionSwallower { + T operator()() const { return T(); } }; // --------------------------------------------------------------------------- template -struct ExceptionSwallower { - T* operator ()() const { +struct ExceptionSwallower { + T *operator()() const { return nullptr; } }; @@ -100,14 +100,12 @@ struct ExceptionSwallower { // --------------------------------------------------------------------------- template <> struct ExceptionSwallower { - aiReturn operator ()() const { + aiReturn operator()() const { try { throw; - } - catch (std::bad_alloc&) { + } catch (std::bad_alloc &) { return aiReturn_OUTOFMEMORY; - } - catch (...) { + } catch (...) { return aiReturn_FAILURE; } } @@ -116,29 +114,32 @@ struct ExceptionSwallower { // --------------------------------------------------------------------------- template <> struct ExceptionSwallower { - void operator ()() const { + void operator()() const { return; } }; -#define ASSIMP_BEGIN_EXCEPTION_REGION()\ -{\ - try { +#define ASSIMP_BEGIN_EXCEPTION_REGION() \ + { \ + try { -#define ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(type, ASSIMP_END_EXCEPTION_REGION_errorString)\ - } catch(const DeadlyImportError& e) {\ - ASSIMP_END_EXCEPTION_REGION_errorString = e.what();\ - return ExceptionSwallower()();\ - } catch(...) {\ - ASSIMP_END_EXCEPTION_REGION_errorString = "Unknown exception";\ - return ExceptionSwallower()();\ - }\ -} +#define ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(type, ASSIMP_END_EXCEPTION_REGION_errorString) \ + } \ + catch (const DeadlyImportError &e) { \ + ASSIMP_END_EXCEPTION_REGION_errorString = e.what(); \ + return ExceptionSwallower()(); \ + } \ + catch (...) { \ + ASSIMP_END_EXCEPTION_REGION_errorString = "Unknown exception"; \ + return ExceptionSwallower()(); \ + } \ + } -#define ASSIMP_END_EXCEPTION_REGION(type)\ - } catch(...) {\ - return ExceptionSwallower()();\ - }\ -} +#define ASSIMP_END_EXCEPTION_REGION(type) \ + } \ + catch (...) { \ + return ExceptionSwallower()(); \ + } \ + } #endif // AI_INCLUDED_EXCEPTIONAL_H diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index dc6661c11..ed910d4d7 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_EXPORT_HPP_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #ifndef ASSIMP_BUILD_NO_EXPORT @@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include namespace Assimp { - + class ExporterPimpl; class IOSystem; class ProgressHandler; @@ -84,7 +84,7 @@ class ASSIMP_API ExportProperties; class ASSIMP_API Exporter { public: /** Function pointer type of a Export worker function */ - typedef void (*fpExportFunc)(const char*, IOSystem*, const aiScene*, const ExportProperties*); + typedef void (*fpExportFunc)(const char *, IOSystem *, const aiScene *, const ExportProperties *); /** Internal description of an Assimp export format option */ struct ExportFormatEntry { @@ -98,8 +98,7 @@ public: unsigned int mEnforcePP; // Constructor to fill all entries - ExportFormatEntry( const char* pId, const char* pDesc, const char* pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u) - { + ExportFormatEntry(const char *pId, const char *pDesc, const char *pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u) { mDescription.id = pId; mDescription.description = pDesc; mDescription.fileExtension = pExtension; @@ -108,12 +107,10 @@ public: } ExportFormatEntry() : - mExportFunction() - , mEnforcePP() - { - mDescription.id = NULL; - mDescription.description = NULL; - mDescription.fileExtension = NULL; + mExportFunction(), mEnforcePP() { + mDescription.id = nullptr; + mDescription.description = nullptr; + mDescription.fileExtension = nullptr; } }; @@ -142,7 +139,7 @@ public: * * @param pIOHandler The IO handler to be used in all file accesses * of the Importer. */ - void SetIOHandler( IOSystem* pIOHandler); + void SetIOHandler(IOSystem *pIOHandler); // ------------------------------------------------------------------- /** Retrieves the IO handler that is currently set. @@ -150,8 +147,8 @@ public: * interface is the default IO handler provided by ASSIMP. The default * handler is active as long the application doesn't supply its own * custom IO handler via #SetIOHandler(). - * @return A valid IOSystem interface, never NULL. */ - IOSystem* GetIOHandler() const; + * @return A valid IOSystem interface, never nullptr. */ + IOSystem *GetIOHandler() const; // ------------------------------------------------------------------- /** Checks whether a default IO handler is active @@ -171,7 +168,7 @@ public: * disable progress reporting. * @note Progress handlers can be used to abort the loading * at almost any time.*/ - void SetProgressHandler(ProgressHandler* pHandler); + void SetProgressHandler(ProgressHandler *pHandler); // ------------------------------------------------------------------- /** Exports the given scene to a chosen file format. Returns the exported @@ -185,22 +182,22 @@ public: * #GetExportFormatCount / #GetExportFormatDescription to learn which * export formats are available. * @param pPreprocessing See the documentation for #Export - * @return the exported data or NULL in case of error. + * @return the exported data or nullptr in case of error. * @note If the Exporter instance did already hold a blob from * a previous call to #ExportToBlob, it will be disposed. * Any IO handlers set via #SetIOHandler are ignored here. * @note Use aiCopyScene() to get a modifiable copy of a previously * imported scene. */ - const aiExportDataBlob* ExportToBlob(const aiScene* pScene, const char* pFormatId, - unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr); - const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, - unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr); + const aiExportDataBlob *ExportToBlob(const aiScene *pScene, const char *pFormatId, + unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr); + const aiExportDataBlob *ExportToBlob(const aiScene *pScene, const std::string &pFormatId, + unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr); // ------------------------------------------------------------------- /** Convenience function to export directly to a file. Use * #SetIOSystem to supply a custom IOSystem to gain fine-grained control * about the output data flow of the export process. - * @param pBlob A data blob obtained from a previous call to #aiExportScene. Must not be NULL. + * @param pBlob A data blob obtained from a previous call to #aiExportScene. Must not be nullptr. * @param pPath Full target file name. Target must be accessible. * @param pPreprocessing Accepts any choice of the #aiPostProcessSteps enumerated * flags, but in reality only a subset of them makes sense here. Specifying @@ -229,10 +226,10 @@ public: * @return AI_SUCCESS if everything was fine. * @note Use aiCopyScene() to get a modifiable copy of a previously * imported scene.*/ - aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, - unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr); - aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, - unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr); + aiReturn Export(const aiScene *pScene, const char *pFormatId, const char *pPath, + unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr); + aiReturn Export(const aiScene *pScene, const std::string &pFormatId, const std::string &pPath, + unsigned int pPreprocessing = 0u, const ExportProperties *pProperties = nullptr); // ------------------------------------------------------------------- /** Returns an error description of an error that occurred in #Export @@ -240,21 +237,21 @@ public: * * Returns an empty string if no error occurred. * @return A description of the last error, an empty string if no - * error occurred. The string is never NULL. + * error occurred. The string is never nullptr. * * @note The returned function remains valid until one of the * following methods is called: #Export, #ExportToBlob, #FreeBlob */ - const char* GetErrorString() const; + const char *GetErrorString() const; // ------------------------------------------------------------------- /** Return the blob obtained from the last call to #ExportToBlob */ - const aiExportDataBlob* GetBlob() const; + const aiExportDataBlob *GetBlob() const; // ------------------------------------------------------------------- /** Orphan the blob from the last call to #ExportToBlob. This means * the caller takes ownership and is thus responsible for calling * the C API function #aiReleaseExportBlob to release it. */ - const aiExportDataBlob* GetOrphanedBlob() const; + const aiExportDataBlob *GetOrphanedBlob() const; // ------------------------------------------------------------------- /** Frees the current blob. @@ -264,7 +261,7 @@ public: * automatically by the destructor. The only reason to call * it manually would be to reclaim as much storage as possible * without giving up the #Exporter instance yet. */ - void FreeBlob( ); + void FreeBlob(); // ------------------------------------------------------------------- /** Returns the number of export file formats available in the current @@ -289,8 +286,8 @@ public: * @param pIndex Index of the export format to retrieve information * for. Valid range is 0 to #Exporter::GetExportFormatCount * @return A description of that specific export format. - * NULL if pIndex is out of range. */ - const aiExportFormatDesc* GetExportFormatDescription( size_t pIndex ) const; + * nullptr if pIndex is out of range. */ + const aiExportFormatDesc *GetExportFormatDescription(size_t pIndex) const; // ------------------------------------------------------------------- /** Register a custom exporter. Custom export formats are limited to @@ -303,7 +300,7 @@ public: * registered. A common cause that would prevent an exporter * from being registered is that its format id is already * occupied by another format. */ - aiReturn RegisterExporter(const ExportFormatEntry& desc); + aiReturn RegisterExporter(const ExportFormatEntry &desc); // ------------------------------------------------------------------- /** Remove an export format previously registered with #RegisterExporter @@ -314,11 +311,11 @@ public: * 'id' field of #aiExportFormatDesc. * @note Calling this method on a format description not yet registered * has no effect.*/ - void UnregisterExporter(const char* id); + void UnregisterExporter(const char *id); protected: // Just because we don't want you to know how we're hacking around. - ExporterPimpl* pimpl; + ExporterPimpl *pimpl; }; class ASSIMP_API ExportProperties { @@ -345,7 +342,7 @@ public: * This copies the configuration properties of another ExportProperties. * @see ExportProperties(const ExportProperties& other) */ - ExportProperties(const ExportProperties& other); + ExportProperties(const ExportProperties &other); // ------------------------------------------------------------------- /** Set an integer configuration property. @@ -360,7 +357,7 @@ public: * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - bool SetPropertyInteger(const char* szName, int iValue); + bool SetPropertyInteger(const char *szName, int iValue); // ------------------------------------------------------------------- /** Set a boolean configuration property. Boolean properties @@ -369,27 +366,27 @@ public: * #GetPropertyBool and vice versa. * @see SetPropertyInteger() */ - bool SetPropertyBool(const char* szName, bool value) { - return SetPropertyInteger(szName,value); + bool SetPropertyBool(const char *szName, bool value) { + return SetPropertyInteger(szName, value); } // ------------------------------------------------------------------- /** Set a floating-point configuration property. * @see SetPropertyInteger() */ - bool SetPropertyFloat(const char* szName, ai_real fValue); + bool SetPropertyFloat(const char *szName, ai_real fValue); // ------------------------------------------------------------------- /** Set a string configuration property. * @see SetPropertyInteger() */ - bool SetPropertyString(const char* szName, const std::string& sValue); + bool SetPropertyString(const char *szName, const std::string &sValue); // ------------------------------------------------------------------- /** Set a matrix configuration property. * @see SetPropertyInteger() */ - bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); + bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue); // ------------------------------------------------------------------- /** Get a configuration property. @@ -404,8 +401,8 @@ public: * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - int GetPropertyInteger(const char* szName, - int iErrorReturn = 0xffffffff) const; + int GetPropertyInteger(const char *szName, + int iErrorReturn = 0xffffffff) const; // ------------------------------------------------------------------- /** Get a boolean configuration property. Boolean properties @@ -414,16 +411,16 @@ public: * #GetPropertyBool and vice versa. * @see GetPropertyInteger() */ - bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const { - return GetPropertyInteger(szName,bErrorReturn)!=0; + bool GetPropertyBool(const char *szName, bool bErrorReturn = false) const { + return GetPropertyInteger(szName, bErrorReturn) != 0; } // ------------------------------------------------------------------- /** Get a floating-point configuration property * @see GetPropertyInteger() */ - ai_real GetPropertyFloat(const char* szName, - ai_real fErrorReturn = 10e10f) const; + ai_real GetPropertyFloat(const char *szName, + ai_real fErrorReturn = 10e10f) const; // ------------------------------------------------------------------- /** Get a string configuration property @@ -431,8 +428,8 @@ public: * The return value remains valid until the property is modified. * @see GetPropertyInteger() */ - const std::string GetPropertyString(const char* szName, - const std::string& sErrorReturn = "") const; + const std::string GetPropertyString(const char *szName, + const std::string &sErrorReturn = "") const; // ------------------------------------------------------------------- /** Get a matrix configuration property @@ -440,37 +437,36 @@ public: * The return value remains valid until the property is modified. * @see GetPropertyInteger() */ - const aiMatrix4x4 GetPropertyMatrix(const char* szName, - const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const; + const aiMatrix4x4 GetPropertyMatrix(const char *szName, + const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const; // ------------------------------------------------------------------- /** Determine a integer configuration property has been set. * @see HasPropertyInteger() */ - bool HasPropertyInteger(const char* szName) const; + bool HasPropertyInteger(const char *szName) const; /** Determine a boolean configuration property has been set. * @see HasPropertyBool() */ - bool HasPropertyBool(const char* szName) const; + bool HasPropertyBool(const char *szName) const; /** Determine a boolean configuration property has been set. * @see HasPropertyFloat() */ - bool HasPropertyFloat(const char* szName) const; + bool HasPropertyFloat(const char *szName) const; /** Determine a String configuration property has been set. * @see HasPropertyString() */ - bool HasPropertyString(const char* szName) const; + bool HasPropertyString(const char *szName) const; /** Determine a Matrix configuration property has been set. * @see HasPropertyMatrix() */ - bool HasPropertyMatrix(const char* szName) const; + bool HasPropertyMatrix(const char *szName) const; protected: - /** List of integer properties */ IntPropertyMap mIntProperties; @@ -485,20 +481,16 @@ protected: }; // ---------------------------------------------------------------------------------- -inline -const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const std::string& pFormatId, - unsigned int pPreprocessing, const ExportProperties* pProperties) -{ - return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing, pProperties); +inline const aiExportDataBlob *Exporter::ExportToBlob(const aiScene *pScene, const std::string &pFormatId, + unsigned int pPreprocessing, const ExportProperties *pProperties) { + return ExportToBlob(pScene, pFormatId.c_str(), pPreprocessing, pProperties); } // ---------------------------------------------------------------------------------- -inline -aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, - const std::string& pPath, unsigned int pPreprocessing, - const ExportProperties* pProperties) -{ - return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing, pProperties); +inline aiReturn Exporter ::Export(const aiScene *pScene, const std::string &pFormatId, + const std::string &pPath, unsigned int pPreprocessing, + const ExportProperties *pProperties) { + return Export(pScene, pFormatId.c_str(), pPath.c_str(), pPreprocessing, pProperties); } } // namespace Assimp diff --git a/include/assimp/GenericProperty.h b/include/assimp/GenericProperty.h index c1891c7b6..e12a443b0 100644 --- a/include/assimp/GenericProperty.h +++ b/include/assimp/GenericProperty.h @@ -87,7 +87,7 @@ inline const T &GetGenericProperty(const std::map &list, // ------------------------------------------------------------------------------------------------ // Special version for pointer types - they will be deleted when replaced with another value -// passing NULL removes the whole property +// passing nullptr removes the whole property template inline void SetGenericPropertyPtr(std::map &list, const char *szName, T *value, bool *bWasExisting = nullptr) { diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp index ca3964c7d..80eae78b3 100644 --- a/include/assimp/Importer.hpp +++ b/include/assimp/Importer.hpp @@ -49,39 +49,39 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_ASSIMP_HPP_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #ifndef __cplusplus -# error This header requires C++ to be used. Use assimp.h for plain C. +#error This header requires C++ to be used. Use assimp.h for plain C. #endif // __cplusplus // Public ASSIMP data structures #include namespace Assimp { - // ======================================================================= - // Public interface to Assimp - class Importer; - class IOStream; - class IOSystem; - class ProgressHandler; +// ======================================================================= +// Public interface to Assimp +class Importer; +class IOStream; +class IOSystem; +class ProgressHandler; - // ======================================================================= - // Plugin development - // - // Include the following headers for the declarations: - // BaseImporter.h - // BaseProcess.h - class BaseImporter; - class BaseProcess; - class SharedPostProcessInfo; - class BatchLoader; +// ======================================================================= +// Plugin development +// +// Include the following headers for the declarations: +// BaseImporter.h +// BaseProcess.h +class BaseImporter; +class BaseProcess; +class SharedPostProcessInfo; +class BatchLoader; - // ======================================================================= - // Holy stuff, only for members of the high council of the Jedi. - class ImporterPimpl; -} //! namespace Assimp +// ======================================================================= +// Holy stuff, only for members of the high council of the Jedi. +class ImporterPimpl; +} // namespace Assimp #define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff @@ -91,7 +91,7 @@ struct aiScene; struct aiImporterDesc; /** @namespace Assimp Assimp's CPP-API and all internal APIs */ -namespace Assimp { +namespace Assimp { // ---------------------------------------------------------------------------------- /** CPP-API: The Importer class forms an C++ interface to the functionality of the @@ -101,7 +101,7 @@ namespace Assimp { * If the import succeeds, the function returns a pointer to the imported data. * The data remains property of the object, it is intended to be accessed * read-only. The imported data will be destroyed along with the Importer -* object. If the import fails, ReadFile() returns a NULL pointer. In this +* object. If the import fails, ReadFile() returns a nullptr pointer. In this * case you can retrieve a human-readable error description be calling * GetErrorString(). You can call ReadFile() multiple times with a single Importer * instance. Actually, constructing Importer objects involves quite many @@ -117,7 +117,7 @@ namespace Assimp { * @note One Importer instance is not thread-safe. If you use multiple * threads for loading, each thread should maintain its own Importer instance. */ -class ASSIMP_API Importer { +class ASSIMP_API Importer { public: /** * @brief The upper limit for hints. @@ -125,7 +125,6 @@ public: static const unsigned int MaxLenHint = 200; public: - // ------------------------------------------------------------------- /** Constructor. Creates an empty importer object. * @@ -141,7 +140,7 @@ public: * If this Importer owns a scene it won't be copied. * Call ReadFile() to start the import process. */ - Importer(const Importer& other)=delete; + Importer(const Importer &other) = delete; // ------------------------------------------------------------------- /** Assignment operator has been deleted @@ -154,7 +153,6 @@ public: */ ~Importer(); - // ------------------------------------------------------------------- /** Registers a new loader. * @@ -164,7 +162,7 @@ public: * @return AI_SUCCESS if the loader has been added. The registration * fails if there is already a loader for a specific file extension. */ - aiReturn RegisterLoader(BaseImporter* pImp); + aiReturn RegisterLoader(BaseImporter *pImp); // ------------------------------------------------------------------- /** Unregisters a loader. @@ -175,7 +173,7 @@ public: * if the #Importer instance is used by more than one thread) or * if it has not yet been registered. */ - aiReturn UnregisterLoader(BaseImporter* pImp); + aiReturn UnregisterLoader(BaseImporter *pImp); // ------------------------------------------------------------------- /** Registers a new post-process step. @@ -188,7 +186,7 @@ public: * deleted with the Importer instance. * @return AI_SUCCESS if the step has been added correctly. */ - aiReturn RegisterPPStep(BaseProcess* pImp); + aiReturn RegisterPPStep(BaseProcess *pImp); // ------------------------------------------------------------------- /** Unregisters a post-process step. @@ -199,7 +197,7 @@ public: * if the #Importer instance is used by more than one thread) or * if it has not yet been registered. */ - aiReturn UnregisterPPStep(BaseProcess* pImp); + aiReturn UnregisterPPStep(BaseProcess *pImp); // ------------------------------------------------------------------- /** Set an integer configuration property. @@ -214,7 +212,7 @@ public: * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - bool SetPropertyInteger(const char* szName, int iValue); + bool SetPropertyInteger(const char *szName, int iValue); // ------------------------------------------------------------------- /** Set a boolean configuration property. Boolean properties @@ -223,27 +221,27 @@ public: * #GetPropertyBool and vice versa. * @see SetPropertyInteger() */ - bool SetPropertyBool(const char* szName, bool value) { - return SetPropertyInteger(szName,value); + bool SetPropertyBool(const char *szName, bool value) { + return SetPropertyInteger(szName, value); } // ------------------------------------------------------------------- /** Set a floating-point configuration property. * @see SetPropertyInteger() */ - bool SetPropertyFloat(const char* szName, ai_real fValue); + bool SetPropertyFloat(const char *szName, ai_real fValue); // ------------------------------------------------------------------- /** Set a string configuration property. * @see SetPropertyInteger() */ - bool SetPropertyString(const char* szName, const std::string& sValue); + bool SetPropertyString(const char *szName, const std::string &sValue); // ------------------------------------------------------------------- /** Set a matrix configuration property. * @see SetPropertyInteger() */ - bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); + bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue); // ------------------------------------------------------------------- /** Get a configuration property. @@ -258,8 +256,8 @@ public: * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - int GetPropertyInteger(const char* szName, - int iErrorReturn = 0xffffffff) const; + int GetPropertyInteger(const char *szName, + int iErrorReturn = 0xffffffff) const; // ------------------------------------------------------------------- /** Get a boolean configuration property. Boolean properties @@ -268,16 +266,16 @@ public: * #GetPropertyBool and vice versa. * @see GetPropertyInteger() */ - bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const { - return GetPropertyInteger(szName,bErrorReturn)!=0; + bool GetPropertyBool(const char *szName, bool bErrorReturn = false) const { + return GetPropertyInteger(szName, bErrorReturn) != 0; } // ------------------------------------------------------------------- /** Get a floating-point configuration property * @see GetPropertyInteger() */ - ai_real GetPropertyFloat(const char* szName, - ai_real fErrorReturn = 10e10) const; + ai_real GetPropertyFloat(const char *szName, + ai_real fErrorReturn = 10e10) const; // ------------------------------------------------------------------- /** Get a string configuration property @@ -285,8 +283,8 @@ public: * The return value remains valid until the property is modified. * @see GetPropertyInteger() */ - std::string GetPropertyString(const char* szName, - const std::string& sErrorReturn = "") const; + std::string GetPropertyString(const char *szName, + const std::string &sErrorReturn = "") const; // ------------------------------------------------------------------- /** Get a matrix configuration property @@ -294,8 +292,8 @@ public: * The return value remains valid until the property is modified. * @see GetPropertyInteger() */ - aiMatrix4x4 GetPropertyMatrix(const char* szName, - const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const; + aiMatrix4x4 GetPropertyMatrix(const char *szName, + const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const; // ------------------------------------------------------------------- /** Supplies a custom IO handler to the importer to use to open and @@ -306,13 +304,13 @@ public: * * The Importer takes ownership of the object and will destroy it * afterwards. The previously assigned handler will be deleted. - * Pass NULL to take again ownership of your IOSystem and reset Assimp + * Pass nullptr to take again ownership of your IOSystem and reset Assimp * to use its default implementation. * * @param pIOHandler The IO handler to be used in all file accesses * of the Importer. */ - void SetIOHandler( IOSystem* pIOHandler); + void SetIOHandler(IOSystem *pIOHandler); // ------------------------------------------------------------------- /** Retrieves the IO handler that is currently set. @@ -320,9 +318,9 @@ public: * interface is the default IO handler provided by ASSIMP. The default * handler is active as long the application doesn't supply its own * custom IO handler via #SetIOHandler(). - * @return A valid IOSystem interface, never NULL. + * @return A valid IOSystem interface, never nullptr. */ - IOSystem* GetIOHandler() const; + IOSystem *GetIOHandler() const; // ------------------------------------------------------------------- /** Checks whether a default IO handler is active @@ -339,11 +337,11 @@ public: * isn't as periodically as you'd like it to have ...). * This can be used to implement progress bars and loading * timeouts. - * @param pHandler Progress callback interface. Pass NULL to + * @param pHandler Progress callback interface. Pass nullptr to * disable progress reporting. * @note Progress handlers can be used to abort the loading * at almost any time.*/ - void SetProgressHandler ( ProgressHandler* pHandler ); + void SetProgressHandler(ProgressHandler *pHandler); // ------------------------------------------------------------------- /** Retrieves the progress handler that is currently set. @@ -351,9 +349,9 @@ public: * interface is the default handler provided by ASSIMP. The default * handler is active as long the application doesn't supply its own * custom handler via #SetProgressHandler(). - * @return A valid ProgressHandler interface, never NULL. + * @return A valid ProgressHandler interface, never nullptr. */ - ProgressHandler* GetProgressHandler() const; + ProgressHandler *GetProgressHandler() const; // ------------------------------------------------------------------- /** Checks whether a default progress handler is active @@ -383,7 +381,7 @@ public: * If the call succeeds, the contents of the file are returned as a * pointer to an aiScene object. The returned data is intended to be * read-only, the importer object keeps ownership of the data and will - * destroy it upon destruction. If the import fails, NULL is returned. + * destroy it upon destruction. If the import fails, nullptr is returned. * A human-readable error description can be retrieved by calling * GetErrorString(). The previous scene will be deleted during this call. * @param pFile Path and filename to the file to be imported. @@ -392,16 +390,16 @@ public: * #aiPostProcessSteps flags. If you wish to inspect the imported * scene first in order to fine-tune your post-processing setup, * consider to use #ApplyPostProcessing(). - * @return A pointer to the imported data, NULL if the import failed. + * @return A pointer to the imported data, nullptr if the import failed. * The pointer to the scene remains in possession of the Importer * instance. Use GetOrphanedScene() to take ownership of it. * * @note Assimp is able to determine the file format of a file * automatically. */ - const aiScene* ReadFile( - const char* pFile, - unsigned int pFlags); + const aiScene *ReadFile( + const char *pFile, + unsigned int pFlags); // ------------------------------------------------------------------- /** Reads the given file from a memory buffer and returns its @@ -410,7 +408,7 @@ public: * If the call succeeds, the contents of the file are returned as a * pointer to an aiScene object. The returned data is intended to be * read-only, the importer object keeps ownership of the data and will - * destroy it upon destruction. If the import fails, NULL is returned. + * destroy it upon destruction. If the import fails, nullptr is returned. * A human-readable error description can be retrieved by calling * GetErrorString(). The previous scene will be deleted during this call. * Calling this method doesn't affect the active IOSystem. @@ -428,7 +426,7 @@ public: * the request, the library continues and tries to determine the * file format on its own, a task that may or may not be successful. * Check the return value, and you'll know ... - * @return A pointer to the imported data, NULL if the import failed. + * @return A pointer to the imported data, nullptr if the import failed. * The pointer to the scene remains in possession of the Importer * instance. Use GetOrphanedScene() to take ownership of it. * @@ -440,11 +438,11 @@ public: * a custom IOSystem to make Assimp find these files and use * the regular ReadFile() API. */ - const aiScene* ReadFileFromMemory( - const void* pBuffer, - size_t pLength, - unsigned int pFlags, - const char* pHint = ""); + const aiScene *ReadFileFromMemory( + const void *pBuffer, + size_t pLength, + unsigned int pFlags, + const char *pHint = ""); // ------------------------------------------------------------------- /** Apply post-processing to an already-imported scene. @@ -456,17 +454,17 @@ public: * #aiPostProcessSteps flags. * @return A pointer to the post-processed data. This is still the * same as the pointer returned by #ReadFile(). However, if - * post-processing fails, the scene could now be NULL. + * post-processing fails, the scene could now be nullptr. * That's quite a rare case, post processing steps are not really * designed to 'fail'. To be exact, the #aiProcess_ValidateDS * flag is currently the only post processing step which can actually - * cause the scene to be reset to NULL. + * cause the scene to be reset to nullptr. * * @note The method does nothing if no scene is currently bound * to the #Importer instance. */ - const aiScene* ApplyPostProcessing(unsigned int pFlags); + const aiScene *ApplyPostProcessing(unsigned int pFlags); - const aiScene* ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation ); + const aiScene *ApplyCustomizedPostProcessing(BaseProcess *rootProcess, bool requestValidation); // ------------------------------------------------------------------- /** @brief Reads the given file and returns its contents if successful. @@ -474,9 +472,9 @@ public: * This function is provided for backward compatibility. * See the const char* version for detailed docs. * @see ReadFile(const char*, pFlags) */ - const aiScene* ReadFile( - const std::string& pFile, - unsigned int pFlags); + const aiScene *ReadFile( + const std::string &pFile, + unsigned int pFlags); // ------------------------------------------------------------------- /** Frees the current scene. @@ -484,33 +482,33 @@ public: * The function does nothing if no scene has previously been * read via ReadFile(). FreeScene() is called automatically by the * destructor and ReadFile() itself. */ - void FreeScene( ); + void FreeScene(); // ------------------------------------------------------------------- /** Returns an error description of an error that occurred in ReadFile(). * * Returns an empty string if no error occurred. * @return A description of the last error, an empty string if no - * error occurred. The string is never NULL. + * error occurred. The string is never nullptr. * * @note The returned function remains valid until one of the * following methods is called: #ReadFile(), #FreeScene(). */ - const char* GetErrorString() const; + const char *GetErrorString() const; // ------------------------------------------------------------------- /** Returns the scene loaded by the last successful call to ReadFile() * - * @return Current scene or NULL if there is currently no scene loaded */ - const aiScene* GetScene() const; + * @return Current scene or nullptr if there is currently no scene loaded */ + const aiScene *GetScene() const; // ------------------------------------------------------------------- /** Returns the scene loaded by the last successful call to ReadFile() * and releases the scene from the ownership of the Importer * instance. The application is now responsible for deleting the * scene. Any further calls to GetScene() or GetOrphanedScene() - * will return NULL - until a new scene has been loaded via ReadFile(). + * will return nullptr - until a new scene has been loaded via ReadFile(). * - * @return Current scene or NULL if there is currently no scene loaded + * @return Current scene or nullptr if there is currently no scene loaded * @note Use this method with maximal caution, and only if you have to. * By design, aiScene's are exclusively maintained, allocated and * deallocated by Assimp and no one else. The reasoning behind this @@ -522,7 +520,7 @@ public: * On Windows, it's typically fine provided everything is linked * against the multithreaded-dll version of the runtime library. * It will work as well for static linkage with Assimp.*/ - aiScene* GetOrphanedScene(); + aiScene *GetOrphanedScene(); // ------------------------------------------------------------------- /** Returns whether a given file extension is supported by ASSIMP. @@ -531,7 +529,7 @@ public: * Must include a trailing dot '.'. Example: ".3ds", ".md3". * Cases-insensitive. * @return true if the extension is supported, false otherwise */ - bool IsExtensionSupported(const char* szExtension) const; + bool IsExtensionSupported(const char *szExtension) const; // ------------------------------------------------------------------- /** @brief Returns whether a given file extension is supported by ASSIMP. @@ -539,7 +537,7 @@ public: * This function is provided for backward compatibility. * See the const char* version for detailed and up-to-date docs. * @see IsExtensionSupported(const char*) */ - inline bool IsExtensionSupported(const std::string& szExtension) const; + inline bool IsExtensionSupported(const std::string &szExtension) const; // ------------------------------------------------------------------- /** Get a full list of all file extensions supported by ASSIMP. @@ -551,7 +549,7 @@ public: * @param szOut String to receive the extension list. * Format of the list: "*.3ds;*.obj;*.dae". This is useful for * use with the WinAPI call GetOpenFileName(Ex). */ - void GetExtensionList(aiString& szOut) const; + void GetExtensionList(aiString &szOut) const; // ------------------------------------------------------------------- /** @brief Get a full list of all file extensions supported by ASSIMP. @@ -559,7 +557,7 @@ public: * This function is provided for backward compatibility. * See the aiString version for detailed and up-to-date docs. * @see GetExtensionList(aiString&)*/ - inline void GetExtensionList(std::string& szOut) const; + inline void GetExtensionList(std::string &szOut) const; // ------------------------------------------------------------------- /** Get the number of importers currently registered with Assimp. */ @@ -570,18 +568,18 @@ public: * * For the declaration of #aiImporterDesc, include . * @param index Index to query, must be within [0,GetImporterCount()) - * @return Importer meta data structure, NULL if the index does not + * @return Importer meta data structure, nullptr if the index does not * exist or if the importer doesn't offer meta information ( * importers may do this at the cost of being hated by their peers).*/ - const aiImporterDesc* GetImporterInfo(size_t index) const; + const aiImporterDesc *GetImporterInfo(size_t index) const; // ------------------------------------------------------------------- /** Find the importer corresponding to a specific index. * * @param index Index to query, must be within [0,GetImporterCount()) - * @return Importer instance. NULL if the index does not + * @return Importer instance. nullptr if the index does not * exist. */ - BaseImporter* GetImporter(size_t index) const; + BaseImporter *GetImporter(size_t index) const; // ------------------------------------------------------------------- /** Find the importer corresponding to a specific file extension. @@ -592,8 +590,8 @@ public: * are recognized (BAH being the file extension): "BAH" (comparison * is case-insensitive), ".bah", "*.bah" (wild card and dot * characters at the beginning of the extension are skipped). - * @return NULL if no importer is found*/ - BaseImporter* GetImporter (const char* szExtension) const; + * @return nullptr if no importer is found*/ + BaseImporter *GetImporter(const char *szExtension) const; // ------------------------------------------------------------------- /** Find the importer index corresponding to a specific file extension. @@ -603,7 +601,7 @@ public: * is case-insensitive), ".bah", "*.bah" (wild card and dot * characters at the beginning of the extension are skipped). * @return (size_t)-1 if no importer is found */ - size_t GetImporterIndex (const char* szExtension) const; + size_t GetImporterIndex(const char *szExtension) const; // ------------------------------------------------------------------- /** Returns the storage allocated by ASSIMP to hold the scene data @@ -614,7 +612,7 @@ public: * @note The returned memory statistics refer to the actual * size of the use data of the aiScene. Heap-related overhead * is (naturally) not included.*/ - void GetMemoryRequirements(aiMemoryInfo& in) const; + void GetMemoryRequirements(aiMemoryInfo &in) const; // ------------------------------------------------------------------- /** Enables "extra verbose" mode. @@ -627,16 +625,14 @@ public: // ------------------------------------------------------------------- /** Private, do not use. */ - ImporterPimpl* Pimpl() { return pimpl; } - const ImporterPimpl* Pimpl() const { return pimpl; } + ImporterPimpl *Pimpl() { return pimpl; } + const ImporterPimpl *Pimpl() const { return pimpl; } protected: - // Just because we don't want you to know how we're hacking around. - ImporterPimpl* pimpl; + ImporterPimpl *pimpl; }; //! class Importer - // ---------------------------------------------------------------------------- // For compatibility, the interface of some functions taking a std::string was // changed to const char* to avoid crashes between binary incompatible STL @@ -644,20 +640,20 @@ protected: // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- -AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,unsigned int pFlags){ - return ReadFile(pFile.c_str(),pFlags); +AI_FORCE_INLINE const aiScene *Importer::ReadFile(const std::string &pFile, unsigned int pFlags) { + return ReadFile(pFile.c_str(), pFlags); } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) const { +AI_FORCE_INLINE void Importer::GetExtensionList(std::string &szOut) const { aiString s; GetExtensionList(s); szOut = s.data; } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string& szExtension) const { +AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string &szExtension) const { return IsExtensionSupported(szExtension.c_str()); } -} // !namespace Assimp +} // namespace Assimp #endif // AI_ASSIMP_HPP_INC diff --git a/include/assimp/LineSplitter.h b/include/assimp/LineSplitter.h index 869585d92..6dfeac7eb 100644 --- a/include/assimp/LineSplitter.h +++ b/include/assimp/LineSplitter.h @@ -72,7 +72,7 @@ for(LineSplitter splitter(stream);splitter;++splitter) { if (strtol(splitter[2]) > 5) { .. } } - ASSIMP_LOG_DEBUG_F("Current line is: ", splitter.get_index()); + ASSIMP_LOG_VERBOSE_DEBUG_F("Current line is: ", splitter.get_index()); } @endcode */ diff --git a/include/assimp/LogAux.h b/include/assimp/LogAux.h index 2265ff19c..330c5e93e 100644 --- a/include/assimp/LogAux.h +++ b/include/assimp/LogAux.h @@ -94,6 +94,12 @@ public: } } + static void LogVerboseDebug(const Formatter::format& message) { + if (!DefaultLogger::isNullLogger()) { + ASSIMP_LOG_VERBOSE_DEBUG(Prefix()+(std::string)message); + } + } + // https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462 #if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) @@ -125,6 +131,12 @@ public: } } + // ------------------------------------------------------------------------------------------------ + static void LogVerboseDebug (const char* message) { + if (!DefaultLogger::isNullLogger()) { + LogVerboseDebug(Formatter::format(message)); + } + } #endif private: diff --git a/include/assimp/LogStream.hpp b/include/assimp/LogStream.hpp index 243f13ee6..18b473430 100644 --- a/include/assimp/LogStream.hpp +++ b/include/assimp/LogStream.hpp @@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "types.h" -namespace Assimp { +namespace Assimp { class IOSystem; @@ -60,7 +60,7 @@ class IOSystem; * are not enough for your purpose. */ class ASSIMP_API LogStream #ifndef SWIG - : public Intern::AllocateFromAssimpHeap + : public Intern::AllocateFromAssimpHeap #endif { protected: @@ -80,28 +80,26 @@ public: * #DefaultLogger:set(). Usually you can *expect* that a log message * is exactly one line and terminated with a single \n character. * @param message Message to be written */ - virtual void write(const char* message) = 0; + virtual void write(const char *message) = 0; // ------------------------------------------------------------------- /** @brief Creates a default log stream * @param streams Type of the default stream * @param name For aiDefaultLogStream_FILE: name of the output file * @param io For aiDefaultLogStream_FILE: IOSystem to be used to open the output - * file. Pass NULL for the default implementation. + * file. Pass nullptr for the default implementation. * @return New LogStream instance. */ - static LogStream* createDefaultStream(aiDefaultLogStream stream, - const char* name = "AssimpLog.txt", - IOSystem* io = nullptr ); + static LogStream *createDefaultStream(aiDefaultLogStream stream, + const char *name = "AssimpLog.txt", + IOSystem *io = nullptr); }; // !class LogStream -inline -LogStream::LogStream() AI_NO_EXCEPT { +inline LogStream::LogStream() AI_NO_EXCEPT { // empty } -inline -LogStream::~LogStream() { +inline LogStream::~LogStream() { // empty } diff --git a/include/assimp/Logger.hpp b/include/assimp/Logger.hpp index a0b798564..1e5a61eee 100644 --- a/include/assimp/Logger.hpp +++ b/include/assimp/Logger.hpp @@ -74,7 +74,8 @@ public: */ enum LogSeverity { NORMAL, //!< Normal granularity of logging - VERBOSE //!< Debug infos will be logged, too + DEBUG, //!< Debug messages will be logged, but not verbose debug messages. + VERBOSE //!< All messages will be logged }; // ---------------------------------------------------------------------- @@ -103,6 +104,12 @@ public: void debug(const char* message); void debug(const std::string &message); + // ---------------------------------------------------------------------- + /** @brief Writes a debug message + * @param message Debug message*/ + void verboseDebug(const char *message); + void verboseDebug(const std::string &message); + // ---------------------------------------------------------------------- /** @brief Writes a info message * @param message Info message*/ @@ -154,7 +161,7 @@ public: * if the result is 0 the stream is detached from the Logger and * the caller retakes the possession of the stream. * @return true if the stream has been detached, false otherwise.*/ - virtual bool detatchStream(LogStream *pStream, + virtual bool detachStream(LogStream *pStream, unsigned int severity = Debugging | Err | Warn | Info) = 0; protected: @@ -178,6 +185,16 @@ protected: */ virtual void OnDebug(const char* message)= 0; + // ---------------------------------------------------------------------- + /** + * @brief Called as a request to write a specific verbose debug message + * @param message Debug message. Never longer than + * MAX_LOG_MESSAGE_LENGTH characters (excluding the '0'). + * @note The message string is only valid until the scope of + * the function is left. + */ + virtual void OnVerboseDebug(const char *message) = 0; + // ---------------------------------------------------------------------- /** * @brief Called as a request to write a specific info message @@ -255,6 +272,11 @@ void Logger::debug(const std::string &message) { return debug(message.c_str()); } +// ---------------------------------------------------------------------------------- +inline void Logger::verboseDebug(const std::string &message) { + return verboseDebug(message.c_str()); +} + // ---------------------------------------------------------------------------------- inline void Logger::error(const std::string &message) { @@ -273,33 +295,37 @@ void Logger::info(const std::string &message) { return info(message.c_str()); } -// ------------------------------------------------------------------------------------------------ -#define ASSIMP_LOG_WARN_F(string,...)\ - DefaultLogger::get()->warn((Formatter::format(string),__VA_ARGS__)) - -#define ASSIMP_LOG_ERROR_F(string,...)\ - DefaultLogger::get()->error((Formatter::format(string),__VA_ARGS__)) - -#define ASSIMP_LOG_DEBUG_F(string,...)\ - DefaultLogger::get()->debug((Formatter::format(string),__VA_ARGS__)) - -#define ASSIMP_LOG_INFO_F(string,...)\ - DefaultLogger::get()->info((Formatter::format(string),__VA_ARGS__)) - - -#define ASSIMP_LOG_WARN(string)\ - DefaultLogger::get()->warn(string) - -#define ASSIMP_LOG_ERROR(string)\ - DefaultLogger::get()->error(string) - -#define ASSIMP_LOG_DEBUG(string)\ - DefaultLogger::get()->debug(string) - -#define ASSIMP_LOG_INFO(string)\ - DefaultLogger::get()->info(string) - - } // Namespace Assimp +// ------------------------------------------------------------------------------------------------ +#define ASSIMP_LOG_WARN_F(string, ...) \ + Assimp::DefaultLogger::get()->warn((Assimp::Formatter::format(string), __VA_ARGS__)) + +#define ASSIMP_LOG_ERROR_F(string, ...) \ + Assimp::DefaultLogger::get()->error((Assimp::Formatter::format(string), __VA_ARGS__)) + +#define ASSIMP_LOG_DEBUG_F(string, ...) \ + Assimp::DefaultLogger::get()->debug((Assimp::Formatter::format(string), __VA_ARGS__)) + +#define ASSIMP_LOG_VERBOSE_DEBUG_F(string, ...) \ + Assimp::DefaultLogger::get()->verboseDebug((Assimp::Formatter::format(string), __VA_ARGS__)) + +#define ASSIMP_LOG_INFO_F(string, ...) \ + Assimp::DefaultLogger::get()->info((Assimp::Formatter::format(string), __VA_ARGS__)) + +#define ASSIMP_LOG_WARN(string) \ + Assimp::DefaultLogger::get()->warn(string) + +#define ASSIMP_LOG_ERROR(string) \ + Assimp::DefaultLogger::get()->error(string) + +#define ASSIMP_LOG_DEBUG(string) \ + Assimp::DefaultLogger::get()->debug(string) + +#define ASSIMP_LOG_VERBOSE_DEBUG(string) \ + Assimp::DefaultLogger::get()->verboseDebug(string) + +#define ASSIMP_LOG_INFO(string) \ + Assimp::DefaultLogger::get()->info(string) + #endif // !! INCLUDED_AI_LOGGER_H diff --git a/include/assimp/NullLogger.hpp b/include/assimp/NullLogger.hpp index 7effca83a..e7a01ed78 100644 --- a/include/assimp/NullLogger.hpp +++ b/include/assimp/NullLogger.hpp @@ -66,6 +66,11 @@ public: (void)message; //this avoids compiler warnings } + /** @brief Logs a verbose debug message */ + void OnVerboseDebug(const char *message) { + (void)message; //this avoids compiler warnings + } + /** @brief Logs an info message */ void OnInfo(const char* message) { (void)message; //this avoids compiler warnings @@ -88,7 +93,7 @@ public: } /** @brief Detach a still attached stream from logger */ - bool detatchStream(LogStream *pStream, unsigned int severity) { + bool detachStream(LogStream *pStream, unsigned int severity) { (void)pStream; (void)severity; //this avoids compiler warnings return false; } diff --git a/include/assimp/ProgressHandler.hpp b/include/assimp/ProgressHandler.hpp index 45d3f57cd..9b5becfa8 100644 --- a/include/assimp/ProgressHandler.hpp +++ b/include/assimp/ProgressHandler.hpp @@ -91,7 +91,7 @@ public: * occasion (loaders and Assimp are generally allowed to perform * all needed cleanup tasks prior to returning control to the * caller). If the loading is aborted, #Importer::ReadFile() - * returns always NULL. + * returns always nullptr. * */ virtual bool Update(float percentage = -1.f) = 0; diff --git a/include/assimp/SceneCombiner.h b/include/assimp/SceneCombiner.h index 40aad0890..ff347d4fa 100644 --- a/include/assimp/SceneCombiner.h +++ b/include/assimp/SceneCombiner.h @@ -48,17 +48,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_SCENE_COMBINER_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif +#include #include #include -#include #include -#include -#include #include +#include +#include #include struct aiScene; @@ -75,68 +75,58 @@ struct aiAnimation; struct aiNodeAnim; struct aiMeshMorphAnim; -namespace Assimp { +namespace Assimp { // --------------------------------------------------------------------------- /** \brief Helper data structure for SceneCombiner. * * Describes to which node a scene must be attached to. */ -struct AttachmentInfo -{ - AttachmentInfo() - : scene (NULL) - , attachToNode (NULL) - {} +struct AttachmentInfo { + AttachmentInfo() : + scene(nullptr), + attachToNode(nullptr) {} - AttachmentInfo(aiScene* _scene, aiNode* _attachToNode) - : scene (_scene) - , attachToNode (_attachToNode) - {} + AttachmentInfo(aiScene *_scene, aiNode *_attachToNode) : + scene(_scene), attachToNode(_attachToNode) {} - aiScene* scene; - aiNode* attachToNode; + aiScene *scene; + aiNode *attachToNode; }; // --------------------------------------------------------------------------- -struct NodeAttachmentInfo -{ - NodeAttachmentInfo() - : node (NULL) - , attachToNode (NULL) - , resolved (false) - , src_idx (SIZE_MAX) - {} +struct NodeAttachmentInfo { + NodeAttachmentInfo() : + node(nullptr), + attachToNode(nullptr), + resolved(false), + src_idx(SIZE_MAX) {} - NodeAttachmentInfo(aiNode* _scene, aiNode* _attachToNode,size_t idx) - : node (_scene) - , attachToNode (_attachToNode) - , resolved (false) - , src_idx (idx) - {} + NodeAttachmentInfo(aiNode *_scene, aiNode *_attachToNode, size_t idx) : + node(_scene), attachToNode(_attachToNode), resolved(false), src_idx(idx) {} - aiNode* node; - aiNode* attachToNode; - bool resolved; - size_t src_idx; + aiNode *node; + aiNode *attachToNode; + bool resolved; + size_t src_idx; }; // --------------------------------------------------------------------------- /** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES * Generate unique names for all named scene items */ -#define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES 0x1 +#define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES 0x1 /** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES * Generate unique names for materials, too. * This is not absolutely required to pass the validation. */ -#define AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES 0x2 +#define AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES 0x2 /** @def AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY * Use deep copies of duplicate scenes */ -#define AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY 0x4 +#define AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY 0x4 /** @def AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS * If attachment nodes are not found in the given master scene, @@ -151,44 +141,39 @@ struct NodeAttachmentInfo */ #define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY 0x10 -typedef std::pair BoneSrcIndex; +typedef std::pair BoneSrcIndex; // --------------------------------------------------------------------------- /** @brief Helper data structure for SceneCombiner::MergeBones. */ -struct BoneWithHash : public std::pair { +struct BoneWithHash : public std::pair { std::vector pSrcBones; }; // --------------------------------------------------------------------------- /** @brief Utility for SceneCombiner */ -struct SceneHelper -{ - SceneHelper () - : scene (NULL) - , idlen (0) - { +struct SceneHelper { + SceneHelper() : + scene(nullptr), + idlen(0) { id[0] = 0; } - explicit SceneHelper (aiScene* _scene) - : scene (_scene) - , idlen (0) - { + explicit SceneHelper(aiScene *_scene) : + scene(_scene), idlen(0) { id[0] = 0; } - AI_FORCE_INLINE aiScene* operator-> () const - { + AI_FORCE_INLINE aiScene *operator->() const { return scene; } // scene we're working on - aiScene* scene; + aiScene *scene; // prefix to be added to all identifiers in the scene ... - char id [32]; + char id[32]; // and its strlen() unsigned int idlen; @@ -220,21 +205,21 @@ public: /** Merges two or more scenes. * * @param dest Receives a pointer to the destination scene. If the - * pointer doesn't point to NULL when the function is called, the + * pointer doesn't point to nullptr when the function is called, the * existing scene is cleared and refilled. * @param src Non-empty list of scenes to be merged. The function * deletes the input scenes afterwards. There may be duplicate scenes. * @param flags Combination of the AI_INT_MERGE_SCENE flags defined above */ - static void MergeScenes(aiScene** dest,std::vector& src, - unsigned int flags = 0); + static void MergeScenes(aiScene **dest, std::vector &src, + unsigned int flags = 0); // ------------------------------------------------------------------- /** Merges two or more scenes and attaches all scenes to a specific * position in the node graph of the master scene. * * @param dest Receives a pointer to the destination scene. If the - * pointer doesn't point to NULL when the function is called, the + * pointer doesn't point to nullptr when the function is called, the * existing scene is cleared and refilled. * @param master Master scene. It will be deleted afterwards. All * other scenes will be inserted in its node graph. @@ -243,9 +228,9 @@ public: * deletes the input scenes afterwards. There may be duplicate scenes. * @param flags Combination of the AI_INT_MERGE_SCENE flags defined above */ - static void MergeScenes(aiScene** dest, aiScene* master, - std::vector& src, - unsigned int flags = 0); + static void MergeScenes(aiScene **dest, aiScene *master, + std::vector &src, + unsigned int flags = 0); // ------------------------------------------------------------------- /** Merges two or more meshes @@ -261,9 +246,9 @@ public: * @param begin First mesh to be processed * @param end Points to the mesh after the last mesh to be processed */ - static void MergeMeshes(aiMesh** dest,unsigned int flags, - std::vector::const_iterator begin, - std::vector::const_iterator end); + static void MergeMeshes(aiMesh **dest, unsigned int flags, + std::vector::const_iterator begin, + std::vector::const_iterator end); // ------------------------------------------------------------------- /** Merges two or more bones @@ -273,8 +258,8 @@ public: * @param begin First mesh to be processed * @param end Points to the mesh after the last mesh to be processed */ - static void MergeBones(aiMesh* out,std::vector::const_iterator it, - std::vector::const_iterator end); + static void MergeBones(aiMesh *out, std::vector::const_iterator it, + std::vector::const_iterator end); // ------------------------------------------------------------------- /** Merges two or more materials @@ -287,9 +272,9 @@ public: * @param begin First material to be processed * @param end Points to the material after the last material to be processed */ - static void MergeMaterials(aiMaterial** dest, - std::vector::const_iterator begin, - std::vector::const_iterator end); + static void MergeMaterials(aiMaterial **dest, + std::vector::const_iterator begin, + std::vector::const_iterator end); // ------------------------------------------------------------------- /** Builds a list of uniquely named bones in a mesh list @@ -298,9 +283,9 @@ public: * @param it First mesh to be processed * @param end Last mesh to be processed */ - static void BuildUniqueBoneList(std::list& asBones, - std::vector::const_iterator it, - std::vector::const_iterator end); + static void BuildUniqueBoneList(std::list &asBones, + std::vector::const_iterator it, + std::vector::const_iterator end); // ------------------------------------------------------------------- /** Add a name prefix to all nodes in a scene. @@ -309,8 +294,8 @@ public: * @param prefix Prefix to be added to all nodes * @param len STring length */ - static void AddNodePrefixes(aiNode* node, const char* prefix, - unsigned int len); + static void AddNodePrefixes(aiNode *node, const char *prefix, + unsigned int len); // ------------------------------------------------------------------- /** Add an offset to all mesh indices in a node graph @@ -318,7 +303,7 @@ public: * @param Current node. This function is called recursively. * @param offset Offset to be added to all mesh indices */ - static void OffsetNodeMeshIndices (aiNode* node, unsigned int offset); + static void OffsetNodeMeshIndices(aiNode *node, unsigned int offset); // ------------------------------------------------------------------- /** Attach a list of node graphs to well-defined nodes in a master @@ -326,18 +311,17 @@ public: * * @param master Master scene * @param srcList List of source scenes along with their attachment - * points. If an attachment point is NULL (or does not exist in + * points. If an attachment point is nullptr (or does not exist in * the master graph), a scene is attached to the root of the master * graph (as an additional child node) * @duplicates List of duplicates. If elem[n] == n the scene is not * a duplicate. Otherwise elem[n] links scene n to its first occurrence. */ - static void AttachToGraph ( aiScene* master, - std::vector& srcList); - - static void AttachToGraph (aiNode* attach, - std::vector& srcList); + static void AttachToGraph(aiScene *master, + std::vector &srcList); + static void AttachToGraph(aiNode *attach, + std::vector &srcList); // ------------------------------------------------------------------- /** Get a deep copy of a scene @@ -345,21 +329,19 @@ public: * @param dest Receives a pointer to the destination scene * @param src Source scene - remains unmodified. */ - static void CopyScene(aiScene** dest,const aiScene* source,bool allocate = true); - + static void CopyScene(aiScene **dest, const aiScene *source, bool allocate = true); // ------------------------------------------------------------------- /** Get a flat copy of a scene * * Only the first hierarchy layer is copied. All pointer members of * aiScene are shared by source and destination scene. If the - * pointer doesn't point to NULL when the function is called, the + * pointer doesn't point to nullptr when the function is called, the * existing scene is cleared and refilled. * @param dest Receives a pointer to the destination scene * @param src Source scene - remains unmodified. */ - static void CopySceneFlat(aiScene** dest,const aiScene* source); - + static void CopySceneFlat(aiScene **dest, const aiScene *source); // ------------------------------------------------------------------- /** Get a deep copy of a mesh @@ -367,44 +349,41 @@ public: * @param dest Receives a pointer to the destination mesh * @param src Source mesh - remains unmodified. */ - static void Copy (aiMesh** dest, const aiMesh* src); + static void Copy(aiMesh **dest, const aiMesh *src); // similar to Copy(): - static void Copy (aiAnimMesh** dest, const aiAnimMesh* src); - static void Copy (aiMaterial** dest, const aiMaterial* src); - static void Copy (aiTexture** dest, const aiTexture* src); - static void Copy (aiAnimation** dest, const aiAnimation* src); - static void Copy (aiCamera** dest, const aiCamera* src); - static void Copy (aiBone** dest, const aiBone* src); - static void Copy (aiLight** dest, const aiLight* src); - static void Copy (aiNodeAnim** dest, const aiNodeAnim* src); - static void Copy (aiMeshMorphAnim** dest, const aiMeshMorphAnim* src); - static void Copy (aiMetadata** dest, const aiMetadata* src); + static void Copy(aiAnimMesh **dest, const aiAnimMesh *src); + static void Copy(aiMaterial **dest, const aiMaterial *src); + static void Copy(aiTexture **dest, const aiTexture *src); + static void Copy(aiAnimation **dest, const aiAnimation *src); + static void Copy(aiCamera **dest, const aiCamera *src); + static void Copy(aiBone **dest, const aiBone *src); + static void Copy(aiLight **dest, const aiLight *src); + static void Copy(aiNodeAnim **dest, const aiNodeAnim *src); + static void Copy(aiMeshMorphAnim **dest, const aiMeshMorphAnim *src); + static void Copy(aiMetadata **dest, const aiMetadata *src); // recursive, of course - static void Copy (aiNode** dest, const aiNode* src); - + static void Copy(aiNode **dest, const aiNode *src); private: - // ------------------------------------------------------------------- // Same as AddNodePrefixes, but with an additional check - static void AddNodePrefixesChecked(aiNode* node, const char* prefix, - unsigned int len, - std::vector& input, - unsigned int cur); + static void AddNodePrefixesChecked(aiNode *node, const char *prefix, + unsigned int len, + std::vector &input, + unsigned int cur); // ------------------------------------------------------------------- // Add node identifiers to a hashing set - static void AddNodeHashes(aiNode* node, std::set& hashes); - + static void AddNodeHashes(aiNode *node, std::set &hashes); // ------------------------------------------------------------------- // Search for duplicate names - static bool FindNameMatch(const aiString& name, - std::vector& input, unsigned int cur); + static bool FindNameMatch(const aiString &name, + std::vector &input, unsigned int cur); }; -} +} // namespace Assimp #endif // !! AI_SCENE_COMBINER_H_INC diff --git a/include/assimp/SkeletonMeshBuilder.h b/include/assimp/SkeletonMeshBuilder.h index 8e1a9830f..f477850a9 100644 --- a/include/assimp/SkeletonMeshBuilder.h +++ b/include/assimp/SkeletonMeshBuilder.h @@ -52,17 +52,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_SKELETONMESHBUILDER_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif -#include #include +#include struct aiMaterial; struct aiScene; struct aiNode; -namespace Assimp { +namespace Assimp { // --------------------------------------------------------------------------- /** @@ -70,57 +70,56 @@ namespace Assimp { * the resembles the node hierarchy. This is useful for file formats * that don't carry any mesh data but only animation data. */ -class ASSIMP_API SkeletonMeshBuilder -{ +class ASSIMP_API SkeletonMeshBuilder { public: - // ------------------------------------------------------------------- /** The constructor processes the given scene and adds a mesh there. * * Does nothing if the scene already has mesh data. * @param pScene The scene for which a skeleton mesh should be constructed. - * @param root The node to start with. NULL is the scene root + * @param root The node to start with. nullptr is the scene root * @param bKnobsOnly Set this to true if you don't want the connectors * between the knobs representing the nodes. */ - SkeletonMeshBuilder( aiScene* pScene, aiNode* root = NULL, - bool bKnobsOnly = false); + SkeletonMeshBuilder(aiScene *pScene, aiNode *root = nullptr, + bool bKnobsOnly = false); protected: - // ------------------------------------------------------------------- /** Recursively builds a simple mesh representation for the given node * and also creates a joint for the node that affects this part of * the mesh. * @param pNode The node to build geometry for. */ - void CreateGeometry( const aiNode* pNode); + void CreateGeometry(const aiNode *pNode); // ------------------------------------------------------------------- /** Creates the mesh from the internally accumulated stuff and returns it. */ - aiMesh* CreateMesh(); + aiMesh *CreateMesh(); // ------------------------------------------------------------------- /** Creates a dummy material and returns it. */ - aiMaterial* CreateMaterial(); + aiMaterial *CreateMaterial(); protected: /** space to assemble the mesh data: points */ std::vector mVertices; /** faces */ - struct Face - { + struct Face { unsigned int mIndices[3]; Face(); - Face( unsigned int p0, unsigned int p1, unsigned int p2) - { mIndices[0] = p0; mIndices[1] = p1; mIndices[2] = p2; } + Face(unsigned int p0, unsigned int p1, unsigned int p2) { + mIndices[0] = p0; + mIndices[1] = p1; + mIndices[2] = p2; + } }; std::vector mFaces; /** bones */ - std::vector mBones; + std::vector mBones; bool mKnobsOnly; }; diff --git a/include/assimp/StandardShapes.h b/include/assimp/StandardShapes.h index 79bdae859..7734138a6 100644 --- a/include/assimp/StandardShapes.h +++ b/include/assimp/StandardShapes.h @@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #include +#include #include struct aiMesh; diff --git a/include/assimp/StringComparison.h b/include/assimp/StringComparison.h index d7b8972e3..255123c0e 100644 --- a/include/assimp/StringComparison.h +++ b/include/assimp/StringComparison.h @@ -54,18 +54,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_STRING_WORKERS_H #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif +#include #include #include -#include -#include #include +#include #include -namespace Assimp { +namespace Assimp { // ------------------------------------------------------------------------------- /** @brief itoa with a fixed base 10 @@ -79,12 +79,12 @@ namespace Assimp { * @return Length of the output string, excluding the '\0' */ AI_FORCE_INLINE -unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) { - ai_assert(NULL != out); +unsigned int ASSIMP_itoa10(char *out, unsigned int max, int32_t number) { + ai_assert(nullptr != out); // write the unary minus to indicate we have a negative number unsigned int written = 1u; - if (number < 0 && written < max) { + if (number < 0 && written < max) { *out++ = '-'; ++written; number = -number; @@ -93,17 +93,17 @@ unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) { // We begin with the largest number that is not zero. int32_t cur = 1000000000; // 2147483648 bool mustPrint = false; - while (written < max) { + while (written < max) { const unsigned int digit = number / cur; if (mustPrint || digit > 0 || 1 == cur) { // print all future zeroe's from now mustPrint = true; - *out++ = '0'+static_cast(digit); + *out++ = '0' + static_cast(digit); ++written; - number -= digit*cur; + number -= digit * cur; if (1 == cur) { break; } @@ -113,7 +113,7 @@ unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) { // append a terminal zero *out++ = '\0'; - return written-1; + return written - 1; } // ------------------------------------------------------------------------------- @@ -122,9 +122,8 @@ unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) { * size of the array automatically. */ template -AI_FORCE_INLINE -unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number) { - return ASSIMP_itoa10(out,length,number); +AI_FORCE_INLINE unsigned int ASSIMP_itoa10(char (&out)[length], int32_t number) { + return ASSIMP_itoa10(out, length, number); } // ------------------------------------------------------------------------------- @@ -140,23 +139,22 @@ unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number) { */ AI_FORCE_INLINE int ASSIMP_stricmp(const char *s1, const char *s2) { - ai_assert( NULL != s1 ); - ai_assert( NULL != s2 ); + ai_assert(nullptr != s1); + ai_assert(nullptr != s2); #if (defined _MSC_VER) - return ::_stricmp(s1,s2); -#elif defined( __GNUC__ ) + return ::_stricmp(s1, s2); +#elif defined(__GNUC__) - return ::strcasecmp(s1,s2); + return ::strcasecmp(s1, s2); #else char c1, c2; - do { + do { c1 = tolower(*s1++); c2 = tolower(*s2++); - } - while ( c1 && (c1 == c2) ); + } while (c1 && (c1 == c2)); return c1 - c2; #endif } @@ -169,9 +167,9 @@ int ASSIMP_stricmp(const char *s1, const char *s2) { * @return 0 if a == b */ AI_FORCE_INLINE -int ASSIMP_stricmp(const std::string& a, const std::string& b) { - int i = (int)b.length()-(int)a.length(); - return (i ? i : ASSIMP_stricmp(a.c_str(),b.c_str())); +int ASSIMP_stricmp(const std::string &a, const std::string &b) { + int i = (int)b.length() - (int)a.length(); + return (i ? i : ASSIMP_stricmp(a.c_str(), b.c_str())); } // ------------------------------------------------------------------------------- @@ -188,51 +186,48 @@ int ASSIMP_stricmp(const std::string& a, const std::string& b) { */ AI_FORCE_INLINE int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n) { - ai_assert( NULL != s1 ); - ai_assert( NULL != s2 ); - if ( !n ) { + ai_assert(nullptr != s1); + ai_assert(nullptr != s2); + if (!n) { return 0; } #if (defined _MSC_VER) - return ::_strnicmp(s1,s2,n); + return ::_strnicmp(s1, s2, n); -#elif defined( __GNUC__ ) +#elif defined(__GNUC__) - return ::strncasecmp(s1,s2, n); + return ::strncasecmp(s1, s2, n); #else char c1, c2; unsigned int p = 0; - do - { - if (p++ >= n)return 0; + do { + if (p++ >= n) return 0; c1 = tolower(*s1++); c2 = tolower(*s2++); - } - while ( c1 && (c1 == c2) ); + } while (c1 && (c1 == c2)); return c1 - c2; #endif } - // ------------------------------------------------------------------------------- /** @brief Evaluates an integer power * * todo: move somewhere where it fits better in than here */ AI_FORCE_INLINE -unsigned int integer_pow( unsigned int base, unsigned int power ) { +unsigned int integer_pow(unsigned int base, unsigned int power) { unsigned int res = 1; - for ( unsigned int i = 0; i < power; ++i ) { + for (unsigned int i = 0; i < power; ++i) { res *= base; } return res; } -} // end of namespace +} // namespace Assimp #endif // ! AI_STRINGCOMPARISON_H_INC diff --git a/include/assimp/ai_assert.h b/include/assimp/ai_assert.h index f018163bf..8b2b396f4 100644 --- a/include/assimp/ai_assert.h +++ b/include/assimp/ai_assert.h @@ -42,14 +42,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_ASSERT_H_INC #define AI_ASSERT_H_INC -#ifdef __GNUC__ -# pragma GCC system_header -#endif +#if defined(ASSIMP_BUILD_DEBUG) + +namespace Assimp +{ + // Assert violation behavior can be customized: see AssertHandler.h. + void aiAssertViolation(const char* failedExpression, const char* file, int line); +} + +# define ai_assert(expression) (void)((!!(expression)) || (Assimp::aiAssertViolation(#expression, __FILE__, __LINE__), 0)) +# define ai_assert_entry() ai_assert(false) -#ifdef ASSIMP_BUILD_DEBUG -# include -# define ai_assert(expression) assert( expression ) -# define ai_assert_entry() assert( false ) #else # define ai_assert(expression) # define ai_assert_entry() diff --git a/include/assimp/anim.h b/include/assimp/anim.h index b43991b80..ea26d0bc4 100644 --- a/include/assimp/anim.h +++ b/include/assimp/anim.h @@ -348,7 +348,7 @@ struct aiMeshAnim { /** Size of the #mKeys array. Must be 1, at least. */ unsigned int mNumKeys; - /** Key frames of the animation. May not be NULL. */ + /** Key frames of the animation. May not be nullptr. */ C_STRUCT aiMeshKey *mKeys; #ifdef __cplusplus @@ -376,7 +376,7 @@ struct aiMeshMorphAnim { /** Size of the #mKeys array. Must be 1, at least. */ unsigned int mNumKeys; - /** Key frames of the animation. May not be NULL. */ + /** Key frames of the animation. May not be nullptr. */ C_STRUCT aiMeshMorphKey *mKeys; #ifdef __cplusplus diff --git a/include/assimp/cimport.h b/include/assimp/cimport.h index a6ab93051..3e1b75a31 100644 --- a/include/assimp/cimport.h +++ b/include/assimp/cimport.h @@ -1044,7 +1044,7 @@ ASSIMP_API void aiMatrix4DecomposeIntoScalingAxisAnglePosition( const C_STRUCT aiMatrix4x4* mat, C_STRUCT aiVector3D* scaling, C_STRUCT aiVector3D* axis, - float* angle, + ai_real* angle, C_STRUCT aiVector3D* position); // -------------------------------------------------------------------------------- diff --git a/include/assimp/config.h.in b/include/assimp/config.h.in index e2f2a3888..c26dcc77f 100644 --- a/include/assimp/config.h.in +++ b/include/assimp/config.h.in @@ -1030,10 +1030,10 @@ enum aiComponent #define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION" // --------------------------------------------------------------------------- -/** @brief Specifies whether the Collada loader should use Collada names as node names. +/** @brief Specifies whether the Collada loader should use Collada names. * - * If this property is set to true, the Collada names will be used as the - * node name. The default is to use the id tag (resp. sid tag, if no id tag is present) + * If this property is set to true, the Collada names will be used as the node and + * mesh names. The default is to use the id tag (resp. sid tag, if no id tag is present) * instead. * Property type: Bool. Default value: false. */ diff --git a/include/assimp/importerdesc.h b/include/assimp/importerdesc.h index e0f22a9d6..f731ed1c4 100644 --- a/include/assimp/importerdesc.h +++ b/include/assimp/importerdesc.h @@ -49,10 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_IMPORTER_DESC_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif - /** Mixed set of flags for #aiImporterDesc, indicating some features * common to many importers*/ enum aiImporterFlags { @@ -81,7 +80,6 @@ enum aiImporterFlags { aiImporterFlags_Experimental = 0x10 }; - /** Meta information about a particular importer. Importers need to fill * this structure, but they can freely decide how talkative they are. * A common use case for loader meta info is a user interface @@ -92,16 +90,16 @@ enum aiImporterFlags { * characteristics. */ struct aiImporterDesc { /** Full name of the importer (i.e. Blender3D importer)*/ - const char* mName; + const char *mName; /** Original author (left blank if unknown or whole assimp team) */ - const char* mAuthor; + const char *mAuthor; /** Current maintainer, left blank if the author maintains */ - const char* mMaintainer; + const char *mMaintainer; /** Implementation comments, i.e. unimplemented features*/ - const char* mComments; + const char *mComments; /** These flags indicate some characteristics common to many importers. */ @@ -134,15 +132,15 @@ struct aiImporterDesc { other methods to quickly reject files (i.e. magic words) so this does not mean that common or generic file extensions such as XML would be tediously slow. */ - const char* mFileExtensions; + const char *mFileExtensions; }; /** \brief Returns the Importer description for a given extension. -Will return a NULL-pointer if no assigned importer desc. was found for the given extension +Will return a nullptr if no assigned importer desc. was found for the given extension \param extension [in] The extension to look for \return A pointer showing to the ImporterDesc, \see aiImporterDesc. */ -ASSIMP_API const C_STRUCT aiImporterDesc* aiGetImporterDesc( const char *extension ); +ASSIMP_API const C_STRUCT aiImporterDesc *aiGetImporterDesc(const char *extension); #endif // AI_IMPORTER_DESC_H_INC diff --git a/include/assimp/irrXMLWrapper.h b/include/assimp/irrXMLWrapper.h index 65a7be298..52c174791 100644 --- a/include/assimp/irrXMLWrapper.h +++ b/include/assimp/irrXMLWrapper.h @@ -63,7 +63,7 @@ namespace Assimp { * @code * // open the file * std::unique_ptr file( pIOHandler->Open( pFile)); - * if( file.get() == NULL) { + * if( file.get() == nullptr ) { * throw DeadlyImportError( "Failed to open file " + pFile + "."); * } * diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index 684508a71..52121fbf1 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -69,7 +69,8 @@ typedef enum aiMetadataType { AI_DOUBLE = 4, AI_AISTRING = 5, AI_AIVECTOR3D = 6, - AI_META_MAX = 7, + AI_AIMETADATA = 7, + AI_META_MAX = 8, #ifndef SWIG FORCE_32BIT = INT_MAX @@ -100,6 +101,8 @@ struct aiMetadataEntry { #include +struct aiMetadata; + // ------------------------------------------------------------------------------- /** * Helper functions to get the aiType enum entry for a type @@ -127,6 +130,9 @@ inline aiMetadataType GetAiType(const aiString &) { inline aiMetadataType GetAiType(const aiVector3D &) { return AI_AIVECTOR3D; } +inline aiMetadataType GetAiType(const aiMetadata &) { + return AI_AIMETADATA; +} #endif // __cplusplus @@ -204,6 +210,11 @@ struct aiMetadata { rhs.Get(mKeys[i], v); mValues[i].mData = new aiVector3D(v); } break; + case AI_AIMETADATA: { + aiMetadata v; + rhs.Get(mKeys[i], v); + mValues[i].mData = new aiMetadata(v); + } break; #ifndef SWIG case FORCE_32BIT: #endif @@ -213,7 +224,15 @@ struct aiMetadata { } } - /** + aiMetadata &operator=(aiMetadata rhs) { + using std::swap; + swap(mNumProperties, rhs.mNumProperties); + swap(mKeys, rhs.mKeys); + swap(mValues, rhs.mValues); + return *this; + } + + /** * @brief The destructor. */ ~aiMetadata() { @@ -245,6 +264,9 @@ struct aiMetadata { case AI_AIVECTOR3D: delete static_cast(data); break; + case AI_AIMETADATA: + delete static_cast(data); + break; #ifndef SWIG case FORCE_32BIT: #endif @@ -323,8 +345,10 @@ struct aiMetadata { mValues[index].mType = GetAiType(value); // Copy the given value to the dynamic storage - if (nullptr != mValues[index].mData) { + if (nullptr != mValues[index].mData && AI_AIMETADATA != mValues[index].mType) { ::memcpy(mValues[index].mData, &value, sizeof(T)); + } else if (nullptr != mValues[index].mData && AI_AIMETADATA == mValues[index].mType) { + *static_cast(mValues[index].mData) = value; } else { mValues[index].mData = new T(value); } @@ -418,6 +442,89 @@ struct aiMetadata { return false; } + friend bool CompareKeys(const aiMetadata &lhs, const aiMetadata &rhs) { + if (lhs.mNumProperties != rhs.mNumProperties) { + return false; + } + + for (unsigned int i = 0; i < lhs.mNumProperties; ++i) { + if (lhs.mKeys[i] != rhs.mKeys[i]) { + return false; + } + } + return true; + } + + friend bool CompareValues(const aiMetadata &lhs, const aiMetadata &rhs) { + if (lhs.mNumProperties != rhs.mNumProperties) { + return false; + } + + for (unsigned int i = 0; i < lhs.mNumProperties; ++i) { + if (lhs.mValues[i].mType != rhs.mValues[i].mType) { + return false; + } + + switch (lhs.mValues[i].mType) { + case AI_BOOL: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_INT32: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_UINT64: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_FLOAT: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_DOUBLE: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_AISTRING: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_AIVECTOR3D: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_AIMETADATA: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; +#ifndef SWIG + case FORCE_32BIT: +#endif + default: + break; + } + } + + return true; + } + + friend bool operator==(const aiMetadata &lhs, const aiMetadata &rhs) { + return CompareKeys(lhs, rhs) && CompareValues(lhs, rhs); + } + + friend bool operator!=(const aiMetadata &lhs, const aiMetadata &rhs) { + return !(lhs == rhs); + } + #endif // __cplusplus }; diff --git a/include/assimp/scene.h b/include/assimp/scene.h index 93d04eee6..a189f5700 100644 --- a/include/assimp/scene.h +++ b/include/assimp/scene.h @@ -1,4 +1,4 @@ -/* +/* --------------------------------------------------------------------------- Open Asset Import Library (assimp) --------------------------------------------------------------------------- diff --git a/packaging/windows-innosetup/WEB b/packaging/windows-innosetup/WEB index 8840d232d..d14d6ed9a 100644 --- a/packaging/windows-innosetup/WEB +++ b/packaging/windows-innosetup/WEB @@ -1,8 +1,6 @@ - -Project home page: -http://assimp.sourceforge.net - -Sourceforge.net project page: -http://www.sourceforge.net/projects/assimp - - + +Project home page: +http://assimp.sourceforge.net + +Sourceforge.net project page: +http://www.sourceforge.net/projects/assimp diff --git a/packaging/windows-innosetup/readme_installer_vieweronly.txt b/packaging/windows-innosetup/readme_installer_vieweronly.txt index bfa4f8c9e..1e84c577d 100644 --- a/packaging/windows-innosetup/readme_installer_vieweronly.txt +++ b/packaging/windows-innosetup/readme_installer_vieweronly.txt @@ -29,4 +29,4 @@ Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending o Add it to PATH. That's not a bug, the installer does not alter the PATH. 4. Crashes immediately -You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry. \ No newline at end of file +You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry. diff --git a/packaging/windows-mkzip/bin_readme.txt b/packaging/windows-mkzip/bin_readme.txt index 10839a3d9..5cff1f30e 100644 --- a/packaging/windows-mkzip/bin_readme.txt +++ b/packaging/windows-mkzip/bin_readme.txt @@ -26,4 +26,4 @@ Install the latest DirectX runtime or grab the file from somewhere (that's evil (Re)install Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system) 3. Crashes immediately -You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry. \ No newline at end of file +You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry. diff --git a/port/PyAssimp/README.md b/port/PyAssimp/README.md index d64d72763..c9944f717 100644 --- a/port/PyAssimp/README.md +++ b/port/PyAssimp/README.md @@ -42,17 +42,14 @@ substituted by assertions ...): ```python -from pyassimp import * -scene = load('hello.3ds') +from pyassimp import load +with load('hello.3ds') as scene: -assert len(scene.meshes) -mesh = scene.meshes[0] + assert len(scene.meshes) + mesh = scene.meshes[0] -assert len(mesh.vertices) -print(mesh.vertices[0]) - -# don't forget this one, or you will leak! -release(scene) + assert len(mesh.vertices) + print(mesh.vertices[0]) ``` @@ -61,13 +58,11 @@ scene: ```python -from pyassimp import * -scene = load('hello.3ds') +from pyassimp import load +with load('hello.3ds') as scene: -for c in scene.rootnode.children: - print(str(c)) - -release(scene) + for c in scene.rootnode.children: + print(str(c)) ``` diff --git a/port/PyAssimp/README.rst b/port/PyAssimp/README.rst index f909e2cd0..03b7968f1 100644 --- a/port/PyAssimp/README.rst +++ b/port/PyAssimp/README.rst @@ -49,30 +49,27 @@ substituted by assertions ...): .. code:: python - from pyassimp import * - scene = load('hello.3ds') + from pyassimp import load + with load('hello.3ds') as scene: - assert len(scene.meshes) - mesh = scene.meshes[0] + assert len(scene.meshes) + mesh = scene.meshes[0] - assert len(mesh.vertices) - print(mesh.vertices[0]) + assert len(mesh.vertices) + print(mesh.vertices[0]) - # don't forget this one, or you will leak! - release(scene) Another example to list the 'top nodes' in a scene: .. code:: python - from pyassimp import * - scene = load('hello.3ds') + from pyassimp import load + with load('hello.3ds') as scene: - for c in scene.rootnode.children: - print(str(c)) + for c in scene.rootnode.children: + print(str(c)) - release(scene) INSTALL ------- diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 85cfe8233..37beac886 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -14,10 +14,13 @@ if sys.version_info >= (3,0): xrange = range -try: import numpy -except ImportError: numpy = None +try: + import numpy +except ImportError: + numpy = None import logging import ctypes +from contextlib import contextmanager logger = logging.getLogger("pyassimp") # attach default null handler to logger so it doesn't complain # even if you don't attach another handler to logger @@ -272,6 +275,13 @@ def recur_pythonize(node, scene): for c in node.children: recur_pythonize(c, scene) +def release(scene): + ''' + Release resources of a loaded scene. + ''' + _assimp_lib.release(ctypes.pointer(scene)) + +@contextmanager def load(filename, file_type = None, processing = postprocess.aiProcess_Triangulate): @@ -319,7 +329,10 @@ def load(filename, raise AssimpError('Could not import file!') scene = _init(model.contents) recur_pythonize(scene.rootnode, scene) - return scene + try: + yield scene + finally: + release(scene) def export(scene, filename, @@ -373,9 +386,6 @@ def export_blob(scene, raise AssimpError('Could not export scene to blob!') return exportBlobPtr -def release(scene): - _assimp_lib.release(ctypes.pointer(scene)) - def _finalize_texture(tex, target): setattr(target, "achformathint", tex.achFormatHint) if numpy: diff --git a/port/PyAssimp/pyassimp/errors.py b/port/PyAssimp/pyassimp/errors.py index 9d776860f..e017b5145 100644 --- a/port/PyAssimp/pyassimp/errors.py +++ b/port/PyAssimp/pyassimp/errors.py @@ -1,11 +1,11 @@ -#-*- coding: UTF-8 -*- - -""" -All possible errors. -""" - -class AssimpError(BaseException): - """ - If an internal error occurs. - """ - pass \ No newline at end of file +#-*- coding: UTF-8 -*- + +""" +All possible errors. +""" + +class AssimpError(BaseException): + """ + If an internal error occurs. + """ + pass diff --git a/port/assimp_rs/Cargo.lock b/port/assimp_rs/Cargo.lock new file mode 100644 index 000000000..4f571f362 --- /dev/null +++ b/port/assimp_rs/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "assimp_rs" +version = "0.1.0" + diff --git a/port/assimp_rs/Cargo.toml b/port/assimp_rs/Cargo.toml new file mode 100644 index 000000000..073a2b283 --- /dev/null +++ b/port/assimp_rs/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "assimp_rs" +version = "0.1.0" +authors = ["David Golembiowski "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/port/assimp_rs/src/camera/mod.rs b/port/assimp_rs/src/camera/mod.rs new file mode 100644 index 000000000..26ca1185b --- /dev/null +++ b/port/assimp_rs/src/camera/mod.rs @@ -0,0 +1 @@ +pub use self::structs::{Camera}; diff --git a/port/assimp_rs/src/core/mod.rs b/port/assimp_rs/src/core/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/errors/mod.rs b/port/assimp_rs/src/errors/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/formats/mod.rs b/port/assimp_rs/src/formats/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/lib.rs b/port/assimp_rs/src/lib.rs new file mode 100644 index 000000000..dbb648876 --- /dev/null +++ b/port/assimp_rs/src/lib.rs @@ -0,0 +1,17 @@ +pub mod camera; +pub mod core; +pub mod errors; +pub mod formats; +pub mod material; +pub mod postprocess; +pub mod shims; +pub mod socket; +pub mod structs; + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(true, true); + } +} diff --git a/port/assimp_rs/src/material/mod.rs b/port/assimp_rs/src/material/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/postprocess/mod.rs b/port/assimp_rs/src/postprocess/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/shims/mod.rs b/port/assimp_rs/src/shims/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/socket/mod.rs b/port/assimp_rs/src/socket/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/anim/anim.rs b/port/assimp_rs/src/structs/anim/anim.rs new file mode 100644 index 000000000..5374151eb --- /dev/null +++ b/port/assimp_rs/src/structs/anim/anim.rs @@ -0,0 +1,44 @@ +pub struct Animation<'mA, 'mMA, 'nA> { + /* The name of the animation. If the modeling package this data was + * exported from does support only a single animation channel, this + * name is usually empty (length is zero). + */ + m_name: Option, + // Duration of the animation in ticks + m_duration: f64, + // Ticks per second. Zero (0.000... ticks/second) if not + // specified in the imported file + m_ticks_per_second: Option, + /* Number of bone animation channels. + Each channel affects a single node. + */ + m_num_channels: u64, + /* Node animation channels. Each channel + affects a single node. + ?? -> The array is m_num_channels in size. + (maybe refine to a derivative type of usize?) + */ + m_channels: &'nA NodeAnim, + /* Number of mesh animation channels. Each + channel affects a single mesh and defines + vertex-based animation. + */ + m_num_mesh_channels: u64, + /* The mesh animation channels. Each channel + affects a single mesh. + The array is m_num_mesh_channels in size + (maybe refine to a derivative of usize?) + */ + m_mesh_channels: &'mA MeshAnim, + /* The number of mesh animation channels. Each channel + affects a single mesh and defines some morphing animation. + */ + m_num_morph_mesh_channels: u64, + /* The morph mesh animation channels. Each channel affects a single mesh. + The array is mNumMorphMeshChannels in size. + */ + m_morph_mesh_channels: &'mMA MeshMorphAnim +} +pub struct NodeAnim {} +pub struct MeshAnim {} +pub struct MeshMorphAnim {} diff --git a/port/assimp_rs/src/structs/anim/mod.rs b/port/assimp_rs/src/structs/anim/mod.rs new file mode 100644 index 000000000..a0d4b7daf --- /dev/null +++ b/port/assimp_rs/src/structs/anim/mod.rs @@ -0,0 +1,6 @@ +mod anim; +pub use self::anim::{ + Animation, + NodeAnim, + MeshAnim, + MeshMorphAnim}; diff --git a/port/assimp_rs/src/structs/blob/blob.rs b/port/assimp_rs/src/structs/blob/blob.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/blob/mod.rs b/port/assimp_rs/src/structs/blob/mod.rs new file mode 100644 index 000000000..ad7612c0a --- /dev/null +++ b/port/assimp_rs/src/structs/blob/mod.rs @@ -0,0 +1,2 @@ +mod blob; + diff --git a/port/assimp_rs/src/structs/bone/bone.rs b/port/assimp_rs/src/structs/bone/bone.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/bone/mod.rs b/port/assimp_rs/src/structs/bone/mod.rs new file mode 100644 index 000000000..758a15afc --- /dev/null +++ b/port/assimp_rs/src/structs/bone/mod.rs @@ -0,0 +1,2 @@ +mod bone; + diff --git a/port/assimp_rs/src/structs/camera/camera.rs b/port/assimp_rs/src/structs/camera/camera.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/camera/mod.rs b/port/assimp_rs/src/structs/camera/mod.rs new file mode 100644 index 000000000..d4d79d026 --- /dev/null +++ b/port/assimp_rs/src/structs/camera/mod.rs @@ -0,0 +1,2 @@ +mod camera; + diff --git a/port/assimp_rs/src/structs/color/color.rs b/port/assimp_rs/src/structs/color/color.rs new file mode 100644 index 000000000..0b5fc6413 --- /dev/null +++ b/port/assimp_rs/src/structs/color/color.rs @@ -0,0 +1,27 @@ +#[derive(Clone, Debug, Copy)] +struct Color3D { + r: f32, + g: f32, + b: f32 +} + +impl Color3D { + pub fn new(r_f32: f32, g_f32: f32, b_f32: f32) -> Color3D { + Color3D {r: r_f32, g: g_f32, b: b_f32 } + } +} + +#[derive(Clone, Debug, Copy)] +struct Color4D { + r: f32, + g: f32, + b: f32, + a: f32 +} + +impl Color4D { + pub fn new(r_f32: f32, g_f32: f32, b_f32: f32, a_f32: f32) -> Color4D { + Color4D {r: r_f32, g: g_f32, b: b_f32, a: a_f32 } + } +} + diff --git a/port/assimp_rs/src/structs/color/mod.rs b/port/assimp_rs/src/structs/color/mod.rs new file mode 100644 index 000000000..d88527ed1 --- /dev/null +++ b/port/assimp_rs/src/structs/color/mod.rs @@ -0,0 +1,5 @@ +mod color; +pub use self::color::{ + Color3D, + Color4D +}; diff --git a/port/assimp_rs/src/structs/face/face.rs b/port/assimp_rs/src/structs/face/face.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/face/mod.rs b/port/assimp_rs/src/structs/face/mod.rs new file mode 100644 index 000000000..ae5aa5bdb --- /dev/null +++ b/port/assimp_rs/src/structs/face/mod.rs @@ -0,0 +1,2 @@ +mod face; + diff --git a/port/assimp_rs/src/structs/key/key.rs b/port/assimp_rs/src/structs/key/key.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/key/mod.rs b/port/assimp_rs/src/structs/key/mod.rs new file mode 100644 index 000000000..b23779d35 --- /dev/null +++ b/port/assimp_rs/src/structs/key/mod.rs @@ -0,0 +1,2 @@ +mod key; + diff --git a/port/assimp_rs/src/structs/light/light.rs b/port/assimp_rs/src/structs/light/light.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/light/mod.rs b/port/assimp_rs/src/structs/light/mod.rs new file mode 100644 index 000000000..a68b51970 --- /dev/null +++ b/port/assimp_rs/src/structs/light/mod.rs @@ -0,0 +1,2 @@ +mod light; + diff --git a/port/assimp_rs/src/structs/material/material.rs b/port/assimp_rs/src/structs/material/material.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/material/mod.rs b/port/assimp_rs/src/structs/material/mod.rs new file mode 100644 index 000000000..54de8b399 --- /dev/null +++ b/port/assimp_rs/src/structs/material/mod.rs @@ -0,0 +1,2 @@ +mod material; + diff --git a/port/assimp_rs/src/structs/matrix/matrix.rs b/port/assimp_rs/src/structs/matrix/matrix.rs new file mode 100644 index 000000000..4673b2d69 --- /dev/null +++ b/port/assimp_rs/src/structs/matrix/matrix.rs @@ -0,0 +1,64 @@ +#[derive(Clone, Debug, Copy)] +struct Matrix3x3 { + a1: f32, + a2: f32, + a3: f32, + b1: f32, + b2: f32, + b3: f32, + c1: f32, + c2: f32, + c3: f32 +} + +#[derive(Clone, Debug, Copy)] +struct Matrix4x4 { + a1: f32, + a2: f32, + a3: f32, + a4: f32, + b1: f32, + b2: f32, + b3: f32, + b4: f32, + c1: f32, + c2: f32, + c3: f32, + c4: f32, + d1: f32, + d2: f32, + d3: f32, + d4: f32 +} + +impl Matrix3x3 { + pub fn new( + a1_f32: f32, a2_f32: f32, a3_f32: f32, + b1_f32: f32, b2_f32: f32, b3_f32: f32, + c1_f32: f32, c2_f32: f32, c3_f32: f32 + ) -> Matrix3x3 { + Matrix3x3 { + a1: a1_f32, a2: a2_f32, a3: a3_f32, + b1: b1_f32, b2: b2_f32, b3: b3_f32, + c1: c1_f32, c2: c2_f32, c3: c3_f32 + } + } +} + +impl Matrix4x4 { + pub fn new( + a1_f32: f32, a2_f32: f32, a3_f32: f32, a4_f32: f32, + b1_f32: f32, b2_f32: f32, b3_f32: f32, b4_f32: f32, + c1_f32: f32, c2_f32: f32, c3_f32: f32, c4_f32: f32, + d1_f32: f32, d2_f32: f32, d3_f32: f32, d4_f32: f32 + ) -> Matrix4x4 { + Matrix4x4 { + a1: a1_f32, a2: a2_f32, a3: a3_f32, a4: a4_f32, + b1: b1_f32, b2: b2_f32, b3: b3_f32, b4: b4_f32, + c1: c1_f32, c2: c2_f32, c3: c3_f32, c4: c4_f32, + d1: d1_f32, d2: d2_f32, d3: d3_f32, d4: d4_f32 + } + } +} + + diff --git a/port/assimp_rs/src/structs/matrix/mod.rs b/port/assimp_rs/src/structs/matrix/mod.rs new file mode 100644 index 000000000..b0fb1e1f9 --- /dev/null +++ b/port/assimp_rs/src/structs/matrix/mod.rs @@ -0,0 +1,4 @@ +mod matrix; +pub use self::matrix::{ + Matrix3x3, + Matrix4x4}; diff --git a/port/assimp_rs/src/structs/memory/memory.rs b/port/assimp_rs/src/structs/memory/memory.rs new file mode 100644 index 000000000..c076f172a --- /dev/null +++ b/port/assimp_rs/src/structs/memory/memory.rs @@ -0,0 +1,35 @@ +#[derive(Clone, Debug, Copy)] +struct MemoryInfo { + textures: u32, + materials: u32, + meshes: u32, + nodes: u32, + animations: u32, + cameras: u32, + lights: u32, + total: u32 +} + +impl MemoryInfo { + pub fn new( + textures_uint: u32, + materials_uint: u32, + meshes_uint: u32, + nodes_uint: u32, + animations_uint: u32, + cameras_uint: u32, + lights_uint: u32, + total_uint: u32) -> MemoryInfo { + + MemoryInfo { + textures: textures_uint, + materials: materials_uint, + meshes: meshes_uint, + nodes: nodes_uint, + animations: animations_uint, + cameras: cameras_uint, + lights: lights_uint, + total: total_uint + } + } +} diff --git a/port/assimp_rs/src/structs/memory/mod.rs b/port/assimp_rs/src/structs/memory/mod.rs new file mode 100644 index 000000000..8c8c31ce8 --- /dev/null +++ b/port/assimp_rs/src/structs/memory/mod.rs @@ -0,0 +1,2 @@ +mod memory; +pub use self::memory::MemoryInfo; diff --git a/port/assimp_rs/src/structs/mesh/mesh.rs b/port/assimp_rs/src/structs/mesh/mesh.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/mesh/mod.rs b/port/assimp_rs/src/structs/mesh/mod.rs new file mode 100644 index 000000000..1c3ef651d --- /dev/null +++ b/port/assimp_rs/src/structs/mesh/mod.rs @@ -0,0 +1,3 @@ +mod mesh; + + diff --git a/port/assimp_rs/src/structs/meta/meta.rs b/port/assimp_rs/src/structs/meta/meta.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/meta/mod.rs b/port/assimp_rs/src/structs/meta/mod.rs new file mode 100644 index 000000000..045294772 --- /dev/null +++ b/port/assimp_rs/src/structs/meta/mod.rs @@ -0,0 +1,2 @@ +mod meta; + diff --git a/port/assimp_rs/src/structs/mod.rs b/port/assimp_rs/src/structs/mod.rs new file mode 100644 index 000000000..fd9087648 --- /dev/null +++ b/port/assimp_rs/src/structs/mod.rs @@ -0,0 +1,61 @@ +mod anim; +/* Animation + * NodeAnim + * MeshAnim + * MeshMorphAnim + */ +mod blob; +/* ExportDataBlob + */ +mod vec; +/* Vector2d + * Vector3d + * */ +mod matrix; +/* Matrix3by3 + * Matrix4by4 + */ +mod camera; +/* Camera */ +mod color; +/* Color3d + * Color4d + */ +mod key; +/* MeshKey + * MeshMorphKey + * QuatKey + * VectorKey + */ +mod texel; +mod plane; +mod string; +/* String + */ +mod material; +/* Material + * MaterialPropery + * MaterialPropertyString + */ +mod mem; +mod quaternion; +mod face; +mod vertex_weight; +mod mesh; +/* Mesh + */ +mod meta; +/* Metadata + * MetadataEntry + */ +mod node; +/* Node + * */ +mod light; +mod texture; +mod ray; +mod transform; +/* UVTransform */ +mod bone; +mod scene; +/* Scene */ diff --git a/port/assimp_rs/src/structs/node/mod.rs b/port/assimp_rs/src/structs/node/mod.rs new file mode 100644 index 000000000..c1fc34cdb --- /dev/null +++ b/port/assimp_rs/src/structs/node/mod.rs @@ -0,0 +1,2 @@ +mod node; + diff --git a/port/assimp_rs/src/structs/node/node.rs b/port/assimp_rs/src/structs/node/node.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/plane/mod.rs b/port/assimp_rs/src/structs/plane/mod.rs new file mode 100644 index 000000000..c73a8ed45 --- /dev/null +++ b/port/assimp_rs/src/structs/plane/mod.rs @@ -0,0 +1,2 @@ +mod plane; + diff --git a/port/assimp_rs/src/structs/plane/plane.rs b/port/assimp_rs/src/structs/plane/plane.rs new file mode 100644 index 000000000..2b0b74499 --- /dev/null +++ b/port/assimp_rs/src/structs/plane/plane.rs @@ -0,0 +1,23 @@ +#[derive(Clone, Debug, Copy)] +struct Plane { + a: f32, + b: f32, + c: f32, + d: f32 +} + +impl Plane { + pub fn new( + a_f32: f32, + b_f32: f32, + c_f32: f32, + d_f32: f32 + ) -> Plane { + Plane { + a: a_f32, + b: b_f32, + c: b_f32, + d: d_f32 + } + } +} diff --git a/port/assimp_rs/src/structs/quaternion/mod.rs b/port/assimp_rs/src/structs/quaternion/mod.rs new file mode 100644 index 000000000..bb2c0616c --- /dev/null +++ b/port/assimp_rs/src/structs/quaternion/mod.rs @@ -0,0 +1,3 @@ +mod quaternion; + +pub use self::quaternion::Quaternion; diff --git a/port/assimp_rs/src/structs/quaternion/quaternion.rs b/port/assimp_rs/src/structs/quaternion/quaternion.rs new file mode 100644 index 000000000..970f5cce5 --- /dev/null +++ b/port/assimp_rs/src/structs/quaternion/quaternion.rs @@ -0,0 +1,7 @@ +use crate::vec; + +#[derive(Clone, Debug, Copy)] +pub struct Quaternion { + _coordinates: vec::Vector4d + +} diff --git a/port/assimp_rs/src/structs/ray/mod.rs b/port/assimp_rs/src/structs/ray/mod.rs new file mode 100644 index 000000000..7f0be074e --- /dev/null +++ b/port/assimp_rs/src/structs/ray/mod.rs @@ -0,0 +1,2 @@ +mod ray; + diff --git a/port/assimp_rs/src/structs/ray/ray.rs b/port/assimp_rs/src/structs/ray/ray.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/scene/mod.rs b/port/assimp_rs/src/structs/scene/mod.rs new file mode 100644 index 000000000..5aea638ee --- /dev/null +++ b/port/assimp_rs/src/structs/scene/mod.rs @@ -0,0 +1,2 @@ +mod scene; + diff --git a/port/assimp_rs/src/structs/scene/scene.rs b/port/assimp_rs/src/structs/scene/scene.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/string/mod.rs b/port/assimp_rs/src/structs/string/mod.rs new file mode 100644 index 000000000..f599ba7cb --- /dev/null +++ b/port/assimp_rs/src/structs/string/mod.rs @@ -0,0 +1,3 @@ +mod string; +pub use self::string::MAXLEN; +pub use self::string::Str; diff --git a/port/assimp_rs/src/structs/string/string.rs b/port/assimp_rs/src/structs/string/string.rs new file mode 100644 index 000000000..b88457df4 --- /dev/null +++ b/port/assimp_rs/src/structs/string/string.rs @@ -0,0 +1,41 @@ +pub const MAXLEN: usize = 1024; + +/// Want to consider replacing `Vec` +/// with a comparable definition at +/// https://doc.rust-lang.org/src/alloc/string.rs.html#415-417 +#[derive(Clone, Debug)] +struct Str { + length: usize, + data: Vec +} + +impl Str { + pub fn new(len_u32: usize, data_string: String) -> Str { + Str { + length: len_u32, + data: data_string.chars().collect() + } + } +} + +/// MaterialPropertyStr +/// The size of length is truncated to 4 bytes on a 64-bit platform when used as a +/// material property (see MaterialSystem.cpp, as aiMaterial::AddProperty() ). +#[derive(Clone, Debug)] +struct MaterialPropertyStr { + length: usize, + data: Vec +} + + +impl MaterialPropertyStr { + pub fn new(len_u32: usize, data_string: String) -> MaterialPropertyStr { + MaterialPropertyStr { + length: len_u32, + data: data_string.chars().collect() + } + } +} + + + diff --git a/port/assimp_rs/src/structs/texture/mod.rs b/port/assimp_rs/src/structs/texture/mod.rs new file mode 100644 index 000000000..1b5c9308d --- /dev/null +++ b/port/assimp_rs/src/structs/texture/mod.rs @@ -0,0 +1,3 @@ +mod texture; +pub use self::texture::Texel; + diff --git a/port/assimp_rs/src/structs/texture/texture.rs b/port/assimp_rs/src/structs/texture/texture.rs new file mode 100644 index 000000000..b2c72f30e --- /dev/null +++ b/port/assimp_rs/src/structs/texture/texture.rs @@ -0,0 +1,19 @@ +#[derive(Clone, Debug, Copy)] +struct Texel { + b: u32, + g: u32, + r: u32, + a: u32 +} + +impl Texel { + pub fn new(b_u32: u32, g_u32: u32, + r_u32: u32, a_u32: u32) -> Texel { + Texel { + b: b_u32, + g: g_u32, + r: r_u32, + a: a_u32 + } + } +} diff --git a/port/assimp_rs/src/structs/transform/mod.rs b/port/assimp_rs/src/structs/transform/mod.rs new file mode 100644 index 000000000..b80c43dd0 --- /dev/null +++ b/port/assimp_rs/src/structs/transform/mod.rs @@ -0,0 +1,2 @@ +mod transform; + diff --git a/port/assimp_rs/src/structs/transform/transform.rs b/port/assimp_rs/src/structs/transform/transform.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/assimp_rs/src/structs/vec/mod.rs b/port/assimp_rs/src/structs/vec/mod.rs new file mode 100644 index 000000000..3613d5d48 --- /dev/null +++ b/port/assimp_rs/src/structs/vec/mod.rs @@ -0,0 +1,2 @@ +mod vec; + diff --git a/port/assimp_rs/src/structs/vec/vec.rs b/port/assimp_rs/src/structs/vec/vec.rs new file mode 100644 index 000000000..ee0d194de --- /dev/null +++ b/port/assimp_rs/src/structs/vec/vec.rs @@ -0,0 +1,48 @@ +struct Vector2d { + x: f32, + y: f32 +} + +struct Vector3d { + x: f32, + y: f32, + z: f32 +} + +struct Vector4d { + x: f32, + y: f32, + z: f32, + w: f32 +} + +impl Vector2d { + pub fn new(x_f32: f32, y_f32: f32) -> Vector2d { + Vector2d { + x: x_f32, + y: y_f32 + } + } +} + +impl Vector3d { + pub fn new(x_f32: f32, y_f32: f32, z_f32: f32) -> Vector3d { + Vector3d { + x: x_f32, + y: y_f32, + z: z_f32 + } + } +} + +impl Vector4d { + pub fn new(x_f32: f32, y_f32: f32, z_f32: f32, w_f32: f32) -> Vector4d { + Vector4d { + x: x_f32, + y: y_f32, + z: z_f32, + w: w_f32 + } + } +} + diff --git a/port/assimp_rs/src/structs/vertex/mod.rs b/port/assimp_rs/src/structs/vertex/mod.rs new file mode 100644 index 000000000..97ae3eced --- /dev/null +++ b/port/assimp_rs/src/structs/vertex/mod.rs @@ -0,0 +1,2 @@ +mod vertex; +// pub use self::vertex:: diff --git a/port/assimp_rs/src/structs/vertex/vertex.rs b/port/assimp_rs/src/structs/vertex/vertex.rs new file mode 100644 index 000000000..e69de29bb diff --git a/port/jassimp/jassimp/src/jassimp/AiAnimation.java b/port/jassimp/jassimp/src/jassimp/AiAnimation.java index 239820aaf..856b918dd 100644 --- a/port/jassimp/jassimp/src/jassimp/AiAnimation.java +++ b/port/jassimp/jassimp/src/jassimp/AiAnimation.java @@ -172,4 +172,4 @@ public final class AiAnimation { public List getMeshChannels() { throw new UnsupportedOperationException("not implemented yet"); } -} \ No newline at end of file +} diff --git a/port/jassimp/jassimp/src/jassimp/AiBlendMode.java b/port/jassimp/jassimp/src/jassimp/AiBlendMode.java index 78cc5a5ed..d3a0e0e96 100644 --- a/port/jassimp/jassimp/src/jassimp/AiBlendMode.java +++ b/port/jassimp/jassimp/src/jassimp/AiBlendMode.java @@ -114,4 +114,4 @@ public enum AiBlendMode { * The mapped c/c++ integer enum value. */ private final int m_rawValue; -} \ No newline at end of file +} diff --git a/port/jassimp/jassimp/src/jassimp/AiCamera.java b/port/jassimp/jassimp/src/jassimp/AiCamera.java index 4445c34fc..b0f692eda 100644 --- a/port/jassimp/jassimp/src/jassimp/AiCamera.java +++ b/port/jassimp/jassimp/src/jassimp/AiCamera.java @@ -300,4 +300,4 @@ public final class AiCamera { * Aspect ratio. */ private final float m_aspect; -} \ No newline at end of file +} diff --git a/port/jassimp/jassimp/src/jassimp/AiProgressHandler.java b/port/jassimp/jassimp/src/jassimp/AiProgressHandler.java index 7998d1bcc..2987e5976 100644 --- a/port/jassimp/jassimp/src/jassimp/AiProgressHandler.java +++ b/port/jassimp/jassimp/src/jassimp/AiProgressHandler.java @@ -43,4 +43,4 @@ package jassimp; public interface AiProgressHandler { boolean update(float percentage); -} \ No newline at end of file +} diff --git a/port/jassimp/jassimp/src/jassimp/AiQuaternion.java b/port/jassimp/jassimp/src/jassimp/AiQuaternion.java index af10e6f91..a9ca7be79 100644 --- a/port/jassimp/jassimp/src/jassimp/AiQuaternion.java +++ b/port/jassimp/jassimp/src/jassimp/AiQuaternion.java @@ -162,4 +162,4 @@ public final class AiQuaternion { return "[" + getX() + ", " + getY() + ", " + getZ() + ", " + getW() + "]"; } -} \ No newline at end of file +} diff --git a/port/jassimp/jassimp/src/jassimp/AiTextureType.java b/port/jassimp/jassimp/src/jassimp/AiTextureType.java index 85b559c30..6b3e642e0 100644 --- a/port/jassimp/jassimp/src/jassimp/AiTextureType.java +++ b/port/jassimp/jassimp/src/jassimp/AiTextureType.java @@ -209,4 +209,4 @@ public enum AiTextureType { * The mapped c/c++ integer enum value. */ private final int m_rawValue; -} \ No newline at end of file +} diff --git a/port/swig/DONOTUSEYET b/port/swig/DONOTUSEYET index be9103007..87c6e0699 100644 --- a/port/swig/DONOTUSEYET +++ b/port/swig/DONOTUSEYET @@ -1 +1 @@ -The interface files are by no means complete yet and only work with the not-yet-released D SWIG backend, although adding support for other languages should not be too much of problem via #ifdefs. +The interface files are by no means complete yet and only work with the not-yet-released D SWIG backend, although adding support for other languages should not be too much of problem via #ifdefs. diff --git a/samples/SimpleAssimpViewX/README b/samples/SimpleAssimpViewX/README index 701a7cdce..dc513d7aa 100644 --- a/samples/SimpleAssimpViewX/README +++ b/samples/SimpleAssimpViewX/README @@ -19,4 +19,4 @@ Troubleshooting: - OSX workspaces are not updated too frequently, so same files may be missing. If you have any problems which you can't solve on your own, -please report them on the thread above. \ No newline at end of file +please report them on the thread above. diff --git a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp index 90338105e..5cce7c376 100644 --- a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp +++ b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp @@ -1,4 +1,4 @@ -// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- // Simple Assimp Directx11 Sample // This is a very basic sample and only reads diffuse texture // but this can load both embedded textures in fbx and non-embedded textures diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bf6694845..8e1746ce2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -87,6 +87,7 @@ SET( COMMON unit/Common/uiScene.cpp unit/Common/utLineSplitter.cpp unit/Common/utSpatialSort.cpp + unit/Common/utAssertHandler.cpp ) SET( IMPORTERS @@ -124,8 +125,7 @@ SET( IMPORTERS unit/utBlendImportMaterials.cpp unit/utBlenderWork.cpp unit/utBVHImportExport.cpp - unit/utColladaExportCamera.cpp - unit/utColladaExportLight.cpp + unit/utColladaExport.cpp unit/utColladaImportExport.cpp unit/utCSMImportExport.cpp unit/utB3DImportExport.cpp diff --git a/test/models-nonbsd/3DS/jeep1.3ds.readme.txt b/test/models-nonbsd/3DS/jeep1.3ds.readme.txt index d17d5e0e9..f52ada0cc 100644 --- a/test/models-nonbsd/3DS/jeep1.3ds.readme.txt +++ b/test/models-nonbsd/3DS/jeep1.3ds.readme.txt @@ -12,4 +12,4 @@ http://xu1productions.com/3dstudio/index.html - 3D Game Resources http://www.psionicdesign.com - My Main 2D/3D Digital Art site -Psionic 2002 \ No newline at end of file +Psionic 2002 diff --git a/test/models-nonbsd/3DS/pyramob.3ds.readme.txt b/test/models-nonbsd/3DS/pyramob.3ds.readme.txt index bf1858410..2bf93aa64 100644 --- a/test/models-nonbsd/3DS/pyramob.3ds.readme.txt +++ b/test/models-nonbsd/3DS/pyramob.3ds.readme.txt @@ -9,4 +9,4 @@ http://www.elektrobar.com/lux/ or mail to: lux@elektrobar.com -have fun.....VIRLUX \ No newline at end of file +have fun.....VIRLUX diff --git a/test/models-nonbsd/ASE/Rifle.source.txt b/test/models-nonbsd/ASE/Rifle.source.txt index 04d40a85d..1b96f8564 100644 --- a/test/models-nonbsd/ASE/Rifle.source.txt +++ b/test/models-nonbsd/ASE/Rifle.source.txt @@ -22,4 +22,4 @@ tutorials. INFO ==== -CONVERTED FROM 3DS TO ASE WITH AC3D \ No newline at end of file +CONVERTED FROM 3DS TO ASE WITH AC3D diff --git a/test/models-nonbsd/ASE/Rifle2.source.txt b/test/models-nonbsd/ASE/Rifle2.source.txt index 2072ddf13..3fa628db4 100644 --- a/test/models-nonbsd/ASE/Rifle2.source.txt +++ b/test/models-nonbsd/ASE/Rifle2.source.txt @@ -21,4 +21,4 @@ tutorials. INFO ==== -CONVERTED FROM 3DS TO ASE WITH AC3D \ No newline at end of file +CONVERTED FROM 3DS TO ASE WITH AC3D diff --git a/test/models-nonbsd/B3D/turtle.source.txt b/test/models-nonbsd/B3D/turtle.source.txt index fab387bdc..cd93aa3d6 100644 --- a/test/models-nonbsd/B3D/turtle.source.txt +++ b/test/models-nonbsd/B3D/turtle.source.txt @@ -8,4 +8,4 @@ RESTRICTIONS: This model pack is available for use in freeware, shareware, commercial games/software with the following restrictions:- **You may not sell/re-sell this model pack or claim it as your own. -***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent. \ No newline at end of file +***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent. diff --git a/test/models-nonbsd/DXF/rifle.source.txt b/test/models-nonbsd/DXF/rifle.source.txt index 3e88f009f..a2585afad 100644 --- a/test/models-nonbsd/DXF/rifle.source.txt +++ b/test/models-nonbsd/DXF/rifle.source.txt @@ -20,4 +20,4 @@ tutorials. INFO ==== -COnverted from 3ds to DXF with Ac3D \ No newline at end of file +COnverted from 3ds to DXF with Ac3D diff --git a/test/models-nonbsd/FBX/2013_ASCII/jeep1.fbx.readme.txt b/test/models-nonbsd/FBX/2013_ASCII/jeep1.fbx.readme.txt index d17d5e0e9..f52ada0cc 100644 --- a/test/models-nonbsd/FBX/2013_ASCII/jeep1.fbx.readme.txt +++ b/test/models-nonbsd/FBX/2013_ASCII/jeep1.fbx.readme.txt @@ -12,4 +12,4 @@ http://xu1productions.com/3dstudio/index.html - 3D Game Resources http://www.psionicdesign.com - My Main 2D/3D Digital Art site -Psionic 2002 \ No newline at end of file +Psionic 2002 diff --git a/test/models-nonbsd/FBX/2013_ASCII/pyramob.fbx.readme.txt b/test/models-nonbsd/FBX/2013_ASCII/pyramob.fbx.readme.txt index bf1858410..2bf93aa64 100644 --- a/test/models-nonbsd/FBX/2013_ASCII/pyramob.fbx.readme.txt +++ b/test/models-nonbsd/FBX/2013_ASCII/pyramob.fbx.readme.txt @@ -9,4 +9,4 @@ http://www.elektrobar.com/lux/ or mail to: lux@elektrobar.com -have fun.....VIRLUX \ No newline at end of file +have fun.....VIRLUX diff --git a/test/models-nonbsd/FBX/2013_BINARY/jeep1.fbx.readme.txt b/test/models-nonbsd/FBX/2013_BINARY/jeep1.fbx.readme.txt index d17d5e0e9..f52ada0cc 100644 --- a/test/models-nonbsd/FBX/2013_BINARY/jeep1.fbx.readme.txt +++ b/test/models-nonbsd/FBX/2013_BINARY/jeep1.fbx.readme.txt @@ -12,4 +12,4 @@ http://xu1productions.com/3dstudio/index.html - 3D Game Resources http://www.psionicdesign.com - My Main 2D/3D Digital Art site -Psionic 2002 \ No newline at end of file +Psionic 2002 diff --git a/test/models-nonbsd/FBX/2013_BINARY/pyramob.fbx.readme.txt b/test/models-nonbsd/FBX/2013_BINARY/pyramob.fbx.readme.txt index bf1858410..2bf93aa64 100644 --- a/test/models-nonbsd/FBX/2013_BINARY/pyramob.fbx.readme.txt +++ b/test/models-nonbsd/FBX/2013_BINARY/pyramob.fbx.readme.txt @@ -9,4 +9,4 @@ http://www.elektrobar.com/lux/ or mail to: lux@elektrobar.com -have fun.....VIRLUX \ No newline at end of file +have fun.....VIRLUX diff --git a/test/models-nonbsd/IFC/linklist.txt b/test/models-nonbsd/IFC/linklist.txt index 06ad3844b..6971b7a45 100644 --- a/test/models-nonbsd/IFC/linklist.txt +++ b/test/models-nonbsd/IFC/linklist.txt @@ -1,4 +1,4 @@ Good IFC test cases =================== -http://www.iai.fzk.de/www-extern/index.php?id=1135 \ No newline at end of file +http://www.iai.fzk.de/www-extern/index.php?id=1135 diff --git a/test/models-nonbsd/LWO/LWO2/LWSReferences/QuickDraw.source.txt b/test/models-nonbsd/LWO/LWO2/LWSReferences/QuickDraw.source.txt index bb07f8e24..aaa244217 100644 --- a/test/models-nonbsd/LWO/LWO2/LWSReferences/QuickDraw.source.txt +++ b/test/models-nonbsd/LWO/LWO2/LWSReferences/QuickDraw.source.txt @@ -28,4 +28,4 @@ INFO These files belong to the QuickDraw model in the LWS folder - they are referenced -and loaded into the LWS scene. \ No newline at end of file +and loaded into the LWS scene. diff --git a/test/models-nonbsd/LWO/LWO2/rifle.source.txt b/test/models-nonbsd/LWO/LWO2/rifle.source.txt index 34576f0ca..5523bbc0c 100644 --- a/test/models-nonbsd/LWO/LWO2/rifle.source.txt +++ b/test/models-nonbsd/LWO/LWO2/rifle.source.txt @@ -21,4 +21,4 @@ tutorials. INFO ==== -CONVERTED FROM 3DS TO LWO2 WITH AC3D \ No newline at end of file +CONVERTED FROM 3DS TO LWO2 WITH AC3D diff --git a/test/models-nonbsd/LWS/QuickDraw v2.2.source.txt b/test/models-nonbsd/LWS/QuickDraw v2.2.source.txt index e0c7d0f7c..92ac5d882 100644 --- a/test/models-nonbsd/LWS/QuickDraw v2.2.source.txt +++ b/test/models-nonbsd/LWS/QuickDraw v2.2.source.txt @@ -12,4 +12,4 @@ In the future more 3d formats will be added and some other sections such as wall CHANGES: -Paths have been modified \ No newline at end of file +Paths have been modified diff --git a/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/readme_kubalwagon.txt b/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/readme_kubalwagon.txt index e0a978ee0..54fbcbd7f 100644 --- a/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/readme_kubalwagon.txt +++ b/test/models-nonbsd/MD3/q3root/models/mapobjects/kt_kubalwagon/readme_kubalwagon.txt @@ -23,4 +23,4 @@ ID software, eskimo roll, EMSIPE, QkenneyQ DISTRIBUTION as long as this readme is included...! --------------------------------------------------------------------------- \ No newline at end of file +-------------------------------------------------------------------------- diff --git a/test/models-nonbsd/MD3/readme_water.txt b/test/models-nonbsd/MD3/readme_water.txt index cdc318ff8..c5346261d 100644 --- a/test/models-nonbsd/MD3/readme_water.txt +++ b/test/models-nonbsd/MD3/readme_water.txt @@ -23,4 +23,4 @@ ID software, eskimo roll, EMSIPE, QkenneyQ DISTRIBUTION as long as this readme is included...! --------------------------------------------------------------------------- \ No newline at end of file +-------------------------------------------------------------------------- diff --git a/test/models-nonbsd/MMD/readme.txt b/test/models-nonbsd/MMD/readme.txt index d8c882420..909beee00 100644 --- a/test/models-nonbsd/MMD/readme.txt +++ b/test/models-nonbsd/MMD/readme.txt @@ -46,4 +46,4 @@ version 4 ◯ クレジット 企画: 株式会社ドワンゴ キャラクターデザイン: 黒星紅白 -モデリング: 雨刻 \ No newline at end of file +モデリング: 雨刻 diff --git a/test/models-nonbsd/NFF/NFFSense8/credits.txt b/test/models-nonbsd/NFF/NFFSense8/credits.txt index ff169151d..f3cef4d09 100644 --- a/test/models-nonbsd/NFF/NFFSense8/credits.txt +++ b/test/models-nonbsd/NFF/NFFSense8/credits.txt @@ -1,4 +1,4 @@ teapot.nff, home4.nff - http://www.martinreddy.net/ukvrsig/wtk.html cokecan.nff -www.vrupl.evl.uic.edu/Eng591_Pages/cokecan.nff -TODO: License status to be confirmed \ No newline at end of file +TODO: License status to be confirmed diff --git a/test/models-nonbsd/OBJ/rifle.source.txt b/test/models-nonbsd/OBJ/rifle.source.txt index b09dcda8c..1d2cec5cf 100644 --- a/test/models-nonbsd/OBJ/rifle.source.txt +++ b/test/models-nonbsd/OBJ/rifle.source.txt @@ -24,4 +24,4 @@ tutorials. INFO ==== -Converted from 3DS to OBJ with AC3D \ No newline at end of file +Converted from 3DS to OBJ with AC3D diff --git a/test/models-nonbsd/OBJ/segment.source.txt b/test/models-nonbsd/OBJ/segment.source.txt index 978d72d26..204bc140e 100644 --- a/test/models-nonbsd/OBJ/segment.source.txt +++ b/test/models-nonbsd/OBJ/segment.source.txt @@ -1,4 +1,4 @@ Obj exported from Blender http://toychest.in.tum.de/wiki/projects:kuka_lwr -License: Creative-Commons-by-Attribution-3.0 \ No newline at end of file +License: Creative-Commons-by-Attribution-3.0 diff --git a/test/models-nonbsd/Ogre/OgreSDK/LICENSE b/test/models-nonbsd/Ogre/OgreSDK/LICENSE index e7e8f4280..ccdfb00fa 100644 --- a/test/models-nonbsd/Ogre/OgreSDK/LICENSE +++ b/test/models-nonbsd/Ogre/OgreSDK/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/test/models-nonbsd/Ogre/OgreSDK/README.md b/test/models-nonbsd/Ogre/OgreSDK/README.md index e7a838cb0..864536558 100644 --- a/test/models-nonbsd/Ogre/OgreSDK/README.md +++ b/test/models-nonbsd/Ogre/OgreSDK/README.md @@ -7,4 +7,4 @@ This asset set is used to test the full functionality of both binary and XML Ass * Material file was created by copying the relevant material parts from the sample sources. See the file for further information. * Some textures were converted from .png to .jpg to reduce the file size. -See the LICENSE file in this folder for further copyright information about these assets. \ No newline at end of file +See the LICENSE file in this folder for further copyright information about these assets. diff --git a/test/models-nonbsd/README.txt b/test/models-nonbsd/README.txt index 8b244d2aa..aac170708 100644 --- a/test/models-nonbsd/README.txt +++ b/test/models-nonbsd/README.txt @@ -1,3 +1,3 @@ These models are not generally redistributable under the terms of Assimp's BSD license. Usually, an additional requirement on the use of the data is imposed (i.e. no commercial use, need credits, some creative commons variants, ...). -So, if you re-package Assimp for use in a 'clean' OSS package, consider removing this directory. \ No newline at end of file +So, if you re-package Assimp for use in a 'clean' OSS package, consider removing this directory. diff --git a/test/models/3DS/UVTransformTest/note.txt b/test/models/3DS/UVTransformTest/note.txt index dc4bd0789..4c8bfedd2 100644 --- a/test/models/3DS/UVTransformTest/note.txt +++ b/test/models/3DS/UVTransformTest/note.txt @@ -8,4 +8,4 @@ In other words: TO DO, but only if someone REALLY needs it. To see how it should look like - test/ReferenceImages Note that the viewer has no 'decal' texture mapping mode, so -the usual clamping is used. \ No newline at end of file +the usual clamping is used. diff --git a/test/models/3DS/textures.txt b/test/models/3DS/textures.txt index 18bbd8f90..136322bea 100644 --- a/test/models/3DS/textures.txt +++ b/test/models/3DS/textures.txt @@ -1 +1 @@ -All textures are from cgtextures.com and are free for commercial use \ No newline at end of file +All textures are from cgtextures.com and are free for commercial use diff --git a/test/models/ASE/MotionCaptureROM.source.txt b/test/models/ASE/MotionCaptureROM.source.txt index 222a3afbb..2b961906a 100644 --- a/test/models/ASE/MotionCaptureROM.source.txt +++ b/test/models/ASE/MotionCaptureROM.source.txt @@ -1,3 +1,3 @@ "MotionCaptureROM.ase" - Free for any purpose. -NOTE: The errors in the middle of the animation are caused by problems during recording, it's not an importer issue. \ No newline at end of file +NOTE: The errors in the middle of the animation are caused by problems during recording, it's not an importer issue. diff --git a/test/models/BLEND/HUMAN.source.txt b/test/models/BLEND/HUMAN.source.txt index 9409b46d3..a19c52468 100644 --- a/test/models/BLEND/HUMAN.source.txt +++ b/test/models/BLEND/HUMAN.source.txt @@ -1,3 +1,3 @@ HUMAN.blend (c) 2010, Tobias Rittig -Redistribution and reuse allowed for any purpose, credits appreciated. \ No newline at end of file +Redistribution and reuse allowed for any purpose, credits appreciated. diff --git a/test/models/BVH/01_nn.bvh.source.txt b/test/models/BVH/01_nn.bvh.source.txt index e538020a2..fc450d15d 100644 --- a/test/models/BVH/01_nn.bvh.source.txt +++ b/test/models/BVH/01_nn.bvh.source.txt @@ -47,4 +47,4 @@ Here's the relevant paragraph from mocap.cs.cmu.edu: obtained from mocap.cs.cmu.edu. The database was created with funding from NSF EIA-0196217." -[...] \ No newline at end of file +[...] diff --git a/test/models/CSM/ThomasFechten.source.txt b/test/models/CSM/ThomasFechten.source.txt index 529560ced..cf60674d8 100644 --- a/test/models/CSM/ThomasFechten.source.txt +++ b/test/models/CSM/ThomasFechten.source.txt @@ -1 +1 @@ -Recorded with vicon IQ, july 2008. Free for any purpose. \ No newline at end of file +Recorded with vicon IQ, july 2008. Free for any purpose. diff --git a/test/models/IRRMesh/credits.txt b/test/models/IRRMesh/credits.txt index a12163233..504746814 100644 --- a/test/models/IRRMesh/credits.txt +++ b/test/models/IRRMesh/credits.txt @@ -1,2 +1,2 @@ cellar.irrmesh - From irrlight/irrEdit. Irrlicht/irredit license (which?) -Textures resized to 400*400, improved JPEG compression to make them smaller \ No newline at end of file +Textures resized to 400*400, improved JPEG compression to make them smaller diff --git a/test/models/LWO/LWO2/MappingModes/earthCylindric.txt b/test/models/LWO/LWO2/MappingModes/earthCylindric.txt index 46660a486..18ea94ea2 100644 --- a/test/models/LWO/LWO2/MappingModes/earthCylindric.txt +++ b/test/models/LWO/LWO2/MappingModes/earthCylindric.txt @@ -2,4 +2,4 @@ Wikipedia Commons, downloaded November 25th 08 -http://upload.wikimedia.org/wikipedia/commons/0/01/Lambert-cylindrical-equal-area-projection.jpg \ No newline at end of file +http://upload.wikimedia.org/wikipedia/commons/0/01/Lambert-cylindrical-equal-area-projection.jpg diff --git a/test/models/LWO/LWO2/MappingModes/earthSpherical.source.txt b/test/models/LWO/LWO2/MappingModes/earthSpherical.source.txt index 218b339e1..db055ea0f 100644 --- a/test/models/LWO/LWO2/MappingModes/earthSpherical.source.txt +++ b/test/models/LWO/LWO2/MappingModes/earthSpherical.source.txt @@ -6,4 +6,4 @@ http://earthobservatory.nasa.gov/Features/BlueMarble/BlueMarble_monthlies.php Downloaded November 24, 08. -Rescaled to 2048 * 1024 with GIMP \ No newline at end of file +Rescaled to 2048 * 1024 with GIMP diff --git a/test/models/LWO/LWO2/concrete.source.txt b/test/models/LWO/LWO2/concrete.source.txt index 2904ae998..90fc73e2d 100644 --- a/test/models/LWO/LWO2/concrete.source.txt +++ b/test/models/LWO/LWO2/concrete.source.txt @@ -1,2 +1,2 @@ cgtextures.com - free, even for commercial use. See the licensing conditions and the FAQ the site for more details. -Great source for free textures, btw! \ No newline at end of file +Great source for free textures, btw! diff --git a/test/models/LWO/LWO2/uvtest-source.txt b/test/models/LWO/LWO2/uvtest-source.txt index 75e4878a7..654d62180 100644 --- a/test/models/LWO/LWO2/uvtest-source.txt +++ b/test/models/LWO/LWO2/uvtest-source.txt @@ -1,2 +1,2 @@ Regression file. -by Tom Speed, see http://groups.google.com/group/bmx3d/browse_thread/thread/36db3b191f81be36 \ No newline at end of file +by Tom Speed, see http://groups.google.com/group/bmx3d/browse_thread/thread/36db3b191f81be36 diff --git a/test/models/MD2/faerie-source.txt b/test/models/MD2/faerie-source.txt index ef0e4f196..4906ff4d1 100644 --- a/test/models/MD2/faerie-source.txt +++ b/test/models/MD2/faerie-source.txt @@ -21,4 +21,4 @@ The Irrlicht Engine License appreciated but is not required. 2. Altered source versions must be clearly 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. \ No newline at end of file + 3. This notice may not be removed or altered from any source distribution. diff --git a/test/models/MD2/sidney-source.txt b/test/models/MD2/sidney-source.txt index ef0e4f196..4906ff4d1 100644 --- a/test/models/MD2/sidney-source.txt +++ b/test/models/MD2/sidney-source.txt @@ -21,4 +21,4 @@ The Irrlicht Engine License appreciated but is not required. 2. Altered source versions must be clearly 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. \ No newline at end of file + 3. This notice may not be removed or altered from any source distribution. diff --git a/test/models/MD5/SimpleCube.source.txt b/test/models/MD5/SimpleCube.source.txt index 6f51bc1cf..77d151ed7 100644 --- a/test/models/MD5/SimpleCube.source.txt +++ b/test/models/MD5/SimpleCube.source.txt @@ -1 +1 @@ -From http://www.doom3world.org/phpbb2/viewtopic.php?f=3&t=16842 (thanks, Rayne, whoever you are) \ No newline at end of file +From http://www.doom3world.org/phpbb2/viewtopic.php?f=3&t=16842 (thanks, Rayne, whoever you are) diff --git a/test/models/MDL/MDL3 (3DGS A4)/minigun_readme.txt b/test/models/MDL/MDL3 (3DGS A4)/minigun_readme.txt index c2ca7c696..4d36f8cbb 100644 --- a/test/models/MDL/MDL3 (3DGS A4)/minigun_readme.txt +++ b/test/models/MDL/MDL3 (3DGS A4)/minigun_readme.txt @@ -3,4 +3,4 @@ Hi everybody!!! This is my first published model so it isn't very good,but i'm still learning!.. This model is free for everybody,but credit will be nice! You may reach me at rojkov91@mail.ru -P.S: Excuse my bad english \ No newline at end of file +P.S: Excuse my bad english diff --git a/test/models/MDL/MDL5 (3DGS A5)/minigun_mdl5_readme.txt b/test/models/MDL/MDL5 (3DGS A5)/minigun_mdl5_readme.txt index c2ca7c696..4d36f8cbb 100644 --- a/test/models/MDL/MDL5 (3DGS A5)/minigun_mdl5_readme.txt +++ b/test/models/MDL/MDL5 (3DGS A5)/minigun_mdl5_readme.txt @@ -3,4 +3,4 @@ Hi everybody!!! This is my first published model so it isn't very good,but i'm still learning!.. This model is free for everybody,but credit will be nice! You may reach me at rojkov91@mail.ru -P.S: Excuse my bad english \ No newline at end of file +P.S: Excuse my bad english diff --git a/test/models/MS3D/jeep1.readme.txt b/test/models/MS3D/jeep1.readme.txt index d17d5e0e9..f52ada0cc 100644 --- a/test/models/MS3D/jeep1.readme.txt +++ b/test/models/MS3D/jeep1.readme.txt @@ -12,4 +12,4 @@ http://xu1productions.com/3dstudio/index.html - 3D Game Resources http://www.psionicdesign.com - My Main 2D/3D Digital Art site -Psionic 2002 \ No newline at end of file +Psionic 2002 diff --git a/test/models/Q3D/E-AT-AT.source.txt b/test/models/Q3D/E-AT-AT.source.txt index 56a96f7d5..2df8826f1 100644 --- a/test/models/Q3D/E-AT-AT.source.txt +++ b/test/models/Q3D/E-AT-AT.source.txt @@ -5,4 +5,4 @@ Downloaded 4th November 08 (Obama ftw!) Copyright notice found on the page: Where do the models in the archive come from? -All 3D files available from the3darchive.com are from the public domain. \ No newline at end of file +All 3D files available from the3darchive.com are from the public domain. diff --git a/test/models/Q3D/earth.source.txt b/test/models/Q3D/earth.source.txt index 56a96f7d5..2df8826f1 100644 --- a/test/models/Q3D/earth.source.txt +++ b/test/models/Q3D/earth.source.txt @@ -5,4 +5,4 @@ Downloaded 4th November 08 (Obama ftw!) Copyright notice found on the page: Where do the models in the archive come from? -All 3D files available from the3darchive.com are from the public domain. \ No newline at end of file +All 3D files available from the3darchive.com are from the public domain. diff --git a/test/models/X/BCN_Epileptic.txt b/test/models/X/BCN_Epileptic.txt index 1538e59fb..398d21b86 100644 --- a/test/models/X/BCN_Epileptic.txt +++ b/test/models/X/BCN_Epileptic.txt @@ -1 +1 @@ -A human body separated into three meshes: lower body, upper body, head. A common bone hierarchy for all three meshes, plus an test animation that makes the body sort of jump. No material information exported. \ No newline at end of file +A human body separated into three meshes: lower body, upper body, head. A common bone hierarchy for all three meshes, plus an test animation that makes the body sort of jump. No material information exported. diff --git a/test/models/X/anim_test.txt b/test/models/X/anim_test.txt index 637ea0581..3d270dc7d 100644 --- a/test/models/X/anim_test.txt +++ b/test/models/X/anim_test.txt @@ -6,4 +6,4 @@ Frame 18 - 24: Zylinder-Spitze bewegt sich zu Position in Richtung x+ Remarks: The exporter failed here for some reasons... although the mesh referres to four bones, only two of them are stored in the corresponding node hierarchy. So you have a mesh with 4 bones, a hirarchy with 2 nodes and a animation that affects only those two nodes. -There is no timing given for the animation. You have to scale the animation manually. For this file, the timing seems to be 24 ticks per second. \ No newline at end of file +There is no timing given for the animation. You have to scale the animation manually. For this file, the timing seems to be 24 ticks per second. diff --git a/test/models/X/test.txt b/test/models/X/test.txt index 7a5e8e74b..eaf9d9c3c 100644 --- a/test/models/X/test.txt +++ b/test/models/X/test.txt @@ -1,3 +1,3 @@ Simple textured test cube exported from Maya. Has a texture that does label each cube side uniquely, but the sides do not match DirectX coordinate space. -Is not readable using D3DXLoadFrameHierarchy, needs custom text parsing. \ No newline at end of file +Is not readable using D3DXLoadFrameHierarchy, needs custom text parsing. diff --git a/test/models/glTF2/BoxBadNormals-glTF-Binary/BoxBadNormals.glb b/test/models/glTF2/BoxBadNormals-glTF-Binary/BoxBadNormals.glb new file mode 100644 index 000000000..c36727d12 Binary files /dev/null and b/test/models/glTF2/BoxBadNormals-glTF-Binary/BoxBadNormals.glb differ diff --git a/test/models/glTF2/BoxWithInfinites-glTF-Binary/BoxWithInfinites.glb b/test/models/glTF2/BoxWithInfinites-glTF-Binary/BoxWithInfinites.glb new file mode 100644 index 000000000..ae83f1f06 Binary files /dev/null and b/test/models/glTF2/BoxWithInfinites-glTF-Binary/BoxWithInfinites.glb differ diff --git a/test/models/glTF2/issue_3269/texcoord_crash.gltf b/test/models/glTF2/issue_3269/texcoord_crash.gltf new file mode 100644 index 000000000..bc5d13f31 --- /dev/null +++ b/test/models/glTF2/issue_3269/texcoord_crash.gltf @@ -0,0 +1,610 @@ +{ + "accessors" : [ + { + "bufferView" : 0, + "componentType" : 5121, + "count" : 6, + "max" : [ + 3 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 1, + "componentType" : 5126, + "count" : 4, + "max" : [ + 1.2000000476837158, + 1.2000001668930054, + -5.205485820169997e-08 + ], + "min" : [ + 0.19999980926513672, + 0.20000004768371582, + -1.5933926533762133e-07 + ], + "type" : "VEC3" + }, + { + "bufferView" : 2, + "componentType" : 5126, + "count" : 4, + "max" : [ + -2.1316282072803006e-14, + 1.0728441424134871e-07, + 1.0 + ], + "min" : [ + -2.1316282072803006e-14, + 1.0728441424134871e-07, + 1.0 + ], + "type" : "VEC3" + }, + { + "name": "TopRight_TEXCOORD_0", + "bufferView" : 3, + "componentType" : 5126, + "count" : 4, + "max" : [ + 1.0, + 0.3999999761581421 + ], + "min" : [ + 0.6000000238418579, + 0.0 + ], + "type" : "VEC2" + }, + { + "bufferView" : 4, + "componentType" : 5121, + "count" : 6, + "max" : [ + 3 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 5, + "componentType" : 5126, + "count" : 4, + "max" : [ + -0.20000006258487701, + 1.2000000476837158, + 1.2601539367551595e-07 + ], + "min" : [ + -1.2000001668930054, + 0.19999974966049194, + -3.3740951721483725e-07 + ], + "type" : "VEC3" + }, + { + "bufferView" : 6, + "componentType" : 5126, + "count" : 4, + "max" : [ + 1.7807019503379706e-07, + 2.853547016457014e-07, + 1.0 + ], + "min" : [ + 1.7807019503379706e-07, + 2.853547016457014e-07, + 1.0 + ], + "type" : "VEC3" + }, + { + "name": "TopLeft_TEXCOORD_0", + "bufferView" : 7, + "componentType" : 5126, + "count" : 4, + "max" : [ + 0.3999999463558197, + 0.3999999761581421 + ], + "min" : [ + 7.915305388905836e-08, + 0.0 + ], + "type" : "VEC2" + }, + { + "bufferView" : 8, + "componentType" : 5121, + "count" : 6, + "max" : [ + 3 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 9, + "componentType" : 5126, + "count" : 4, + "max" : [ + 1.2000001668930054, + -0.1999996304512024, + 5.255118367131217e-07 + ], + "min" : [ + 0.2000000923871994, + -1.2000000476837158, + 6.20869826661874e-08 + ], + "type" : "VEC3" + }, + { + "bufferView" : 10, + "componentType" : 5126, + "count" : 4, + "max" : [ + -1.7807025187721592e-07, + 2.853545879588637e-07, + 1.0 + ], + "min" : [ + -1.7807025187721592e-07, + 2.853545879588637e-07, + 1.0 + ], + "type" : "VEC3" + }, + { + "name": "BottomRight_TEXCOORD_0", + "bufferView" : 11, + "componentType" : 5126, + "count" : 4, + "max" : [ + 0.9999998807907104, + 1.0 + ], + "min" : [ + 0.6000000834465027, + 0.599999874830246 + ], + "type" : "VEC2" + }, + { + "bufferView" : 12, + "componentType" : 5121, + "count" : 6, + "max" : [ + 3 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 13, + "componentType" : 5126, + "count" : 4, + "max" : [ + 1.0000001192092896, + 1.0000001192092896, + -0.052591003477573395 + ], + "min" : [ + -1.0000001192092896, + -1.0000001192092896, + -0.05259115248918533 + ], + "type" : "VEC3" + }, + { + "bufferView" : 14, + "componentType" : 5126, + "count" : 4, + "max" : [ + 1.0658142730467397e-14, + -7.450581307466564e-08, + -1.0 + ], + "min" : [ + 1.0658142730467397e-14, + -7.450581307466564e-08, + -1.0 + ], + "type" : "VEC3" + }, + { + "bufferView" : 15, + "componentType" : 5121, + "count" : 6, + "max" : [ + 3 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 16, + "componentType" : 5126, + "count" : 4, + "max" : [ + -0.19999969005584717, + -0.2000000774860382, + 5.255118367131217e-07 + ], + "min" : [ + -1.2000000476837158, + -1.2000001668930054, + 6.208701108789683e-08 + ], + "type" : "VEC3" + }, + { + "bufferView" : 17, + "componentType" : 5126, + "count" : 4, + "max" : [ + -8.526512829121202e-14, + 4.6342486825778906e-07, + 1.0 + ], + "min" : [ + -8.526512829121202e-14, + 4.6342486825778906e-07, + 1.0 + ], + "type" : "VEC3" + }, + { + "name": "BottomLeft_TEXCOORD_0", + "bufferView" : 18, + "componentType" : 5126, + "count" : 4, + "max" : [ + 0.40000009536743164, + 0.9999999208469248 + ], + "min" : [ + 0.0, + 0.6000000536441803 + ], + "type" : "VEC2" + } + ], + "asset" : { + "copyright" : "Copyright 2017-2018 Analytical Graphics, Inc., CC-BY 4.0 https://creativecommons.org/licenses/by/4.0/ - Mesh and textures by Ed Mackey.", + "generator" : "Khronos Blender glTF 2.0 exporter, plus hand-edits", + "version" : "2.0" + }, + "bufferViews" : [ + { + "buffer" : 0, + "byteLength" : 6, + "byteOffset" : 0, + "target" : 34963 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 8, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 56, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 32, + "byteOffset" : 104, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 6, + "byteOffset" : 136, + "target" : 34963 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 144, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 192, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 32, + "byteOffset" : 240, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 6, + "byteOffset" : 272, + "target" : 34963 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 280, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 328, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 32, + "byteOffset" : 376, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 6, + "byteOffset" : 408, + "target" : 34963 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 416, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 464, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 6, + "byteOffset" : 512, + "target" : 34963 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 520, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 568, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 32, + "byteOffset" : 616, + "target" : 34962 + } + ], + "buffers" : [ + { + "byteLength" : 648, + "uri" : "data:application/octet-stream;base64,AAECAwEAAACamZk/2sxMPuySX7PAzEw+mZmZP9gWK7TKzEw+0MxMPuySX7OYmZk/m5mZP9gWK7QAAMCoO2TmMwAAgD8AAMCoO2TmMwAAgD8AAMCoO2TmMwAAgD8AAMCoO2TmMwAAgD8AAIA/zMzMPpqZGT8AAAAAmpkZP8zMzD4AAIA/AAAAAAABAgMBAAAA0cxMvsnMTD7okl+zm5mZv5iZmT/aFiu0mZmZv7zMTD7ZTgc03sxMvpqZmT82JbW0kDM/NNoymTQAAIA/kDM/NNoymTQAAIA/kDM/NNoymTQAAIA/kDM/NNoymTQAAIA/y8zMPszMzD7a+qkzAAAAANr6qTPMzMw+y8zMPgAAAAAAAQIDAQAAAJuZmT+YmZm/5hANNdPMTD7HzEy+rlSFM+bMTD6amZm/Boi6NJmZmT+0zEy+8u6ANJQzP7TWMpk0AACAP5QzP7TWMpk0AACAP5QzP7TWMpk0AACAP5QzP7TWMpk0AACAP/3/fz8AAIA/m5kZP5iZGT+cmRk/AACAP/7/fz+YmRk/AAECAAMBAAABAIC//f9/P9JpV70BAIA//f9/v6ppV739/3+/AQCAv6ppV739/38/AQCAP9JpV70CAEAoAQCgswAAgL8CAEAoAQCgswAAgL8CAEAoAQCgswAAgL8CAEAoAQCgswAAgL8AAQIDAQAAALjMTL6ZmZm/5hANNZqZmb/izEy+uFSFM5iZmb+bmZm/5hANNcjMTL7SzEy+slSFMwAAwKmhzPg0AACAPwAAwKmhzPg0AACAPwAAwKmhzPg0AACAPwAAwKmhzPg0AACAP9DMzD7//38/AACAM5qZGT8AAAAA//9/P83MzD6amRk/" + } + ], + "images" : [ + { + "uri" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QYcDhkW4QlOQwAAHBNJREFUeNrt3XuMlNX9P/DP4u7OLkshVEGkgKyVWzTNsloTbYtGaIgmRGM1tRq1TbVSaqm2qdREwbSJoQlQGm9NiNSmCSyRRhNtm0YTTUyq1jWhtFDF2lKrqcKuCsJegfP74/vbDbC3mZ2Zvcy8Xslkk5lnn3l2zjPn8z7nuWxFSikFAFBWJvgIAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABg9FRmu2BFRUVWy7mxIAAUXqHrcOVY/kOECQBKvWiPVq2rLPUPV4gAQH0pwQBQzAYWHgD08aWq0u5R2J1KaADQ7woADLrj2mkBfaO+UQCg3y+DLwKgP0MA4JQvlC8ToE9iuNwIqIS+hNleIwqgn0EAKPFU7ssK6EPot41TgedsCnmnokLcQCGf6ziHc/lILmepZnPyy2DH0Pqbeut5LqUUFRUVpuSAvPrznr6kv35msD4pm/4sl75xOP1uPn18IepLIWtdtusyA0BRdhZAH0LpcBKgLyyAfkUAwJcSQN8jAOCLBqC/EgDwZQHQ5wkA2MEB9KMCgJ0QAH21AGDHAEB9EAA0DgACxDgNAIW66xEAkFvdLHQNdidAAChDAgAACAAAgAAAAAgAAIAAAAAIAACAAAAAjFk53QgomxsMuFkQAORmNGqnGQAAKEMCAAAIAACAAAAACAAAgAAAAAgAAIAAAACMWZW5/sJQNytwkx8AyE0hbrSXa/01AwAAZUgAAAABAAAQAAAAAQAASklFRUVW/4lPAGDEHTt2LNatWxf19fWRyWRizpw5PhQg74KX7WO0ty+TycTnPve5uP7666O5uXlUC3iphYWKlON1A6N9GWCuH/5IX5bYs32Fet/169fHfffd1+dvKvT7AOUTAMZDH9qfqqqqeOaZZ+Lqq68uWJ+by++Pdr876pcBppQGfYy1NDnePfnkkxERsXXr1ujo6FDwgbz0129n89pobWdHR0f8/e9/j69//evR3d3d74CoVPrFoernUPU3VxPsvGPb/v37o6qqKr75zW9GJpPRewEjpru7OzZt2hSNjY1RV1cXdXV10djYGJs3b45jx471W7w+/PDDWLlyZcyYMSNqa2vjS1/6Urz22mvD3oZMJhMXXHBBPPLIIxERsW/fvn7f92Tt7e2xdu3aqK+vj6qqqpg7d2488MADMWnSpAEHou+++27ceuutMXXq1JgxY0bcdddd0dHR0e/ou2QGtqnAImLQRzEMtO6urq60cePGtHjx4jRx4sQ0ceLEtHjx4vSLX/widXd397uODz74IN15553p7LPPTjU1Nemyyy5Lr776at7bcrqdO3emZcuWpalTp6aqqqp07rnnptWrV6eWlpZBP8uhPmOAQvShXV1dadmyZQP2NcuXLz+lH+15fsqUKX2WraurS2+//XZefeg//vGPFBGpvr5+0OW7urrSV77ylaz7yZ7nzjzzzD7LrVu3LqvaNl7rZ8kGgLG2857sjjvuGHC75s+fnz755BMBABjVALBhw4YUEWn69OmpqakptbS0pJaWlrRt27Y0bdq0FBFp06ZNfdZx/fXXp1dffTW1t7en3bt3p8bGxhQR6dvf/vawtuXQoUPpxRdf7F3P2rVrB13+l7/8Ze92P/300+nw4cPp4MGDaefOnYMGgMsvvzzt2rUrHTp0KK1ZsyZFRJo3b96wBngCwCgHgLGy857uySefTBGRZs2alXbs2JEOHDiQ2traUnNzc7riiitSRKT77rtvyPUp+EAx+9CGhoYUEempp57qs3xTU1OKiLR48eIh+6SXX36535H7cGrIddddlzo6Ogbd9osvvjhFRNq+fXtWf2fPc8ePH+997sMPP0wRkTKZjAAwHgPAaO+8A7n00ktTRKTm5uY+r/33v/9NEZEWLVokAACjGgBqa2tTRKTW1tY+y7e0tKSISBMnThyyT/r0009TRKTq6uq8asj69euz2va6uroUEengwYM5BYCTdXd3Z73seK6fJXsfgLfeeisiIq688so+ry1btuyUZQbT0NAQERHvv/9+QbZr9+7dERFx8cUX9zmRZPbs2RER8e9//9vZR8CYOfE6m+cG0nMiXVVV1bBO+H700UcjImLz5s2xf//+IX+vq6srIiJqa2uH/TdXVlaWRdtOsPMWZ+cdyIkTJ7J+T4DRMn/+/IiIeP755/u89sILL0RExIIFC4Zcz0svvRQREYsWLRrWdqxatSruueee+OCDD+Kqq66Kjz76aNDlZ86cecpgqxg6OzvLNwCM5HWK433nPd3ChQsjIuKdd94pyOdUKjsiMLbccsstERGxevXqaGpqitbW1mhtbY2mpqZYvXr1Kcuc7Pe//3188sknceTIkXjuued6l73pppuGvS0bNmyIa6+9Nt5888245pprBu33emZ977777tizZ08cPXo0mpub47bbbsv7M+kJFw899FC0tbUVZcCahnmfneG+YUGPU4y1M1inTZuWtm/f3nsS4Pbt2wc9CfC5555LH3/8cfr000/Ts88+m84555w+y+ZzDsBjjz2WIiLNnj07PfHEE+k///lPam9vT21tbWnPnj3p0UcfTRdddNGQ65s5c2bvGbFHjx51EBMoaB/a1dWVli5dmvOVVP09LrvsstTZ2ZlXH3r06NHeE/xuuOGGdOLEiX6X37dvX5o0aVKfbaiurs7puH5/z69cuXJU616ha2/JBoDR3nkHehw/fjx961vfyvpkj4E+19HeEYHSDgA9/ejGjRtTQ0NDqq2tTbW1tamhoSFt2rRpwHuprFmzJn3+859PmUwmzZo1K/34xz9OR44cyXtbUkrpf//7X5ozZ06KiHT33XcPuPzrr7+elixZkmpqatLkyZPTihUr0htvvJEiItXU1Aw7ABw5ciTde++96bzzzkuZTCZNmTIlXXLJJeM2AOT8vwB6DgHkcsy92Aa6P3N3d3c8/PDD8dvf/rb3hL8FCxbErbfeGt///vdPOdGjZx1r1qyJnTt3xnvvvRfTpk2Lb3zjG7Fu3bqoq6vL+7M5eRv/+Mc/xhNPPBGvvfZaHDhwICoqKqK+vj6WLl0aN954Y3z5y18e9G87evRo/PSnP42dO3fG+++/HzU1NbFgwYK87rgFUOh+eKzYs2dPXHjhhTFv3rw+dxMcb59xoWpvSQSActh5AfShuevu7o69e/fGqlWr4s9//nPcdddd8fDDDwsAAoAAAFBqfehANWrGjBnxxhtv9J7MV+4BYILdFoBSsmLFipg9e3bU1tZGdXV1zJ07N+688854/fXXx23xL0qgSAWOa+N1dsAMAAClNsofTKWPe+yHEwAoNIcAAEAAAAAEAABAAAAABAAAYJwa9lUAA12q4Gx6ABiewWpooeuuGQAAKEMCAAAIAACAAAAACAAAQGkY9lUAA5116OoAABi+kaqjZgAAoAwJAAAgAAAAAgAAIAAAAKWhMp9f7u9MRWf7A8Dw5XKVXT411wwAAJQhAQAABAAAQAAAAEpSXicB9nfygRMDASA/I1FLzQAAQBkSAABAAAAABAAAoCRV5ruC009UcMIfAOQnm5Ps8623ZgAAoAwJAAAgAAAA5SDvcwBOPwbhnAAAyF+x66kZAAAoQwIAAAgAAEA5qCzESk4+TuGYPwDkb7Bz7ApRa80AAEAZEgAAoAwV5BDAyVMRDgcAQGEUs6aaAQCAMiQAAEAZqizUinqmKUz7A0Bh9HeIvVB11gwAAJgByD+lmAkAgMIpVl01AwAAZgDyTylG/gBQOCfPsBeyxk4o9Eae/u8LAYCxN8CeMNY3EADMAhR+gF2RVGwAKDtOAgQAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAAiqTSRwBDq6io6Pf5lJIPR7uAGQAolwKT6zJoFxAAYBwVmWxGkiklxUa7gAAApSLbApJtQUK7gAAARppoFxAAwEgT7QICABhpol1AAAAjTbQLCABgpKldtAsIAGCkqV20CwgAYKSpXbQLCABgpKldAAEAjDS1CyAAgJGmdgEBAMpg5Jjrz1xHmrn+RLuAAABFLjI9BSHXn6O5bu2iXaBo379kjgyyHqX2N8pEu4AAAOOoSIwV5foV1C4wuhwCAAABAAAQAAAAAQAAEAAAgHHKVQCQzRfF5WbaBcwAwPgtFMW4M1wx161dtAsIAJCH4d4RLpdbzhZj3dpFu0DRArhDADD4KHKw28MqGtoFzABAiRaZbEeaaBcQAKAE+Lez2gUEADDSNNLULiAAgJGmkaZ2AQEAjDSNNLULCABgpIl2AQEAjDTRLiAAgJEm2gUEADDSRLuAAABGmmgXEADASBPtAgIAGGmiXUAAgBEpNoVYBu0CY43/BggAZgAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAAAQAAEAAAAAEAABAAAAABAAAQAAAAAQAAEAAAAAEAABAAAAARkaljwCGVlFR0e/zKSUfjnYBMwBQLgUm12XQLiAAwDgqMtmMJFNKio12AQEASkW2BSTbgoR2AQEAjDTRLiAAgJEm2gUEADDSRLuAAABGmmgXEADASFO7aBcQAMBIU7toFxAAwEhTu2gXEADASFO7AAIAGGlqF0AAACNN7QICAJTByDHXn7mONHP9iXYBAQCKXGR6CkKuP0dz3dpFu0DRvn/JHBlkPUrtb5SJdgEBAMZRkRgryvUrqF1gdDkEAAACAAAgAAAAAgAAIAAAAOOUqwAgmy+Ky820C5gBgPFbKIpxZ7hirlu7aBcQACAPw70jXC63nC3GurWLdoGiBXCHAGDwUeRgt4dVNLQLmAGAEi0y2Y400S4gAEAJ8G9ntQsIAGCkaaSpXUAAACNNI03tAgIAGGkaaWoXEADASBPtAgIAGGmiXUAAACNNtAsIAGCkiXYBAQCMNNEuIACAkSbaBQQAMNJEu4AAACNSbAqxDNoFxhr/DRAAzAAAAAIAACAAAAACAAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAACAAAAACAAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAAAAAgAAIAAAAACAAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAAAAAgAAIAAAAAIAAAgAAIAAAAAIAACAAAAACAAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAAAAIzJAFBRUeETBYAiKHSNLWgASCkJAQBQhOKfUhrbMwCF3kAAKHfFGGBXFmsDBQEAKMzguhh11UmAAFCGCjYDYOQPAIXXU1cLXWfNAACAGYDCJRSzAQCQn2LWVDMAAFCGBAAAKEMFOQRg2h8ACu/kmlroWmsGAADKkAAAAGWoIIcABpqiOP01ACA7xa6nZgAAoAwJAAAgAAAA5SDvcwAc8weAwju9nha63poBAIAyJAAAgAAAAJSDvM8BGOoYRX/LAAADG4laagYAAMqQAAAAAgAAIAAAACUpr5MAnfAHAIXXXy0tdM01AwAAZUgAAAABAAAQAACAkpTXSYDZnqQw0LIAwOjUUTMAAFCGBAAAEAAAAAFgDKqoqDjlUVNTE+eff3786Ec/ikOHDuW93lxfA0AfPS7bKhX4rIJin7wwWCNfc8018cwzz+S13sFObHQiI4A+erQ+wzFzEuDpKa/nkVLq91FoKaU4ceJEfPrpp/H4449HRMSf/vQn3z6AMUAfnd9n199joLo74gFgrKSkSZMmxc033xwREdOnTz/l9e7u7ti0aVM0NjZGXV1d1NXVRWNjY2zevDmOHTvWb9oa7MPt7/ls3+P0dezevTuuvfbamDx5ckyePDluuumm+Pjjj+Oll16K5cuXx2c+85mYMWNGrFy5Mtrb230jAH20PrrgSWNYIqLfR7Gd/j6HDx9O999/f4qItGXLlt7nu7q60rJlywbczuXLl6fu7u5B/5ahHrm8x+nbP2HChD7Lz507t9/13H///QlgPNBHF/+zLVTdHbcB4PRHY2Njev/993uX27BhQ4qINH369NTU1JRaWlpSS0tL2rZtW5o2bVqKiLRp06YBd9rBdujhvsfJ61qyZEnatWtX6ujoSA8++GC/z69duzZFRDr//PP1KsC4CgD6aAFgxD6AiEhTp05Nu3btSiml1NDQkCIiPfXUU33W0dTUlCIiLV68OK+dK9f3OHldx48f733uwIEDKSJSVVXVKc9/+OGHKSJSJpPRqwDjOgDoowWAgk8vdXV1pf3796fbb7+9d0onpZRqa2tTRKTW1tY+62hpaUkRkSZOnJjXzpXrewy0rmPHjuX0PMBYDwD66LEfACbkce5ATmcpFusazaqqqjj33HNj48aNERHx6quvDnnZRCrwVQn5vscZZ5yR0/MA44U+OvcTJ0fqKruSuRPg4cOHT2nU+fPnR0TE888/32fZF154ISIiFixY0Oe1zs7OAd/j9NeG+x4A5UYfPfaM+wDQ1dUVu3fvjttvvz0iIpYsWRIREbfccktERKxevTqampqitbU1Wltbo6mpKVavXn3KMhERM2fOjIiIhx56KNra2k55j4Fey/U9AMqNPnoMG8kTQIq9/smTJ6e//e1vvcedli5dmvXlHytXrhxwmwd6Ldf3GOxYVa7PA4y3kwD10aNfQwtyEuBYCQBnnHFGOuecc9LNN9+c3n777VOW7erqShs3bkwNDQ2ptrY21dbWpoaGhrRp06Y+jX7kyJF07733pvPOOy9lMpk0ZcqUdMkllwz5Wi7vIQAA5RYA9NFjNwCM2P8COPnYDwAwujXUvwMGgDJUaZQPAGPDYDW00LXXDAAAlCEBAAAEAABAAAAABAAAQAAoCceOHYt169ZFfX19ZDKZmDNnjr0CoAwV8x/Xjcm/dyRvBBSR/2WCPesv1GavX78+7rvvvj7bWOj3ASC/elJdXR1nnXVWXHrppfGTn/wkLr744oLWh1x+vxg1otj1UwA4zcKFC+Ott96KrVu3xk033RSZTKZojQtAYepJVVVVPPPMM3H11VcLAALA8NTU1MSJEyeis7PzlG0XAADGRgDo6Yc7Ozvjn//8Z/zsZz+LHTt2xBe+8IX461//WrT3K/UAULLnAPzud7+Lr371q/HZz342qqurY+7cufGDH/wgWltbT/mwOzs7o7u7OyZMmND74Z8eBE5+ADA6MplMXHDBBfHII49ERMS+ffv6FNDT++n29vZYu3Zt1NfXR1VVVcydOzceeOCBmDRp0oB9+rvvvhu33nprTJ06NWbMmBF33XVXdHR09Fuox3ONKMkZgO985zuxZcuWfl+bP39+/OUvf4kpU6b0u60nH/8fiQQGQG79/ZtvvhmLFi2K+vr6+Ne//jXg8t3d3bF06dJ4+eWXs+rTe37/zDPPPGWwGBGxbt26ePDBB4esc/nUCDMAefrNb34TW7ZsiVmzZsWOHTviwIED0dbWFs3NzXHFFVfEvn374uc//3mfD/P//2vkAZ8/+XUARt7hw4fjpZdeiptvvjkiIm655ZZBl3/88cfj5ZdfjunTp8fTTz8dhw8fjoMHD8bOnTsH/b0LL7wwdu3aFYcOHYo1a9ZERMS2bdv6LcTjuUaU3AzAZZddFq+88ko0NzfHRRdddMpr7733XsyePTsWLVoUe/fuHXR9zgEAGBszAP257rrrYtu2bb0nbvfXb3/xi1+M5ubm2L59e9x4441D9vE9zx0/fjwmTPi/8fGBAwfi7LPPjkwm0+9hACcBjqEAMGnSpDh69Oig66ipqYn29nYBAGAcBoD169f3jswH67d76sHBgwfjrLPOyjoAnPzcsWPHoqqqKqtlx1sAmDCcDRzscfp0yEhPj5w4cWLIZU5OcQCMbT3149FHH42IiM2bN8f+/fuH/L2urq6IiKitrR32e1dWVo743znQY6j6W/QAMNYtXLgwIiLeeeedggSRzs5O3z6AMWDVqlVxzz33xAcffBBXXXVVfPTRR4MuP3PmzIiI2L17d9G2aTzXiJILAHfccUdERFxxxRWxdevWePfdd6OjoyPa29tj79698dhjj/W5e9RgO85DDz0UbW1tvnkAY8CGDRvi2muvjTfffDOuueaaQQvwlVdeGRERd999d+zZsyeOHj0azc3Ncdttt+W9HaVQI3I+B2Ckj1Hk+v7Hjx+P22+/PX79619ntZ0DHcf57ne/G7/61a9G/O8DIAbtn9va2uLyyy+P5ubmuOGGG2LHjh2nTIP3LP/2229HY2NjHDly5JTfr66u7j08kM1x/f6eH40aUej6W3IzABMmTIitW7fGH/7wh/ja174Ws2bNiurq6shkMrFw4cL43ve+N+g1oSenzHvvvTfOO++8yGQyMWXKlLjkkkt8IwFG2cSJE+PZZ5+NOXPmxFNPPRU//OEP+11u3rx58eKLL8aSJUuipqYmJk+eHCtWrIhXXnklIv7vhPB8ZiLGe40YdzMAAJCPPXv2xIUXXhjz5s3rczfB8TAjUqj6W2lXAKAcdHd3x969e2PVqlUREbF8+fKy/jzMAABQukVugJo1Y8aMeOONN3pP5ivHGYCczwHI9zpF/1AHgJGyYsWKmD17dtTW1vb+Y7g777wzXn/99TFV/LOpnYW+z86I3wnQLAEAjH7tnOBjB4DyIwAAgAAAAAgAAIAAAAAIAACAAAAAjBc53QrYNf4AUHjZ1M5C12AzAABQhgQAABAAAAABAAAQAAAAAQAAEAAAAAEAABizcroRUKFuVJDtugCg1I1W3awc7x+KIAGAGlViAWAkGkiAAFDAy7E+VNoFhrdzCA4A+moBgCF3RDshgH5UAGDAndwODujzEADo84XxZQH0VwgAvmy+aIC+h2FxI6AS/GJme00pgH5FAKDEUzqAPoSTVRZ6R8h2OqhQN1DI9zrO4V4+kutZqtme/DLUMbSBpt56nu95rqKiIlJKvT8Bci3+p/chp/czg/VJ2fRnufSNw+l38+njC1FfClnrilGHzQCUqJ4dQPEH9CHkNQPA+PiyAuhnEAB8AQH0SQgAvkwA+jMEAF8EAH2jAICdFkC/KwDYoQDQxwsAGhcA4UEA8MECwLiudRVJJQaAsuNOgAAgAAAAAgAAIAAAAAIAACAAAAACAAAgAAAAAgAAMIr+HyP6AtxN3EzKAAAAAElFTkSuQmCC" + } + ], + "materials" : [ + { + "name" : "BackPlaneMat", + "doubleSided": true, + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.16000001668930075, + 0.16000001668930075, + 0.16000001668930075, + 1.0 + ], + "metallicFactor" : 0.0 + } + }, + { + "name" : "BottomLeftMat", + "doubleSided": true, + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.0, + 0.16000000476837162, + 0.800000011920929, + 1.0 + ], + "baseColorTexture" : { + "index" : 0 + }, + "metallicFactor" : 0.0 + } + }, + { + "name" : "BottomRightMat", + "doubleSided": true, + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.0, + 0.800000011920929, + 0.0, + 1.0 + ], + "baseColorTexture" : { + "index" : 0 + }, + "metallicFactor" : 0.0 + } + }, + { + "name" : "TopLeftMat", + "doubleSided": true, + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.0, + 1.0 + ], + "baseColorTexture" : { + "index" : 0 + }, + "metallicFactor" : 0.0 + } + }, + { + "name" : "TopRightMat", + "doubleSided": true, + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.08000000238418581, + 0.0, + 1.0 + ], + "baseColorTexture" : { + "index" : 0 + }, + "metallicFactor" : 0.0 + } + } + ], + "meshes" : [ + { + "name" : "TopRightMesh", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 2, + "POSITION" : 1, + "TEXCOORD_1" : 3 + }, + "indices" : 0, + "material" : 4 + } + ] + }, + { + "name" : "TopLeftMesh", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 6, + "POSITION" : 5, + "TEXCOORD_0" : 7 + }, + "indices" : 4, + "material" : 3 + } + ] + }, + { + "name" : "BottomRightMesh", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 10, + "POSITION" : 9, + "TEXCOORD_0" : 11 + }, + "indices" : 8, + "material" : 2 + } + ] + }, + { + "name" : "BackPlaneMesh", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 14, + "POSITION" : 13 + }, + "indices" : 12, + "material" : 0 + } + ] + }, + { + "name" : "BottomLeftMesh", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 17, + "POSITION" : 16, + "TEXCOORD_0" : 18 + }, + "indices" : 15, + "material" : 1 + } + ] + } + ], + "nodes" : [ + { + "mesh" : 3, + "name" : "BackPlane" + }, + { + "mesh" : 4, + "name" : "BottomLeftObj" + }, + { + "mesh" : 2, + "name" : "BottomRightObj" + }, + { + "mesh" : 1, + "name" : "TopLeftObj" + }, + { + "mesh" : 0, + "name" : "TopRightObj" + } + ], + "samplers" : [ + {} + ], + "scene" : 0, + "scenes" : [ + { + "name" : "Scene", + "nodes" : [ + 0, + 2, + 1, + 4, + 3 + ] + } + ], + "textures" : [ + { + "sampler" : 0, + "source" : 0 + } + ] +} diff --git a/test/regression/result_checker.py b/test/regression/result_checker.py index 19772f8af..1b01c52e6 100644 --- a/test/regression/result_checker.py +++ b/test/regression/result_checker.py @@ -110,4 +110,4 @@ def run(): if __name__ == "__main__": sys.exit(run()) -# vim: ai ts=4 sts=4 et sw=4 \ No newline at end of file +# vim: ai ts=4 sts=4 et sw=4 diff --git a/test/unit/AssimpAPITest_aiMatrix4x4.cpp b/test/unit/AssimpAPITest_aiMatrix4x4.cpp index 2c89726e0..89883dc0d 100644 --- a/test/unit/AssimpAPITest_aiMatrix4x4.cpp +++ b/test/unit/AssimpAPITest_aiMatrix4x4.cpp @@ -176,7 +176,7 @@ TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeIntoScalingAxisAnglePosition aiVector3D scaling_c, scaling_cpp, axis_c, axis_cpp, position_c, position_cpp; - float angle_c, angle_cpp; + ai_real angle_c, angle_cpp; result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition(); result_cpp.Decompose(scaling_cpp, axis_cpp, angle_cpp, position_cpp); diff --git a/test/unit/Common/utAssertHandler.cpp b/test/unit/Common/utAssertHandler.cpp new file mode 100644 index 000000000..4a567c0c3 --- /dev/null +++ b/test/unit/Common/utAssertHandler.cpp @@ -0,0 +1,110 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +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 +OWNER 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 "UnitTestPCH.h" + +/// Ensure this test has asserts on, even if the build type doesn't have asserts by default. +#if !defined(ASSIMP_BUILD_DEBUG) +#define ASSIMP_BUILD_DEBUG +#endif + +#include +#include + +namespace +{ + /// An exception which is thrown by the testAssertHandler + struct TestAssertException + { + TestAssertException(const char* failedExpression, const char* file, int line) + : m_failedExpression(failedExpression) + , m_file(file) + , m_line(line) + { + } + + std::string m_failedExpression; + std::string m_file; + int m_line; + }; + + /// Swap the default handler, which aborts, by one which throws. + void testAssertHandler(const char* failedExpression, const char* file, int line) + { + throw TestAssertException(failedExpression, file, line); + } + + /// Ensure that the default assert handler is restored after the test is finished. + struct ReplaceHandlerScope + { + ReplaceHandlerScope() + { + Assimp::setAiAssertHandler(testAssertHandler); + } + + ~ReplaceHandlerScope() + { + Assimp::setAiAssertHandler(Assimp::defaultAiAssertHandler); + } + }; +} + +TEST(utAssertHandler, replaceWithThrow) +{ + ReplaceHandlerScope scope; + + try + { + ai_assert((2 + 2 == 5) && "Sometimes people put messages here"); + EXPECT_TRUE(false); + } + catch(const TestAssertException& e) + { + EXPECT_STREQ(e.m_failedExpression.c_str(), "(2 + 2 == 5) && \"Sometimes people put messages here\""); + EXPECT_STREQ(e.m_file.c_str(), __FILE__); + EXPECT_GT(e.m_line, 0); + EXPECT_LT(e.m_line, __LINE__); + } + catch(...) + { + EXPECT_TRUE(false); + } +} diff --git a/test/unit/utColladaExportLight.cpp b/test/unit/utColladaExport.cpp similarity index 78% rename from test/unit/utColladaExportLight.cpp rename to test/unit/utColladaExport.cpp index 0327b296e..efb2d7f17 100644 --- a/test/unit/utColladaExportLight.cpp +++ b/test/unit/utColladaExport.cpp @@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_EXPORT -class ColladaExportLight : public ::testing::Test { +class utColladaExport : public ::testing::Test { public: void SetUp() override { ex = new Assimp::Exporter(); @@ -58,7 +58,9 @@ public: void TearDown() override { delete ex; + ex = nullptr; delete im; + im = nullptr; } protected: @@ -66,8 +68,53 @@ protected: Assimp::Importer *im; }; +TEST_F(utColladaExport, testExportCamera) { + const char *file = "cameraExp.dae"; + + const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, pTest); + ASSERT_TRUE(pTest->HasCameras()); + + EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file)); + const unsigned int origNumCams(pTest->mNumCameras); + std::unique_ptr origFOV(new float[origNumCams]); + std::unique_ptr orifClipPlaneNear(new float[origNumCams]); + std::unique_ptr orifClipPlaneFar(new float[origNumCams]); + std::unique_ptr names(new aiString[origNumCams]); + std::unique_ptr pos(new aiVector3D[origNumCams]); + for (size_t i = 0; i < origNumCams; i++) { + const aiCamera *orig = pTest->mCameras[i]; + ASSERT_NE(nullptr, orig); + + origFOV[i] = orig->mHorizontalFOV; + orifClipPlaneNear[i] = orig->mClipPlaneNear; + orifClipPlaneFar[i] = orig->mClipPlaneFar; + names[i] = orig->mName; + pos[i] = orig->mPosition; + } + const aiScene *imported = im->ReadFile(file, aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, imported); + + EXPECT_TRUE(imported->HasCameras()); + EXPECT_EQ(origNumCams, imported->mNumCameras); + + for (size_t i = 0; i < imported->mNumCameras; i++) { + const aiCamera *read = imported->mCameras[i]; + + EXPECT_TRUE(names[i] == read->mName); + EXPECT_NEAR(origFOV[i], read->mHorizontalFOV, 0.0001f); + EXPECT_FLOAT_EQ(orifClipPlaneNear[i], read->mClipPlaneNear); + EXPECT_FLOAT_EQ(orifClipPlaneFar[i], read->mClipPlaneFar); + + EXPECT_FLOAT_EQ(pos[i].x, read->mPosition.x); + EXPECT_FLOAT_EQ(pos[i].y, read->mPosition.y); + EXPECT_FLOAT_EQ(pos[i].z, read->mPosition.z); + } +} + // ------------------------------------------------------------------------------------------------ -TEST_F(ColladaExportLight, testExportLight) { +TEST_F(utColladaExport, testExportLight) { const char *file = "lightsExp.dae"; const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae", aiProcess_ValidateDataStructure); diff --git a/test/unit/utColladaExportCamera.cpp b/test/unit/utColladaExportCamera.cpp deleted file mode 100644 index c2c704056..000000000 --- a/test/unit/utColladaExportCamera.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2020, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -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 -OWNER 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 "UnitTestPCH.h" - -#include -#include -#include -#include -#include - -#ifndef ASSIMP_BUILD_NO_EXPORT - -class ColladaExportCamera : public ::testing::Test { -public: - void SetUp() override { - ex = new Assimp::Exporter(); - im = new Assimp::Importer(); - } - - void TearDown() override { - delete ex; - ex = nullptr; - delete im; - im = nullptr; - } - -protected: - Assimp::Exporter *ex; - Assimp::Importer *im; -}; - -TEST_F(ColladaExportCamera, testExportCamera) { - const char *file = "cameraExp.dae"; - - const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure); - ASSERT_NE(nullptr, pTest); - ASSERT_TRUE(pTest->HasCameras()); - - EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file)); - const unsigned int origNumCams(pTest->mNumCameras); - std::unique_ptr origFOV(new float[origNumCams]); - std::unique_ptr orifClipPlaneNear(new float[origNumCams]); - std::unique_ptr orifClipPlaneFar(new float[origNumCams]); - std::unique_ptr names(new aiString[origNumCams]); - std::unique_ptr pos(new aiVector3D[origNumCams]); - for (size_t i = 0; i < origNumCams; i++) { - const aiCamera *orig = pTest->mCameras[i]; - ASSERT_NE(nullptr, orig); - - origFOV[i] = orig->mHorizontalFOV; - orifClipPlaneNear[i] = orig->mClipPlaneNear; - orifClipPlaneFar[i] = orig->mClipPlaneFar; - names[i] = orig->mName; - pos[i] = orig->mPosition; - } - const aiScene *imported = im->ReadFile(file, aiProcess_ValidateDataStructure); - - ASSERT_NE(nullptr, imported); - - EXPECT_TRUE(imported->HasCameras()); - EXPECT_EQ(origNumCams, imported->mNumCameras); - - for (size_t i = 0; i < imported->mNumCameras; i++) { - const aiCamera *read = imported->mCameras[i]; - - EXPECT_TRUE(names[i] == read->mName); - EXPECT_NEAR(origFOV[i], read->mHorizontalFOV, 0.0001f); - EXPECT_FLOAT_EQ(orifClipPlaneNear[i], read->mClipPlaneNear); - EXPECT_FLOAT_EQ(orifClipPlaneFar[i], read->mClipPlaneFar); - - EXPECT_FLOAT_EQ(pos[i].x, read->mPosition.x); - EXPECT_FLOAT_EQ(pos[i].y, read->mPosition.y); - EXPECT_FLOAT_EQ(pos[i].z, read->mPosition.z); - } -} - -#endif // ASSIMP_BUILD_NO_EXPORT diff --git a/test/unit/utColladaImportExport.cpp b/test/unit/utColladaImportExport.cpp index 549ff68fb..451c8e235 100644 --- a/test/unit/utColladaImportExport.cpp +++ b/test/unit/utColladaImportExport.cpp @@ -41,16 +41,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "AbstractImportExportBase.h" #include "UnitTestPCH.h" +#include +#include #include #include #include +#include #include using namespace Assimp; class utColladaImportExport : public AbstractImportExportBase { public: - virtual bool importerTest() { + // Clones the scene in an exception-safe way + struct SceneCloner { + SceneCloner(const aiScene *scene) { + sceneCopy = nullptr; + SceneCombiner::CopyScene(&sceneCopy, scene); + } + + ~SceneCloner() { + delete sceneCopy; + sceneCopy = nullptr; + } + aiScene *sceneCopy; + }; + + virtual bool importerTest() final { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure); if (scene == nullptr) @@ -80,15 +97,255 @@ public: return true; } + + typedef std::pair IdNameString; + typedef std::map IdNameMap; + + template + static inline IdNameString GetColladaIdName(const T *item, size_t index) { + std::ostringstream stream; + stream << typeid(T).name() << "@" << index; + if (item->mMetaData) { + aiString aiStr; + if (item->mMetaData->Get(AI_METADATA_COLLADA_ID, aiStr)) + return std::make_pair(std::string(aiStr.C_Str()), stream.str()); + } + return std::make_pair(std::string(), stream.str()); + } + + template + static inline IdNameString GetItemIdName(const T *item, size_t index) { + std::ostringstream stream; + stream << typeid(T).name() << "@" << index; + return std::make_pair(std::string(item->mName.C_Str()), stream.str()); + } + + // Specialisations + static inline IdNameString GetItemIdName(aiMaterial *item, size_t index) { + std::ostringstream stream; + stream << typeid(aiMaterial).name() << "@" << index; + return std::make_pair(std::string(item->GetName().C_Str()), stream.str()); + } + + static inline IdNameString GetItemIdName(aiTexture *item, size_t index) { + std::ostringstream stream; + stream << typeid(aiTexture).name() << "@" << index; + return std::make_pair(std::string(item->mFilename.C_Str()), stream.str()); + } + + static inline void ReportDuplicate(IdNameMap &itemIdMap, const IdNameString &namePair, const char *typeNameStr) { + const auto result = itemIdMap.insert(namePair); + EXPECT_TRUE(result.second) << "Duplicate '" << typeNameStr << "' name: '" << namePair.first << "'. " << namePair.second << " == " << result.first->second; + } + + template + static inline void CheckUniqueIds(IdNameMap &itemIdMap, unsigned int itemCount, T **itemArray) { + for (size_t idx = 0; idx < itemCount; ++idx) { + IdNameString namePair = GetItemIdName(itemArray[idx], idx); + ReportDuplicate(itemIdMap, namePair, typeid(T).name()); + } + } + + static inline void CheckUniqueIds(IdNameMap &itemIdMap, const aiNode *parent, size_t index) { + IdNameString namePair = GetItemIdName(parent, index); + ReportDuplicate(itemIdMap, namePair, typeid(aiNode).name()); + + for (size_t idx = 0; idx < parent->mNumChildren; ++idx) { + CheckUniqueIds(itemIdMap, parent->mChildren[idx], idx); + } + } + + static inline void CheckNodeIdNames(IdNameMap &nodeIdMap, IdNameMap &nodeNameMap, const aiNode *parent, size_t index) { + IdNameString namePair = GetItemIdName(parent, index); + const auto result = nodeNameMap.insert(namePair); + IdNameString idPair = GetColladaIdName(parent, index); + ReportDuplicate(nodeIdMap, idPair, typeid(aiNode).name()); + + for (size_t idx = 0; idx < parent->mNumChildren; ++idx) { + CheckNodeIdNames(nodeIdMap, nodeNameMap, parent->mChildren[idx], idx); + } + } + + static inline void SetAllNodeNames(const aiString &newName, aiNode *node) { + node->mName = newName; + for (size_t idx = 0; idx < node->mNumChildren; ++idx) { + SetAllNodeNames(newName, node->mChildren[idx]); + } + } + + void ImportAndCheckIds(const char *file, const aiScene *origScene) { + // Import the Collada using the 'default' where aiNode and aiMesh names are the Collada ids + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(file, aiProcess_ValidateDataStructure); + ASSERT_TRUE(scene != nullptr) << "Fatal: could not re-import " << file; + EXPECT_EQ(origScene->mNumMeshes, scene->mNumMeshes) << "in " << file; + + // Check the ids are unique + IdNameMap itemIdMap; + // Recurse the Nodes + CheckUniqueIds(itemIdMap, scene->mRootNode, 0); + // Check the lists + CheckUniqueIds(itemIdMap, scene->mNumMeshes, scene->mMeshes); + // The remaining will come in using the name, which may not be unique + // Check we have the right number + EXPECT_EQ(origScene->mNumAnimations, scene->mNumAnimations); + EXPECT_EQ(origScene->mNumMaterials, scene->mNumMaterials); + EXPECT_EQ(origScene->mNumTextures, scene->mNumTextures); + EXPECT_EQ(origScene->mNumLights, scene->mNumLights); + EXPECT_EQ(origScene->mNumCameras, scene->mNumCameras); + } + + void ImportAsNames(const char *file, const aiScene *origScene) { + // Import the Collada but using the user-visible names for aiNode and aiMesh + // Note that this mode may not support bones or animations + Assimp::Importer importer; + importer.SetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES, 1); + + const aiScene *scene = importer.ReadFile(file, aiProcess_ValidateDataStructure); + ASSERT_TRUE(scene != nullptr) << "Fatal: could not re-import " << file; + EXPECT_EQ(origScene->mNumMeshes, scene->mNumMeshes) << "in " << file; + + // Check the node ids are unique but the node names are not + IdNameMap nodeIdMap; + IdNameMap nodeNameMap; + // Recurse the Nodes + CheckNodeIdNames(nodeIdMap, nodeNameMap, scene->mRootNode, 0); + + // nodeNameMap should have fewer than nodeIdMap + EXPECT_LT(nodeNameMap.size(), nodeIdMap.size()) << "Some nodes should have the same names"; + // Check the counts haven't changed + EXPECT_EQ(origScene->mNumAnimations, scene->mNumAnimations); + EXPECT_EQ(origScene->mNumMaterials, scene->mNumMaterials); + EXPECT_EQ(origScene->mNumTextures, scene->mNumTextures); + EXPECT_EQ(origScene->mNumLights, scene->mNumLights); + EXPECT_EQ(origScene->mNumCameras, scene->mNumCameras); + } }; -TEST_F(utColladaImportExport, importBlenFromFileTest) { +TEST_F(utColladaImportExport, importDaeFromFileTest) { EXPECT_TRUE(importerTest()); } +unsigned int GetMeshUseCount(const aiNode *rootNode) { + unsigned int result = rootNode->mNumMeshes; + for (unsigned int i = 0; i < rootNode->mNumChildren; ++i) { + result += GetMeshUseCount(rootNode->mChildren[i]); + } + return result; +} + +TEST_F(utColladaImportExport, exportRootNodeMeshTest) { + Assimp::Importer importer; + Assimp::Exporter exporter; + const char *outFile = "exportRootNodeMeshTest_out.dae"; + + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure); + ASSERT_TRUE(scene != nullptr) << "Fatal: could not import duck.dae!"; + + ASSERT_EQ(0u, scene->mRootNode->mNumMeshes) << "Collada import should not give the root node a mesh"; + + { + SceneCloner clone(scene); + ASSERT_TRUE(clone.sceneCopy != nullptr) << "Fatal: could not copy scene!"; + // Do this by moving the meshes from the first child that has some + aiNode *rootNode = clone.sceneCopy->mRootNode; + ASSERT_TRUE(rootNode->mNumChildren > 0) << "Fatal: root has no children"; + aiNode *meshNode = rootNode->mChildren[0]; + ASSERT_EQ(1u, meshNode->mNumMeshes) << "Fatal: First child node has no duck mesh"; + + // Move the meshes to the parent + rootNode->mNumMeshes = meshNode->mNumMeshes; + rootNode->mMeshes = new unsigned int[rootNode->mNumMeshes]; + for (unsigned int i = 0; i < rootNode->mNumMeshes; ++i) { + rootNode->mMeshes[i] = meshNode->mMeshes[i]; + } + + // Remove the meshes from the original node + meshNode->mNumMeshes = 0; + delete[] meshNode->mMeshes; + meshNode->mMeshes = nullptr; + + ASSERT_EQ(AI_SUCCESS, exporter.Export(clone.sceneCopy, "collada", outFile)) << "Fatal: Could not export file"; + } + + // Reimport and look for meshes + scene = importer.ReadFile(outFile, aiProcess_ValidateDataStructure); + ASSERT_TRUE(scene != nullptr) << "Fatal: could not reimport!"; + + // A Collada root node is not allowed to have a mesh + ASSERT_EQ(0u, scene->mRootNode->mNumMeshes) << "Collada reimport should not give the root node a mesh"; + + // Walk nodes and counts used meshes + // Should be exactly one + EXPECT_EQ(1u, GetMeshUseCount(scene->mRootNode)) << "Nodes had unexpected number of meshes in use"; +} + +TEST_F(utColladaImportExport, exporterUniqueIdsTest) { + Assimp::Importer importer; + Assimp::Exporter exporter; + const char *outFileEmpty = "exportMeshIdTest_empty_out.dae"; + const char *outFileNamed = "exportMeshIdTest_named_out.dae"; + + // Load a sample file containing multiple meshes + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/teapots.DAE", aiProcess_ValidateDataStructure); + + ASSERT_TRUE(scene != nullptr) << "Fatal: could not import teapots.DAE!"; + ASSERT_EQ(3u, scene->mNumMeshes) << "Fatal: teapots.DAE initial load failed"; + + // Clear all the names + for (size_t idx = 0; idx < scene->mNumMeshes; ++idx) { + scene->mMeshes[idx]->mName.Clear(); + } + for (size_t idx = 0; idx < scene->mNumMaterials; ++idx) { + scene->mMaterials[idx]->RemoveProperty(AI_MATKEY_NAME); + } + for (size_t idx = 0; idx < scene->mNumAnimations; ++idx) { + scene->mAnimations[idx]->mName.Clear(); + } + // Can't clear texture names + for (size_t idx = 0; idx < scene->mNumLights; ++idx) { + scene->mLights[idx]->mName.Clear(); + } + for (size_t idx = 0; idx < scene->mNumCameras; ++idx) { + scene->mCameras[idx]->mName.Clear(); + } + + SetAllNodeNames(aiString(), scene->mRootNode); + + ASSERT_EQ(AI_SUCCESS, exporter.Export(scene, "collada", outFileEmpty)) << "Fatal: Could not export un-named meshes file"; + + ImportAndCheckIds(outFileEmpty, scene); + + // Force everything to have the same non-empty name + aiString testName("test_name"); + for (size_t idx = 0; idx < scene->mNumMeshes; ++idx) { + scene->mMeshes[idx]->mName = testName; + } + for (size_t idx = 0; idx < scene->mNumMaterials; ++idx) { + scene->mMaterials[idx]->AddProperty(&testName, AI_MATKEY_NAME); + } + for (size_t idx = 0; idx < scene->mNumAnimations; ++idx) { + scene->mAnimations[idx]->mName = testName; + } + // Can't clear texture names + for (size_t idx = 0; idx < scene->mNumLights; ++idx) { + scene->mLights[idx]->mName = testName; + } + for (size_t idx = 0; idx < scene->mNumCameras; ++idx) { + scene->mCameras[idx]->mName = testName; + } + + SetAllNodeNames(testName, scene->mRootNode); + + ASSERT_EQ(AI_SUCCESS, exporter.Export(scene, "collada", outFileNamed)) << "Fatal: Could not export named meshes file"; + + ImportAndCheckIds(outFileNamed, scene); + ImportAsNames(outFileNamed, scene); +} + class utColladaZaeImportExport : public AbstractImportExportBase { public: - virtual bool importerTest() { + virtual bool importerTest() final { { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.zae", aiProcess_ValidateDataStructure); diff --git a/test/unit/utFindInvalidData.cpp b/test/unit/utFindInvalidData.cpp index e7dc123bb..17a9c0379 100644 --- a/test/unit/utFindInvalidData.cpp +++ b/test/unit/utFindInvalidData.cpp @@ -106,8 +106,10 @@ void utFindInvalidDataProcess::TearDown() { // ------------------------------------------------------------------------------------------------ TEST_F(utFindInvalidDataProcess, testStepNegativeResult) { - ::memset(mMesh->mNormals, 0, mMesh->mNumVertices * sizeof(aiVector3D)); - ::memset(mMesh->mBitangents, 0, mMesh->mNumVertices * sizeof(aiVector3D)); + for ( size_t i=0; imNumVertices; ++i ) { + mMesh->mNormals[i].x = mMesh->mNormals[i].y = mMesh->mNormals[i].z =0; + mMesh->mBitangents[i].x = mMesh->mBitangents[i].y = mMesh->mBitangents[i].z = 0; + } mMesh->mTextureCoords[2][455] = aiVector3D(std::numeric_limits::quiet_NaN()); diff --git a/test/unit/utMatrix3x3.cpp b/test/unit/utMatrix3x3.cpp index 50fa66c50..3905b1d35 100644 --- a/test/unit/utMatrix3x3.cpp +++ b/test/unit/utMatrix3x3.cpp @@ -73,9 +73,21 @@ TEST_F(utMatrix3x3Test, FromToMatrixTest) { aiVector3D from, to; + auto random_ratio = []() -> float { + return static_cast(rand()) / static_cast(RAND_MAX); + }; + for (int i = 0; i < NUM_SAMPLES; ++i) { - from = aiVector3D(1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX).Normalize(); - to = aiVector3D(1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX, 1.f * rand() / RAND_MAX).Normalize(); + from = aiVector3D( + 1.f * random_ratio(), + 1.f * random_ratio(), + 1.f * random_ratio()) + .Normalize(); + to = aiVector3D( + 1.f * random_ratio(), + 1.f * random_ratio(), + 1.f * random_ratio()) + .Normalize(); aiMatrix3x3::FromToMatrix(from, to, trafo); res = trafo * from; diff --git a/test/unit/utMetadata.cpp b/test/unit/utMetadata.cpp index a605107db..81ab61435 100644 --- a/test/unit/utMetadata.cpp +++ b/test/unit/utMetadata.cpp @@ -197,9 +197,11 @@ TEST_F( utMetadata, copy_test ) { m_data->Set( 5, "aiString", strVal ); aiVector3D vecVal( 1, 2, 3 ); m_data->Set( 6, "aiVector3D", vecVal ); + aiMetadata metaVal; + m_data->Set( 7, "aiMetadata", metaVal ); aiMetadata copy( *m_data ); - EXPECT_EQ( 7u, copy.mNumProperties ); + EXPECT_EQ( 8u, copy.mNumProperties ); // bool test { @@ -251,4 +253,11 @@ TEST_F( utMetadata, copy_test ) { EXPECT_TRUE( copy.Get( "aiVector3D", v ) ); EXPECT_EQ( vecVal, v ); } + + // metadata test + { + aiMetadata v; + EXPECT_TRUE( copy.Get( "aiMetadata", v ) ); + EXPECT_EQ( metaVal, v ); + } } diff --git a/test/unit/utRemoveComponent.cpp b/test/unit/utRemoveComponent.cpp index d3c102cfb..622a582d6 100644 --- a/test/unit/utRemoveComponent.cpp +++ b/test/unit/utRemoveComponent.cpp @@ -98,13 +98,6 @@ void RemoveVCProcessTest::SetUp() { pScene->mCameras = new aiCamera *[pScene->mNumCameras = 2]; pScene->mCameras[0] = new aiCamera(); pScene->mCameras[1] = new aiCamera(); - - // COMPILE TEST: aiMaterial may no add any extra members, - // so we don't need a virtual destructor - char check[sizeof(aiMaterial) == sizeof(aiMaterial) ? 10 : -1]; - check[0] = 0; - // to remove compiler warning - EXPECT_EQ(0, check[0]); } // ------------------------------------------------------------------------------------------------ diff --git a/test/unit/utTriangulate.cpp b/test/unit/utTriangulate.cpp index 7c5ba738c..a95331250 100644 --- a/test/unit/utTriangulate.cpp +++ b/test/unit/utTriangulate.cpp @@ -65,8 +65,7 @@ void TriangulateProcessTest::SetUp() { pcMesh->mFaces = new aiFace[1000]; pcMesh->mVertices = new aiVector3D[10000]; - pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE | - aiPrimitiveType_LINE | aiPrimitiveType_POLYGON; + pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE | aiPrimitiveType_POLYGON; for (unsigned int m = 0, t = 0, q = 4; m < 1000; ++m) { ++t; diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 55cd2ef6a..6791d5f89 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -436,6 +436,31 @@ TEST_F(utglTF2ImportExport, error_string_preserved) { ASSERT_NE(error.find("BoxTextured0.bin"), std::string::npos) << "Error string should contain an error about missing .bin file"; } +TEST_F(utglTF2ImportExport, export_bad_accessor_bounds) { + Assimp::Importer importer; + Assimp::Exporter exporter; + const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxWithInfinites-glTF-Binary/BoxWithInfinites.glb", aiProcess_ValidateDataStructure); + ASSERT_NE(scene, nullptr); + + EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxWithInfinites-glTF-Binary/BoxWithInfinites_out.glb")); + EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "gltf2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxWithInfinites-glTF-Binary/BoxWithInfinites_out.gltf")); +} + +TEST_F(utglTF2ImportExport, export_normalized_normals) { + Assimp::Importer importer; + Assimp::Exporter exporter; + const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxBadNormals-glTF-Binary/BoxBadNormals.glb", aiProcess_ValidateDataStructure); + ASSERT_NE(scene, nullptr); + EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxBadNormals-glTF-Binary/BoxBadNormals_out.glb")); + + // load in again and ensure normal-length normals but no Nan's or Inf's introduced + scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxBadNormals-glTF-Binary/BoxBadNormals_out.glb", aiProcess_ValidateDataStructure); + for ( auto i = 0u; i < scene->mMeshes[0]->mNumVertices; ++i ) { + const auto length = scene->mMeshes[0]->mNormals[i].Length(); + EXPECT_TRUE(abs(length) < 1e-6 || abs(length - 1) < 1e-6); + } +} + #endif // ASSIMP_BUILD_NO_EXPORT TEST_F(utglTF2ImportExport, sceneMetadata) { @@ -509,3 +534,10 @@ TEST_F(utglTF2ImportExport, norootnode_scenewithoutnodes) { ASSERT_NE(scene, nullptr); ASSERT_NE(scene->mRootNode, nullptr); } + +// Shall not crash! +TEST_F(utglTF2ImportExport, norootnode_issue_3269) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/issue_3269/texcoord_crash.gltf", aiProcess_ValidateDataStructure); + ASSERT_EQ(scene, nullptr); +} diff --git a/tools/assimp_view/AnimEvaluator.cpp b/tools/assimp_view/AnimEvaluator.cpp index 710950fe2..e97bdf290 100644 --- a/tools/assimp_view/AnimEvaluator.cpp +++ b/tools/assimp_view/AnimEvaluator.cpp @@ -47,10 +47,11 @@ using namespace AssimpView; // ------------------------------------------------------------------------------------------------ // Constructor on a given animation. -AnimEvaluator::AnimEvaluator( const aiAnimation *pAnim ) -: mAnim(pAnim) -, mLastTime(0.0) { - mLastPositions.resize( pAnim->mNumChannels, std::make_tuple( 0, 0, 0)); +AnimEvaluator::AnimEvaluator(const aiAnimation *pAnim) : + mAnim(pAnim), + mLastTime(0.0) { + ai_assert(nullptr != pAnim); + mLastPositions.resize(pAnim->mNumChannels, std::make_tuple(0, 0, 0)); } // ------------------------------------------------------------------------------------------------ @@ -61,7 +62,7 @@ AnimEvaluator::~AnimEvaluator() { // ------------------------------------------------------------------------------------------------ // Evaluates the animation tracks for a given time stamp. -void AnimEvaluator::Evaluate( double pTime ) { +void AnimEvaluator::Evaluate(double pTime) { // extract ticks per second. Assume default value if not given double ticksPerSecond = mAnim->mTicksPerSecond != 0.0 ? mAnim->mTicksPerSecond : 25.0; // every following time calculation happens in ticks @@ -78,16 +79,16 @@ void AnimEvaluator::Evaluate( double pTime ) { } // calculate the transformations for each animation channel - for( unsigned int a = 0; a < mAnim->mNumChannels; ++a ) { - const aiNodeAnim* channel = mAnim->mChannels[a]; + for (unsigned int a = 0; a < mAnim->mNumChannels; ++a) { + const aiNodeAnim *channel = mAnim->mChannels[a]; // ******** Position ***** - aiVector3D presentPosition( 0, 0, 0); - if( channel->mNumPositionKeys > 0) { + aiVector3D presentPosition(0, 0, 0); + if (channel->mNumPositionKeys > 0) { // Look for present frame number. Search from last position if time is after the last time, else from beginning // Should be much quicker than always looking from start for the average use case. unsigned int frame = (time >= mLastTime) ? std::get<0>(mLastPositions[a]) : 0; - while( frame < channel->mNumPositionKeys - 1) { + while (frame < channel->mNumPositionKeys - 1) { if (time < channel->mPositionKeys[frame + 1].mTime) { break; } @@ -96,14 +97,14 @@ void AnimEvaluator::Evaluate( double pTime ) { // interpolate between this frame's value and next frame's value unsigned int nextFrame = (frame + 1) % channel->mNumPositionKeys; - const aiVectorKey& key = channel->mPositionKeys[frame]; - const aiVectorKey& nextKey = channel->mPositionKeys[nextFrame]; + const aiVectorKey &key = channel->mPositionKeys[frame]; + const aiVectorKey &nextKey = channel->mPositionKeys[nextFrame]; double diffTime = nextKey.mTime - key.mTime; if (diffTime < 0.0) { diffTime += mAnim->mDuration; } - if( diffTime > 0) { - float factor = float( (time - key.mTime) / diffTime); + if (diffTime > 0) { + float factor = float((time - key.mTime) / diffTime); presentPosition = key.mValue + (nextKey.mValue - key.mValue) * factor; } else { presentPosition = key.mValue; @@ -113,10 +114,10 @@ void AnimEvaluator::Evaluate( double pTime ) { } // ******** Rotation ********* - aiQuaternion presentRotation( 1, 0, 0, 0); - if( channel->mNumRotationKeys > 0) { + aiQuaternion presentRotation(1, 0, 0, 0); + if (channel->mNumRotationKeys > 0) { unsigned int frame = (time >= mLastTime) ? std::get<1>(mLastPositions[a]) : 0; - while( frame < channel->mNumRotationKeys - 1) { + while (frame < channel->mNumRotationKeys - 1) { if (time < channel->mRotationKeys[frame + 1].mTime) { break; } @@ -125,15 +126,15 @@ void AnimEvaluator::Evaluate( double pTime ) { // interpolate between this frame's value and next frame's value unsigned int nextFrame = (frame + 1) % channel->mNumRotationKeys; - const aiQuatKey& key = channel->mRotationKeys[frame]; - const aiQuatKey& nextKey = channel->mRotationKeys[nextFrame]; + const aiQuatKey &key = channel->mRotationKeys[frame]; + const aiQuatKey &nextKey = channel->mRotationKeys[nextFrame]; double diffTime = nextKey.mTime - key.mTime; if (diffTime < 0.0) { diffTime += mAnim->mDuration; } - if( diffTime > 0) { - float factor = float( (time - key.mTime) / diffTime); - aiQuaternion::Interpolate( presentRotation, key.mValue, nextKey.mValue, factor); + if (diffTime > 0) { + float factor = float((time - key.mTime) / diffTime); + aiQuaternion::Interpolate(presentRotation, key.mValue, nextKey.mValue, factor); } else { presentRotation = key.mValue; } @@ -142,10 +143,10 @@ void AnimEvaluator::Evaluate( double pTime ) { } // ******** Scaling ********** - aiVector3D presentScaling( 1, 1, 1); - if( channel->mNumScalingKeys > 0) { + aiVector3D presentScaling(1, 1, 1); + if (channel->mNumScalingKeys > 0) { unsigned int frame = (time >= mLastTime) ? std::get<2>(mLastPositions[a]) : 0; - while( frame < channel->mNumScalingKeys - 1) { + while (frame < channel->mNumScalingKeys - 1) { if (time < channel->mScalingKeys[frame + 1].mTime) { break; } @@ -158,12 +159,20 @@ void AnimEvaluator::Evaluate( double pTime ) { } // build a transformation matrix from it - aiMatrix4x4& mat = mTransforms[a]; - mat = aiMatrix4x4( presentRotation.GetMatrix()); - mat.a1 *= presentScaling.x; mat.b1 *= presentScaling.x; mat.c1 *= presentScaling.x; - mat.a2 *= presentScaling.y; mat.b2 *= presentScaling.y; mat.c2 *= presentScaling.y; - mat.a3 *= presentScaling.z; mat.b3 *= presentScaling.z; mat.c3 *= presentScaling.z; - mat.a4 = presentPosition.x; mat.b4 = presentPosition.y; mat.c4 = presentPosition.z; + aiMatrix4x4 &mat = mTransforms[a]; + mat = aiMatrix4x4(presentRotation.GetMatrix()); + mat.a1 *= presentScaling.x; + mat.b1 *= presentScaling.x; + mat.c1 *= presentScaling.x; + mat.a2 *= presentScaling.y; + mat.b2 *= presentScaling.y; + mat.c2 *= presentScaling.y; + mat.a3 *= presentScaling.z; + mat.b3 *= presentScaling.z; + mat.c3 *= presentScaling.z; + mat.a4 = presentPosition.x; + mat.b4 = presentPosition.y; + mat.c4 = presentPosition.z; } mLastTime = time; diff --git a/tools/assimp_view/AnimEvaluator.h b/tools/assimp_view/AnimEvaluator.h index 9267853e1..12bb91c30 100644 --- a/tools/assimp_view/AnimEvaluator.h +++ b/tools/assimp_view/AnimEvaluator.h @@ -58,7 +58,7 @@ public: /// the object. /// @param pAnim The animation to calculate poses for. Ownership of the animation object stays /// at the caller, the evaluator just keeps a reference to it as long as it persists. - AnimEvaluator( const aiAnimation* pAnim); + AnimEvaluator(const aiAnimation *pAnim); /// @brief The class destructor. ~AnimEvaluator(); @@ -68,16 +68,16 @@ public: * @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so * it can be an arbitrary value. Best use with ever-increasing time stamps. */ - void Evaluate( double pTime); + void Evaluate(double pTime); /** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of * the aiAnimation. */ - const std::vector& GetTransformations() const { return mTransforms; } + const std::vector &GetTransformations() const { return mTransforms; } protected: - const aiAnimation* mAnim; + const aiAnimation *mAnim; double mLastTime; - std::vector > mLastPositions; + std::vector> mLastPositions; std::vector mTransforms; }; diff --git a/tools/assimp_view/AssetHelper.h b/tools/assimp_view/AssetHelper.h index 7731e44e5..fe3761cfd 100644 --- a/tools/assimp_view/AssetHelper.h +++ b/tools/assimp_view/AssetHelper.h @@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------- */ - #if (!defined AV_ASSET_HELPER_H_INCLUDED) #define AV_ASSET_HELPER_H_INCLUDED @@ -51,200 +50,187 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace AssimpView { - class SceneAnimator; +class SceneAnimator; - //------------------------------------------------------------------------------- - /** \brief Class to wrap ASSIMP's asset output structures +//------------------------------------------------------------------------------- +/** \brief Class to wrap ASSIMP's asset output structures */ - //------------------------------------------------------------------------------- - class AssetHelper - { - public: - enum - { - // the original normal set will be used - ORIGINAL = 0x0u, +//------------------------------------------------------------------------------- +class AssetHelper { +public: + enum { + // the original normal set will be used + ORIGINAL = 0x0u, - // a smoothed normal set will be used - SMOOTH = 0x1u, + // a smoothed normal set will be used + SMOOTH = 0x1u, - // a hard normal set will be used - HARD = 0x2u, - }; + // a hard normal set will be used + HARD = 0x2u, + }; - // default constructor - AssetHelper() - : iNormalSet( ORIGINAL ) - { - mAnimator = NULL; - apcMeshes = NULL; - pcScene = NULL; + // default constructor + AssetHelper() : + iNormalSet(ORIGINAL) { + mAnimator = NULL; + apcMeshes = NULL; + pcScene = NULL; + } + + //--------------------------------------------------------------- + // default vertex data structure + // (even if tangents, bitangents or normals aren't + // required by the shader they will be committed to the GPU) + //--------------------------------------------------------------- + struct Vertex { + aiVector3D vPosition; + aiVector3D vNormal; + + D3DCOLOR dColorDiffuse; + aiVector3D vTangent; + aiVector3D vBitangent; + aiVector2D vTextureUV; + aiVector2D vTextureUV2; + unsigned char mBoneIndices[4]; + unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader + + /** Returns the vertex declaration elements to create a declaration from. */ + static D3DVERTEXELEMENT9 *GetDeclarationElements() { + static D3DVERTEXELEMENT9 decl[] = { + { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, + { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, + { 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 }, + { 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 }, + { 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 }, + { 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, + { 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 }, + { 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 }, + { 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 }, + D3DDECL_END() + }; + + return decl; } + }; - //--------------------------------------------------------------- - // default vertex data structure - // (even if tangents, bitangents or normals aren't - // required by the shader they will be committed to the GPU) - //--------------------------------------------------------------- - struct Vertex - { - aiVector3D vPosition; - aiVector3D vNormal; + //--------------------------------------------------------------- + // FVF vertex structure used for normals + //--------------------------------------------------------------- + struct LineVertex { + aiVector3D vPosition; + DWORD dColorDiffuse; - D3DCOLOR dColorDiffuse; - aiVector3D vTangent; - aiVector3D vBitangent; - aiVector2D vTextureUV; - aiVector2D vTextureUV2; - unsigned char mBoneIndices[ 4 ]; - unsigned char mBoneWeights[ 4 ]; // last Weight not used, calculated inside the vertex shader + // retrieves the FVF code of the vertex type + static DWORD GetFVF() { + return D3DFVF_DIFFUSE | D3DFVF_XYZ; + } + }; - /** Returns the vertex declaration elements to create a declaration from. */ - static D3DVERTEXELEMENT9* GetDeclarationElements() - { - static D3DVERTEXELEMENT9 decl[] = - { - { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, - { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, - { 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 }, - { 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 }, - { 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 }, - { 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, - { 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 }, - { 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 }, - { 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 }, - D3DDECL_END() - }; - - return decl; - } - }; - - //--------------------------------------------------------------- - // FVF vertex structure used for normals - //--------------------------------------------------------------- - struct LineVertex - { - aiVector3D vPosition; - DWORD dColorDiffuse; - - // retrieves the FVF code of the vertex type - static DWORD GetFVF() - { - return D3DFVF_DIFFUSE | D3DFVF_XYZ; - } - }; - - //--------------------------------------------------------------- - // Helper class to store GPU related resources created for - // a given aiMesh - //--------------------------------------------------------------- - class MeshHelper - { - public: - - MeshHelper() - : + //--------------------------------------------------------------- + // Helper class to store GPU related resources created for + // a given aiMesh + //--------------------------------------------------------------- + class MeshHelper { + public: + MeshHelper() : eShadingMode(), - piVB( NULL ), - piIB( NULL ), - piVBNormals( NULL ), - piEffect( NULL ), - bSharedFX( false ), - piDiffuseTexture( NULL ), - piSpecularTexture( NULL ), - piAmbientTexture( NULL ), - piEmissiveTexture( NULL ), - piNormalTexture( NULL ), - piOpacityTexture( NULL ), - piShininessTexture( NULL ), - piLightmapTexture( NULL ), + piVB(NULL), + piIB(NULL), + piVBNormals(NULL), + piEffect(NULL), + bSharedFX(false), + piDiffuseTexture(NULL), + piSpecularTexture(NULL), + piAmbientTexture(NULL), + piEmissiveTexture(NULL), + piNormalTexture(NULL), + piOpacityTexture(NULL), + piShininessTexture(NULL), + piLightmapTexture(NULL), fOpacity(), fShininess(), fSpecularStrength(), - twosided( false ), - pvOriginalNormals( NULL ) - {} + twosided(false), + pvOriginalNormals(NULL) {} - ~MeshHelper() - { - // NOTE: This is done in DeleteAssetData() - // TODO: Make this a proper d'tor - } + ~MeshHelper() { + // NOTE: This is done in DeleteAssetData() + // TODO: Make this a proper d'tor + } - // shading mode to use. Either Lambert or otherwise phong - // will be used in every case - aiShadingMode eShadingMode; + // shading mode to use. Either Lambert or otherwise phong + // will be used in every case + aiShadingMode eShadingMode; - // vertex buffer - IDirect3DVertexBuffer9* piVB; + // vertex buffer + IDirect3DVertexBuffer9 *piVB; - // index buffer. For partially transparent meshes - // created with dynamic usage to be able to update - // the buffer contents quickly - IDirect3DIndexBuffer9* piIB; + // index buffer. For partially transparent meshes + // created with dynamic usage to be able to update + // the buffer contents quickly + IDirect3DIndexBuffer9 *piIB; - // vertex buffer to be used to draw vertex normals - // (vertex normals are generated in every case) - IDirect3DVertexBuffer9* piVBNormals; + // vertex buffer to be used to draw vertex normals + // (vertex normals are generated in every case) + IDirect3DVertexBuffer9 *piVBNormals; - // shader to be used - ID3DXEffect* piEffect; - bool bSharedFX; + // shader to be used + ID3DXEffect *piEffect; + bool bSharedFX; - // material textures - IDirect3DTexture9* piDiffuseTexture; - IDirect3DTexture9* piSpecularTexture; - IDirect3DTexture9* piAmbientTexture; - IDirect3DTexture9* piEmissiveTexture; - IDirect3DTexture9* piNormalTexture; - IDirect3DTexture9* piOpacityTexture; - IDirect3DTexture9* piShininessTexture; - IDirect3DTexture9* piLightmapTexture; + // material textures + IDirect3DTexture9 *piDiffuseTexture; + IDirect3DTexture9 *piSpecularTexture; + IDirect3DTexture9 *piAmbientTexture; + IDirect3DTexture9 *piEmissiveTexture; + IDirect3DTexture9 *piNormalTexture; + IDirect3DTexture9 *piOpacityTexture; + IDirect3DTexture9 *piShininessTexture; + IDirect3DTexture9 *piLightmapTexture; - // material colors - D3DXVECTOR4 vDiffuseColor; - D3DXVECTOR4 vSpecularColor; - D3DXVECTOR4 vAmbientColor; - D3DXVECTOR4 vEmissiveColor; + // material colors + D3DXVECTOR4 vDiffuseColor; + D3DXVECTOR4 vSpecularColor; + D3DXVECTOR4 vAmbientColor; + D3DXVECTOR4 vEmissiveColor; - // opacity for the material - float fOpacity; + // opacity for the material + float fOpacity; - // shininess for the material - float fShininess; + // shininess for the material + float fShininess; - // strength of the specular highlight - float fSpecularStrength; + // strength of the specular highlight + float fSpecularStrength; - // two-sided? - bool twosided; + // two-sided? + bool twosided; - // Stores a pointer to the original normal set of the asset - aiVector3D* pvOriginalNormals; - }; - - // One instance per aiMesh in the globally loaded asset - MeshHelper** apcMeshes; - - // Scene wrapper instance - aiScene* pcScene; - - // Animation player to animate the scene if necessary - SceneAnimator* mAnimator; - - // Specifies the normal set to be used - unsigned int iNormalSet; - - // ------------------------------------------------------------------ - // set the normal set to be used - void SetNormalSet( unsigned int iSet ); - - // ------------------------------------------------------------------ - // flip all normal vectors - void FlipNormals(); - void FlipNormalsInt(); + // Stores a pointer to the original normal set of the asset + aiVector3D *pvOriginalNormals; }; -} + + // One instance per aiMesh in the globally loaded asset + MeshHelper **apcMeshes; + + // Scene wrapper instance + aiScene *pcScene; + + // Animation player to animate the scene if necessary + SceneAnimator *mAnimator; + + // Specifies the normal set to be used + unsigned int iNormalSet; + + // ------------------------------------------------------------------ + // set the normal set to be used + void SetNormalSet(unsigned int iSet); + + // ------------------------------------------------------------------ + // flip all normal vectors + void FlipNormals(); + void FlipNormalsInt(); +}; +} // namespace AssimpView #endif // !! IG diff --git a/tools/assimp_view/Background.cpp b/tools/assimp_view/Background.cpp index 3cf0a81e3..fe6e68c09 100644 --- a/tools/assimp_view/Background.cpp +++ b/tools/assimp_view/Background.cpp @@ -118,8 +118,9 @@ CBackgroundPainter CBackgroundPainter::s_cInstance; //------------------------------------------------------------------------------- void CBackgroundPainter::SetColor(D3DCOLOR p_clrNew) { - if (TEXTURE_CUBE == eMode) + if (TEXTURE_CUBE == eMode) { RemoveSBDeps(); + } clrColor = p_clrNew; eMode = SIMPLE_COLOR; diff --git a/tools/assimp_view/Camera.h b/tools/assimp_view/Camera.h index dd82af029..9c3103827 100644 --- a/tools/assimp_view/Camera.h +++ b/tools/assimp_view/Camera.h @@ -82,4 +82,4 @@ class Camera } ; -#endif // !!IG \ No newline at end of file +#endif // !!IG diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 9fa157c41..1f6bb89eb 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -462,7 +462,7 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType, TVINSERTSTRUCT sNew; tvi.pszText = chTemp; tvi.cchTextMax = (int)strlen(chTemp); - tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE | TVIF_HANDLE; + tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE; tvi.lParam = (LPARAM)20; // find out whether this is the default texture or not diff --git a/tools/assimp_view/Display.h b/tools/assimp_view/Display.h index f52e65e42..1ca29f498 100644 --- a/tools/assimp_view/Display.h +++ b/tools/assimp_view/Display.h @@ -539,4 +539,4 @@ namespace AssimpView }; } -#endif // AV_DISPLAY_H_INCLUDE \ No newline at end of file +#endif // AV_DISPLAY_H_INCLUDE diff --git a/tools/assimp_view/Input.cpp b/tools/assimp_view/Input.cpp index 505433404..f9f463412 100644 --- a/tools/assimp_view/Input.cpp +++ b/tools/assimp_view/Input.cpp @@ -369,4 +369,4 @@ void HandleKeyboardInputTextureView( void ) if( keys[VK_RIGHT] & 0x80 ) CDisplay::Instance().SetTextureViewOffsetX ( -g_fElpasedTime * 150.0f ); } -}; \ No newline at end of file +}; diff --git a/tools/assimp_view/LogWindow.h b/tools/assimp_view/LogWindow.h index 671d8be8f..5b2a3d2d3 100644 --- a/tools/assimp_view/LogWindow.h +++ b/tools/assimp_view/LogWindow.h @@ -130,4 +130,4 @@ namespace AssimpView } -#endif // AV_LOG_DISPLA \ No newline at end of file +#endif // AV_LOG_DISPLA diff --git a/tools/assimp_view/MaterialManager.h b/tools/assimp_view/MaterialManager.h index fb3fcb38f..107c4d9f0 100644 --- a/tools/assimp_view/MaterialManager.h +++ b/tools/assimp_view/MaterialManager.h @@ -45,164 +45,154 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "AssetHelper.h" -namespace AssimpView -{ +namespace AssimpView { - //------------------------------------------------------------------------------- - /* Helper class to create, access and destroy materials +//------------------------------------------------------------------------------- +/* Helper class to create, access and destroy materials */ - //------------------------------------------------------------------------------- - class CMaterialManager - { - private: +//------------------------------------------------------------------------------- +class CMaterialManager { +private: + friend class CDisplay; - friend class CDisplay; + // default constructor + CMaterialManager() : + m_iShaderCount(0), sDefaultTexture() {} - // default constructor - CMaterialManager() - : m_iShaderCount( 0 ), sDefaultTexture() {} - - ~CMaterialManager() { - if( sDefaultTexture ) { - sDefaultTexture->Release(); - } - Reset(); + ~CMaterialManager() { + if (sDefaultTexture) { + sDefaultTexture->Release(); } + Reset(); + } - public: +public: + //------------------------------------------------------------------ + // Singleton accessors + static CMaterialManager s_cInstance; + inline static CMaterialManager &Instance() { + return s_cInstance; + } - //------------------------------------------------------------------ - // Singleton accessors - static CMaterialManager s_cInstance; - inline static CMaterialManager& Instance() - { - return s_cInstance; + //------------------------------------------------------------------ + // Delete all resources of a given material + // + // Must be called before CreateMaterial() to prevent memory leaking + void DeleteMaterial(AssetHelper::MeshHelper *pcIn); + + //------------------------------------------------------------------ + // Create the material for a mesh. + // + // The function checks whether an identical shader is already in use. + // A shader is considered to be identical if it has the same input + // signature and takes the same number of texture channels. + int CreateMaterial(AssetHelper::MeshHelper *pcMesh, + const aiMesh *pcSource); + + //------------------------------------------------------------------ + // Setup the material for a given mesh + // pcMesh Mesh to be rendered + // pcProj Projection matrix + // aiMe Current world matrix + // pcCam Camera matrix + // vPos Position of the camera + // TODO: Extract camera position from matrix ... + // + int SetupMaterial(AssetHelper::MeshHelper *pcMesh, + const aiMatrix4x4 &pcProj, + const aiMatrix4x4 &aiMe, + const aiMatrix4x4 &pcCam, + const aiVector3D &vPos); + + //------------------------------------------------------------------ + // End the material for a given mesh + // Called after mesh rendering is complete + // pcMesh Mesh object + int EndMaterial(AssetHelper::MeshHelper *pcMesh); + + //------------------------------------------------------------------ + // Recreate all specular materials depending on the current + // specularity settings + // + // Diffuse-only materials are ignored. + // Must be called after specular highlights have been toggled + int UpdateSpecularMaterials(); + + //------------------------------------------------------------------ + // find a valid path to a texture file + // + // Handle 8.3 syntax correctly, search the environment of the + // executable and the asset for a texture with a name very similar + // to a given one + int FindValidPath(aiString *p_szString); + + //------------------------------------------------------------------ + // Load a texture into memory and create a native D3D texture resource + // + // The function tries to find a valid path for a texture + int LoadTexture(IDirect3DTexture9 **p_ppiOut, aiString *szPath); + + //------------------------------------------------------------------ + // Getter for m_iShaderCount + // + inline unsigned int GetShaderCount() { + return this->m_iShaderCount; + } + + //------------------------------------------------------------------ + // Reset the state of the class + // Called whenever a new asset is loaded + inline void Reset() { + this->m_iShaderCount = 0; + for (TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it) { + (*it).second->Release(); } + sCachedTextures.clear(); + } - //------------------------------------------------------------------ - // Delete all resources of a given material - // - // Must be called before CreateMaterial() to prevent memory leaking - void DeleteMaterial( AssetHelper::MeshHelper* pcIn ); +private: + //------------------------------------------------------------------ + // find a valid path to a texture file + // + // Handle 8.3 syntax correctly, search the environment of the + // executable and the asset for a texture with a name very similar + // to a given one + bool TryLongerPath(char *szTemp, aiString *p_szString); - //------------------------------------------------------------------ - // Create the material for a mesh. - // - // The function checks whether an identical shader is already in use. - // A shader is considered to be identical if it has the same input - // signature and takes the same number of texture channels. - int CreateMaterial( AssetHelper::MeshHelper* pcMesh, - const aiMesh* pcSource ); + //------------------------------------------------------------------ + // Setup the default texture for a texture channel + // + // Generates a default checker pattern for a texture + int SetDefaultTexture(IDirect3DTexture9 **p_ppiOut); - //------------------------------------------------------------------ - // Setup the material for a given mesh - // pcMesh Mesh to be rendered - // pcProj Projection matrix - // aiMe Current world matrix - // pcCam Camera matrix - // vPos Position of the camera - // TODO: Extract camera position from matrix ... - // - int SetupMaterial( AssetHelper::MeshHelper* pcMesh, - const aiMatrix4x4& pcProj, - const aiMatrix4x4& aiMe, - const aiMatrix4x4& pcCam, - const aiVector3D& vPos ); + //------------------------------------------------------------------ + // Convert a height map to a normal map if necessary + // + // The function tries to detect the type of a texture automatically. + // However, this won't work in every case. + void HMtoNMIfNecessary(IDirect3DTexture9 *piTexture, + IDirect3DTexture9 **piTextureOut, + bool bWasOriginallyHM = true); - //------------------------------------------------------------------ - // End the material for a given mesh - // Called after mesh rendering is complete - // pcMesh Mesh object - int EndMaterial( AssetHelper::MeshHelper* pcMesh ); + //------------------------------------------------------------------ + // Search for non-opaque pixels in a texture + // + // A pixel is considered to be non-opaque if its alpha value is + // less than 255 + //------------------------------------------------------------------ + bool HasAlphaPixels(IDirect3DTexture9 *piTexture); - //------------------------------------------------------------------ - // Recreate all specular materials depending on the current - // specularity settings - // - // Diffuse-only materials are ignored. - // Must be called after specular highlights have been toggled - int UpdateSpecularMaterials(); +private: + // + // Specifies the number of different shaders generated for + // the current asset. This number is incremented by CreateMaterial() + // each time a shader isn't found in cache and needs to be created + // + unsigned int m_iShaderCount; + IDirect3DTexture9 *sDefaultTexture; - //------------------------------------------------------------------ - // find a valid path to a texture file - // - // Handle 8.3 syntax correctly, search the environment of the - // executable and the asset for a texture with a name very similar - // to a given one - int FindValidPath( aiString* p_szString ); + typedef std::map TextureCache; + TextureCache sCachedTextures; +}; - //------------------------------------------------------------------ - // Load a texture into memory and create a native D3D texture resource - // - // The function tries to find a valid path for a texture - int LoadTexture( IDirect3DTexture9** p_ppiOut, aiString* szPath ); - - - //------------------------------------------------------------------ - // Getter for m_iShaderCount - // - inline unsigned int GetShaderCount() - { - return this->m_iShaderCount; - } - - //------------------------------------------------------------------ - // Reset the state of the class - // Called whenever a new asset is loaded - inline void Reset() - { - this->m_iShaderCount = 0; - for( TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it ) { - ( *it ).second->Release(); - } - sCachedTextures.clear(); - } - - private: - - //------------------------------------------------------------------ - // find a valid path to a texture file - // - // Handle 8.3 syntax correctly, search the environment of the - // executable and the asset for a texture with a name very similar - // to a given one - bool TryLongerPath( char* szTemp, aiString* p_szString ); - - //------------------------------------------------------------------ - // Setup the default texture for a texture channel - // - // Generates a default checker pattern for a texture - int SetDefaultTexture( IDirect3DTexture9** p_ppiOut ); - - //------------------------------------------------------------------ - // Convert a height map to a normal map if necessary - // - // The function tries to detect the type of a texture automatically. - // However, this won't work in every case. - void HMtoNMIfNecessary( IDirect3DTexture9* piTexture, - IDirect3DTexture9** piTextureOut, - bool bWasOriginallyHM = true ); - - //------------------------------------------------------------------ - // Search for non-opaque pixels in a texture - // - // A pixel is considered to be non-opaque if its alpha value is - // less than 255 - //------------------------------------------------------------------ - bool HasAlphaPixels( IDirect3DTexture9* piTexture ); - - private: - - // - // Specifies the number of different shaders generated for - // the current asset. This number is incremented by CreateMaterial() - // each time a shader isn't found in cache and needs to be created - // - unsigned int m_iShaderCount; - IDirect3DTexture9* sDefaultTexture; - - typedef std::map TextureCache; - TextureCache sCachedTextures; - }; - -} +} // namespace AssimpView diff --git a/tools/assimp_view/MeshRenderer.cpp b/tools/assimp_view/MeshRenderer.cpp index 27bc6704f..d93bb4aea 100644 --- a/tools/assimp_view/MeshRenderer.cpp +++ b/tools/assimp_view/MeshRenderer.cpp @@ -161,4 +161,4 @@ int CMeshRenderer::DrawSorted(unsigned int iIndex,const aiMatrix4x4& mWorld) { return 1; } -}; \ No newline at end of file +}; diff --git a/tools/assimp_view/MeshRenderer.h b/tools/assimp_view/MeshRenderer.h index 38cfa6326..d756a9984 100644 --- a/tools/assimp_view/MeshRenderer.h +++ b/tools/assimp_view/MeshRenderer.h @@ -96,4 +96,4 @@ namespace AssimpView { }; } -#endif //!! include guard \ No newline at end of file +#endif //!! include guard diff --git a/tools/assimp_view/NOTE@help.rtf.txt b/tools/assimp_view/NOTE@help.rtf.txt index f00962db6..dd20078e9 100644 --- a/tools/assimp_view/NOTE@help.rtf.txt +++ b/tools/assimp_view/NOTE@help.rtf.txt @@ -1,2 +1,2 @@ text1.bin is the corresponding bin file to be included with the executable file. -When updating the rich formatted text inside Visual Studio, a terminating 0 character must be appended \ No newline at end of file +When updating the rich formatted text inside Visual Studio, a terminating 0 character must be appended diff --git a/tools/assimp_view/RenderOptions.h b/tools/assimp_view/RenderOptions.h index bd9e8a871..69297419e 100644 --- a/tools/assimp_view/RenderOptions.h +++ b/tools/assimp_view/RenderOptions.h @@ -110,4 +110,4 @@ class RenderOptions bool bCulling,bSkeleton; }; -#endif // !! IG \ No newline at end of file +#endif // !! IG diff --git a/tools/assimp_view/SceneAnimator.h b/tools/assimp_view/SceneAnimator.h index 956edb3e3..33b8568a4 100644 --- a/tools/assimp_view/SceneAnimator.h +++ b/tools/assimp_view/SceneAnimator.h @@ -58,8 +58,8 @@ namespace AssimpView { */ struct SceneAnimNode { std::string mName; - SceneAnimNode* mParent; - std::vector mChildren; + SceneAnimNode *mParent; + std::vector mChildren; //! most recently calculated local transform aiMatrix4x4 mLocalTransform; @@ -71,30 +71,20 @@ struct SceneAnimNode { int mChannelIndex; //! Default construction - SceneAnimNode() - : mName() - , mParent(nullptr) - , mChildren() - , mLocalTransform() - , mGlobalTransform() - , mChannelIndex(-1) { + SceneAnimNode() : + mName(), mParent(nullptr), mChildren(), mLocalTransform(), mGlobalTransform(), mChannelIndex(-1) { // empty } //! Construction from a given name - SceneAnimNode( const std::string& pName) - : mName( pName) - , mParent(nullptr) - , mChildren() - , mLocalTransform() - , mGlobalTransform() - , mChannelIndex(-1) { + SceneAnimNode(const std::string &pName) : + mName(pName), mParent(nullptr), mChildren(), mLocalTransform(), mGlobalTransform(), mChannelIndex(-1) { // empty } //! Destruct all children recursively ~SceneAnimNode() { - for (std::vector::iterator it = mChildren.begin(); it != mChildren.end(); ++it) { + for (std::vector::iterator it = mChildren.begin(); it != mChildren.end(); ++it) { delete *it; } } @@ -112,7 +102,6 @@ struct SceneAnimNode { */ class SceneAnimator { public: - // ---------------------------------------------------------------------------- /** Constructor for a given scene. * @@ -122,7 +111,7 @@ public: * @param pAnimIndex [optional] Index of the animation to play. Assumed to * be 0 if not given. */ - SceneAnimator( const aiScene* pScene, size_t pAnimIndex = 0); + SceneAnimator(const aiScene *pScene, size_t pAnimIndex = 0); /** Destructor */ ~SceneAnimator(); @@ -132,14 +121,14 @@ public: * mapping structures, which might take a few cycles. * @param pAnimIndex Index of the animation in the scene's animation array */ - void SetAnimIndex( size_t pAnimIndex); + void SetAnimIndex(size_t pAnimIndex); // ---------------------------------------------------------------------------- /** Calculates the node transformations for the scene. Call this to get * uptodate results before calling one of the getters. * @param pTime Current time. Can be an arbitrary range. */ - void Calculate( double pTime); + void Calculate(double pTime); // ---------------------------------------------------------------------------- /** Retrieves the most recent local transformation matrix for the given node. @@ -154,7 +143,7 @@ public: * @return A reference to the node's most recently calculated local * transformation matrix. */ - const aiMatrix4x4& GetLocalTransform( const aiNode* node) const; + const aiMatrix4x4 &GetLocalTransform(const aiNode *node) const; // ---------------------------------------------------------------------------- /** Retrieves the most recent global transformation matrix for the given node. @@ -169,7 +158,7 @@ public: * @return A reference to the node's most recently calculated global * transformation matrix. */ - const aiMatrix4x4& GetGlobalTransform( const aiNode* node) const; + const aiMatrix4x4 &GetGlobalTransform(const aiNode *node) const; // ---------------------------------------------------------------------------- /** Calculates the bone matrices for the given mesh. @@ -187,8 +176,8 @@ public: * @return A reference to a vector of bone matrices. Stays stable till the * next call to GetBoneMatrices(); */ - const std::vector& GetBoneMatrices( const aiNode* pNode, - size_t pMeshIndex = 0); + const std::vector &GetBoneMatrices(const aiNode *pNode, + size_t pMeshIndex = 0); // ---------------------------------------------------------------------------- /** @brief Get the current animation index @@ -200,44 +189,43 @@ public: // ---------------------------------------------------------------------------- /** @brief Get the current animation or NULL */ - aiAnimation* CurrentAnim() const { - return static_cast( mCurrentAnimIndex ) < mScene->mNumAnimations ? mScene->mAnimations[ mCurrentAnimIndex ] : NULL; + aiAnimation *CurrentAnim() const { + return static_cast(mCurrentAnimIndex) < mScene->mNumAnimations ? mScene->mAnimations[mCurrentAnimIndex] : NULL; } protected: - /** Recursively creates an internal node structure matching the * current scene and animation. */ - SceneAnimNode* CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent); + SceneAnimNode *CreateNodeTree(aiNode *pNode, SceneAnimNode *pParent); /** Recursively updates the internal node transformations from the * given matrix array */ - void UpdateTransforms( SceneAnimNode* pNode, const std::vector& pTransforms); + void UpdateTransforms(SceneAnimNode *pNode, const std::vector &pTransforms); /** Calculates the global transformation matrix for the given internal node */ - void CalculateGlobalTransform( SceneAnimNode* pInternalNode); + void CalculateGlobalTransform(SceneAnimNode *pInternalNode); protected: /** The scene we're operating on */ - const aiScene* mScene; + const aiScene *mScene; /** Current animation index */ int mCurrentAnimIndex; /** The AnimEvaluator we use to calculate the current pose for the current animation */ - AnimEvaluator* mAnimEvaluator; + AnimEvaluator *mAnimEvaluator; /** Root node of the internal scene structure */ - SceneAnimNode* mRootNode; + SceneAnimNode *mRootNode; /** Name to node map to quickly find nodes by their name */ - typedef std::map NodeMap; + typedef std::map NodeMap; NodeMap mNodesByName; /** Name to node map to quickly find nodes for given bones by their name */ - typedef std::map BoneMap; + typedef std::map BoneMap; BoneMap mBoneNodesByName; /** Array to return transformations results inside. */ @@ -246,4 +234,4 @@ protected: } // end of namespace AssimpView -#endif // AV_SCENEANIMATOR_H_INCLUDED \ No newline at end of file +#endif // AV_SCENEANIMATOR_H_INCLUDED diff --git a/tools/assimp_view/Shaders.cpp b/tools/assimp_view/Shaders.cpp index 8adb873a2..17c51bbda 100644 --- a/tools/assimp_view/Shaders.cpp +++ b/tools/assimp_view/Shaders.cpp @@ -1394,4 +1394,4 @@ std::string g_szCheckerBackgroundShader = std::string( "VertexShader = compile vs_3_0 DefaultVShader();\n" "}\n" "};\n"); -}; // namespace AssimpView +} // namespace AssimpView diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index 79a902b2a..5342f14d0 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -41,15 +39,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------- */ - #include "assimp_view.h" #include #include #ifdef __MINGW32__ -# include +#include #else -# include +#include #endif using namespace std; @@ -61,122 +58,118 @@ extern std::string g_szDefaultShader; extern std::string g_szPassThroughShader; //------------------------------------------------------------------------------- -HINSTANCE g_hInstance = nullptr; -HWND g_hDlg = nullptr; -IDirect3D9* g_piD3D = nullptr; -IDirect3DDevice9* g_piDevice = nullptr; -IDirect3DVertexDeclaration9* gDefaultVertexDecl = nullptr; -double g_fFPS = 0.0f; +HINSTANCE g_hInstance = nullptr; +HWND g_hDlg = nullptr; +IDirect3D9 *g_piD3D = nullptr; +IDirect3DDevice9 *g_piDevice = nullptr; +IDirect3DVertexDeclaration9 *gDefaultVertexDecl = nullptr; +double g_fFPS = 0.0f; char g_szFileName[MAX_PATH]; -ID3DXEffect* g_piDefaultEffect = nullptr; -ID3DXEffect* g_piNormalsEffect = nullptr; -ID3DXEffect* g_piPassThroughEffect = nullptr; -ID3DXEffect* g_piPatternEffect = nullptr; -bool g_bMousePressed = false; -bool g_bMousePressedR = false; -bool g_bMousePressedM = false; -bool g_bMousePressedBoth = false; -float g_fElpasedTime = 0.0f; +ID3DXEffect *g_piDefaultEffect = nullptr; +ID3DXEffect *g_piNormalsEffect = nullptr; +ID3DXEffect *g_piPassThroughEffect = nullptr; +ID3DXEffect *g_piPatternEffect = nullptr; +bool g_bMousePressed = false; +bool g_bMousePressedR = false; +bool g_bMousePressedM = false; +bool g_bMousePressedBoth = false; +float g_fElpasedTime = 0.0f; D3DCAPS9 g_sCaps; -bool g_bLoadingFinished = false; -HANDLE g_hThreadHandle = nullptr; -float g_fWheelPos = -10.0f; -bool g_bLoadingCanceled = false; -IDirect3DTexture9* g_pcTexture = nullptr; -bool g_bPlay = false; +bool g_bLoadingFinished = false; +HANDLE g_hThreadHandle = nullptr; +float g_fWheelPos = -10.0f; +bool g_bLoadingCanceled = false; +IDirect3DTexture9 *g_pcTexture = nullptr; +bool g_bPlay = false; double g_dCurrent = 0.; // default pp steps unsigned int ppsteps = aiProcess_CalcTangentSpace | // calculate tangents and bitangents if possible - aiProcess_JoinIdenticalVertices | // join identical vertices/ optimize indexing - aiProcess_ValidateDataStructure | // perform a full validation of the loader's output - aiProcess_ImproveCacheLocality | // improve the cache locality of the output vertices - aiProcess_RemoveRedundantMaterials | // remove redundant materials - aiProcess_FindDegenerates | // remove degenerated polygons from the import - aiProcess_FindInvalidData | // detect invalid model data, such as invalid normal vectors - aiProcess_GenUVCoords | // convert spherical, cylindrical, box and planar mapping to proper UVs - aiProcess_TransformUVCoords | // preprocess UV transformations (scaling, translation ...) - aiProcess_FindInstances | // search for instanced meshes and remove them by references to one master - aiProcess_LimitBoneWeights | // limit bone weights to 4 per vertex - aiProcess_OptimizeMeshes | // join small meshes, if possible; - aiProcess_SplitByBoneCount | // split meshes with too many bones. Necessary for our (limited) hardware skinning shader - 0; + aiProcess_JoinIdenticalVertices | // join identical vertices/ optimize indexing + aiProcess_ValidateDataStructure | // perform a full validation of the loader's output + aiProcess_ImproveCacheLocality | // improve the cache locality of the output vertices + aiProcess_RemoveRedundantMaterials | // remove redundant materials + aiProcess_FindDegenerates | // remove degenerated polygons from the import + aiProcess_FindInvalidData | // detect invalid model data, such as invalid normal vectors + aiProcess_GenUVCoords | // convert spherical, cylindrical, box and planar mapping to proper UVs + aiProcess_TransformUVCoords | // preprocess UV transformations (scaling, translation ...) + aiProcess_FindInstances | // search for instanced meshes and remove them by references to one master + aiProcess_LimitBoneWeights | // limit bone weights to 4 per vertex + aiProcess_OptimizeMeshes | // join small meshes, if possible; + aiProcess_SplitByBoneCount | // split meshes with too many bones. Necessary for our (limited) hardware skinning shader + 0; unsigned int ppstepsdefault = ppsteps; bool nopointslines = false; -extern bool g_bWasFlipped /*= false*/; +extern bool g_bWasFlipped /*= false*/; aiMatrix4x4 g_mWorld; aiMatrix4x4 g_mWorldRotate; -aiVector3D g_vRotateSpeed = aiVector3D(0.5f,0.5f,0.5f); +aiVector3D g_vRotateSpeed = aiVector3D(0.5f, 0.5f, 0.5f); // NOTE: The second light direction is now computed from the first -aiVector3D g_avLightDirs[1] = -{ aiVector3D(-0.5f,0.6f,0.2f) }; +aiVector3D g_avLightDirs[1] = { aiVector3D(-0.5f, 0.6f, 0.2f) }; -D3DCOLOR g_avLightColors[3] = -{ - D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF), - D3DCOLOR_ARGB(0xFF,0xFF,0x00,0x00), - D3DCOLOR_ARGB(0xFF,0x05,0x05,0x05), + D3DCOLOR g_avLightColors[3] = { + D3DCOLOR_ARGB(0xFF, 0xFF, 0xFF, 0xFF), + D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00), + D3DCOLOR_ARGB(0xFF, 0x05, 0x05, 0x05), }; POINT g_mousePos; POINT g_LastmousePos; -bool g_bFPSView = false; -bool g_bInvert = false; -EClickPos g_eClick = EClickPos_Circle; -unsigned int g_iCurrentColor = 0; +bool g_bFPSView = false; +bool g_bInvert = false; +EClickPos g_eClick = EClickPos_Circle; +unsigned int g_iCurrentColor = 0; -float g_fLightIntensity = 1.0f; -float g_fLightColor = 1.0f; +float g_fLightIntensity = 1.0f; +float g_fLightColor = 1.0f; RenderOptions g_sOptions; Camera g_sCamera; -AssetHelper *g_pcAsset = nullptr; +AssetHelper *g_pcAsset = nullptr; // -// Contains the mask image for the HUD +// Contains the mask image for the HUD // (used to determine the position of a click) // -unsigned char* g_szImageMask = nullptr; +unsigned char *g_szImageMask = nullptr; float g_fLoadTime = 0.0f; - //------------------------------------------------------------------------------- // Entry point for the loader thread // The loader thread loads the asset while the progress dialog displays the // smart progress bar //------------------------------------------------------------------------------- -DWORD WINAPI LoadThreadProc(LPVOID lpParameter) -{ +DWORD WINAPI LoadThreadProc(LPVOID lpParameter) { UNREFERENCED_PARAMETER(lpParameter); // get current time double fCur = (double)timeGetTime(); - aiPropertyStore* props = aiCreatePropertyStore(); - aiSetImportPropertyInteger(props,AI_CONFIG_IMPORT_TER_MAKE_UVS,1); - aiSetImportPropertyFloat(props,AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,g_smoothAngle); - aiSetImportPropertyInteger(props,AI_CONFIG_PP_SBP_REMOVE,nopointslines ? aiPrimitiveType_LINE | aiPrimitiveType_POINT : 0 ); + aiPropertyStore *props = aiCreatePropertyStore(); + aiSetImportPropertyInteger(props, AI_CONFIG_IMPORT_TER_MAKE_UVS, 1); + aiSetImportPropertyFloat(props, AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, g_smoothAngle); + aiSetImportPropertyInteger(props, AI_CONFIG_PP_SBP_REMOVE, nopointslines ? aiPrimitiveType_LINE | aiPrimitiveType_POINT : 0); - aiSetImportPropertyInteger(props,AI_CONFIG_GLOB_MEASURE_TIME,1); + aiSetImportPropertyInteger(props, AI_CONFIG_GLOB_MEASURE_TIME, 1); //aiSetImportPropertyInteger(props,AI_CONFIG_PP_PTV_KEEP_HIERARCHY,1); // Call ASSIMPs C-API to load the file - g_pcAsset->pcScene = (aiScene*)aiImportFileExWithProperties(g_szFileName, - ppsteps | /* configurable pp steps */ - aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing - aiProcess_SplitLargeMeshes | // split large, unrenderable meshes into submeshes - aiProcess_Triangulate | // triangulate polygons with more than 3 edges - aiProcess_ConvertToLeftHanded | // convert everything to D3D left handed space - aiProcess_SortByPType | // make 'clean' meshes which consist of a single typ of primitives - 0, - nullptr, - props); + g_pcAsset->pcScene = (aiScene *)aiImportFileExWithProperties(g_szFileName, + ppsteps | /* configurable pp steps */ + aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing + aiProcess_SplitLargeMeshes | // split large, unrenderable meshes into submeshes + aiProcess_Triangulate | // triangulate polygons with more than 3 edges + aiProcess_ConvertToLeftHanded | // convert everything to D3D left handed space + aiProcess_SortByPType | // make 'clean' meshes which consist of a single typ of primitives + 0, + nullptr, + props); aiReleasePropertyStore(props); @@ -186,14 +179,13 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter) g_bLoadingFinished = true; // check whether the loading process has failed ... - if (nullptr == g_pcAsset->pcScene) - { + if (nullptr == g_pcAsset->pcScene) { CLogDisplay::Instance().AddEntry("[ERROR] Unable to load this asset:", - D3DCOLOR_ARGB(0xFF,0xFF,0,0)); + D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0)); // print ASSIMPs error string to the log display CLogDisplay::Instance().AddEntry(aiGetErrorString(), - D3DCOLOR_ARGB(0xFF,0xFF,0,0)); + D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0)); return 1; } @@ -204,38 +196,36 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter) // load the current asset // THe path to the asset is specified in the global path variable //------------------------------------------------------------------------------- -int LoadAsset() -{ +int LoadAsset() { // set the world and world rotation matrices to the identity g_mWorldRotate = aiMatrix4x4(); g_mWorld = aiMatrix4x4(); -// char szTemp[MAX_PATH+64]; -// sprintf(szTemp,"Starting to load %s",g_szFileName); + // char szTemp[MAX_PATH+64]; + // sprintf(szTemp,"Starting to load %s",g_szFileName); CLogWindow::Instance().WriteLine( - "----------------------------------------------------------------------------"); -// CLogWindow::Instance().WriteLine(szTemp); -// CLogWindow::Instance().WriteLine( -// "----------------------------------------------------------------------------"); + "----------------------------------------------------------------------------"); + // CLogWindow::Instance().WriteLine(szTemp); + // CLogWindow::Instance().WriteLine( + // "----------------------------------------------------------------------------"); CLogWindow::Instance().SetAutoUpdate(false); // create a helper thread to load the asset DWORD dwID; g_bLoadingCanceled = false; g_pcAsset = new AssetHelper(); - g_hThreadHandle = CreateThread(nullptr,0,&LoadThreadProc,nullptr,0,&dwID); + g_hThreadHandle = CreateThread(nullptr, 0, &LoadThreadProc, nullptr, 0, &dwID); - if (!g_hThreadHandle) - { + if (!g_hThreadHandle) { CLogDisplay::Instance().AddEntry( - "[ERROR] Unable to create helper thread for loading", - D3DCOLOR_ARGB(0xFF,0xFF,0,0)); + "[ERROR] Unable to create helper thread for loading", + D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0)); return 0; } // show the progress bar dialog - DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_LOADDIALOG), - g_hDlg,&ProgressMessageProc); + DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_LOADDIALOG), + g_hDlg, &ProgressMessageProc); // update the log window CLogWindow::Instance().SetAutoUpdate(true); @@ -243,10 +233,8 @@ int LoadAsset() // now we should have loaded the asset. Check this ... g_bLoadingFinished = false; - if (!g_pcAsset || !g_pcAsset->pcScene) - { - if (g_pcAsset) - { + if (!g_pcAsset || !g_pcAsset->pcScene) { + if (g_pcAsset) { delete g_pcAsset; g_pcAsset = nullptr; } @@ -255,40 +243,38 @@ int LoadAsset() // allocate a new MeshHelper array and build a new instance // for each mesh in the original asset - g_pcAsset->apcMeshes = new AssetHelper::MeshHelper*[g_pcAsset->pcScene->mNumMeshes](); - for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) + g_pcAsset->apcMeshes = new AssetHelper::MeshHelper *[g_pcAsset->pcScene->mNumMeshes](); + for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) g_pcAsset->apcMeshes[i] = new AssetHelper::MeshHelper(); - // create animator - g_pcAsset->mAnimator = new SceneAnimator( g_pcAsset->pcScene); + g_pcAsset->mAnimator = new SceneAnimator(g_pcAsset->pcScene); // build a new caption string for the viewer - static const size_t Size = MAX_PATH + 10; - char szOut[Size]; - ai_snprintf(szOut, Size,AI_VIEW_CAPTION_BASE " [%s]",g_szFileName); - SetWindowText(g_hDlg,szOut); + static const size_t Size = MAX_PATH + 10; + char szOut[Size]; + ai_snprintf(szOut, Size, AI_VIEW_CAPTION_BASE " [%s]", g_szFileName); + SetWindowText(g_hDlg, szOut); // scale the asset vertices to fit into the viewer window ScaleAsset(); // reset the camera view to the default position - g_sCamera.vPos = aiVector3D(0.0f,0.0f,-10.0f); - g_sCamera.vLookAt = aiVector3D(0.0f,0.0f,1.0f); - g_sCamera.vUp = aiVector3D(0.0f,1.0f,0.0f); - g_sCamera.vRight = aiVector3D(0.0f,1.0f,0.0f); + g_sCamera.vPos = aiVector3D(0.0f, 0.0f, -10.0f); + g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f); + g_sCamera.vUp = aiVector3D(0.0f, 1.0f, 0.0f); + g_sCamera.vRight = aiVector3D(0.0f, 1.0f, 0.0f); // build native D3D vertex/index buffers, textures, materials - if( 1 != CreateAssetData()) + if (1 != CreateAssetData()) return 0; if (!g_pcAsset->pcScene->HasAnimations()) { - EnableWindow(GetDlgItem(g_hDlg,IDC_PLAY),FALSE); - EnableWindow(GetDlgItem(g_hDlg,IDC_SLIDERANIM),FALSE); - } - else { - EnableWindow(GetDlgItem(g_hDlg,IDC_PLAY),TRUE); - EnableWindow(GetDlgItem(g_hDlg,IDC_SLIDERANIM),TRUE); + EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), FALSE); + EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), FALSE); + } else { + EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), TRUE); + EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), TRUE); } CLogDisplay::Instance().AddEntry("[OK] The asset has been loaded successfully"); @@ -296,7 +282,7 @@ int LoadAsset() CDisplay::Instance().FillAnimList(); CDisplay::Instance().FillDefaultStatistics(); - + // render the scene once CDisplay::Instance().OnRender(); @@ -305,7 +291,6 @@ int LoadAsset() return 1; } - //------------------------------------------------------------------------------- // Delete the loaded asset // The function does nothing is no asset is loaded @@ -320,8 +305,7 @@ int DeleteAsset(void) { // delete everything DeleteAssetData(); - for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) - { + for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) { delete g_pcAsset->apcMeshes[i]; } aiReleaseImport(g_pcAsset->pcScene); @@ -331,7 +315,7 @@ int DeleteAsset(void) { g_pcAsset = nullptr; // reset the caption of the viewer window - SetWindowText(g_hDlg,AI_VIEW_CAPTION_BASE); + SetWindowText(g_hDlg, AI_VIEW_CAPTION_BASE); // clear UI CDisplay::Instance().ClearAnimList(); @@ -342,7 +326,6 @@ int DeleteAsset(void) { return 1; } - //------------------------------------------------------------------------------- // Calculate the boundaries of a given node and all of its children // The boundaries are in Worldspace (AABB) @@ -350,7 +333,7 @@ int DeleteAsset(void) { // p_avOut Receives the min/max boundaries. Must point to 2 vec3s // piMatrix Transformation matrix of the graph at this position //------------------------------------------------------------------------------- -int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMatrix) { +int CalculateBounds(aiNode *piNode, aiVector3D *p_avOut, const aiMatrix4x4 &piMatrix) { ai_assert(nullptr != piNode); ai_assert(nullptr != p_avOut); @@ -358,28 +341,24 @@ int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMa mTemp.Transpose(); aiMatrix4x4 aiMe = mTemp * piMatrix; - for (unsigned int i = 0; i < piNode->mNumMeshes;++i) - { - for( unsigned int a = 0; a < g_pcAsset->pcScene->mMeshes[ - piNode->mMeshes[i]]->mNumVertices;++a) - { - aiVector3D pc =g_pcAsset->pcScene->mMeshes[piNode->mMeshes[i]]->mVertices[a]; + for (unsigned int i = 0; i < piNode->mNumMeshes; ++i) { + for (unsigned int a = 0; a < g_pcAsset->pcScene->mMeshes[piNode->mMeshes[i]]->mNumVertices; ++a) { + aiVector3D pc = g_pcAsset->pcScene->mMeshes[piNode->mMeshes[i]]->mVertices[a]; aiVector3D pc1; - D3DXVec3TransformCoord((D3DXVECTOR3*)&pc1,(D3DXVECTOR3*)&pc, - (D3DXMATRIX*)&aiMe); + D3DXVec3TransformCoord((D3DXVECTOR3 *)&pc1, (D3DXVECTOR3 *)&pc, + (D3DXMATRIX *)&aiMe); - p_avOut[0].x = min( p_avOut[0].x, pc1.x); - p_avOut[0].y = min( p_avOut[0].y, pc1.y); - p_avOut[0].z = min( p_avOut[0].z, pc1.z); - p_avOut[1].x = max( p_avOut[1].x, pc1.x); - p_avOut[1].y = max( p_avOut[1].y, pc1.y); - p_avOut[1].z = max( p_avOut[1].z, pc1.z); + p_avOut[0].x = min(p_avOut[0].x, pc1.x); + p_avOut[0].y = min(p_avOut[0].y, pc1.y); + p_avOut[0].z = min(p_avOut[0].z, pc1.z); + p_avOut[1].x = max(p_avOut[1].x, pc1.x); + p_avOut[1].y = max(p_avOut[1].y, pc1.y); + p_avOut[1].z = max(p_avOut[1].z, pc1.z); } } - for (unsigned int i = 0; i < piNode->mNumChildren;++i) - { - CalculateBounds( piNode->mChildren[i], p_avOut, aiMe ); + for (unsigned int i = 0; i < piNode->mNumChildren; ++i) { + CalculateBounds(piNode->mChildren[i], p_avOut, aiMe); } return 1; } @@ -388,31 +367,29 @@ int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMa // The function calculates the boundaries of the mesh and modifies the // global world transformation matrix according to the aset AABB //------------------------------------------------------------------------------- -int ScaleAsset(void) -{ - aiVector3D aiVecs[2] = {aiVector3D( 1e10f, 1e10f, 1e10f), - aiVector3D( -1e10f, -1e10f, -1e10f) }; +int ScaleAsset(void) { + aiVector3D aiVecs[2] = { aiVector3D(1e10f, 1e10f, 1e10f), + aiVector3D(-1e10f, -1e10f, -1e10f) }; - if (g_pcAsset->pcScene->mRootNode) - { + if (g_pcAsset->pcScene->mRootNode) { aiMatrix4x4 m; - CalculateBounds(g_pcAsset->pcScene->mRootNode,aiVecs,m); + CalculateBounds(g_pcAsset->pcScene->mRootNode, aiVecs, m); } - aiVector3D vDelta = aiVecs[1]-aiVecs[0]; - aiVector3D vHalf = aiVecs[0] + (vDelta / 2.0f); + aiVector3D vDelta = aiVecs[1] - aiVecs[0]; + aiVector3D vHalf = aiVecs[0] + (vDelta / 2.0f); float fScale = 10.0f / vDelta.Length(); - g_mWorld = aiMatrix4x4( - 1.0f,0.0f,0.0f,0.0f, - 0.0f,1.0f,0.0f,0.0f, - 0.0f,0.0f,1.0f,0.0f, - -vHalf.x,-vHalf.y,-vHalf.z,1.0f) * - aiMatrix4x4( - fScale,0.0f,0.0f,0.0f, - 0.0f,fScale,0.0f,0.0f, - 0.0f,0.0f,fScale,0.0f, - 0.0f,0.0f,0.0f,1.0f); + g_mWorld = aiMatrix4x4( + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + -vHalf.x, -vHalf.y, -vHalf.z, 1.0f) * + aiMatrix4x4( + fScale, 0.0f, 0.0f, 0.0f, + 0.0f, fScale, 0.0f, 0.0f, + 0.0f, 0.0f, fScale, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f); return 1; } @@ -422,30 +399,27 @@ int ScaleAsset(void) // pcMesh Input mesh // pcSource Source mesh from ASSIMP //------------------------------------------------------------------------------- -int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource) -{ +int GenerateNormalsAsLineList(AssetHelper::MeshHelper *pcMesh, const aiMesh *pcSource) { ai_assert(nullptr != pcMesh); ai_assert(nullptr != pcSource); - if (!pcSource->mNormals)return 0; + if (!pcSource->mNormals) return 0; // create vertex buffer - if(FAILED( g_piDevice->CreateVertexBuffer(sizeof(AssetHelper::LineVertex) * - pcSource->mNumVertices * 2, - D3DUSAGE_WRITEONLY, - AssetHelper::LineVertex::GetFVF(), - D3DPOOL_DEFAULT, &pcMesh->piVBNormals,nullptr))) - { + if (FAILED(g_piDevice->CreateVertexBuffer(sizeof(AssetHelper::LineVertex) * + pcSource->mNumVertices * 2, + D3DUSAGE_WRITEONLY, + AssetHelper::LineVertex::GetFVF(), + D3DPOOL_DEFAULT, &pcMesh->piVBNormals, nullptr))) { CLogDisplay::Instance().AddEntry("Failed to create vertex buffer for the normal list", - D3DCOLOR_ARGB(0xFF,0xFF,0,0)); + D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0)); return 2; } // now fill the vertex buffer with data - AssetHelper::LineVertex* pbData2; - pcMesh->piVBNormals->Lock(0,0,(void**)&pbData2,0); - for (unsigned int x = 0; x < pcSource->mNumVertices;++x) - { + AssetHelper::LineVertex *pbData2; + pcMesh->piVBNormals->Lock(0, 0, (void **)&pbData2, 0); + for (unsigned int x = 0; x < pcSource->mNumVertices; ++x) { pbData2->vPosition = pcSource->mVertices[x]; ++pbData2; @@ -456,9 +430,9 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo // scalo with the inverse of the world scaling to make sure // the normals have equal length in each case // TODO: Check whether this works in every case, I don't think so - vNormal.x /= g_mWorld.a1*4; - vNormal.y /= g_mWorld.b2*4; - vNormal.z /= g_mWorld.c3*4; + vNormal.x /= g_mWorld.a1 * 4; + vNormal.y /= g_mWorld.b2 * 4; + vNormal.z /= g_mWorld.c3 * 4; pbData2->vPosition = pcSource->mVertices[x] + vNormal; @@ -472,32 +446,30 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo // Create the native D3D representation of the asset: vertex buffers, // index buffers, materials ... //------------------------------------------------------------------------------- -int CreateAssetData() -{ - if (!g_pcAsset)return 0; +int CreateAssetData() { + if (!g_pcAsset) return 0; // reset all subsystems CMaterialManager::Instance().Reset(); CDisplay::Instance().Reset(); - for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) - { - const aiMesh* mesh = g_pcAsset->pcScene->mMeshes[i]; + for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) { + const aiMesh *mesh = g_pcAsset->pcScene->mMeshes[i]; // create the material for the mesh - if (!g_pcAsset->apcMeshes[i]->piEffect) { + if (!g_pcAsset->apcMeshes[i]->piEffect) { CMaterialManager::Instance().CreateMaterial( - g_pcAsset->apcMeshes[i],mesh); + g_pcAsset->apcMeshes[i], mesh); } // create vertex buffer - if(FAILED( g_piDevice->CreateVertexBuffer(sizeof(AssetHelper::Vertex) * - mesh->mNumVertices, - D3DUSAGE_WRITEONLY, - 0, - D3DPOOL_DEFAULT, &g_pcAsset->apcMeshes[i]->piVB,nullptr))) { - MessageBox(g_hDlg,"Failed to create vertex buffer", - "ASSIMP Viewer Utility",MB_OK); + if (FAILED(g_piDevice->CreateVertexBuffer(sizeof(AssetHelper::Vertex) * + mesh->mNumVertices, + D3DUSAGE_WRITEONLY, + 0, + D3DPOOL_DEFAULT, &g_pcAsset->apcMeshes[i]->piVB, nullptr))) { + MessageBox(g_hDlg, "Failed to create vertex buffer", + "ASSIMP Viewer Utility", MB_OK); return 2; } @@ -507,18 +479,18 @@ int CreateAssetData() unsigned int nidx = 0; switch (mesh->mPrimitiveTypes) { - case aiPrimitiveType_POINT: - nidx = 1; - break; - case aiPrimitiveType_LINE: - nidx = 2; - break; - case aiPrimitiveType_TRIANGLE: - nidx = 3; - break; - default: - ai_assert(false); - break; + case aiPrimitiveType_POINT: + nidx = 1; + break; + case aiPrimitiveType_LINE: + nidx = 2; + break; + case aiPrimitiveType_TRIANGLE: + nidx = 3; + break; + default: + ai_assert(false); + break; }; unsigned int numIndices = mesh->mNumFaces * 3; @@ -526,54 +498,47 @@ int CreateAssetData() numIndices = mesh->mNumVertices; } // check whether we can use 16 bit indices - if (numIndices >= 65536) { + if (numIndices >= 65536) { // create 32 bit index buffer - if(FAILED( g_piDevice->CreateIndexBuffer( 4 * - numIndices, - D3DUSAGE_WRITEONLY | dwUsage, - D3DFMT_INDEX32, - D3DPOOL_DEFAULT, - &g_pcAsset->apcMeshes[i]->piIB, - nullptr))) - { - MessageBox(g_hDlg,"Failed to create 32 Bit index buffer", - "ASSIMP Viewer Utility",MB_OK); + if (FAILED(g_piDevice->CreateIndexBuffer(4 * + numIndices, + D3DUSAGE_WRITEONLY | dwUsage, + D3DFMT_INDEX32, + D3DPOOL_DEFAULT, + &g_pcAsset->apcMeshes[i]->piIB, + nullptr))) { + MessageBox(g_hDlg, "Failed to create 32 Bit index buffer", + "ASSIMP Viewer Utility", MB_OK); return 2; } // now fill the index buffer - unsigned int* pbData; - g_pcAsset->apcMeshes[i]->piIB->Lock(0,0,(void**)&pbData,0); - for (unsigned int x = 0; x < mesh->mNumFaces;++x) - { - for (unsigned int a = 0; a < nidx;++a) - { + unsigned int *pbData; + g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0); + for (unsigned int x = 0; x < mesh->mNumFaces; ++x) { + for (unsigned int a = 0; a < nidx; ++a) { *pbData++ = mesh->mFaces[x].mIndices[a]; } } - } - else { + } else { // create 16 bit index buffer - if(FAILED( g_piDevice->CreateIndexBuffer( 2 * - numIndices, - D3DUSAGE_WRITEONLY | dwUsage, - D3DFMT_INDEX16, - D3DPOOL_DEFAULT, - &g_pcAsset->apcMeshes[i]->piIB, - nullptr))) - { - MessageBox(g_hDlg,"Failed to create 16 Bit index buffer", - "ASSIMP Viewer Utility",MB_OK); + if (FAILED(g_piDevice->CreateIndexBuffer(2 * + numIndices, + D3DUSAGE_WRITEONLY | dwUsage, + D3DFMT_INDEX16, + D3DPOOL_DEFAULT, + &g_pcAsset->apcMeshes[i]->piIB, + nullptr))) { + MessageBox(g_hDlg, "Failed to create 16 Bit index buffer", + "ASSIMP Viewer Utility", MB_OK); return 2; } // now fill the index buffer - uint16_t* pbData; - g_pcAsset->apcMeshes[i]->piIB->Lock(0,0,(void**)&pbData,0); - for (unsigned int x = 0; x < mesh->mNumFaces;++x) - { - for (unsigned int a = 0; a < nidx;++a) - { + uint16_t *pbData; + g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0); + for (unsigned int x = 0; x < mesh->mNumFaces; ++x) { + for (unsigned int a = 0; a < nidx; ++a) { *pbData++ = (uint16_t)mesh->mFaces[x].mIndices[a]; } } @@ -581,74 +546,71 @@ int CreateAssetData() g_pcAsset->apcMeshes[i]->piIB->Unlock(); // collect weights on all vertices. Quick and careless - std::vector > weightsPerVertex( mesh->mNumVertices); - for( unsigned int a = 0; a < mesh->mNumBones; a++) { - const aiBone* bone = mesh->mBones[a]; - for( unsigned int b = 0; b < bone->mNumWeights; b++) - weightsPerVertex[bone->mWeights[b].mVertexId].push_back( aiVertexWeight( a, bone->mWeights[b].mWeight)); + std::vector> weightsPerVertex(mesh->mNumVertices); + for (unsigned int a = 0; a < mesh->mNumBones; a++) { + const aiBone *bone = mesh->mBones[a]; + for (unsigned int b = 0; b < bone->mNumWeights; b++) + weightsPerVertex[bone->mWeights[b].mVertexId].push_back(aiVertexWeight(a, bone->mWeights[b].mWeight)); } // now fill the vertex buffer - AssetHelper::Vertex* pbData2; - g_pcAsset->apcMeshes[i]->piVB->Lock(0,0,(void**)&pbData2,0); - for (unsigned int x = 0; x < mesh->mNumVertices;++x) - { + AssetHelper::Vertex *pbData2; + g_pcAsset->apcMeshes[i]->piVB->Lock(0, 0, (void **)&pbData2, 0); + for (unsigned int x = 0; x < mesh->mNumVertices; ++x) { pbData2->vPosition = mesh->mVertices[x]; if (nullptr == mesh->mNormals) - pbData2->vNormal = aiVector3D(0.0f,0.0f,0.0f); - else pbData2->vNormal = mesh->mNormals[x]; + pbData2->vNormal = aiVector3D(0.0f, 0.0f, 0.0f); + else + pbData2->vNormal = mesh->mNormals[x]; - if (nullptr == mesh->mTangents) { - pbData2->vTangent = aiVector3D(0.0f,0.0f,0.0f); - pbData2->vBitangent = aiVector3D(0.0f,0.0f,0.0f); - } - else { + if (nullptr == mesh->mTangents) { + pbData2->vTangent = aiVector3D(0.0f, 0.0f, 0.0f); + pbData2->vBitangent = aiVector3D(0.0f, 0.0f, 0.0f); + } else { pbData2->vTangent = mesh->mTangents[x]; pbData2->vBitangent = mesh->mBitangents[x]; } - if (mesh->HasVertexColors( 0)) { + if (mesh->HasVertexColors(0)) { pbData2->dColorDiffuse = D3DCOLOR_ARGB( - ((unsigned char)max( min( mesh->mColors[0][x].a * 255.0f, 255.0f),0.0f)), - ((unsigned char)max( min( mesh->mColors[0][x].r * 255.0f, 255.0f),0.0f)), - ((unsigned char)max( min( mesh->mColors[0][x].g * 255.0f, 255.0f),0.0f)), - ((unsigned char)max( min( mesh->mColors[0][x].b * 255.0f, 255.0f),0.0f))); - } - else pbData2->dColorDiffuse = D3DCOLOR_ARGB(0xFF,0xff,0xff,0xff); + ((unsigned char)max(min(mesh->mColors[0][x].a * 255.0f, 255.0f), 0.0f)), + ((unsigned char)max(min(mesh->mColors[0][x].r * 255.0f, 255.0f), 0.0f)), + ((unsigned char)max(min(mesh->mColors[0][x].g * 255.0f, 255.0f), 0.0f)), + ((unsigned char)max(min(mesh->mColors[0][x].b * 255.0f, 255.0f), 0.0f))); + } else + pbData2->dColorDiffuse = D3DCOLOR_ARGB(0xFF, 0xff, 0xff, 0xff); // ignore a third texture coordinate component - if (mesh->HasTextureCoords( 0)) { + if (mesh->HasTextureCoords(0)) { pbData2->vTextureUV = aiVector2D( - mesh->mTextureCoords[0][x].x, - mesh->mTextureCoords[0][x].y); - } - else pbData2->vTextureUV = aiVector2D(0.5f,0.5f); + mesh->mTextureCoords[0][x].x, + mesh->mTextureCoords[0][x].y); + } else + pbData2->vTextureUV = aiVector2D(0.5f, 0.5f); - if (mesh->HasTextureCoords( 1)) { + if (mesh->HasTextureCoords(1)) { pbData2->vTextureUV2 = aiVector2D( - mesh->mTextureCoords[1][x].x, - mesh->mTextureCoords[1][x].y); - } - else pbData2->vTextureUV2 = aiVector2D(0.5f,0.5f); + mesh->mTextureCoords[1][x].x, + mesh->mTextureCoords[1][x].y); + } else + pbData2->vTextureUV2 = aiVector2D(0.5f, 0.5f); // Bone indices and weights - if( mesh->HasBones()) { + if (mesh->HasBones()) { unsigned char boneIndices[4] = { 0, 0, 0, 0 }; unsigned char boneWeights[4] = { 0, 0, 0, 0 }; - ai_assert( weightsPerVertex[x].size() <= 4); - for( unsigned int a = 0; a < weightsPerVertex[x].size(); a++) - { + ai_assert(weightsPerVertex[x].size() <= 4); + for (unsigned int a = 0; a < weightsPerVertex[x].size(); a++) { boneIndices[a] = static_cast(weightsPerVertex[x][a].mVertexId); - boneWeights[a] = (unsigned char) (weightsPerVertex[x][a].mWeight * 255.0f); + boneWeights[a] = (unsigned char)(weightsPerVertex[x][a].mWeight * 255.0f); } - memcpy( pbData2->mBoneIndices, boneIndices, sizeof( boneIndices)); - memcpy( pbData2->mBoneWeights, boneWeights, sizeof( boneWeights)); - } else - { - memset( pbData2->mBoneIndices, 0, sizeof( pbData2->mBoneIndices)); - memset( pbData2->mBoneWeights, 0, sizeof( pbData2->mBoneWeights)); + memcpy(pbData2->mBoneIndices, boneIndices, sizeof(boneIndices)); + memcpy(pbData2->mBoneWeights, boneWeights, sizeof(boneWeights)); + } else { + memset(pbData2->mBoneIndices, 0, sizeof(pbData2->mBoneIndices)); + memset(pbData2->mBoneWeights, 0, sizeof(pbData2->mBoneWeights)); } ++pbData2; @@ -656,8 +618,8 @@ int CreateAssetData() g_pcAsset->apcMeshes[i]->piVB->Unlock(); // now generate the second vertex buffer, holding all normals - if (!g_pcAsset->apcMeshes[i]->piVBNormals) { - GenerateNormalsAsLineList(g_pcAsset->apcMeshes[i],mesh); + if (!g_pcAsset->apcMeshes[i]->piVBNormals) { + GenerateNormalsAsLineList(g_pcAsset->apcMeshes[i], mesh); } } return 1; @@ -667,25 +629,20 @@ int CreateAssetData() // Delete all effects, textures, vertex buffers ... associated with // an asset //------------------------------------------------------------------------------- -int DeleteAssetData(bool bNoMaterials) -{ - if (!g_pcAsset)return 0; +int DeleteAssetData(bool bNoMaterials) { + if (!g_pcAsset) return 0; // TODO: Move this to a proper destructor - for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) - { - if(g_pcAsset->apcMeshes[i]->piVB) - { + for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) { + if (g_pcAsset->apcMeshes[i]->piVB) { g_pcAsset->apcMeshes[i]->piVB->Release(); g_pcAsset->apcMeshes[i]->piVB = nullptr; } - if(g_pcAsset->apcMeshes[i]->piVBNormals) - { + if (g_pcAsset->apcMeshes[i]->piVBNormals) { g_pcAsset->apcMeshes[i]->piVBNormals->Release(); g_pcAsset->apcMeshes[i]->piVBNormals = nullptr; } - if(g_pcAsset->apcMeshes[i]->piIB) - { + if (g_pcAsset->apcMeshes[i]->piIB) { g_pcAsset->apcMeshes[i]->piIB->Release(); g_pcAsset->apcMeshes[i]->piIB = nullptr; } @@ -698,45 +655,36 @@ int DeleteAssetData(bool bNoMaterials) // delete[] g_pcAsset->apcMeshes[i]->pvOriginalNormals; //} - if (!bNoMaterials) - { - if(g_pcAsset->apcMeshes[i]->piEffect) - { + if (!bNoMaterials) { + if (g_pcAsset->apcMeshes[i]->piEffect) { g_pcAsset->apcMeshes[i]->piEffect->Release(); g_pcAsset->apcMeshes[i]->piEffect = nullptr; } - if(g_pcAsset->apcMeshes[i]->piDiffuseTexture) - { + if (g_pcAsset->apcMeshes[i]->piDiffuseTexture) { g_pcAsset->apcMeshes[i]->piDiffuseTexture->Release(); g_pcAsset->apcMeshes[i]->piDiffuseTexture = nullptr; } - if(g_pcAsset->apcMeshes[i]->piNormalTexture) - { + if (g_pcAsset->apcMeshes[i]->piNormalTexture) { g_pcAsset->apcMeshes[i]->piNormalTexture->Release(); g_pcAsset->apcMeshes[i]->piNormalTexture = nullptr; } - if(g_pcAsset->apcMeshes[i]->piSpecularTexture) - { + if (g_pcAsset->apcMeshes[i]->piSpecularTexture) { g_pcAsset->apcMeshes[i]->piSpecularTexture->Release(); g_pcAsset->apcMeshes[i]->piSpecularTexture = nullptr; } - if(g_pcAsset->apcMeshes[i]->piAmbientTexture) - { + if (g_pcAsset->apcMeshes[i]->piAmbientTexture) { g_pcAsset->apcMeshes[i]->piAmbientTexture->Release(); g_pcAsset->apcMeshes[i]->piAmbientTexture = nullptr; } - if(g_pcAsset->apcMeshes[i]->piEmissiveTexture) - { + if (g_pcAsset->apcMeshes[i]->piEmissiveTexture) { g_pcAsset->apcMeshes[i]->piEmissiveTexture->Release(); g_pcAsset->apcMeshes[i]->piEmissiveTexture = nullptr; } - if(g_pcAsset->apcMeshes[i]->piOpacityTexture) - { + if (g_pcAsset->apcMeshes[i]->piOpacityTexture) { g_pcAsset->apcMeshes[i]->piOpacityTexture->Release(); g_pcAsset->apcMeshes[i]->piOpacityTexture = nullptr; } - if(g_pcAsset->apcMeshes[i]->piShininessTexture) - { + if (g_pcAsset->apcMeshes[i]->piShininessTexture) { g_pcAsset->apcMeshes[i]->piShininessTexture->Release(); g_pcAsset->apcMeshes[i]->piShininessTexture = nullptr; } @@ -745,27 +693,22 @@ int DeleteAssetData(bool bNoMaterials) return 1; } - //------------------------------------------------------------------------------- // Switch between zoom/rotate view and the standard FPS view // g_bFPSView specifies the view mode to setup //------------------------------------------------------------------------------- -int SetupFPSView() -{ - if (!g_bFPSView) - { - g_sCamera.vPos = aiVector3D(0.0f,0.0f,g_fWheelPos); - g_sCamera.vLookAt = aiVector3D(0.0f,0.0f,1.0f); - g_sCamera.vUp = aiVector3D(0.0f,1.0f,0.0f); - g_sCamera.vRight = aiVector3D(0.0f,1.0f,0.0f); - } - else - { +int SetupFPSView() { + if (!g_bFPSView) { + g_sCamera.vPos = aiVector3D(0.0f, 0.0f, g_fWheelPos); + g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f); + g_sCamera.vUp = aiVector3D(0.0f, 1.0f, 0.0f); + g_sCamera.vRight = aiVector3D(0.0f, 1.0f, 0.0f); + } else { g_fWheelPos = g_sCamera.vPos.z; - g_sCamera.vPos = aiVector3D(0.0f,0.0f,-10.0f); - g_sCamera.vLookAt = aiVector3D(0.0f,0.0f,1.0f); - g_sCamera.vUp = aiVector3D(0.0f,1.0f,0.0f); - g_sCamera.vRight = aiVector3D(0.0f,1.0f,0.0f); + g_sCamera.vPos = aiVector3D(0.0f, 0.0f, -10.0f); + g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f); + g_sCamera.vUp = aiVector3D(0.0f, 1.0f, 0.0f); + g_sCamera.vRight = aiVector3D(0.0f, 1.0f, 0.0f); } return 1; } @@ -774,35 +717,29 @@ int SetupFPSView() // Initialize the IDIrect3D interface // Called by the WinMain //------------------------------------------------------------------------------- -int InitD3D(void) -{ - if (nullptr == g_piD3D) - { +int InitD3D(void) { + if (nullptr == g_piD3D) { g_piD3D = Direct3DCreate9(D3D_SDK_VERSION); - if (nullptr == g_piD3D)return 0; + if (nullptr == g_piD3D) return 0; } return 1; } - //------------------------------------------------------------------------------- // Release the IDirect3D interface. // NOTE: Assumes that the device has already been deleted //------------------------------------------------------------------------------- -int ShutdownD3D(void) -{ +int ShutdownD3D(void) { ShutdownDevice(); - if (nullptr != g_piD3D) - { + if (nullptr != g_piD3D) { g_piD3D->Release(); g_piD3D = nullptr; } return 1; } -template -inline -void SafeRelease(TComPtr *&ptr) { +template +inline void SafeRelease(TComPtr *&ptr) { if (nullptr != ptr) { ptr->Release(); ptr = nullptr; @@ -813,8 +750,7 @@ void SafeRelease(TComPtr *&ptr) { // Shutdown the D3D device object and all resources associated with it // NOTE: Assumes that the asset has already been deleted //------------------------------------------------------------------------------- -int ShutdownDevice(void) -{ +int ShutdownDevice(void) { // release other subsystems CBackgroundPainter::Instance().ReleaseNativeResource(); CLogDisplay::Instance().ReleaseNativeResource(); @@ -837,35 +773,32 @@ int ShutdownDevice(void) return 1; } - //------------------------------------------------------------------------------- //------------------------------------------------------------------------------- -int CreateHUDTexture() -{ +int CreateHUDTexture() { // lock the memory resource ourselves - HRSRC res = FindResource(nullptr,MAKEINTRESOURCE(IDR_HUD),RT_RCDATA); - HGLOBAL hg = LoadResource(nullptr,res); - void* pData = LockResource(hg); + HRSRC res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUD), RT_RCDATA); + HGLOBAL hg = LoadResource(nullptr, res); + void *pData = LockResource(hg); - if(FAILED(D3DXCreateTextureFromFileInMemoryEx(g_piDevice, - pData,SizeofResource(nullptr,res), - D3DX_DEFAULT_NONPOW2, - D3DX_DEFAULT_NONPOW2, - 1, - 0, - D3DFMT_A8R8G8B8, - D3DPOOL_MANAGED, - D3DX_DEFAULT, - D3DX_DEFAULT, - 0, - nullptr, - nullptr, - &g_pcTexture))) - { + if (FAILED(D3DXCreateTextureFromFileInMemoryEx(g_piDevice, + pData, SizeofResource(nullptr, res), + D3DX_DEFAULT_NONPOW2, + D3DX_DEFAULT_NONPOW2, + 1, + 0, + D3DFMT_A8R8G8B8, + D3DPOOL_MANAGED, + D3DX_DEFAULT, + D3DX_DEFAULT, + 0, + nullptr, + nullptr, + &g_pcTexture))) { CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD texture", - D3DCOLOR_ARGB(0xFF,0xFF,0,0)); + D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0)); - g_pcTexture = nullptr; + g_pcTexture = nullptr; g_szImageMask = nullptr; FreeResource(hg); @@ -875,32 +808,30 @@ int CreateHUDTexture() FreeResource(hg); D3DSURFACE_DESC sDesc; - g_pcTexture->GetLevelDesc(0,&sDesc); - + g_pcTexture->GetLevelDesc(0, &sDesc); // lock the memory resource ourselves - res = FindResource(nullptr,MAKEINTRESOURCE(IDR_HUDMASK),RT_RCDATA); - hg = LoadResource(nullptr,res); + res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUDMASK), RT_RCDATA); + hg = LoadResource(nullptr, res); pData = LockResource(hg); - IDirect3DTexture9* pcTex; - if(FAILED(D3DXCreateTextureFromFileInMemoryEx(g_piDevice, - pData,SizeofResource(nullptr,res), - sDesc.Width, - sDesc.Height, - 1, - 0, - D3DFMT_L8, - D3DPOOL_MANAGED, // unnecessary - D3DX_DEFAULT, - D3DX_DEFAULT, - 0, - nullptr, - nullptr, - &pcTex))) - { + IDirect3DTexture9 *pcTex; + if (FAILED(D3DXCreateTextureFromFileInMemoryEx(g_piDevice, + pData, SizeofResource(nullptr, res), + sDesc.Width, + sDesc.Height, + 1, + 0, + D3DFMT_L8, + D3DPOOL_MANAGED, // unnecessary + D3DX_DEFAULT, + D3DX_DEFAULT, + 0, + nullptr, + nullptr, + &pcTex))) { CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD mask texture", - D3DCOLOR_ARGB(0xFF,0xFF,0,0)); + D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0)); g_szImageMask = nullptr; FreeResource(hg); @@ -911,15 +842,14 @@ int CreateHUDTexture() // lock the texture and copy it to get a pointer D3DLOCKED_RECT sRect; - pcTex->LockRect(0,&sRect,nullptr,D3DLOCK_READONLY); + pcTex->LockRect(0, &sRect, nullptr, D3DLOCK_READONLY); - unsigned char* szOut = new unsigned char[sDesc.Width * sDesc.Height]; - unsigned char* _szOut = szOut; + unsigned char *szOut = new unsigned char[sDesc.Width * sDesc.Height]; + unsigned char *_szOut = szOut; - unsigned char* szCur = (unsigned char*) sRect.pBits; - for (unsigned int y = 0; y < sDesc.Height;++y) - { - memcpy(_szOut,szCur,sDesc.Width); + unsigned char *szCur = (unsigned char *)sRect.pBits; + for (unsigned int y = 0; y < sDesc.Height; ++y) { + memcpy(_szOut, szCur, sDesc.Width); szCur += sRect.Pitch; _szOut += sDesc.Width; @@ -933,159 +863,141 @@ int CreateHUDTexture() //------------------------------------------------------------------------------- //------------------------------------------------------------------------------- -int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/) -{ +int CreateDevice(bool p_bMultiSample, bool p_bSuperSample, bool bHW /*= true*/) { D3DDEVTYPE eType = bHW ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF; // get the client rectangle of the window. RECT sRect; - GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect); + GetWindowRect(GetDlgItem(g_hDlg, IDC_RT), &sRect); sRect.right -= sRect.left; sRect.bottom -= sRect.top; D3DPRESENT_PARAMETERS sParams; - memset(&sParams,0,sizeof(D3DPRESENT_PARAMETERS)); + memset(&sParams, 0, sizeof(D3DPRESENT_PARAMETERS)); // get the current display mode D3DDISPLAYMODE sMode; - g_piD3D->GetAdapterDisplayMode(0,&sMode); + g_piD3D->GetAdapterDisplayMode(0, &sMode); // fill the presentation parameter structure - sParams.Windowed = TRUE; - sParams.hDeviceWindow = GetDlgItem( g_hDlg, IDC_RT ); - sParams.EnableAutoDepthStencil = TRUE; - sParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE; - sParams.BackBufferWidth = (UINT)sRect.right; - sParams.BackBufferHeight = (UINT)sRect.bottom; - sParams.SwapEffect = D3DSWAPEFFECT_DISCARD; - sParams.BackBufferCount = 1; + sParams.Windowed = TRUE; + sParams.hDeviceWindow = GetDlgItem(g_hDlg, IDC_RT); + sParams.EnableAutoDepthStencil = TRUE; + sParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE; + sParams.BackBufferWidth = (UINT)sRect.right; + sParams.BackBufferHeight = (UINT)sRect.bottom; + sParams.SwapEffect = D3DSWAPEFFECT_DISCARD; + sParams.BackBufferCount = 1; // check whether we can use a D32 depth buffer format - if (SUCCEEDED ( g_piD3D->CheckDepthStencilMatch(0,eType, - D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,D3DFMT_D32))) - { + if (SUCCEEDED(g_piD3D->CheckDepthStencilMatch(0, eType, + D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_D32))) { sParams.AutoDepthStencilFormat = D3DFMT_D32; - } - else sParams.AutoDepthStencilFormat = D3DFMT_D24X8; + } else + sParams.AutoDepthStencilFormat = D3DFMT_D24X8; // find the highest multisample type available on this device D3DMULTISAMPLE_TYPE sMS = D3DMULTISAMPLE_2_SAMPLES; D3DMULTISAMPLE_TYPE sMSOut = D3DMULTISAMPLE_NONE; DWORD dwQuality = 0; - if (p_bMultiSample) - { - while ((D3DMULTISAMPLE_TYPE)(D3DMULTISAMPLE_16_SAMPLES + 1) != - (sMS = (D3DMULTISAMPLE_TYPE)(sMS + 1))) - { - if(SUCCEEDED( g_piD3D->CheckDeviceMultiSampleType(0,eType, - sMode.Format,TRUE,sMS,&dwQuality))) - { + if (p_bMultiSample) { + while ((D3DMULTISAMPLE_TYPE)(D3DMULTISAMPLE_16_SAMPLES + 1) != + (sMS = (D3DMULTISAMPLE_TYPE)(sMS + 1))) { + if (SUCCEEDED(g_piD3D->CheckDeviceMultiSampleType(0, eType, + sMode.Format, TRUE, sMS, &dwQuality))) { sMSOut = sMS; } } - if (0 != dwQuality)dwQuality -= 1; - + if (0 != dwQuality) dwQuality -= 1; sParams.MultiSampleQuality = dwQuality; sParams.MultiSampleType = sMSOut; } // get the device capabilities. If the hardware vertex shader is too old, we prefer software vertex processing - g_piD3D->GetDeviceCaps( 0, D3DDEVTYPE_HAL, &g_sCaps); + g_piD3D->GetDeviceCaps(0, D3DDEVTYPE_HAL, &g_sCaps); DWORD creationFlags = D3DCREATE_MULTITHREADED; - if( g_sCaps.VertexShaderVersion >= D3DVS_VERSION( 2, 0)) + if (g_sCaps.VertexShaderVersion >= D3DVS_VERSION(2, 0)) creationFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; else creationFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; // create the D3D9 device object. with software-vertexprocessing if VS2.0 isn`t supported in hardware - if(FAILED(g_piD3D->CreateDevice(0,eType, g_hDlg, creationFlags ,&sParams,&g_piDevice))) - { + if (FAILED(g_piD3D->CreateDevice(0, eType, g_hDlg, creationFlags, &sParams, &g_piDevice))) { // if hardware fails use software rendering instead - if (bHW)return CreateDevice(p_bMultiSample,p_bSuperSample,false); + if (bHW) return CreateDevice(p_bMultiSample, p_bSuperSample, false); return 0; } // create a vertex declaration to match the vertex - D3DVERTEXELEMENT9* vdecl = AssetHelper::Vertex::GetDeclarationElements(); - if( FAILED( g_piDevice->CreateVertexDeclaration( vdecl, &gDefaultVertexDecl))) - { - MessageBox( g_hDlg, "Failed to create vertex declaration", "Init", MB_OK); + D3DVERTEXELEMENT9 *vdecl = AssetHelper::Vertex::GetDeclarationElements(); + if (FAILED(g_piDevice->CreateVertexDeclaration(vdecl, &gDefaultVertexDecl))) { + MessageBox(g_hDlg, "Failed to create vertex declaration", "Init", MB_OK); return 0; } - g_piDevice->SetVertexDeclaration( gDefaultVertexDecl); + g_piDevice->SetVertexDeclaration(gDefaultVertexDecl); // get the capabilities of the device object g_piDevice->GetDeviceCaps(&g_sCaps); - if(g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0)) - { - EnableWindow(GetDlgItem(g_hDlg,IDC_LOWQUALITY),FALSE); + if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(3, 0)) { + EnableWindow(GetDlgItem(g_hDlg, IDC_LOWQUALITY), FALSE); } // compile the default material shader (gray gouraud/phong) - ID3DXBuffer* piBuffer = nullptr; - if(FAILED( D3DXCreateEffect(g_piDevice, - g_szDefaultShader.c_str(), - (UINT)g_szDefaultShader.length(), - nullptr, - nullptr, - AI_SHADER_COMPILE_FLAGS, - nullptr, - &g_piDefaultEffect,&piBuffer))) - { - if( piBuffer) - { - MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK); + ID3DXBuffer *piBuffer = nullptr; + if (FAILED(D3DXCreateEffect(g_piDevice, + g_szDefaultShader.c_str(), + (UINT)g_szDefaultShader.length(), + nullptr, + nullptr, + AI_SHADER_COMPILE_FLAGS, + nullptr, + &g_piDefaultEffect, &piBuffer))) { + if (piBuffer) { + MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK); piBuffer->Release(); } return 0; } - if( piBuffer) - { + if (piBuffer) { piBuffer->Release(); piBuffer = nullptr; } // use Fixed Function effect when working with shaderless cards - if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0)) - g_piDefaultEffect->SetTechnique( "DefaultFXSpecular_FF"); + if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(2, 0)) + g_piDefaultEffect->SetTechnique("DefaultFXSpecular_FF"); // create the shader used to draw the HUD - if(FAILED( D3DXCreateEffect(g_piDevice, - g_szPassThroughShader.c_str(),(UINT)g_szPassThroughShader.length(), - nullptr,nullptr,AI_SHADER_COMPILE_FLAGS,nullptr,&g_piPassThroughEffect,&piBuffer))) - { - if( piBuffer) - { - MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK); + if (FAILED(D3DXCreateEffect(g_piDevice, + g_szPassThroughShader.c_str(), (UINT)g_szPassThroughShader.length(), + nullptr, nullptr, AI_SHADER_COMPILE_FLAGS, nullptr, &g_piPassThroughEffect, &piBuffer))) { + if (piBuffer) { + MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK); piBuffer->Release(); } return 0; } - if( piBuffer) - { + if (piBuffer) { piBuffer->Release(); piBuffer = nullptr; } // use Fixed Function effect when working with shaderless cards - if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0)) - g_piPassThroughEffect->SetTechnique( "PassThrough_FF"); + if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(2, 0)) + g_piPassThroughEffect->SetTechnique("PassThrough_FF"); // create the shader used to visualize normal vectors - if(FAILED( D3DXCreateEffect(g_piDevice, - g_szNormalsShader.c_str(),(UINT)g_szNormalsShader.length(), - nullptr,nullptr,AI_SHADER_COMPILE_FLAGS,nullptr,&g_piNormalsEffect, &piBuffer))) - { - if( piBuffer) - { - MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK); + if (FAILED(D3DXCreateEffect(g_piDevice, + g_szNormalsShader.c_str(), (UINT)g_szNormalsShader.length(), + nullptr, nullptr, AI_SHADER_COMPILE_FLAGS, nullptr, &g_piNormalsEffect, &piBuffer))) { + if (piBuffer) { + MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK); piBuffer->Release(); } return 0; } - if( piBuffer) - { + if (piBuffer) { piBuffer->Release(); piBuffer = nullptr; } @@ -1093,30 +1005,28 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/) //MessageBox( g_hDlg, "Failed to create vertex declaration", "Init", MB_OK); // use Fixed Function effect when working with shaderless cards - if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0)) - g_piNormalsEffect->SetTechnique( "RenderNormals_FF"); + if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(2, 0)) + g_piNormalsEffect->SetTechnique("RenderNormals_FF"); - g_piDevice->SetRenderState(D3DRS_DITHERENABLE,TRUE); + g_piDevice->SetRenderState(D3DRS_DITHERENABLE, TRUE); // create the texture for the HUD CreateHUDTexture(); CBackgroundPainter::Instance().RecreateNativeResource(); CLogDisplay::Instance().RecreateNativeResource(); - g_piPassThroughEffect->SetTexture("TEXTURE_2D",g_pcTexture); + g_piPassThroughEffect->SetTexture("TEXTURE_2D", g_pcTexture); return 1; } //------------------------------------------------------------------------------- -int CreateDevice() -{ +int CreateDevice() { return CreateDevice(g_sOptions.bMultiSample, - g_sOptions.bSuperSample); + g_sOptions.bSuperSample); } //------------------------------------------------------------------------------- -int GetProjectionMatrix (aiMatrix4x4& p_mOut) -{ +int GetProjectionMatrix(aiMatrix4x4 &p_mOut) { const float fFarPlane = 100.0f; const float fNearPlane = 0.1f; const float fFOV = (float)(45.0 * 0.0174532925); @@ -1125,30 +1035,29 @@ int GetProjectionMatrix (aiMatrix4x4& p_mOut) const float Q = fFarPlane / (fFarPlane - fNearPlane); RECT sRect; - GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect); + GetWindowRect(GetDlgItem(g_hDlg, IDC_RT), &sRect); sRect.right -= sRect.left; sRect.bottom -= sRect.top; const float fAspect = (float)sRect.right / (float)sRect.bottom; p_mOut = aiMatrix4x4( - s / fAspect, 0.0f, 0.0f, 0.0f, - 0.0f, s, 0.0f, 0.0f, - 0.0f, 0.0f, Q, 1.0f, - 0.0f, 0.0f, -Q * fNearPlane, 0.0f); + s / fAspect, 0.0f, 0.0f, 0.0f, + 0.0f, s, 0.0f, 0.0f, + 0.0f, 0.0f, Q, 1.0f, + 0.0f, 0.0f, -Q * fNearPlane, 0.0f); return 1; } //------------------------------------------------------------------------------- -aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut) -{ +aiVector3D GetCameraMatrix(aiMatrix4x4 &p_mOut) { D3DXMATRIX view; - D3DXMatrixIdentity( &view ); + D3DXMatrixIdentity(&view); - D3DXVec3Normalize( (D3DXVECTOR3*)&g_sCamera.vLookAt, (D3DXVECTOR3*)&g_sCamera.vLookAt ); - D3DXVec3Cross( (D3DXVECTOR3*)&g_sCamera.vRight, (D3DXVECTOR3*)&g_sCamera.vUp, (D3DXVECTOR3*)&g_sCamera.vLookAt ); - D3DXVec3Normalize( (D3DXVECTOR3*)&g_sCamera.vRight, (D3DXVECTOR3*)&g_sCamera.vRight ); - D3DXVec3Cross( (D3DXVECTOR3*)&g_sCamera.vUp, (D3DXVECTOR3*)&g_sCamera.vLookAt, (D3DXVECTOR3*)&g_sCamera.vRight ); - D3DXVec3Normalize( (D3DXVECTOR3*)&g_sCamera.vUp, (D3DXVECTOR3*)&g_sCamera.vUp ); + D3DXVec3Normalize((D3DXVECTOR3 *)&g_sCamera.vLookAt, (D3DXVECTOR3 *)&g_sCamera.vLookAt); + D3DXVec3Cross((D3DXVECTOR3 *)&g_sCamera.vRight, (D3DXVECTOR3 *)&g_sCamera.vUp, (D3DXVECTOR3 *)&g_sCamera.vLookAt); + D3DXVec3Normalize((D3DXVECTOR3 *)&g_sCamera.vRight, (D3DXVECTOR3 *)&g_sCamera.vRight); + D3DXVec3Cross((D3DXVECTOR3 *)&g_sCamera.vUp, (D3DXVECTOR3 *)&g_sCamera.vLookAt, (D3DXVECTOR3 *)&g_sCamera.vRight); + D3DXVec3Normalize((D3DXVECTOR3 *)&g_sCamera.vUp, (D3DXVECTOR3 *)&g_sCamera.vUp); view._11 = g_sCamera.vRight.x; view._12 = g_sCamera.vUp.x; @@ -1165,14 +1074,14 @@ aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut) view._33 = g_sCamera.vLookAt.z; view._34 = 0.0f; - view._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&g_sCamera.vPos, (D3DXVECTOR3*)&g_sCamera.vRight ); - view._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&g_sCamera.vPos, (D3DXVECTOR3*)&g_sCamera.vUp ); - view._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&g_sCamera.vPos, (D3DXVECTOR3*)&g_sCamera.vLookAt ); - view._44 = 1.0f; + view._41 = -D3DXVec3Dot((D3DXVECTOR3 *)&g_sCamera.vPos, (D3DXVECTOR3 *)&g_sCamera.vRight); + view._42 = -D3DXVec3Dot((D3DXVECTOR3 *)&g_sCamera.vPos, (D3DXVECTOR3 *)&g_sCamera.vUp); + view._43 = -D3DXVec3Dot((D3DXVECTOR3 *)&g_sCamera.vPos, (D3DXVECTOR3 *)&g_sCamera.vLookAt); + view._44 = 1.0f; - memcpy(&p_mOut,&view,sizeof(aiMatrix4x4)); + memcpy(&p_mOut, &view, sizeof(aiMatrix4x4)); return g_sCamera.vPos; } -} +} // namespace AssimpView diff --git a/tools/assimp_view/assimp_view.h b/tools/assimp_view/assimp_view.h index 2adffacff..8e04f7117 100644 --- a/tools/assimp_view/assimp_view.h +++ b/tools/assimp_view/assimp_view.h @@ -51,27 +51,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "resource.h" #include -#include #include #include -#include #include +#include +#include #include // Include ASSIMP headers (XXX: do we really need all of them?) -#include -#include #include #include +#include #include #include -#include -#include -#include #include +#include +#include +#include +#include -#include "Material/MaterialSystem.h" // aiMaterial class -#include // ASSIMP_stricmp and ASSIMP_strincmp +#include "Material/MaterialSystem.h" // aiMaterial class +#include // ASSIMP_stricmp and ASSIMP_strincmp #include @@ -79,33 +79,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MOVE_SPEED 3.f #include "AssetHelper.h" -#include "Camera.h" -#include "RenderOptions.h" -#include "Shaders.h" #include "Background.h" +#include "Camera.h" +#include "Display.h" #include "LogDisplay.h" #include "LogWindow.h" -#include "Display.h" -#include "MeshRenderer.h" #include "MaterialManager.h" - +#include "MeshRenderer.h" +#include "RenderOptions.h" +#include "Shaders.h" // outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle #include "AnimEvaluator.h" #include "SceneAnimator.h" -namespace AssimpView -{ +namespace AssimpView { //------------------------------------------------------------------------------- // Function prototypes //------------------------------------------------------------------------------- int InitD3D(void); int ShutdownD3D(void); -int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true); -int CreateDevice (void); +int CreateDevice(bool p_bMultiSample, bool p_bSuperSample, bool bHW = true); +int CreateDevice(void); int ShutdownDevice(void); -int GetProjectionMatrix (aiMatrix4x4& p_mOut); +int GetProjectionMatrix(aiMatrix4x4 &p_mOut); int LoadAsset(void); int CreateAssetData(void); int DeleteAssetData(bool bNoMaterials = false); @@ -113,26 +111,25 @@ int ScaleAsset(void); int DeleteAsset(void); int SetupFPSView(); -aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut); -int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource); - -void HandleMouseInputFPS( void ); -void HandleMouseInputLightRotate( void ); -void HandleMouseInputLocal( void ); -void HandleKeyboardInputFPS( void ); -void HandleMouseInputLightIntensityAndColor( void ); -void HandleMouseInputSkyBox( void ); -void HandleKeyboardInputTextureView( void ); -void HandleMouseInputTextureView( void ); +aiVector3D GetCameraMatrix(aiMatrix4x4 &p_mOut); +int CreateMaterial(AssetHelper::MeshHelper *pcMesh, const aiMesh *pcSource); +void HandleMouseInputFPS(void); +void HandleMouseInputLightRotate(void); +void HandleMouseInputLocal(void); +void HandleKeyboardInputFPS(void); +void HandleMouseInputLightIntensityAndColor(void); +void HandleMouseInputSkyBox(void); +void HandleKeyboardInputTextureView(void); +void HandleMouseInputTextureView(void); //------------------------------------------------------------------------------- // // Dialog procedure for the progress bar window // //------------------------------------------------------------------------------- -INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg, - WPARAM wParam,LPARAM lParam); +INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg, UINT uMsg, + WPARAM wParam, LPARAM lParam); //------------------------------------------------------------------------------- // Main message procedure of the application @@ -142,25 +139,24 @@ INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg, // NOTE: Due to the impossibility to process WM_CHAR messages in dialogs // properly the code for all hotkeys has been moved to the WndMain //------------------------------------------------------------------------------- -INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, - WPARAM wParam,LPARAM lParam); +INT_PTR CALLBACK MessageProc(HWND hwndDlg, UINT uMsg, + WPARAM wParam, LPARAM lParam); //------------------------------------------------------------------------------- // // Dialog procedure for the about dialog // //------------------------------------------------------------------------------- -INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg, - WPARAM wParam,LPARAM lParam); +INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg, UINT uMsg, + WPARAM wParam, LPARAM lParam); //------------------------------------------------------------------------------- // // Dialog procedure for the help dialog // //------------------------------------------------------------------------------- -INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg, - WPARAM wParam,LPARAM lParam); - +INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg, UINT uMsg, + WPARAM wParam, LPARAM lParam); //------------------------------------------------------------------------------- // Handle command line parameters @@ -168,24 +164,20 @@ INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg, // The function loads an asset specified on the command line as first argument // Other command line parameters are not handled //------------------------------------------------------------------------------- -void HandleCommandLine(char* p_szCommand); - +void HandleCommandLine(char *p_szCommand); //------------------------------------------------------------------------------- template -type clamp(intype in) -{ +type clamp(intype in) { // for unsigned types only ... - intype mask = (0x1u << (sizeof(type)*8))-1; - return (type)std::max((intype)0,std::min(in,mask)); + intype mask = (0x1u << (sizeof(type) * 8)) - 1; + return (type)std::max((intype)0, std::min(in, mask)); } - //------------------------------------------------------------------------------- // Position of the cursor relative to the 3ds max' like control circle //------------------------------------------------------------------------------- -enum EClickPos -{ +enum EClickPos { // The click was inside the inner circle (x,y axis) EClickPos_Circle, // The click was inside one of the vertical snap-ins @@ -197,84 +189,82 @@ enum EClickPos }; #if (!defined AI_VIEW_CAPTION_BASE) -# define AI_VIEW_CAPTION_BASE "Open Asset Import Library : Viewer " +#define AI_VIEW_CAPTION_BASE "Open Asset Import Library : Viewer " #endif // !! AI_VIEW_CAPTION_BASE //------------------------------------------------------------------------------- // Evil globals //------------------------------------------------------------------------------- - extern HINSTANCE g_hInstance /*= NULL*/; - extern HWND g_hDlg /*= NULL*/; - extern IDirect3D9* g_piD3D /*= NULL*/; - extern IDirect3DDevice9* g_piDevice /*= NULL*/; - extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/; - extern double g_fFPS /*= 0.0f*/; - extern char g_szFileName[MAX_PATH]; - extern ID3DXEffect* g_piDefaultEffect /*= NULL*/; - extern ID3DXEffect* g_piNormalsEffect /*= NULL*/; - extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/; - extern ID3DXEffect* g_piPatternEffect /*= NULL*/; - extern bool g_bMousePressed /*= false*/; - extern bool g_bMousePressedR /*= false*/; - extern bool g_bMousePressedM /*= false*/; - extern bool g_bMousePressedBoth /*= false*/; - extern float g_fElpasedTime /*= 0.0f*/; - extern D3DCAPS9 g_sCaps; - extern bool g_bLoadingFinished /*= false*/; - extern HANDLE g_hThreadHandle /*= NULL*/; - extern float g_fWheelPos /*= -10.0f*/; - extern bool g_bLoadingCanceled /*= false*/; - extern IDirect3DTexture9* g_pcTexture /*= NULL*/; +extern HINSTANCE g_hInstance /*= NULL*/; +extern HWND g_hDlg /*= NULL*/; +extern IDirect3D9 *g_piD3D /*= NULL*/; +extern IDirect3DDevice9 *g_piDevice /*= NULL*/; +extern IDirect3DVertexDeclaration9 *gDefaultVertexDecl /*= NULL*/; +extern double g_fFPS /*= 0.0f*/; +extern char g_szFileName[MAX_PATH]; +extern ID3DXEffect *g_piDefaultEffect /*= NULL*/; +extern ID3DXEffect *g_piNormalsEffect /*= NULL*/; +extern ID3DXEffect *g_piPassThroughEffect /*= NULL*/; +extern ID3DXEffect *g_piPatternEffect /*= NULL*/; +extern bool g_bMousePressed /*= false*/; +extern bool g_bMousePressedR /*= false*/; +extern bool g_bMousePressedM /*= false*/; +extern bool g_bMousePressedBoth /*= false*/; +extern float g_fElpasedTime /*= 0.0f*/; +extern D3DCAPS9 g_sCaps; +extern bool g_bLoadingFinished /*= false*/; +extern HANDLE g_hThreadHandle /*= NULL*/; +extern float g_fWheelPos /*= -10.0f*/; +extern bool g_bLoadingCanceled /*= false*/; +extern IDirect3DTexture9 *g_pcTexture /*= NULL*/; - extern aiMatrix4x4 g_mWorld; - extern aiMatrix4x4 g_mWorldRotate; - extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/; +extern aiMatrix4x4 g_mWorld; +extern aiMatrix4x4 g_mWorldRotate; +extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/; - extern aiVector3D g_avLightDirs[1] /* = +extern aiVector3D g_avLightDirs[1] /* = { aiVector3D(-0.5f,0.6f,0.2f) , - aiVector3D(-0.5f,0.5f,0.5f)} */; + aiVector3D(-0.5f,0.5f,0.5f)} */ + ; +extern POINT g_mousePos /*= {0,0};*/; +extern POINT g_LastmousePos /*= {0,0}*/; +extern bool g_bFPSView /*= false*/; +extern bool g_bInvert /*= false*/; +extern EClickPos g_eClick; +extern unsigned int g_iCurrentColor /*= 0*/; - extern POINT g_mousePos /*= {0,0};*/; - extern POINT g_LastmousePos /*= {0,0}*/; - extern bool g_bFPSView /*= false*/; - extern bool g_bInvert /*= false*/; - extern EClickPos g_eClick; - extern unsigned int g_iCurrentColor /*= 0*/; +// NOTE: The light intensity is separated from the color, it can +// directly be manipulated using the middle mouse button. +// When the user chooses a color from the palette the intensity +// is reset to 1.0 +// index[2] is the ambient color +extern float g_fLightIntensity /*=0.0f*/; +extern D3DCOLOR g_avLightColors[3]; - // NOTE: The light intensity is separated from the color, it can - // directly be manipulated using the middle mouse button. - // When the user chooses a color from the palette the intensity - // is reset to 1.0 - // index[2] is the ambient color - extern float g_fLightIntensity /*=0.0f*/; - extern D3DCOLOR g_avLightColors[3]; +extern RenderOptions g_sOptions; +extern Camera g_sCamera; +extern AssetHelper *g_pcAsset /*= NULL*/; - extern RenderOptions g_sOptions; - extern Camera g_sCamera; - extern AssetHelper *g_pcAsset /*= NULL*/; +// +// Contains the mask image for the HUD +// (used to determine the position of a click) +// +// The size of the image is identical to the size of the main +// HUD texture +// +extern unsigned char *g_szImageMask /*= NULL*/; +extern float g_fACMR /*= 3.0f*/; +extern IDirect3DQuery9 *g_piQuery; - // - // Contains the mask image for the HUD - // (used to determine the position of a click) - // - // The size of the image is identical to the size of the main - // HUD texture - // - extern unsigned char* g_szImageMask /*= NULL*/; +extern bool g_bPlay /*= false*/; +extern double g_dCurrent; +extern float g_smoothAngle /*= 80.f*/; - extern float g_fACMR /*= 3.0f*/; - extern IDirect3DQuery9* g_piQuery; +extern unsigned int ppsteps, ppstepsdefault; +extern bool nopointslines; +} // namespace AssimpView - extern bool g_bPlay /*= false*/; - - extern double g_dCurrent; - extern float g_smoothAngle /*= 80.f*/; - - extern unsigned int ppsteps,ppstepsdefault; - extern bool nopointslines; - } - -#endif // !! AV_MAIN_H_INCLUDED \ No newline at end of file +#endif // !! AV_MAIN_H_INCLUDED