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
"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
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 "
#define AI_AC_GET_STRING(out) \
if (*buffer == '\0') { \
throw DeadlyImportError("AC3D: Unexpected EOF in string"); \
} \
++buffer; \
const char* sz = buffer; \
while ('\"' != *buffer) \
@ -293,7 +296,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
SkipSpaces(&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");
}
obj.vertices.reserve(t);
@ -349,8 +352,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
{
if(!GetNextLine())
{
DefaultLogger::get()->error("AC3D: Unexpected EOF: surface is incomplete");
break;
throw DeadlyImportError("AC3D: Unexpected EOF: surface is incomplete");
}
if (TokenMatch(buffer,"mat",3))
{
@ -585,9 +587,19 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
// allocate storage for vertices and normals
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];
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];
unsigned int cur = 0;

View File

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

View File

@ -1,23 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
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
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
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
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
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
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
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
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
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
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
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
DEALINGS IN THE SOFTWARE.

View File

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

View File

@ -1,82 +1,82 @@
/* DEPRECATED! - use code/TinyFormatter.h instead.
*
*
* */
#ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED
#define AI_BOOST_FORMAT_DUMMY_INCLUDED
#if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST)
#include <string>
#include <vector>
#include <sstream>
namespace boost
{
class format
{
public:
format (const std::string& _d)
: d(_d)
{
}
template <typename T>
format& operator % (T in)
{
// XXX add replacement for boost::lexical_cast?
std::ostringstream ss;
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());
return *this;
}
operator std::string () const {
std::string res; // pray for NRVO to kick in
size_t start = 0, last = 0;
std::vector<std::string>::const_iterator chunkin = chunks.begin();
for ( start = d.find('%');start != std::string::npos; start = d.find('%',last)) {
res += d.substr(last,start-last);
last = start+2;
if (d[start+1] == '%') {
res += "%";
continue;
}
if (chunkin == chunks.end()) {
break;
}
res += *chunkin++;
}
res += d.substr(last);
return res;
}
private:
std::string d;
std::vector<std::string> chunks;
};
inline std::string str(const std::string& s) {
return s;
}
}
#else
# error "format.h was already included"
#endif //
#endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED
/* DEPRECATED! - use code/TinyFormatter.h instead.
*
*
* */
#ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED
#define AI_BOOST_FORMAT_DUMMY_INCLUDED
#if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST)
#include <string>
#include <vector>
#include <sstream>
namespace boost
{
class format
{
public:
format (const std::string& _d)
: d(_d)
{
}
template <typename T>
format& operator % (T in)
{
// XXX add replacement for boost::lexical_cast?
std::ostringstream ss;
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());
return *this;
}
operator std::string () const {
std::string res; // pray for NRVO to kick in
size_t start = 0, last = 0;
std::vector<std::string>::const_iterator chunkin = chunks.begin();
for ( start = d.find('%');start != std::string::npos; start = d.find('%',last)) {
res += d.substr(last,start-last);
last = start+2;
if (d[start+1] == '%') {
res += "%";
continue;
}
if (chunkin == chunks.end()) {
break;
}
res += *chunkin++;
}
res += d.substr(last);
return res;
}
private:
std::string d;
std::vector<std::string> chunks;
};
inline std::string str(const std::string& s) {
return s;
}
}
#else
# error "format.h was already included"
#endif //
#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
#ifndef __AI_BOOST_WORKAROUND_LEXICAL_CAST
#define __AI_BOOST_WORKAROUND_LEXICAL_CAST
#include <sstream>
namespace boost
{
/// A quick replacement for boost::lexical_cast - should work for all types a stringstream can handle
template <typename TargetType, typename SourceType>
TargetType lexical_cast( const SourceType& source)
{
std::stringstream stream;
TargetType result;
stream << source;
stream >> result;
return result;
}
} // namespace boost
#endif // __AI_BOOST_WORKAROUND_LEXICAL_CAST
/// A quick replacement for boost::lexical_cast for all the Boost haters out there
#ifndef __AI_BOOST_WORKAROUND_LEXICAL_CAST
#define __AI_BOOST_WORKAROUND_LEXICAL_CAST
#include <sstream>
namespace boost
{
/// A quick replacement for boost::lexical_cast - should work for all types a stringstream can handle
template <typename TargetType, typename SourceType>
TargetType lexical_cast( const SourceType& source)
{
std::stringstream stream;
TargetType result;
stream << source;
stream >> result;
return result;
}
} // namespace boost
#endif // __AI_BOOST_WORKAROUND_LEXICAL_CAST

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,283 +1,283 @@
// A very small replacement for boost::tuple
// (c) Alexander Gessler, 2008 [alexander.gessler@gmx.net]
#ifndef BOOST_TUPLE_INCLUDED
#define BOOST_TUPLE_INCLUDED
namespace boost {
namespace detail {
// Represents an empty tuple slot (up to 5 supported)
struct nulltype {};
// For readable error messages
struct tuple_component_idx_out_of_bounds;
// To share some code for the const/nonconst versions of the getters
template <bool b, typename T>
struct ConstIf {
typedef T t;
};
template <typename T>
struct ConstIf<true,T> {
typedef const T t;
};
// Predeclare some stuff
template <typename, unsigned, typename, bool, unsigned> struct value_getter;
// Helper to obtain the type of a tuple element
template <typename T, unsigned NIDX, typename TNEXT, unsigned N /*= 0*/>
struct type_getter {
typedef type_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type,N> next_elem_getter;
typedef typename next_elem_getter::type type;
};
template <typename T, unsigned NIDX, typename TNEXT >
struct type_getter <T,NIDX,TNEXT,NIDX> {
typedef T type;
};
// Base class for all explicit specializations of list_elem
template <typename T, unsigned NIDX, typename TNEXT >
struct list_elem_base {
// Store template parameters
typedef TNEXT next_type;
typedef T type;
static const unsigned nidx = NIDX;
};
// Represents an element in the tuple component list
template <typename T, unsigned NIDX, typename TNEXT >
struct list_elem : list_elem_base<T,NIDX,TNEXT>{
// Real members
T me;
TNEXT next;
// Get the value of a specific tuple element
template <unsigned N>
typename type_getter<T,NIDX,TNEXT,N>::type& get () {
value_getter <T,NIDX,TNEXT,false,N> s;
return s(*this);
}
// Get the value of a specific tuple element
template <unsigned N>
const typename type_getter<T,NIDX,TNEXT,N>::type& get () const {
value_getter <T,NIDX,TNEXT,true,N> s;
return s(*this);
}
// Explicit cast
template <typename T2, typename TNEXT2 >
operator list_elem<T2,NIDX,TNEXT2> () const {
list_elem<T2,NIDX,TNEXT2> ret;
ret.me = (T2)me;
ret.next = next;
return ret;
}
// Recursively compare two elements (last element returns always true)
bool operator == (const list_elem& s) const {
return (me == s.me && next == s.next);
}
};
// Represents a non-used tuple element - the very last element processed
template <typename TNEXT, unsigned NIDX >
struct list_elem<nulltype,NIDX,TNEXT> : list_elem_base<nulltype,NIDX,TNEXT> {
template <unsigned N, bool IS_CONST = true> struct value_getter {
/* just dummy members to produce readable error messages */
tuple_component_idx_out_of_bounds operator () (typename ConstIf<IS_CONST,list_elem>::t& me);
};
template <unsigned N> struct type_getter {
/* just dummy members to produce readable error messages */
typedef tuple_component_idx_out_of_bounds type;
};
// dummy
list_elem& operator = (const list_elem& /*other*/) {
return *this;
}
// dummy
bool operator == (const list_elem& other) {
return true;
}
};
// Represents the absolute end of the list
typedef list_elem<nulltype,0,int> list_end;
// 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
// partial specialization of a nested class of a non-specialized template
template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST, unsigned N>
struct value_getter {
// calling list_elem
typedef list_elem<T,NIDX,TNEXT> outer_elem;
// typedef for the getter for next element
typedef value_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type,
IS_CONST, N> next_value_getter;
typename ConstIf<IS_CONST,typename type_getter<T,NIDX,TNEXT,N>::type>::t&
operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) {
next_value_getter s;
return s(me.next);
}
};
template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST>
struct value_getter <T,NIDX,TNEXT,IS_CONST,NIDX> {
typedef list_elem<T,NIDX,TNEXT> outer_elem;
typename ConstIf<IS_CONST,T>::t& operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) {
return me.me;
}
};
}
// A very minimal implementation for up to 5 elements
template <typename T0 = detail::nulltype,
typename T1 = detail::nulltype,
typename T2 = detail::nulltype,
typename T3 = detail::nulltype,
typename T4 = detail::nulltype>
class tuple {
template <typename T0b,
typename T1b,
typename T2b,
typename T3b,
typename T4b >
friend class tuple;
private:
typedef detail::list_elem<T0,0,
detail::list_elem<T1,1,
detail::list_elem<T2,2,
detail::list_elem<T3,3,
detail::list_elem<T4,4,
detail::list_end > > > > > very_long;
very_long m;
public:
// Get a specific tuple element
template <unsigned N>
typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () {
return m.template get<N>();
}
// ... and the const version
template <unsigned N>
const typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () const {
return m.template get<N>();
}
// comparison operators
bool operator== (const tuple& other) const {
return m == other.m;
}
// ... and the other way round
bool operator!= (const tuple& other) const {
return !(m == other.m);
}
// cast to another tuple - all single elements must be convertible
template <typename T0b, typename T1b,typename T2b,typename T3b, typename T4b>
operator tuple <T0b,T1b,T2b,T3b,T4b> () const {
tuple <T0b,T1b,T2b,T3b,T4b> s;
s.m = (typename tuple <T0b,T1b,T2b,T3b,T4b>::very_long)m;
return s;
}
};
// Another way to access an element ...
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 (
tuple<T0,T1,T2,T3,T4>& m) {
return m.template get<N>();
}
// ... and the const version
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 (
const tuple<T0,T1,T2,T3,T4>& m) {
return m.template get<N>();
}
// Constructs a tuple with 5 elements
template <typename T0,typename T1,typename T2,typename T3,typename T4>
inline tuple <T0,T1,T2,T3,T4> make_tuple (const T0& t0,
const T1& t1,const T2& t2,const T3& t3,const T4& t4) {
tuple <T0,T1,T2,T3,T4> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
t.template get<2>() = t2;
t.template get<3>() = t3;
t.template get<4>() = t4;
return t;
}
// Constructs a tuple with 4 elements
template <typename T0,typename T1,typename T2,typename T3>
inline tuple <T0,T1,T2,T3> make_tuple (const T0& t0,
const T1& t1,const T2& t2,const T3& t3) {
tuple <T0,T1,T2,T3> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
t.template get<2>() = t2;
t.template get<3>() = t3;
return t;
}
// Constructs a tuple with 3 elements
template <typename T0,typename T1,typename T2>
inline tuple <T0,T1,T2> make_tuple (const T0& t0,
const T1& t1,const T2& t2) {
tuple <T0,T1,T2> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
t.template get<2>() = t2;
return t;
}
// Constructs a tuple with 2 elements
template <typename T0,typename T1>
inline tuple <T0,T1> make_tuple (const T0& t0,
const T1& t1) {
tuple <T0,T1> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
return t;
}
// Constructs a tuple with 1 elements (well ...)
template <typename T0>
inline tuple <T0> make_tuple (const T0& t0) {
tuple <T0> t;
t.template get<0>() = t0;
return t;
}
// Constructs a tuple with 0 elements (well ...)
inline tuple <> make_tuple () {
tuple <> t;
return t;
}
}
#endif // !! BOOST_TUPLE_INCLUDED
// A very small replacement for boost::tuple
// (c) Alexander Gessler, 2008 [alexander.gessler@gmx.net]
#ifndef BOOST_TUPLE_INCLUDED
#define BOOST_TUPLE_INCLUDED
namespace boost {
namespace detail {
// Represents an empty tuple slot (up to 5 supported)
struct nulltype {};
// For readable error messages
struct tuple_component_idx_out_of_bounds;
// To share some code for the const/nonconst versions of the getters
template <bool b, typename T>
struct ConstIf {
typedef T t;
};
template <typename T>
struct ConstIf<true,T> {
typedef const T t;
};
// Predeclare some stuff
template <typename, unsigned, typename, bool, unsigned> struct value_getter;
// Helper to obtain the type of a tuple element
template <typename T, unsigned NIDX, typename TNEXT, unsigned N /*= 0*/>
struct type_getter {
typedef type_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type,N> next_elem_getter;
typedef typename next_elem_getter::type type;
};
template <typename T, unsigned NIDX, typename TNEXT >
struct type_getter <T,NIDX,TNEXT,NIDX> {
typedef T type;
};
// Base class for all explicit specializations of list_elem
template <typename T, unsigned NIDX, typename TNEXT >
struct list_elem_base {
// Store template parameters
typedef TNEXT next_type;
typedef T type;
static const unsigned nidx = NIDX;
};
// Represents an element in the tuple component list
template <typename T, unsigned NIDX, typename TNEXT >
struct list_elem : list_elem_base<T,NIDX,TNEXT>{
// Real members
T me;
TNEXT next;
// Get the value of a specific tuple element
template <unsigned N>
typename type_getter<T,NIDX,TNEXT,N>::type& get () {
value_getter <T,NIDX,TNEXT,false,N> s;
return s(*this);
}
// Get the value of a specific tuple element
template <unsigned N>
const typename type_getter<T,NIDX,TNEXT,N>::type& get () const {
value_getter <T,NIDX,TNEXT,true,N> s;
return s(*this);
}
// Explicit cast
template <typename T2, typename TNEXT2 >
operator list_elem<T2,NIDX,TNEXT2> () const {
list_elem<T2,NIDX,TNEXT2> ret;
ret.me = (T2)me;
ret.next = next;
return ret;
}
// Recursively compare two elements (last element returns always true)
bool operator == (const list_elem& s) const {
return (me == s.me && next == s.next);
}
};
// Represents a non-used tuple element - the very last element processed
template <typename TNEXT, unsigned NIDX >
struct list_elem<nulltype,NIDX,TNEXT> : list_elem_base<nulltype,NIDX,TNEXT> {
template <unsigned N, bool IS_CONST = true> struct value_getter {
/* just dummy members to produce readable error messages */
tuple_component_idx_out_of_bounds operator () (typename ConstIf<IS_CONST,list_elem>::t& me);
};
template <unsigned N> struct type_getter {
/* just dummy members to produce readable error messages */
typedef tuple_component_idx_out_of_bounds type;
};
// dummy
list_elem& operator = (const list_elem& /*other*/) {
return *this;
}
// dummy
bool operator == (const list_elem& other) {
return true;
}
};
// Represents the absolute end of the list
typedef list_elem<nulltype,0,int> list_end;
// 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
// partial specialization of a nested class of a non-specialized template
template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST, unsigned N>
struct value_getter {
// calling list_elem
typedef list_elem<T,NIDX,TNEXT> outer_elem;
// typedef for the getter for next element
typedef value_getter<typename TNEXT::type,NIDX+1,typename TNEXT::next_type,
IS_CONST, N> next_value_getter;
typename ConstIf<IS_CONST,typename type_getter<T,NIDX,TNEXT,N>::type>::t&
operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) {
next_value_getter s;
return s(me.next);
}
};
template <typename T, unsigned NIDX, typename TNEXT, bool IS_CONST>
struct value_getter <T,NIDX,TNEXT,IS_CONST,NIDX> {
typedef list_elem<T,NIDX,TNEXT> outer_elem;
typename ConstIf<IS_CONST,T>::t& operator () (typename ConstIf<IS_CONST,outer_elem >::t& me) {
return me.me;
}
};
}
// A very minimal implementation for up to 5 elements
template <typename T0 = detail::nulltype,
typename T1 = detail::nulltype,
typename T2 = detail::nulltype,
typename T3 = detail::nulltype,
typename T4 = detail::nulltype>
class tuple {
template <typename T0b,
typename T1b,
typename T2b,
typename T3b,
typename T4b >
friend class tuple;
private:
typedef detail::list_elem<T0,0,
detail::list_elem<T1,1,
detail::list_elem<T2,2,
detail::list_elem<T3,3,
detail::list_elem<T4,4,
detail::list_end > > > > > very_long;
very_long m;
public:
// Get a specific tuple element
template <unsigned N>
typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () {
return m.template get<N>();
}
// ... and the const version
template <unsigned N>
const typename detail::type_getter<T0,0,typename very_long::next_type, N>::type& get () const {
return m.template get<N>();
}
// comparison operators
bool operator== (const tuple& other) const {
return m == other.m;
}
// ... and the other way round
bool operator!= (const tuple& other) const {
return !(m == other.m);
}
// cast to another tuple - all single elements must be convertible
template <typename T0b, typename T1b,typename T2b,typename T3b, typename T4b>
operator tuple <T0b,T1b,T2b,T3b,T4b> () const {
tuple <T0b,T1b,T2b,T3b,T4b> s;
s.m = (typename tuple <T0b,T1b,T2b,T3b,T4b>::very_long)m;
return s;
}
};
// Another way to access an element ...
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 (
tuple<T0,T1,T2,T3,T4>& m) {
return m.template get<N>();
}
// ... and the const version
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 (
const tuple<T0,T1,T2,T3,T4>& m) {
return m.template get<N>();
}
// Constructs a tuple with 5 elements
template <typename T0,typename T1,typename T2,typename T3,typename T4>
inline tuple <T0,T1,T2,T3,T4> make_tuple (const T0& t0,
const T1& t1,const T2& t2,const T3& t3,const T4& t4) {
tuple <T0,T1,T2,T3,T4> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
t.template get<2>() = t2;
t.template get<3>() = t3;
t.template get<4>() = t4;
return t;
}
// Constructs a tuple with 4 elements
template <typename T0,typename T1,typename T2,typename T3>
inline tuple <T0,T1,T2,T3> make_tuple (const T0& t0,
const T1& t1,const T2& t2,const T3& t3) {
tuple <T0,T1,T2,T3> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
t.template get<2>() = t2;
t.template get<3>() = t3;
return t;
}
// Constructs a tuple with 3 elements
template <typename T0,typename T1,typename T2>
inline tuple <T0,T1,T2> make_tuple (const T0& t0,
const T1& t1,const T2& t2) {
tuple <T0,T1,T2> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
t.template get<2>() = t2;
return t;
}
// Constructs a tuple with 2 elements
template <typename T0,typename T1>
inline tuple <T0,T1> make_tuple (const T0& t0,
const T1& t1) {
tuple <T0,T1> t;
t.template get<0>() = t0;
t.template get<1>() = t1;
return t;
}
// Constructs a tuple with 1 elements (well ...)
template <typename T0>
inline tuple <T0> make_tuple (const T0& t0) {
tuple <T0> t;
t.template get<0>() = t0;
return t;
}
// Constructs a tuple with 0 elements (well ...)
inline tuple <> make_tuple () {
tuple <> t;
return t;
}
}
#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
#include <sstream>
#include <stdarg.h>
#include "ColladaParser.h"
#include "fast_atof.h"
#include "ParsingUtils.h"
@ -1066,6 +1067,12 @@ void ColladaParser::ReadLight( Collada::Light& pLight)
pLight.mFalloffAngle = ReadFloatFromTextContent();
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) {
if( strcmp( mReader->getNodeName(), "light") == 0)
@ -1998,7 +2005,8 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
}
#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);
}
#endif
@ -2107,13 +2115,19 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
}
}
// complain if the index count doesn't fit
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets)
ThrowException( "Expected different index count in <p> element.");
else if( expectedPointCount == 0 && (indices.size() % numOffsets) != 0)
ThrowException( "Expected different index count in <p> element.");
// complain if the index count doesn't fit
if( expectedPointCount > 0 && indices.size() != expectedPointCount * numOffsets) {
if (pPrimType == Prim_Lines) {
// HACK: We just fix this number since SketchUp 15.3.331 writes the wrong 'count' for 'lines'
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)
{
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));
}
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

