Merge pull request #8 from assimp/master

Update Fork
pull/1350/head
Madrich 2015-09-04 13:08:28 +02:00
commit a58d0f57b3
137 changed files with 21094 additions and 18720 deletions

View File

@ -94,7 +94,11 @@ SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE PATH
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH
"Path the tool executables are installed to." ) "Path the tool executables are installed to." )
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools") IF (CMAKE_BUILD_TYPE STREQUAL "Release")
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Debug Postfix for lib, samples and tools")
ELSE()
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfix for lib, samples and tools")
ENDIF()
# Only generate this target if no higher-level project already has # Only generate this target if no higher-level project already has
IF (NOT TARGET uninstall) IF (NOT TARGET uninstall)

View File

@ -89,6 +89,9 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// read a string (may be enclosed in double quotation marks). buffer must point to " // read a string (may be enclosed in double quotation marks). buffer must point to "
#define AI_AC_GET_STRING(out) \ #define AI_AC_GET_STRING(out) \
if (*buffer == '\0') { \
throw DeadlyImportError("AC3D: Unexpected EOF in string"); \
} \
++buffer; \ ++buffer; \
const char* sz = buffer; \ const char* sz = buffer; \
while ('\"' != *buffer) \ while ('\"' != *buffer) \
@ -293,7 +296,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
SkipSpaces(&buffer); SkipSpaces(&buffer);
unsigned int t = strtoul10(buffer,&buffer); unsigned int t = strtoul10(buffer,&buffer);
if (t >= std::numeric_limits<int32_t>::max() / sizeof(aiVector3D)) { if (t >= AI_MAX_ALLOC(aiVector3D)) {
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory"); throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
} }
obj.vertices.reserve(t); obj.vertices.reserve(t);
@ -349,8 +352,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
{ {
if(!GetNextLine()) if(!GetNextLine())
{ {
DefaultLogger::get()->error("AC3D: Unexpected EOF: surface is incomplete"); throw DeadlyImportError("AC3D: Unexpected EOF: surface is incomplete");
break;
} }
if (TokenMatch(buffer,"mat",3)) if (TokenMatch(buffer,"mat",3))
{ {
@ -585,9 +587,19 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
// allocate storage for vertices and normals // allocate storage for vertices and normals
mesh->mNumFaces = (*cit).first; mesh->mNumFaces = (*cit).first;
if (mesh->mNumFaces == 0) {
throw DeadlyImportError("AC3D: No faces");
} else if (mesh->mNumFaces > AI_MAX_ALLOC(aiFace)) {
throw DeadlyImportError("AC3D: Too many faces, would run out of memory");
}
aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces]; aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
mesh->mNumVertices = (*cit).second; mesh->mNumVertices = (*cit).second;
if (mesh->mNumVertices == 0) {
throw DeadlyImportError("AC3D: No vertices");
} else if (mesh->mNumVertices > AI_MAX_ALLOC(aiVector3D)) {
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
}
aiVector3D* vertices = mesh->mVertices = new aiVector3D[mesh->mNumVertices]; aiVector3D* vertices = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
unsigned int cur = 0; unsigned int cur = 0;

View File

@ -103,7 +103,7 @@ struct Image;
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
struct ID : ElemBase { struct ID : ElemBase {
char name[24] WARN; char name[1024] WARN;
short flag; short flag;
}; };

View File

@ -1,23 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003 Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute, this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following: do so, all subject to the following:
The copyright notices in the Software and this entire statement, including The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer, the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by works are solely in the form of machine-executable object code generated by
a source language processor. a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.

View File

@ -1,99 +1,99 @@
#ifndef BOOST_FOREACH #ifndef BOOST_FOREACH
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// A stripped down version of FOREACH for // A stripped down version of FOREACH for
// illustration purposes. NOT FOR GENERAL USE. // illustration purposes. NOT FOR GENERAL USE.
// For a complete implementation, see BOOST_FOREACH at // For a complete implementation, see BOOST_FOREACH at
// http://boost-sandbox.sourceforge.net/vault/index.php?directory=eric_niebler // http://boost-sandbox.sourceforge.net/vault/index.php?directory=eric_niebler
// //
// Copyright 2004 Eric Niebler. // Copyright 2004 Eric Niebler.
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
// Adapted to Assimp November 29th, 2008 (Alexander Gessler). // Adapted to Assimp November 29th, 2008 (Alexander Gessler).
// Added code to handle both const and non-const iterators, simplified some // Added code to handle both const and non-const iterators, simplified some
// parts. // parts.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace boost {
namespace foreach_detail { namespace foreach_detail {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// auto_any // auto_any
struct auto_any_base struct auto_any_base
{ {
operator bool() const { return false; } operator bool() const { return false; }
}; };
template<typename T> template<typename T>
struct auto_any : auto_any_base struct auto_any : auto_any_base
{ {
auto_any(T const& t) : item(t) {} auto_any(T const& t) : item(t) {}
mutable T item; mutable T item;
}; };
template<typename T> template<typename T>
T& auto_any_cast(auto_any_base const& any) T& auto_any_cast(auto_any_base const& any)
{ {
return static_cast<auto_any<T> const&>(any).item; return static_cast<auto_any<T> const&>(any).item;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// FOREACH helper function // FOREACH helper function
template<typename T> template<typename T>
auto_any<typename T::const_iterator> begin(T const& t) auto_any<typename T::const_iterator> begin(T const& t)
{ {
return t.begin(); return t.begin();
} }
template<typename T> template<typename T>
auto_any<typename T::const_iterator> end(T const& t) auto_any<typename T::const_iterator> end(T const& t)
{ {
return t.end(); return t.end();
} }
// iterator // iterator
template<typename T> template<typename T>
bool done(auto_any_base const& cur, auto_any_base const& end, T&) bool done(auto_any_base const& cur, auto_any_base const& end, T&)
{ {
typedef typename T::iterator iter_type; typedef typename T::iterator iter_type;
return auto_any_cast<iter_type>(cur) == auto_any_cast<iter_type>(end); return auto_any_cast<iter_type>(cur) == auto_any_cast<iter_type>(end);
} }
template<typename T> template<typename T>
void next(auto_any_base const& cur, T&) void next(auto_any_base const& cur, T&)
{ {
++auto_any_cast<typename T::iterator>(cur); ++auto_any_cast<typename T::iterator>(cur);
} }
template<typename T> template<typename T>
typename T::reference deref(auto_any_base const& cur, T&) typename T::reference deref(auto_any_base const& cur, T&)
{ {
return *auto_any_cast<typename T::iterator>(cur); return *auto_any_cast<typename T::iterator>(cur);
} }
template<typename T> template<typename T>
typename T::const_reference deref(auto_any_base const& cur, const T&) typename T::const_reference deref(auto_any_base const& cur, const T&)
{ {
return *auto_any_cast<typename T::iterator>(cur); return *auto_any_cast<typename T::iterator>(cur);
} }
} // end foreach_detail } // end foreach_detail
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// FOREACH // FOREACH
#define BOOST_FOREACH(item, container) \ #define BOOST_FOREACH(item, container) \
if(boost::foreach_detail::auto_any_base const& foreach_magic_b = boost::foreach_detail::begin(container)) {} else \ if(boost::foreach_detail::auto_any_base const& foreach_magic_b = boost::foreach_detail::begin(container)) {} else \
if(boost::foreach_detail::auto_any_base const& foreach_magic_e = boost::foreach_detail::end(container)) {} else \ if(boost::foreach_detail::auto_any_base const& foreach_magic_e = boost::foreach_detail::end(container)) {} else \
for(;!boost::foreach_detail::done(foreach_magic_b,foreach_magic_e,container); boost::foreach_detail::next(foreach_magic_b,container)) \ for(;!boost::foreach_detail::done(foreach_magic_b,foreach_magic_e,container); boost::foreach_detail::next(foreach_magic_b,container)) \
if (bool ugly_and_unique_break = false) {} else \ if (bool ugly_and_unique_break = false) {} else \
for(item = boost::foreach_detail::deref(foreach_magic_b,container); !ugly_and_unique_break; ugly_and_unique_break = true) for(item = boost::foreach_detail::deref(foreach_magic_b,container); !ugly_and_unique_break; ugly_and_unique_break = true)
} // end boost } // end boost
#endif #endif

View File

@ -1,82 +1,82 @@
/* DEPRECATED! - use code/TinyFormatter.h instead. /* DEPRECATED! - use code/TinyFormatter.h instead.
* *
* *
* */ * */
#ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED #ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED
#define AI_BOOST_FORMAT_DUMMY_INCLUDED #define AI_BOOST_FORMAT_DUMMY_INCLUDED
#if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST) #if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST)
#include <string> #include <string>
#include <vector> #include <vector>
#include <sstream> #include <sstream>
namespace boost namespace boost
{ {
class format class format
{ {
public: public:
format (const std::string& _d) format (const std::string& _d)
: d(_d) : d(_d)
{ {
} }
template <typename T> template <typename T>
format& operator % (T in) format& operator % (T in)
{ {
// XXX add replacement for boost::lexical_cast? // XXX add replacement for boost::lexical_cast?
std::ostringstream ss; std::ostringstream ss;
ss << in; // note: ss cannot be an rvalue, or the global operator << (const char*) is not called for T == const char*. ss << in; // note: ss cannot be an rvalue, or the global operator << (const char*) is not called for T == const char*.
chunks.push_back( ss.str()); chunks.push_back( ss.str());
return *this; return *this;
} }
operator std::string () const { operator std::string () const {
std::string res; // pray for NRVO to kick in std::string res; // pray for NRVO to kick in
size_t start = 0, last = 0; size_t start = 0, last = 0;
std::vector<std::string>::const_iterator chunkin = chunks.begin(); std::vector<std::string>::const_iterator chunkin = chunks.begin();
for ( start = d.find('%');start != std::string::npos; start = d.find('%',last)) { for ( start = d.find('%');start != std::string::npos; start = d.find('%',last)) {
res += d.substr(last,start-last); res += d.substr(last,start-last);
last = start+2; last = start+2;
if (d[start+1] == '%') { if (d[start+1] == '%') {
res += "%"; res += "%";
continue; continue;
} }
if (chunkin == chunks.end()) { if (chunkin == chunks.end()) {
break; break;
} }
res += *chunkin++; res += *chunkin++;
} }
res += d.substr(last); res += d.substr(last);
return res; return res;
} }
private: private:
std::string d; std::string d;
std::vector<std::string> chunks; std::vector<std::string> chunks;
}; };
inline std::string str(const std::string& s) { inline std::string str(const std::string& s) {
return s; return s;
} }
} }
#else #else
# error "format.h was already included" # error "format.h was already included"
#endif // #endif //
#endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED #endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED

View File

@ -1,26 +1,26 @@
/// A quick replacement for boost::lexical_cast for all the Boost haters out there /// A quick replacement for boost::lexical_cast for all the Boost haters out there
#ifndef __AI_BOOST_WORKAROUND_LEXICAL_CAST #ifndef __AI_BOOST_WORKAROUND_LEXICAL_CAST
#define __AI_BOOST_WORKAROUND_LEXICAL_CAST #define __AI_BOOST_WORKAROUND_LEXICAL_CAST
#include <sstream> #include <sstream>
namespace boost namespace boost
{ {
/// A quick replacement for boost::lexical_cast - should work for all types a stringstream can handle /// A quick replacement for boost::lexical_cast - should work for all types a stringstream can handle
template <typename TargetType, typename SourceType> template <typename TargetType, typename SourceType>
TargetType lexical_cast( const SourceType& source) TargetType lexical_cast( const SourceType& source)
{ {
std::stringstream stream; std::stringstream stream;
TargetType result; TargetType result;
stream << source; stream << source;
stream >> result; stream >> result;
return result; return result;
} }
} // namespace boost } // namespace boost
#endif // __AI_BOOST_WORKAROUND_LEXICAL_CAST #endif // __AI_BOOST_WORKAROUND_LEXICAL_CAST

View File

@ -1,57 +1,57 @@
// please note that this replacement implementation does not // please note that this replacement implementation does not
// provide the performance benefit of the original, which // provide the performance benefit of the original, which
// makes only one allocation as opposed to two allocations // makes only one allocation as opposed to two allocations
// (smart pointer counter and payload) which are usually // (smart pointer counter and payload) which are usually
// required if object and smart pointer are constructed // required if object and smart pointer are constructed
// independently. // independently.
#ifndef INCLUDED_AI_BOOST_MAKE_SHARED #ifndef INCLUDED_AI_BOOST_MAKE_SHARED
#define INCLUDED_AI_BOOST_MAKE_SHARED #define INCLUDED_AI_BOOST_MAKE_SHARED
namespace boost { namespace boost {
template <typename T> template <typename T>
shared_ptr<T> make_shared() { shared_ptr<T> make_shared() {
return shared_ptr<T>(new T()); return shared_ptr<T>(new T());
} }
template <typename T, typename T0> template <typename T, typename T0>
shared_ptr<T> make_shared(const T0& t0) { shared_ptr<T> make_shared(const T0& t0) {
return shared_ptr<T>(new T(t0)); return shared_ptr<T>(new T(t0));
} }
template <typename T, typename T0,typename T1> template <typename T, typename T0,typename T1>
shared_ptr<T> make_shared(const T0& t0, const T1& t1) { shared_ptr<T> make_shared(const T0& t0, const T1& t1) {
return shared_ptr<T>(new T(t0,t1)); return shared_ptr<T>(new T(t0,t1));
} }
template <typename T, typename T0,typename T1,typename T2> template <typename T, typename T0,typename T1,typename T2>
shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2) { shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2) {
return shared_ptr<T>(new T(t0,t1,t2)); return shared_ptr<T>(new T(t0,t1,t2));
} }
template <typename T, typename T0,typename T1,typename T2,typename T3> template <typename T, typename T0,typename T1,typename T2,typename T3>
shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3) { shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3) {
return shared_ptr<T>(new T(t0,t1,t2,t3)); return shared_ptr<T>(new T(t0,t1,t2,t3));
} }
template <typename T, typename T0,typename T1,typename T2,typename T3, typename T4> template <typename T, typename T0,typename T1,typename T2,typename T3, typename T4>
shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4) { shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4) {
return shared_ptr<T>(new T(t0,t1,t2,t3,t4)); return shared_ptr<T>(new T(t0,t1,t2,t3,t4));
} }
template <typename T, typename T0,typename T1,typename T2,typename T3, typename T4, typename T5> template <typename T, typename T0,typename T1,typename T2,typename T3, typename T4, typename T5>
shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) { shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) {
return shared_ptr<T>(new T(t0,t1,t2,t3,t4,t5)); return shared_ptr<T>(new T(t0,t1,t2,t3,t4,t5));
} }
template <typename T, typename T0,typename T1,typename T2,typename T3, typename T4, typename T5, typename T6> template <typename T, typename T0,typename T1,typename T2,typename T3, typename T4, typename T5, typename T6>
shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) { shared_ptr<T> make_shared(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) {
return shared_ptr<T>(new T(t0,t1,t2,t3,t4,t5,t6)); return shared_ptr<T>(new T(t0,t1,t2,t3,t4,t5,t6));
} }
} }
#endif #endif

View File

@ -1,37 +1,37 @@
#ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP #ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP
#define BOOST_MATH_COMMON_FACTOR_RT_HPP #define BOOST_MATH_COMMON_FACTOR_RT_HPP
namespace boost { namespace boost {
namespace math { namespace math {
// TODO: use binary GCD for unsigned integers .... // TODO: use binary GCD for unsigned integers ....
template < typename IntegerType > template < typename IntegerType >
IntegerType gcd( IntegerType a, IntegerType b ) IntegerType gcd( IntegerType a, IntegerType b )
{ {
const IntegerType zero = (IntegerType)0; const IntegerType zero = (IntegerType)0;
while ( true ) while ( true )
{ {
if ( a == zero ) if ( a == zero )
return b; return b;
b %= a; b %= a;
if ( b == zero ) if ( b == zero )
return a; return a;
a %= b; a %= b;
} }
} }
template < typename IntegerType > template < typename IntegerType >
IntegerType lcm( IntegerType a, IntegerType b ) IntegerType lcm( IntegerType a, IntegerType b )
{ {
const IntegerType t = gcd (a,b); const IntegerType t = gcd (a,b);
if (!t)return t; if (!t)return t;
return a / t * b; return a / t * b;
} }
}} }}
#endif #endif

View File

