Compare commits

...
20 changed files with 100 additions and 127 deletions
+2 -4
View File
@@ -47,8 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_FBX_EXPORTER #ifndef ASSIMP_BUILD_NO_FBX_EXPORTER
namespace Assimp { namespace Assimp::FBX {
namespace FBX {
static constexpr size_t NumNullRecords = 25; static constexpr size_t NumNullRecords = 25;
@@ -84,8 +83,7 @@ enum TransformInheritance {
TransformInheritance_MAX // end-of-enum sentinel TransformInheritance_MAX // end-of-enum sentinel
}; };
} // namespace FBX } // namespace Assimp::FBX
} // namespace Assimp
#endif // ASSIMP_BUILD_NO_FBX_EXPORTER #endif // ASSIMP_BUILD_NO_FBX_EXPORTER
+2 -9
View File
@@ -50,11 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string> #include <string>
#include <cstring> #include <cstring>
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER namespace Assimp::FBX::Util {
namespace Assimp {
namespace FBX {
namespace Util {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const char* TokenTypeString(TokenType t) const char* TokenTypeString(TokenType t)
@@ -233,8 +229,5 @@ std::string EncodeBase64(const char* data, size_t length)
return encoded_string; return encoded_string;
} }
} // !Util } // namespace Assimp::FBX::Util
} // !FBX
} // !Assimp
#endif
+1 -9
View File
@@ -49,10 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXTokenizer.h" #include "FBXTokenizer.h"
#include <stdint.h> #include <stdint.h>
namespace Assimp { namespace Assimp::FBX::Util {
namespace FBX {
namespace Util {
/** helper for std::for_each to delete all heap-allocated items in a container */ /** helper for std::for_each to delete all heap-allocated items in a container */
template<typename T> template<typename T>
@@ -73,12 +70,9 @@ struct destructor_fun {
} }
}; };
/** Get a string representation for a #TokenType. */ /** Get a string representation for a #TokenType. */
const char* TokenTypeString(TokenType t); const char* TokenTypeString(TokenType t);
/** Format log/error messages using a given offset in the source binary file /** Format log/error messages using a given offset in the source binary file
* *
* @param offset offset within the file * @param offset offset within the file
@@ -129,8 +123,6 @@ char EncodeBase64(char byte);
* @return base64-encoded string*/ * @return base64-encoded string*/
std::string EncodeBase64(const char* data, size_t length); std::string EncodeBase64(const char* data, size_t length);
}
}
} }
#endif // ! INCLUDED_AI_FBX_UTIL_H #endif // ! INCLUDED_AI_FBX_UTIL_H
+32 -22
View File
@@ -80,7 +80,7 @@ ObjFileParser::ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::stri
m_buffer(), m_buffer(),
m_pIO(io), m_pIO(io),
m_progress(progress), m_progress(progress),
m_originalObjFileName(originalObjFileName) { m_originalObjFileName(originalObjFileName) {
std::fill_n(m_buffer, Buffersize, '\0'); std::fill_n(m_buffer, Buffersize, '\0');
// Create the model instance to store all the data // Create the model instance to store all the data
@@ -140,9 +140,11 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
if (insideCstype) { if (insideCstype) {
switch (*m_DataIt) { switch (*m_DataIt) {
case 'e': { case 'e': {
std::string name; char *name{nullptr};
getNameNoSpace(m_DataIt, m_DataItEnd, name); size_t len{0};
insideCstype = name != "end"; getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
//insideCstype = name != "end";
insideCstype = strncmp(name, "end", len) == 0;
} break; } break;
} }
goto pf_skip_line; goto pf_skip_line;
@@ -198,32 +200,37 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
case 'u': // Parse a material desc. setter case 'u': // Parse a material desc. setter
{ {
std::string name; //std::string name;
char *name{nullptr};
size_t len{ 0 };
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
getNameNoSpace(m_DataIt, m_DataItEnd, name); //size_t nextSpace = name.find(' ');
//if (nextSpace != std::string::npos)
// name = name.substr(0, nextSpace);
size_t nextSpace = name.find(' '); //if (name == "usemtl") {
if (nextSpace != std::string::npos) if (strncmp(name, "usemtl", len) == 0) {
name = name.substr(0, nextSpace);
if (name == "usemtl") {
getMaterialDesc(); getMaterialDesc();
} }
} break; } break;
case 'm': // Parse a material library or merging group ('mg') case 'm': // Parse a material library or merging group ('mg')
{ {
std::string name; // std::string name;
char *name{nullptr};
size_t len{ 0 };
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
getNameNoSpace(m_DataIt, m_DataItEnd, name); //size_t nextSpace = name.find(' ');
//if (nextSpace != std::string::npos)
// name = name.substr(0, nextSpace);
size_t nextSpace = name.find(' '); if (strncmp(name, "mg", len) == 0)
if (nextSpace != std::string::npos) //if (name == "mg")
name = name.substr(0, nextSpace);
if (name == "mg")
getGroupNumberAndResolution(); getGroupNumberAndResolution();
else if (name == "mtllib") //else if (name == "mtllib")
else if (strncmp(name, "mtllib", len) == 0)
getMaterialLib(); getMaterialLib();
else else
goto pf_skip_line; goto pf_skip_line;
@@ -246,9 +253,12 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
case 'c': // handle cstype section start case 'c': // handle cstype section start
{ {
std::string name; //std::string name;
getNameNoSpace(m_DataIt, m_DataItEnd, name); char *name{nullptr};
insideCstype = name == "cstype"; size_t len{0};
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
//insideCstype = name == "cstype";
insideCstype = strncmp(name, "cstype", len) == 0;
goto pf_skip_line; goto pf_skip_line;
} }
+9 -7
View File
@@ -177,8 +177,9 @@ inline char_t getName(char_t it, char_t end, std::string &name) {
* @return Current-iterator with new position * @return Current-iterator with new position
*/ */
template <class char_t> template <class char_t>
inline char_t getNameNoSpace(char_t it, char_t end, std::string &name) { inline char_t getNameNoSpace(char_t it, char_t end, char **name, size_t &len) {
name = ""; *name = nullptr;
len = 0;
if (isEndOfBuffer(it, end)) { if (isEndOfBuffer(it, end)) {
return end; return end;
} }
@@ -186,22 +187,23 @@ inline char_t getNameNoSpace(char_t it, char_t end, std::string &name) {
char *pStart = &(*it); char *pStart = &(*it);
while (!isEndOfBuffer(it, end) && !IsLineEnd(*it) && !IsSpaceOrNewLine(*it)) { while (!isEndOfBuffer(it, end) && !IsLineEnd(*it) && !IsSpaceOrNewLine(*it)) {
++it; ++it;
++len;
} }
while (isEndOfBuffer(it, end) || IsLineEnd(*it) || IsSpaceOrNewLine(*it)) { while (isEndOfBuffer(it, end) || IsLineEnd(*it) || IsSpaceOrNewLine(*it)) {
--it; --it;
--len;
} }
++it; ++it;
++len;
// Get name // Get name
// if there is no name, and the previous char is a separator, come back to start // if there is no name, and the previous char is a separator, come back to start
while (&(*it) < pStart) { while (&(*it) < pStart) {
++it; ++it;
++len;
} }
std::string strName(pStart, &(*it)); *name = pStart;
if (!strName.empty()) {
name = strName;
}
return it; return it;
} }
@@ -239,7 +241,7 @@ inline char_t CopyNextWord(char_t it, char_t end, char *pBuffer, size_t length)
*/ */
template <class char_t> template <class char_t>
inline char_t getFloat(char_t it, char_t end, ai_real &value) { inline char_t getFloat(char_t it, char_t end, ai_real &value) {
static const size_t BUFFERSIZE = 1024; static constexpr size_t BUFFERSIZE = 1024;
char buffer[BUFFERSIZE] = {}; char buffer[BUFFERSIZE] = {};
it = CopyNextWord<char_t>(it, end, buffer, BUFFERSIZE); it = CopyNextWord<char_t>(it, end, buffer, BUFFERSIZE);
value = (ai_real)fast_atof(buffer); value = (ai_real)fast_atof(buffer);
-4
View File
@@ -49,8 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GLTFASSET_H_INC #ifndef GLTFASSET_H_INC
#define GLTFASSET_H_INC #define GLTFASSET_H_INC
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
#include "AssetLib/glTFCommon/glTFCommon.h" #include "AssetLib/glTFCommon/glTFCommon.h"
#include <assimp/Exceptional.h> #include <assimp/Exceptional.h>
#include <list> #include <list>
@@ -1008,6 +1006,4 @@ private:
// Include the implementation of the methods // Include the implementation of the methods
#include "glTFAsset.inl" #include "glTFAsset.inl"
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // GLTFASSET_H_INC #endif // GLTFASSET_H_INC
+12 -12
View File
@@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GLTFASSETWRITER_H_INC #ifndef GLTFASSETWRITER_H_INC
#define GLTFASSETWRITER_H_INC #define GLTFASSETWRITER_H_INC
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER) //#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
#include "glTFAsset.h" #include "glTFAsset.h"
@@ -63,16 +63,6 @@ class AssetWriter
template<class T> template<class T>
friend void WriteLazyDict(LazyDict<T>& d, AssetWriter& w); friend void WriteLazyDict(LazyDict<T>& d, AssetWriter& w);
private:
void WriteBinaryData(IOStream* outfile, size_t sceneLength);
void WriteMetadata();
void WriteExtensionsUsed();
template<class T>
void WriteObjects(LazyDict<T>& d);
public: public:
Document mDoc; Document mDoc;
Asset& mAsset; Asset& mAsset;
@@ -80,9 +70,19 @@ public:
MemoryPoolAllocator<>& mAl; MemoryPoolAllocator<>& mAl;
AssetWriter(Asset& asset); AssetWriter(Asset& asset);
~AssetWriter() = default;
void WriteFile(const char* path); void WriteFile(const char* path);
void WriteGLBFile(const char* path); void WriteGLBFile(const char* path);
private:
void WriteBinaryData(IOStream* outfile, size_t sceneLength);
void WriteMetadata();
void WriteExtensionsUsed();
template<class T>
void WriteObjects(LazyDict<T>& d);
}; };
} }
@@ -90,6 +90,6 @@ public:
// Include the implementation of the methods // Include the implementation of the methods
#include "glTFAssetWriter.inl" #include "glTFAssetWriter.inl"
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER //#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // GLTFASSETWRITER_H_INC #endif // GLTFASSETWRITER_H_INC
+5 -1
View File
@@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER #ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
#include "AssetLib/glTF/glTFExporter.h" #include "AssetLib/glTF/glTFExporter.h"
#include "AssetLib/glTF/glTFAsset.h"
#include "AssetLib/glTF/glTFAssetWriter.h" #include "AssetLib/glTF/glTFAssetWriter.h"
#include "PostProcessing/SplitLargeMeshes.h" #include "PostProcessing/SplitLargeMeshes.h"
@@ -62,6 +63,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <limits> #include <limits>
#include <inttypes.h> #include <inttypes.h>
#include <rapidjson/rapidjson.h>
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC #ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
// Header files, Open3DGC. // Header files, Open3DGC.
# include <Open3DGC/o3dgcSC3DMCEncoder.h> # include <Open3DGC/o3dgcSC3DMCEncoder.h>
@@ -1064,6 +1069,5 @@ void glTFExporter::ExportAnimations()
} // End: for-loop mNumAnimations } // End: for-loop mNumAnimations
} }
#endif // ASSIMP_BUILD_NO_GLTF_EXPORTER #endif // ASSIMP_BUILD_NO_GLTF_EXPORTER
#endif // ASSIMP_BUILD_NO_EXPORT #endif // ASSIMP_BUILD_NO_EXPORT
+2 -2
View File
@@ -58,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GLTF2ASSET_H_INC #ifndef GLTF2ASSET_H_INC
#define GLTF2ASSET_H_INC #define GLTF2ASSET_H_INC
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER) //#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
#include <assimp/Exceptional.h> #include <assimp/Exceptional.h>
@@ -1283,6 +1283,6 @@ inline std::string getContextForErrorMessages(const std::string &id, const std::
// Include the implementation of the methods // Include the implementation of the methods
#include "glTF2Asset.inl" #include "glTF2Asset.inl"
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER //#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // GLTF2ASSET_H_INC #endif // GLTF2ASSET_H_INC
-4
View File
@@ -57,8 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GLTF2ASSETWRITER_H_INC #ifndef GLTF2ASSETWRITER_H_INC
#define GLTF2ASSETWRITER_H_INC #define GLTF2ASSETWRITER_H_INC
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
#include "glTF2Asset.h" #include "glTF2Asset.h"
namespace glTF2 namespace glTF2
@@ -98,6 +96,4 @@ public:
// Include the implementation of the methods // Include the implementation of the methods
#include "glTF2AssetWriter.inl" #include "glTF2AssetWriter.inl"
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // GLTF2ASSETWRITER_H_INC #endif // GLTF2ASSETWRITER_H_INC
+4
View File
@@ -64,6 +64,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
#include <iostream> #include <iostream>
#include <rapidjson/rapidjson.h>
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
using namespace rapidjson; using namespace rapidjson;
using namespace Assimp; using namespace Assimp;
-4
View File
@@ -45,8 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_GLTF2EXPORTER_H_INC #ifndef AI_GLTF2EXPORTER_H_INC
#define AI_GLTF2EXPORTER_H_INC #define AI_GLTF2EXPORTER_H_INC
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
#include <assimp/material.h> #include <assimp/material.h>
#include <assimp/types.h> #include <assimp/types.h>
#include <assimp/defs.h> #include <assimp/defs.h>
@@ -150,6 +148,4 @@ private:
} // namespace Assimp } // namespace Assimp
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // AI_GLTF2EXPORTER_H_INC #endif // AI_GLTF2EXPORTER_H_INC
+1
View File
@@ -65,6 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <rapidjson/document.h> #include <rapidjson/document.h>
#include <rapidjson/rapidjson.h> #include <rapidjson/rapidjson.h>
#include <rapidjson/error/en.h>
using namespace Assimp; using namespace Assimp;
using namespace glTF2; using namespace glTF2;
+2 -9
View File
@@ -38,15 +38,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
#include "AssetLib/glTFCommon/glTFCommon.h" #include "AssetLib/glTFCommon/glTFCommon.h"
namespace glTFCommon {
using namespace glTFCommon::Util; using namespace glTFCommon::Util;
namespace Util { namespace glTFCommon::Util {
bool ParseDataURI(const char *const_uri, size_t uriLen, DataURI &out) { bool ParseDataURI(const char *const_uri, size_t uriLen, DataURI &out) {
if (nullptr == const_uri) { if (nullptr == const_uri) {
@@ -111,7 +107,4 @@ bool ParseDataURI(const char *const_uri, size_t uriLen, DataURI &out) {
return true; return true;
} }
} // namespace Util } // namespace glTFCommon::Uti
} // namespace glTFCommon
#endif
-4
View File
@@ -41,8 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_GLFTCOMMON_H_INC #ifndef AI_GLFTCOMMON_H_INC
#define AI_GLFTCOMMON_H_INC #define AI_GLFTCOMMON_H_INC
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
#include <assimp/Exceptional.h> #include <assimp/Exceptional.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
@@ -532,6 +530,4 @@ inline Value *FindNumber(Value &val, const char *id) {
} // namespace glTFCommon } // namespace glTFCommon
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // AI_GLFTCOMMON_H_INC #endif // AI_GLFTCOMMON_H_INC
+8 -3
View File
@@ -602,6 +602,12 @@ ADD_ASSIMP_IMPORTER( XGL
AssetLib/XGL/XGLLoader.h AssetLib/XGL/XGLLoader.h
) )
SET( FBX_COMMON_SRCS
AssetLib/FBX/FBXUtil.h
AssetLib/FBX/FBXUtil.cpp
AssetLib/FBX/FBXCommon.h
)
ADD_ASSIMP_IMPORTER( FBX ADD_ASSIMP_IMPORTER( FBX
AssetLib/FBX/FBXImporter.cpp AssetLib/FBX/FBXImporter.cpp
AssetLib/FBX/FBXCompileConfig.h AssetLib/FBX/FBXCompileConfig.h
@@ -613,8 +619,6 @@ ADD_ASSIMP_IMPORTER( FBX
AssetLib/FBX/FBXImportSettings.h AssetLib/FBX/FBXImportSettings.h
AssetLib/FBX/FBXConverter.h AssetLib/FBX/FBXConverter.h
AssetLib/FBX/FBXConverter.cpp AssetLib/FBX/FBXConverter.cpp
AssetLib/FBX/FBXUtil.h
AssetLib/FBX/FBXUtil.cpp
AssetLib/FBX/FBXDocument.h AssetLib/FBX/FBXDocument.h
AssetLib/FBX/FBXDocument.cpp AssetLib/FBX/FBXDocument.cpp
AssetLib/FBX/FBXProperties.h AssetLib/FBX/FBXProperties.h
@@ -628,7 +632,6 @@ ADD_ASSIMP_IMPORTER( FBX
AssetLib/FBX/FBXDeformer.cpp AssetLib/FBX/FBXDeformer.cpp
AssetLib/FBX/FBXBinaryTokenizer.cpp AssetLib/FBX/FBXBinaryTokenizer.cpp
AssetLib/FBX/FBXDocumentUtil.cpp AssetLib/FBX/FBXDocumentUtil.cpp
AssetLib/FBX/FBXCommon.h
) )
if (NOT ASSIMP_NO_EXPORT) if (NOT ASSIMP_NO_EXPORT)
@@ -1348,6 +1351,8 @@ SET( assimp_src
${ASSIMP_LOADER_SRCS} ${ASSIMP_LOADER_SRCS}
${ASSIMP_EXPORTER_SRCS} ${ASSIMP_EXPORTER_SRCS}
${FBX_COMMON_SRCS}
# Third-party libraries # Third-party libraries
${unzip_compile_SRCS} ${unzip_compile_SRCS}
${Poly2Tri_SRCS} ${Poly2Tri_SRCS}
+4 -4
View File
@@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp; using namespace Assimp;
static const float VertComponents[24 * 3] = { static constexpr float VertComponents[24 * 3] = {
-0.500000, 0.500000, 0.500000, -0.500000, 0.500000, 0.500000,
-0.500000, 0.500000, -0.500000, -0.500000, 0.500000, -0.500000,
-0.500000, -0.500000, -0.500000, -0.500000, -0.500000, -0.500000,
@@ -76,7 +76,7 @@ static const float VertComponents[24 * 3] = {
0.500000, -0.500000, 0.500000f 0.500000, -0.500000, 0.500000f
}; };
static const char *ObjModel = static constexpr char ObjModel[] =
"o 1\n" "o 1\n"
"\n" "\n"
"# Vertex list\n" "# Vertex list\n"
@@ -103,7 +103,7 @@ static const char *ObjModel =
"\n" "\n"
"# End of file\n"; "# End of file\n";
static const char *ObjModel_Issue1111 = static constexpr char ObjModel_Issue1111[] =
"o 1\n" "o 1\n"
"\n" "\n"
"# Vertex list\n" "# Vertex list\n"
@@ -408,7 +408,7 @@ TEST_F(utObjImportExport, homogeneous_coordinates_divide_by_zero_Test) {
EXPECT_EQ(nullptr, scene); EXPECT_EQ(nullptr, scene);
} }
TEST_F(utObjImportExport, 0based_array_Test) { TEST_F(utObjImportExport, zero_based_array_Test) {
static const char *curObjModel = static const char *curObjModel =
"v -0.500000 0.000000 0.400000\n" "v -0.500000 0.000000 0.400000\n"
"v -0.500000 0.000000 -0.800000\n" "v -0.500000 0.000000 -0.800000\n"
+7 -8
View File
@@ -38,22 +38,19 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
#include "AssetLib/Obj/ObjFileParser.h" #include "AssetLib/Obj/ObjFileParser.h"
#include "AssetLib/Obj/ObjTools.h" #include "AssetLib/Obj/ObjTools.h"
#include "UnitTestPCH.h" #include "UnitTestPCH.h"
using namespace ::Assimp; using namespace ::Assimp;
class utObjTools : public ::testing::Test { class utObjTools : public ::testing::Test {};
// empty
};
class TestObjFileParser : public ObjFileParser { class TestObjFileParser : public ObjFileParser {
public: public:
TestObjFileParser() : TestObjFileParser() = default;
ObjFileParser() {
// empty
}
~TestObjFileParser() = default; ~TestObjFileParser() = default;
@@ -84,7 +81,7 @@ TEST_F(utObjTools, skipDataLine_TwoLines_Success) {
buffer.resize(data.size()); buffer.resize(data.size());
::memcpy(&buffer[0], &data[0], data.size()); ::memcpy(&buffer[0], &data[0], data.size());
test_parser.setBuffer(buffer); test_parser.setBuffer(buffer);
static const size_t Size = 4096UL; static constexpr size_t Size = 4096UL;
char data_buffer[Size]; char data_buffer[Size];
test_parser.testCopyNextWord(data_buffer, Size); test_parser.testCopyNextWord(data_buffer, Size);
@@ -112,3 +109,5 @@ TEST_F(utObjTools, countComponents_TwoLines_Success) {
size_t numComps = test_parser.testGetNumComponentsInDataDefinition(); size_t numComps = test_parser.testGetNumComponentsInDataDefinition();
EXPECT_EQ(3U, numComps); EXPECT_EQ(3U, numComps);
} }
#endif // ASSIMP_BUILD_NO_OBJ_IMPORTER
+5 -11
View File
@@ -52,22 +52,16 @@ using namespace ::Assimp;
class utSIBImporter : public AbstractImportExportBase { class utSIBImporter : public AbstractImportExportBase {
public: public:
virtual bool importerTest() { virtual bool importerTest() {
Assimp::Importer importer; Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", aiProcess_ValidateDataStructure);
return nullptr != scene; return nullptr != scene;
} }
}; };
TEST_F(utSIBImporter, createTest) {
bool ok(true);
try {
SIBImporter myImporter;
} catch (...) {
ok = false;
}
EXPECT_TRUE(ok);
}
TEST_F(utSIBImporter, importTest) { TEST_F(utSIBImporter, importTest) {
#ifdef ASSIMP_BUILD_NO_SIB_IMPORTER
EXPECT_FALSE(importerTest());
#else
EXPECT_TRUE(importerTest()); EXPECT_TRUE(importerTest());
#endif
} }
+4 -10
View File
@@ -56,18 +56,12 @@ public:
} }
}; };
TEST_F(utSMDImporter, createTest) {
bool ok(true);
try {
SMDImporter myImporter;
} catch (...) {
ok = false;
}
EXPECT_TRUE(ok);
}
TEST_F(utSMDImporter, importTest) { TEST_F(utSMDImporter, importTest) {
#ifndef ASSIMP_BUILD_NO_SMD_IMPORTER
EXPECT_TRUE(importerTest()); EXPECT_TRUE(importerTest());
#else
EXPECT_FALSE(importerTest());
#endif
} }
TEST_F(utSMDImporter, issue_899_Texture_garbage_at_end_of_string_Test) { TEST_F(utSMDImporter, issue_899_Texture_garbage_at_end_of_string_Test) {