Coverage Report

Created: 2026-10-28 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/assimp/code/AssetLib/COB/COBLoader.h
Line
Count
Source
1
/*
2
Open Asset Import Library (assimp)
3
----------------------------------------------------------------------
4
5
Copyright (c) 2006-2026, 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
42
/** @file  COBLoader.h
43
 *  @brief Declaration of the TrueSpace (*.cob,*.scn) importer class.
44
 */
45
#ifndef INCLUDED_AI_COB_LOADER_H
46
#define INCLUDED_AI_COB_LOADER_H
47
48
#include <assimp/BaseImporter.h>
49
#include <assimp/StreamReader.h>
50
51
struct aiNode;
52
53
namespace Assimp {
54
class LineSplitter;
55
56
// TinyFormatter.h
57
namespace Formatter {
58
    template <typename T, typename TR, typename A>
59
    class basic_formatter;
60
    typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
61
} // namespace Formatter
62
63
// COBScene.h
64
namespace COB {
65
    struct ChunkInfo;
66
    struct Node;
67
    struct Scene;
68
} // namespace COB
69
70
// -------------------------------------------------------------------------------------------
71
/// @brief Importer class to load TrueSpace files (cob,scn) up to v6.
72
///
73
/// Currently, relatively limited, loads only ASCII files and needs more test coverage.
74
// -------------------------------------------------------------------------------------------
75
class COBImporter final : public BaseImporter {
76
public:
77
130k
    COBImporter() = default;
78
    ~COBImporter() override = default;
79
    bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const override;
80
    AI_WONT_RETURN static void ThrowException(const std::string &msg) AI_WONT_RETURN_SUFFIX;
81
82
protected:
83
    const aiImporterDesc *GetInfo() const override;
84
    void SetupProperties(const Importer *pImp) override;
85
    void InternReadFile(const std::string &pFile, aiScene *pScene,
86
            IOSystem *pIOHandler) override;
87
88
private:
89
    // -------------------------------------------------------------------
90
    /** @brief Read from an ascii scene/object file
91
     *  @param out Receives output data.
92
     *  @param stream Stream to read from. */
93
    void ReadAsciiFile(COB::Scene &out, StreamReaderLE *stream);
94
95
    // -------------------------------------------------------------------
96
    /** @brief Read from a binary scene/object file
97
     *  @param out Receives output data.
98
     *  @param stream Stream to read from.  */
99
    void ReadBinaryFile(COB::Scene &out, StreamReaderLE *stream);
100
101
    // Conversion to Assimp output format
102
    aiNode *BuildNodes(const COB::Node &root, const COB::Scene &scin, aiScene *fill);
103
104
private:
105
    // ASCII file support
106
107
    void UnsupportedChunk_Ascii(LineSplitter &splitter, const COB::ChunkInfo &nfo, const char *name);
108
    void ReadChunkInfo_Ascii(COB::ChunkInfo &out, const LineSplitter &splitter);
109
    void ReadBasicNodeInfo_Ascii(COB::Node &msh, LineSplitter &splitter, const COB::ChunkInfo &nfo);
110
    template <typename T>
111
    void ReadFloat3Tuple_Ascii(T &fill, const char **in, const char *end);
112
113
    void ReadPolH_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
114
    void ReadBitM_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
115
    void ReadMat1_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
116
    void ReadGrou_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
117
    void ReadBone_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
118
    void ReadCame_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
119
    void ReadLght_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
120
    void ReadUnit_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
121
    void ReadChan_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
122
123
    // Binary file support
124
125
    void UnsupportedChunk_Binary(StreamReaderLE &reader, const COB::ChunkInfo &nfo, const char *name);
126
    void ReadString_Binary(std::string &out, StreamReaderLE &reader);
127
    void ReadBasicNodeInfo_Binary(COB::Node &msh, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
128
129
    void ReadPolH_Binary(COB::Scene &out, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
130
    void ReadBitM_Binary(COB::Scene &out, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
131
    void ReadMat1_Binary(COB::Scene &out, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
132
    void ReadCame_Binary(COB::Scene &out, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
133
    void ReadLght_Binary(COB::Scene &out, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
134
    void ReadGrou_Binary(COB::Scene &out, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
135
    void ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const COB::ChunkInfo &nfo);
136
137
}; // !class COBImporter
138
139
} // end of namespace Assimp
140
141
#endif // AI_UNREALIMPORTER_H_INC