@ -1,36 +1,36 @@
// Boost noncopyable.hpp header file --------------------------------------// // Boost noncopyable.hpp header file --------------------------------------//
// (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost // (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file // Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/utility for documentation. // See http://www.boost.org/libs/utility for documentation.
#ifndef BOOST_NONCOPYABLE_HPP_INCLUDED #ifndef BOOST_NONCOPYABLE_HPP_INCLUDED
#define BOOST_NONCOPYABLE_HPP_INCLUDED #define BOOST_NONCOPYABLE_HPP_INCLUDED
namespace boost { namespace boost {
// Private copy constructor and copy assignment ensure classes derived from // Private copy constructor and copy assignment ensure classes derived from
// class noncopyable cannot be copied. // class noncopyable cannot be copied.
// Contributed by Dave Abrahams // Contributed by Dave Abrahams
namespace noncopyable_ // protection from unintended ADL namespace noncopyable_ // protection from unintended ADL
{ {
class noncopyable class noncopyable
{ {
protected: protected:
noncopyable() {} noncopyable() {}
~noncopyable() {} ~noncopyable() {}
private: // emphasize the following members are private private: // emphasize the following members are private
noncopyable( const noncopyable& ); noncopyable( const noncopyable& );
const noncopyable& operator=( const noncopyable& ); const noncopyable& operator=( const noncopyable& );
}; };
} }
typedef noncopyable_::noncopyable noncopyable; typedef noncopyable_::noncopyable noncopyable;
} // namespace boost } // namespace boost
#endif // BOOST_NONCOPYABLE_HPP_INCLUDED #endif // BOOST_NONCOPYABLE_HPP_INCLUDED

View File

@ -1,45 +1,45 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //
// (C) Copyright Ion Gaztanaga 2005. // (C) Copyright Ion Gaztanaga 2005.
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_POINTER_CAST_HPP #ifndef BOOST_POINTER_CAST_HPP
#define BOOST_POINTER_CAST_HPP #define BOOST_POINTER_CAST_HPP
namespace boost { namespace boost {
//static_pointer_cast overload for raw pointers //static_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* static_pointer_cast(U *ptr) inline T* static_pointer_cast(U *ptr)
{ {
return static_cast<T*>(ptr); return static_cast<T*>(ptr);
} }
//dynamic_pointer_cast overload for raw pointers //dynamic_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* dynamic_pointer_cast(U *ptr) inline T* dynamic_pointer_cast(U *ptr)
{ {
return dynamic_cast<T*>(ptr); return dynamic_cast<T*>(ptr);
} }
//const_pointer_cast overload for raw pointers //const_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* const_pointer_cast(U *ptr) inline T* const_pointer_cast(U *ptr)
{ {
return const_cast<T*>(ptr); return const_cast<T*>(ptr);
} }
//reinterpret_pointer_cast overload for raw pointers //reinterpret_pointer_cast overload for raw pointers
template<class T, class U> template<class T, class U>
inline T* reinterpret_pointer_cast(U *ptr) inline T* reinterpret_pointer_cast(U *ptr)
{ {
return reinterpret_cast<T*>(ptr); return reinterpret_cast<T*>(ptr);
} }
} // namespace boost } // namespace boost
#endif //BOOST_POINTER_CAST_HPP #endif //BOOST_POINTER_CAST_HPP

View File

@ -1,79 +1,79 @@
#ifndef __AI_BOOST_SCOPED_ARRAY_INCLUDED #ifndef __AI_BOOST_SCOPED_ARRAY_INCLUDED
#define __AI_BOOST_SCOPED_ARRAY_INCLUDED #define __AI_BOOST_SCOPED_ARRAY_INCLUDED
#ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED #ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED
namespace boost { namespace boost {
// small replacement for boost::scoped_array // small replacement for boost::scoped_array
template <class T> template <class T>
class scoped_array class scoped_array
{ {
public: public:
// provide a default construtctor // provide a default construtctor
scoped_array() scoped_array()
: ptr(0) : ptr(0)
{ {
} }
// construction from an existing heap object of type T // construction from an existing heap object of type T
scoped_array(T* _ptr) scoped_array(T* _ptr)
: ptr(_ptr) : ptr(_ptr)
{ {
} }
// automatic destruction of the wrapped object at the // automatic destruction of the wrapped object at the
// end of our lifetime // end of our lifetime
~scoped_array() ~scoped_array()
{ {
delete[] ptr; delete[] ptr;
} }
inline T* get() inline T* get()
{ {
return ptr; return ptr;
} }
inline T* operator-> () inline T* operator-> ()
{ {
return ptr; return ptr;
} }
inline void reset (T* t = 0) inline void reset (T* t = 0)
{ {
delete[] ptr; delete[] ptr;
ptr = t; ptr = t;
} }
T & operator[](std::ptrdiff_t i) const T & operator[](std::ptrdiff_t i) const
{ {
return ptr[i]; return ptr[i];
} }
void swap(scoped_array & b) void swap(scoped_array & b)
{ {
std::swap(ptr, b.ptr); std::swap(ptr, b.ptr);
} }
private: private:
// encapsulated object pointer // encapsulated object pointer
T* ptr; T* ptr;
}; };
template<class T> template<class T>
inline void swap(scoped_array<T> & a, scoped_array<T> & b) inline void swap(scoped_array<T> & a, scoped_array<T> & b)
{ {
a.swap(b); a.swap(b);
} }
} // end of namespace boost } // end of namespace boost
#else #else
# error "scoped_array.h was already included" # error "scoped_array.h was already included"
#endif #endif
#endif // __AI_BOOST_SCOPED_ARRAY_INCLUDED #endif // __AI_BOOST_SCOPED_ARRAY_INCLUDED

View File

@ -1,79 +1,79 @@
#ifndef __AI_BOOST_SCOPED_PTR_INCLUDED #ifndef __AI_BOOST_SCOPED_PTR_INCLUDED
#define __AI_BOOST_SCOPED_PTR_INCLUDED #define __AI_BOOST_SCOPED_PTR_INCLUDED
#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
namespace boost { namespace boost {
// small replacement for boost::scoped_ptr // small replacement for boost::scoped_ptr
template <class T> template <class T>
class scoped_ptr class scoped_ptr
{ {
public: public:
// provide a default construtctor // provide a default construtctor
scoped_ptr() scoped_ptr()
: ptr(0) : ptr(0)
{ {
} }
// construction from an existing heap object of type T // construction from an existing heap object of type T
scoped_ptr(T* _ptr) scoped_ptr(T* _ptr)
: ptr(_ptr) : ptr(_ptr)
{ {
} }
// automatic destruction of the wrapped object at the // automatic destruction of the wrapped object at the
// end of our lifetime // end of our lifetime
~scoped_ptr() ~scoped_ptr()
{ {
delete ptr; delete ptr;
} }
inline T* get() const inline T* get() const
{ {
return ptr; return ptr;
} }
inline operator T*() inline operator T*()
{ {
return ptr; return ptr;
} }
inline T* operator-> () inline T* operator-> ()
{ {
return ptr; return ptr;
} }
inline void reset (T* t = 0) inline void reset (T* t = 0)
{ {
delete ptr; delete ptr;
ptr = t; ptr = t;
} }
void swap(scoped_ptr & b) void swap(scoped_ptr & b)
{ {
std::swap(ptr, b.ptr); std::swap(ptr, b.ptr);
} }
private: private:
// encapsulated object pointer // encapsulated object pointer
T* ptr; T* ptr;
}; };
template<class T> template<class T>
inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b)
{ {
a.swap(b); a.swap(b);
} }
} // end of namespace boost } // end of namespace boost
#else #else
# error "scoped_ptr.h was already included" # error "scoped_ptr.h was already included"
#endif #endif
#endif // __AI_BOOST_SCOPED_PTR_INCLUDED #endif // __AI_BOOST_SCOPED_PTR_INCLUDED

View File

@ -1,228 +1,228 @@
#ifndef INCLUDED_AI_BOOST_SHARED_ARRAY #ifndef INCLUDED_AI_BOOST_SHARED_ARRAY
#define INCLUDED_AI_BOOST_SHARED_ARRAY #define INCLUDED_AI_BOOST_SHARED_ARRAY
#ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED #ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED
// ------------------------------ // ------------------------------
// Internal stub // Internal stub
namespace boost { namespace boost {
namespace array_detail { namespace array_detail {
class controller { class controller {
public: public:
controller() controller()
: cnt(1) : cnt(1)
{} {}
public: public:
template <typename T> template <typename T>
controller* decref(T* pt) { controller* decref(T* pt) {
if (--cnt <= 0) { if (--cnt <= 0) {
delete this; delete this;
delete[] pt; delete[] pt;
} }
return NULL; return NULL;
} }
controller* incref() { controller* incref() {
++cnt; ++cnt;
return this; return this;
} }
long get() const { long get() const {
return cnt; return cnt;
} }
private: private:
long cnt; long cnt;
}; };
struct empty {}; struct empty {};
template <typename DEST, typename SRC> template <typename DEST, typename SRC>
struct is_convertible_stub { struct is_convertible_stub {
struct yes {char s[1];}; struct yes {char s[1];};
struct no {char s[2];}; struct no {char s[2];};
static yes foo(DEST*); static yes foo(DEST*);
static no foo(...); static no foo(...);
enum {result = (sizeof(foo((SRC*)0)) == sizeof(yes) ? 1 : 0)}; enum {result = (sizeof(foo((SRC*)0)) == sizeof(yes) ? 1 : 0)};
}; };
template <bool> struct enable_if {}; template <bool> struct enable_if {};
template <> struct enable_if<true> { template <> struct enable_if<true> {
typedef empty result; typedef empty result;
}; };
template <typename DEST, typename SRC> template <typename DEST, typename SRC>
struct is_convertible : public enable_if<is_convertible_stub<DEST,SRC>::result > { struct is_convertible : public enable_if<is_convertible_stub<DEST,SRC>::result > {
}; };
} }
// ------------------------------ // ------------------------------
// Small replacement for boost::shared_array, not threadsafe because no // Small replacement for boost::shared_array, not threadsafe because no
// atomic reference counter is in use. // atomic reference counter is in use.
// ------------------------------ // ------------------------------
template <class T> template <class T>
class shared_array class shared_array
{ {
template <typename TT> friend class shared_array; template <typename TT> friend class shared_array;
template<class TT> friend bool operator== (const shared_array<TT>& a, const shared_array<TT>& b); template<class TT> friend bool operator== (const shared_array<TT>& a, const shared_array<TT>& b);
template<class TT> friend bool operator!= (const shared_array<TT>& a, const shared_array<TT>& b); template<class TT> friend bool operator!= (const shared_array<TT>& a, const shared_array<TT>& b);
template<class TT> friend bool operator< (const shared_array<TT>& a, const shared_array<TT>& b); template<class TT> friend bool operator< (const shared_array<TT>& a, const shared_array<TT>& b);
public: public:
typedef T element_type; typedef T element_type;
public: public:
// provide a default constructor // provide a default constructor
shared_array() shared_array()
: ptr() : ptr()
, ctr(NULL) , ctr(NULL)
{ {
} }
// construction from an existing object of type T // construction from an existing object of type T
explicit shared_array(T* ptr) explicit shared_array(T* ptr)
: ptr(ptr) : ptr(ptr)
, ctr(ptr ? new array_detail::controller() : NULL) , ctr(ptr ? new array_detail::controller() : NULL)
{ {
} }
shared_array(const shared_array& r) shared_array(const shared_array& r)
: ptr(r.ptr) : ptr(r.ptr)
, ctr(r.ctr ? r.ctr->incref() : NULL) , ctr(r.ctr ? r.ctr->incref() : NULL)
{ {
} }
template <typename Y> template <typename Y>
shared_array(const shared_array<Y>& r,typename detail::is_convertible<T,Y>::result = detail::empty()) shared_array(const shared_array<Y>& r,typename detail::is_convertible<T,Y>::result = detail::empty())
: ptr(r.ptr) : ptr(r.ptr)
, ctr(r.ctr ? r.ctr->incref() : NULL) , ctr(r.ctr ? r.ctr->incref() : NULL)
{ {
} }
// automatic destruction of the wrapped object when all // automatic destruction of the wrapped object when all
// references are freed. // references are freed.
~shared_array() { ~shared_array() {
if (ctr) { if (ctr) {
ctr = ctr->decref(ptr); ctr = ctr->decref(ptr);
} }
} }
shared_array& operator=(const shared_array& r) { shared_array& operator=(const shared_array& r) {
if (this == &r) { if (this == &r) {
return *this; return *this;
} }
if (ctr) { if (ctr) {
ctr->decref(ptr); ctr->decref(ptr);
} }
ptr = r.ptr; ptr = r.ptr;
ctr = ptr?r.ctr->incref():NULL; ctr = ptr?r.ctr->incref():NULL;
return *this; return *this;
} }
template <typename Y> template <typename Y>
shared_array& operator=(const shared_array<Y>& r) { shared_array& operator=(const shared_array<Y>& r) {
if (this == &r) { if (this == &r) {
return *this; return *this;
} }
if (ctr) { if (ctr) {
ctr->decref(ptr); ctr->decref(ptr);
} }
ptr = r.ptr; ptr = r.ptr;
ctr = ptr?r.ctr->incref():NULL; ctr = ptr?r.ctr->incref():NULL;
return *this; return *this;
} }
// pointer access // pointer access
inline operator T*() { inline operator T*() {
return ptr; return ptr;
} }
inline T* operator-> () const { inline T* operator-> () const {
return ptr; return ptr;
} }
// standard semantics // standard semantics
inline T* get() { inline T* get() {
return ptr; return ptr;
} }
T& operator[] (std::ptrdiff_t index) const { T& operator[] (std::ptrdiff_t index) const {
return ptr[index]; return ptr[index];
} }
inline const T* get() const { inline const T* get() const {
return ptr; return ptr;
} }
inline operator bool () const { inline operator bool () const {
return ptr != NULL; return ptr != NULL;
} }
inline bool unique() const { inline bool unique() const {
return use_count() == 1; return use_count() == 1;
} }
inline long use_count() const { inline long use_count() const {
return ctr->get(); return ctr->get();
} }
inline void reset (T* t = 0) { inline void reset (T* t = 0) {
if (ctr) { if (ctr) {
ctr->decref(ptr); ctr->decref(ptr);
} }
ptr = t; ptr = t;
ctr = ptr?new array_detail::controller():NULL; ctr = ptr?new array_detail::controller():NULL;
} }
void swap(shared_array & b) { void swap(shared_array & b) {
std::swap(ptr, b.ptr); std::swap(ptr, b.ptr);
std::swap(ctr, b.ctr); std::swap(ctr, b.ctr);
} }
private: private:
// encapsulated object pointer // encapsulated object pointer
T* ptr; T* ptr;
// control block // control block
array_detail::controller* ctr; array_detail::controller* ctr;
}; };
template<class T> template<class T>
inline void swap(shared_array<T> & a, shared_array<T> & b) inline void swap(shared_array<T> & a, shared_array<T> & b)
{ {
a.swap(b); a.swap(b);
} }
template<class T> template<class T>
bool operator== (const shared_array<T>& a, const shared_array<T>& b) { bool operator== (const shared_array<T>& a, const shared_array<T>& b) {
return a.ptr == b.ptr; return a.ptr == b.ptr;
} }
template<class T> template<class T>
bool operator!= (const shared_array<T>& a, const shared_array<T>& b) { bool operator!= (const shared_array<T>& a, const shared_array<T>& b) {
return a.ptr != b.ptr; return a.ptr != b.ptr;
} }
template<class T> template<class T>
bool operator< (const shared_array<T>& a, const shared_array<T>& b) { bool operator< (const shared_array<T>& a, const shared_array<T>& b) {
return a.ptr < b.ptr; return a.ptr < b.ptr;
} }
} // end of namespace boost } // end of namespace boost
#else #else
# error "shared_array.h was already included" # error "shared_array.h was already included"
#endif #endif
#endif // INCLUDED_AI_BOOST_SHARED_ARRAY #endif // INCLUDED_AI_BOOST_SHARED_ARRAY

View File

@ -1,260 +1,260 @@
#ifndef INCLUDED_AI_BOOST_SHARED_PTR #ifndef INCLUDED_AI_BOOST_SHARED_PTR
#define INCLUDED_AI_BOOST_SHARED_PTR #define INCLUDED_AI_BOOST_SHARED_PTR
#ifndef BOOST_SHARED_PTR_HPP_INCLUDED #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
// ------------------------------ // ------------------------------
// Internal stub // Internal stub
#include <stddef.h> //NULL #include <stddef.h> //NULL
#include <algorithm> //std::swap #include <algorithm> //std::swap
namespace boost { namespace boost {
namespace detail { namespace detail {
class controller { class controller {
public: public:
controller() controller()
: cnt(1) : cnt(1)
{} {}
public: public:
template <typename T> template <typename T>
controller* decref(T* pt) { controller* decref(T* pt) {
if (--cnt <= 0) { if (--cnt <= 0) {
delete this; delete this;
delete pt; delete pt;
} }
return NULL; return NULL;
} }
controller* incref() { controller* incref() {
++cnt; ++cnt;
return this; return this;
} }
long get() const { long get() const {
return cnt; return cnt;
} }
private: private:
long cnt; long cnt;
}; };
struct empty {}; struct empty {};
template <typename DEST, typename SRC> template <typename DEST, typename SRC>
struct is_convertible_stub { struct is_convertible_stub {
struct yes {char s[1];}; struct yes {char s[1];};
struct no {char s[2];}; struct no {char s[2];};
static yes foo(DEST*); static yes foo(DEST*);
static no foo(...); static no foo(...);
enum {result = (sizeof(foo((SRC*)0)) == sizeof(yes) ? 1 : 0)}; enum {result = (sizeof(foo((SRC*)0)) == sizeof(yes) ? 1 : 0)};
}; };
template <bool> struct enable_if {}; template <bool> struct enable_if {};
template <> struct enable_if<true> { template <> struct enable_if<true> {
typedef empty result; typedef empty result;
}; };
template <typename DEST, typename SRC> template <typename DEST, typename SRC>
struct is_convertible : public enable_if<is_convertible_stub<DEST,SRC>::result > { struct is_convertible : public enable_if<is_convertible_stub<DEST,SRC>::result > {
}; };
} }
// ------------------------------ // ------------------------------
// Small replacement for boost::shared_ptr, not threadsafe because no // Small replacement for boost::shared_ptr, not threadsafe because no
// atomic reference counter is in use. // atomic reference counter is in use.
// ------------------------------ // ------------------------------
template <class T> template <class T>
class shared_ptr class shared_ptr
{ {
template <typename TT> friend class shared_ptr; template <typename TT> friend class shared_ptr;
template<class TT, class U> friend shared_ptr<TT> static_pointer_cast (shared_ptr<U> ptr); template<class TT, class U> friend shared_ptr<TT> static_pointer_cast (shared_ptr<U> ptr);
template<class TT, class U> friend shared_ptr<TT> dynamic_pointer_cast (shared_ptr<U> ptr); template<class TT, class U> friend shared_ptr<TT> dynamic_pointer_cast (shared_ptr<U> ptr);
template<class TT, class U> friend shared_ptr<TT> const_pointer_cast (shared_ptr<U> ptr); template<class TT, class U> friend shared_ptr<TT> const_pointer_cast (shared_ptr<U> ptr);
template<class TT> friend bool operator== (const shared_ptr<TT>& a, const shared_ptr<TT>& b); template<class TT> friend bool operator== (const shared_ptr<TT>& a, const shared_ptr<TT>& b);
template<class TT> friend bool operator!= (const shared_ptr<TT>& a, const shared_ptr<TT>& b); template<class TT> friend bool operator!= (const shared_ptr<TT>& a, const shared_ptr<TT>& b);
template<class TT> friend bool operator< (const shared_ptr<TT>& a, const shared_ptr<TT>& b); template<class TT> friend bool operator< (const shared_ptr<TT>& a, const shared_ptr<TT>& b);
public: public:
typedef T element_type; typedef T element_type;
public: public:
// provide a default constructor // provide a default constructor
shared_ptr() shared_ptr()
: ptr() : ptr()
, ctr(NULL) , ctr(NULL)
{ {
} }
// construction from an existing object of type T // construction from an existing object of type T
explicit shared_ptr(T* ptr) explicit shared_ptr(T* ptr)
: ptr(ptr) : ptr(ptr)
, ctr(ptr ? new detail::controller() : NULL) , ctr(ptr ? new detail::controller() : NULL)
{ {
} }
shared_ptr(const shared_ptr& r) shared_ptr(const shared_ptr& r)
: ptr(r.ptr) : ptr(r.ptr)
, ctr(r.ctr ? r.ctr->incref() : NULL) , ctr(r.ctr ? r.ctr->incref() : NULL)
{ {
} }
template <typename Y> template <typename Y>
shared_ptr(const shared_ptr<Y>& r,typename detail::is_convertible<T,Y>::result = detail::empty()) shared_ptr(const shared_ptr<Y>& r,typename detail::is_convertible<T,Y>::result = detail::empty())
: ptr(r.ptr) : ptr(r.ptr)
, ctr(r.ctr ? r.ctr->incref() : NULL) , ctr(r.ctr ? r.ctr->incref() : NULL)
{ {
} }
// automatic destruction of the wrapped object when all // automatic destruction of the wrapped object when all
// references are freed. // references are freed.
~shared_ptr() { ~shared_ptr() {
if (ctr) { if (ctr) {
ctr = ctr->decref(ptr); ctr = ctr->decref(ptr);
} }
} }
shared_ptr& operator=(const shared_ptr& r) { shared_ptr& operator=(const shared_ptr& r) {
if (this == &r) { if (this == &r) {
return *this; return *this;
} }
if (ctr) { if (ctr) {
ctr->decref(ptr); ctr->decref(ptr);
} }
ptr = r.ptr; ptr = r.ptr;
ctr = ptr?r.ctr->incref():NULL; ctr = ptr?r.ctr->incref():NULL;
return *this; return *this;
} }
template <typename Y> template <typename Y>
shared_ptr& operator=(const shared_ptr<Y>& r) { shared_ptr& operator=(const shared_ptr<Y>& r) {
if (this == &r) { if (this == &r) {
return *this; return *this;
} }
if (ctr) { if (ctr) {
ctr->decref(ptr); ctr->decref(ptr);
} }
ptr = r.ptr; ptr = r.ptr;
ctr = ptr?r.ctr->incref():NULL; ctr = ptr?r.ctr->incref():NULL;
return *this; return *this;
} }
// pointer access // pointer access
inline operator T*() const { inline operator T*() const {
return ptr; return ptr;
} }
inline T* operator-> () const { inline T* operator-> () const {
return ptr; return ptr;
} }
// standard semantics // standard semantics
inline T* get() { inline T* get() {
return ptr; return ptr;
} }
inline const T* get() const { inline const T* get() const {
return ptr; return ptr;
} }
inline operator bool () const { inline operator bool () const {
return ptr != NULL; return ptr != NULL;
} }
inline bool unique() const { inline bool unique() const {
return use_count() == 1; return use_count() == 1;
} }
inline long use_count() const { inline long use_count() const {
return ctr->get(); return ctr->get();
} }
inline void reset (T* t = 0) { inline void reset (T* t = 0) {
if (ctr) { if (ctr) {
ctr->decref(ptr); ctr->decref(ptr);
} }
ptr = t; ptr = t;
ctr = ptr?new detail::controller():NULL; ctr = ptr?new detail::controller():NULL;
} }
void swap(shared_ptr & b) { void swap(shared_ptr & b) {
std::swap(ptr, b.ptr); std::swap(ptr, b.ptr);
std::swap(ctr, b.ctr); std::swap(ctr, b.ctr);
} }
private: private:
// for use by the various xxx_pointer_cast helper templates // for use by the various xxx_pointer_cast helper templates
explicit shared_ptr(T* ptr, detail::controller* ctr) explicit shared_ptr(T* ptr, detail::controller* ctr)
: ptr(ptr) : ptr(ptr)
, ctr(ctr->incref()) , ctr(ctr->incref())
{ {
} }
private: private:
// encapsulated object pointer // encapsulated object pointer
T* ptr; T* ptr;
// control block // control block
detail::controller* ctr; detail::controller* ctr;
}; };
template<class T> template<class T>
inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) inline void swap(shared_ptr<T> & a, shared_ptr<T> & b)
{ {
a.swap(b); a.swap(b);
} }
template<class T> template<class T>
bool operator== (const shared_ptr<T>& a, const shared_ptr<T>& b) { bool operator== (const shared_ptr<T>& a, const shared_ptr<T>& b) {
return a.ptr == b.ptr; return a.ptr == b.ptr;
} }
template<class T> template<class T>
bool operator!= (const shared_ptr<T>& a, const shared_ptr<T>& b) { bool operator!= (const shared_ptr<T>& a, const shared_ptr<T>& b) {
return a.ptr != b.ptr; return a.ptr != b.ptr;
} }
template<class T> template<class T>
bool operator< (const shared_ptr<T>& a, const shared_ptr<T>& b) { bool operator< (const shared_ptr<T>& a, const shared_ptr<T>& b) {
return a.ptr < b.ptr; return a.ptr < b.ptr;
} }
template<class T, class U> template<class T, class U>
inline shared_ptr<T> static_pointer_cast( shared_ptr<U> ptr) inline shared_ptr<T> static_pointer_cast( shared_ptr<U> ptr)
{ {
return shared_ptr<T>(static_cast<T*>(ptr.ptr),ptr.ctr); return shared_ptr<T>(static_cast<T*>(ptr.ptr),ptr.ctr);
} }
template<class T, class U> template<class T, class U>
inline shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> ptr) inline shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> ptr)
{ {
return shared_ptr<T>(dynamic_cast<T*>(ptr.ptr),ptr.ctr); return shared_ptr<T>(dynamic_cast<T*>(ptr.ptr),ptr.ctr);
} }
template<class T, class U> template<class T, class U>
inline shared_ptr<T> const_pointer_cast( shared_ptr<U> ptr) inline shared_ptr<T> const_pointer_cast( shared_ptr<U> ptr)
{ {
return shared_ptr<T>(const_cast<T*>(ptr.ptr),ptr.ctr); return shared_ptr<T>(const_cast<T*>(ptr.ptr),ptr.ctr);
} }
} // end of namespace boost } // end of namespace boost
#else #else
# error "shared_ptr.h was already included" # error "shared_ptr.h was already included"
#endif #endif
#endif // INCLUDED_AI_BOOST_SHARED_PTR #endif // INCLUDED_AI_BOOST_SHARED_PTR

View File

@ -1,20 +1,20 @@
#ifndef AI_BOOST_STATIC_ASSERT_INCLUDED #ifndef AI_BOOST_STATIC_ASSERT_INCLUDED
#define AI_BOOST_STATIC_ASSERT_INCLUDED #define AI_BOOST_STATIC_ASSERT_INCLUDED
#ifndef BOOST_STATIC_ASSERT #ifndef BOOST_STATIC_ASSERT
namespace boost { namespace boost {
namespace detail { namespace detail {
template <bool b> class static_assertion_failure; template <bool b> class static_assertion_failure;
template <> class static_assertion_failure<true> {}; template <> class static_assertion_failure<true> {};
} }
} }
#define BOOST_STATIC_ASSERT(eval) \ #define BOOST_STATIC_ASSERT(eval) \
{boost::detail::static_assertion_failure<(eval)> assert_dummy;(void)assert_dummy;} {boost::detail::static_assertion_failure<(eval)> assert_dummy;(void)assert_dummy;}
#endif #endif
#endif // !! AI_BOOST_STATIC_ASSERT_INCLUDED #endif // !! AI_BOOST_STATIC_ASSERT_INCLUDED

View File

@ -1,73 +1,73 @@
// boost timer.hpp header file ---------------------------------------------// // boost timer.hpp header file ---------------------------------------------//
// Copyright Beman Dawes 1994-99. Distributed under the Boost // Copyright Beman Dawes 1994-99. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file // Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/timer for documentation. // See http://www.boost.org/libs/timer for documentation.
// Revision History // Revision History
// 01 Apr 01 Modified to use new <boost/limits.hpp> header. (JMaddock) // 01 Apr 01 Modified to use new <boost/limits.hpp> header. (JMaddock)
// 12 Jan 01 Change to inline implementation to allow use without library // 12 Jan 01 Change to inline implementation to allow use without library
// builds. See docs for more rationale. (Beman Dawes) // builds. See docs for more rationale. (Beman Dawes)
// 25 Sep 99 elapsed_max() and elapsed_min() added (John Maddock) // 25 Sep 99 elapsed_max() and elapsed_min() added (John Maddock)
// 16 Jul 99 Second beta // 16 Jul 99 Second beta
// 6 Jul 99 Initial boost version // 6 Jul 99 Initial boost version
#ifndef BOOST_TIMER_HPP #ifndef BOOST_TIMER_HPP
#define BOOST_TIMER_HPP #define BOOST_TIMER_HPP
//#include <boost/config.hpp> //#include <boost/config.hpp>
#include <ctime> #include <ctime>
#include <limits> #include <limits>
//#include <boost/limits.hpp> //#include <boost/limits.hpp>
# ifdef BOOST_NO_STDC_NAMESPACE # ifdef BOOST_NO_STDC_NAMESPACE
namespace std { using ::clock_t; using ::clock; } namespace std { using ::clock_t; using ::clock; }
# endif # endif
namespace boost { namespace boost {
// timer -------------------------------------------------------------------// // timer -------------------------------------------------------------------//
// A timer object measures elapsed time. // A timer object measures elapsed time.
// It is recommended that implementations measure wall clock rather than CPU // It is recommended that implementations measure wall clock rather than CPU
// time since the intended use is performance measurement on systems where // time since the intended use is performance measurement on systems where
// total elapsed time is more important than just process or CPU time. // total elapsed time is more important than just process or CPU time.
// Warnings: The maximum measurable elapsed time may well be only 596.5+ hours // Warnings: The maximum measurable elapsed time may well be only 596.5+ hours
// due to implementation limitations. The accuracy of timings depends on the // due to implementation limitations. The accuracy of timings depends on the
// accuracy of timing information provided by the underlying platform, and // accuracy of timing information provided by the underlying platform, and
// this varies a great deal from platform to platform. // this varies a great deal from platform to platform.
class timer class timer
{ {
public: public:
timer() { _start_time = std::clock(); } // postcondition: elapsed()==0 timer() { _start_time = std::clock(); } // postcondition: elapsed()==0
// timer( const timer& src ); // post: elapsed()==src.elapsed() // timer( const timer& src ); // post: elapsed()==src.elapsed()
// ~timer(){} // ~timer(){}
// timer& operator=( const timer& src ); // post: elapsed()==src.elapsed() // timer& operator=( const timer& src ); // post: elapsed()==src.elapsed()
void restart() { _start_time = std::clock(); } // post: elapsed()==0 void restart() { _start_time = std::clock(); } // post: elapsed()==0
double elapsed() const // return elapsed time in seconds double elapsed() const // return elapsed time in seconds
{ return double(std::clock() - _start_time) / CLOCKS_PER_SEC; } { return double(std::clock() - _start_time) / CLOCKS_PER_SEC; }
double elapsed_max() const // return estimated maximum value for elapsed() double elapsed_max() const // return estimated maximum value for elapsed()
// Portability warning: elapsed_max() may return too high a value on systems // Portability warning: elapsed_max() may return too high a value on systems
// where std::clock_t overflows or resets at surprising values. // where std::clock_t overflows or resets at surprising values.
{ {
return (double((std::numeric_limits<std::clock_t>::max)()) return (double((std::numeric_limits<std::clock_t>::max)())
- double(_start_time)) / double(CLOCKS_PER_SEC); - double(_start_time)) / double(CLOCKS_PER_SEC);
} }
double elapsed_min() const // return minimum value for elapsed() double elapsed_min() const // return minimum value for elapsed()
{ return double(1)/double(CLOCKS_PER_SEC); } { return double(1)/double(CLOCKS_PER_SEC); }
private: private:
std::clock_t _start_time; std::clock_t _start_time;
}; // timer }; // timer
} // namespace boost } // namespace boost
#endif // BOOST_TIMER_HPP #endif // BOOST_TIMER_HPP

View File

@ -1,283 +1,283 @@
// A very small replacement for boost::tuple // A very small replacement for boost::tuple
// (c) Alexander Gessler, 2008 [alexander.gessler@gmx.net] // (c) Alexander Gessler, 2008 [alexander.gessler@gmx.net]
#ifndef BOOST_TUPLE_INCLUDED #ifndef BOOST_TUPLE_INCLUDED
#define BOOST_TUPLE_INCLUDED #define BOOST_TUPLE_INCLUDED
namespace boost { namespace boost {
namespace detail { namespace detail {
// Represents an empty tuple slot (up to 5 supported) // Represents an empty tuple slot (up to 5 supported)
struct nulltype {}; struct nulltype {};
// For readable error messages // For readable error messages
struct tuple_component_idx_out_of_bounds; struct tuple_component_idx_out_of_bounds;
// To share some code for the const/nonconst versions of the getters // To share some code for the const/nonconst versions of the getters
template <bool b, typename T> template <bool b, typename T>
struct ConstIf { struct ConstIf {
typedef T t; typedef T t;
}; };
template <typename T> template <typename T>
struct ConstIf<true,T> { struct ConstIf<true,T> {
typedef const T t; typedef const T t;
}; };
// Predeclare some stuff // Predeclare some stuff
template <typename, unsigned, typename, bool, unsigned> struct value_getter; template <typename, unsigned, typename, bool, unsigned> struct value_getter;
// Helper to obtain the type of a tuple element // Helper to obtain the type of a tuple element
template <typename T, unsigned NIDX, typename TNEXT, unsigned N /*= 0*/> template <typename T, unsigned NIDX, typename TNEXT, unsigned N /*= 0*/>
struct type_getter { struct type_getter {
typedef type_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type,N> next_elem_getter; typedef type_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type,N> next_elem_getter;
typedef typename next_elem_getter::type type; typedef typename next_elem_getter::type type;
}; };
template <typename T, unsigned NIDX, typename TNEXT > template <typename T, unsigned NIDX, typename TNEXT >
struct type_getter <T,NIDX,TNEXT,NIDX> { struct type_getter <T,NIDX,TNEXT,NIDX> {
typedef T type; typedef T type;
}; };
// Base class for all explicit specializations of list_elem // Base class for all explicit specializations of list_elem
template <typename T, unsigned NIDX, typename TNEXT > template <typename T, unsigned NIDX, typename TNEXT >
struct list_elem_base { struct list_elem_base {
// Store template parameters // Store template parameters
typedef TNEXT next_type; typedef TNEXT next_type;
typedef T type; typedef T type;
static const unsigned nidx = NIDX; static const unsigned nidx = NIDX;
}; };
// Represents an element in the tuple component list // Represents an element in the tuple component list
template <typename T, unsigned NIDX, typename TNEXT > template <typename T, unsigned NIDX, typename TNEXT >
struct list_elem : list_elem_base<T,NIDX,TNEXT>{ struct list_elem : list_elem_base<T,NIDX,TNEXT>{
// Real members // Real members
T me; T me;
TNEXT next; TNEXT next;
// Get the value of a specific tuple element // Get the value of a specific tuple element
template <unsigned N> template <unsigned N>
typename type_getter<T,NIDX,TNEXT,N>::type& get () { typename type_getter<T,NIDX,TNEXT,N>::type& get () {
value_getter <T,NIDX,TNEXT,false,N> s; value_getter <T,NIDX,TNEXT,false,N> s;
return s(*this); return s(*this);
} }
// Get the value of a specific tuple element // Get the value of a specific tuple element
template <unsigned N> template <unsigned N>
const typename type_getter<T,NIDX,TNEXT,N>::type& get () const { const typename type_getter<T,NIDX,TNEXT,N>::type& get () const {
value_getter <T,NIDX,TNEXT,true,N> s; value_getter <T,NIDX,TNEXT,true,N> s;
return s(*this); return s(*this);
} }
// Explicit cast // Explicit cast
template <typename T2, typename TNEXT2 > template <typename T2, typename TNEXT2 >
operator list_elem<T2,NIDX,TNEXT2> () const { operator list_elem<T2,NIDX,TNEXT2> () const {
list_elem<T2,NIDX,TNEXT2> ret; list_elem<T2,NIDX,TNEXT2> ret;
ret.me = (T2)me; ret.me = (T2)me;
ret.next = next; ret.next = next;
return ret; return ret;
} }
// Recursively compare two elements (last element returns always true) // Recursively compare two elements (last element returns always true)
bool operator == (const list_elem& s) const { bool operator == (const list_elem& s) const {
return (me == s.me && next == s.next); return (me == s.me && next == s.next);
} }
}; };
// Represents a non-used tuple element - the very last element processed // Represents a non-used tuple element - the very last element processed
template <typename TNEXT, unsigned NIDX > template <typename TNEXT, unsigned NIDX >
struct list_elem<nulltype,NIDX,TNEXT> : list_elem_base<nulltype,NIDX,TNEXT> { struct list_elem<nulltype,NIDX,TNEXT> : list_elem_base<nulltype,NIDX,TNEXT> {
template <unsigned N, bool IS_CONST = true> struct value_getter { template <unsigned N, bool IS_CONST = true> struct value_getter {
/* just dummy members to produce readable error messages */ /* just dummy members to produce readable error messages */
tuple_component_idx_out_of_bounds operator () (typename ConstIf<IS_CONST,list_elem>::t& me); tuple_component_idx_out_of_bounds operator () (typename ConstIf<IS_CONST,list_elem>::t& me);
}; };
template <unsigned N> struct type_getter { template <unsigned N> struct type_getter {
/* just dummy members to produce readable error messages */ /* just dummy members to produce readable error messages */
typedef tuple_component_idx_out_of_bounds type; typedef tuple_component_idx_out_of_bounds type;
}; };
// dummy // dummy
list_elem& operator = (const list_elem& /*other*/) { list_elem& operator = (const list_elem& /*other*/) {
return *this; return *this;
} }
// dummy // dummy
bool operator == (const list_elem& other) { bool operator == (const list_elem& other) {
return true; return true;
} }
}; };
// Represents the absolute end of the list // Represents the absolute end of the list
typedef list_elem<nulltype,0,int> list_end; typedef list_elem<nulltype,0,int> list_end;
// Helper obtain to query the value of a tuple element // Helper obtain to query the value of a tuple element
// NOTE: This can't be a nested class as the compiler won't accept a full or // NOTE: This can't be a nested class as the compiler won't accept a full or
// partial specialization of a nested class of a non-specialized template // partial specialization of a nested class of a non-specialized template
template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST, unsigned N> template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST, unsigned N>
struct value_getter { struct value_getter {
// calling list_elem // calling list_elem
typedef list_elem<T,NIDX,TNEXT> outer_elem; typedef list_elem<T,NIDX,TNEXT> outer_elem;
// typedef for the getter for next element // typedef for the getter for next element
typedef value_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type, typedef value_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type,
IS_CONST, N> next_value_getter; IS_CONST, N> next_value_getter;
typename ConstIf<IS_CONST,typename type_getter<T,NIDX,TNEXT,N>::type>::t& typename ConstIf<IS_CONST,typename type_getter<T,NIDX,TNEXT,N>::type>::t&
operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) { operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) {
next_value_getter s; next_value_getter s;
return s(me.next); return s(me.next);
} }
}; };
template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST> template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST>
struct value_getter <T,NIDX,TNEXT,IS_CONST,NIDX> { struct value_getter <T,NIDX,TNEXT,IS_CONST,NIDX> {
typedef list_elem<T,NIDX,TNEXT> outer_elem; typedef list_elem<T,NIDX,TNEXT> outer_elem;
typename ConstIf<IS_CONST,T>::t& operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) { typename ConstIf<IS_CONST,T>::t& operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) {
return me.me; return me.me;
} }
}; };
} }
// A very minimal implementation for up to 5 elements // A very minimal implementation for up to 5 elements
template <typename T0 = detail::nulltype, template <typename T0 = detail::nulltype,
typename T1 = detail::nulltype, typename T1 = detail::nulltype,
typename T2 = detail::nulltype, typename T2 = detail::nulltype,
typename T3 = detail::nulltype, typename T3 = detail::nulltype,
typename T4 = detail::nulltype> typename T4 = detail::nulltype>
class tuple { class tuple {
template <typename T0b, template <typename T0b,
typename T1b, typename T1b,
typename T2b, typename T2b,
typename T3b, typename T3b,
typename T4b > typename T4b >
friend class tuple; friend class tuple;
private: private:
typedef detail::list_elem<T0,0, typedef detail::list_elem<T0,0,
detail::list_elem<T1,1, detail::list_elem<T1,1,
detail::list_elem<T2,2, detail::list_elem<T2,2,
detail::list_elem<T3,3, detail::list_elem<T3,3,
detail::list_elem<T4,4, detail::list_elem<T4,4,
detail::list_end > > > > > very_long; detail::list_end > > > > > very_long;
very_long m; very_long m;
public: public:
// Get a specific tuple element // Get a specific tuple element
template <unsigned N> template <unsigned N>
typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () { typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () {
return m.template get<N>(); return m.template get<N>();
} }
// ... and the const version // ... and the const version
template <unsigned N> template <unsigned N>
const typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () const { const typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () const {
return m.template get<N>(); return m.template get<N>();
} }
// comparison operators // comparison operators
bool operator== (const tuple& other) const { bool operator== (const tuple& other) const {
return m == other.m; return m == other.m;
} }
// ... and the other way round // ... and the other way round
bool operator!= (const tuple& other) const { bool operator!= (const tuple& other) const {
return !(m == other.m); return !(m == other.m);
} }
// cast to another tuple - all single elements must be convertible // cast to another tuple - all single elements must be convertible
template <typename T0b, typename T1b,typename T2b,typename T3b, typename T4b> template <typename T0b, typename T1b,typename T2b,typename T3b, typename T4b>
operator tuple <T0b,T1b,T2b,T3b,T4b> () const { operator tuple <T0b,T1b,T2b,T3b,T4b> () const {
tuple <T0b,T1b,T2b,T3b,T4b> s; tuple <T0b,T1b,T2b,T3b,T4b> s;
s.m = (typename tuple <T0b,T1b,T2b,T3b,T4b>::very_long)m; s.m = (typename tuple <T0b,T1b,T2b,T3b,T4b>::very_long)m;
return s; return s;
} }
}; };
// Another way to access an element ... // Another way to access an element ...
template <unsigned N,typename T0,typename T1,typename T2,typename T3,typename T4> template <unsigned N,typename T0,typename T1,typename T2,typename T3,typename T4>
inline typename tuple<T0,T1,T2,T3,T4>::very_long::template type_getter<N>::type& get ( inline typename tuple<T0,T1,T2,T3,T4>::very_long::template type_getter<N>::type& get (
tuple<T0,T1,T2,T3,T4>& m) { tuple<T0,T1,T2,T3,T4>& m) {
return m.template get<N>(); return m.template get<N>();
} }
// ... and the const version // ... and the const version
template <unsigned N,typename T0,typename T1,typename T2,typename T3,typename T4> template <unsigned N,typename T0,typename T1,typename T2,typename T3,typename T4>
inline const typename tuple<T0,T1,T2,T3,T4>::very_long::template type_getter<N>::type& get ( inline const typename tuple<T0,T1,T2,T3,T4>::very_long::template type_getter<N>::type& get (
const tuple<T0,T1,T2,T3,T4>& m) { const tuple<T0,T1,T2,T3,T4>& m) {
return m.template get<N>(); return m.template get<N>();
} }
// Constructs a tuple with 5 elements // Constructs a tuple with 5 elements
template <typename T0,typename T1,typename T2,typename T3,typename T4> template <typename T0,typename T1,typename T2,typename T3,typename T4>
inline tuple <T0,T1,T2,T3,T4> make_tuple (const T0& t0, inline tuple <T0,T1,T2,T3,T4> make_tuple (const T0& t0,
const T1& t1,const T2& t2,const T3& t3,const T4& t4) { const T1& t1,const T2& t2,const T3& t3,const T4& t4) {
tuple <T0,T1,T2,T3,T4> t; tuple <T0,T1,T2,T3,T4> t;
t.template get<0>() = t0; t.template get<0>() = t0;
t.template get<1>() = t1; t.template get<1>() = t1;
t.template get<2>() = t2; t.template get<2>() = t2;
t.template get<3>() = t3; t.template get<3>() = t3;
t.template get<4>() = t4; t.template get<4>() = t4;
return t; return t;
} }
// Constructs a tuple with 4 elements // Constructs a tuple with 4 elements
template <typename T0,typename T1,typename T2,typename T3> template <typename T0,typename T1,typename T2,typename T3>
inline tuple <T0,T1,T2,T3> make_tuple (const T0& t0, inline tuple <T0,T1,T2,T3> make_tuple (const T0& t0,
const T1& t1,const T2& t2,const T3& t3) { const T1& t1,const T2& t2,const T3& t3) {
tuple <T0,T1,T2,T3> t; tuple <T0,T1,T2,T3> t;
t.template get<0>() = t0; t.template get<0>() = t0;
t.template get<1>() = t1; t.template get<1>() = t1;
t.template get<2>() = t2; t.template get<2>() = t2;
t.template get<3>() = t3; t.template get<3>() = t3;
return t; return t;
} }
// Constructs a tuple with 3 elements // Constructs a tuple with 3 elements
template <typename T0,typename T1,typename T2> template <typename T0,typename T1,typename T2>
inline tuple <T0,T1,T2> make_tuple (const T0& t0, inline tuple <T0,T1,T2> make_tuple (const T0& t0,
const T1& t1,const T2& t2) { const T1& t1,const T2& t2) {
tuple <T0,T1,T2> t; tuple <T0,T1,T2> t;
t.template get<0>() = t0; t.template get<0>() = t0;
t.template get<1>() = t1; t.template get<1>() = t1;
t.template get<2>() = t2; t.template get<2>() = t2;
return t; return t;
} }
// Constructs a tuple with 2 elements // Constructs a tuple with 2 elements
template <typename T0,typename T1> template <typename T0,typename T1>
inline tuple <T0,T1> make_tuple (const T0& t0, inline tuple <T0,T1> make_tuple (const T0& t0,
const T1& t1) { const T1& t1) {
tuple <T0,T1> t; tuple <T0,T1> t;
t.template get<0>() = t0; t.template get<0>() = t0;
t.template get<1>() = t1; t.template get<1>() = t1;
return t; return t;
} }
// Constructs a tuple with 1 elements (well ...) // Constructs a tuple with 1 elements (well ...)
template <typename T0> template <typename T0>
inline tuple <T0> make_tuple (const T0& t0) { inline tuple <T0> make_tuple (const T0& t0) {
tuple <T0> t; tuple <T0> t;
t.template get<0>() = t0; t.template get<0>() = t0;
return t; return t;
} }
// Constructs a tuple with 0 elements (well ...) // Constructs a tuple with 0 elements (well ...)
inline tuple <> make_tuple () { inline tuple <> make_tuple () {
tuple <> t; tuple <> t;
return t; return t;
} }
} }
#endif // !! BOOST_TUPLE_INCLUDED #endif // !! BOOST_TUPLE_INCLUDED

View File