View File

@ -1,42 +1,42 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2015, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2015, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file ColladaParser.h
* @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
{
// ------------------------------------------------------------------------------------------
/** Parser helper class for the Collada loader.
*
* Does all the XML reading and builds internal data structures from it,
* 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.
// ------------------------------------------------------------------------------------------
/** Parser helper class for the Collada loader.
*
* Does all the XML reading and builds internal data structures from it,
* but leaves the resolving of all the references to the loader.
*/
void ReadSource();
/** 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.
*/
void ReadDataArray();
/** Reads an accessor and stores it in the global library under the given ID -
* accessors use the ID of the parent <source> element
*/
void ReadAccessor( const std::string& pID);
/** Reads input declarations of per-vertex mesh data into the given mesh */
void ReadVertexData( Collada::Mesh* pMesh);
/** Reads input declarations of per-index mesh data into the given mesh */
void ReadIndexData( Collada::Mesh* pMesh);
/** Reads a single input channel element and stores it in the given array, if valid */
void ReadInputChannel( std::vector<Collada::InputChannel>& poChannels);
/** Reads a <p> primitive index list and assembles the mesh data into the given mesh */
size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
size_t pNumPrimitives, const std::vector<size_t>& pVCount, Collada::PrimitiveType pPrimType);
/** 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,
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
size_t currentPrimitive, const std::vector<size_t>& indices);
/** Reads one triangle of a tristrip into the mesh */
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);
/** 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 library of node hierarchies and scene parts */
void ReadSceneLibrary();
/** Reads a scene node's contents including children and stores it in the given node */
void ReadSceneNode( Collada::Node* pNode);
/** 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 a mesh reference in a node and adds it to the node's mesh list */
void ReadNodeGeometry( Collada::Node* pNode);
/** Reads the collada scene */
void ReadScene();
// Processes bind_vertex_input and bind elements
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
protected:
/** Aborts the file reading with an exception */
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
/** 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;
}
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();
/** 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.
*/
void ReadDataArray();
/** Reads an accessor and stores it in the global library under the given ID -
* accessors use the ID of the parent <source> element
*/
void ReadAccessor( const std::string& pID);
/** Reads input declarations of per-vertex mesh data into the given mesh */
void ReadVertexData( Collada::Mesh* pMesh);
/** Reads input declarations of per-index mesh data into the given mesh */
void ReadIndexData( Collada::Mesh* pMesh);
/** Reads a single input channel element and stores it in the given array, if valid */
void ReadInputChannel( std::vector<Collada::InputChannel>& poChannels);
/** Reads a <p> primitive index list and assembles the mesh data into the given mesh */
size_t ReadPrimitives( Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
size_t pNumPrimitives, const std::vector<size_t>& pVCount, Collada::PrimitiveType pPrimType);
/** 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,
Collada::Mesh* pMesh, std::vector<Collada::InputChannel>& pPerIndexChannels,
size_t currentPrimitive, const std::vector<size_t>& indices);
/** Reads one triangle of a tristrip into the mesh */
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);
/** 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 library of node hierarchies and scene parts */
void ReadSceneLibrary();
/** Reads a scene node's contents including children and stores it in the given node */
void ReadSceneNode( Collada::Node* pNode);
/** 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 a mesh reference in a node and adds it to the node's mesh list */
void ReadNodeGeometry( Collada::Node* pNode);
/** Reads the collada scene */
void ReadScene();
// Processes bind_vertex_input and bind elements
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
protected:
/** Aborts the file reading with an exception */
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
void ReportWarning(const char* msg,...);
/** 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
#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;
// now compare the volumes of the bounding boxes
if (std::fabs(fDelta0_x * fDelta1_yz) <
std::fabs(fDelta1_x * fDelta1_y * fDelta1_z))
if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) <
std::fabs(fDelta1_x * fDelta1_yz))
{
if (!DefaultLogger::isNullLogger())
{

View File

@ -602,12 +602,12 @@ bool IntersectingLineSegments(const IfcVector2& n0, const IfcVector2& n1,
const IfcVector2& m0, const IfcVector2& m1,
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& n1_to_m1 = m1 - n1;
const IfcVector2 n0_to_m0 = m0 - n0;
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 smalle = 1e-9f;
@ -927,7 +927,7 @@ size_t CloseWindows(ContourVector& contours,
IfcFloat best = static_cast<IfcFloat>(1e10);
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 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
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
// (which are present, of course), this should be the same value for
// all polygon vertices (assuming the polygon is planar).
@ -1144,7 +1144,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
std::vector<IfcVector2> contour_flat;
IfcVector3 nor;
const IfcMatrix4& m = ProjectOntoPlane(contour_flat, curmesh, ok, nor);
const IfcMatrix4 m = ProjectOntoPlane(contour_flat, curmesh, ok, nor);
if(!ok) {
return false;
}
@ -1227,7 +1227,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
bool side_flag = true;
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();
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) {
const IfcVector3& x = profile_verts[vi_total];
const IfcVector3& v = m * x;
const IfcVector3 v = m * x;
IfcVector2 vv(v.x, v.y);
//if(check_intersection) {
@ -1322,7 +1322,7 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
MakeDisjunctWindowContours(other, temp_contour, poly);
if(poly.size() == 1) {
const BoundingBox& newbb = GetBoundingBox(poly[0].outer);
const BoundingBox newbb = GetBoundingBox(poly[0].outer);
if (!BoundingBoxesOverlapping(ibb, newbb )) {
// Good guy bounding box
bb = newbb ;
@ -1438,7 +1438,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,const std:
// working coordinate system.
bool ok;
IfcVector3 nor;
const IfcMatrix3& m = DerivePlaneCoordinateSpace(curmesh, ok, nor);
const IfcMatrix3 m = DerivePlaneCoordinateSpace(curmesh, ok, nor);
if (!ok) {
return false;
}
@ -1686,13 +1686,13 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,const std:
continue;
}
const std::vector<p2t::Triangle*>& tris = cdt->GetTriangles();
const std::vector<p2t::Triangle*> tris = cdt->GetTriangles();
// Collect the triangles we just produced
BOOST_FOREACH(p2t::Triangle* tri, tris) {
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)->y )
);

View File

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

View File

@ -133,15 +133,16 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
TextFileToBuffer(file.get(),m_Buffer);
// Get the model name
std::string strModelName;
std::string modelName, folderName;
std::string::size_type pos = pFile.find_last_of( "\\/" );
if ( pos != std::string::npos )
{
strModelName = pFile.substr(pos+1, pFile.size() - pos - 1);
}
else
{
strModelName = pFile;
if ( pos != std::string::npos ) {
modelName = pFile.substr(pos+1, pFile.size() - pos - 1);
folderName = pFile.substr( 0, pos );
if ( folderName.empty() ) {
pIOHandler->PushDirectory( folderName );
}
} else {
modelName = pFile;
}
// process all '\'
@ -161,13 +162,18 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
}
// 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
CreateDataFromImport(parser.GetModel(), pScene);
// Clean up allocated storage for the next import
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
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 ];
// 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.
ObjFileParser::ObjFileParser(std::vector<char> &Data,const std::string &strModelName, IOSystem *io ) :
m_DataIt(Data.begin()),
m_DataItEnd(Data.end()),
ObjFileParser::ObjFileParser(std::vector<char> &data,const std::string &modelName, IOSystem *io ) :
m_DataIt(data.begin()),
m_DataItEnd(data.end()),
m_pModel(NULL),
m_uiLine(0),
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
m_pModel = new ObjFile::Model();
m_pModel->m_ModelName = strModelName;
m_pModel->m_ModelName = modelName;
// 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_MaterialLib.push_back( DEFAULT_MATERIAL );
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;
if( 2 == numComponents ) {
copyNextWord( m_buffer, BUFFERSIZE );
copyNextWord( m_buffer, Buffersize );
x = ( float ) fast_atof( m_buffer );
copyNextWord( m_buffer, BUFFERSIZE );
copyNextWord( m_buffer, Buffersize );
y = ( float ) fast_atof( m_buffer );
z = 0.0;
} else if( 3 == numComponents ) {
copyNextWord( m_buffer, BUFFERSIZE );
copyNextWord( m_buffer, Buffersize );
x = ( float ) fast_atof( m_buffer );
copyNextWord( m_buffer, BUFFERSIZE );
copyNextWord( m_buffer, Buffersize );
y = ( float ) fast_atof( m_buffer );
copyNextWord( m_buffer, BUFFERSIZE );
copyNextWord( m_buffer, Buffersize );
z = ( float ) fast_atof( m_buffer );
} else {
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
void ObjFileParser::getVector3(std::vector<aiVector3D> &point3d_array) {
float x, y, z;
copyNextWord(m_buffer, BUFFERSIZE);
copyNextWord(m_buffer, Buffersize);
x = (float) fast_atof(m_buffer);
copyNextWord(m_buffer, BUFFERSIZE);
copyNextWord(m_buffer, Buffersize);
y = (float) fast_atof(m_buffer);
copyNextWord( m_buffer, BUFFERSIZE );
copyNextWord( m_buffer, Buffersize );
z = ( float ) fast_atof( m_buffer );
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
void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
float x, y;
copyNextWord(m_buffer, BUFFERSIZE);
copyNextWord(m_buffer, Buffersize);
x = (float) fast_atof(m_buffer);
copyNextWord(m_buffer, BUFFERSIZE);
copyNextWord(m_buffer, Buffersize);
y = (float) fast_atof(m_buffer);
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
void ObjFileParser::getFace(aiPrimitiveType type)
{
copyNextLine(m_buffer, BUFFERSIZE);
copyNextLine(m_buffer, Buffersize);
if (m_DataIt == m_DataItEnd)
return;
char *pPtr = m_buffer;
char *pEnd = &pPtr[BUFFERSIZE];
char *pEnd = &pPtr[Buffersize];
pPtr = getNextToken<char*>(pPtr, pEnd);
if (pPtr == pEnd || *pPtr == '\0')
return;
@ -468,8 +468,9 @@ void ObjFileParser::getMaterialDesc()
// Get next data for material data
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
if (m_DataIt == m_DataItEnd)
if (m_DataIt == m_DataItEnd) {
return;
}
char *pStart = &(*m_DataIt);
while( m_DataIt != m_DataItEnd && !IsLineEnd( *m_DataIt ) ) {
@ -483,14 +484,11 @@ void ObjFileParser::getMaterialDesc()
// Search for material
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
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", skipping");
}
else
{
} else {
// Found, using detected material
m_pModel->m_pCurrentMaterial = (*it).second;
if ( needsNewMesh( strName ))
@ -539,18 +537,24 @@ void ObjFileParser::getMaterialLib()
// Check for existence
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 )
{
DefaultLogger::get()->error("OBJ: Unable to locate material file " + strMatName);
if (!pFile ) {
DefaultLogger::get()->error( "OBJ: Unable to locate material file " + strMatName );
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
return;
}
// Import material library data from file
std::vector<char> buffer;
BaseImporter::TextFileToBuffer(pFile,buffer);
BaseImporter::TextFileToBuffer( pFile, buffer );
m_pIO->Close( pFile );
// Importing the material library

View File

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

View File

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

View File

@ -189,7 +189,12 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
}
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;
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) {
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) {
unsigned int index = f.mIndices[c] + offset;
mOutput.write(reinterpret_cast<const char*>(&index), 4);
IndexType index = f.mIndices[c] + offset;
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

View File

@ -310,6 +310,10 @@ void PLYImporter::ConvertMeshes(std::vector<PLY::Face>* avFaces,
iNum += (unsigned int)(*avFaces)[aiSplit[p][i]].mIndices.size();
}
p_pcOut->mNumVertices = iNum;
if( 0 == iNum ) { // nothing to do
delete[] aiSplit; // cleanup
return;
}
p_pcOut->mVertices = new aiVector3D[iNum];
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)
{
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())
p_pcOut->mColors[0][iVertex] = (*avColors)[(*avFaces)[*i].mIndices[q]];
p_pcOut->mColors[ 0 ][ iVertex ] = ( *avColors )[ idx ];
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].y = vec.y;
}
if (!avNormals->empty())
p_pcOut->mNormals[iVertex] = (*avNormals)[(*avFaces)[*i].mIndices[q]];
p_pcOut->mNormals[ iVertex ] = ( *avNormals )[ idx ];
iVertex++;
}

View File

@ -75,8 +75,9 @@ static const aiImporterDesc desc = {
// 2) 4 byte face count
// 3) 50 bytes per face
bool IsBinarySTL(const char* buffer, unsigned int fileSize) {
if (fileSize < 84)
if( fileSize < 84 ) {
return false;
}
const uint32_t faceCount = *reinterpret_cast<const uint32_t*>(buffer + 80);
const uint32_t expectedBinaryFileSize = faceCount * 50 + 84;
@ -99,7 +100,20 @@ bool IsAsciiSTL(const char* buffer, unsigned int fileSize) {
if (buffer + 5 >= bufferEnd)
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
@ -122,23 +136,37 @@ bool STLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
{
const std::string extension = GetExtension(pFile);
if (extension == "stl")
if( extension == "stl" ) {
return true;
else if (!extension.length() || checkSig) {
if (!pIOHandler)
} else if (!extension.length() || checkSig) {
if( !pIOHandler ) {
return true;
}
const char* tokens[] = {"STL","solid"};
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2);
}
return false;
}
// ------------------------------------------------------------------------------------------------
const aiImporterDesc* STLImporter::GetInfo () const
{
const aiImporterDesc* STLImporter::GetInfo () const {
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.
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.
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
pScene->mRootNode = new aiNode();
pScene->mRootNode->mNumMeshes = 1;
pScene->mRootNode->mMeshes = new unsigned int[1];
pScene->mRootNode->mMeshes[0] = 0;
bool bMatClr = false;
@ -186,16 +205,11 @@ void STLImporter::InternReadFile( const std::string& pFile,
throw DeadlyImportError( "Failed to determine STL storage representation for " + pFile + ".");
}
// now copy faces
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;
}
}
// add all created meshes to the single node
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
for (unsigned int i = 0; i < pScene->mNumMeshes; i++)
pScene->mRootNode->mMeshes[i] = i;
// create a single default material, using a light gray diffuse color for consistency with
// other geometric types (e.g., PLY).
@ -221,140 +235,171 @@ void STLImporter::InternReadFile( const std::string& pFile,
// Read an ASCII STL file
void STLImporter::LoadASCIIFile()
{
aiMesh* pMesh = pScene->mMeshes[0];
std::vector<aiMesh*> meshes;
const char* sz = mBuffer;
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>");
const char* bufferEnd = mBuffer + fileSize;
std::vector<aiVector3D> positionBuffer;
std::vector<aiVector3D> normalBuffer;
// try to guess how many vertices we could have
// assume we'll need 160 bytes for each face
pMesh->mNumVertices = ( pMesh->mNumFaces = std::max(1u,fileSize / 160u )) * 3;
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
size_t sizeEstimate = std::max(1u, fileSize / 160u ) * 3;
positionBuffer.reserve(sizeEstimate);
normalBuffer.reserve(sizeEstimate);
unsigned int curFace = 0, curVertex = 3;
for ( ;; )
while (IsAsciiSTL(sz, bufferEnd - sz))
{
// go to the next token
if(!SkipSpacesAndLineEnd(&sz))
aiMesh* pMesh = new aiMesh();
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
DefaultLogger::get()->warn("STL: unexpected EOF. \'endsolid\' keyword was expected");
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
// go to the next token
if(!SkipSpacesAndLineEnd(&sz))
{
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 );
*(vn+1) = *vn;
*(vn+2) = *vn;
// seems we're finished although there was no end marker
DefaultLogger::get()->warn("STL: unexpected EOF. \'endsolid\' keyword was expected");
break;
}
}
// vertex 1.50000 1.50000 0.00000
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));
}
}
// facet normal -0.13 -0.13 -0.98
if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5)) && *(sz + 5) != '\0') {
if (!curFace) {
pMesh->mNumFaces = 0;
throw DeadlyImportError("STL: ASCII file is empty or invalid; no data loaded");
if (faceVertexCounter != 3) {
DefaultLogger::get()->warn("STL: A new facet begins but the old is not yet complete");
}
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
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
if (fileSize < 84) {
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;
// now read the number of facets
aiMesh* pMesh = pScene->mMeshes[0];
pScene->mRootNode->mName.Set("<STL_BINARY>");
pMesh->mNumFaces = *((uint32_t*)sz);
@ -402,7 +446,7 @@ bool STLImporter::LoadBinaryFile()
vp = pMesh->mVertices = 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
// our fault ... the RemoveInvalidData helper step should fix that
@ -455,6 +499,10 @@ bool STLImporter::LoadBinaryFile()
*(clr+2) = *clr;
}
}
// now copy faces
addFacesToMesh(pMesh);
if (bIsMaterialise && !pMesh->mColors[0])
{
// use the color as diffuse material color

View File

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

View File

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

View File

@ -1,29 +1,29 @@
The Clipper code library, the "Software" (that includes Delphi, C++ & C#
source code, accompanying samples and documentation), has been released
under the following license, terms and conditions:
Boost Software License - Version 1.0 - August 17th, 2003
http://www.boost.org/LICENSE_1_0.txt
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
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
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
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
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
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
DEALINGS IN THE SOFTWARE.
The Clipper code library, the "Software" (that includes Delphi, C++ & C#
source code, accompanying samples and documentation), has been released
under the following license, terms and conditions:
Boost Software License - Version 1.0 - August 17th, 2003
http://www.boost.org/LICENSE_1_0.txt
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
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
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
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
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
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
DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,108 +1,108 @@
// Copyright (C) 2002-2005 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_TYPES_H_INCLUDED__
#define __IRR_TYPES_H_INCLUDED__
namespace irr
{
//! 8 bit unsigned variable.
/** This is a typedef for unsigned char, it ensures portability of the engine. */
typedef unsigned char u8;
//! 8 bit signed variable.
/** This is a typedef for signed char, it ensures portability of the engine. */
typedef signed char s8;
//! 8 bit character variable.
/** This is a typedef for char, it ensures portability of the engine. */
typedef char c8;
//! 16 bit unsigned variable.
/** This is a typedef for unsigned short, it ensures portability of the engine. */
typedef unsigned short u16;
//! 16 bit signed variable.
/** This is a typedef for signed short, it ensures portability of the engine. */
typedef signed short s16;
//! 32 bit unsigned variable.
/** This is a typedef for unsigned int, it ensures portability of the engine. */
typedef unsigned int u32;
//! 32 bit signed variable.
/** This is a typedef for signed int, it ensures portability of the engine. */
typedef signed int s32;
// 64 bit signed variable.
// 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
// other than Microsoft Compilers, so it is outcommented.
//typedef __int64 s64;
//! 32 bit floating point variable.
/** This is a typedef for float, it ensures portability of the engine. */
typedef float f32;
//! 64 bit floating point variable.
/** This is a typedef for double, it ensures portability of the engine. */
typedef double f64;
} // end namespace
// define the wchar_t type if not already built in.
#ifdef _MSC_VER
#ifndef _WCHAR_T_DEFINED
//! A 16 bit wide character type.
/**
Defines the wchar_t-type.
In VS6, its not possible to tell
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,
so we'll use this.
*/
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif // wchar is not defined
#endif // microsoft compiler
//! define a break macro for debugging only in Win32 mode.
// WORKAROUND (assimp): remove __asm
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#if defined(_M_IX86)
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) /*if (_CONDITION_) {_asm int 3}*/
#else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif
#else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif
//! Defines a small statement to work around a microsoft compiler 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,
the return value may appear as true. See
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*/
// WORKAROUND (assimp): remove __asm
#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX /*__asm mov eax,100*/
#else
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX
#endif // __IRR_TYPES_H_INCLUDED__
// Copyright (C) 2002-2005 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_TYPES_H_INCLUDED__
#define __IRR_TYPES_H_INCLUDED__
namespace irr
{
//! 8 bit unsigned variable.
/** This is a typedef for unsigned char, it ensures portability of the engine. */
typedef unsigned char u8;
//! 8 bit signed variable.
/** This is a typedef for signed char, it ensures portability of the engine. */
typedef signed char s8;
//! 8 bit character variable.
/** This is a typedef for char, it ensures portability of the engine. */
typedef char c8;
//! 16 bit unsigned variable.
/** This is a typedef for unsigned short, it ensures portability of the engine. */
typedef unsigned short u16;
//! 16 bit signed variable.
/** This is a typedef for signed short, it ensures portability of the engine. */
typedef signed short s16;
//! 32 bit unsigned variable.
/** This is a typedef for unsigned int, it ensures portability of the engine. */
typedef unsigned int u32;
//! 32 bit signed variable.
/** This is a typedef for signed int, it ensures portability of the engine. */
typedef signed int s32;
// 64 bit signed variable.
// 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
// other than Microsoft Compilers, so it is outcommented.
//typedef __int64 s64;
//! 32 bit floating point variable.
/** This is a typedef for float, it ensures portability of the engine. */
typedef float f32;
//! 64 bit floating point variable.
/** This is a typedef for double, it ensures portability of the engine. */
typedef double f64;
} // end namespace
// define the wchar_t type if not already built in.
#ifdef _MSC_VER
#ifndef _WCHAR_T_DEFINED
//! A 16 bit wide character type.
/**
Defines the wchar_t-type.
In VS6, its not possible to tell
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,
so we'll use this.
*/
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif // wchar is not defined
#endif // microsoft compiler
//! define a break macro for debugging only in Win32 mode.
// WORKAROUND (assimp): remove __asm
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#if defined(_M_IX86)
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) /*if (_CONDITION_) {_asm int 3}*/
#else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif
#else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif
//! Defines a small statement to work around a microsoft compiler 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,
the return value may appear as true. See
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*/
// WORKAROUND (assimp): remove __asm
#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX /*__asm mov eax,100*/
#else
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX
#endif // __IRR_TYPES_H_INCLUDED__

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,199 +1,199 @@
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
# 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
cmake_policy(PUSH)
if(CMAKE_MAJOR_VERSION GREATER 2)
cmake_policy(SET CMP0048 OLD)
endif()
project(zlib C)
cmake_policy(POP)
set(VERSION "1.2.8")
option(ASM686 "Enable building i686 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_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_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")
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
enable_testing()
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
# We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x.
if(HAVE_SYS_TYPES_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
endif()
if(HAVE_STDINT_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
endif()
if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif()
check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE=1)
endif()
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()
#
# Check for unistd.h
#
check_include_file(unistd.h Z_HAVE_UNISTD_H)
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
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
# in their source tree...
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
message(STATUS "Renaming")
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
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)
endif()
endif()
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
#============================================================================
# zlib
#============================================================================
set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
zlib.h
)
set(ZLIB_PRIVATE_HDRS
crc32.h
deflate.h
gzguts.h
inffast.h
inffixed.h
inflate.h
inftrees.h
trees.h
zutil.h
)
set(ZLIB_SRCS
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
inflate.c
infback.c
inftrees.c
inffast.c
trees.c
uncompr.c
zutil.c
)
if(NOT MINGW)
set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below.
)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
if(ASM686)
set(ZLIB_ASMS contrib/asm686/match.S)
elseif (AMD64)
set(ZLIB_ASMS contrib/amd64/amd64-match.S)
endif ()
if(ZLIB_ASMS)
add_definitions(-DASMV)
set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
endif()
endif()
if(MSVC)
if(ASM686)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx86/inffas32.asm
contrib/masmx86/match686.asm
)
elseif (AMD64)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx64/gvmat64.asm
contrib/masmx64/inffasx64.asm
)
endif()
if(ZLIB_ASMS)
add_definitions(-DASMV -DASMINF)
endif()
endif()
# 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)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
if(MINGW)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe)
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND ${CMAKE_RC_COMPILER}
-D GCC_WINDRES
-I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
INSTALL( TARGETS zlibstatic
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR}
COMPONENT ${LIBASSIMP_COMPONENT})
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
# 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
cmake_policy(PUSH)
if(CMAKE_MAJOR_VERSION GREATER 2)
cmake_policy(SET CMP0048 OLD)
endif()
project(zlib C)
cmake_policy(POP)
set(VERSION "1.2.8")
option(ASM686 "Enable building i686 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_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_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")
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
enable_testing()
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
# We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x.
if(HAVE_SYS_TYPES_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
endif()
if(HAVE_STDINT_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
endif()
if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif()
check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE=1)
endif()
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()
#
# Check for unistd.h
#
check_include_file(unistd.h Z_HAVE_UNISTD_H)
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
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
# in their source tree...
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
message(STATUS "Renaming")
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
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)
endif()
endif()
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
#============================================================================
# zlib
#============================================================================
set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
zlib.h
)
set(ZLIB_PRIVATE_HDRS
crc32.h
deflate.h
gzguts.h
inffast.h
inffixed.h
inflate.h
inftrees.h
trees.h
zutil.h
)
set(ZLIB_SRCS
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
inflate.c
infback.c
inftrees.c
inffast.c
trees.c
uncompr.c
zutil.c
)
if(NOT MINGW)
set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below.
)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
if(ASM686)
set(ZLIB_ASMS contrib/asm686/match.S)
elseif (AMD64)
set(ZLIB_ASMS contrib/amd64/amd64-match.S)
endif ()
if(ZLIB_ASMS)
add_definitions(-DASMV)
set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
endif()
endif()
if(MSVC)
if(ASM686)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx86/inffas32.asm
contrib/masmx86/match686.asm
)
elseif (AMD64)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx64/gvmat64.asm
contrib/masmx64/inffasx64.asm
)
endif()
if(ZLIB_ASMS)
add_definitions(-DASMV -DASMINF)
endif()
endif()
# 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)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
if(MINGW)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe)
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND ${CMAKE_RC_COMPILER}
-D GCC_WINDRES
-I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
INSTALL( TARGETS zlibstatic
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR}
COMPONENT ${LIBASSIMP_COMPONENT})

