Just the functional assimp lib rather than the entire assimp repository unnecessarily.

This commit is contained in:
Areloch 2019-02-28 16:37:15 -06:00
parent 0f7641a282
commit e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions

View file

@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2018, assimp team
Copyright (c) 2006-2017, assimp team
All rights reserved.
@ -72,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# endif
#endif
#include <assimp/LineSplitter.h>
#include "LineSplitter.h"
// uncomment this to have the loader evaluate all entities upon loading.
// this is intended as stress test - by default, entities are evaluated
@ -139,10 +138,10 @@ namespace STEP {
* error (i.e. an entity expects a string but receives a bool) occurs.
* It is typically coupled with both an entity id and a line number.*/
// -------------------------------------------------------------------------------
struct TypeError : DeadlyImportError {
struct TypeError : DeadlyImportError
{
enum {
ENTITY_NOT_SPECIFIED = 0xffffffffffffffffLL,
ENTITY_NOT_SPECIFIED_32 = -1u
ENTITY_NOT_SPECIFIED = 0xffffffffffffffffLL
};
TypeError (const std::string& s,uint64_t entity = ENTITY_NOT_SPECIFIED, uint64_t line = SyntaxError::LINE_NOT_SPECIFIED);
@ -164,6 +163,7 @@ namespace STEP {
class DataType
{
public:
typedef std::shared_ptr<const DataType> Out;
public:
@ -356,60 +356,53 @@ namespace STEP {
MemberList members;
};
class BINARY : public PrimitiveDataType<uint32_t> {
public:
BINARY(uint32_t val)
: PrimitiveDataType<uint32_t>(val) {
// empty
}
BINARY()
: PrimitiveDataType<uint32_t>(TypeError::ENTITY_NOT_SPECIFIED_32) {
// empty
}
};
// -------------------------------------------------------------------------------
/* Not exactly a full EXPRESS schema but rather a list of conversion functions
* to extract valid C++ objects out of a STEP file. Those conversion functions
* may, however, perform further schema validations. */
// -------------------------------------------------------------------------------
class ConversionSchema {
public:
struct SchemaEntry {
SchemaEntry( const char *name, ConvertObjectProc func )
: mName( name )
, mFunc(func) {
// empty
}
class ConversionSchema
{
const char* mName;
ConvertObjectProc mFunc;
public:
struct SchemaEntry {
SchemaEntry(const char* name,ConvertObjectProc func)
: name(name)
, func(func)
{}
const char* name;
ConvertObjectProc func;
};
typedef std::map<std::string,ConvertObjectProc> ConverterMap;
public:
template <size_t N>
explicit ConversionSchema( const SchemaEntry (& schemas)[N]) {
*this = schemas;
}
ConversionSchema() {
ConversionSchema() {}
}
public:
ConvertObjectProc GetConverterProc(const std::string& name) const {
ConverterMap::const_iterator it = converters.find(name);
return it == converters.end() ? nullptr : (*it).second;
return it == converters.end() ? NULL : (*it).second;
}
bool IsKnownToken(const std::string& name) const {
return converters.find(name) != converters.end();
}
const char* GetStaticStringForToken(const std::string& token) const {
ConverterMap::const_iterator it = converters.find(token);
return it == converters.end() ? nullptr : (*it).first.c_str();
return it == converters.end() ? NULL : (*it).first.c_str();
}
@ -417,12 +410,13 @@ namespace STEP {
const ConversionSchema& operator=( const SchemaEntry (& schemas)[N]) {
for(size_t i = 0; i < N; ++i ) {
const SchemaEntry& schema = schemas[i];
converters[schema.mName] = schema.mFunc;
converters[schema.name] = schema.func;
}
return *this;
}
private:
ConverterMap converters;
};
}
@ -457,6 +451,8 @@ namespace STEP {
// empty
}
public:
// utilities to simplify casting to concrete types
template <typename T>
const T& To() const {
@ -478,6 +474,7 @@ namespace STEP {
return dynamic_cast<T*>(this);
}
public:
uint64_t GetID() const {
return id;
}
@ -504,11 +501,9 @@ namespace STEP {
/** CRTP shared base class for use by concrete entity implementation classes */
// ------------------------------------------------------------------------------
template <typename TDerived, size_t arg_count>
struct ObjectHelper : virtual Object {
ObjectHelper()
: aux_is_derived(0) {
// empty
}
struct ObjectHelper : virtual Object
{
ObjectHelper() : aux_is_derived(0) {}
static Object* Construct(const STEP::DB& db, const EXPRESS::LIST& params) {
// make sure we don't leak if Fill() throws an exception
@ -537,16 +532,10 @@ namespace STEP {
/** Class template used to represent OPTIONAL data members in the converted schema */
// ------------------------------------------------------------------------------
template <typename T>
struct Maybe {
Maybe()
: have() {
// empty
}
explicit Maybe(const T& ptr)
: ptr(ptr)
, have(true) {
// empty
struct Maybe
{
Maybe() : have() {}
explicit Maybe(const T& ptr) : ptr(ptr), have(true) {
}
@ -583,6 +572,7 @@ namespace STEP {
}
private:
template <typename T2> friend struct InternGenericConvert;
operator T&() {
@ -597,13 +587,16 @@ namespace STEP {
/** A LazyObject is created when needed. Before this happens, we just keep
the text line that contains the object definition. */
// -------------------------------------------------------------------------------
class LazyObject {
class LazyObject
{
friend class DB;
public:
LazyObject(DB& db, uint64_t id, uint64_t line, const char* type,const char* args);
~LazyObject();
public:
Object& operator * () {
if (!obj) {
LazyInit();
@ -661,37 +654,38 @@ namespace STEP {
}
private:
void LazyInit() const;
private:
mutable uint64_t id;
const char* const type;
DB& db;
mutable const char* args;
mutable Object* obj;
};
template <typename T>
inline
bool operator==( std::shared_ptr<LazyObject> lo, T whatever ) {
inline bool operator==( std::shared_ptr<LazyObject> lo, T whatever ) {
return *lo == whatever; // XXX use std::forward if we have 0x
}
template <typename T>
inline
bool operator==( const std::pair<uint64_t, std::shared_ptr<LazyObject> >& lo, T whatever ) {
inline bool operator==( const std::pair<uint64_t, std::shared_ptr<LazyObject> >& lo, T whatever ) {
return *(lo.second) == whatever; // XXX use std::forward if we have 0x
}
// ------------------------------------------------------------------------------
/** Class template used to represent lazily evaluated object references in the converted schema */
// ------------------------------------------------------------------------------
template <typename T>
struct Lazy {
struct Lazy
{
typedef Lazy Out;
Lazy(const LazyObject* obj = nullptr)
: obj(obj) {
// empty
Lazy(const LazyObject* obj = NULL) : obj(obj) {
}
operator const T*() const {
@ -717,15 +711,19 @@ namespace STEP {
/** Class template used to represent LIST and SET data members in the converted schema */
// ------------------------------------------------------------------------------
template <typename T, uint64_t min_cnt, uint64_t max_cnt=0uL>
struct ListOf : public std::vector<typename T::Out> {
struct ListOf : public std::vector<typename T::Out>
{
typedef typename T::Out OutScalar;
typedef ListOf Out;
ListOf() {
static_assert(min_cnt <= max_cnt || !max_cnt, "min_cnt <= max_cnt || !max_cnt");
}
};
// ------------------------------------------------------------------------------
template <typename TOut>
struct PickBaseType {
@ -737,8 +735,7 @@ namespace STEP {
typedef EXPRESS::ENTITY Type;
};
template<>
struct PickBaseType< std::shared_ptr< const EXPRESS::DataType > >;
template <> struct PickBaseType< std::shared_ptr< const EXPRESS::DataType > >;
// ------------------------------------------------------------------------------
template <typename T>
@ -746,7 +743,8 @@ namespace STEP {
void operator()(T& out, const std::shared_ptr< const EXPRESS::DataType >& in, const STEP::DB& /*db*/) {
try{
out = dynamic_cast< const typename PickBaseType<T>::Type& > ( *in );
} catch(std::bad_cast&) {
}
catch(std::bad_cast&) {
throw TypeError("type error reading literal field");
}
}
@ -778,10 +776,10 @@ namespace STEP {
// XXX is this really how the EXPRESS notation ([?:3],[1:3]) is intended?
if (max_cnt && inp->GetSize() > max_cnt) {
ASSIMP_LOG_WARN("too many aggregate elements");
DefaultLogger::get()->warn("too many aggregate elements");
}
else if (inp->GetSize() < min_cnt) {
ASSIMP_LOG_WARN("too few aggregate elements");
DefaultLogger::get()->warn("too few aggregate elements");
}
out.reserve(inp->GetSize());
@ -819,6 +817,7 @@ namespace STEP {
return InternGenericConvertList<T1,N1,N2>()(a,b,db);
}
// ------------------------------------------------------------------------------
/** Lightweight manager class that holds the map of all objects in a
* STEP file. DB's are exclusively maintained by the functions in
@ -835,6 +834,7 @@ namespace STEP {
friend class LazyObject;
public:
// objects indexed by ID - this can grow pretty large (i.e some hundred million
// entries), so use raw pointers to avoid *any* overhead.
typedef std::map<uint64_t,const LazyObject* > ObjectMap;
@ -859,16 +859,19 @@ namespace STEP {
: reader(reader)
, splitter(*reader,true,true)
, evaluated_count()
, schema( nullptr )
, schema( NULL )
{}
public:
~DB() {
for(ObjectMap::value_type& o : objects) {
delete o.second;
}
}
public:
uint64_t GetObjectCount() const {
return objects.size();
}
@ -897,6 +900,7 @@ namespace STEP {
return refs;
}
bool KeepInverseIndicesForType(const char* const type) const {
return inv_whitelist.find(type) != inv_whitelist.end();
}
@ -908,7 +912,7 @@ namespace STEP {
if (it != objects.end()) {
return (*it).second;
}
return nullptr;
return NULL;
}