@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
#include <sstream> #include <sstream>
#include <stdarg.h>
#include "ColladaParser.h" #include "ColladaParser.h"
#include "fast_atof.h" #include "fast_atof.h"
#include "ParsingUtils.h" #include "ParsingUtils.h"
@ -1066,6 +1067,12 @@ void ColladaParser::ReadLight( Collada::Light& pLight)
pLight.mFalloffAngle = ReadFloatFromTextContent(); pLight.mFalloffAngle = ReadFloatFromTextContent();
TestClosing("hotspot_beam"); TestClosing("hotspot_beam");
} }
// OpenCOLLADA extensions
// -------------------------------------------------------
else if (IsElement("decay_falloff")) {
pLight.mOuterAngle = ReadFloatFromTextContent();
TestClosing("decay_falloff");
}
} }
else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
if( strcmp( mReader->getNodeName(), "light") == 0) if( strcmp( mReader->getNodeName(), "light") == 0)
@ -1998,7 +2005,8 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
} }
#ifdef ASSIMP_BUILD_DEBUG #ifdef ASSIMP_BUILD_DEBUG
if (primType != Prim_TriFans && primType != Prim_TriStrips) { if (primType != Prim_TriFans && primType != Prim_TriStrips &&
primType != Prim_Lines) { // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'.
ai_assert(actualPrimitives == numPrimitives); ai_assert(actualPrimitives == numPrimitives);
} }
#endif #endif
@ -2107,13 +2115,19 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
} }
} }
// complain if the index count doesn't fit // complain if the index count doesn't fit
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) {
ThrowException( "Expected different index count in <p> element."); if (pPrimType == Prim_Lines) {
else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0) // HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines'
ThrowException( "Expected different index count in <p> element."); ReportWarning( "Expected different index count in <p> element, %d instead of %d.", indices.size(), expectedPointCount * numOffsets);
pNumPrimitives = (indices.size() / numOffsets) / 2;
} else
ThrowException( "Expected different index count in <p> element.");
// find the data for all sources } else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
ThrowException( "Expected different index count in <p> element.");
// find the data for all sources
for( std::vector<InputChannel>::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it) for( std::vector<InputChannel>::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it)
{ {
InputChannel& input = *it; InputChannel& input = *it;
@ -2712,6 +2726,21 @@ AI_WONT_RETURN void ColladaParser::ThrowException( const std::string& pError) co
{ {
throw DeadlyImportError( boost::str( boost::format( "Collada: %s - %s") % mFileName % pError)); throw DeadlyImportError( boost::str( boost::format( "Collada: %s - %s") % mFileName % pError));
} }
void ColladaParser::ReportWarning(const char* msg,...)
{
ai_assert(NULL != msg);
va_list args;
va_start(args,msg);
char szBuffer[3000];
const int iLen = vsprintf(szBuffer,msg,args);
ai_assert(iLen > 0);
va_end(args);
DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen));
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Skips all data until the end node of the current element // Skips all data until the end node of the current element

View File

@ -1,42 +1,42 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2015, assimp team Copyright (c) 2006-2015, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the with or without modification, are permitted provided that the
following conditions are met: following conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer. following disclaimer.
* Redistributions in binary form must reproduce the above * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other following disclaimer in the documentation and/or other
materials provided with the distribution. materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its * Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products contributors may be used to endorse or promote products
derived from this software without specific prior derived from this software without specific prior
written permission of the assimp team. written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
/** @file ColladaParser.h /** @file ColladaParser.h
* @brief Defines the parser helper class for the collada loader * @brief Defines the parser helper class for the collada loader
@ -52,301 +52,302 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp namespace Assimp
{ {
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
/** Parser helper class for the Collada loader. /** Parser helper class for the Collada loader.
* *
* Does all the XML reading and builds internal data structures from it, * Does all the XML reading and builds internal data structures from it,
* but leaves the resolving of all the references to the loader. * but leaves the resolving of all the references to the loader.
*/
class ColladaParser
{
friend class ColladaLoader;
protected:
/** Constructor from XML file */
ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
/** Destructor */
~ColladaParser();
/** Reads the contents of the file */
void ReadContents();
/** Reads the structure of the file */
void ReadStructure();
/** Reads asset informations such as coordinate system informations and legal blah */
void ReadAssetInfo();
/** Reads the animation library */
void ReadAnimationLibrary();
/** Reads an animation into the given parent structure */
void ReadAnimation( Collada::Animation* pParent);
/** Reads an animation sampler into the given anim channel */
void ReadAnimationSampler( Collada::AnimationChannel& pChannel);
/** Reads the skeleton controller library */
void ReadControllerLibrary();
/** Reads a controller into the given mesh structure */
void ReadController( Collada::Controller& pController);
/** Reads the joint definitions for the given controller */
void ReadControllerJoints( Collada::Controller& pController);
/** Reads the joint weights for the given controller */
void ReadControllerWeights( Collada::Controller& pController);
/** Reads the image library contents */
void ReadImageLibrary();
/** Reads an image entry into the given image */
void ReadImage( Collada::Image& pImage);
/** Reads the material library */
void ReadMaterialLibrary();
/** Reads a material entry into the given material */
void ReadMaterial( Collada::Material& pMaterial);
/** Reads the camera library */
void ReadCameraLibrary();
/** Reads a camera entry into the given camera */
void ReadCamera( Collada::Camera& pCamera);
/** Reads the light library */
void ReadLightLibrary();
/** Reads a light entry into the given light */
void ReadLight( Collada::Light& pLight);
/** Reads the effect library */
void ReadEffectLibrary();
/** Reads an effect entry into the given effect*/
void ReadEffect( Collada::Effect& pEffect);
/** Reads an COMMON effect profile */
void ReadEffectProfileCommon( Collada::Effect& pEffect);
/** Read sampler properties */
void ReadSamplerProperties( Collada::Sampler& pSampler);
/** Reads an effect entry containing a color or a texture defining that color */
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
/** Reads an effect entry containing a float */
void ReadEffectFloat( float& pFloat);
/** Reads an effect parameter specification of any kind */
void ReadEffectParam( Collada::EffectParam& pParam);
/** Reads the geometry library contents */
void ReadGeometryLibrary();
/** Reads a geometry from the geometry library. */
void ReadGeometry( Collada::Mesh* pMesh);
/** Reads a mesh from the geometry library */
void ReadMesh( Collada::Mesh* pMesh);
/** Reads a source element - a combination of raw data and an accessor defining
* things that should not be redefinable. Yes, that's another rant.
*/ */
void ReadSource(); class ColladaParser
{
/** Reads a data array holding a number of elements, and stores it in the global library. friend class ColladaLoader;
* Currently supported are array of floats and arrays of strings.
*/ protected:
void ReadDataArray(); /** Constructor from XML file */
ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
/** Reads an accessor and stores it in the global library under the given ID -
* accessors use the ID of the parent <source> element /** Destructor */
*/ ~ColladaParser();
void ReadAccessor( const std::string& pID);
/** Reads the contents of the file */
/** Reads input declarations of per-vertex mesh data into the given mesh */ void ReadContents();
void ReadVertexData( Collada::Mesh* pMesh);
/** Reads the structure of the file */
/** Reads input declarations of per-index mesh data into the given mesh */ void ReadStructure();
void ReadIndexData( Collada::Mesh* pMesh);
/** Reads asset informations such as coordinate system informations and legal blah */
/** Reads a single input channel element and stores it in the given array, if valid */ void ReadAssetInfo();
void ReadInputChannel( std::vector<Collada::InputChannel>& poChannels);
/** Reads the animation library */
/** Reads a <p> primitive index list and assembles the mesh data into the given mesh */ void ReadAnimationLibrary();
size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
size_t pNumPrimitives, const std::vector<size_t>& pVCount, Collada::PrimitiveType pPrimType); /** Reads an animation into the given parent structure */
void ReadAnimation( Collada::Animation* pParent);
/** Copies the data for a single primitive into the mesh, based on the InputChannels */
void CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, /** Reads an animation sampler into the given anim channel */
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels, void ReadAnimationSampler( Collada::AnimationChannel& pChannel);
size_t currentPrimitive, const std::vector<size_t>& indices);
/** Reads the skeleton controller library */
/** Reads one triangle of a tristrip into the mesh */ void ReadControllerLibrary();
void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh* pMesh,
std::vector<Collada::InputChannel>& pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t>& indices); /** Reads a controller into the given mesh structure */
void ReadController( Collada::Controller& pController);
/** Extracts a single object from an input channel and stores it in the appropriate mesh data array */
void ExtractDataObjectFromChannel( const Collada::InputChannel& pInput, size_t pLocalIndex, Collada::Mesh* pMesh); /** Reads the joint definitions for the given controller */
void ReadControllerJoints( Collada::Controller& pController);
/** Reads the library of node hierarchies and scene parts */
void ReadSceneLibrary(); /** Reads the joint weights for the given controller */
void ReadControllerWeights( Collada::Controller& pController);
/** Reads a scene node's contents including children and stores it in the given node */
void ReadSceneNode( Collada::Node* pNode); /** Reads the image library contents */
void ReadImageLibrary();
/** Reads a node transformation entry of the given type and adds it to the given node's transformation list. */
void ReadNodeTransformation( Collada::Node* pNode, Collada::TransformType pType); /** Reads an image entry into the given image */
void ReadImage( Collada::Image& pImage);
/** Reads a mesh reference in a node and adds it to the node's mesh list */
void ReadNodeGeometry( Collada::Node* pNode); /** Reads the material library */
void ReadMaterialLibrary();
/** Reads the collada scene */
void ReadScene(); /** Reads a material entry into the given material */
void ReadMaterial( Collada::Material& pMaterial);
// Processes bind_vertex_input and bind elements
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl); /** Reads the camera library */
void ReadCameraLibrary();
protected:
/** Aborts the file reading with an exception */ /** Reads a camera entry into the given camera */
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX; void ReadCamera( Collada::Camera& pCamera);
/** Skips all data until the end node of the current element */ /** Reads the light library */
void SkipElement(); void ReadLightLibrary();
/** Skips all data until the end node of the given element */ /** Reads a light entry into the given light */
void SkipElement( const char* pElement); void ReadLight( Collada::Light& pLight);
/** Compares the current xml element name to the given string and returns true if equal */ /** Reads the effect library */
bool IsElement( const char* pName) const; void ReadEffectLibrary();
/** Tests for the opening tag of the given element, throws an exception if not found */ /** Reads an effect entry into the given effect*/
void TestOpening( const char* pName); void ReadEffect( Collada::Effect& pEffect);
/** Tests for the closing tag of the given element, throws an exception if not found */ /** Reads an COMMON effect profile */
void TestClosing( const char* pName); void ReadEffectProfileCommon( Collada::Effect& pEffect);
/** Checks the present element for the presence of the attribute, returns its index /** Read sampler properties */
or throws an exception if not found */ void ReadSamplerProperties( Collada::Sampler& pSampler);
int GetAttribute( const char* pAttr) const;
/** Reads an effect entry containing a color or a texture defining that color */
/** Returns the index of the named attribute or -1 if not found. Does not throw, void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
therefore useful for optional attributes */
int TestAttribute( const char* pAttr) const; /** Reads an effect entry containing a float */
void ReadEffectFloat( float& pFloat);
/** Reads the text contents of an element, throws an exception if not given.
Skips leading whitespace. */ /** Reads an effect parameter specification of any kind */
const char* GetTextContent(); void ReadEffectParam( Collada::EffectParam& pParam);
/** Reads the text contents of an element, returns NULL if not given. /** Reads the geometry library contents */
Skips leading whitespace. */ void ReadGeometryLibrary();
const char* TestTextContent();
/** Reads a geometry from the geometry library. */
/** Reads a single bool from current text content */ void ReadGeometry( Collada::Mesh* pMesh);
bool ReadBoolFromTextContent();
/** Reads a mesh from the geometry library */
/** Reads a single float from current text content */ void ReadMesh( Collada::Mesh* pMesh);
float ReadFloatFromTextContent();
/** Reads a source element - a combination of raw data and an accessor defining
/** Calculates the resulting transformation from all the given transform steps */ * things that should not be redefinable. Yes, that's another rant.
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& pTransforms) const; */
void ReadSource();
/** Determines the input data type for the given semantic string */
Collada::InputType GetTypeForSemantic( const std::string& pSemantic); /** Reads a data array holding a number of elements, and stores it in the global library.
* Currently supported are array of floats and arrays of strings.
/** Finds the item in the given library by its reference, throws if not found */ */
template <typename Type> const Type& ResolveLibraryReference( void ReadDataArray();
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
/** Reads an accessor and stores it in the global library under the given ID -
protected: * accessors use the ID of the parent <source> element
/** Filename, for a verbose error message */ */
std::string mFileName; void ReadAccessor( const std::string& pID);
/** XML reader, member for everyday use */ /** Reads input declarations of per-vertex mesh data into the given mesh */
irr::io::IrrXMLReader* mReader; void ReadVertexData( Collada::Mesh* pMesh);
/** All data arrays found in the file by ID. Might be referred to by actually /** Reads input declarations of per-index mesh data into the given mesh */
everyone. Collada, you are a steaming pile of indirection. */ void ReadIndexData( Collada::Mesh* pMesh);
typedef std::map<std::string, Collada::Data> DataLibrary;
DataLibrary mDataLibrary; /** Reads a single input channel element and stores it in the given array, if valid */
void ReadInputChannel( std::vector<Collada::InputChannel>& poChannels);
/** Same for accessors which define how the data in a data array is accessed. */
typedef std::map<std::string, Collada::Accessor> AccessorLibrary; /** Reads a <p> primitive index list and assembles the mesh data into the given mesh */
AccessorLibrary mAccessorLibrary; size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
size_t pNumPrimitives, const std::vector<size_t>& pVCount, Collada::PrimitiveType pPrimType);
/** Mesh library: mesh by ID */
typedef std::map<std::string, Collada::Mesh*> MeshLibrary; /** Copies the data for a single primitive into the mesh, based on the InputChannels */
MeshLibrary mMeshLibrary; void CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset,
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
/** node library: root node of the hierarchy part by ID */ size_t currentPrimitive, const std::vector<size_t>& indices);
typedef std::map<std::string, Collada::Node*> NodeLibrary;
NodeLibrary mNodeLibrary; /** Reads one triangle of a tristrip into the mesh */
void ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, Collada::Mesh* pMesh,
/** Image library: stores texture properties by ID */ std::vector<Collada::InputChannel>& pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t>& indices);
typedef std::map<std::string, Collada::Image> ImageLibrary;
ImageLibrary mImageLibrary; /** Extracts a single object from an input channel and stores it in the appropriate mesh data array */
void ExtractDataObjectFromChannel( const Collada::InputChannel& pInput, size_t pLocalIndex, Collada::Mesh* pMesh);
/** Effect library: surface attributes by ID */
typedef std::map<std::string, Collada::Effect> EffectLibrary; /** Reads the library of node hierarchies and scene parts */
EffectLibrary mEffectLibrary; void ReadSceneLibrary();
/** Material library: surface material by ID */ /** Reads a scene node's contents including children and stores it in the given node */
typedef std::map<std::string, Collada::Material> MaterialLibrary; void ReadSceneNode( Collada::Node* pNode);
MaterialLibrary mMaterialLibrary;
/** Reads a node transformation entry of the given type and adds it to the given node's transformation list. */
/** Light library: surface light by ID */ void ReadNodeTransformation( Collada::Node* pNode, Collada::TransformType pType);
typedef std::map<std::string, Collada::Light> LightLibrary;
LightLibrary mLightLibrary; /** Reads a mesh reference in a node and adds it to the node's mesh list */
void ReadNodeGeometry( Collada::Node* pNode);
/** Camera library: surface material by ID */
typedef std::map<std::string, Collada::Camera> CameraLibrary; /** Reads the collada scene */
CameraLibrary mCameraLibrary; void ReadScene();
/** Controller library: joint controllers by ID */ // Processes bind_vertex_input and bind elements
typedef std::map<std::string, Collada::Controller> ControllerLibrary; void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
ControllerLibrary mControllerLibrary;
protected:
/** Pointer to the root node. Don't delete, it just points to one of /** Aborts the file reading with an exception */
the nodes in the node library. */ AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
Collada::Node* mRootNode; void ReportWarning(const char* msg,...);
/** Root animation container */
Collada::Animation mAnims;
/** Size unit: how large compared to a meter */
float mUnitSize;
/** Which is the up vector */
enum { UP_X, UP_Y, UP_Z } mUpDirection;
/** Collada file format version */
Collada::FormatVersion mFormat;
};
// ------------------------------------------------------------------------------------------------
// Check for element match
inline bool ColladaParser::IsElement( const char* pName) const
{
ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT);
return ::strcmp( mReader->getNodeName(), pName) == 0;
}
// ------------------------------------------------------------------------------------------------
// Finds the item in the given library by its reference, throws if not found
template <typename Type>
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const
{
typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL);
if( it == pLibrary.end())
ThrowException( boost::str( boost::format( "Unable to resolve library reference \"%s\".") % pURL));
return it->second;
}
/** Skips all data until the end node of the current element */
void SkipElement();
/** Skips all data until the end node of the given element */
void SkipElement( const char* pElement);
/** Compares the current xml element name to the given string and returns true if equal */
bool IsElement( const char* pName) const;
/** Tests for the opening tag of the given element, throws an exception if not found */
void TestOpening( const char* pName);
/** Tests for the closing tag of the given element, throws an exception if not found */
void TestClosing( const char* pName);
/** Checks the present element for the presence of the attribute, returns its index
or throws an exception if not found */
int GetAttribute( const char* pAttr) const;
/** Returns the index of the named attribute or -1 if not found. Does not throw,
therefore useful for optional attributes */
int TestAttribute( const char* pAttr) const;
/** Reads the text contents of an element, throws an exception if not given.
Skips leading whitespace. */
const char* GetTextContent();
/** Reads the text contents of an element, returns NULL if not given.
Skips leading whitespace. */
const char* TestTextContent();
/** Reads a single bool from current text content */
bool ReadBoolFromTextContent();
/** Reads a single float from current text content */
float ReadFloatFromTextContent();
/** Calculates the resulting transformation from all the given transform steps */
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& pTransforms) const;
/** Determines the input data type for the given semantic string */
Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
/** Finds the item in the given library by its reference, throws if not found */
template <typename Type> const Type& ResolveLibraryReference(
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
protected:
/** Filename, for a verbose error message */
std::string mFileName;
/** XML reader, member for everyday use */
irr::io::IrrXMLReader* mReader;
/** All data arrays found in the file by ID. Might be referred to by actually
everyone. Collada, you are a steaming pile of indirection. */
typedef std::map<std::string, Collada::Data> DataLibrary;
DataLibrary mDataLibrary;
/** Same for accessors which define how the data in a data array is accessed. */
typedef std::map<std::string, Collada::Accessor> AccessorLibrary;
AccessorLibrary mAccessorLibrary;
/** Mesh library: mesh by ID */
typedef std::map<std::string, Collada::Mesh*> MeshLibrary;
MeshLibrary mMeshLibrary;
/** node library: root node of the hierarchy part by ID */
typedef std::map<std::string, Collada::Node*> NodeLibrary;
NodeLibrary mNodeLibrary;
/** Image library: stores texture properties by ID */
typedef std::map<std::string, Collada::Image> ImageLibrary;
ImageLibrary mImageLibrary;
/** Effect library: surface attributes by ID */
typedef std::map<std::string, Collada::Effect> EffectLibrary;
EffectLibrary mEffectLibrary;
/** Material library: surface material by ID */
typedef std::map<std::string, Collada::Material> MaterialLibrary;
MaterialLibrary mMaterialLibrary;
/** Light library: surface light by ID */
typedef std::map<std::string, Collada::Light> LightLibrary;
LightLibrary mLightLibrary;
/** Camera library: surface material by ID */
typedef std::map<std::string, Collada::Camera> CameraLibrary;
CameraLibrary mCameraLibrary;
/** Controller library: joint controllers by ID */
typedef std::map<std::string, Collada::Controller> ControllerLibrary;
ControllerLibrary mControllerLibrary;
/** Pointer to the root node. Don't delete, it just points to one of
the nodes in the node library. */
Collada::Node* mRootNode;
/** Root animation container */
Collada::Animation mAnims;
/** Size unit: how large compared to a meter */
float mUnitSize;
/** Which is the up vector */
enum { UP_X, UP_Y, UP_Z } mUpDirection;
/** Collada file format version */
Collada::FormatVersion mFormat;
};
// ------------------------------------------------------------------------------------------------
// Check for element match
inline bool ColladaParser::IsElement( const char* pName) const
{
ai_assert( mReader->getNodeType() == irr::io::EXN_ELEMENT);
return ::strcmp( mReader->getNodeName(), pName) == 0;
}
// ------------------------------------------------------------------------------------------------
// Finds the item in the given library by its reference, throws if not found
template <typename Type>
const Type& ColladaParser::ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const
{
typename std::map<std::string, Type>::const_iterator it = pLibrary.find( pURL);
if( it == pLibrary.end())
ThrowException( boost::str( boost::format( "Unable to resolve library reference \"%s\".") % pURL));
return it->second;
}
} // end of namespace Assimp } // end of namespace Assimp
#endif // AI_COLLADAPARSER_H_INC #endif // AI_COLLADAPARSER_H_INC

View File