View File

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

View File

@ -1,40 +1,40 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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
// for all supported compilers. Reverts the changes made by #include <pushpack1.h>
//
// Currently this works on the following compilers:
// MSVC 7,8,9
// GCC
// BORLAND (complains about 'pack state changed but not reverted', but works)
// ===============================================================================
#ifndef AI_PUSHPACK_IS_DEFINED
# error pushpack1.h must be included after poppack1.h
#endif
// reset packing to the original value
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop )
#endif
#undef PACK_STRUCT
#undef AI_PUSHPACK_IS_DEFINED
// ===============================================================================
// May be included multiple times - resets structure packing to the defaults
// for all supported compilers. Reverts the changes made by #include <pushpack1.h>
//
// Currently this works on the following compilers:
// MSVC 7,8,9
// GCC
// BORLAND (complains about 'pack state changed but not reverted', but works)
// ===============================================================================
#ifndef AI_PUSHPACK_IS_DEFINED
# error pushpack1.h must be included after poppack1.h
#endif
// reset packing to the original value
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop )
#endif
#undef PACK_STRUCT
#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
#include "types.h"
#include <vector>
namespace Assimp {
class IOStream;
@ -102,18 +105,14 @@ public:
* @param pFile Path to the file
* @return true if there is a file with this path, else false.
*/
virtual bool Exists( const char* pFile) const = 0;
// -------------------------------------------------------------------
/** @brief Returns the system specific directory separator
* @return System specific directory separator
*/
virtual char getOsSeparator() const = 0;
// -------------------------------------------------------------------
/** @brief Open a new file with a given path.
*
@ -139,8 +138,6 @@ public:
inline IOStream* Open(const std::string& pFile,
const std::string& pMode = std::string("rb"));
// -------------------------------------------------------------------
/** @brief Closes the given file and releases all resources
* associated with it.
@ -170,10 +167,41 @@ public:
*/
inline bool ComparePaths (const std::string& one,
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
}
@ -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
#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
#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

View File

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

View File

@ -1,23 +1,23 @@
------------------------------------------------------------------------------------
Open Asset Import Library (Assimp) SDK Installer
Release Notes
------------------------------------------------------------------------------------
http://assimp.sf.net
Troubleshooting
===============
1. Missing d3dx9_(some-number).dll?
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?
Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. assimp.exe not in PATH
Add it to PATH. That's not a bug, the installer does not alter the PATH.
4. Crashes immediately
You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry.
------------------------------------------------------------------------------------
Open Asset Import Library (Assimp) SDK Installer
Release Notes
------------------------------------------------------------------------------------
http://assimp.sf.net
Troubleshooting
===============
1. Missing d3dx9_(some-number).dll?
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?
Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. assimp.exe not in PATH
Add it to PATH. That's not a bug, the installer does not alter the PATH.
4. Crashes immediately
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
Release Notes
------------------------------------------------------------------------------------
http://assimp.sf.net
Known Bugs & Limitations
========================
Viewer
- 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.
- Several important texture file formats (such as GIF) are not supported.
- HUD is blurred on the right side. ATI/AMD hardware only.
Troubleshooting
===============
1. Missing d3dx9_(number).dll?
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?
Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. assimp.exe not in PATH
Add it to PATH. That's not a bug, the installer does not alter the PATH.
4. Crashes immediately
------------------------------------------------------------------------------------
Open Asset Import Library (Assimp) Viewer Installer
Release Notes
------------------------------------------------------------------------------------
http://assimp.sf.net
Known Bugs & Limitations
========================
Viewer
- 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.
- Several important texture file formats (such as GIF) are not supported.
- HUD is blurred on the right side. ATI/AMD hardware only.
Troubleshooting
===============
1. Missing d3dx9_(number).dll?
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?
Reinstall Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. assimp.exe not in PATH
Add it to PATH. That's not a bug, the installer does not alter the PATH.
4. Crashes immediately
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
Release Notes
------------------------------------------------------------------------------------
Known Bugs & Limitations
========================
Viewer
- 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.
- Alpha-sorting is implemented, but still causes artifacts when models are moved quickly.
- Several important texture file formats (such as GIF) are not supported.
- HUD is blurred on the right side. ATI/AMD hardware only.
Troubleshooting
===============
1. Missing d3dx9_42.dll?
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?
(Re)install Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. Crashes immediately
------------------------------------------------------------------------------------
Open Asset Import Library (Assimp) Tools/Binaries for Windows
Release Notes
------------------------------------------------------------------------------------
Known Bugs & Limitations
========================
Viewer
- 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.
- Alpha-sorting is implemented, but still causes artifacts when models are moved quickly.
- Several important texture file formats (such as GIF) are not supported.
- HUD is blurred on the right side. ATI/AMD hardware only.
Troubleshooting
===============
1. Missing d3dx9_42.dll?
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?
(Re)install Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
3. Crashes immediately
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)
---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file Android extension of DefaultIOSystem using the standard C file functions */
#include <code/AssimpPCH.h>
#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
#include <stdlib.h>
#include <android/log.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/native_activity.h>
#include <assimp/port/AndroidJNI/AndroidJNIIOSystem.h>
#include <code/DefaultIOStream.h>
#include <fstream>
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor.
AndroidJNIIOSystem::AndroidJNIIOSystem(ANativeActivity* activity)
{
AndroidActivityInit(activity);
}
// ------------------------------------------------------------------------------------------------
// Destructor.
AndroidJNIIOSystem::~AndroidJNIIOSystem()
{
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Tests for the existence of a file at the given path.
bool AndroidJNIIOSystem::Exists( const char* pFile) const
{
AAsset* asset = AAssetManager_open(mApkAssetManager, pFile,
AASSET_MODE_UNKNOWN);
FILE* file = ::fopen( (mApkWorkspacePath + getOsSeparator() + std::string(pFile)).c_str(), "rb");
if (!asset && !file)
{
__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);
return true;
}
// ------------------------------------------------------------------------------------------------
// Inits Android extractor
void AndroidJNIIOSystem::AndroidActivityInit(ANativeActivity* activity)
{
mApkWorkspacePath = activity->internalDataPath;
mApkAssetManager = activity->assetManager;
}
// ------------------------------------------------------------------------------------------------
// Extracts android asset
bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name)
{
std::string newPath = mApkWorkspacePath + getOsSeparator() + name;
DefaultIOSystem io;
// Do not extract if extracted already
if ( io.Exists(newPath.c_str()) ) {
__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset already extracted");
return true;
}
// Open file
AAsset* asset = AAssetManager_open(mApkAssetManager, name.c_str(),
AASSET_MODE_UNKNOWN);
std::string assetContent;
if (asset != NULL) {
// Find size
off_t assetSize = AAsset_getLength(asset);
// Prepare input buffer
assetContent.resize(assetSize);
// Store input buffer
AAsset_read(asset, &assetContent[0], assetSize);
// Close
AAsset_close(asset);
// Prepare output buffer
std::ofstream assetExtracted(newPath.c_str(),
std::ios::out | std::ios::binary);
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();
__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset extracted");
} else {
__android_log_print(ANDROID_LOG_ERROR, "assimp", "Asset not found: %s", name.c_str());
return false;
}
return true;
}
// ------------------------------------------------------------------------------------------------
// Open a new file with a given path.
IOStream* AndroidJNIIOSystem::Open( const char* strFile, const char* strMode)
{
ai_assert(NULL != strFile);
ai_assert(NULL != strMode);
std::string fullPath(mApkWorkspacePath + getOsSeparator() + std::string(strFile));
if (Exists(strFile))
AndroidExtractAsset(std::string(strFile));
FILE* file = ::fopen( fullPath.c_str(), strMode);
if( NULL == file)
return NULL;
__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)
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2012, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file Android extension of DefaultIOSystem using the standard C file functions */
#include <assimp/config.h>
#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 <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/native_activity.h>
#include <assimp/ai_assert.h>
#include <assimp/port/AndroidJNI/AndroidJNIIOSystem.h>
#include <code/DefaultIOStream.h>
#include <fstream>
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor.
AndroidJNIIOSystem::AndroidJNIIOSystem(ANativeActivity* activity)
{
AndroidActivityInit(activity);
}
// ------------------------------------------------------------------------------------------------
// Destructor.
AndroidJNIIOSystem::~AndroidJNIIOSystem()
{
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Tests for the existence of a file at the given path.
bool AndroidJNIIOSystem::Exists( const char* pFile) const
{
AAsset* asset = AAssetManager_open(mApkAssetManager, pFile,
AASSET_MODE_UNKNOWN);
FILE* file = ::fopen( (mApkWorkspacePath + getOsSeparator() + std::string(pFile)).c_str(), "rb");
if (!asset && !file)
{
__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);
return true;
}
// ------------------------------------------------------------------------------------------------
// Inits Android extractor
void AndroidJNIIOSystem::AndroidActivityInit(ANativeActivity* activity)
{
mApkWorkspacePath = activity->internalDataPath;
mApkAssetManager = activity->assetManager;
}
// ------------------------------------------------------------------------------------------------
// Extracts android asset
bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name)
{
std::string newPath = mApkWorkspacePath + getOsSeparator() + name;
DefaultIOSystem io;
// Do not extract if extracted already
if ( io.Exists(newPath.c_str()) ) {
__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset already extracted");
return true;
}
// Open file
AAsset* asset = AAssetManager_open(mApkAssetManager, name.c_str(),
AASSET_MODE_UNKNOWN);
std::vector<char> assetContent;
if (asset != NULL) {
// Find size
off_t assetSize = AAsset_getLength(asset);
// Prepare input buffer
assetContent.resize(assetSize);
// Store input buffer
AAsset_read(asset, &assetContent[0], assetSize);
// Close
AAsset_close(asset);
// Prepare output buffer
std::ofstream assetExtracted(newPath.c_str(),
std::ios::out | std::ios::binary);
if (!assetExtracted) {
__android_log_print(ANDROID_LOG_ERROR, "assimp",
"Can not open output file");
}
// Write output buffer into a file
assetExtracted.write(&assetContent[0], assetContent.size());
assetExtracted.close();
__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset extracted");
} else {
__android_log_print(ANDROID_LOG_ERROR, "assimp", "Asset not found: %s", name.c_str());
return false;
}
return true;
}
// ------------------------------------------------------------------------------------------------
// Open a new file with a given path.
IOStream* AndroidJNIIOSystem::Open( const char* strFile, const char* strMode)
{
ai_assert(NULL != strFile);
ai_assert(NULL != strMode);
std::string fullPath(mApkWorkspacePath + getOsSeparator() + std::string(strFile));
if (Exists(strFile))
AndroidExtractAsset(std::string(strFile));
FILE* file = ::fopen( fullPath.c_str(), strMode);
if( NULL == file)
return NULL;
__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)

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 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
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.
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
# depending on the platform we're running on.
if os.name=='posix':
additional_dirs.append('./')
additional_dirs.append('/usr/lib/')
additional_dirs.append('/usr/local/lib/')

