Coverage Report

Created: 2025-08-28 06:38

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