@ -152,8 +152,8 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
if (fDelta1_z < 0.05f * sqrtf( fDelta1_y * fDelta1_x ))return false; if (fDelta1_z < 0.05f * sqrtf( fDelta1_y * fDelta1_x ))return false;
// now compare the volumes of the bounding boxes // now compare the volumes of the bounding boxes
if (std::fabs(fDelta0_x * fDelta1_yz) < if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) <
std::fabs(fDelta1_x * fDelta1_y * fDelta1_z)) std::fabs(fDelta1_x * fDelta1_yz))
{ {
if (!DefaultLogger::isNullLogger()) if (!DefaultLogger::isNullLogger())
{ {

View File

@ -602,12 +602,12 @@ bool IntersectingLineSegments(const IfcVector2& n0, const IfcVector2& n1,
const IfcVector2& m0, const IfcVector2& m1, const IfcVector2& m0, const IfcVector2& m1,
IfcVector2& out0, IfcVector2& out1) IfcVector2& out0, IfcVector2& out1)
{ {
const IfcVector2& n0_to_n1 = n1 - n0; const IfcVector2 n0_to_n1 = n1 - n0;
const IfcVector2& n0_to_m0 = m0 - n0; const IfcVector2 n0_to_m0 = m0 - n0;
const IfcVector2& n1_to_m1 = m1 - n1; const IfcVector2 n1_to_m1 = m1 - n1;
const IfcVector2& n0_to_m1 = m1 - n0; const IfcVector2 n0_to_m1 = m1 - n0;
const IfcFloat e = 1e-5f; const IfcFloat e = 1e-5f;
const IfcFloat smalle = 1e-9f; const IfcFloat smalle = 1e-9f;
@ -927,7 +927,7 @@ size_t CloseWindows(ContourVector& contours,
IfcFloat best = static_cast<IfcFloat>(1e10); IfcFloat best = static_cast<IfcFloat>(1e10);
IfcVector3 bestv; IfcVector3 bestv;
const IfcVector3& world_point = minv * IfcVector3(proj_point.x,proj_point.y,0.0f); const IfcVector3 world_point = minv * IfcVector3(proj_point.x,proj_point.y,0.0f);
BOOST_FOREACH(const TempOpening* opening, refs) { BOOST_FOREACH(const TempOpening* opening, refs) {
BOOST_FOREACH(const IfcVector3& other, opening->wallPoints) { BOOST_FOREACH(const IfcVector3& other, opening->wallPoints) {
@ -1066,7 +1066,7 @@ IfcMatrix4 ProjectOntoPlane(std::vector<IfcVector2>& out_contour, const TempMesh
// Project all points into the new coordinate system, collect min/max verts on the way // Project all points into the new coordinate system, collect min/max verts on the way
BOOST_FOREACH(const IfcVector3& x, in_verts) { BOOST_FOREACH(const IfcVector3& x, in_verts) {
const IfcVector3& vv = m * x; const IfcVector3 vv = m * x;
// keep Z offset in the plane coordinate system. Ignoring precision issues // keep Z offset in the plane coordinate system. Ignoring precision issues
// (which are present, of course), this should be the same value for // (which are present, of course), this should be the same value for
// all polygon vertices (assuming the polygon is planar). // all polygon vertices (assuming the polygon is planar).
@ -1144,7 +1144,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
std::vector<IfcVector2> contour_flat; std::vector<IfcVector2> contour_flat;
IfcVector3 nor; IfcVector3 nor;
const IfcMatrix4& m = ProjectOntoPlane(contour_flat, curmesh, ok, nor); const IfcMatrix4 m = ProjectOntoPlane(contour_flat, curmesh, ok, nor);
if(!ok) { if(!ok) {
return false; return false;
} }
@ -1227,7 +1227,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
bool side_flag = true; bool side_flag = true;
if (!is_2d_source) { if (!is_2d_source) {
const IfcVector3& face_nor = ((profile_verts[vi_total+2] - profile_verts[vi_total]) ^ const IfcVector3 face_nor = ((profile_verts[vi_total+2] - profile_verts[vi_total]) ^
(profile_verts[vi_total+1] - profile_verts[vi_total])).Normalize(); (profile_verts[vi_total+1] - profile_verts[vi_total])).Normalize();
const IfcFloat abs_dot_face_nor = std::abs(nor * face_nor); const IfcFloat abs_dot_face_nor = std::abs(nor * face_nor);
@ -1242,7 +1242,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
for (unsigned int vi = 0, vend = profile_vertcnts[f]; vi < vend; ++vi, ++vi_total) { for (unsigned int vi = 0, vend = profile_vertcnts[f]; vi < vend; ++vi, ++vi_total) {
const IfcVector3& x = profile_verts[vi_total]; const IfcVector3& x = profile_verts[vi_total];
const IfcVector3& v = m * x; const IfcVector3 v = m * x;
IfcVector2 vv(v.x, v.y); IfcVector2 vv(v.x, v.y);
//if(check_intersection) { //if(check_intersection) {
@ -1322,7 +1322,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
MakeDisjunctWindowContours(other, temp_contour, poly); MakeDisjunctWindowContours(other, temp_contour, poly);
if(poly.size() == 1) { if(poly.size() == 1) {
const BoundingBox& newbb = GetBoundingBox(poly[0].outer); const BoundingBox newbb = GetBoundingBox(poly[0].outer);
if (!BoundingBoxesOverlapping(ibb, newbb )) { if (!BoundingBoxesOverlapping(ibb, newbb )) {
// Good guy bounding box // Good guy bounding box
bb = newbb ; bb = newbb ;
@ -1438,7 +1438,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,const std:
// working coordinate system. // working coordinate system.
bool ok; bool ok;
IfcVector3 nor; IfcVector3 nor;
const IfcMatrix3& m = DerivePlaneCoordinateSpace(curmesh, ok, nor); const IfcMatrix3 m = DerivePlaneCoordinateSpace(curmesh, ok, nor);
if (!ok) { if (!ok) {
return false; return false;
} }
@ -1686,13 +1686,13 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,const std:
continue; continue;
} }
const std::vector<p2t::Triangle*>& tris = cdt->GetTriangles(); const std::vector<p2t::Triangle*> tris = cdt->GetTriangles();
// Collect the triangles we just produced // Collect the triangles we just produced
BOOST_FOREACH(p2t::Triangle* tri, tris) { BOOST_FOREACH(p2t::Triangle* tri, tris) {
for(int i = 0; i < 3; ++i) { for(int i = 0; i < 3; ++i) {
const IfcVector2& v = IfcVector2( const IfcVector2 v = IfcVector2(
static_cast<IfcFloat>( tri->GetPoint(i)->x ), static_cast<IfcFloat>( tri->GetPoint(i)->x ),
static_cast<IfcFloat>( tri->GetPoint(i)->y ) static_cast<IfcFloat>( tri->GetPoint(i)->y )
); );

View File

@ -954,6 +954,9 @@ inline void LWOImporter::DoRecursiveVMAPAssignment(VMapEntry* base, unsigned int
LWO::ReferrerList& refList = mCurLayer->mPointReferrers; LWO::ReferrerList& refList = mCurLayer->mPointReferrers;
unsigned int i; unsigned int i;
if (idx >= base->abAssigned.size()) {
throw DeadlyImportError("Bad index");
}
base->abAssigned[idx] = true; base->abAssigned[idx] = true;
for (i = 0; i < numRead;++i) { for (i = 0; i < numRead;++i) {
base->rawData[idx*base->dims+i]= data[i]; base->rawData[idx*base->dims+i]= data[i];

View File

@ -783,6 +783,13 @@ void MD3Importer::InternReadFile( const std::string& pFile,
// Allocate output storage // Allocate output storage
pScene->mNumMeshes = pcHeader->NUM_SURFACES; pScene->mNumMeshes = pcHeader->NUM_SURFACES;
if (pcHeader->NUM_SURFACES == 0) {
throw DeadlyImportError("MD3: No surfaces");
} else if (pcHeader->NUM_SURFACES > AI_MAX_ALLOC(aiMesh)) {
// We allocate pointers but check against the size of aiMesh
// since those pointers will eventually have to point to real objects
throw DeadlyImportError("MD3: Too many surfaces, would run out of memory");
}
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
pScene->mNumMaterials = pcHeader->NUM_SURFACES; pScene->mNumMaterials = pcHeader->NUM_SURFACES;

View File

@ -355,6 +355,9 @@ void MDLImporter::InternReadFile_Quake1( )
for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins;++i) for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins;++i)
{ {
union{BE_NCONST MDL::Skin* pcSkin;BE_NCONST MDL::GroupSkin* pcGroupSkin;}; union{BE_NCONST MDL::Skin* pcSkin;BE_NCONST MDL::GroupSkin* pcGroupSkin;};
if (szCurrent + sizeof(MDL::Skin) > this->mBuffer + this->iFileSize) {
throw DeadlyImportError("[Quake 1 MDL] Unexpected EOF");
}
pcSkin = (BE_NCONST MDL::Skin*)szCurrent; pcSkin = (BE_NCONST MDL::Skin*)szCurrent;
AI_SWAP4( pcSkin->group ); AI_SWAP4( pcSkin->group );

View File

@ -133,15 +133,16 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
TextFileToBuffer(file.get(),m_Buffer); TextFileToBuffer(file.get(),m_Buffer);
// Get the model name // Get the model name
std::string strModelName; std::string modelName, folderName;
std::string::size_type pos = pFile.find_last_of( "\\/" ); std::string::size_type pos = pFile.find_last_of( "\\/" );
if ( pos != std::string::npos ) if ( pos != std::string::npos ) {
{ modelName = pFile.substr(pos+1, pFile.size() - pos - 1);
strModelName = pFile.substr(pos+1, pFile.size() - pos - 1); folderName = pFile.substr( 0, pos );
} if ( folderName.empty() ) {
else pIOHandler->PushDirectory( folderName );
{ }
strModelName = pFile; } else {
modelName = pFile;
} }
// process all '\' // process all '\'
@ -161,13 +162,18 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
} }
// parse the file into a temporary representation // parse the file into a temporary representation
ObjFileParser parser(m_Buffer, strModelName, pIOHandler); ObjFileParser parser(m_Buffer, modelName, pIOHandler);
// And create the proper return structures out of it // And create the proper return structures out of it
CreateDataFromImport(parser.GetModel(), pScene); CreateDataFromImport(parser.GetModel(), pScene);
// Clean up allocated storage for the next import // Clean up allocated storage for the next import
m_Buffer.clear(); m_Buffer.clear();
// Pop directory stack
if ( pIOHandler->StackSize() > 0 ) {
pIOHandler->PopDirectory();
}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -380,6 +386,11 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
// Copy vertices of this mesh instance // Copy vertices of this mesh instance
pMesh->mNumVertices = numIndices; pMesh->mNumVertices = numIndices;
if (pMesh->mNumVertices == 0) {
throw DeadlyImportError( "OBJ: no vertices" );
} else if (pMesh->mNumVertices > AI_MAX_ALLOC(aiVector3D)) {
throw DeadlyImportError( "OBJ: Too many vertices, would run out of memory" );
}
pMesh->mVertices = new aiVector3D[ pMesh->mNumVertices ]; pMesh->mVertices = new aiVector3D[ pMesh->mNumVertices ];
// Allocate buffer for normal vectors // Allocate buffer for normal vectors

View File

@ -61,21 +61,21 @@ const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Constructor with loaded data and directories. // Constructor with loaded data and directories.
ObjFileParser::ObjFileParser(std::vector<char> &Data,const std::string &strModelName, IOSystem *io ) : ObjFileParser::ObjFileParser(std::vector<char> &data,const std::string &modelName, IOSystem *io ) :
m_DataIt(Data.begin()), m_DataIt(data.begin()),
m_DataItEnd(Data.end()), m_DataItEnd(data.end()),
m_pModel(NULL), m_pModel(NULL),
m_uiLine(0), m_uiLine(0),
m_pIO( io ) m_pIO( io )
{ {
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
m_pModel = new ObjFile::Model(); m_pModel = new ObjFile::Model();
m_pModel->m_ModelName = strModelName; m_pModel->m_ModelName = modelName;
// create default material and store it // create default material and store it
m_pModel->m_pDefaultMaterial = new ObjFile::Material(); m_pModel->m_pDefaultMaterial = new ObjFile::Material;
m_pModel->m_pDefaultMaterial->MaterialName.Set( DEFAULT_MATERIAL ); m_pModel->m_pDefaultMaterial->MaterialName.Set( DEFAULT_MATERIAL );
m_pModel->m_MaterialLib.push_back( DEFAULT_MATERIAL ); m_pModel->m_MaterialLib.push_back( DEFAULT_MATERIAL );
m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial; m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial;
@ -248,20 +248,20 @@ void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
} }
float x, y, z; float x, y, z;
if( 2 == numComponents ) { if( 2 == numComponents ) {
copyNextWord( m_buffer, BUFFERSIZE ); copyNextWord( m_buffer, Buffersize );
x = ( float ) fast_atof( m_buffer ); x = ( float ) fast_atof( m_buffer );
copyNextWord( m_buffer, BUFFERSIZE ); copyNextWord( m_buffer, Buffersize );
y = ( float ) fast_atof( m_buffer ); y = ( float ) fast_atof( m_buffer );
z = 0.0; z = 0.0;
} else if( 3 == numComponents ) { } else if( 3 == numComponents ) {
copyNextWord( m_buffer, BUFFERSIZE ); copyNextWord( m_buffer, Buffersize );
x = ( float ) fast_atof( m_buffer ); x = ( float ) fast_atof( m_buffer );
copyNextWord( m_buffer, BUFFERSIZE ); copyNextWord( m_buffer, Buffersize );
y = ( float ) fast_atof( m_buffer ); y = ( float ) fast_atof( m_buffer );
copyNextWord( m_buffer, BUFFERSIZE ); copyNextWord( m_buffer, Buffersize );
z = ( float ) fast_atof( m_buffer ); z = ( float ) fast_atof( m_buffer );
} else { } else {
throw DeadlyImportError( "OBJ: Invalid number of components" ); throw DeadlyImportError( "OBJ: Invalid number of components" );
@ -274,13 +274,13 @@ void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
// Get values for a new 3D vector instance // Get values for a new 3D vector instance
void ObjFileParser::getVector3(std::vector<aiVector3D> &point3d_array) { void ObjFileParser::getVector3(std::vector<aiVector3D> &point3d_array) {
float x, y, z; float x, y, z;
copyNextWord(m_buffer, BUFFERSIZE); copyNextWord(m_buffer, Buffersize);
x = (float) fast_atof(m_buffer); x = (float) fast_atof(m_buffer);
copyNextWord(m_buffer, BUFFERSIZE); copyNextWord(m_buffer, Buffersize);
y = (float) fast_atof(m_buffer); y = (float) fast_atof(m_buffer);
copyNextWord( m_buffer, BUFFERSIZE ); copyNextWord( m_buffer, Buffersize );
z = ( float ) fast_atof( m_buffer ); z = ( float ) fast_atof( m_buffer );
point3d_array.push_back( aiVector3D( x, y, z ) ); point3d_array.push_back( aiVector3D( x, y, z ) );
@ -291,10 +291,10 @@ void ObjFileParser::getVector3(std::vector<aiVector3D> &point3d_array) {
// Get values for a new 2D vector instance // Get values for a new 2D vector instance
void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) { void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
float x, y; float x, y;
copyNextWord(m_buffer, BUFFERSIZE); copyNextWord(m_buffer, Buffersize);
x = (float) fast_atof(m_buffer); x = (float) fast_atof(m_buffer);
copyNextWord(m_buffer, BUFFERSIZE); copyNextWord(m_buffer, Buffersize);
y = (float) fast_atof(m_buffer); y = (float) fast_atof(m_buffer);
point2d_array.push_back(aiVector2D(x, y)); point2d_array.push_back(aiVector2D(x, y));
@ -306,12 +306,12 @@ void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
// Get values for a new face instance // Get values for a new face instance
void ObjFileParser::getFace(aiPrimitiveType type) void ObjFileParser::getFace(aiPrimitiveType type)
{ {
copyNextLine(m_buffer, BUFFERSIZE); copyNextLine(m_buffer, Buffersize);
if (m_DataIt == m_DataItEnd) if (m_DataIt == m_DataItEnd)
return; return;
char *pPtr = m_buffer; char *pPtr = m_buffer;
char *pEnd = &pPtr[BUFFERSIZE]; char *pEnd = &pPtr[Buffersize];
pPtr = getNextToken<char*>(pPtr, pEnd); pPtr = getNextToken<char*>(pPtr, pEnd);
if (pPtr == pEnd || *pPtr == '\0') if (pPtr == pEnd || *pPtr == '\0')
return; return;
@ -468,8 +468,9 @@ void ObjFileParser::getMaterialDesc()
// Get next data for material data // Get next data for material data
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd); m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
if (m_DataIt == m_DataItEnd) if (m_DataIt == m_DataItEnd) {
return; return;
}
char *pStart = &(*m_DataIt); char *pStart = &(*m_DataIt);
while( m_DataIt != m_DataItEnd && !IsLineEnd( *m_DataIt ) ) { while( m_DataIt != m_DataItEnd && !IsLineEnd( *m_DataIt ) ) {
@ -483,14 +484,11 @@ void ObjFileParser::getMaterialDesc()
// Search for material // Search for material
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( strName ); std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( strName );
if ( it == m_pModel->m_MaterialMap.end() ) if ( it == m_pModel->m_MaterialMap.end() ) {
{
// Not found, use default material // Not found, use default material
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial; m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", skipping"); DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", skipping");
} } else {
else
{
// Found, using detected material // Found, using detected material
m_pModel->m_pCurrentMaterial = (*it).second; m_pModel->m_pCurrentMaterial = (*it).second;
if ( needsNewMesh( strName )) if ( needsNewMesh( strName ))
@ -539,18 +537,24 @@ void ObjFileParser::getMaterialLib()
// Check for existence // Check for existence
const std::string strMatName(pStart, &(*m_DataIt)); const std::string strMatName(pStart, &(*m_DataIt));
IOStream *pFile = m_pIO->Open(strMatName); std::string absName;
if ( m_pIO->StackSize() > 0 ) {
const std::string &path = m_pIO->CurrentDirectory();
absName = path + strMatName;
} else {
absName = strMatName;
}
IOStream *pFile = m_pIO->Open( absName );
if (!pFile ) if (!pFile ) {
{ DefaultLogger::get()->error( "OBJ: Unable to locate material file " + strMatName );
DefaultLogger::get()->error("OBJ: Unable to locate material file " + strMatName);
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
return; return;
} }
// Import material library data from file // Import material library data from file
std::vector<char> buffer; std::vector<char> buffer;
BaseImporter::TextFileToBuffer(pFile,buffer); BaseImporter::TextFileToBuffer( pFile, buffer );
m_pIO->Close( pFile ); m_pIO->Close( pFile );
// Importing the material library // Importing the material library

View File

@ -62,10 +62,9 @@ class IOSystem;
/// \class ObjFileParser /// \class ObjFileParser
/// \brief Parser for a obj waveform file /// \brief Parser for a obj waveform file
class ObjFileParser class ObjFileParser {
{
public: public:
static const size_t BUFFERSIZE = 4096; static const size_t Buffersize = 4096;
typedef std::vector<char> DataArray; typedef std::vector<char> DataArray;
typedef std::vector<char>::iterator DataArrayIt; typedef std::vector<char>::iterator DataArrayIt;
typedef std::vector<char>::const_iterator ConstDataArrayIt; typedef std::vector<char>::const_iterator ConstDataArrayIt;
@ -137,9 +136,10 @@ private:
//! Current line (for debugging) //! Current line (for debugging)
unsigned int m_uiLine; unsigned int m_uiLine;
//! Helper buffer //! Helper buffer
char m_buffer[BUFFERSIZE]; char m_buffer[Buffersize];
/// Pointer to IO system instance. /// Pointer to IO system instance.
IOSystem *m_pIO; IOSystem *m_pIO;
/// Path to the current model
}; };
} // Namespace Assimp } // Namespace Assimp

View File

@ -63,23 +63,23 @@ static const aiImporterDesc desc = {
}; };
namespace Grammar { namespace Grammar {
static const char *MetricType = "Metric"; static const std::string MetricType = "Metric";
static const char *Metric_DistanceType = "distance"; static const std::string Metric_DistanceType = "distance";
static const char *Metric_AngleType = "angle"; static const std::string Metric_AngleType = "angle";
static const char *Metric_TimeType = "time"; static const std::string Metric_TimeType = "time";
static const char *Metric_UpType = "up"; static const std::string Metric_UpType = "up";
static const char *NameType = "Name"; static const std::string NameType = "Name";
static const char *ObjectRefType = "ObjectRef"; static const std::string ObjectRefType = "ObjectRef";
static const char *MaterialRefType = "MaterialRef"; static const std::string MaterialRefType = "MaterialRef";
static const char *MetricKeyType = "key"; static const std::string MetricKeyType = "key";
static const char *GeometryNodeType = "GeometryNode"; static const std::string GeometryNodeType = "GeometryNode";
static const char *GeometryObjectType = "GeometryObject"; static const std::string GeometryObjectType = "GeometryObject";
static const char *TransformType = "Transform"; static const std::string TransformType = "Transform";
static const char *MeshType = "Mesh"; static const std::string MeshType = "Mesh";
static const char *VertexArrayType = "VertexArray"; static const std::string VertexArrayType = "VertexArray";
static const char *IndexArrayType = "IndexArray"; static const std::string IndexArrayType = "IndexArray";
static const char *MaterialType = "Material"; static const std::string MaterialType = "Material";
static const char *ColorType = "Color"; static const std::string ColorType = "Color";
static const std::string DiffuseColorToken = "diffuse"; static const std::string DiffuseColorToken = "diffuse";
static const std::string SpecularColorToken = "specular"; static const std::string SpecularColorToken = "specular";
static const std::string EmissionColorToken = "emission"; static const std::string EmissionColorToken = "emission";
@ -112,7 +112,7 @@ namespace Grammar {
TextureToken TextureToken
}; };
static const char *ValidMetricToken[ 4 ] = { static const std::string ValidMetricToken[ 4 ] = {
Metric_DistanceType, Metric_DistanceType,
Metric_AngleType, Metric_AngleType,
Metric_TimeType, Metric_TimeType,
@ -126,7 +126,7 @@ namespace Grammar {
int idx( -1 ); int idx( -1 );
for( size_t i = 0; i < 4; i++ ) { for( size_t i = 0; i < 4; i++ ) {
if( 0 == strncmp( ValidMetricToken[ i ], token, strlen( token ) ) ) { if( ValidMetricToken[ i ] == token ) {
idx = (int) i; idx = (int) i;
break; break;
} }
@ -136,45 +136,33 @@ namespace Grammar {
} }
static TokenType matchTokenType( const char *tokenType ) { static TokenType matchTokenType( const char *tokenType ) {
if( 0 == strncmp( MetricType, tokenType, strlen( MetricType ) ) ) { if( MetricType == tokenType ) {
return MetricToken; return MetricToken;
} else if( 0 == strncmp( NameType, tokenType, strlen( NameType ) ) ) { } else if( NameType == tokenType ) {
return NameToken; return NameToken;
} } else if( ObjectRefType == tokenType ) {
else if( 0 == strncmp( ObjectRefType, tokenType, strlen( ObjectRefType ) ) ) {
return ObjectRefToken; return ObjectRefToken;
} } else if( MaterialRefType == tokenType ) {
else if( 0 == strncmp( MaterialRefType, tokenType, strlen( MaterialRefType ) ) ) {
return MaterialRefToken; return MaterialRefToken;
} } else if( MetricKeyType == tokenType ) {
else if( 0 == strncmp( MetricKeyType, tokenType, strlen( MetricKeyType ) ) ) {
return MetricKeyToken; return MetricKeyToken;
} } else if( GeometryNodeType == tokenType ) {
else if( 0 == strncmp( GeometryNodeType, tokenType, strlen( GeometryNodeType ) ) ) {
return GeometryNodeToken; return GeometryNodeToken;
} } else if( GeometryObjectType == tokenType ) {
else if( 0 == strncmp( GeometryObjectType, tokenType, strlen( GeometryObjectType ) ) ) {
return GeometryObjectToken; return GeometryObjectToken;
} } else if( TransformType == tokenType ) {
else if( 0 == strncmp( TransformType, tokenType, strlen( TransformType ) ) ) {
return TransformToken; return TransformToken;
} } else if( MeshType == tokenType ) {
else if( 0 == strncmp( MeshType, tokenType, strlen( MeshType ) ) ) {
return MeshToken; return MeshToken;
} } else if( VertexArrayType == tokenType ) {
else if( 0 == strncmp( VertexArrayType, tokenType, strlen( VertexArrayType ) ) ) {
return VertexArrayToken; return VertexArrayToken;
} } else if( IndexArrayType == tokenType ) {
else if( 0 == strncmp( IndexArrayType, tokenType, strlen( IndexArrayType ) ) ) {
return IndexArrayToken; return IndexArrayToken;
} } else if( MaterialType == tokenType ) {
else if( 0 == strncmp( MaterialType, tokenType, strlen( MaterialType ) ) ) {
return MaterialToken; return MaterialToken;
} } else if( ColorType == tokenType ) {
else if( 0 == strncmp( ColorType, tokenType, strlen( ColorType ) ) ) {
return ColorToken; return ColorToken;
} } else if( TextureType == tokenType ) {
else if( 0 == strncmp( TextureType, tokenType, strlen( TextureType ) ) ) {
return TextureToken; return TextureToken;
} }

View File

@ -189,7 +189,12 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
} }
mOutput << "element face " << faces << endl; mOutput << "element face " << faces << endl;
mOutput << "property list uint uint vertex_index" << endl;
// uchar seems to be the most common type for the number of indices per polygon and int seems to be most common for the vertex indices.
// For instance, MeshLab fails to load meshes in which both types are uint. Houdini seems to have problems as well.
// Obviously, using uchar will not work for meshes with polygons with more than 255 indices, but how realistic is this case?
mOutput << "property list uchar int vertex_index" << endl;
mOutput << "end_header" << endl; mOutput << "end_header" << endl;
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
@ -342,16 +347,24 @@ void PlyExporter::WriteMeshIndices(const aiMesh* m, unsigned int offset)
} }
} }
void PlyExporter::WriteMeshIndicesBinary(const aiMesh* m, unsigned int offset) // Generic method in case we want to use different data types for the indices or make this configurable.
template<typename NumIndicesType, typename IndexType>
void WriteMeshIndicesBinary_Generic(const aiMesh* m, unsigned int offset, std::ostringstream& output)
{ {
for (unsigned int i = 0; i < m->mNumFaces; ++i) { for (unsigned int i = 0; i < m->mNumFaces; ++i) {
const aiFace& f = m->mFaces[i]; const aiFace& f = m->mFaces[i];
mOutput.write(reinterpret_cast<const char*>(&f.mNumIndices), 4); NumIndicesType numIndices = static_cast<NumIndicesType>(f.mNumIndices);
output.write(reinterpret_cast<const char*>(&numIndices), sizeof(NumIndicesType));
for (unsigned int c = 0; c < f.mNumIndices; ++c) { for (unsigned int c = 0; c < f.mNumIndices; ++c) {
unsigned int index = f.mIndices[c] + offset; IndexType index = f.mIndices[c] + offset;
mOutput.write(reinterpret_cast<const char*>(&index), 4); output.write(reinterpret_cast<const char*>(&index), sizeof(IndexType));
} }
} }
} }
void PlyExporter::WriteMeshIndicesBinary(const aiMesh* m, unsigned int offset)
{
WriteMeshIndicesBinary_Generic<unsigned char, int>(m, offset, mOutput);
}
#endif #endif

View File

@ -310,6 +310,10 @@ void PLYImporter::ConvertMeshes(std::vector<PLY::Face>* avFaces,
iNum += (unsigned int)(*avFaces)[aiSplit[p][i]].mIndices.size(); iNum += (unsigned int)(*avFaces)[aiSplit[p][i]].mIndices.size();
} }
p_pcOut->mNumVertices = iNum; p_pcOut->mNumVertices = iNum;
if( 0 == iNum ) { // nothing to do
delete[] aiSplit; // cleanup
return;
}
p_pcOut->mVertices = new aiVector3D[iNum]; p_pcOut->mVertices = new aiVector3D[iNum];
if (!avColors->empty()) if (!avColors->empty())
@ -335,20 +339,25 @@ void PLYImporter::ConvertMeshes(std::vector<PLY::Face>* avFaces,
for (unsigned int q = 0; q < p_pcOut->mFaces[iNum].mNumIndices;++q) for (unsigned int q = 0; q < p_pcOut->mFaces[iNum].mNumIndices;++q)
{ {
p_pcOut->mFaces[iNum].mIndices[q] = iVertex; p_pcOut->mFaces[iNum].mIndices[q] = iVertex;
p_pcOut->mVertices[iVertex] = (*avPositions)[(*avFaces)[*i].mIndices[q]]; const size_t idx = ( *avFaces )[ *i ].mIndices[ q ];
if( idx >= ( *avPositions ).size() ) {
// out of border
continue;
}
p_pcOut->mVertices[ iVertex ] = ( *avPositions )[ idx ];
if (!avColors->empty()) if (!avColors->empty())
p_pcOut->mColors[0][iVertex] = (*avColors)[(*avFaces)[*i].mIndices[q]]; p_pcOut->mColors[ 0 ][ iVertex ] = ( *avColors )[ idx ];
if (!avTexCoords->empty()) if (!avTexCoords->empty())
{ {
const aiVector2D& vec = (*avTexCoords)[(*avFaces)[*i].mIndices[q]]; const aiVector2D& vec = ( *avTexCoords )[ idx ];
p_pcOut->mTextureCoords[0][iVertex].x = vec.x; p_pcOut->mTextureCoords[0][iVertex].x = vec.x;
p_pcOut->mTextureCoords[0][iVertex].y = vec.y; p_pcOut->mTextureCoords[0][iVertex].y = vec.y;
} }
if (!avNormals->empty()) if (!avNormals->empty())
p_pcOut->mNormals[iVertex] = (*avNormals)[(*avFaces)[*i].mIndices[q]]; p_pcOut->mNormals[ iVertex ] = ( *avNormals )[ idx ];
iVertex++; iVertex++;
} }

View File

@ -75,8 +75,9 @@ static const aiImporterDesc desc = {
// 2) 4 byte face count // 2) 4 byte face count
// 3) 50 bytes per face // 3) 50 bytes per face
bool IsBinarySTL(const char* buffer, unsigned int fileSize) { bool IsBinarySTL(const char* buffer, unsigned int fileSize) {
if (fileSize < 84) if( fileSize < 84 ) {
return false; return false;
}
const uint32_t faceCount = *reinterpret_cast<const uint32_t*>(buffer + 80); const uint32_t faceCount = *reinterpret_cast<const uint32_t*>(buffer + 80);
const uint32_t expectedBinaryFileSize = faceCount * 50 + 84; const uint32_t expectedBinaryFileSize = faceCount * 50 + 84;
@ -99,7 +100,20 @@ bool IsAsciiSTL(const char* buffer, unsigned int fileSize) {
if (buffer + 5 >= bufferEnd) if (buffer + 5 >= bufferEnd)
return false; return false;
return strncmp(buffer, "solid", 5) == 0; bool isASCII( strncmp( buffer, "solid", 5 ) == 0 );
if( isASCII ) {
// A lot of importers are write solid even if the file is binary. So we have to check for ASCII-characters.
if( fileSize >= 500 ) {
isASCII = true;
for( unsigned int i = 0; i < 500; i++ ) {
if( buffer[ i ] > 127 ) {
isASCII = false;
break;
}
}
}
}
return isASCII;
} }
} // namespace } // namespace
@ -122,23 +136,37 @@ bool STLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
{ {
const std::string extension = GetExtension(pFile); const std::string extension = GetExtension(pFile);
if (extension == "stl") if( extension == "stl" ) {
return true; return true;
else if (!extension.length() || checkSig) { } else if (!extension.length() || checkSig) {
if (!pIOHandler) if( !pIOHandler ) {
return true; return true;
}
const char* tokens[] = {"STL","solid"}; const char* tokens[] = {"STL","solid"};
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2); return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2);
} }
return false; return false;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const aiImporterDesc* STLImporter::GetInfo () const const aiImporterDesc* STLImporter::GetInfo () const {
{
return &desc; return &desc;
} }
void addFacesToMesh(aiMesh* pMesh)
{
pMesh->mFaces = new aiFace[pMesh->mNumFaces];
for (unsigned int i = 0, p = 0; i < pMesh->mNumFaces;++i) {
aiFace& face = pMesh->mFaces[i];
face.mIndices = new unsigned int[face.mNumIndices = 3];
for (unsigned int o = 0; o < 3;++o,++p) {
face.mIndices[o] = p;
}
}
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure. // Imports the given file into the given scene structure.
void STLImporter::InternReadFile( const std::string& pFile, void STLImporter::InternReadFile( const std::string& pFile,
@ -164,17 +192,8 @@ void STLImporter::InternReadFile( const std::string& pFile,
// the default vertex color is light gray. // the default vertex color is light gray.
clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6f; clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6f;
// allocate one mesh
pScene->mNumMeshes = 1;
pScene->mMeshes = new aiMesh*[1];
aiMesh* pMesh = pScene->mMeshes[0] = new aiMesh();
pMesh->mMaterialIndex = 0;
// allocate a single node // allocate a single node
pScene->mRootNode = new aiNode(); pScene->mRootNode = new aiNode();
pScene->mRootNode->mNumMeshes = 1;
pScene->mRootNode->mMeshes = new unsigned int[1];
pScene->mRootNode->mMeshes[0] = 0;
bool bMatClr = false; bool bMatClr = false;
@ -186,16 +205,11 @@ void STLImporter::InternReadFile( const std::string& pFile,
throw DeadlyImportError( "Failed to determine STL storage representation for " + pFile + "."); throw DeadlyImportError( "Failed to determine STL storage representation for " + pFile + ".");
} }
// now copy faces // add all created meshes to the single node
pMesh->mFaces = new aiFace[pMesh->mNumFaces]; pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
for (unsigned int i = 0, p = 0; i < pMesh->mNumFaces;++i) { pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
for (unsigned int i = 0; i < pScene->mNumMeshes; i++)
aiFace& face = pMesh->mFaces[i]; pScene->mRootNode->mMeshes[i] = i;
face.mIndices = new unsigned int[face.mNumIndices = 3];
for (unsigned int o = 0; o < 3;++o,++p) {
face.mIndices[o] = p;
}
}
// create a single default material, using a light gray diffuse color for consistency with // create a single default material, using a light gray diffuse color for consistency with
// other geometric types (e.g., PLY). // other geometric types (e.g., PLY).
@ -221,140 +235,171 @@ void STLImporter::InternReadFile( const std::string& pFile,
// Read an ASCII STL file // Read an ASCII STL file
void STLImporter::LoadASCIIFile() void STLImporter::LoadASCIIFile()
{ {
aiMesh* pMesh = pScene->mMeshes[0]; std::vector<aiMesh*> meshes;
const char* sz = mBuffer; const char* sz = mBuffer;
SkipSpaces(&sz); const char* bufferEnd = mBuffer + fileSize;
ai_assert(!IsLineEnd(sz)); std::vector<aiVector3D> positionBuffer;
std::vector<aiVector3D> normalBuffer;
sz += 5; // skip the "solid"
SkipSpaces(&sz);
const char* szMe = sz;
while (!::IsSpaceOrNewLine(*sz)) {
sz++;
}
size_t temp;
// setup the name of the node
if ((temp = (size_t)(sz-szMe))) {
if (temp >= MAXLEN) {
throw DeadlyImportError( "STL: Node name too long" );
}
pScene->mRootNode->mName.length = temp;
memcpy(pScene->mRootNode->mName.data,szMe,temp);
pScene->mRootNode->mName.data[temp] = '\0';
}
else pScene->mRootNode->mName.Set("<STL_ASCII>");
// try to guess how many vertices we could have // try to guess how many vertices we could have
// assume we'll need 160 bytes for each face // assume we'll need 160 bytes for each face
pMesh->mNumVertices = ( pMesh->mNumFaces = std::max(1u,fileSize / 160u )) * 3; size_t sizeEstimate = std::max(1u, fileSize / 160u ) * 3;
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; positionBuffer.reserve(sizeEstimate);
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; normalBuffer.reserve(sizeEstimate);
unsigned int curFace = 0, curVertex = 3; while (IsAsciiSTL(sz, bufferEnd - sz))
for ( ;; )
{ {
// go to the next token aiMesh* pMesh = new aiMesh();
if(!SkipSpacesAndLineEnd(&sz)) pMesh->mMaterialIndex = 0;
meshes.push_back(pMesh);
SkipSpaces(&sz);
ai_assert(!IsLineEnd(sz));
sz += 5; // skip the "solid"
SkipSpaces(&sz);
const char* szMe = sz;
while (!::IsSpaceOrNewLine(*sz)) {
sz++;
}
size_t temp;
// setup the name of the node
if ((temp = (size_t)(sz-szMe))) {
if (temp >= MAXLEN) {
throw DeadlyImportError( "STL: Node name too long" );
}
pScene->mRootNode->mName.length = temp;
memcpy(pScene->mRootNode->mName.data,szMe,temp);
pScene->mRootNode->mName.data[temp] = '\0';
}
else pScene->mRootNode->mName.Set("<STL_ASCII>");
unsigned int faceVertexCounter = 0;
for ( ;; )
{ {
// seems we're finished although there was no end marker // go to the next token
DefaultLogger::get()->warn("STL: unexpected EOF. \'endsolid\' keyword was expected"); if(!SkipSpacesAndLineEnd(&sz))
break;
}
// facet normal -0.13 -0.13 -0.98
if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5))) {
if (3 != curVertex) {
DefaultLogger::get()->warn("STL: A new facet begins but the old is not yet complete");
}
if (pMesh->mNumFaces == curFace) {
ai_assert(pMesh->mNumFaces != 0);
// need to resize the arrays, our size estimate was wrong
unsigned int iNeededSize = (unsigned int)(sz-mBuffer) / pMesh->mNumFaces;
if (iNeededSize <= 160)iNeededSize >>= 1; // prevent endless looping
unsigned int add = (unsigned int)((mBuffer+fileSize)-sz) / iNeededSize;
add += add >> 3; // add 12.5% as buffer
iNeededSize = (pMesh->mNumFaces + add)*3;
aiVector3D* pv = new aiVector3D[iNeededSize];
memcpy(pv,pMesh->mVertices,pMesh->mNumVertices*sizeof(aiVector3D));
delete[] pMesh->mVertices;
pMesh->mVertices = pv;
pv = new aiVector3D[iNeededSize];
memcpy(pv,pMesh->mNormals,pMesh->mNumVertices*sizeof(aiVector3D));
delete[] pMesh->mNormals;
pMesh->mNormals = pv;
pMesh->mNumVertices = iNeededSize;
pMesh->mNumFaces += add;
}
aiVector3D* vn = &pMesh->mNormals[curFace++*3];
sz += 6;
curVertex = 0;
SkipSpaces(&sz);
if (strncmp(sz,"normal",6)) {
DefaultLogger::get()->warn("STL: a facet normal vector was expected but not found");
}
else
{ {
sz += 7; // seems we're finished although there was no end marker
SkipSpaces(&sz); DefaultLogger::get()->warn("STL: unexpected EOF. \'endsolid\' keyword was expected");
sz = fast_atoreal_move<float>(sz, (float&)vn->x ); break;
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
*(vn+1) = *vn;
*(vn+2) = *vn;
} }
} // facet normal -0.13 -0.13 -0.98
// vertex 1.50000 1.50000 0.00000 if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5)) && *(sz + 5) != '\0') {
else if (!strncmp(sz,"vertex",6) && ::IsSpaceOrNewLine(*(sz+6)))
{
if (3 == curVertex) {
DefaultLogger::get()->error("STL: a facet with more than 3 vertices has been found");
++sz;
}
else
{
sz += 7;
SkipSpaces(&sz);
aiVector3D* vn = &pMesh->mVertices[(curFace-1)*3 + curVertex++];
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
}
}
else if (!::strncmp(sz,"endsolid",8)) {
// finished!
break;
}
// else skip the whole identifier
else {
do {
++sz;
} while (!::IsSpaceOrNewLine(*sz));
}
}
if (!curFace) { if (faceVertexCounter != 3) {
pMesh->mNumFaces = 0; DefaultLogger::get()->warn("STL: A new facet begins but the old is not yet complete");
throw DeadlyImportError("STL: ASCII file is empty or invalid; no data loaded"); }
faceVertexCounter = 0;
normalBuffer.push_back(aiVector3D());
aiVector3D* vn = &normalBuffer.back();
sz += 6;
SkipSpaces(&sz);
if (strncmp(sz,"normal",6)) {
DefaultLogger::get()->warn("STL: a facet normal vector was expected but not found");
}
else
{
if (sz[6] == '\0') {
throw DeadlyImportError("STL: unexpected EOF while parsing facet");
}
sz += 7;
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
normalBuffer.push_back(*vn);
normalBuffer.push_back(*vn);
}
}
// vertex 1.50000 1.50000 0.00000
else if (!strncmp(sz,"vertex",6) && ::IsSpaceOrNewLine(*(sz+6)))
{
if (faceVertexCounter >= 3) {
DefaultLogger::get()->error("STL: a facet with more than 3 vertices has been found");
++sz;
}
else
{
if (sz[6] == '\0') {
throw DeadlyImportError("STL: unexpected EOF while parsing facet");
}
sz += 7;
SkipSpaces(&sz);
positionBuffer.push_back(aiVector3D());
aiVector3D* vn = &positionBuffer.back();
sz = fast_atoreal_move<float>(sz, (float&)vn->x );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
faceVertexCounter++;
}
}
else if (!::strncmp(sz,"endsolid",8)) {
do {
++sz;
} while (!::IsLineEnd(*sz));
SkipSpacesAndLineEnd(&sz);
// finished!
break;
}
// else skip the whole identifier
else {
do {
++sz;
} while (!::IsSpaceOrNewLine(*sz));
}
}
if (positionBuffer.empty()) {
pMesh->mNumFaces = 0;
throw DeadlyImportError("STL: ASCII file is empty or invalid; no data loaded");
}
if (positionBuffer.size() % 3 != 0) {
pMesh->mNumFaces = 0;
throw DeadlyImportError("STL: Invalid number of vertices");
}
if (normalBuffer.size() != positionBuffer.size()) {
pMesh->mNumFaces = 0;
throw DeadlyImportError("Normal buffer size does not match position buffer size");
}
pMesh->mNumFaces = positionBuffer.size() / 3;
pMesh->mNumVertices = positionBuffer.size();
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
memcpy(pMesh->mVertices, &positionBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D));
positionBuffer.clear();
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
memcpy(pMesh->mNormals, &normalBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D));
normalBuffer.clear();
// now copy faces
addFacesToMesh(pMesh);
}
// now add the loaded meshes
pScene->mNumMeshes = (unsigned int)meshes.size();
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
for (size_t i = 0; i < meshes.size(); i++)
{
pScene->mMeshes[i] = meshes[i];
} }
pMesh->mNumFaces = curFace;
pMesh->mNumVertices = curFace*3;
// we are finished!
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Read a binary STL file // Read a binary STL file
bool STLImporter::LoadBinaryFile() bool STLImporter::LoadBinaryFile()
{ {
// allocate one mesh
pScene->mNumMeshes = 1;
pScene->mMeshes = new aiMesh*[1];
aiMesh* pMesh = pScene->mMeshes[0] = new aiMesh();
pMesh->mMaterialIndex = 0;
// skip the first 80 bytes // skip the first 80 bytes
if (fileSize < 84) { if (fileSize < 84) {
throw DeadlyImportError("STL: file is too small for the header"); throw DeadlyImportError("STL: file is too small for the header");
@ -382,7 +427,6 @@ bool STLImporter::LoadBinaryFile()
const unsigned char* sz = (const unsigned char*)mBuffer + 80; const unsigned char* sz = (const unsigned char*)mBuffer + 80;
// now read the number of facets // now read the number of facets
aiMesh* pMesh = pScene->mMeshes[0];
pScene->mRootNode->mName.Set("<STL_BINARY>"); pScene->mRootNode->mName.Set("<STL_BINARY>");
pMesh->mNumFaces = *((uint32_t*)sz); pMesh->mNumFaces = *((uint32_t*)sz);
@ -402,7 +446,7 @@ bool STLImporter::LoadBinaryFile()
vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
for (unsigned int i = 0; i < pMesh->mNumFaces;++i) { for (unsigned int i = 0; i < pMesh->mNumFaces;++i) {
// NOTE: Blender sometimes writes empty normals ... this is not // NOTE: Blender sometimes writes empty normals ... this is not
// our fault ... the RemoveInvalidData helper step should fix that // our fault ... the RemoveInvalidData helper step should fix that
@ -455,6 +499,10 @@ bool STLImporter::LoadBinaryFile()
*(clr+2) = *clr; *(clr+2) = *clr;
} }
} }
// now copy faces
addFacesToMesh(pMesh);
if (bIsMaterialise && !pMesh->mColors[0]) if (bIsMaterialise && !pMesh->mColors[0])
{ {
// use the color as diffuse material color // use the color as diffuse material color

View File

@ -399,10 +399,14 @@ void CatmullClarkSubdivider::InternSubdivide (
bool haveit = false; bool haveit = false;
for (unsigned int i = 0; i < f.mNumIndices; ++i) { for (unsigned int i = 0; i < f.mNumIndices; ++i) {
if (maptbl[FLATTEN_VERTEX_IDX(n,f.mIndices[i])]==(unsigned int)t) { if (maptbl[FLATTEN_VERTEX_IDX(n,f.mIndices[i])]==(unsigned int)t) {
haveit = true; break; haveit = true;
break;
} }
} }
ai_assert(haveit); ai_assert(haveit);
if (!haveit) {
DefaultLogger::get()->debug("Catmull-Clark Subdivider: Index not used");
}
break; break;
} }
} }

View File

@ -1,14 +1,14 @@
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file. // Microsoft Visual C++ generated include file.
// Used by assimp.rc // Used by assimp.rc
// Nächste Standardwerte für neue Objekte // Nächste Standardwerte für neue Objekte
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif

View File

@ -1,29 +1,29 @@
The Clipper code library, the "Software" (that includes Delphi, C++ & C# The Clipper code library, the "Software" (that includes Delphi, C++ & C#
source code, accompanying samples and documentation), has been released source code, accompanying samples and documentation), has been released
under the following license, terms and conditions: under the following license, terms and conditions:
Boost Software License - Version 1.0 - August 17th, 2003 Boost Software License - Version 1.0 - August 17th, 2003
http://www.boost.org/LICENSE_1_0.txt http://www.boost.org/LICENSE_1_0.txt
Permission is hereby granted, free of charge, to any person or organization Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute, this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following: do so, all subject to the following:
The copyright notices in the Software and this entire statement, including The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer, the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by works are solely in the form of machine-executable object code generated by
a source language processor. a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@ -1,306 +1,306 @@
/******************************************************************************* /*******************************************************************************
* * * *
* Author : Angus Johnson * * Author : Angus Johnson *
* Version : 4.8.8 * * Version : 4.8.8 *
* Date : 30 August 2012 * * Date : 30 August 2012 *
* Website : http://www.angusj.com * * Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2012 * * Copyright : Angus Johnson 2010-2012 *
* * * *
* License: * * License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. * * Use, modification & distribution is subject to Boost Software License Ver 1. *
* http://www.boost.org/LICENSE_1_0.txt * * http://www.boost.org/LICENSE_1_0.txt *
* * * *
* Attributions: * * Attributions: *
* The code in this library is an extension of Bala Vatti's clipping algorithm: * * The code in this library is an extension of Bala Vatti's clipping algorithm: *
* "A generic solution to polygon clipping" * * "A generic solution to polygon clipping" *
* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. * * Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
* http://portal.acm.org/citation.cfm?id=129906 * * http://portal.acm.org/citation.cfm?id=129906 *
* * * *
* Computer graphics and geometric modeling: implementation and algorithms * * Computer graphics and geometric modeling: implementation and algorithms *
* By Max K. Agoston * * By Max K. Agoston *
* Springer; 1 edition (January 4, 2005) * * Springer; 1 edition (January 4, 2005) *
* http://books.google.com/books?q=vatti+clipping+agoston * * http://books.google.com/books?q=vatti+clipping+agoston *
* * * *
* See also: * * See also: *
* "Polygon Offsetting by Computing Winding Numbers" * * "Polygon Offsetting by Computing Winding Numbers" *
* Paper no. DETC2005-85513 pp. 565-575 * * Paper no. DETC2005-85513 pp. 565-575 *
* ASME 2005 International Design Engineering Technical Conferences * * ASME 2005 International Design Engineering Technical Conferences *
* and Computers and Information in Engineering Conference (IDETC/CIE2005) * * and Computers and Information in Engineering Conference (IDETC/CIE2005) *
* September 24–28, 2005 , Long Beach, California, USA * * September 24–28, 2005 , Long Beach, California, USA *
* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * * http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef clipper_hpp #ifndef clipper_hpp
#define clipper_hpp #define clipper_hpp
#include <vector> #include <vector>
#include <stdexcept> #include <stdexcept>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <ostream> #include <ostream>
namespace ClipperLib { namespace ClipperLib {
enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
enum PolyType { ptSubject, ptClip }; enum PolyType { ptSubject, ptClip };
//By far the most widely used winding rules for polygon filling are //By far the most widely used winding rules for polygon filling are
//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32) //EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32)
//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL) //Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL)
//see http://glprogramming.com/red/chapter11.html //see http://glprogramming.com/red/chapter11.html
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
typedef signed long long long64; typedef signed long long long64;
typedef unsigned long long ulong64; typedef unsigned long long ulong64;
struct IntPoint { struct IntPoint {
public: public:
long64 X; long64 X;
long64 Y; long64 Y;
IntPoint(long64 x = 0, long64 y = 0): X(x), Y(y) {}; IntPoint(long64 x = 0, long64 y = 0): X(x), Y(y) {};
friend std::ostream& operator <<(std::ostream &s, IntPoint &p); friend std::ostream& operator <<(std::ostream &s, IntPoint &p);
}; };
typedef std::vector< IntPoint > Polygon; typedef std::vector< IntPoint > Polygon;
typedef std::vector< Polygon > Polygons; typedef std::vector< Polygon > Polygons;
std::ostream& operator <<(std::ostream &s, Polygon &p); std::ostream& operator <<(std::ostream &s, Polygon &p);
std::ostream& operator <<(std::ostream &s, Polygons &p); std::ostream& operator <<(std::ostream &s, Polygons &p);
struct ExPolygon { struct ExPolygon {
Polygon outer; Polygon outer;
Polygons holes; Polygons holes;
}; };
typedef std::vector< ExPolygon > ExPolygons; typedef std::vector< ExPolygon > ExPolygons;
enum JoinType { jtSquare, jtRound, jtMiter }; enum JoinType { jtSquare, jtRound, jtMiter };
bool Orientation(const Polygon &poly); bool Orientation(const Polygon &poly);
double Area(const Polygon &poly); double Area(const Polygon &poly);
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys,
double delta, JoinType jointype = jtSquare, double MiterLimit = 2); double delta, JoinType jointype = jtSquare, double MiterLimit = 2);
void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd);
void ReversePolygon(Polygon& p); void ReversePolygon(Polygon& p);
void ReversePolygons(Polygons& p); void ReversePolygons(Polygons& p);
//used internally ... //used internally ...
enum EdgeSide { esNeither = 0, esLeft = 1, esRight = 2, esBoth = 3 }; enum EdgeSide { esNeither = 0, esLeft = 1, esRight = 2, esBoth = 3 };
enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 }; enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 };
struct TEdge { struct TEdge {
long64 xbot; long64 xbot;
long64 ybot; long64 ybot;
long64 xcurr; long64 xcurr;
long64 ycurr; long64 ycurr;
long64 xtop; long64 xtop;
long64 ytop; long64 ytop;
double dx; double dx;
long64 tmpX; long64 tmpX;
PolyType polyType; PolyType polyType;
EdgeSide side; EdgeSide side;
int windDelta; //1 or -1 depending on winding direction int windDelta; //1 or -1 depending on winding direction
int windCnt; int windCnt;
int windCnt2; //winding count of the opposite polytype int windCnt2; //winding count of the opposite polytype
int outIdx; int outIdx;
TEdge *next; TEdge *next;
TEdge *prev; TEdge *prev;
TEdge *nextInLML; TEdge *nextInLML;
TEdge *nextInAEL; TEdge *nextInAEL;
TEdge *prevInAEL; TEdge *prevInAEL;
TEdge *nextInSEL; TEdge *nextInSEL;
TEdge *prevInSEL; TEdge *prevInSEL;
}; };
struct IntersectNode { struct IntersectNode {
TEdge *edge1; TEdge *edge1;
TEdge *edge2; TEdge *edge2;
IntPoint pt; IntPoint pt;
IntersectNode *next; IntersectNode *next;
}; };
struct LocalMinima { struct LocalMinima {
long64 Y; long64 Y;
TEdge *leftBound; TEdge *leftBound;
TEdge *rightBound; TEdge *rightBound;
LocalMinima *next; LocalMinima *next;
}; };
struct Scanbeam { struct Scanbeam {
long64 Y; long64 Y;
Scanbeam *next; Scanbeam *next;
}; };
struct OutPt; //forward declaration struct OutPt; //forward declaration
struct OutRec { struct OutRec {
int idx; int idx;
bool isHole; bool isHole;
OutRec *FirstLeft; OutRec *FirstLeft;
OutRec *AppendLink; OutRec *AppendLink;
OutPt *pts; OutPt *pts;
OutPt *bottomPt; OutPt *bottomPt;
OutPt *bottomFlag; OutPt *bottomFlag;
EdgeSide sides; EdgeSide sides;
}; };
struct OutPt { struct OutPt {
int idx; int idx;
IntPoint pt; IntPoint pt;
OutPt *next; OutPt *next;
OutPt *prev; OutPt *prev;
}; };
struct JoinRec { struct JoinRec {
IntPoint pt1a; IntPoint pt1a;
IntPoint pt1b; IntPoint pt1b;
int poly1Idx; int poly1Idx;
IntPoint pt2a; IntPoint pt2a;
IntPoint pt2b; IntPoint pt2b;
int poly2Idx; int poly2Idx;
}; };
struct HorzJoinRec { struct HorzJoinRec {
TEdge *edge; TEdge *edge;
int savedIdx; int savedIdx;
}; };
struct IntRect { long64 left; long64 top; long64 right; long64 bottom; }; struct IntRect { long64 left; long64 top; long64 right; long64 bottom; };
typedef std::vector < OutRec* > PolyOutList; typedef std::vector < OutRec* > PolyOutList;
typedef std::vector < TEdge* > EdgeList; typedef std::vector < TEdge* > EdgeList;
typedef std::vector < JoinRec* > JoinList; typedef std::vector < JoinRec* > JoinList;
typedef std::vector < HorzJoinRec* > HorzJoinList; typedef std::vector < HorzJoinRec* > HorzJoinList;
//ClipperBase is the ancestor to the Clipper class. It should not be //ClipperBase is the ancestor to the Clipper class. It should not be
//instantiated directly. This class simply abstracts the conversion of sets of //instantiated directly. This class simply abstracts the conversion of sets of
//polygon coordinates into edge objects that are stored in a LocalMinima list. //polygon coordinates into edge objects that are stored in a LocalMinima list.
class ClipperBase class ClipperBase
{ {
public: public:
ClipperBase(); ClipperBase();
virtual ~ClipperBase(); virtual ~ClipperBase();
bool AddPolygon(const Polygon &pg, PolyType polyType); bool AddPolygon(const Polygon &pg, PolyType polyType);
bool AddPolygons( const Polygons &ppg, PolyType polyType); bool AddPolygons( const Polygons &ppg, PolyType polyType);
virtual void Clear(); virtual void Clear();
IntRect GetBounds(); IntRect GetBounds();
protected: protected:
void DisposeLocalMinimaList(); void DisposeLocalMinimaList();
TEdge* AddBoundsToLML(TEdge *e); TEdge* AddBoundsToLML(TEdge *e);
void PopLocalMinima(); void PopLocalMinima();
virtual void Reset(); virtual void Reset();
void InsertLocalMinima(LocalMinima *newLm); void InsertLocalMinima(LocalMinima *newLm);
LocalMinima *m_CurrentLM; LocalMinima *m_CurrentLM;
LocalMinima *m_MinimaList; LocalMinima *m_MinimaList;
bool m_UseFullRange; bool m_UseFullRange;
EdgeList m_edges; EdgeList m_edges;
}; };
class Clipper : public virtual ClipperBase class Clipper : public virtual ClipperBase
{ {
public: public:
Clipper(); Clipper();
~Clipper(); ~Clipper();
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
Polygons &solution, Polygons &solution,
PolyFillType subjFillType = pftEvenOdd, PolyFillType subjFillType = pftEvenOdd,
PolyFillType clipFillType = pftEvenOdd); PolyFillType clipFillType = pftEvenOdd);
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
ExPolygons &solution, ExPolygons &solution,
PolyFillType subjFillType = pftEvenOdd, PolyFillType subjFillType = pftEvenOdd,
PolyFillType clipFillType = pftEvenOdd); PolyFillType clipFillType = pftEvenOdd);
void Clear(); void Clear();
bool ReverseSolution() {return m_ReverseOutput;}; bool ReverseSolution() {return m_ReverseOutput;};
void ReverseSolution(bool value) {m_ReverseOutput = value;}; void ReverseSolution(bool value) {m_ReverseOutput = value;};
protected: protected:
void Reset(); void Reset();
virtual bool ExecuteInternal(bool fixHoleLinkages); virtual bool ExecuteInternal(bool fixHoleLinkages);
private: private:
PolyOutList m_PolyOuts; PolyOutList m_PolyOuts;
JoinList m_Joins; JoinList m_Joins;
HorzJoinList m_HorizJoins; HorzJoinList m_HorizJoins;
ClipType m_ClipType; ClipType m_ClipType;
Scanbeam *m_Scanbeam; Scanbeam *m_Scanbeam;
TEdge *m_ActiveEdges; TEdge *m_ActiveEdges;
TEdge *m_SortedEdges; TEdge *m_SortedEdges;
IntersectNode *m_IntersectNodes; IntersectNode *m_IntersectNodes;
bool m_ExecuteLocked; bool m_ExecuteLocked;
PolyFillType m_ClipFillType; PolyFillType m_ClipFillType;
PolyFillType m_SubjFillType; PolyFillType m_SubjFillType;
bool m_ReverseOutput; bool m_ReverseOutput;
void DisposeScanbeamList(); void DisposeScanbeamList();
void SetWindingCount(TEdge& edge); void SetWindingCount(TEdge& edge);
bool IsEvenOddFillType(const TEdge& edge) const; bool IsEvenOddFillType(const TEdge& edge) const;
bool IsEvenOddAltFillType(const TEdge& edge) const; bool IsEvenOddAltFillType(const TEdge& edge) const;
void InsertScanbeam(const long64 Y); void InsertScanbeam(const long64 Y);
long64 PopScanbeam(); long64 PopScanbeam();
void InsertLocalMinimaIntoAEL(const long64 botY); void InsertLocalMinimaIntoAEL(const long64 botY);
void InsertEdgeIntoAEL(TEdge *edge); void InsertEdgeIntoAEL(TEdge *edge);
void AddEdgeToSEL(TEdge *edge); void AddEdgeToSEL(TEdge *edge);
void CopyAELToSEL(); void CopyAELToSEL();
void DeleteFromSEL(TEdge *e); void DeleteFromSEL(TEdge *e);
void DeleteFromAEL(TEdge *e); void DeleteFromAEL(TEdge *e);
void UpdateEdgeIntoAEL(TEdge *&e); void UpdateEdgeIntoAEL(TEdge *&e);
void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2); void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
bool IsContributing(const TEdge& edge) const; bool IsContributing(const TEdge& edge) const;
bool IsTopHorz(const long64 XPos); bool IsTopHorz(const long64 XPos);
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2); void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
void DoMaxima(TEdge *e, long64 topY); void DoMaxima(TEdge *e, long64 topY);
void ProcessHorizontals(); void ProcessHorizontals();
void ProcessHorizontal(TEdge *horzEdge); void ProcessHorizontal(TEdge *horzEdge);
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
void AppendPolygon(TEdge *e1, TEdge *e2); void AppendPolygon(TEdge *e1, TEdge *e2);
void DoEdge1(TEdge *edge1, TEdge *edge2, const IntPoint &pt); void DoEdge1(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
void DoEdge2(TEdge *edge1, TEdge *edge2, const IntPoint &pt); void DoEdge2(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
void DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt); void DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
void IntersectEdges(TEdge *e1, TEdge *e2, void IntersectEdges(TEdge *e1, TEdge *e2,
const IntPoint &pt, IntersectProtects protects); const IntPoint &pt, IntersectProtects protects);
OutRec* CreateOutRec(); OutRec* CreateOutRec();
void AddOutPt(TEdge *e, const IntPoint &pt); void AddOutPt(TEdge *e, const IntPoint &pt);
void DisposeBottomPt(OutRec &outRec); void DisposeBottomPt(OutRec &outRec);
void DisposeAllPolyPts(); void DisposeAllPolyPts();
void DisposeOutRec(PolyOutList::size_type index); void DisposeOutRec(PolyOutList::size_type index);
bool ProcessIntersections(const long64 botY, const long64 topY); bool ProcessIntersections(const long64 botY, const long64 topY);
void AddIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt); void AddIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt);
void BuildIntersectList(const long64 botY, const long64 topY); void BuildIntersectList(const long64 botY, const long64 topY);
void ProcessIntersectList(); void ProcessIntersectList();
void ProcessEdgesAtTopOfScanbeam(const long64 topY); void ProcessEdgesAtTopOfScanbeam(const long64 topY);
void BuildResult(Polygons& polys); void BuildResult(Polygons& polys);
void BuildResultEx(ExPolygons& polys); void BuildResultEx(ExPolygons& polys);
void SetHoleState(TEdge *e, OutRec *OutRec); void SetHoleState(TEdge *e, OutRec *OutRec);
void DisposeIntersectNodes(); void DisposeIntersectNodes();
bool FixupIntersections(); bool FixupIntersections();
void FixupOutPolygon(OutRec &outRec); void FixupOutPolygon(OutRec &outRec);
bool IsHole(TEdge *e); bool IsHole(TEdge *e);
void FixHoleLinkage(OutRec *outRec); void FixHoleLinkage(OutRec *outRec);
void CheckHoleLinkages1(OutRec *outRec1, OutRec *outRec2); void CheckHoleLinkages1(OutRec *outRec1, OutRec *outRec2);
void CheckHoleLinkages2(OutRec *outRec1, OutRec *outRec2); void CheckHoleLinkages2(OutRec *outRec1, OutRec *outRec2);
void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1); void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1);
void ClearJoins(); void ClearJoins();
void AddHorzJoin(TEdge *e, int idx); void AddHorzJoin(TEdge *e, int idx);
void ClearHorzJoins(); void ClearHorzJoins();
void JoinCommonEdges(bool fixHoleLinkages); void JoinCommonEdges(bool fixHoleLinkages);
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
class clipperException : public std::exception class clipperException : public std::exception
{ {
public: public:
clipperException(const char* description): m_descr(description) {} clipperException(const char* description): m_descr(description) {}
virtual ~clipperException() throw() {} virtual ~clipperException() throw() {}
virtual const char* what() const throw() {return m_descr.c_str();} virtual const char* what() const throw() {return m_descr.c_str();}
private: private:
std::string m_descr; std::string m_descr;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
} //ClipperLib namespace } //ClipperLib namespace
#endif //clipper_hpp #endif //clipper_hpp

File diff suppressed because it is too large Load Diff

View File

@ -1,73 +1,73 @@
// Copyright (C) 2002-2005 Nikolaus Gebhardt // Copyright (C) 2002-2005 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_HEAPSORT_H_INCLUDED__ #ifndef __IRR_HEAPSORT_H_INCLUDED__
#define __IRR_HEAPSORT_H_INCLUDED__ #define __IRR_HEAPSORT_H_INCLUDED__
#include "irrTypes.h" #include "irrTypes.h"
namespace irr namespace irr
{ {
namespace core namespace core
{ {
//! Sinks an element into the heap. //! Sinks an element into the heap.
template<class T> template<class T>
inline void heapsink(T*array, s32 element, s32 max) inline void heapsink(T*array, s32 element, s32 max)
{ {
while ((element<<1) < max) // there is a left child while ((element<<1) < max) // there is a left child
{ {
s32 j = (element<<1); s32 j = (element<<1);
if (j+1 < max && array[j] < array[j+1]) if (j+1 < max && array[j] < array[j+1])
j = j+1; // take right child j = j+1; // take right child
if (array[element] < array[j]) if (array[element] < array[j])
{ {
T t = array[j]; // swap elements T t = array[j]; // swap elements
array[j] = array[element]; array[j] = array[element];
array[element] = t; array[element] = t;
element = j; element = j;
} }
else else
return; return;
} }
} }
//! Sorts an array with size 'size' using heapsort. //! Sorts an array with size 'size' using heapsort.
template<class T> template<class T>
inline void heapsort(T* array_, s32 size) inline void heapsort(T* array_, s32 size)
{ {
// for heapsink we pretent this is not c++, where // for heapsink we pretent this is not c++, where
// arrays start with index 0. So we decrease the array pointer, // arrays start with index 0. So we decrease the array pointer,
// the maximum always +2 and the element always +1 // the maximum always +2 and the element always +1
T* virtualArray = array_ - 1; T* virtualArray = array_ - 1;
s32 virtualSize = size + 2; s32 virtualSize = size + 2;
s32 i; s32 i;
// build heap // build heap
for (i=((size-1)/2); i>=0; --i) for (i=((size-1)/2); i>=0; --i)
heapsink(virtualArray, i+1, virtualSize-1); heapsink(virtualArray, i+1, virtualSize-1);
// sort array // sort array
for (i=size-1; i>=0; --i) for (i=size-1; i>=0; --i)
{ {
T t = array_[0]; T t = array_[0];
array_[0] = array_[i]; array_[0] = array_[i];
array_[i] = t; array_[i] = t;
heapsink(virtualArray, 1, i + 1); heapsink(virtualArray, 1, i + 1);
} }
} }
} // end namespace core } // end namespace core
} // end namespace irr } // end namespace irr
#endif #endif

View File

@ -1,444 +1,444 @@
// Copyright (C) 2002-2005 Nikolaus Gebhardt // Copyright (C) 2002-2005 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine" and the "irrXML" project. // This file is part of the "Irrlicht Engine" and the "irrXML" project.
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h // For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
#ifndef __IRR_ARRAY_H_INCLUDED__ #ifndef __IRR_ARRAY_H_INCLUDED__
#define __IRR_ARRAY_H_INCLUDED__ #define __IRR_ARRAY_H_INCLUDED__
#include "irrTypes.h" #include "irrTypes.h"
#include "heapsort.h" #include "heapsort.h"
namespace irr namespace irr
{ {
namespace core namespace core
{ {
//! Self reallocating template array (like stl vector) with additional features. //! Self reallocating template array (like stl vector) with additional features.
/** Some features are: Heap sorting, binary search methods, easier debugging. /** Some features are: Heap sorting, binary search methods, easier debugging.
*/ */
template <class T> template <class T>
class array class array
{ {
public: public:
array() array()
: data(0), allocated(0), used(0), : data(0), allocated(0), used(0),
free_when_destroyed(true), is_sorted(true) free_when_destroyed(true), is_sorted(true)
{ {
} }
//! Constructs a array and allocates an initial chunk of memory. //! Constructs a array and allocates an initial chunk of memory.
//! \param start_count: Amount of elements to allocate. //! \param start_count: Amount of elements to allocate.
array(u32 start_count) array(u32 start_count)
: data(0), allocated(0), used(0), : data(0), allocated(0), used(0),
free_when_destroyed(true), is_sorted(true) free_when_destroyed(true), is_sorted(true)
{ {
reallocate(start_count); reallocate(start_count);
} }
//! Copy constructor //! Copy constructor
array(const array<T>& other) array(const array<T>& other)
: data(0) : data(0)
{ {
*this = other; *this = other;
} }
//! Destructor. Frees allocated memory, if set_free_when_destroyed //! Destructor. Frees allocated memory, if set_free_when_destroyed
//! was not set to false by the user before. //! was not set to false by the user before.
~array() ~array()
{ {
if (free_when_destroyed) if (free_when_destroyed)
delete [] data; delete [] data;
} }
//! Reallocates the array, make it bigger or smaller. //! Reallocates the array, make it bigger or smaller.
//! \param new_size: New size of array. //! \param new_size: New size of array.
void reallocate(u32 new_size) void reallocate(u32 new_size)
{ {
T* old_data = data; T* old_data = data;
data = new T[new_size]; data = new T[new_size];
allocated = new_size; allocated = new_size;
s32 end = used < new_size ? used : new_size; s32 end = used < new_size ? used : new_size;
for (s32 i=0; i<end; ++i) for (s32 i=0; i<end; ++i)
data[i] = old_data[i]; data[i] = old_data[i];
if (allocated < used) if (allocated < used)
used = allocated; used = allocated;
delete [] old_data; delete [] old_data;
} }
//! Adds an element at back of array. If the array is to small to //! Adds an element at back of array. If the array is to small to
//! add this new element, the array is made bigger. //! add this new element, the array is made bigger.
//! \param element: Element to add at the back of the array. //! \param element: Element to add at the back of the array.
void push_back(const T& element) void push_back(const T& element)
{ {
if (used + 1 > allocated) if (used + 1 > allocated)
{ {
// reallocate(used * 2 +1); // reallocate(used * 2 +1);
// this doesn't work if the element is in the same array. So // this doesn't work if the element is in the same array. So
// we'll copy the element first to be sure we'll get no data // we'll copy the element first to be sure we'll get no data
// corruption // corruption
T e; T e;
e = element; // copy element e = element; // copy element
reallocate(used * 2 +1); // increase data block reallocate(used * 2 +1); // increase data block
data[used++] = e; // push_back data[used++] = e; // push_back
is_sorted = false; is_sorted = false;
return; return;
} }
data[used++] = element; data[used++] = element;
is_sorted = false; is_sorted = false;
} }
//! Adds an element at the front of the array. If the array is to small to //! Adds an element at the front of the array. If the array is to small to
//! add this new element, the array is made bigger. Please note that this //! add this new element, the array is made bigger. Please note that this
//! is slow, because the whole array needs to be copied for this. //! is slow, because the whole array needs to be copied for this.
//! \param element: Element to add at the back of the array. //! \param element: Element to add at the back of the array.
void push_front(const T& element) void push_front(const T& element)
{ {
if (used + 1 > allocated) if (used + 1 > allocated)
reallocate(used * 2 +1); reallocate(used * 2 +1);
for (int i=(int)used; i>0; --i) for (int i=(int)used; i>0; --i)
data[i] = data[i-1]; data[i] = data[i-1];
data[0] = element; data[0] = element;
is_sorted = false; is_sorted = false;
++used; ++used;
} }
//! Insert item into array at specified position. Please use this //! Insert item into array at specified position. Please use this
//! only if you know what you are doing (possible performance loss). //! only if you know what you are doing (possible performance loss).
//! The preferred method of adding elements should be push_back(). //! The preferred method of adding elements should be push_back().
//! \param element: Element to be inserted //! \param element: Element to be inserted
//! \param index: Where position to insert the new element. //! \param index: Where position to insert the new element.
void insert(const T& element, u32 index=0) void insert(const T& element, u32 index=0)
{ {
_IRR_DEBUG_BREAK_IF(index>used) // access violation _IRR_DEBUG_BREAK_IF(index>used) // access violation
if (used + 1 > allocated) if (used + 1 > allocated)
reallocate(used * 2 +1); reallocate(used * 2 +1);
for (u32 i=used++; i>index; i--) for (u32 i=used++; i>index; i--)
data[i] = data[i-1]; data[i] = data[i-1];
data[index] = element; data[index] = element;
is_sorted = false; is_sorted = false;
} }
//! Clears the array and deletes all allocated memory. //! Clears the array and deletes all allocated memory.
void clear() void clear()
{ {
delete [] data; delete [] data;
data = 0; data = 0;
used = 0; used = 0;
allocated = 0; allocated = 0;
is_sorted = true; is_sorted = true;
} }
//! Sets pointer to new array, using this as new workspace. //! Sets pointer to new array, using this as new workspace.
//! \param newPointer: Pointer to new array of elements. //! \param newPointer: Pointer to new array of elements.
//! \param size: Size of the new array. //! \param size: Size of the new array.
void set_pointer(T* newPointer, u32 size) void set_pointer(T* newPointer, u32 size)
{ {
delete [] data; delete [] data;
data = newPointer; data = newPointer;
allocated = size; allocated = size;
used = size; used = size;
is_sorted = false; is_sorted = false;
} }
//! Sets if the array should delete the memory it used. //! Sets if the array should delete the memory it used.
//! \param f: If true, the array frees the allocated memory in its //! \param f: If true, the array frees the allocated memory in its
//! destructor, otherwise not. The default is true. //! destructor, otherwise not. The default is true.
void set_free_when_destroyed(bool f) void set_free_when_destroyed(bool f)
{ {
free_when_destroyed = f; free_when_destroyed = f;
} }
//! Sets the size of the array. //! Sets the size of the array.
//! \param usedNow: Amount of elements now used. //! \param usedNow: Amount of elements now used.
void set_used(u32 usedNow) void set_used(u32 usedNow)
{ {
if (allocated < usedNow) if (allocated < usedNow)
reallocate(usedNow); reallocate(usedNow);
used = usedNow; used = usedNow;
} }
//! Assignement operator //! Assignement operator
void operator=(const array<T>& other) void operator=(const array<T>& other)
{ {
if (data) if (data)
delete [] data; delete [] data;
//if (allocated < other.allocated) //if (allocated < other.allocated)
if (other.allocated == 0) if (other.allocated == 0)
data = 0; data = 0;
else else
data = new T[other.allocated]; data = new T[other.allocated];
used = other.used; used = other.used;
free_when_destroyed = other.free_when_destroyed; free_when_destroyed = other.free_when_destroyed;
is_sorted = other.is_sorted; is_sorted = other.is_sorted;
allocated = other.allocated; allocated = other.allocated;
for (u32 i=0; i<other.used; ++i) for (u32 i=0; i<other.used; ++i)
data[i] = other.data[i]; data[i] = other.data[i];
} }
//! Direct access operator //! Direct access operator
T& operator [](u32 index) T& operator [](u32 index)
{ {
_IRR_DEBUG_BREAK_IF(index>=used) // access violation _IRR_DEBUG_BREAK_IF(index>=used) // access violation
return data[index]; return data[index];
} }
//! Direct access operator //! Direct access operator
const T& operator [](u32 index) const const T& operator [](u32 index) const
{ {
_IRR_DEBUG_BREAK_IF(index>=used) // access violation _IRR_DEBUG_BREAK_IF(index>=used) // access violation
return data[index]; return data[index];
} }
//! Gets last frame //! Gets last frame
const T& getLast() const const T& getLast() const
{ {
_IRR_DEBUG_BREAK_IF(!used) // access violation _IRR_DEBUG_BREAK_IF(!used) // access violation
return data[used-1]; return data[used-1];
} }
//! Gets last frame //! Gets last frame
T& getLast() T& getLast()
{ {
_IRR_DEBUG_BREAK_IF(!used) // access violation _IRR_DEBUG_BREAK_IF(!used) // access violation
return data[used-1]; return data[used-1];
} }
//! Returns a pointer to the array. //! Returns a pointer to the array.
//! \return Pointer to the array. //! \return Pointer to the array.
T* pointer() T* pointer()
{ {
return data; return data;
} }
//! Returns a const pointer to the array. //! Returns a const pointer to the array.
//! \return Pointer to the array. //! \return Pointer to the array.
const T* const_pointer() const const T* const_pointer() const
{ {
return data; return data;
} }
//! Returns size of used array. //! Returns size of used array.
//! \return Size of elements in the array. //! \return Size of elements in the array.
u32 size() const u32 size() const
{ {
return used; return used;
} }
//! Returns amount memory allocated. //! Returns amount memory allocated.
//! \return Returns amount of memory allocated. The amount of bytes //! \return Returns amount of memory allocated. The amount of bytes
//! allocated would be allocated_size() * sizeof(ElementsUsed); //! allocated would be allocated_size() * sizeof(ElementsUsed);
u32 allocated_size() const u32 allocated_size() const
{ {
return allocated; return allocated;
} }
//! Returns true if array is empty //! Returns true if array is empty
//! \return True if the array is empty, false if not. //! \return True if the array is empty, false if not.
bool empty() const bool empty() const
{ {
return used == 0; return used == 0;
} }
//! Sorts the array using heapsort. There is no additional memory waste and //! Sorts the array using heapsort. There is no additional memory waste and
//! the algorithm performs (O) n log n in worst case. //! the algorithm performs (O) n log n in worst case.
void sort() void sort()
{ {
if (is_sorted || used<2) if (is_sorted || used<2)
return; return;
heapsort(data, used); heapsort(data, used);
is_sorted = true; is_sorted = true;
} }
//! Performs a binary search for an element, returns -1 if not found. //! Performs a binary search for an element, returns -1 if not found.
//! The array will be sorted before the binary search if it is not //! The array will be sorted before the binary search if it is not
//! already sorted. //! already sorted.
//! \param element: Element to search for. //! \param element: Element to search for.
//! \return Returns position of the searched element if it was found, //! \return Returns position of the searched element if it was found,
//! otherwise -1 is returned. //! otherwise -1 is returned.
s32 binary_search(const T& element) s32 binary_search(const T& element)
{ {
return binary_search(element, 0, used-1); return binary_search(element, 0, used-1);
} }
//! Performs a binary search for an element, returns -1 if not found. //! Performs a binary search for an element, returns -1 if not found.
//! The array will be sorted before the binary search if it is not //! The array will be sorted before the binary search if it is not
//! already sorted. //! already sorted.
//! \param element: Element to search for. //! \param element: Element to search for.
//! \param left: First left index //! \param left: First left index
//! \param right: Last right index. //! \param right: Last right index.
//! \return Returns position of the searched element if it was found, //! \return Returns position of the searched element if it was found,
//! otherwise -1 is returned. //! otherwise -1 is returned.
s32 binary_search(const T& element, s32 left, s32 right) s32 binary_search(const T& element, s32 left, s32 right)
{ {
if (!used) if (!used)
return -1; return -1;
sort(); sort();
s32 m; s32 m;
do do
{ {
m = (left+right)>>1; m = (left+right)>>1;
if (element < data[m]) if (element < data[m])
right = m - 1; right = m - 1;
else else
left = m + 1; left = m + 1;
} while((element < data[m] || data[m] < element) && left<=right); } while((element < data[m] || data[m] < element) && left<=right);
// this last line equals to: // this last line equals to:
// " while((element != array[m]) && left<=right);" // " while((element != array[m]) && left<=right);"
// but we only want to use the '<' operator. // but we only want to use the '<' operator.
// the same in next line, it is "(element == array[m])" // the same in next line, it is "(element == array[m])"
if (!(element < data[m]) && !(data[m] < element)) if (!(element < data[m]) && !(data[m] < element))
return m; return m;
return -1; return -1;
} }
//! Finds an element in linear time, which is very slow. Use //! Finds an element in linear time, which is very slow. Use
//! binary_search for faster finding. Only works if =operator is implemented. //! binary_search for faster finding. Only works if =operator is implemented.
//! \param element: Element to search for. //! \param element: Element to search for.
//! \return Returns position of the searched element if it was found, //! \return Returns position of the searched element if it was found,
//! otherwise -1 is returned. //! otherwise -1 is returned.
s32 linear_search(T& element) s32 linear_search(T& element)
{ {
for (u32 i=0; i<used; ++i) for (u32 i=0; i<used; ++i)
if (!(element < data[i]) && !(data[i] < element)) if (!(element < data[i]) && !(data[i] < element))
return (s32)i; return (s32)i;
return -1; return -1;
} }
//! Finds an element in linear time, which is very slow. Use //! Finds an element in linear time, which is very slow. Use
//! binary_search for faster finding. Only works if =operator is implemented. //! binary_search for faster finding. Only works if =operator is implemented.
//! \param element: Element to search for. //! \param element: Element to search for.
//! \return Returns position of the searched element if it was found, //! \return Returns position of the searched element if it was found,
//! otherwise -1 is returned. //! otherwise -1 is returned.
s32 linear_reverse_search(T& element) s32 linear_reverse_search(T& element)
{ {
for (s32 i=used-1; i>=0; --i) for (s32 i=used-1; i>=0; --i)
if (data[i] == element) if (data[i] == element)
return (s32)i; return (s32)i;
return -1; return -1;
} }
//! Erases an element from the array. May be slow, because all elements //! Erases an element from the array. May be slow, because all elements
//! following after the erased element have to be copied. //! following after the erased element have to be copied.
//! \param index: Index of element to be erased. //! \param index: Index of element to be erased.
void erase(u32 index) void erase(u32 index)
{ {
_IRR_DEBUG_BREAK_IF(index>=used || index<0) // access violation _IRR_DEBUG_BREAK_IF(index>=used || index<0) // access violation
for (u32 i=index+1; i<used; ++i) for (u32 i=index+1; i<used; ++i)
data[i-1] = data[i]; data[i-1] = data[i];
--used; --used;
} }
//! Erases some elements from the array. may be slow, because all elements //! Erases some elements from the array. may be slow, because all elements
//! following after the erased element have to be copied. //! following after the erased element have to be copied.
//! \param index: Index of the first element to be erased. //! \param index: Index of the first element to be erased.
//! \param count: Amount of elements to be erased. //! \param count: Amount of elements to be erased.
void erase(u32 index, s32 count) void erase(u32 index, s32 count)
{ {
_IRR_DEBUG_BREAK_IF(index>=used || index<0 || count<1 || index+count>used) // access violation _IRR_DEBUG_BREAK_IF(index>=used || index<0 || count<1 || index+count>used) // access violation
for (u32 i=index+count; i<used; ++i) for (u32 i=index+count; i<used; ++i)
data[i-count] = data[i]; data[i-count] = data[i];
used-= count; used-= count;
} }
//! Sets if the array is sorted //! Sets if the array is sorted
void set_sorted(bool _is_sorted) void set_sorted(bool _is_sorted)
{ {
is_sorted = _is_sorted; is_sorted = _is_sorted;
} }
private: private:
T* data; T* data;
u32 allocated; u32 allocated;
u32 used; u32 used;
bool free_when_destroyed; bool free_when_destroyed;
bool is_sorted; bool is_sorted;
}; };
} // end namespace core } // end namespace core
} // end namespace irr } // end namespace irr
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,108 +1,108 @@
// Copyright (C) 2002-2005 Nikolaus Gebhardt // Copyright (C) 2002-2005 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_TYPES_H_INCLUDED__ #ifndef __IRR_TYPES_H_INCLUDED__
#define __IRR_TYPES_H_INCLUDED__ #define __IRR_TYPES_H_INCLUDED__
namespace irr namespace irr
{ {
//! 8 bit unsigned variable. //! 8 bit unsigned variable.
/** This is a typedef for unsigned char, it ensures portability of the engine. */ /** This is a typedef for unsigned char, it ensures portability of the engine. */
typedef unsigned char u8; typedef unsigned char u8;
//! 8 bit signed variable. //! 8 bit signed variable.
/** This is a typedef for signed char, it ensures portability of the engine. */ /** This is a typedef for signed char, it ensures portability of the engine. */
typedef signed char s8; typedef signed char s8;
//! 8 bit character variable. //! 8 bit character variable.
/** This is a typedef for char, it ensures portability of the engine. */ /** This is a typedef for char, it ensures portability of the engine. */
typedef char c8; typedef char c8;
//! 16 bit unsigned variable. //! 16 bit unsigned variable.
/** This is a typedef for unsigned short, it ensures portability of the engine. */ /** This is a typedef for unsigned short, it ensures portability of the engine. */
typedef unsigned short u16; typedef unsigned short u16;
//! 16 bit signed variable. //! 16 bit signed variable.
/** This is a typedef for signed short, it ensures portability of the engine. */ /** This is a typedef for signed short, it ensures portability of the engine. */
typedef signed short s16; typedef signed short s16;
//! 32 bit unsigned variable. //! 32 bit unsigned variable.
/** This is a typedef for unsigned int, it ensures portability of the engine. */ /** This is a typedef for unsigned int, it ensures portability of the engine. */
typedef unsigned int u32; typedef unsigned int u32;
//! 32 bit signed variable. //! 32 bit signed variable.
/** This is a typedef for signed int, it ensures portability of the engine. */ /** This is a typedef for signed int, it ensures portability of the engine. */
typedef signed int s32; typedef signed int s32;
// 64 bit signed variable. // 64 bit signed variable.
// This is a typedef for __int64, it ensures portability of the engine. // This is a typedef for __int64, it ensures portability of the engine.
// This type is currently not used by the engine and not supported by compilers // This type is currently not used by the engine and not supported by compilers
// other than Microsoft Compilers, so it is outcommented. // other than Microsoft Compilers, so it is outcommented.
//typedef __int64 s64; //typedef __int64 s64;
//! 32 bit floating point variable. //! 32 bit floating point variable.
/** This is a typedef for float, it ensures portability of the engine. */ /** This is a typedef for float, it ensures portability of the engine. */
typedef float f32; typedef float f32;
//! 64 bit floating point variable. //! 64 bit floating point variable.
/** This is a typedef for double, it ensures portability of the engine. */ /** This is a typedef for double, it ensures portability of the engine. */
typedef double f64; typedef double f64;
} // end namespace } // end namespace
// define the wchar_t type if not already built in. // define the wchar_t type if not already built in.
#ifdef _MSC_VER #ifdef _MSC_VER
#ifndef _WCHAR_T_DEFINED #ifndef _WCHAR_T_DEFINED
//! A 16 bit wide character type. //! A 16 bit wide character type.
/** /**
Defines the wchar_t-type. Defines the wchar_t-type.
In VS6, its not possible to tell In VS6, its not possible to tell
the standard compiler to treat wchar_t as a built-in type, and the standard compiler to treat wchar_t as a built-in type, and
sometimes we just don't want to include the huge stdlib.h or wchar.h, sometimes we just don't want to include the huge stdlib.h or wchar.h,
so we'll use this. so we'll use this.
*/ */
typedef unsigned short wchar_t; typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED #define _WCHAR_T_DEFINED
#endif // wchar is not defined #endif // wchar is not defined
#endif // microsoft compiler #endif // microsoft compiler
//! define a break macro for debugging only in Win32 mode. //! define a break macro for debugging only in Win32 mode.
// WORKAROUND (assimp): remove __asm // WORKAROUND (assimp): remove __asm
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG) #if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#if defined(_M_IX86) #if defined(_M_IX86)
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) /*if (_CONDITION_) {_asm int 3}*/ #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) /*if (_CONDITION_) {_asm int 3}*/
#else #else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) #define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif #endif
#else #else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) #define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif #endif
//! Defines a small statement to work around a microsoft compiler bug. //! Defines a small statement to work around a microsoft compiler bug.
/** The microsft compiler 7.0 - 7.1 has a bug: /** The microsft compiler 7.0 - 7.1 has a bug:
When you call unmanaged code that returns a bool type value of false from managed code, When you call unmanaged code that returns a bool type value of false from managed code,
the return value may appear as true. See the return value may appear as true. See
http://support.microsoft.com/default.aspx?kbid=823071 for details. http://support.microsoft.com/default.aspx?kbid=823071 for details.
Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/ Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/
// WORKAROUND (assimp): remove __asm // WORKAROUND (assimp): remove __asm
#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400) #if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX /*__asm mov eax,100*/ #define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX /*__asm mov eax,100*/
#else #else
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX #define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX #endif // _IRR_MANAGED_MARSHALLING_BUGFIX
#endif // __IRR_TYPES_H_INCLUDED__ #endif // __IRR_TYPES_H_INCLUDED__

View File

@ -1,151 +1,151 @@
// Copyright (C) 2002-2005 Nikolaus Gebhardt // Copyright (C) 2002-2005 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine" and the "irrXML" project. // This file is part of the "Irrlicht Engine" and the "irrXML" project.
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h // For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
// Need to include Assimp, too. We're using Assimp's version of fast_atof // Need to include Assimp, too. We're using Assimp's version of fast_atof
// so we need stdint.h. But no PCH. // so we need stdint.h. But no PCH.
#include "irrXML.h" #include "irrXML.h"
#include "irrString.h" #include "irrString.h"
#include "irrArray.h" #include "irrArray.h"
#include "./../../code/fast_atof.h" #include "./../../code/fast_atof.h"
#include "CXMLReaderImpl.h" #include "CXMLReaderImpl.h"
namespace irr namespace irr
{ {
namespace io namespace io
{ {
//! Implementation of the file read callback for ordinary files //! Implementation of the file read callback for ordinary files
class CFileReadCallBack : public IFileReadCallBack class CFileReadCallBack : public IFileReadCallBack
{ {
public: public:
//! construct from filename //! construct from filename
CFileReadCallBack(const char* filename) CFileReadCallBack(const char* filename)
: File(0), Size(0), Close(true) : File(0), Size(0), Close(true)
{ {
// open file // open file
File = fopen(filename, "rb"); File = fopen(filename, "rb");
if (File) if (File)
getFileSize(); getFileSize();
} }
//! construct from FILE pointer //! construct from FILE pointer
CFileReadCallBack(FILE* file) CFileReadCallBack(FILE* file)
: File(file), Size(0), Close(false) : File(file), Size(0), Close(false)
{ {
if (File) if (File)
getFileSize(); getFileSize();
} }
//! destructor //! destructor
virtual ~CFileReadCallBack() virtual ~CFileReadCallBack()
{ {
if (Close && File) if (Close && File)
fclose(File); fclose(File);
} }
//! Reads an amount of bytes from the file. //! Reads an amount of bytes from the file.
virtual int read(void* buffer, int sizeToRead) virtual int read(void* buffer, int sizeToRead)
{ {
if (!File) if (!File)
return 0; return 0;
return (int)fread(buffer, 1, sizeToRead, File); return (int)fread(buffer, 1, sizeToRead, File);
} }
//! Returns size of file in bytes //! Returns size of file in bytes
virtual int getSize() virtual int getSize()
{ {
return Size; return Size;
} }
private: private:
//! retrieves the file size of the open file //! retrieves the file size of the open file
void getFileSize() void getFileSize()
{ {
fseek(File, 0, SEEK_END); fseek(File, 0, SEEK_END);
Size = ftell(File); Size = ftell(File);
fseek(File, 0, SEEK_SET); fseek(File, 0, SEEK_SET);
} }
FILE* File; FILE* File;
int Size; int Size;
bool Close; bool Close;
}; // end class CFileReadCallBack }; // end class CFileReadCallBack
// FACTORY FUNCTIONS: // FACTORY FUNCTIONS:
//! Creates an instance of an UFT-8 or ASCII character xml parser. //! Creates an instance of an UFT-8 or ASCII character xml parser.
IrrXMLReader* createIrrXMLReader(const char* filename) IrrXMLReader* createIrrXMLReader(const char* filename)
{ {
return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(filename)); return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(filename));
} }
//! Creates an instance of an UFT-8 or ASCII character xml parser. //! Creates an instance of an UFT-8 or ASCII character xml parser.
IrrXMLReader* createIrrXMLReader(FILE* file) IrrXMLReader* createIrrXMLReader(FILE* file)
{ {
return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(file)); return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(file));
} }
//! Creates an instance of an UFT-8 or ASCII character xml parser. //! Creates an instance of an UFT-8 or ASCII character xml parser.
IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback) IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback)
{ {
return new CXMLReaderImpl<char, IXMLBase>(callback, false); return new CXMLReaderImpl<char, IXMLBase>(callback, false);
} }
//! Creates an instance of an UTF-16 xml parser. //! Creates an instance of an UTF-16 xml parser.
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename) IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename)
{ {
return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(filename)); return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(filename));
} }
//! Creates an instance of an UTF-16 xml parser. //! Creates an instance of an UTF-16 xml parser.
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file) IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file)
{ {
return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(file)); return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(file));
} }
//! Creates an instance of an UTF-16 xml parser. //! Creates an instance of an UTF-16 xml parser.
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback) IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback)
{ {
return new CXMLReaderImpl<char16, IXMLBase>(callback, false); return new CXMLReaderImpl<char16, IXMLBase>(callback, false);
} }
//! Creates an instance of an UTF-32 xml parser. //! Creates an instance of an UTF-32 xml parser.
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename) IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename)
{ {
return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(filename)); return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(filename));
} }
//! Creates an instance of an UTF-32 xml parser. //! Creates an instance of an UTF-32 xml parser.
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file) IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file)
{ {
return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(file)); return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(file));
} }
//! Creates an instance of an UTF-32 xml parser. //! Creates an instance of an UTF-32 xml parser.
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback) IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback)
{ {
return new CXMLReaderImpl<char32, IXMLBase>(callback, false); return new CXMLReaderImpl<char32, IXMLBase>(callback, false);
} }
} // end namespace io } // end namespace io
} // end namespace irr } // end namespace irr

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
IrrXML IrrXML
Downloaded September 2008 Downloaded September 2008
- fixed a minor compiler warning (vs 2005, shift too large) - fixed a minor compiler warning (vs 2005, shift too large)
- fixed an issue regarding wchar_t/unsigned short - fixed an issue regarding wchar_t/unsigned short

View File

@ -1,105 +1,105 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* * Redistributions of source code must retain the above copyright notice, * * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, * * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be * * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific * used to endorse or promote products derived from this software without specific
* prior written permission. * prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef UTILS_H #ifndef UTILS_H
#define UTILS_H #define UTILS_H
// Otherwise #defines like M_PI are undeclared under Visual Studio // Otherwise #defines like M_PI are undeclared under Visual Studio
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include <exception> #include <exception>
#include <math.h> #include <math.h>
namespace p2t { namespace p2t {
const double PI_3div4 = 3 * M_PI / 4; const double PI_3div4 = 3 * M_PI / 4;
const double EPSILON = 1e-15; const double EPSILON = 1e-15;
enum Orientation { CW, CCW, COLLINEAR }; enum Orientation { CW, CCW, COLLINEAR };
/** /**
* Forumla to calculate signed area<br> * Forumla to calculate signed area<br>
* Positive if CCW<br> * Positive if CCW<br>
* Negative if CW<br> * Negative if CW<br>
* 0 if collinear<br> * 0 if collinear<br>
* <pre> * <pre>
* A[P1,P2,P3] = (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1) * A[P1,P2,P3] = (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1)
* = (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3) * = (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
* </pre> * </pre>
*/ */
Orientation Orient2d(Point& pa, Point& pb, Point& pc) Orientation Orient2d(Point& pa, Point& pb, Point& pc)
{ {
double detleft = (pa.x - pc.x) * (pb.y - pc.y); double detleft = (pa.x - pc.x) * (pb.y - pc.y);
double detright = (pa.y - pc.y) * (pb.x - pc.x); double detright = (pa.y - pc.y) * (pb.x - pc.x);
double val = detleft - detright; double val = detleft - detright;
if (val > -EPSILON && val < EPSILON) { if (val > -EPSILON && val < EPSILON) {
return COLLINEAR; return COLLINEAR;
} else if (val > 0) { } else if (val > 0) {
return CCW; return CCW;
} }
return CW; return CW;
} }
bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd) bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
{ {
double pdx = pd.x; double pdx = pd.x;
double pdy = pd.y; double pdy = pd.y;
double adx = pa.x - pdx; double adx = pa.x - pdx;
double ady = pa.y - pdy; double ady = pa.y - pdy;
double bdx = pb.x - pdx; double bdx = pb.x - pdx;
double bdy = pb.y - pdy; double bdy = pb.y - pdy;
double adxbdy = adx * bdy; double adxbdy = adx * bdy;
double bdxady = bdx * ady; double bdxady = bdx * ady;
double oabd = adxbdy - bdxady; double oabd = adxbdy - bdxady;
if (oabd <= EPSILON) { if (oabd <= EPSILON) {
return false; return false;
} }
double cdx = pc.x - pdx; double cdx = pc.x - pdx;
double cdy = pc.y - pdy; double cdy = pc.y - pdy;
double cdxady = cdx * ady; double cdxady = cdx * ady;
double adxcdy = adx * cdy; double adxcdy = adx * cdy;
double ocad = cdxady - adxcdy; double ocad = cdxady - adxcdy;
if (ocad <= EPSILON) { if (ocad <= EPSILON) {
return false; return false;
} }
return true; return true;
} }
} }
#endif #endif

View File

@ -1,105 +1,105 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* * Redistributions of source code must retain the above copyright notice, * * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, * * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be * * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific * used to endorse or promote products derived from this software without specific
* prior written permission. * prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef CDT_H #ifndef CDT_H
#define CDT_H #define CDT_H
#include "advancing_front.h" #include "advancing_front.h"
#include "sweep_context.h" #include "sweep_context.h"
#include "sweep.h" #include "sweep.h"
/** /**
* *
* @author Mason Green <mason.green@gmail.com> * @author Mason Green <mason.green@gmail.com>
* *
*/ */
namespace p2t { namespace p2t {
class CDT class CDT
{ {
public: public:
/** /**
* Constructor - add polyline with non repeating points * Constructor - add polyline with non repeating points
* *
* @param polyline * @param polyline
*/ */
CDT(std::vector<Point*> polyline); CDT(std::vector<Point*> polyline);
/** /**
* Destructor - clean up memory * Destructor - clean up memory
*/ */
~CDT(); ~CDT();
/** /**
* Add a hole * Add a hole
* *
* @param polyline * @param polyline
*/ */
void AddHole(std::vector<Point*> polyline); void AddHole(std::vector<Point*> polyline);
/** /**
* Add a steiner point * Add a steiner point
* *
* @param point * @param point
*/ */
void AddPoint(Point* point); void AddPoint(Point* point);
/** /**
* Triangulate - do this AFTER you've added the polyline, holes, and Steiner points * Triangulate - do this AFTER you've added the polyline, holes, and Steiner points
*/ */
void Triangulate(); void Triangulate();
/** /**
* Get CDT triangles * Get CDT triangles
*/ */
std::vector<Triangle*> GetTriangles(); std::vector<Triangle*> GetTriangles();
/** /**
* Get triangle map * Get triangle map
*/ */
std::list<Triangle*> GetMap(); std::list<Triangle*> GetMap();
private: private:
/** /**
* Internals * Internals
*/ */
SweepContext* sweep_context_; SweepContext* sweep_context_;
Sweep* sweep_; Sweep* sweep_;
}; };
} }
#endif #endif

View File

@ -1,186 +1,186 @@
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* * Redistributions of source code must retain the above copyright notice, * * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, * * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be * * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific * used to endorse or promote products derived from this software without specific
* prior written permission. * prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef SWEEP_CONTEXT_H #ifndef SWEEP_CONTEXT_H
#define SWEEP_CONTEXT_H #define SWEEP_CONTEXT_H
#include <list> #include <list>
#include <vector> #include <vector>
#include <cstddef> #include <cstddef>
namespace p2t { namespace p2t {
// Inital triangle factor, seed triangle will extend 30% of // Inital triangle factor, seed triangle will extend 30% of
// PointSet width to both left and right. // PointSet width to both left and right.
const double kAlpha = 0.3; const double kAlpha = 0.3;
struct Point; struct Point;
class Triangle; class Triangle;
struct Node; struct Node;
struct Edge; struct Edge;
class AdvancingFront; class AdvancingFront;
class SweepContext { class SweepContext {
public: public:
/// Constructor /// Constructor
SweepContext(std::vector<Point*> polyline); SweepContext(std::vector<Point*> polyline);
/// Destructor /// Destructor
~SweepContext(); ~SweepContext();
void set_head(Point* p1); void set_head(Point* p1);
Point* head(); Point* head();
void set_tail(Point* p1); void set_tail(Point* p1);
Point* tail(); Point* tail();
int point_count(); int point_count();
Node& LocateNode(Point& point); Node& LocateNode(Point& point);
void RemoveNode(Node* node); void RemoveNode(Node* node);
void CreateAdvancingFront(std::vector<Node*> nodes); void CreateAdvancingFront(std::vector<Node*> nodes);
/// Try to map a node to all sides of this triangle that don't have a neighbor /// Try to map a node to all sides of this triangle that don't have a neighbor
void MapTriangleToNodes(Triangle& t); void MapTriangleToNodes(Triangle& t);
void AddToMap(Triangle* triangle); void AddToMap(Triangle* triangle);
Point* GetPoint(const int& index); Point* GetPoint(const int& index);
Point* GetPoints(); Point* GetPoints();
void RemoveFromMap(Triangle* triangle); void RemoveFromMap(Triangle* triangle);
void AddHole(std::vector<Point*> polyline); void AddHole(std::vector<Point*> polyline);
void AddPoint(Point* point); void AddPoint(Point* point);
AdvancingFront* front(); AdvancingFront* front();
void MeshClean(Triangle& triangle); void MeshClean(Triangle& triangle);
std::vector<Triangle*> GetTriangles(); std::vector<Triangle*> GetTriangles();
std::list<Triangle*> GetMap(); std::list<Triangle*> GetMap();
std::vector<Edge*> edge_list; std::vector<Edge*> edge_list;
struct Basin { struct Basin {
Node* left_node; Node* left_node;
Node* bottom_node; Node* bottom_node;
Node* right_node; Node* right_node;
double width; double width;
bool left_highest; bool left_highest;
Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false) Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false)
{ {
} }
void Clear() void Clear()
{ {
left_node = NULL; left_node = NULL;
bottom_node = NULL; bottom_node = NULL;
right_node = NULL; right_node = NULL;
width = 0.0; width = 0.0;
left_highest = false; left_highest = false;
} }
}; };
struct EdgeEvent { struct EdgeEvent {
Edge* constrained_edge; Edge* constrained_edge;
bool right; bool right;
EdgeEvent() : constrained_edge(NULL), right(false) EdgeEvent() : constrained_edge(NULL), right(false)
{ {
} }
}; };
Basin basin; Basin basin;
EdgeEvent edge_event; EdgeEvent edge_event;
private: private:
friend class Sweep; friend class Sweep;
std::vector<Triangle*> triangles_; std::vector<Triangle*> triangles_;
std::list<Triangle*> map_; std::list<Triangle*> map_;
std::vector<Point*> points_; std::vector<Point*> points_;
// Advancing front // Advancing front
AdvancingFront* front_; AdvancingFront* front_;
// head point used with advancing front // head point used with advancing front
Point* head_; Point* head_;
// tail point used with advancing front // tail point used with advancing front
Point* tail_; Point* tail_;
Node *af_head_, *af_middle_, *af_tail_; Node *af_head_, *af_middle_, *af_tail_;
void InitTriangulation(); void InitTriangulation();
void InitEdges(std::vector<Point*> polyline); void InitEdges(std::vector<Point*> polyline);
}; };
inline AdvancingFront* SweepContext::front() inline AdvancingFront* SweepContext::front()
{ {
return front_; return front_;
} }
inline int SweepContext::point_count() inline int SweepContext::point_count()
{ {
return points_.size(); return points_.size();
} }
inline void SweepContext::set_head(Point* p1) inline void SweepContext::set_head(Point* p1)
{ {
head_ = p1; head_ = p1;
} }
inline Point* SweepContext::head() inline Point* SweepContext::head()
{ {
return head_; return head_;
} }
inline void SweepContext::set_tail(Point* p1) inline void SweepContext::set_tail(Point* p1)
{ {
tail_ = p1; tail_ = p1;
} }
inline Point* SweepContext::tail() inline Point* SweepContext::tail()
{ {
return tail_; return tail_;
} }
} }
#endif #endif

View File

@ -1,75 +1,75 @@
diff -r 5de9623d6a50 poly2tri/common/shapes.h diff -r 5de9623d6a50 poly2tri/common/shapes.h
--- a/poly2tri/common/shapes.h Mon Aug 08 22:26:41 2011 -0400 --- a/poly2tri/common/shapes.h Mon Aug 08 22:26:41 2011 -0400
+++ b/poly2tri/common/shapes.h Tue Jan 17 02:36:52 2012 +0100 +++ b/poly2tri/common/shapes.h Tue Jan 17 02:36:52 2012 +0100
@@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
#include <vector> #include <vector>
#include <cstddef> #include <cstddef>
+#include <stdexcept> +#include <stdexcept>
#include <assert.h> #include <assert.h>
#include <cmath> #include <cmath>
@@ -136,7 +137,9 @@ @@ -136,7 +137,9 @@
p = &p2; p = &p2;
} else if (p1.x == p2.x) { } else if (p1.x == p2.x) {
// Repeat points // Repeat points
- assert(false); - assert(false);
+ // ASSIMP_CHANGE (aramis_acg) + // ASSIMP_CHANGE (aramis_acg)
+ throw std::runtime_error("repeat points"); + throw std::runtime_error("repeat points");
+ //assert(false); + //assert(false);
} }
} }
diff -r 5de9623d6a50 poly2tri/sweep/sweep.cc diff -r 5de9623d6a50 poly2tri/sweep/sweep.cc
--- a/poly2tri/sweep/sweep.cc Mon Aug 08 22:26:41 2011 -0400 --- a/poly2tri/sweep/sweep.cc Mon Aug 08 22:26:41 2011 -0400
+++ b/poly2tri/sweep/sweep.cc Tue Jan 17 02:36:52 2012 +0100 +++ b/poly2tri/sweep/sweep.cc Tue Jan 17 02:36:52 2012 +0100
@@ -113,6 +113,8 @@ @@ -113,6 +113,8 @@
Point* p1 = triangle->PointCCW(point); Point* p1 = triangle->PointCCW(point);
Orientation o1 = Orient2d(eq, *p1, ep); Orientation o1 = Orient2d(eq, *p1, ep);
if (o1 == COLLINEAR) { if (o1 == COLLINEAR) {
+ // ASSIMP_CHANGE (aramis_acg) + // ASSIMP_CHANGE (aramis_acg)
+ throw std::runtime_error("EdgeEvent - collinear points not supported"); + throw std::runtime_error("EdgeEvent - collinear points not supported");
if( triangle->Contains(&eq, p1)) { if( triangle->Contains(&eq, p1)) {
triangle->MarkConstrainedEdge(&eq, p1 ); triangle->MarkConstrainedEdge(&eq, p1 );
// We are modifying the constraint maybe it would be better to // We are modifying the constraint maybe it would be better to
@@ -121,8 +123,8 @@ @@ -121,8 +123,8 @@
triangle = &triangle->NeighborAcross(point); triangle = &triangle->NeighborAcross(point);
EdgeEvent( tcx, ep, *p1, triangle, *p1 ); EdgeEvent( tcx, ep, *p1, triangle, *p1 );
} else { } else {
+ // ASSIMP_CHANGE (aramis_acg) + // ASSIMP_CHANGE (aramis_acg)
std::runtime_error("EdgeEvent - collinear points not supported"); std::runtime_error("EdgeEvent - collinear points not supported");
- assert(0); - assert(0);
} }
return; return;
} }
@@ -130,6 +132,9 @@ @@ -130,6 +132,9 @@
Point* p2 = triangle->PointCW(point); Point* p2 = triangle->PointCW(point);
Orientation o2 = Orient2d(eq, *p2, ep); Orientation o2 = Orient2d(eq, *p2, ep);
if (o2 == COLLINEAR) { if (o2 == COLLINEAR) {
+ // ASSIMP_CHANGE (aramis_acg) + // ASSIMP_CHANGE (aramis_acg)
+ throw std::runtime_error("EdgeEvent - collinear points not supported"); + throw std::runtime_error("EdgeEvent - collinear points not supported");
+ +
if( triangle->Contains(&eq, p2)) { if( triangle->Contains(&eq, p2)) {
triangle->MarkConstrainedEdge(&eq, p2 ); triangle->MarkConstrainedEdge(&eq, p2 );
// We are modifying the constraint maybe it would be better to // We are modifying the constraint maybe it would be better to
@@ -138,8 +143,8 @@ @@ -138,8 +143,8 @@
triangle = &triangle->NeighborAcross(point); triangle = &triangle->NeighborAcross(point);
EdgeEvent( tcx, ep, *p2, triangle, *p2 ); EdgeEvent( tcx, ep, *p2, triangle, *p2 );
} else { } else {
- std::runtime_error("EdgeEvent - collinear points not supported"); - std::runtime_error("EdgeEvent - collinear points not supported");
- assert(0); - assert(0);
+ // ASSIMP_CHANGE (aramis_acg) + // ASSIMP_CHANGE (aramis_acg)
+ throw std::runtime_error("EdgeEvent - collinear points not supported"); + throw std::runtime_error("EdgeEvent - collinear points not supported");
} }
return; return;
} }
@@ -712,7 +717,8 @@ @@ -712,7 +717,8 @@
return *ot.PointCW(op); return *ot.PointCW(op);
} else{ } else{
//throw new RuntimeException("[Unsupported] Opposing point on constrained edge"); //throw new RuntimeException("[Unsupported] Opposing point on constrained edge");
- assert(0); - assert(0);
+ // ASSIMP_CHANGE (aramis_acg) + // ASSIMP_CHANGE (aramis_acg)
+ throw std::runtime_error("[Unsupported] Opposing point on constrained edge"); + throw std::runtime_error("[Unsupported] Opposing point on constrained edge");
} }
} }