View File

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

View File

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

View File

@ -1,389 +1,389 @@
/* ----------------------------------------------------------------------------
// 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
// settings and displays it.
//
// If you intend to _use_ this code sample in your app, do yourself a favour
// and replace immediate mode calls with VBOs ...
//
// The vc8 solution links against assimp-release-dll_win32 - be sure to
// have this configuration built.
// ----------------------------------------------------------------------------
*/
#include <stdlib.h>
#include <stdio.h>
#ifdef __APPLE__
#include <glut.h>
#else
#include <GL/glut.h>
#endif
/* assimp include files. These three are usually needed. */
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
/* the global Assimp scene object */
const struct aiScene* scene = NULL;
GLuint scene_list = 0;
struct aiVector3D scene_min, scene_max, scene_center;
/* current rotation angle */
static float angle = 0.f;
#define aisgl_min(x,y) (x<y?x:y)
#define aisgl_max(x,y) (y>x?y:x)
/* ---------------------------------------------------------------------------- */
void reshape(int width, int height)
{
const double aspectRatio = (float) width / height, fieldOfView = 45.0;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fieldOfView, aspectRatio,
1.0, 1000.0); /* Znear and Zfar */
glViewport(0, 0, width, height);
}
/* ---------------------------------------------------------------------------- */
void get_bounding_box_for_node (const struct aiNode* nd,
struct aiVector3D* min,
struct aiVector3D* max,
struct aiMatrix4x4* trafo
){
struct aiMatrix4x4 prev;
unsigned int n = 0, t;
prev = *trafo;
aiMultiplyMatrix4(trafo,&nd->mTransformation);
for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
for (t = 0; t < mesh->mNumVertices; ++t) {
struct aiVector3D tmp = mesh->mVertices[t];
aiTransformVecByMatrix4(&tmp,trafo);
min->x = aisgl_min(min->x,tmp.x);
min->y = aisgl_min(min->y,tmp.y);
min->z = aisgl_min(min->z,tmp.z);
max->x = aisgl_max(max->x,tmp.x);
max->y = aisgl_max(max->y,tmp.y);
max->z = aisgl_max(max->z,tmp.z);
}
}
for (n = 0; n < nd->mNumChildren; ++n) {
get_bounding_box_for_node(nd->mChildren[n],min,max,trafo);
}
*trafo = prev;
}
/* ---------------------------------------------------------------------------- */
void get_bounding_box (struct aiVector3D* min, struct aiVector3D* max)
{
struct aiMatrix4x4 trafo;
aiIdentityMatrix4(&trafo);
min->x = min->y = min->z = 1e10f;
max->x = max->y = max->z = -1e10f;
get_bounding_box_for_node(scene->mRootNode,min,max,&trafo);
}
/* ---------------------------------------------------------------------------- */
void color4_to_float4(const struct aiColor4D *c, float f[4])
{
f[0] = c->r;
f[1] = c->g;
f[2] = c->b;
f[3] = c->a;
}
/* ---------------------------------------------------------------------------- */
void set_float4(float f[4], float a, float b, float c, float d)
{
f[0] = a;
f[1] = b;
f[2] = c;
f[3] = d;
}
/* ---------------------------------------------------------------------------- */
void apply_material(const struct aiMaterial *mtl)
{
float c[4];
GLenum fill_mode;
int ret1, ret2;
struct aiColor4D diffuse;
struct aiColor4D specular;
struct aiColor4D ambient;
struct aiColor4D emission;
float shininess, strength;
int two_sided;
int wireframe;
unsigned int max;
set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
color4_to_float4(&diffuse, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular))
color4_to_float4(&specular, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient))
color4_to_float4(&ambient, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, c);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission))
color4_to_float4(&emission, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, c);
max = 1;
ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max);
if(ret1 == AI_SUCCESS) {
max = 1;
ret2 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max);
if(ret2 == AI_SUCCESS)
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength);
else
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
}
else {
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f);
set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
}
max = 1;
if(AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max))
fill_mode = wireframe ? GL_LINE : GL_FILL;
else
fill_mode = GL_FILL;
glPolygonMode(GL_FRONT_AND_BACK, fill_mode);
max = 1;
if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided)
glDisable(GL_CULL_FACE);
else
glEnable(GL_CULL_FACE);
}
/* ---------------------------------------------------------------------------- */
void recursive_render (const struct aiScene *sc, const struct aiNode* nd)
{
unsigned int i;
unsigned int n = 0, t;
struct aiMatrix4x4 m = nd->mTransformation;
/* update transform */
aiTransposeMatrix4(&m);
glPushMatrix();
glMultMatrixf((float*)&m);
/* draw all meshes assigned to this node */
for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
apply_material(sc->mMaterials[mesh->mMaterialIndex]);
if(mesh->mNormals == NULL) {
glDisable(GL_LIGHTING);
} else {
glEnable(GL_LIGHTING);
}
for (t = 0; t < mesh->mNumFaces; ++t) {
const struct aiFace* face = &mesh->mFaces[t];
GLenum face_mode;
switch(face->mNumIndices) {
case 1: face_mode = GL_POINTS; break;
case 2: face_mode = GL_LINES; break;
case 3: face_mode = GL_TRIANGLES; break;
default: face_mode = GL_POLYGON; break;
}
glBegin(face_mode);
for(i = 0; i < face->mNumIndices; i++) {
int index = face->mIndices[i];
if(mesh->mColors[0] != NULL)
glColor4fv((GLfloat*)&mesh->mColors[0][index]);
if(mesh->mNormals != NULL)
glNormal3fv(&mesh->mNormals[index].x);
glVertex3fv(&mesh->mVertices[index].x);
}
glEnd();
}
}
/* draw all children */
for (n = 0; n < nd->mNumChildren; ++n) {
recursive_render(sc, nd->mChildren[n]);
}
glPopMatrix();
}
/* ---------------------------------------------------------------------------- */
void do_motion (void)
{
static GLint prev_time = 0;
static GLint prev_fps_time = 0;
static int frames = 0;
int time = glutGet(GLUT_ELAPSED_TIME);
angle += (time-prev_time)*0.01;
prev_time = time;
frames += 1;
if ((time - prev_fps_time) > 1000) /* update every seconds */
{
int current_fps = frames * 1000 / (time - prev_fps_time);
printf("%d fps\n", current_fps);
frames = 0;
prev_fps_time = time;
}
glutPostRedisplay ();
}
/* ---------------------------------------------------------------------------- */
void display(void)
{
float tmp;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
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 */
glRotatef(angle,0.f,1.f,0.f);
/* scale the whole asset to fit into our view frustum */
tmp = scene_max.x-scene_min.x;
tmp = aisgl_max(scene_max.y - scene_min.y,tmp);
tmp = aisgl_max(scene_max.z - scene_min.z,tmp);
tmp = 1.f / tmp;
glScalef(tmp, tmp, tmp);
/* center the model */
glTranslatef( -scene_center.x, -scene_center.y, -scene_center.z );
/* if the display list has not been made yet, create a new one and
fill it with scene contents */
if(scene_list == 0) {
scene_list = glGenLists(1);
glNewList(scene_list, GL_COMPILE);
/* now begin at the root node of the imported data and traverse
the scenegraph by multiplying subsequent local transforms
together on GL's matrix stack. */
recursive_render(scene, scene->mRootNode);
glEndList();
}
glCallList(scene_list);
glutSwapBuffers();
do_motion();
}
/* ---------------------------------------------------------------------------- */
int loadasset (const char* path)
{
/* we are taking one of the postprocessing presets to avoid
spelling out 20+ single postprocessing flags here. */
scene = aiImportFile(path,aiProcessPreset_TargetRealtime_MaxQuality);
if (scene) {
get_bounding_box(&scene_min,&scene_max);
scene_center.x = (scene_min.x + scene_max.x) / 2.0f;
scene_center.y = (scene_min.y + scene_max.y) / 2.0f;
scene_center.z = (scene_min.z + scene_max.z) / 2.0f;
return 0;
}
return 1;
}
/* ---------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
struct aiLogStream stream;
glutInitWindowSize(900,600);
glutInitWindowPosition(100,100);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInit(&argc, argv);
glutCreateWindow("Assimp - Very simple OpenGL sample");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
/* get a handle to the predefined STDOUT log stream and attach
it to the logging system. It remains active for all further
calls to aiImportFile(Ex) and aiApplyPostProcessing. */
stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
aiAttachLogStream(&stream);
/* ... same procedure, but this stream now writes the
log messages to assimp_log.txt */
stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt");
aiAttachLogStream(&stream);
/* the model name can be specified on the command line. If none
is specified, we try to locate one of the more expressive test
models from the repository (/models-nonbsd may be missing in
some distributions so we need a fallback from /models!). */
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"))) {
return -1;
}
}
glClearColor(0.1f,0.1f,0.1f,1.f);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); /* Uses default lighting parameters */
glEnable(GL_DEPTH_TEST);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_NORMALIZE);
/* XXX docs say all polygons are emitted CCW, but tests show that some aren't. */
if(getenv("MODEL_IS_BROKEN"))
glFrontFace(GL_CW);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glutGet(GLUT_ELAPSED_TIME);
glutMainLoop();
/* cleanup - calling 'aiReleaseImport' is important, as the library
keeps internal resources until the scene is freed again. Not
doing so can cause severe resource leaking. */
aiReleaseImport(scene);
/* We added a log stream to the library, it's our job to disable it
again. This will definitely release the last resources allocated
by Assimp.*/
aiDetachAllLogStreams();
return 0;
}
/* ----------------------------------------------------------------------------
// 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
// settings and displays it.
//
// If you intend to _use_ this code sample in your app, do yourself a favour
// and replace immediate mode calls with VBOs ...
//
// The vc8 solution links against assimp-release-dll_win32 - be sure to
// have this configuration built.
// ----------------------------------------------------------------------------
*/
#include <stdlib.h>
#include <stdio.h>
#ifdef __APPLE__
#include <glut.h>
#else
#include <GL/glut.h>
#endif
/* assimp include files. These three are usually needed. */
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
/* the global Assimp scene object */
const struct aiScene* scene = NULL;
GLuint scene_list = 0;
struct aiVector3D scene_min, scene_max, scene_center;
/* current rotation angle */
static float angle = 0.f;
#define aisgl_min(x,y) (x<y?x:y)
#define aisgl_max(x,y) (y>x?y:x)
/* ---------------------------------------------------------------------------- */
void reshape(int width, int height)
{
const double aspectRatio = (float) width / height, fieldOfView = 45.0;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fieldOfView, aspectRatio,
1.0, 1000.0); /* Znear and Zfar */
glViewport(0, 0, width, height);
}
/* ---------------------------------------------------------------------------- */
void get_bounding_box_for_node (const struct aiNode* nd,
struct aiVector3D* min,
struct aiVector3D* max,
struct aiMatrix4x4* trafo
){
struct aiMatrix4x4 prev;
unsigned int n = 0, t;
prev = *trafo;
aiMultiplyMatrix4(trafo,&nd->mTransformation);
for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
for (t = 0; t < mesh->mNumVertices; ++t) {
struct aiVector3D tmp = mesh->mVertices[t];
aiTransformVecByMatrix4(&tmp,trafo);
min->x = aisgl_min(min->x,tmp.x);
min->y = aisgl_min(min->y,tmp.y);
min->z = aisgl_min(min->z,tmp.z);
max->x = aisgl_max(max->x,tmp.x);
max->y = aisgl_max(max->y,tmp.y);
max->z = aisgl_max(max->z,tmp.z);
}
}
for (n = 0; n < nd->mNumChildren; ++n) {
get_bounding_box_for_node(nd->mChildren[n],min,max,trafo);
}
*trafo = prev;
}
/* ---------------------------------------------------------------------------- */
void get_bounding_box (struct aiVector3D* min, struct aiVector3D* max)
{
struct aiMatrix4x4 trafo;
aiIdentityMatrix4(&trafo);
min->x = min->y = min->z = 1e10f;
max->x = max->y = max->z = -1e10f;
get_bounding_box_for_node(scene->mRootNode,min,max,&trafo);
}
/* ---------------------------------------------------------------------------- */
void color4_to_float4(const struct aiColor4D *c, float f[4])
{
f[0] = c->r;
f[1] = c->g;
f[2] = c->b;
f[3] = c->a;
}
/* ---------------------------------------------------------------------------- */
void set_float4(float f[4], float a, float b, float c, float d)
{
f[0] = a;
f[1] = b;
f[2] = c;
f[3] = d;
}
/* ---------------------------------------------------------------------------- */
void apply_material(const struct aiMaterial *mtl)
{
float c[4];
GLenum fill_mode;
int ret1, ret2;
struct aiColor4D diffuse;
struct aiColor4D specular;
struct aiColor4D ambient;
struct aiColor4D emission;
float shininess, strength;
int two_sided;
int wireframe;
unsigned int max;
set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
color4_to_float4(&diffuse, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular))
color4_to_float4(&specular, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient))
color4_to_float4(&ambient, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, c);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission))
color4_to_float4(&emission, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, c);
max = 1;
ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max);
if(ret1 == AI_SUCCESS) {
max = 1;
ret2 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max);
if(ret2 == AI_SUCCESS)
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength);
else
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
}
else {
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f);
set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
}
max = 1;
if(AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max))
fill_mode = wireframe ? GL_LINE : GL_FILL;
else
fill_mode = GL_FILL;
glPolygonMode(GL_FRONT_AND_BACK, fill_mode);
max = 1;
if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided)
glDisable(GL_CULL_FACE);
else
glEnable(GL_CULL_FACE);
}
/* ---------------------------------------------------------------------------- */
void recursive_render (const struct aiScene *sc, const struct aiNode* nd)
{
unsigned int i;
unsigned int n = 0, t;
struct aiMatrix4x4 m = nd->mTransformation;
/* update transform */
aiTransposeMatrix4(&m);
glPushMatrix();
glMultMatrixf((float*)&m);
/* draw all meshes assigned to this node */
for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
apply_material(sc->mMaterials[mesh->mMaterialIndex]);
if(mesh->mNormals == NULL) {
glDisable(GL_LIGHTING);
} else {
glEnable(GL_LIGHTING);
}
for (t = 0; t < mesh->mNumFaces; ++t) {
const struct aiFace* face = &mesh->mFaces[t];
GLenum face_mode;
switch(face->mNumIndices) {
case 1: face_mode = GL_POINTS; break;
case 2: face_mode = GL_LINES; break;
case 3: face_mode = GL_TRIANGLES; break;
default: face_mode = GL_POLYGON; break;
}
glBegin(face_mode);
for(i = 0; i < face->mNumIndices; i++) {
int index = face->mIndices[i];
if(mesh->mColors[0] != NULL)
glColor4fv((GLfloat*)&mesh->mColors[0][index]);
if(mesh->mNormals != NULL)
glNormal3fv(&mesh->mNormals[index].x);
glVertex3fv(&mesh->mVertices[index].x);
}
glEnd();
}
}
/* draw all children */
for (n = 0; n < nd->mNumChildren; ++n) {
recursive_render(sc, nd->mChildren[n]);
}
glPopMatrix();
}
/* ---------------------------------------------------------------------------- */
void do_motion (void)
{
static GLint prev_time = 0;
static GLint prev_fps_time = 0;
static int frames = 0;
int time = glutGet(GLUT_ELAPSED_TIME);
angle += (time-prev_time)*0.01;
prev_time = time;
frames += 1;
if ((time - prev_fps_time) > 1000) /* update every seconds */
{
int current_fps = frames * 1000 / (time - prev_fps_time);
printf("%d fps\n", current_fps);
frames = 0;
prev_fps_time = time;
}
glutPostRedisplay ();
}
/* ---------------------------------------------------------------------------- */
void display(void)
{
float tmp;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
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 */
glRotatef(angle,0.f,1.f,0.f);
/* scale the whole asset to fit into our view frustum */
tmp = scene_max.x-scene_min.x;
tmp = aisgl_max(scene_max.y - scene_min.y,tmp);
tmp = aisgl_max(scene_max.z - scene_min.z,tmp);
tmp = 1.f / tmp;
glScalef(tmp, tmp, tmp);
/* center the model */
glTranslatef( -scene_center.x, -scene_center.y, -scene_center.z );
/* if the display list has not been made yet, create a new one and
fill it with scene contents */
if(scene_list == 0) {
scene_list = glGenLists(1);
glNewList(scene_list, GL_COMPILE);
/* now begin at the root node of the imported data and traverse
the scenegraph by multiplying subsequent local transforms
together on GL's matrix stack. */
recursive_render(scene, scene->mRootNode);
glEndList();
}
glCallList(scene_list);
glutSwapBuffers();
do_motion();
}
/* ---------------------------------------------------------------------------- */
int loadasset (const char* path)
{
/* we are taking one of the postprocessing presets to avoid
spelling out 20+ single postprocessing flags here. */
scene = aiImportFile(path,aiProcessPreset_TargetRealtime_MaxQuality);
if (scene) {
get_bounding_box(&scene_min,&scene_max);
scene_center.x = (scene_min.x + scene_max.x) / 2.0f;
scene_center.y = (scene_min.y + scene_max.y) / 2.0f;
scene_center.z = (scene_min.z + scene_max.z) / 2.0f;
return 0;
}
return 1;
}
/* ---------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
struct aiLogStream stream;
glutInitWindowSize(900,600);
glutInitWindowPosition(100,100);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInit(&argc, argv);
glutCreateWindow("Assimp - Very simple OpenGL sample");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
/* get a handle to the predefined STDOUT log stream and attach
it to the logging system. It remains active for all further
calls to aiImportFile(Ex) and aiApplyPostProcessing. */
stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
aiAttachLogStream(&stream);
/* ... same procedure, but this stream now writes the
log messages to assimp_log.txt */
stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt");
aiAttachLogStream(&stream);
/* the model name can be specified on the command line. If none
is specified, we try to locate one of the more expressive test
models from the repository (/models-nonbsd may be missing in
some distributions so we need a fallback from /models!). */
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"))) {
return -1;
}
}
glClearColor(0.1f,0.1f,0.1f,1.f);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); /* Uses default lighting parameters */
glEnable(GL_DEPTH_TEST);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_NORMALIZE);
/* XXX docs say all polygons are emitted CCW, but tests show that some aren't. */
if(getenv("MODEL_IS_BROKEN"))
glFrontFace(GL_CW);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glutGet(GLUT_ELAPSED_TIME);
glutMainLoop();
/* cleanup - calling 'aiReleaseImport' is important, as the library
keeps internal resources until the scene is freed again. Not
doing so can cause severe resource leaking. */
aiReleaseImport(scene);
/* We added a log stream to the library, it's our job to disable it
again. This will definitely release the last resources allocated
by Assimp.*/
aiDetachAllLogStreams();
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
# ==============================================================================
# use genentitylist.sh to update this list
# This machine-generated list is not complete, it lacks many intermediate
# classes in the inheritance hierarchy. Those are magically augmented by the
# code generator. Also, the names of all used entities need to be present
# in the source code for this to work.
IfcAnnotation
IfcArbitraryClosedProfileDef
IfcArbitraryOpenProfileDef
IfcArbitraryProfileDefWithVoids
IfcAxis1Placement
IfcAxis2Placement
IfcAxis2Placement2D
IfcAxis2Placement3D
IfcBooleanClippingResult
IfcBooleanResult
IfcBoundedCurve
IfcBoundingBox
IfcBSplineCurve
IfcBuilding
IfcCartesianPoint
IfcCartesianTransformationOperator
IfcCartesianTransformationOperator3D
IfcCartesianTransformationOperator3DnonUniform
IfcCircle
IfcCircleHollowProfileDef
IfcCircleProfileDef
IfcClosedShell
IfcColourOrFactor
IfcColourRgb
IfcCompositeCurve
IfcCompositeCurveSegment
IfcConic
IfcConnectedFaceSet
IfcConversionBasedUnit
IfcCurve
IfcDirection
IfcDoor
IfcEllipse
IfcExtrudedAreaSolid
IfcFace
IfcFaceBasedSurfaceModel
IfcFaceBound
IfcFaceOuterBound
IfcFeatureElementSubtraction
IfcGeometricRepresentationContext
IfcGeometricRepresentationItem
IfcHalfSpaceSolid
IfcLine
IfcLocalPlacement
IfcManifoldSolidBrep
IfcMappedItem
IfcMeasureWithUnit
IfcNamedUnit
IfcObjectDefinition
IfcObjectPlacement
IfcOpeningElement
IfcParameterizedProfileDef
IfcPlane
IfcPolygonalBoundedHalfSpace
IfcPolyline
IfcPolyLoop
IfcPresentationStyleAssignment
IfcPresentationStyleSelect
IfcProduct
IfcProductRepresentation
IfcProfileDef
IfcProject
IfcRectangleProfileDef
IfcRelAggregates
IfcRelContainedInSpatialStructure
IfcRelFillsElement
IfcRelVoidsElement
IfcRepresentation
IfcRepresentationContext
IfcRepresentationItem
IfcRepresentationMap
IfcRevolvedAreaSolid
IfcShell
IfcShellBasedSurfaceModel
IfcSite
IfcSIUnit
IfcSomething
IfcSpace
IfcSpatialStructureElement
IfcSpatialStructureElements
IfcStyledItem
IfcSurfaceStyle
IfcSurfaceStyleElementSelect
IfcSurfaceStyleRendering
IfcSurfaceStyleShading
IfcSurfaceStyleWithTextures
IfcSweptAreaSolid
IfcSweptDiskSolid
IfcTopologicalRepresentationItem
IfcTrimmedCurve
IfcUnit
IfcUnitAssignment
IfcVector
IfcIShapeProfileDef
IfcPropertyListValue
IfcRelDefinesByProperties
IfcPropertySet
IfcPropertySingleValue
IfcProperty
IfcComplexProperty
IfcElementQuantity
# ==============================================================================
# List of IFC structures needed by Assimp
# ==============================================================================
# use genentitylist.sh to update this list
# This machine-generated list is not complete, it lacks many intermediate
# classes in the inheritance hierarchy. Those are magically augmented by the
# code generator. Also, the names of all used entities need to be present
# in the source code for this to work.
IfcAnnotation
IfcArbitraryClosedProfileDef
IfcArbitraryOpenProfileDef
IfcArbitraryProfileDefWithVoids
IfcAxis1Placement
IfcAxis2Placement
IfcAxis2Placement2D
IfcAxis2Placement3D
IfcBooleanClippingResult
IfcBooleanResult
IfcBoundedCurve
IfcBoundingBox
IfcBSplineCurve
IfcBuilding
IfcCartesianPoint
IfcCartesianTransformationOperator
IfcCartesianTransformationOperator3D
IfcCartesianTransformationOperator3DnonUniform
IfcCircle
IfcCircleHollowProfileDef
IfcCircleProfileDef
IfcClosedShell
IfcColourOrFactor
IfcColourRgb
IfcCompositeCurve
IfcCompositeCurveSegment
IfcConic
IfcConnectedFaceSet
IfcConversionBasedUnit
IfcCurve
IfcDirection
IfcDoor
IfcEllipse
IfcExtrudedAreaSolid
IfcFace
IfcFaceBasedSurfaceModel
IfcFaceBound
IfcFaceOuterBound
IfcFeatureElementSubtraction
IfcGeometricRepresentationContext
IfcGeometricRepresentationItem
IfcHalfSpaceSolid
IfcLine
IfcLocalPlacement
IfcManifoldSolidBrep
IfcMappedItem
IfcMeasureWithUnit
IfcNamedUnit
IfcObjectDefinition
IfcObjectPlacement
IfcOpeningElement
IfcParameterizedProfileDef
IfcPlane
IfcPolygonalBoundedHalfSpace
IfcPolyline
IfcPolyLoop
IfcPresentationStyleAssignment
IfcPresentationStyleSelect
IfcProduct
IfcProductRepresentation
IfcProfileDef
IfcProject
IfcRectangleProfileDef
IfcRelAggregates
IfcRelContainedInSpatialStructure
IfcRelFillsElement
IfcRelVoidsElement
IfcRepresentation
IfcRepresentationContext
IfcRepresentationItem
IfcRepresentationMap
IfcRevolvedAreaSolid
IfcShell
IfcShellBasedSurfaceModel
IfcSite
IfcSIUnit
IfcSomething
IfcSpace
IfcSpatialStructureElement
IfcSpatialStructureElements
IfcStyledItem
IfcSurfaceStyle
IfcSurfaceStyleElementSelect
IfcSurfaceStyleRendering
IfcSurfaceStyleShading
IfcSurfaceStyleWithTextures
IfcSweptAreaSolid
IfcSweptDiskSolid
IfcTopologicalRepresentationItem
IfcTrimmedCurve
IfcUnit
IfcUnitAssignment
IfcVector
IfcIShapeProfileDef
IfcPropertyListValue
IfcRelDefinesByProperties
IfcPropertySet
IfcPropertySingleValue
IfcProperty
IfcComplexProperty
IfcElementQuantity

