/src/assimp/code/AssetLib/X3D/X3DImporter_Macro.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | Open Asset Import Library (assimp) |
3 | | ---------------------------------------------------------------------- |
4 | | |
5 | | Copyright (c) 2006-2019, assimp team |
6 | | |
7 | | |
8 | | All rights reserved. |
9 | | |
10 | | Redistribution and use of this software in source and binary forms, |
11 | | with or without modification, are permitted provided that the |
12 | | following conditions are met: |
13 | | |
14 | | * Redistributions of source code must retain the above |
15 | | copyright notice, this list of conditions and the |
16 | | following disclaimer. |
17 | | |
18 | | * Redistributions in binary form must reproduce the above |
19 | | copyright notice, this list of conditions and the |
20 | | following disclaimer in the documentation and/or other |
21 | | materials provided with the distribution. |
22 | | |
23 | | * Neither the name of the assimp team, nor the names of its |
24 | | contributors may be used to endorse or promote products |
25 | | derived from this software without specific prior |
26 | | written permission of the assimp team. |
27 | | |
28 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
29 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
30 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
31 | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
32 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
33 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
34 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
35 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
36 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
37 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
38 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
39 | | |
40 | | ---------------------------------------------------------------------- |
41 | | */ |
42 | | /// \file X3DImporter_Macro.hpp |
43 | | /// \brief Useful macrodefines. |
44 | | /// \date 2015-2016 |
45 | | /// \author smal.root@gmail.com |
46 | | |
47 | | #ifndef X3DIMPORTER_MACRO_HPP_INCLUDED |
48 | | #define X3DIMPORTER_MACRO_HPP_INCLUDED |
49 | | |
50 | | #include <assimp/XmlParser.h> |
51 | | #include "X3DImporter.hpp" |
52 | | #include <string> |
53 | | |
54 | | namespace Assimp { |
55 | | |
56 | | /// Used for regular checking while attribute "USE" is defined. |
57 | | /// \param [in] pNode - pugi xml node to read. |
58 | | /// \param [in] pDEF - string holding "DEF" value. |
59 | | /// \param [in] pUSE - string holding "USE" value. |
60 | | /// \param [in] pType - type of element to find. |
61 | | /// \param [out] pNE - pointer to found node element. |
62 | 0 | inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, const std::string &pDEF, const std::string &pUSE, X3DElemType pType, X3DNodeElementBase *pNE) { |
63 | 0 | checkNodeMustBeEmpty(node); |
64 | 0 | if (!pDEF.empty()) |
65 | 0 | Assimp::Throw_DEF_And_USE(node.name()); |
66 | 0 | if (!FindNodeElement(pUSE, pType, &pNE)) |
67 | 0 | Assimp::Throw_USE_NotFound(node.name(), pUSE); |
68 | 0 | ai_assert(nullptr != mNodeElementCur); |
69 | 0 | mNodeElementCur->Children.push_back(pNE); /* add found object as child to current element */ |
70 | |
|
71 | 0 | return pNE; |
72 | 0 | } |
73 | | |
74 | | } // namespace Assimp |
75 | | |
76 | | /// \def MACRO_ATTRREAD_CHECKUSEDEF_RET |
77 | | /// Compact variant for checking "USE" and "DEF". |
78 | | /// \param [in] pNode - pugi xml node to read. |
79 | | /// \param [out] pDEF_Var - output variable name for "DEF" value. |
80 | | /// \param [out] pUSE_Var - output variable name for "USE" value. |
81 | | #define MACRO_ATTRREAD_CHECKUSEDEF_RET(pNode, pDEF_Var, pUSE_Var) \ |
82 | 0 | do { \ |
83 | 0 | XmlParser::getStdStrAttribute(pNode, "DEF", pDEF_Var); \ |
84 | 0 | XmlParser::getStdStrAttribute(pNode, "USE", pUSE_Var); \ |
85 | 0 | } while (false) |
86 | | |
87 | | /// \def MACRO_FACE_ADD_QUAD_FA(pCCW, pOut, pIn, pP1, pP2, pP3, pP4) |
88 | | /// Add points as quad. Means that pP1..pP4 set in CCW order. |
89 | | #define MACRO_FACE_ADD_QUAD_FA(pCCW, pOut, pIn, pP1, pP2, pP3, pP4) \ |
90 | | do { \ |
91 | | if (pCCW) { \ |
92 | | pOut.push_back(pIn[pP1]); \ |
93 | | pOut.push_back(pIn[pP2]); \ |
94 | | pOut.push_back(pIn[pP3]); \ |
95 | | pOut.push_back(pIn[pP4]); \ |
96 | | } else { \ |
97 | | pOut.push_back(pIn[pP4]); \ |
98 | | pOut.push_back(pIn[pP3]); \ |
99 | | pOut.push_back(pIn[pP2]); \ |
100 | | pOut.push_back(pIn[pP1]); \ |
101 | | } \ |
102 | | } while (false) |
103 | | |
104 | | /// \def MACRO_FACE_ADD_QUAD(pCCW, pOut, pP1, pP2, pP3, pP4) |
105 | | /// Add points as quad. Means that pP1..pP4 set in CCW order. |
106 | | #define MACRO_FACE_ADD_QUAD(pCCW, pOut, pP1, pP2, pP3, pP4) \ |
107 | 0 | do { \ |
108 | 0 | if (pCCW) { \ |
109 | 0 | pOut.push_back(pP1); \ |
110 | 0 | pOut.push_back(pP2); \ |
111 | 0 | pOut.push_back(pP3); \ |
112 | 0 | pOut.push_back(pP4); \ |
113 | 0 | } else { \ |
114 | 0 | pOut.push_back(pP4); \ |
115 | 0 | pOut.push_back(pP3); \ |
116 | 0 | pOut.push_back(pP2); \ |
117 | 0 | pOut.push_back(pP1); \ |
118 | 0 | } \ |
119 | 0 | } while (false) |
120 | | |
121 | | #endif // X3DIMPORTER_MACRO_HPP_INCLUDED |