View File

@ -1,132 +1,132 @@
/* crypt.h -- base code for crypt/uncrypt ZIPfile /* crypt.h -- base code for crypt/uncrypt ZIPfile
Version 1.01e, February 12th, 2005 Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant Copyright (C) 1998-2005 Gilles Vollant
This code is a modified version of crypting code in Infozip distribution This code is a modified version of crypting code in Infozip distribution
The encryption/decryption parts of this source code (as opposed to the The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA. whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.) (Prior to January 2000, re-export from the US was a violation of US law.)
This encryption code is a direct transcription of the algorithm from This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities). version without encryption capabilities).
If you don't need crypting in your application, just define symbols If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT. NOCRYPT and NOUNCRYPT.
This code support the "Traditional PKWARE Encryption". This code support the "Traditional PKWARE Encryption".
The new AES encryption added on Zip format by Winzip (see the page The new AES encryption added on Zip format by Winzip (see the page
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
Encryption is not supported. Encryption is not supported.
*/ */
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
/*********************************************************************** /***********************************************************************
* Return the next byte in the pseudo-random sequence * Return the next byte in the pseudo-random sequence
*/ */
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{ {
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem * unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */ * with any known compiler so far, though */
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
} }
/*********************************************************************** /***********************************************************************
* Update the encryption keys with the next byte of plain text * Update the encryption keys with the next byte of plain text
*/ */
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
{ {
(*(pkeys+0)) = CRC32((*(pkeys+0)), c); (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff; (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{ {
register int keyshift = (int)((*(pkeys+1)) >> 24); register int keyshift = (int)((*(pkeys+1)) >> 24);
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
} }
return c; return c;
} }
/*********************************************************************** /***********************************************************************
* Initialize the encryption keys and the random header according to * Initialize the encryption keys and the random header according to
* the given password. * the given password.
*/ */
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
{ {
*(pkeys+0) = 305419896L; *(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L; *(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L; *(pkeys+2) = 878082192L;
while (*passwd != '\0') { while (*passwd != '\0') {
update_keys(pkeys,pcrc_32_tab,(int)*passwd); update_keys(pkeys,pcrc_32_tab,(int)*passwd);
passwd++; passwd++;
} }
} }
#define zdecode(pkeys,pcrc_32_tab,c) \ #define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
#define zencode(pkeys,pcrc_32_tab,c,t) \ #define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#define RAND_HEAD_LEN 12 #define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */ /* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2 # ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ # define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif # endif
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
const char *passwd; /* password string */ const char *passwd; /* password string */
unsigned char *buf; /* where to write header */ unsigned char *buf; /* where to write header */
int bufSize; int bufSize;
unsigned long* pkeys; unsigned long* pkeys;
const unsigned long* pcrc_32_tab; const unsigned long* pcrc_32_tab;
unsigned long crcForCrypting; unsigned long crcForCrypting;
{ {
int n; /* index in random header */ int n; /* index in random header */
int t; /* temporary */ int t; /* temporary */
int c; /* random byte */ int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */ unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */ static unsigned calls = 0; /* ensure different random header each time */
if (bufSize<RAND_HEAD_LEN) if (bufSize<RAND_HEAD_LEN)
return 0; return 0;
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is * output of rand() to get less predictability, since rand() is
* often poorly implemented. * often poorly implemented.
*/ */
if (++calls == 1) if (++calls == 1)
{ {
srand((unsigned)(time(NULL) ^ ZCR_SEED2)); srand((unsigned)(time(NULL) ^ ZCR_SEED2));
} }
init_keys(passwd, pkeys, pcrc_32_tab); init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++) for (n = 0; n < RAND_HEAD_LEN-2; n++)
{ {
c = (rand() >> 7) & 0xff; c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
} }
/* Encrypt random header (last two bytes is high word of crc) */ /* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab); init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++) for (n = 0; n < RAND_HEAD_LEN-2; n++)
{ {
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
} }
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
return n; return n;
} }
#endif #endif

View File

@ -1,181 +1,181 @@
/* ioapi.c -- IO base function header for compress/uncompress .zip /* ioapi.c -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005 Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant Copyright (C) 1998-2005 Gilles Vollant
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
# ifdef ASSIMP_BUILD_NO_OWN_ZLIB # ifdef ASSIMP_BUILD_NO_OWN_ZLIB
# include <zlib.h> # include <zlib.h>
# else # else
# include "../zlib/zlib.h" # include "../zlib/zlib.h"
# endif # endif
#include "ioapi.h" #include "ioapi.h"
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
#ifndef SEEK_CUR #ifndef SEEK_CUR
#define SEEK_CUR 1 #define SEEK_CUR 1
#endif #endif
#ifndef SEEK_END #ifndef SEEK_END
#define SEEK_END 2 #define SEEK_END 2
#endif #endif
#ifndef SEEK_SET #ifndef SEEK_SET
#define SEEK_SET 0 #define SEEK_SET 0
#endif #endif
voidpf ZCALLBACK fopen_file_func ( voidpf ZCALLBACK fopen_file_func (
voidpf opaque, voidpf opaque,
const char* filename, const char* filename,
int mode); int mode);
uLong ZCALLBACK fread_file_func ( uLong ZCALLBACK fread_file_func (
voidpf opaque, voidpf opaque,
voidpf stream, voidpf stream,
void* buf, void* buf,
uLong size); uLong size);
uLong ZCALLBACK fwrite_file_func ( uLong ZCALLBACK fwrite_file_func (
voidpf opaque, voidpf opaque,
voidpf stream, voidpf stream,
const void* buf, const void* buf,
uLong size); uLong size);
long ZCALLBACK ftell_file_func ( long ZCALLBACK ftell_file_func (
voidpf opaque, voidpf opaque,
voidpf stream); voidpf stream);
long ZCALLBACK fseek_file_func ( long ZCALLBACK fseek_file_func (
voidpf opaque, voidpf opaque,
voidpf stream, voidpf stream,
uLong offset, uLong offset,
int origin); int origin);
int ZCALLBACK fclose_file_func ( int ZCALLBACK fclose_file_func (
voidpf opaque, voidpf opaque,
voidpf stream); voidpf stream);
int ZCALLBACK ferror_file_func ( int ZCALLBACK ferror_file_func (
voidpf opaque, voidpf opaque,
voidpf stream); voidpf stream);
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
voidpf opaque; voidpf opaque;
const char* filename; const char* filename;
int mode; int mode;
{ {
FILE* file = NULL; FILE* file = NULL;
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb"; mode_fopen = "rb";
else else
if (mode & ZLIB_FILEFUNC_MODE_EXISTING) if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
mode_fopen = "r+b"; mode_fopen = "r+b";
else else
if (mode & ZLIB_FILEFUNC_MODE_CREATE) if (mode & ZLIB_FILEFUNC_MODE_CREATE)
mode_fopen = "wb"; mode_fopen = "wb";
if ((filename!=NULL) && (mode_fopen != NULL)) if ((filename!=NULL) && (mode_fopen != NULL))
file = fopen(filename, mode_fopen); file = fopen(filename, mode_fopen);
return file; return file;
} }
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
voidpf opaque; voidpf opaque;
voidpf stream; voidpf stream;
void* buf; void* buf;
uLong size; uLong size;
{ {
uLong ret; uLong ret;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret; return ret;
} }
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
voidpf opaque; voidpf opaque;
voidpf stream; voidpf stream;
const void* buf; const void* buf;
uLong size; uLong size;
{ {
uLong ret; uLong ret;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret; return ret;
} }
long ZCALLBACK ftell_file_func (opaque, stream) long ZCALLBACK ftell_file_func (opaque, stream)
voidpf opaque; voidpf opaque;
voidpf stream; voidpf stream;
{ {
long ret; long ret;
ret = ftell((FILE *)stream); ret = ftell((FILE *)stream);
return ret; return ret;
} }
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
voidpf opaque; voidpf opaque;
voidpf stream; voidpf stream;
uLong offset; uLong offset;
int origin; int origin;
{ {
int fseek_origin=0; int fseek_origin=0;
long ret; long ret;
switch (origin) switch (origin)
{ {
case ZLIB_FILEFUNC_SEEK_CUR : case ZLIB_FILEFUNC_SEEK_CUR :
fseek_origin = SEEK_CUR; fseek_origin = SEEK_CUR;
break; break;
case ZLIB_FILEFUNC_SEEK_END : case ZLIB_FILEFUNC_SEEK_END :
fseek_origin = SEEK_END; fseek_origin = SEEK_END;
break; break;
case ZLIB_FILEFUNC_SEEK_SET : case ZLIB_FILEFUNC_SEEK_SET :
fseek_origin = SEEK_SET; fseek_origin = SEEK_SET;
break; break;
default: return -1; default: return -1;
} }
ret = 0; ret = 0;
fseek((FILE *)stream, offset, fseek_origin); fseek((FILE *)stream, offset, fseek_origin);
return ret; return ret;
} }
int ZCALLBACK fclose_file_func (opaque, stream) int ZCALLBACK fclose_file_func (opaque, stream)
voidpf opaque; voidpf opaque;
voidpf stream; voidpf stream;
{ {
int ret; int ret;
ret = fclose((FILE *)stream); ret = fclose((FILE *)stream);
return ret; return ret;
} }
int ZCALLBACK ferror_file_func (opaque, stream) int ZCALLBACK ferror_file_func (opaque, stream)
voidpf opaque; voidpf opaque;
voidpf stream; voidpf stream;
{ {
int ret; int ret;
ret = ferror((FILE *)stream); ret = ferror((FILE *)stream);
return ret; return ret;
} }
void fill_fopen_filefunc (pzlib_filefunc_def) void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def; zlib_filefunc_def* pzlib_filefunc_def;
{ {
pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func;
pzlib_filefunc_def->ztell_file = ftell_file_func; pzlib_filefunc_def->ztell_file = ftell_file_func;
pzlib_filefunc_def->zseek_file = fseek_file_func; pzlib_filefunc_def->zseek_file = fseek_file_func;
pzlib_filefunc_def->zclose_file = fclose_file_func; pzlib_filefunc_def->zclose_file = fclose_file_func;
pzlib_filefunc_def->zerror_file = ferror_file_func; pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL; pzlib_filefunc_def->opaque = NULL;
} }

View File

@ -1,75 +1,75 @@
/* ioapi.h -- IO base function header for compress/uncompress .zip /* ioapi.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005 Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant Copyright (C) 1998-2005 Gilles Vollant
*/ */
#ifndef _ZLIBIOAPI_H #ifndef _ZLIBIOAPI_H
#define _ZLIBIOAPI_H #define _ZLIBIOAPI_H
#define ZLIB_FILEFUNC_SEEK_CUR (1) #define ZLIB_FILEFUNC_SEEK_CUR (1)
#define ZLIB_FILEFUNC_SEEK_END (2) #define ZLIB_FILEFUNC_SEEK_END (2)
#define ZLIB_FILEFUNC_SEEK_SET (0) #define ZLIB_FILEFUNC_SEEK_SET (0)
#define ZLIB_FILEFUNC_MODE_READ (1) #define ZLIB_FILEFUNC_MODE_READ (1)
#define ZLIB_FILEFUNC_MODE_WRITE (2) #define ZLIB_FILEFUNC_MODE_WRITE (2)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
#define ZLIB_FILEFUNC_MODE_EXISTING (4) #define ZLIB_FILEFUNC_MODE_EXISTING (4)
#define ZLIB_FILEFUNC_MODE_CREATE (8) #define ZLIB_FILEFUNC_MODE_CREATE (8)
#ifndef ZCALLBACK #ifndef ZCALLBACK
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
#define ZCALLBACK CALLBACK #define ZCALLBACK CALLBACK
#else #else
#define ZCALLBACK #define ZCALLBACK
#endif #endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode); typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size); typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
typedef uLong (ZCALLBACK *write_file_func)(voidpf opaque, voidpf stream, const void* buf, uLong size); typedef uLong (ZCALLBACK *write_file_func)(voidpf opaque, voidpf stream, const void* buf, uLong size);
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream); typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin); typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream); typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream); typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
typedef struct zlib_filefunc_def_s typedef struct zlib_filefunc_def_s
{ {
open_file_func zopen_file; open_file_func zopen_file;
read_file_func zread_file; read_file_func zread_file;
write_file_func zwrite_file; write_file_func zwrite_file;
tell_file_func ztell_file; tell_file_func ztell_file;
seek_file_func zseek_file; seek_file_func zseek_file;
close_file_func zclose_file; close_file_func zclose_file;
testerror_file_func zerror_file; testerror_file_func zerror_file;
voidpf opaque; voidpf opaque;
} zlib_filefunc_def; } zlib_filefunc_def;
void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def); void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def);
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,358 +1,358 @@
/* unzip.h -- IO for uncompress .zip files using zlib /* unzip.h -- IO for uncompress .zip files using zlib
Version 1.01e, February 12th, 2005 Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant Copyright (C) 1998-2005 Gilles Vollant
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
WinZip, InfoZip tools and compatible. WinZip, InfoZip tools and compatible.
Multi volume ZipFile (span) are not supported. Multi volume ZipFile (span) are not supported.
Encryption compatible with pkzip 2.04g only supported Encryption compatible with pkzip 2.04g only supported
Old compressions used by old PKZip 1.x are not supported Old compressions used by old PKZip 1.x are not supported
I WAIT FEEDBACK at mail info@winimage.com I WAIT FEEDBACK at mail info@winimage.com
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
Condition of use and distribution are the same than zlib : Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* for more info about .ZIP format, see /* for more info about .ZIP format, see
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
http://www.info-zip.org/pub/infozip/doc/ http://www.info-zip.org/pub/infozip/doc/
PkWare has also a specification at : PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip ftp://ftp.pkware.com/probdesc.zip
*/ */
#ifndef _unz_H #ifndef _unz_H
#define _unz_H #define _unz_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef _ZLIB_H #ifndef _ZLIB_H
# ifdef ASSIMP_BUILD_NO_OWN_ZLIB # ifdef ASSIMP_BUILD_NO_OWN_ZLIB
# include <zlib.h> # include <zlib.h>
# else # else
# include "../zlib/zlib.h" # include "../zlib/zlib.h"
# endif # endif
#endif #endif
#ifndef _ZLIBIOAPI_H #ifndef _ZLIBIOAPI_H
#include "ioapi.h" #include "ioapi.h"
#endif #endif
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted /* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */ from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__; typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile; typedef unzFile__ *unzFile;
#else #else
typedef voidp unzFile; typedef voidp unzFile;
#endif #endif
#define UNZ_OK (0) #define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO) #define UNZ_ERRNO (Z_ERRNO)
#define UNZ_EOF (0) #define UNZ_EOF (0)
#define UNZ_PARAMERROR (-102) #define UNZ_PARAMERROR (-102)
#define UNZ_BADZIPFILE (-103) #define UNZ_BADZIPFILE (-103)
#define UNZ_INTERNALERROR (-104) #define UNZ_INTERNALERROR (-104)
#define UNZ_CRCERROR (-105) #define UNZ_CRCERROR (-105)
/* tm_unz contain date/time info */ /* tm_unz contain date/time info */
typedef struct tm_unz_s typedef struct tm_unz_s
{ {
uInt tm_sec; /* seconds after the minute - [0,59] */ uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */ uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */ uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */ uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */ uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */ uInt tm_year; /* years - [1980..2044] */
} tm_unz; } tm_unz;
/* unz_global_info structure contain global data about the ZIPfile /* unz_global_info structure contain global data about the ZIPfile
These data comes from the end of central dir */ These data comes from the end of central dir */
typedef struct unz_global_info_s typedef struct unz_global_info_s
{ {
uLong number_entry; /* total number of entries in uLong number_entry; /* total number of entries in
the central dir on this disk */ the central dir on this disk */
uLong size_comment; /* size of the global comment of the zipfile */ uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info; } unz_global_info;
/* unz_file_info contain information about a file in the zipfile */ /* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info_s typedef struct unz_file_info_s
{ {
uLong version; /* version made by 2 bytes */ uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */ uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */ uLong crc; /* crc-32 4 bytes */
uLong compressed_size; /* compressed size 4 bytes */ uLong compressed_size; /* compressed size 4 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */ uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */ uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */ uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date; tm_unz tmu_date;
} unz_file_info; } unz_file_info;
extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
const char* fileName2, const char* fileName2,
int iCaseSensitivity); int iCaseSensitivity);
/* /*
Compare two filename (fileName1,fileName2). Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
or strcasecmp) or strcasecmp)
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
(like 1 on Unix, 2 on Windows) (like 1 on Unix, 2 on Windows)
*/ */
extern unzFile ZEXPORT unzOpen (const char *path); extern unzFile ZEXPORT unzOpen (const char *path);
/* /*
Open a Zip file. path contain the full pathname (by example, Open a Zip file. path contain the full pathname (by example,
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
"zlib/zlib113.zip". "zlib/zlib113.zip".
If the zipfile cannot be opened (file don't exist or in not valid), the If the zipfile cannot be opened (file don't exist or in not valid), the
return value is NULL. return value is NULL.
Else, the return value is a unzFile Handle, usable with other function Else, the return value is a unzFile Handle, usable with other function
of this unzip package. of this unzip package.
*/ */
extern unzFile ZEXPORT unzOpen2 (const char *path, extern unzFile ZEXPORT unzOpen2 (const char *path,
zlib_filefunc_def* pzlib_filefunc_def); zlib_filefunc_def* pzlib_filefunc_def);
/* /*
Open a Zip file, like unzOpen, but provide a set of file low level API Open a Zip file, like unzOpen, but provide a set of file low level API
for read/write the zip file (see ioapi.h) for read/write the zip file (see ioapi.h)
*/ */
extern int ZEXPORT unzClose (unzFile file); extern int ZEXPORT unzClose (unzFile file);
/* /*
Close a ZipFile opened with unzipOpen. Close a ZipFile opened with unzipOpen.
If there is files inside the .Zip opened with unzOpenCurrentFile (see later), If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose. these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */ return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo (unzFile file, extern int ZEXPORT unzGetGlobalInfo (unzFile file,
unz_global_info *pglobal_info); unz_global_info *pglobal_info);
/* /*
Write info about the ZipFile in the *pglobal_info structure. Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed No preparation of the structure is needed
return UNZ_OK if there is no problem. */ return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalComment (unzFile file, extern int ZEXPORT unzGetGlobalComment (unzFile file,
char *szComment, char *szComment,
uLong uSizeBuf); uLong uSizeBuf);
/* /*
Get the global comment string of the ZipFile, in the szComment buffer. Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer. uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0 return the number of byte copied or an error code <0
*/ */
/***************************************************************************/ /***************************************************************************/
/* Unzip package allow you browse the directory of the zipfile */ /* Unzip package allow you browse the directory of the zipfile */
extern int ZEXPORT unzGoToFirstFile (unzFile file); extern int ZEXPORT unzGoToFirstFile (unzFile file);
/* /*
Set the current file of the zipfile to the first file. Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem return UNZ_OK if there is no problem
*/ */
extern int ZEXPORT unzGoToNextFile (unzFile file); extern int ZEXPORT unzGoToNextFile (unzFile file);
/* /*
Set the current file of the zipfile to the next file. Set the current file of the zipfile to the next file.
return UNZ_OK if there is no problem return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/ */
extern int ZEXPORT unzLocateFile (unzFile file, extern int ZEXPORT unzLocateFile (unzFile file,
const char *szFileName, const char *szFileName,
int iCaseSensitivity); int iCaseSensitivity);
/* /*
Try locate the file szFileName in the zipfile. Try locate the file szFileName in the zipfile.
For the iCaseSensitivity signification, see unzStringFileNameCompare For the iCaseSensitivity signification, see unzStringFileNameCompare
return value : return value :
UNZ_OK if the file is found. It becomes the current file. UNZ_OK if the file is found. It becomes the current file.
UNZ_END_OF_LIST_OF_FILE if the file is not found UNZ_END_OF_LIST_OF_FILE if the file is not found
*/ */
/* ****************************************** */ /* ****************************************** */
/* Ryan supplied functions */ /* Ryan supplied functions */
/* unz_file_info contain information about a file in the zipfile */ /* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_pos_s typedef struct unz_file_pos_s
{ {
uLong pos_in_zip_directory; /* offset in zip file directory */ uLong pos_in_zip_directory; /* offset in zip file directory */
uLong num_of_file; /* # of file */ uLong num_of_file; /* # of file */
} unz_file_pos; } unz_file_pos;
extern int ZEXPORT unzGetFilePos( extern int ZEXPORT unzGetFilePos(
unzFile file, unzFile file,
unz_file_pos* file_pos); unz_file_pos* file_pos);
extern int ZEXPORT unzGoToFilePos( extern int ZEXPORT unzGoToFilePos(
unzFile file, unzFile file,
unz_file_pos* file_pos); unz_file_pos* file_pos);
/* ****************************************** */ /* ****************************************** */
extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
unz_file_info *pfile_info, unz_file_info *pfile_info,
char *szFileName, char *szFileName,
uLong fileNameBufferSize, uLong fileNameBufferSize,
void *extraField, void *extraField,
uLong extraFieldBufferSize, uLong extraFieldBufferSize,
char *szComment, char *szComment,
uLong commentBufferSize); uLong commentBufferSize);
/* /*
Get Info about the current file Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain somes info about if pfile_info!=NULL, the *pfile_info structure will contain somes info about
the current file the current file
if szFileName!=NULL, the filemane string will be copied in szFileName if szFileName!=NULL, the filemane string will be copied in szFileName
(fileNameBufferSize is the size of the buffer) (fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField if extraField!=NULL, the extra field information will be copied in extraField
(extraFieldBufferSize is the size of the buffer). (extraFieldBufferSize is the size of the buffer).
This is the Central-header version of the extra field This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment if szComment!=NULL, the comment string of the file will be copied in szComment
(commentBufferSize is the size of the buffer) (commentBufferSize is the size of the buffer)
*/ */
/***************************************************************************/ /***************************************************************************/
/* for reading the content of the current zipfile, you can open it, read data /* for reading the content of the current zipfile, you can open it, read data
from it, and close it (you can close it before reading all the file) from it, and close it (you can close it before reading all the file)
*/ */
extern int ZEXPORT unzOpenCurrentFile (unzFile file); extern int ZEXPORT unzOpenCurrentFile (unzFile file);
/* /*
Open for reading data the current file in the zipfile. Open for reading data the current file in the zipfile.
If there is no error, the return value is UNZ_OK. If there is no error, the return value is UNZ_OK.
*/ */
extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file,
const char* password); const char* password);
/* /*
Open for reading data the current file in the zipfile. Open for reading data the current file in the zipfile.
password is a crypting password password is a crypting password
If there is no error, the return value is UNZ_OK. If there is no error, the return value is UNZ_OK.
*/ */
extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, extern int ZEXPORT unzOpenCurrentFile2 (unzFile file,
int* method, int* method,
int* level, int* level,
int raw); int raw);
/* /*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1 if raw==1
*method will receive method of compression, *level will receive level of *method will receive method of compression, *level will receive level of
compression compression
note : you can set level parameter as NULL (if you did not want known level, note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL but you CANNOT set method parameter as NULL
*/ */
extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, extern int ZEXPORT unzOpenCurrentFile3 (unzFile file,
int* method, int* method,
int* level, int* level,
int raw, int raw,
const char* password); const char* password);
/* /*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1 if raw==1
*method will receive method of compression, *level will receive level of *method will receive method of compression, *level will receive level of
compression compression
note : you can set level parameter as NULL (if you did not want known level, note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL but you CANNOT set method parameter as NULL
*/ */
extern int ZEXPORT unzCloseCurrentFile (unzFile file); extern int ZEXPORT unzCloseCurrentFile (unzFile file);
/* /*
Close the file in zip opened with unzOpenCurrentFile Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/ */
extern int ZEXPORT unzReadCurrentFile (unzFile file, extern int ZEXPORT unzReadCurrentFile (unzFile file,
voidp buf, voidp buf,
unsigned len); unsigned len);
/* /*
Read bytes from the current file (opened by unzOpenCurrentFile) Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied buf contain buffer where data must be copied
len the size of buf. len the size of buf.
return the number of byte copied if somes bytes are copied return the number of byte copied if somes bytes are copied
return 0 if the end of file was reached return 0 if the end of file was reached
return <0 with error code if there is an error return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error) (UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/ */
extern z_off_t ZEXPORT unztell (unzFile file); extern z_off_t ZEXPORT unztell (unzFile file);
/* /*
Give the current position in uncompressed data Give the current position in uncompressed data
*/ */
extern int ZEXPORT unzeof (unzFile file); extern int ZEXPORT unzeof (unzFile file);
/* /*
return 1 if the end of file was reached, 0 elsewhere return 1 if the end of file was reached, 0 elsewhere
*/ */
extern int ZEXPORT unzGetLocalExtrafield (unzFile file, extern int ZEXPORT unzGetLocalExtrafield (unzFile file,
voidp buf, voidp buf,
unsigned len); unsigned len);
/* /*
Read extra field from the current file (opened by unzOpenCurrentFile) Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is This is the local-header version of the extra field (sometimes, there is
more info in the local-header version than in the central-header) more info in the local-header version than in the central-header)
if buf==NULL, it return the size of the local extra field if buf==NULL, it return the size of the local extra field
if buf!=NULL, len is the size of the buffer, the extra header is copied in if buf!=NULL, len is the size of the buffer, the extra header is copied in
buf. buf.
the return value is the number of bytes copied in buf, or (if <0) the return value is the number of bytes copied in buf, or (if <0)
the error code the error code
*/ */
/***************************************************************************/ /***************************************************************************/
/* Get the current file offset */ /* Get the current file offset */
extern uLong ZEXPORT unzGetOffset (unzFile file); extern uLong ZEXPORT unzGetOffset (unzFile file);
/* Set the current file offset */ /* Set the current file offset */
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _unz_H */ #endif /* _unz_H */