View File

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

View File

@ -1,18 +1,18 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008.
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. 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.
"
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008.
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. 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.
"

View File

@ -1,18 +1,18 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"

View File

@ -1,15 +1,15 @@
Jeep designed, modelled and skinned by me, Psionic
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.
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:-
http://xu1productions.com/3dstudio/index.html - 3D Game Resources
http://www.psionicdesign.com - My Main 2D/3D Digital Art site
Jeep designed, modelled and skinned by me, Psionic
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.
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:-
http://xu1productions.com/3dstudio/index.html - 3D Game Resources
http://www.psionicdesign.com - My Main 2D/3D Digital Art site
Psionic 2002

View File

@ -1,18 +1,18 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"

View File

@ -1,18 +1,18 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"

View File

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

View File

@ -1,25 +1,25 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
CONVERTED FROM 3DS TO ASE WITH AC3D

View File

@ -1,24 +1,24 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
CONVERTED FROM 3DS TO ASE WITH AC3D

View File

@ -1,51 +1,51 @@
Dwarf lowpoly model Pack
Copyright 2004, Psionic Design
e-mail: psionic@blueyonder.co.uk
Used with permission.
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!
USAGE INFORMATION:
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
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:-
website: http://www.psionic3d.co.uk
email: psionic@blueyonder.co.uk
WHAT'S INCLUDED IN THE ZIP:
ReadMe.txt - This file
b3d.zip - Blitz 3D Format models and textures
ms3d.zip - Milkshape 3D Format models and textures
x.zip - DarkBasic Direct X 8 Format models and textures
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 redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent.
Psi
http://www.psionic3d.co.uk
Dwarf lowpoly model Pack
Copyright 2004, Psionic Design
e-mail: psionic@blueyonder.co.uk
Used with permission.
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!
USAGE INFORMATION:
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
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:-
website: http://www.psionic3d.co.uk
email: psionic@blueyonder.co.uk
WHAT'S INCLUDED IN THE ZIP:
ReadMe.txt - This file
b3d.zip - Blitz 3D Format models and textures
ms3d.zip - Milkshape 3D Format models and textures
x.zip - DarkBasic Direct X 8 Format models and textures
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 redistribute this pack in some other model pack through a website or on a compilation CD of any kind, without my written consent.
Psi
http://www.psionic3d.co.uk