View File

@ -1,199 +1,199 @@
cmake_minimum_required(VERSION 2.4.4) cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
# CMake 3.0 changed the project command, setting policy CMP0048 reverts to the old behaviour. # CMake 3.0 changed the project command, setting policy CMP0048 reverts to the old behaviour.
# See http://www.cmake.org/cmake/help/v3.0/policy/CMP0048.html # See http://www.cmake.org/cmake/help/v3.0/policy/CMP0048.html
cmake_policy(PUSH) cmake_policy(PUSH)
if(CMAKE_MAJOR_VERSION GREATER 2) if(CMAKE_MAJOR_VERSION GREATER 2)
cmake_policy(SET CMP0048 OLD) cmake_policy(SET CMP0048 OLD)
endif() endif()
project(zlib C) project(zlib C)
cmake_policy(POP) cmake_policy(POP)
set(VERSION "1.2.8") set(VERSION "1.2.8")
option(ASM686 "Enable building i686 assembly implementation for zlib") option(ASM686 "Enable building i686 assembly implementation for zlib")
option(AMD64 "Enable building amd64 assembly implementation for zlib") option(AMD64 "Enable building amd64 assembly implementation for zlib")
#set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") #set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
#set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") #set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
#set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") #set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
#set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") #set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
#set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") #set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
include(CheckTypeSize) include(CheckTypeSize)
include(CheckFunctionExists) include(CheckFunctionExists)
include(CheckIncludeFile) include(CheckIncludeFile)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
enable_testing() enable_testing()
check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H) check_include_file(stddef.h HAVE_STDDEF_H)
# #
# Check to see if we have large file support # Check to see if we have large file support
# #
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
# We add these other definitions here because CheckTypeSize.cmake # We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want # in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x. # compatibility with CMake 2.4.x.
if(HAVE_SYS_TYPES_H) if(HAVE_SYS_TYPES_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
endif() endif()
if(HAVE_STDINT_H) if(HAVE_STDINT_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
endif() endif()
if(HAVE_STDDEF_H) if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif() endif()
check_type_size(off64_t OFF64_T) check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T) if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE=1) add_definitions(-D_LARGEFILE64_SOURCE=1)
endif() endif()
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
# #
# Check for fseeko # Check for fseeko
# #
check_function_exists(fseeko HAVE_FSEEKO) check_function_exists(fseeko HAVE_FSEEKO)
if(NOT HAVE_FSEEKO) if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO) add_definitions(-DNO_FSEEKO)
endif() endif()
# #
# Check for unistd.h # Check for unistd.h
# #
check_include_file(unistd.h Z_HAVE_UNISTD_H) check_include_file(unistd.h Z_HAVE_UNISTD_H)
if(MSVC) if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d") set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif() endif()
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
# If we're doing an out of source build and the user has a zconf.h # If we're doing an out of source build and the user has a zconf.h
# in their source tree... # in their source tree...
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
message(STATUS "Renaming") message(STATUS "Renaming")
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h") message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
message(STATUS "to 'zconf.h.included' because this file is included with zlib") message(STATUS "to 'zconf.h.included' because this file is included with zlib")
message(STATUS "but CMake generates it automatically in the build directory.") message(STATUS "but CMake generates it automatically in the build directory.")
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
endif() endif()
endif() endif()
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY) ${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
#============================================================================ #============================================================================
# zlib # zlib
#============================================================================ #============================================================================
set(ZLIB_PUBLIC_HDRS set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h ${CMAKE_CURRENT_BINARY_DIR}/zconf.h
zlib.h zlib.h
) )
set(ZLIB_PRIVATE_HDRS set(ZLIB_PRIVATE_HDRS
crc32.h crc32.h
deflate.h deflate.h
gzguts.h gzguts.h
inffast.h inffast.h
inffixed.h inffixed.h
inflate.h inflate.h
inftrees.h inftrees.h
trees.h trees.h
zutil.h zutil.h
) )
set(ZLIB_SRCS set(ZLIB_SRCS
adler32.c adler32.c
compress.c compress.c
crc32.c crc32.c
deflate.c deflate.c
gzclose.c gzclose.c
gzlib.c gzlib.c
gzread.c gzread.c
gzwrite.c gzwrite.c
inflate.c inflate.c
infback.c infback.c
inftrees.c inftrees.c
inffast.c inffast.c
trees.c trees.c
uncompr.c uncompr.c
zutil.c zutil.c
) )
if(NOT MINGW) if(NOT MINGW)
set(ZLIB_DLL_SRCS set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below. win32/zlib1.rc # If present will override custom build rule below.
) )
endif() endif()
if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
if(ASM686) if(ASM686)
set(ZLIB_ASMS contrib/asm686/match.S) set(ZLIB_ASMS contrib/asm686/match.S)
elseif (AMD64) elseif (AMD64)
set(ZLIB_ASMS contrib/amd64/amd64-match.S) set(ZLIB_ASMS contrib/amd64/amd64-match.S)
endif () endif ()
if(ZLIB_ASMS) if(ZLIB_ASMS)
add_definitions(-DASMV) add_definitions(-DASMV)
set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
endif() endif()
endif() endif()
if(MSVC) if(MSVC)
if(ASM686) if(ASM686)
ENABLE_LANGUAGE(ASM_MASM) ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS set(ZLIB_ASMS
contrib/masmx86/inffas32.asm contrib/masmx86/inffas32.asm
contrib/masmx86/match686.asm contrib/masmx86/match686.asm
) )
elseif (AMD64) elseif (AMD64)
ENABLE_LANGUAGE(ASM_MASM) ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS set(ZLIB_ASMS
contrib/masmx64/gvmat64.asm contrib/masmx64/gvmat64.asm
contrib/masmx64/inffasx64.asm contrib/masmx64/inffasx64.asm
) )
endif() endif()
if(ZLIB_ASMS) if(ZLIB_ASMS)
add_definitions(-DASMV -DASMINF) add_definitions(-DASMV -DASMINF)
endif() endif()
endif() endif()
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
if(MINGW) if(MINGW)
# This gets us DLL resource information when compiling on MinGW. # This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER) if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe) set(CMAKE_RC_COMPILER windres.exe)
endif() endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND ${CMAKE_RC_COMPILER} COMMAND ${CMAKE_RC_COMPILER}
-D GCC_WINDRES -D GCC_WINDRES
-I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${CMAKE_CURRENT_BINARY_DIR} -I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW) endif(MINGW)
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
INSTALL( TARGETS zlibstatic INSTALL( TARGETS zlibstatic
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR} ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR} RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR}
COMPONENT ${LIBASSIMP_COMPONENT}) COMPONENT ${LIBASSIMP_COMPONENT})