View File

@ -1,11 +1,11 @@
turtle1.b3d
Copyright 2004, Psionic Design
e-mail: psionic@blueyonder.co.uk
Used with permission.
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.
turtle1.b3d
Copyright 2004, Psionic Design
e-mail: psionic@blueyonder.co.uk
Used with permission.
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 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
AUTHOR : Ken Beyer (kat)
EMAIL ADDRESS : info@katsbits.com
HOMEPAGE URL : http://www.katsbits.com
MODEL NAME/s
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.
DISTRIBUTION
Copyright © 2009 KatsBits. Distribution MUST include this readme and authorship attribution.
Commercial use is permitted with written licensed permission.
----------------------------------------------------------------------------------------------
Files:
- Bob.md5mesh
- Bob.md5anim
- Bob.blend
- ./*.png
Changes:
- converted all tga's to png, updated .blend and .md5mesh accordingly
- removed absolute texture paths from the md5mesh file
- minor downscaling of all textures to fit in less bytes
----------------------------------------------------------------------------------------------
TITLE : Bob, MD5 character source file
AUTHOR : Ken Beyer (kat)
EMAIL ADDRESS : info@katsbits.com
HOMEPAGE URL : http://www.katsbits.com
MODEL NAME/s
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.
DISTRIBUTION
Copyright © 2009 KatsBits. Distribution MUST include this readme and authorship attribution.
Commercial use is permitted with written licensed permission.
----------------------------------------------------------------------------------------------
Files:
- Bob.md5mesh
- Bob.md5anim
- Bob.blend
- ./*.png
Changes:
- converted all tga's to png, updated .blend and .md5mesh accordingly
- removed absolute texture paths from the md5mesh file
- minor downscaling of all textures to fit in less bytes

View File

@ -1,23 +1,23 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
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

View File

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

View File

@ -1,31 +1,31 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
"These 3d models are contributed by John Hoffman and are based on
characters from a cartoon show called "Jayce and the wheel warriors"
(except the marauder) John's site: http://www3.sympatico.ca/john.hoffman"
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
These files belong to the QuickDraw model in the LWS folder - they are referenced
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
"These 3d models are contributed by John Hoffman and are based on
characters from a cartoon show called "Jayce and the wheel warriors"
(except the marauder) John's site: http://www3.sympatico.ca/john.hoffman"
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
These files belong to the QuickDraw model in the LWS folder - they are referenced
and loaded into the LWS scene.

View File

@ -1,24 +1,24 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
INFO
====
CONVERTED FROM 3DS TO LWO2 WITH AC3D

View File

@ -1,15 +1,15 @@
From http://telias.free.fr
Downloaded 4th November 2008 (Obama ftw!).
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.
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.
"
CHANGES:
From http://telias.free.fr
Downloaded 4th November 2008 (Obama ftw!).
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.
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.
"
CHANGES:
Paths have been modified

View File

@ -1,18 +1,18 @@
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"
=====================================================================
From http://telias.free.fr
Model copyright: Elias Tsiantas
=====================================================================
Downloaded 4th November 2008 (Obama ftw!).
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. 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.
"

View File

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

View File

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

View File

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

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