View File

@ -1,11 +1,11 @@
This is a heavily modified and shrinked version of zlib 1.2.3 This is a heavily modified and shrinked version of zlib 1.2.3
- Removed comments from zlib.h - Removed comments from zlib.h
- Removed gzip/zip archive I/O - Removed gzip/zip archive I/O
- Removed infback.c - Removed infback.c
- Added Assimp #idefs to exclude it if not needed - Added Assimp #idefs to exclude it if not needed
- Disabled debug macros in zutil.h - Disabled debug macros in zutil.h
Assimp itself does not use the compression part yet, so Assimp itself does not use the compression part yet, so
it needn't be compiled (trees.c, deflate.c, compress.c). it needn't be compiled (trees.c, deflate.c, compress.c).
Currently these units are just used by assimp_cmd. Currently these units are just used by assimp_cmd.

View File

@ -1,40 +1,40 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2012, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following with or without modification, are permitted provided that the following
conditions are met: conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer. following disclaimer.
* Redistributions in binary form must reproduce the above * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other following disclaimer in the documentation and/or other
materials provided with the distribution. materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its * Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products contributors may be used to endorse or promote products
derived from this software without specific prior derived from this software without specific prior
written permission of the assimp team. written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */

3410
doc/dox.h

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,22 @@
// =============================================================================== // ===============================================================================
// May be included multiple times - resets structure packing to the defaults // May be included multiple times - resets structure packing to the defaults
// for all supported compilers. Reverts the changes made by #include <pushpack1.h> // for all supported compilers. Reverts the changes made by #include <pushpack1.h>
// //
// Currently this works on the following compilers: // Currently this works on the following compilers:
// MSVC 7,8,9 // MSVC 7,8,9
// GCC // GCC
// BORLAND (complains about 'pack state changed but not reverted', but works) // BORLAND (complains about 'pack state changed but not reverted', but works)
// =============================================================================== // ===============================================================================
#ifndef AI_PUSHPACK_IS_DEFINED #ifndef AI_PUSHPACK_IS_DEFINED
# error pushpack1.h must be included after poppack1.h # error pushpack1.h must be included after poppack1.h
#endif #endif
// reset packing to the original value // reset packing to the original value
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop ) # pragma pack( pop )
#endif #endif
#undef PACK_STRUCT #undef PACK_STRUCT
#undef AI_PUSHPACK_IS_DEFINED #undef AI_PUSHPACK_IS_DEFINED

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif #endif
#include "types.h" #include "types.h"
#include <vector>
namespace Assimp { namespace Assimp {
class IOStream; class IOStream;
@ -102,18 +105,14 @@ public:
* @param pFile Path to the file * @param pFile Path to the file
* @return true if there is a file with this path, else false. * @return true if there is a file with this path, else false.
*/ */
virtual bool Exists( const char* pFile) const = 0; virtual bool Exists( const char* pFile) const = 0;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Returns the system specific directory separator /** @brief Returns the system specific directory separator
* @return System specific directory separator * @return System specific directory separator
*/ */
virtual char getOsSeparator() const = 0; virtual char getOsSeparator() const = 0;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Open a new file with a given path. /** @brief Open a new file with a given path.
* *
@ -139,8 +138,6 @@ public:
inline IOStream* Open(const std::string& pFile, inline IOStream* Open(const std::string& pFile,
const std::string& pMode = std::string("rb")); const std::string& pMode = std::string("rb"));
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Closes the given file and releases all resources /** @brief Closes the given file and releases all resources
* associated with it. * associated with it.
@ -170,10 +167,41 @@ public:
*/ */
inline bool ComparePaths (const std::string& one, inline bool ComparePaths (const std::string& one,
const std::string& second) const; const std::string& second) const;
// -------------------------------------------------------------------
/** @brief Pushes a new directory onto the directory stack.
* @param path Path to push onto the stack.
* @return True, when push was successful, false if path is empty.
*/
virtual bool PushDirectory( const std::string &path );
// -------------------------------------------------------------------
/** @brief Returns the top directory from the stack.
* @return The directory on the top of the stack.
* Returns empty when no directory was pushed to the stack.
*/
virtual const std::string &CurrentDirectory() const;
// -------------------------------------------------------------------
/** @brief Returns the number of directories stored on the stack.
* @return The number of directories of the stack.
*/
virtual size_t StackSize() const;
// -------------------------------------------------------------------
/** @brief Pops the top directory from the stack.
* @return True, when a directory was on the stack. False if no
* directory was on the stack.
*/
virtual bool PopDirectory();
private:
std::vector<std::string> m_pathStack;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
AI_FORCE_INLINE IOSystem::IOSystem() AI_FORCE_INLINE IOSystem::IOSystem() :
m_pathStack()
{ {
// empty // empty
} }
@ -220,6 +248,43 @@ inline bool IOSystem::ComparePaths (const std::string& one,
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
inline bool IOSystem::PushDirectory( const std::string &path ) {
if ( path.empty() ) {
return false;
}
m_pathStack.push_back( path );
return true;
}
// ----------------------------------------------------------------------------
inline const std::string &IOSystem::CurrentDirectory() const {
if ( m_pathStack.empty() ) {
static const std::string Dummy("");
return Dummy;
}
return m_pathStack[ m_pathStack.size()-1 ];
}
// ----------------------------------------------------------------------------
inline size_t IOSystem::StackSize() const {
return m_pathStack.size();
}
// ----------------------------------------------------------------------------
inline bool IOSystem::PopDirectory() {
if ( m_pathStack.empty() ) {
return false;
}
m_pathStack.pop_back();
return true;
}
// ----------------------------------------------------------------------------
} //!ns Assimp } //!ns Assimp
#endif //AI_IOSYSTEM_H_INC #endif //AI_IOSYSTEM_H_INC

View File

@ -276,4 +276,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define AI_BUILD_BIG_ENDIAN # define AI_BUILD_BIG_ENDIAN
#endif #endif
/* To avoid running out of memory
* This can be adjusted for specific use cases
* It's NOT a total limit, just a limit for individual allocations
*/
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
#endif // !! INCLUDED_AI_DEFINES_H #endif // !! INCLUDED_AI_DEFINES_H

View File

@ -1,92 +1,92 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2012, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the with or without modification, are permitted provided that the
following conditions are met: following conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer. following disclaimer.
* Redistributions in binary form must reproduce the above * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other following disclaimer in the documentation and/or other
materials provided with the distribution. materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its * Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products contributors may be used to endorse or promote products
derived from this software without specific prior derived from this software without specific prior
written permission of the assimp team. written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
/** @file Android implementation of IOSystem using the standard C file functions. /** @file Android implementation of IOSystem using the standard C file functions.
* Aimed to ease the acces to android assets */ * Aimed to ease the acces to android assets */
#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) #if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
#ifndef AI_ANDROIDJNIIOSYSTEM_H_INC #ifndef AI_ANDROIDJNIIOSYSTEM_H_INC
#define AI_ANDROIDJNIIOSYSTEM_H_INC #define AI_ANDROIDJNIIOSYSTEM_H_INC
#include "../code/DefaultIOSystem.h" #include "../code/DefaultIOSystem.h"
#include <android/asset_manager.h> #include <android/asset_manager.h>
#include <android/asset_manager_jni.h> #include <android/asset_manager_jni.h>
#include <android/native_activity.h> #include <android/native_activity.h>
namespace Assimp { namespace Assimp {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Android extension to DefaultIOSystem using the standard C file functions */ /** Android extension to DefaultIOSystem using the standard C file functions */
class AndroidJNIIOSystem : public DefaultIOSystem class AndroidJNIIOSystem : public DefaultIOSystem
{ {
public: public:
/** Initialize android activity data */ /** Initialize android activity data */
std::string mApkWorkspacePath; std::string mApkWorkspacePath;
AAssetManager* mApkAssetManager; AAssetManager* mApkAssetManager;
/** Constructor. */ /** Constructor. */
AndroidJNIIOSystem(ANativeActivity* activity); AndroidJNIIOSystem(ANativeActivity* activity);
/** Destructor. */ /** Destructor. */
~AndroidJNIIOSystem(); ~AndroidJNIIOSystem();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Tests for the existence of a file at the given path. */ /** Tests for the existence of a file at the given path. */
bool Exists( const char* pFile) const; bool Exists( const char* pFile) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Opens a file at the given path, with given mode */ /** Opens a file at the given path, with given mode */
IOStream* Open( const char* strFile, const char* strMode); IOStream* Open( const char* strFile, const char* strMode);
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Inits Android extractor // Inits Android extractor
void AndroidActivityInit(ANativeActivity* activity); void AndroidActivityInit(ANativeActivity* activity);
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Extracts android asset // Extracts android asset
bool AndroidExtractAsset(std::string name); bool AndroidExtractAsset(std::string name);
}; };
} //!ns Assimp } //!ns Assimp
#endif //AI_ANDROIDJNIIOSYSTEM_H_INC #endif //AI_ANDROIDJNIIOSYSTEM_H_INC
#endif //__ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) #endif //__ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)

View File

@ -1,16 +1,16 @@
How to build the Assimp installer using Inno Setup How to build the Assimp installer using Inno Setup
1) Get MS VC 2008 SP1 redist packages for x86 and amd64 and copy 'em right here. 1) Get MS VC 2008 SP1 redist packages for x86 and amd64 and copy 'em right here.
vcredist_x86.exe vcredist_x86.exe
vcredist_x64.exe vcredist_x64.exe
2) Get D3DCompiler_NN.dll and D3DX9_NN.dll from a) your system32 folder and b) your SysWOW64 folder. Copy all 4 here. Rename the 64 bit files to <originalname>_x64.dll. NN is the D3DX version targeted by your DX SDK. If it is not 42, you need to update the Inno setup script (script.iss) as well. If you don't have a 64 bit Windows, get the DLLs from somebody else. Please don't ask google because many DLL downloads are infected. 2) Get D3DCompiler_NN.dll and D3DX9_NN.dll from a) your system32 folder and b) your SysWOW64 folder. Copy all 4 here. Rename the 64 bit files to <originalname>_x64.dll. NN is the D3DX version targeted by your DX SDK. If it is not 42, you need to update the Inno setup script (script.iss) as well. If you don't have a 64 bit Windows, get the DLLs from somebody else. Please don't ask google because many DLL downloads are infected.
3) Build assimp, assimpcmd and assimpview for the 'release-dll' target and both the Win32 and x64 architectures. 3) Build assimp, assimpcmd and assimpview for the 'release-dll' target and both the Win32 and x64 architectures.
4) Get Inno Setup 4) Get Inno Setup
5) Compile, output is written to the 'out' folder. 5) Compile, output is written to the 'out' folder.

View File

@ -1,23 +1,23 @@
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
Open Asset Import Library (Assimp) SDK Installer Open Asset Import Library (Assimp) SDK Installer
Release Notes Release Notes
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
http://assimp.sf.net http://assimp.sf.net
Troubleshooting Troubleshooting
=============== ===============
1. Missing d3dx9_(some-number).dll? 1. Missing d3dx9_(some-number).dll?
Install the latest DirectX runtime or grab the file from somewhere (that's evil but mostly fine). Install the latest DirectX runtime or grab the file from somewhere (that's evil but mostly fine).
2. Application configuration not correct / missing msvcr***.dll? 2. Application configuration not correct / missing msvcr***.dll?
Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system) Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. assimp.exe not in PATH 3. assimp.exe not in PATH
Add it to PATH. That's not a bug, the installer does not alter the PATH. Add it to PATH. That's not a bug, the installer does not alter the PATH.
4. Crashes immediately 4. Crashes immediately
You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry. You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry.

View File

@ -1,32 +1,32 @@
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
Open Asset Import Library (Assimp) Viewer Installer Open Asset Import Library (Assimp) Viewer Installer
Release Notes Release Notes
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
http://assimp.sf.net http://assimp.sf.net
Known Bugs & Limitations Known Bugs & Limitations
======================== ========================
Viewer Viewer
- Normals appear flipped from time to time when either of the normals-related menu items was hit. - Normals appear flipped from time to time when either of the normals-related menu items was hit.
- Alpha-sorting is implemented, but still causes artifacts when models are moved quickly. - Alpha-sorting is implemented, but still causes artifacts when models are moved quickly.
- Several important texture file formats (such as GIF) are not supported. - Several important texture file formats (such as GIF) are not supported.
- HUD is blurred on the right side. ATI/AMD hardware only. - HUD is blurred on the right side. ATI/AMD hardware only.
Troubleshooting Troubleshooting
=============== ===============
1. Missing d3dx9_(number).dll? 1. Missing d3dx9_(number).dll?
Install the latest DirectX runtime or grab the file from somewhere (that's evil but mostly fine). Install the latest DirectX runtime or grab the file from somewhere (that's evil but mostly fine).
2. Application configuration not correct / missing msvcr***.dll? 2. Application configuration not correct / missing msvcr***.dll?
Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system) Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. assimp.exe not in PATH 3. assimp.exe not in PATH
Add it to PATH. That's not a bug, the installer does not alter the PATH. Add it to PATH. That's not a bug, the installer does not alter the PATH.
4. Crashes immediately 4. Crashes immediately
You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry. You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry.

View File

@ -1,29 +1,29 @@
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
Open Asset Import Library (Assimp) Tools/Binaries for Windows Open Asset Import Library (Assimp) Tools/Binaries for Windows
Release Notes Release Notes
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
Known Bugs & Limitations Known Bugs & Limitations
======================== ========================
Viewer Viewer
- For files more than one embedded texture, only the first is loaded. - For files more than one embedded texture, only the first is loaded.
- Normals appear flipped from time to time when either of the normals-related menu items was hit. - Normals appear flipped from time to time when either of the normals-related menu items was hit.
- Alpha-sorting is implemented, but still causes artifacts when models are moved quickly. - Alpha-sorting is implemented, but still causes artifacts when models are moved quickly.
- Several important texture file formats (such as GIF) are not supported. - Several important texture file formats (such as GIF) are not supported.
- HUD is blurred on the right side. ATI/AMD hardware only. - HUD is blurred on the right side. ATI/AMD hardware only.
Troubleshooting Troubleshooting
=============== ===============
1. Missing d3dx9_42.dll? 1. Missing d3dx9_42.dll?
Install the latest DirectX runtime or grab the file from somewhere (that's evil but mostly fine). Install the latest DirectX runtime or grab the file from somewhere (that's evil but mostly fine).
2. Application configuration not correct / missing msv*** DLLs? 2. Application configuration not correct / missing msv*** DLLs?
(Re)install Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system) (Re)install Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. Crashes immediately 3. Crashes immediately
You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry. You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry.

View File

@ -1,173 +1,175 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team Copyright (c) 2006-2012, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following with or without modification, are permitted provided that the following
conditions are met: conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer. following disclaimer.
* Redistributions in binary form must reproduce the above * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other following disclaimer in the documentation and/or other
materials provided with the distribution. materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its * Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products contributors may be used to endorse or promote products
derived from this software without specific prior derived from this software without specific prior
written permission of the assimp team. written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
/** @file Android extension of DefaultIOSystem using the standard C file functions */ /** @file Android extension of DefaultIOSystem using the standard C file functions */
#include <code/AssimpPCH.h> #include <assimp/config.h>
#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) #include <android/api-level.h>
#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
#include <stdlib.h>
#include <android/log.h> #include <stdlib.h>
#include <android/asset_manager.h> #include <android/log.h>
#include <android/asset_manager_jni.h> #include <android/asset_manager.h>
#include <android/native_activity.h> #include <android/asset_manager_jni.h>
#include <assimp/port/AndroidJNI/AndroidJNIIOSystem.h> #include <android/native_activity.h>
#include <code/DefaultIOStream.h> #include <assimp/ai_assert.h>
#include <fstream> #include <assimp/port/AndroidJNI/AndroidJNIIOSystem.h>
#include <code/DefaultIOStream.h>
using namespace Assimp; #include <fstream>
// ------------------------------------------------------------------------------------------------ using namespace Assimp;
// Constructor.
AndroidJNIIOSystem::AndroidJNIIOSystem(ANativeActivity* activity) // ------------------------------------------------------------------------------------------------
{ // Constructor.
AndroidActivityInit(activity); AndroidJNIIOSystem::AndroidJNIIOSystem(ANativeActivity* activity)
} {
AndroidActivityInit(activity);
// ------------------------------------------------------------------------------------------------ }
// Destructor.
AndroidJNIIOSystem::~AndroidJNIIOSystem() // ------------------------------------------------------------------------------------------------
{ // Destructor.
// nothing to do here AndroidJNIIOSystem::~AndroidJNIIOSystem()
} {
// nothing to do here
// ------------------------------------------------------------------------------------------------ }
// Tests for the existence of a file at the given path.
bool AndroidJNIIOSystem::Exists( const char* pFile) const // ------------------------------------------------------------------------------------------------
{ // Tests for the existence of a file at the given path.
AAsset* asset = AAssetManager_open(mApkAssetManager, pFile, bool AndroidJNIIOSystem::Exists( const char* pFile) const
AASSET_MODE_UNKNOWN); {
FILE* file = ::fopen( (mApkWorkspacePath + getOsSeparator() + std::string(pFile)).c_str(), "rb"); AAsset* asset = AAssetManager_open(mApkAssetManager, pFile,
AASSET_MODE_UNKNOWN);
if (!asset && !file) FILE* file = ::fopen( (mApkWorkspacePath + getOsSeparator() + std::string(pFile)).c_str(), "rb");
{
__android_log_print(ANDROID_LOG_ERROR, "Assimp", "Asset manager can not find: %s", pFile); if (!asset && !file)
return false; {
} __android_log_print(ANDROID_LOG_ERROR, "Assimp", "Asset manager can not find: %s", pFile);
return false;
__android_log_print(ANDROID_LOG_ERROR, "Assimp", "Asset exists"); }
if (file)
::fclose( file); __android_log_print(ANDROID_LOG_ERROR, "Assimp", "Asset exists");
return true; if (file)
} ::fclose( file);
return true;
// ------------------------------------------------------------------------------------------------ }
// Inits Android extractor
void AndroidJNIIOSystem::AndroidActivityInit(ANativeActivity* activity) // ------------------------------------------------------------------------------------------------
{ // Inits Android extractor
mApkWorkspacePath = activity->internalDataPath; void AndroidJNIIOSystem::AndroidActivityInit(ANativeActivity* activity)
mApkAssetManager = activity->assetManager; {
} mApkWorkspacePath = activity->internalDataPath;
mApkAssetManager = activity->assetManager;
// ------------------------------------------------------------------------------------------------ }
// Extracts android asset
bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name) // ------------------------------------------------------------------------------------------------
{ // Extracts android asset
std::string newPath = mApkWorkspacePath + getOsSeparator() + name; bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name)
{
DefaultIOSystem io; std::string newPath = mApkWorkspacePath + getOsSeparator() + name;
// Do not extract if extracted already DefaultIOSystem io;
if ( io.Exists(newPath.c_str()) ) {
__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset already extracted"); // Do not extract if extracted already
return true; if ( io.Exists(newPath.c_str()) ) {
} __android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset already extracted");
// Open file return true;
AAsset* asset = AAssetManager_open(mApkAssetManager, name.c_str(), }
AASSET_MODE_UNKNOWN); // Open file
std::string assetContent; AAsset* asset = AAssetManager_open(mApkAssetManager, name.c_str(),
AASSET_MODE_UNKNOWN);
if (asset != NULL) { std::vector<char> assetContent;
// Find size
off_t assetSize = AAsset_getLength(asset); if (asset != NULL) {
// Find size
// Prepare input buffer off_t assetSize = AAsset_getLength(asset);
assetContent.resize(assetSize);
// Prepare input buffer
// Store input buffer assetContent.resize(assetSize);
AAsset_read(asset, &assetContent[0], assetSize);
// Store input buffer
// Close AAsset_read(asset, &assetContent[0], assetSize);
AAsset_close(asset);
// Close
// Prepare output buffer AAsset_close(asset);
std::ofstream assetExtracted(newPath.c_str(),
std::ios::out | std::ios::binary); // Prepare output buffer
if (!assetExtracted) { std::ofstream assetExtracted(newPath.c_str(),
__android_log_print(ANDROID_LOG_ERROR, "assimp", std::ios::out | std::ios::binary);
"Can not open output file"); if (!assetExtracted) {
} __android_log_print(ANDROID_LOG_ERROR, "assimp",
"Can not open output file");
// Write output buffer into a file }
assetExtracted.write(assetContent.c_str(), strlen(assetContent.c_str()));
assetExtracted.close(); // Write output buffer into a file
assetExtracted.write(&assetContent[0], assetContent.size());
__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset extracted"); assetExtracted.close();
} else {
__android_log_print(ANDROID_LOG_ERROR, "assimp", "Asset not found: %s", name.c_str()); __android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset extracted");
return false; } else {
} __android_log_print(ANDROID_LOG_ERROR, "assimp", "Asset not found: %s", name.c_str());
return true; return false;
} }
return true;
// ------------------------------------------------------------------------------------------------ }
// Open a new file with a given path.
IOStream* AndroidJNIIOSystem::Open( const char* strFile, const char* strMode) // ------------------------------------------------------------------------------------------------
{ // Open a new file with a given path.
ai_assert(NULL != strFile); IOStream* AndroidJNIIOSystem::Open( const char* strFile, const char* strMode)
ai_assert(NULL != strMode); {
ai_assert(NULL != strFile);
std::string fullPath(mApkWorkspacePath + getOsSeparator() + std::string(strFile)); ai_assert(NULL != strMode);
if (Exists(strFile))
AndroidExtractAsset(std::string(strFile)); std::string fullPath(mApkWorkspacePath + getOsSeparator() + std::string(strFile));
if (Exists(strFile))
FILE* file = ::fopen( fullPath.c_str(), strMode); AndroidExtractAsset(std::string(strFile));
if( NULL == file) FILE* file = ::fopen( fullPath.c_str(), strMode);
return NULL;
if( NULL == file)
__android_log_print(ANDROID_LOG_ERROR, "assimp", "AndroidIOSystem: file %s opened", fullPath.c_str()); return NULL;
return new DefaultIOStream(file, fullPath);
} __android_log_print(ANDROID_LOG_ERROR, "assimp", "AndroidIOSystem: file %s opened", fullPath.c_str());
return new DefaultIOStream(file, fullPath);
#undef PATHLIMIT }
#endif // __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
#undef PATHLIMIT
#endif // __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)

View File

@ -1,6 +1,6 @@
This is a set of Delphi units for using the Assimp C DLL. This was created for use with Delphi 7, but should be usable as-is or with minimal modifications with later Delphi versions. This is a set of Delphi units for using the Assimp C DLL. This was created for use with Delphi 7, but should be usable as-is or with minimal modifications with later Delphi versions.
This set of headers is enough to load and display a model with external textures. Since I'm not familiar with animated models and some of the other functionality of the assimp library, I did not convert the headers for those features. This set of headers is enough to load and display a model with external textures. Since I'm not familiar with animated models and some of the other functionality of the assimp library, I did not convert the headers for those features.
See http://sourceforge.net/tracker/?func=detail&aid=3212646&group_id=226462&atid=1067634 for the original patch See http://sourceforge.net/tracker/?func=detail&aid=3212646&group_id=226462&atid=1067634 for the original patch

View File

@ -20,6 +20,7 @@ additional_dirs, ext_whitelist = [],[]
# populate search directories and lists of allowed file extensions # populate search directories and lists of allowed file extensions
# depending on the platform we're running on. # depending on the platform we're running on.
if os.name=='posix': if os.name=='posix':
additional_dirs.append('./')
additional_dirs.append('/usr/lib/') additional_dirs.append('/usr/lib/')
additional_dirs.append('/usr/local/lib/') additional_dirs.append('/usr/local/lib/')

View File

@ -68,7 +68,7 @@ class PyAssimp3DViewer:
pygame.init() pygame.init()
pygame.display.set_caption(self.base_name) pygame.display.set_caption(self.base_name)
pygame.display.set_mode((w,h), pygame.OPENGL | pygame.DOUBLEBUF) pygame.display.set_mode((w,h), pygame.OPENGL | pygame.DOUBLEBUF)
glutInit()
self.prepare_shaders() self.prepare_shaders()
self.cameras = [DefaultCamera(w,h,fov)] self.cameras = [DefaultCamera(w,h,fov)]

View File

@ -1,26 +1,26 @@
#ifndef __ILUT_CONFIG_H__ #ifndef __ILUT_CONFIG_H__
#define __ILUT_CONFIG_H__ #define __ILUT_CONFIG_H__
#define IL_USE_PRAGMA_LIBS #define IL_USE_PRAGMA_LIBS
// Supported APIs (ILUT) // Supported APIs (ILUT)
// //
// sorry just // sorry just
// cant get this one to work under windows // cant get this one to work under windows
// have disabled for the now // have disabled for the now
// //
// will look at it some more later // will look at it some more later
// //
// Kriss // Kriss
// //
#undef ILUT_USE_ALLEGRO #undef ILUT_USE_ALLEGRO
#undef ILUT_USE_DIRECTX8 #undef ILUT_USE_DIRECTX8
//#define ILUT_USE_DIRECTX9 //#define ILUT_USE_DIRECTX9
//#define ILUT_USE_DIRECTX10 //#define ILUT_USE_DIRECTX10
#define ILUT_USE_OPENGL #define ILUT_USE_OPENGL
//#define ILUT_USE_SDL //#define ILUT_USE_SDL
#define ILUT_USE_WIN32 #define ILUT_USE_WIN32
#endif//__ILUT_CONFIG_H__ #endif//__ILUT_CONFIG_H__

View File

@ -1,389 +1,389 @@
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
// Simple sample to prove that Assimp is easy to use with OpenGL. // Simple sample to prove that Assimp is easy to use with OpenGL.
// It takes a file name as command line parameter, loads it using standard // It takes a file name as command line parameter, loads it using standard
// settings and displays it. // settings and displays it.
// //
// If you intend to _use_ this code sample in your app, do yourself a favour // If you intend to _use_ this code sample in your app, do yourself a favour
// and replace immediate mode calls with VBOs ... // and replace immediate mode calls with VBOs ...
// //
// The vc8 solution links against assimp-release-dll_win32 - be sure to // The vc8 solution links against assimp-release-dll_win32 - be sure to
// have this configuration built. // have this configuration built.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <glut.h> #include <glut.h>
#else #else
#include <GL/glut.h> #include <GL/glut.h>
#endif #endif
/* assimp include files. These three are usually needed. */ /* assimp include files. These three are usually needed. */
#include <assimp/cimport.h> #include <assimp/cimport.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
/* the global Assimp scene object */ /* the global Assimp scene object */
const struct aiScene* scene = NULL; const struct aiScene* scene = NULL;
GLuint scene_list = 0; GLuint scene_list = 0;
struct aiVector3D scene_min, scene_max, scene_center; struct aiVector3D scene_min, scene_max, scene_center;
/* current rotation angle */ /* current rotation angle */
static float angle = 0.f; static float angle = 0.f;
#define aisgl_min(x,y) (x<y?x:y) #define aisgl_min(x,y) (x<y?x:y)
#define aisgl_max(x,y) (y>x?y:x) #define aisgl_max(x,y) (y>x?y:x)
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void reshape(int width, int height) void reshape(int width, int height)
{ {
const double aspectRatio = (float) width / height, fieldOfView = 45.0; const double aspectRatio = (float) width / height, fieldOfView = 45.0;
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(fieldOfView, aspectRatio, gluPerspective(fieldOfView, aspectRatio,
1.0, 1000.0); /* Znear and Zfar */ 1.0, 1000.0); /* Znear and Zfar */
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void get_bounding_box_for_node (const struct aiNode* nd, void get_bounding_box_for_node (const struct aiNode* nd,
struct aiVector3D* min, struct aiVector3D* min,
struct aiVector3D* max, struct aiVector3D* max,
struct aiMatrix4x4* trafo struct aiMatrix4x4* trafo
){ ){
struct aiMatrix4x4 prev; struct aiMatrix4x4 prev;
unsigned int n = 0, t; unsigned int n = 0, t;
prev = *trafo; prev = *trafo;
aiMultiplyMatrix4(trafo,&nd->mTransformation); aiMultiplyMatrix4(trafo,&nd->mTransformation);
for (; n < nd->mNumMeshes; ++n) { for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]]; const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
for (t = 0; t < mesh->mNumVertices; ++t) { for (t = 0; t < mesh->mNumVertices; ++t) {
struct aiVector3D tmp = mesh->mVertices[t]; struct aiVector3D tmp = mesh->mVertices[t];
aiTransformVecByMatrix4(&tmp,trafo); aiTransformVecByMatrix4(&tmp,trafo);
min->x = aisgl_min(min->x,tmp.x); min->x = aisgl_min(min->x,tmp.x);
min->y = aisgl_min(min->y,tmp.y); min->y = aisgl_min(min->y,tmp.y);
min->z = aisgl_min(min->z,tmp.z); min->z = aisgl_min(min->z,tmp.z);
max->x = aisgl_max(max->x,tmp.x); max->x = aisgl_max(max->x,tmp.x);
max->y = aisgl_max(max->y,tmp.y); max->y = aisgl_max(max->y,tmp.y);
max->z = aisgl_max(max->z,tmp.z); max->z = aisgl_max(max->z,tmp.z);
} }
} }
for (n = 0; n < nd->mNumChildren; ++n) { for (n = 0; n < nd->mNumChildren; ++n) {
get_bounding_box_for_node(nd->mChildren[n],min,max,trafo); get_bounding_box_for_node(nd->mChildren[n],min,max,trafo);
} }
*trafo = prev; *trafo = prev;
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void get_bounding_box (struct aiVector3D* min, struct aiVector3D* max) void get_bounding_box (struct aiVector3D* min, struct aiVector3D* max)
{ {
struct aiMatrix4x4 trafo; struct aiMatrix4x4 trafo;
aiIdentityMatrix4(&trafo); aiIdentityMatrix4(&trafo);
min->x = min->y = min->z = 1e10f; min->x = min->y = min->z = 1e10f;
max->x = max->y = max->z = -1e10f; max->x = max->y = max->z = -1e10f;
get_bounding_box_for_node(scene->mRootNode,min,max,&trafo); get_bounding_box_for_node(scene->mRootNode,min,max,&trafo);
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void color4_to_float4(const struct aiColor4D *c, float f[4]) void color4_to_float4(const struct aiColor4D *c, float f[4])
{ {
f[0] = c->r; f[0] = c->r;
f[1] = c->g; f[1] = c->g;
f[2] = c->b; f[2] = c->b;
f[3] = c->a; f[3] = c->a;
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void set_float4(float f[4], float a, float b, float c, float d) void set_float4(float f[4], float a, float b, float c, float d)
{ {
f[0] = a; f[0] = a;
f[1] = b; f[1] = b;
f[2] = c; f[2] = c;
f[3] = d; f[3] = d;
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void apply_material(const struct aiMaterial *mtl) void apply_material(const struct aiMaterial *mtl)
{ {
float c[4]; float c[4];
GLenum fill_mode; GLenum fill_mode;
int ret1, ret2; int ret1, ret2;
struct aiColor4D diffuse; struct aiColor4D diffuse;
struct aiColor4D specular; struct aiColor4D specular;
struct aiColor4D ambient; struct aiColor4D ambient;
struct aiColor4D emission; struct aiColor4D emission;
float shininess, strength; float shininess, strength;
int two_sided; int two_sided;
int wireframe; int wireframe;
unsigned int max; unsigned int max;
set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f); set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse)) if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
color4_to_float4(&diffuse, c); color4_to_float4(&diffuse, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f); set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular)) if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular))
color4_to_float4(&specular, c); color4_to_float4(&specular, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f); set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient)) if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient))
color4_to_float4(&ambient, c); color4_to_float4(&ambient, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, c); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, c);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f); set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission)) if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission))
color4_to_float4(&emission, c); color4_to_float4(&emission, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, c); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, c);
max = 1; max = 1;
ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max); ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max);
if(ret1 == AI_SUCCESS) { if(ret1 == AI_SUCCESS) {
max = 1; max = 1;
ret2 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max); ret2 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max);
if(ret2 == AI_SUCCESS) if(ret2 == AI_SUCCESS)
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength);
else else
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
} }
else { else {
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f);
set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f); set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
} }
max = 1; max = 1;
if(AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max)) if(AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max))
fill_mode = wireframe ? GL_LINE : GL_FILL; fill_mode = wireframe ? GL_LINE : GL_FILL;
else else
fill_mode = GL_FILL; fill_mode = GL_FILL;
glPolygonMode(GL_FRONT_AND_BACK, fill_mode); glPolygonMode(GL_FRONT_AND_BACK, fill_mode);
max = 1; max = 1;
if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided) if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided)
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
else else
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void recursive_render (const struct aiScene *sc, const struct aiNode* nd) void recursive_render (const struct aiScene *sc, const struct aiNode* nd)
{ {
unsigned int i; unsigned int i;
unsigned int n = 0, t; unsigned int n = 0, t;
struct aiMatrix4x4 m = nd->mTransformation; struct aiMatrix4x4 m = nd->mTransformation;
/* update transform */ /* update transform */
aiTransposeMatrix4(&m); aiTransposeMatrix4(&m);
glPushMatrix(); glPushMatrix();
glMultMatrixf((float*)&m); glMultMatrixf((float*)&m);
/* draw all meshes assigned to this node */ /* draw all meshes assigned to this node */
for (; n < nd->mNumMeshes; ++n) { for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]]; const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
apply_material(sc->mMaterials[mesh->mMaterialIndex]); apply_material(sc->mMaterials[mesh->mMaterialIndex]);
if(mesh->mNormals == NULL) { if(mesh->mNormals == NULL) {
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
} else { } else {
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
} }
for (t = 0; t < mesh->mNumFaces; ++t) { for (t = 0; t < mesh->mNumFaces; ++t) {
const struct aiFace* face = &mesh->mFaces[t]; const struct aiFace* face = &mesh->mFaces[t];
GLenum face_mode; GLenum face_mode;
switch(face->mNumIndices) { switch(face->mNumIndices) {
case 1: face_mode = GL_POINTS; break; case 1: face_mode = GL_POINTS; break;
case 2: face_mode = GL_LINES; break; case 2: face_mode = GL_LINES; break;
case 3: face_mode = GL_TRIANGLES; break; case 3: face_mode = GL_TRIANGLES; break;
default: face_mode = GL_POLYGON; break; default: face_mode = GL_POLYGON; break;
} }
glBegin(face_mode); glBegin(face_mode);
for(i = 0; i < face->mNumIndices; i++) { for(i = 0; i < face->mNumIndices; i++) {
int index = face->mIndices[i]; int index = face->mIndices[i];
if(mesh->mColors[0] != NULL) if(mesh->mColors[0] != NULL)
glColor4fv((GLfloat*)&mesh->mColors[0][index]); glColor4fv((GLfloat*)&mesh->mColors[0][index]);
if(mesh->mNormals != NULL) if(mesh->mNormals != NULL)
glNormal3fv(&mesh->mNormals[index].x); glNormal3fv(&mesh->mNormals[index].x);
glVertex3fv(&mesh->mVertices[index].x); glVertex3fv(&mesh->mVertices[index].x);
} }
glEnd(); glEnd();
} }
} }
/* draw all children */ /* draw all children */
for (n = 0; n < nd->mNumChildren; ++n) { for (n = 0; n < nd->mNumChildren; ++n) {
recursive_render(sc, nd->mChildren[n]); recursive_render(sc, nd->mChildren[n]);
} }
glPopMatrix(); glPopMatrix();
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void do_motion (void) void do_motion (void)
{ {
static GLint prev_time = 0; static GLint prev_time = 0;
static GLint prev_fps_time = 0; static GLint prev_fps_time = 0;
static int frames = 0; static int frames = 0;
int time = glutGet(GLUT_ELAPSED_TIME); int time = glutGet(GLUT_ELAPSED_TIME);
angle += (time-prev_time)*0.01; angle += (time-prev_time)*0.01;
prev_time = time; prev_time = time;
frames += 1; frames += 1;
if ((time - prev_fps_time) > 1000) /* update every seconds */ if ((time - prev_fps_time) > 1000) /* update every seconds */
{ {
int current_fps = frames * 1000 / (time - prev_fps_time); int current_fps = frames * 1000 / (time - prev_fps_time);
printf("%d fps\n", current_fps); printf("%d fps\n", current_fps);
frames = 0; frames = 0;
prev_fps_time = time; prev_fps_time = time;
} }
glutPostRedisplay (); glutPostRedisplay ();
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void display(void) void display(void)
{ {
float tmp; float tmp;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
gluLookAt(0.f,0.f,3.f,0.f,0.f,-5.f,0.f,1.f,0.f); gluLookAt(0.f,0.f,3.f,0.f,0.f,-5.f,0.f,1.f,0.f);
/* rotate it around the y axis */ /* rotate it around the y axis */
glRotatef(angle,0.f,1.f,0.f); glRotatef(angle,0.f,1.f,0.f);
/* scale the whole asset to fit into our view frustum */ /* scale the whole asset to fit into our view frustum */
tmp = scene_max.x-scene_min.x; tmp = scene_max.x-scene_min.x;
tmp = aisgl_max(scene_max.y - scene_min.y,tmp); tmp = aisgl_max(scene_max.y - scene_min.y,tmp);
tmp = aisgl_max(scene_max.z - scene_min.z,tmp); tmp = aisgl_max(scene_max.z - scene_min.z,tmp);
tmp = 1.f / tmp; tmp = 1.f / tmp;
glScalef(tmp, tmp, tmp); glScalef(tmp, tmp, tmp);
/* center the model */ /* center the model */
glTranslatef( -scene_center.x, -scene_center.y, -scene_center.z ); glTranslatef( -scene_center.x, -scene_center.y, -scene_center.z );
/* if the display list has not been made yet, create a new one and /* if the display list has not been made yet, create a new one and
fill it with scene contents */ fill it with scene contents */
if(scene_list == 0) { if(scene_list == 0) {
scene_list = glGenLists(1); scene_list = glGenLists(1);
glNewList(scene_list, GL_COMPILE); glNewList(scene_list, GL_COMPILE);
/* now begin at the root node of the imported data and traverse /* now begin at the root node of the imported data and traverse
the scenegraph by multiplying subsequent local transforms the scenegraph by multiplying subsequent local transforms
together on GL's matrix stack. */ together on GL's matrix stack. */
recursive_render(scene, scene->mRootNode); recursive_render(scene, scene->mRootNode);
glEndList(); glEndList();
} }
glCallList(scene_list); glCallList(scene_list);
glutSwapBuffers(); glutSwapBuffers();
do_motion(); do_motion();
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
int loadasset (const char* path) int loadasset (const char* path)
{ {
/* we are taking one of the postprocessing presets to avoid /* we are taking one of the postprocessing presets to avoid
spelling out 20+ single postprocessing flags here. */ spelling out 20+ single postprocessing flags here. */
scene = aiImportFile(path,aiProcessPreset_TargetRealtime_MaxQuality); scene = aiImportFile(path,aiProcessPreset_TargetRealtime_MaxQuality);
if (scene) { if (scene) {
get_bounding_box(&scene_min,&scene_max); get_bounding_box(&scene_min,&scene_max);
scene_center.x = (scene_min.x + scene_max.x) / 2.0f; scene_center.x = (scene_min.x + scene_max.x) / 2.0f;
scene_center.y = (scene_min.y + scene_max.y) / 2.0f; scene_center.y = (scene_min.y + scene_max.y) / 2.0f;
scene_center.z = (scene_min.z + scene_max.z) / 2.0f; scene_center.z = (scene_min.z + scene_max.z) / 2.0f;
return 0; return 0;
} }
return 1; return 1;
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct aiLogStream stream; struct aiLogStream stream;
glutInitWindowSize(900,600); glutInitWindowSize(900,600);
glutInitWindowPosition(100,100); glutInitWindowPosition(100,100);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInit(&argc, argv); glutInit(&argc, argv);
glutCreateWindow("Assimp - Very simple OpenGL sample"); glutCreateWindow("Assimp - Very simple OpenGL sample");
glutDisplayFunc(display); glutDisplayFunc(display);
glutReshapeFunc(reshape); glutReshapeFunc(reshape);
/* get a handle to the predefined STDOUT log stream and attach /* get a handle to the predefined STDOUT log stream and attach
it to the logging system. It remains active for all further it to the logging system. It remains active for all further
calls to aiImportFile(Ex) and aiApplyPostProcessing. */ calls to aiImportFile(Ex) and aiApplyPostProcessing. */
stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL); stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
aiAttachLogStream(&stream); aiAttachLogStream(&stream);
/* ... same procedure, but this stream now writes the /* ... same procedure, but this stream now writes the
log messages to assimp_log.txt */ log messages to assimp_log.txt */
stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt"); stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt");
aiAttachLogStream(&stream); aiAttachLogStream(&stream);
/* the model name can be specified on the command line. If none /* the model name can be specified on the command line. If none
is specified, we try to locate one of the more expressive test is specified, we try to locate one of the more expressive test
models from the repository (/models-nonbsd may be missing in models from the repository (/models-nonbsd may be missing in
some distributions so we need a fallback from /models!). */ some distributions so we need a fallback from /models!). */
if( 0 != loadasset( argc >= 2 ? argv[1] : "../../test/models-nonbsd/X/dwarf.x")) { if( 0 != loadasset( argc >= 2 ? argv[1] : "../../test/models-nonbsd/X/dwarf.x")) {
if( argc != 1 || (0 != loadasset( "../../../../test/models-nonbsd/X/dwarf.x") && 0 != loadasset( "../../test/models/X/Testwuson.X"))) { if( argc != 1 || (0 != loadasset( "../../../../test/models-nonbsd/X/dwarf.x") && 0 != loadasset( "../../test/models/X/Testwuson.X"))) {
return -1; return -1;
} }
} }
glClearColor(0.1f,0.1f,0.1f,1.f); glClearColor(0.1f,0.1f,0.1f,1.f);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); /* Uses default lighting parameters */ glEnable(GL_LIGHT0); /* Uses default lighting parameters */
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
/* XXX docs say all polygons are emitted CCW, but tests show that some aren't. */ /* XXX docs say all polygons are emitted CCW, but tests show that some aren't. */
if(getenv("MODEL_IS_BROKEN")) if(getenv("MODEL_IS_BROKEN"))
glFrontFace(GL_CW); glFrontFace(GL_CW);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glutGet(GLUT_ELAPSED_TIME); glutGet(GLUT_ELAPSED_TIME);
glutMainLoop(); glutMainLoop();
/* cleanup - calling 'aiReleaseImport' is important, as the library /* cleanup - calling 'aiReleaseImport' is important, as the library
keeps internal resources until the scene is freed again. Not keeps internal resources until the scene is freed again. Not
doing so can cause severe resource leaking. */ doing so can cause severe resource leaking. */
aiReleaseImport(scene); aiReleaseImport(scene);
/* We added a log stream to the library, it's our job to disable it /* We added a log stream to the library, it's our job to disable it
again. This will definitely release the last resources allocated again. This will definitely release the last resources allocated
by Assimp.*/ by Assimp.*/
aiDetachAllLogStreams(); aiDetachAllLogStreams();
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,111 +1,111 @@
# ============================================================================== # ==============================================================================
# List of IFC structures needed by Assimp # List of IFC structures needed by Assimp
# ============================================================================== # ==============================================================================
# use genentitylist.sh to update this list # use genentitylist.sh to update this list
# This machine-generated list is not complete, it lacks many intermediate # This machine-generated list is not complete, it lacks many intermediate
# classes in the inheritance hierarchy. Those are magically augmented by the # classes in the inheritance hierarchy. Those are magically augmented by the
# code generator. Also, the names of all used entities need to be present # code generator. Also, the names of all used entities need to be present
# in the source code for this to work. # in the source code for this to work.
IfcAnnotation IfcAnnotation
IfcArbitraryClosedProfileDef IfcArbitraryClosedProfileDef
IfcArbitraryOpenProfileDef IfcArbitraryOpenProfileDef
IfcArbitraryProfileDefWithVoids IfcArbitraryProfileDefWithVoids
IfcAxis1Placement IfcAxis1Placement
IfcAxis2Placement IfcAxis2Placement
IfcAxis2Placement2D IfcAxis2Placement2D
IfcAxis2Placement3D IfcAxis2Placement3D
IfcBooleanClippingResult IfcBooleanClippingResult
IfcBooleanResult IfcBooleanResult
IfcBoundedCurve IfcBoundedCurve
IfcBoundingBox IfcBoundingBox
IfcBSplineCurve IfcBSplineCurve
IfcBuilding IfcBuilding
IfcCartesianPoint IfcCartesianPoint
IfcCartesianTransformationOperator IfcCartesianTransformationOperator
IfcCartesianTransformationOperator3D IfcCartesianTransformationOperator3D
IfcCartesianTransformationOperator3DnonUniform IfcCartesianTransformationOperator3DnonUniform
IfcCircle IfcCircle
IfcCircleHollowProfileDef IfcCircleHollowProfileDef
IfcCircleProfileDef IfcCircleProfileDef
IfcClosedShell IfcClosedShell
IfcColourOrFactor IfcColourOrFactor
IfcColourRgb IfcColourRgb
IfcCompositeCurve IfcCompositeCurve
IfcCompositeCurveSegment IfcCompositeCurveSegment
IfcConic IfcConic
IfcConnectedFaceSet IfcConnectedFaceSet
IfcConversionBasedUnit IfcConversionBasedUnit
IfcCurve IfcCurve
IfcDirection IfcDirection
IfcDoor IfcDoor
IfcEllipse IfcEllipse
IfcExtrudedAreaSolid IfcExtrudedAreaSolid
IfcFace IfcFace
IfcFaceBasedSurfaceModel IfcFaceBasedSurfaceModel
IfcFaceBound IfcFaceBound
IfcFaceOuterBound IfcFaceOuterBound
IfcFeatureElementSubtraction IfcFeatureElementSubtraction
IfcGeometricRepresentationContext IfcGeometricRepresentationContext
IfcGeometricRepresentationItem IfcGeometricRepresentationItem
IfcHalfSpaceSolid IfcHalfSpaceSolid
IfcLine IfcLine
IfcLocalPlacement IfcLocalPlacement
IfcManifoldSolidBrep IfcManifoldSolidBrep
IfcMappedItem IfcMappedItem
IfcMeasureWithUnit IfcMeasureWithUnit
IfcNamedUnit IfcNamedUnit
IfcObjectDefinition IfcObjectDefinition
IfcObjectPlacement IfcObjectPlacement
IfcOpeningElement IfcOpeningElement
IfcParameterizedProfileDef IfcParameterizedProfileDef
IfcPlane IfcPlane
IfcPolygonalBoundedHalfSpace IfcPolygonalBoundedHalfSpace
IfcPolyline IfcPolyline
IfcPolyLoop IfcPolyLoop
IfcPresentationStyleAssignment IfcPresentationStyleAssignment
IfcPresentationStyleSelect IfcPresentationStyleSelect
IfcProduct IfcProduct
IfcProductRepresentation IfcProductRepresentation
IfcProfileDef IfcProfileDef
IfcProject IfcProject
IfcRectangleProfileDef IfcRectangleProfileDef
IfcRelAggregates IfcRelAggregates
IfcRelContainedInSpatialStructure IfcRelContainedInSpatialStructure
IfcRelFillsElement IfcRelFillsElement
IfcRelVoidsElement IfcRelVoidsElement
IfcRepresentation IfcRepresentation
IfcRepresentationContext IfcRepresentationContext
IfcRepresentationItem IfcRepresentationItem
IfcRepresentationMap IfcRepresentationMap
IfcRevolvedAreaSolid IfcRevolvedAreaSolid
IfcShell IfcShell
IfcShellBasedSurfaceModel IfcShellBasedSurfaceModel
IfcSite IfcSite
IfcSIUnit IfcSIUnit
IfcSomething IfcSomething
IfcSpace IfcSpace
IfcSpatialStructureElement IfcSpatialStructureElement
IfcSpatialStructureElements IfcSpatialStructureElements
IfcStyledItem IfcStyledItem
IfcSurfaceStyle IfcSurfaceStyle
IfcSurfaceStyleElementSelect IfcSurfaceStyleElementSelect
IfcSurfaceStyleRendering IfcSurfaceStyleRendering
IfcSurfaceStyleShading IfcSurfaceStyleShading
IfcSurfaceStyleWithTextures IfcSurfaceStyleWithTextures
IfcSweptAreaSolid IfcSweptAreaSolid
IfcSweptDiskSolid IfcSweptDiskSolid
IfcTopologicalRepresentationItem IfcTopologicalRepresentationItem
IfcTrimmedCurve IfcTrimmedCurve
IfcUnit IfcUnit
IfcUnitAssignment IfcUnitAssignment
IfcVector IfcVector
IfcIShapeProfileDef IfcIShapeProfileDef
IfcPropertyListValue IfcPropertyListValue
IfcRelDefinesByProperties IfcRelDefinesByProperties
IfcPropertySet IfcPropertySet
IfcPropertySingleValue IfcPropertySingleValue
IfcProperty IfcProperty
IfcComplexProperty IfcComplexProperty
IfcElementQuantity IfcElementQuantity

View File

@ -24,6 +24,7 @@ SET( TEST_SRCS
unit/utGenNormals.cpp unit/utGenNormals.cpp
unit/utImporter.cpp unit/utImporter.cpp
unit/utImproveCacheLocality.cpp unit/utImproveCacheLocality.cpp
unit/utIOSystem.cpp
unit/utJoinVertices.cpp unit/utJoinVertices.cpp
unit/utLimitBoneWeights.cpp unit/utLimitBoneWeights.cpp
unit/utMaterialSystem.cpp unit/utMaterialSystem.cpp

View File

@ -1,18 +1,18 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008. Downloaded 4th November 2008.
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "

View File

@ -1,18 +1,18 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "

View File

@ -1,15 +1,15 @@
Jeep designed, modelled and skinned by me, Psionic Jeep designed, modelled and skinned by me, Psionic
FREE for use however you like, credits are appreciated!!! FREE for use however you like, credits are appreciated!!!
It was modelled in Milkshape 3D and includes the MS3D files oriented for X or B3D format (BlitzBasic 3D), its 2032 polys with a 512x512 jpg texture map. There are two skin variations plus a UV template to help out if you want to create your own skin variations. It was modelled in Milkshape 3D and includes the MS3D files oriented for X or B3D format (BlitzBasic 3D), its 2032 polys with a 512x512 jpg texture map. There are two skin variations plus a UV template to help out if you want to create your own skin variations.
I'd love to see a few screenshots of it being used in-game so feel free to stop by my site and maybe drop by my forums and show us all what your doing with it!!!!!!! I'd love to see a few screenshots of it being used in-game so feel free to stop by my site and maybe drop by my forums and show us all what your doing with it!!!!!!!
Check out more of my work at:- Check out more of my work at:-
http://xu1productions.com/3dstudio/index.html - 3D Game Resources http://xu1productions.com/3dstudio/index.html - 3D Game Resources
http://www.psionicdesign.com - My Main 2D/3D Digital Art site http://www.psionicdesign.com - My Main 2D/3D Digital Art site
Psionic 2002 Psionic 2002

View File

@ -1,18 +1,18 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "

View File

@ -1,18 +1,18 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "

View File

@ -1,12 +1,12 @@
hello! hello!
fell free to use the object...so do what U want! fell free to use the object...so do what U want!
& sent me your pictures...:-) & sent me your pictures...:-)
for commercial use, contact me! for commercial use, contact me!
http://www.elektrobar.com/lux/ http://www.elektrobar.com/lux/
or mail to: or mail to:
lux@elektrobar.com lux@elektrobar.com
have fun.....VIRLUX have fun.....VIRLUX

View File

@ -1,25 +1,25 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "
INFO INFO
==== ====
CONVERTED FROM 3DS TO ASE WITH AC3D CONVERTED FROM 3DS TO ASE WITH AC3D

View File

@ -1,24 +1,24 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "
INFO INFO
==== ====
CONVERTED FROM 3DS TO ASE WITH AC3D CONVERTED FROM 3DS TO ASE WITH AC3D

View File

@ -1,51 +1,51 @@
Dwarf lowpoly model Pack Dwarf lowpoly model Pack
Copyright 2004, Psionic Design Copyright 2004, Psionic Design
e-mail: psionic@blueyonder.co.uk e-mail: psionic@blueyonder.co.uk
Used with permission. Used with permission.
INSTALLATION INSTRUCTIONS: INSTALLATION INSTRUCTIONS:
To install, simply unzip to your hard drive with the "Use Folder Names" option turned on. And that's it you're ready to go! To install, simply unzip to your hard drive with the "Use Folder Names" option turned on. And that's it you're ready to go!
USAGE INFORMATION: USAGE INFORMATION:
Each zip contains the models, textures and animation info for that particular format! Each zip contains the models, textures and animation info for that particular format!
Please Read the "animationinfo.txt" file included in each zip for the exact frames of animation to use Please Read the "animationinfo.txt" file included in each zip for the exact frames of animation to use
Credits to me "Psionic" are really appreciated but are not essential ;-) Credits to me "Psionic" are really appreciated but are not essential ;-)
Any questions, screenshots of him in use etc drop by my site or email me at:- Any questions, screenshots of him in use etc drop by my site or email me at:-
website: http://www.psionic3d.co.uk website: http://www.psionic3d.co.uk
email: psionic@blueyonder.co.uk email: psionic@blueyonder.co.uk
WHAT'S INCLUDED IN THE ZIP: WHAT'S INCLUDED IN THE ZIP:
ReadMe.txt - This file ReadMe.txt - This file
b3d.zip - Blitz 3D Format models and textures b3d.zip - Blitz 3D Format models and textures
ms3d.zip - Milkshape 3D Format models and textures ms3d.zip - Milkshape 3D Format models and textures
x.zip - DarkBasic Direct X 8 Format models and textures x.zip - DarkBasic Direct X 8 Format models and textures
RESTRICTIONS: RESTRICTIONS:
This model pack is available for use in freeware, shareware, commercial games/software with the following restrictions:- This model pack is available for use in freeware, shareware, commercial games/software with the following restrictions:-
**You may not sell/re-sell this model pack or claim it as your own. **You may not sell/re-sell this model pack or claim it as your own.
***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent. ***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent.
Psi Psi
http://www.psionic3d.co.uk http://www.psionic3d.co.uk

View File

@ -1,11 +1,11 @@
turtle1.b3d turtle1.b3d
Copyright 2004, Psionic Design Copyright 2004, Psionic Design
e-mail: psionic@blueyonder.co.uk e-mail: psionic@blueyonder.co.uk
Used with permission. Used with permission.
RESTRICTIONS: RESTRICTIONS:
This model pack is available for use in freeware, shareware, commercial games/software with the following restrictions:- This model pack is available for use in freeware, shareware, commercial games/software with the following restrictions:-
**You may not sell/re-sell this model pack or claim it as your own. **You may not sell/re-sell this model pack or claim it as your own.
***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent. ***You may not redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent.

View File

@ -1,31 +1,31 @@
---------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------
TITLE : Bob, MD5 character source file TITLE : Bob, MD5 character source file
AUTHOR : Ken Beyer (kat) AUTHOR : Ken Beyer (kat)
EMAIL ADDRESS : info@katsbits.com EMAIL ADDRESS : info@katsbits.com
HOMEPAGE URL : http://www.katsbits.com HOMEPAGE URL : http://www.katsbits.com
MODEL NAME/s MODEL NAME/s
Zip file contains *.blend source file and TGA texture assets for MD5 format testing. Zip file contains *.blend source file and TGA texture assets for MD5 format testing.
Files and media are provided "as is" without any explicit or implied warranty of fuctionality. Files and media are provided "as is" without any explicit or implied warranty of fuctionality.
DISTRIBUTION DISTRIBUTION
Copyright © 2009 KatsBits. Distribution MUST include this readme and authorship attribution. Copyright © 2009 KatsBits. Distribution MUST include this readme and authorship attribution.
Commercial use is permitted with written licensed permission. Commercial use is permitted with written licensed permission.
---------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------
Files: Files:
- Bob.md5mesh - Bob.md5mesh
- Bob.md5anim - Bob.md5anim
- Bob.blend - Bob.blend
- ./*.png - ./*.png
Changes: Changes:
- converted all tga's to png, updated .blend and .md5mesh accordingly - converted all tga's to png, updated .blend and .md5mesh accordingly
- removed absolute texture paths from the md5mesh file - removed absolute texture paths from the md5mesh file
- minor downscaling of all textures to fit in less bytes - minor downscaling of all textures to fit in less bytes

View File

@ -1,23 +1,23 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "
INFO INFO
==== ====
COnverted from 3ds to DXF with Ac3D COnverted from 3ds to DXF with Ac3D

View File

@ -1,4 +1,4 @@
Good IFC test cases Good IFC test cases
=================== ===================
http://www.iai.fzk.de/www-extern/index.php?id=1135 http://www.iai.fzk.de/www-extern/index.php?id=1135

View File

@ -1,11 +1,11 @@
This skybox is basing on a skydome texture from This skybox is basing on a skydome texture from
http://mikepan.homeip.net/earth http://mikepan.homeip.net/earth
Downloaded November 22th, 08 Downloaded November 22th, 08
Distribution note: Distribution note:
"These royalty-free skydome textures work best when applied to a sphere or hemisphere" "These royalty-free skydome textures work best when applied to a sphere or hemisphere"
Thanks for your great work! Thanks for your great work!

View File

@ -1,31 +1,31 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
"These 3d models are contributed by John Hoffman and are based on "These 3d models are contributed by John Hoffman and are based on
characters from a cartoon show called "Jayce and the wheel warriors" characters from a cartoon show called "Jayce and the wheel warriors"
(except the marauder) John's site: http://www3.sympatico.ca/john.hoffman" (except the marauder) John's site: http://www3.sympatico.ca/john.hoffman"
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "
INFO INFO
==== ====
These files belong to the QuickDraw model in the LWS folder - they are referenced These files belong to the QuickDraw model in the LWS folder - they are referenced
and loaded into the LWS scene. and loaded into the LWS scene.

View File

@ -1,24 +1,24 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "
INFO INFO
==== ====
CONVERTED FROM 3DS TO LWO2 WITH AC3D CONVERTED FROM 3DS TO LWO2 WITH AC3D

View File

@ -1,15 +1,15 @@
From http://telias.free.fr From http://telias.free.fr
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, lightwave and md2 format. Also a great collection of textures to use in your favorite modelling and rendering program. Free the models is a site that offers free 3d models in 3ds, bryce, poser, lightwave and md2 format. Also a great collection of textures to use in your favorite modelling and rendering program.
All the content is free for any use. All the content is free for any use.
In the future more 3d formats will be added and some other sections such as wallpapers, 3d screensavers, 3d coding source code and tutorials. In the future more 3d formats will be added and some other sections such as wallpapers, 3d screensavers, 3d coding source code and tutorials.
" "
CHANGES: CHANGES:
Paths have been modified Paths have been modified

View File

@ -1,18 +1,18 @@
===================================================================== =====================================================================
From http://telias.free.fr From http://telias.free.fr
Model copyright: Elias Tsiantas Model copyright: Elias Tsiantas
===================================================================== =====================================================================
Downloaded 4th November 2008 (Obama ftw!). Downloaded 4th November 2008 (Obama ftw!).
Notice found on the page: Notice found on the page:
" "
Free the models is a site that offers free 3d models in 3ds, bryce, poser, Free the models is a site that offers free 3d models in 3ds, bryce, poser,
lightwave and md2 format. Also a great collection of textures to use in lightwave and md2 format. Also a great collection of textures to use in
your favorite modelling and rendering program. All the content is free your favorite modelling and rendering program. All the content is free
for any use. In the future more 3d formats will be added and some other for any use. In the future more 3d formats will be added and some other
sections such as wallpapers, 3d screensavers, 3d coding source code and sections such as wallpapers, 3d screensavers, 3d coding source code and
tutorials. tutorials.
" "

View File

@ -1,26 +1,26 @@
------------------------------------------------------------------------- -------------------------------------------------------------------------
TITLE : kt_kubalwagon TITLE : kt_kubalwagon
AUTHOR : ken 'kat' beyer AUTHOR : ken 'kat' beyer
EMAIL ADDRESS : cpdt@telinco.co.uk EMAIL ADDRESS : cpdt@telinco.co.uk
HOMEPAGE URL : http://www.quake3bits.co.uk HOMEPAGE URL : http://www.quake3bits.co.uk
NUMBER OF MODELS : 1 NUMBER OF MODELS : 1
SHADER SCRIPTS : yes - included SHADER SCRIPTS : yes - included
------------------ ------------------
* MODEL NAME/s * * MODEL NAME/s *
[model details below] [model details below]
european_fnt_v2.md3 european_fnt_v2.md3
euro_rnt_2.tga (alpha'd steering wheel) euro_rnt_2.tga (alpha'd steering wheel)
european_fnt.tga european_fnt.tga
------------------ ------------------
CREDITS CREDITS
ID software, eskimo roll, EMSIPE, QkenneyQ ID software, eskimo roll, EMSIPE, QkenneyQ
DISTRIBUTION DISTRIBUTION
as long as this readme is included...! as long as this readme is included...!
-------------------------------------------------------------------------- --------------------------------------------------------------------------

View File

@ -1,26 +1,26 @@
------------------------------------------------------------------------- -------------------------------------------------------------------------
TITLE : kt_watercan TITLE : kt_watercan
AUTHOR : ken 'kat' beyer AUTHOR : ken 'kat' beyer
EMAIL ADDRESS : cpdt@telinco.co.uk EMAIL ADDRESS : cpdt@telinco.co.uk
HOMEPAGE URL : http://www.quake3bits.co.uk HOMEPAGE URL : http://www.quake3bits.co.uk
NUMBER OF MODELS : 2 NUMBER OF MODELS : 2
SHADER SCRIPTS : n/a SHADER SCRIPTS : n/a
------------------ ------------------
* MODEL NAME/s * * MODEL NAME/s *
[model details below] [model details below]
watercan.md3 watercan.md3
watercan_dmg.md3 (dmg='damaged') watercan_dmg.md3 (dmg='damaged')
water_can.tga 256x128 water_can.tga 256x128
------------------ ------------------
CREDITS CREDITS
ID software, eskimo roll, EMSIPE, QkenneyQ ID software, eskimo roll, EMSIPE, QkenneyQ
DISTRIBUTION DISTRIBUTION
as long as this readme is included...! as long as this readme is included...!
-------------------------------------------------------------------------- --------------------------------------------------------------------------

View File

@ -1,8 +1,8 @@
License: Creative Commons License: Creative Commons
- Remix - Remix
- Share alike - Share alike
- Attribution Author: zphr (Christian Lenke) - Attribution Author: zphr (Christian Lenke)

Some files were not shown because too many files have changed in this diff Show More