First checkin for OpenMesh 2.0

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@2 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2009-02-06 13:37:46 +00:00
parent c3321ebdd9
commit 97f515985d
417 changed files with 76182 additions and 0 deletions

17
Core/System/ACGMakefile Normal file
View File

@@ -0,0 +1,17 @@
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Config
#==============================================================================
SUBDIRS = $(call find-subdirs)
PACKAGES :=
PROJ_LIBS :=
MODULES := cxxlib
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Rules
#==============================================================================

161
Core/System/compiler.hh Normal file
View File

@@ -0,0 +1,161 @@
//=============================================================================
//
// OpenMesh
// Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen
// www.openmesh.org
//
//-----------------------------------------------------------------------------
//
// License
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, version 2.1.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//-----------------------------------------------------------------------------
//
// $Revision: 1801 $
// $Date: 2008-05-19 11:53:56 +0200 (Mo, 19. Mai 2008) $
//
//=============================================================================
#ifndef OPENMESH_COMPILER_H
#define OPENMESH_COMPILER_H
//=============================================================================
#if defined(ACGMAKE_STATIC_BUILD)
# define OM_STATIC_BUILD 1
#endif
//=============================================================================
#if defined(_DEBUG) || defined(DEBUG)
# define OM_DEBUG
#endif
//=============================================================================
// Workaround for Intel Compiler with MS VC++ 6
#if defined(_MSC_VER) && \
( defined(__ICL) || defined(__INTEL_COMPILER) || defined(__ICC) )
# if !defined(__INTEL_COMPILER)
# define __INTEL_COMPILER __ICL
# endif
# define OM_USE_INTEL_COMPILER 1
#endif
// --------------------------------------------------------- MS Visual C++ ----
// Compiler _MSC_VER
// .NET 2002 1300
// .NET 2003 1310
// .NET 2005 1400
#if defined(_MSC_VER) && !defined(OM_USE_INTEL_COMPILER)
# if (_MSC_VER == 1300)
# define OM_CC_MSVC
# define OM_TYPENAME
# define OM_OUT_OF_CLASS_TEMPLATE 0
# define OM_PARTIAL_SPECIALIZATION 0
# define OM_INCLUDE_TEMPLATES 1
# elif (_MSC_VER == 1310)
# define OM_CC_MSVC
# define OM_TYPENAME
# define OM_OUT_OF_CLASS_TEMPLATE 1
# define OM_PARTIAL_SPECIALIZATION 1
# define OM_INCLUDE_TEMPLATES 1
# elif (_MSC_VER >= 1400) // settings for .NET 2005 (NOTE: not fully tested)
# pragma warning(disable : 4996)
# define OM_TYPENAME
# define OM_OUT_OF_CLASS_TEMPLATE 1
# define OM_PARTIAL_SPECIALIZATION 1
# define OM_INCLUDE_TEMPLATES 1
# else
# error "Version 7 (.NET 2002) or higher of the MS VC++ is required!"
# endif
// currently no windows dll supported
# define OM_STATIC_BUILD 1
# if defined(_MT)
# define OM_REENTRANT 1
# endif
# define OM_CC "MSVC++"
# define OM_CC_VERSION _MSC_VER
// Does not work stable because the define _CPPRTTI sometimes does not exist,
// though the option /GR is set!?
# if defined(__cplusplus) && !defined(_CPPRTTI)
# error "Enable Runtime Type Information (Compiler Option /GR)!"
# endif
# if !defined(_USE_MATH_DEFINES)
# error "You have to define _USE_MATH_DEFINES in the compiler settings!"
# endif
// ------------------------------------------------------------- Borland C ----
#elif defined(__BORLANDC__)
# error "Borland Compiler are not supported yet!"
// ------------------------------------------------------------- GNU C/C++ ----
#elif defined(__GNUC__) && !defined(__ICC)
# define OM_CC_GCC
# define OM_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 )
# define OM_GCC_MAJOR __GNUC__
# define OM_GCC_MINOR __GNUC_MINOR__
# if (OM_GCC_VERSION >= 30200)
# define OM_TYPENAME typename
# define OM_OUT_OF_CLASS_TEMPLATE 1
# define OM_PARTIAL_SPECIALIZATION 1
# define OM_INCLUDE_TEMPLATES 1
# else
# error "Version 3.2.0 or better of the GNU Compiler is required!"
# endif
# if defined(_REENTRANT)
# define OM_REENTRANT 1
# endif
# define OM_CC "GCC"
# define OM_CC_VERSION OM_GCC_VERSION
// ------------------------------------------------------------- Intel icc ----
#elif defined(__ICC) || defined(__INTEL_COMPILER)
# define OM_CC_ICC
# define OM_TYPENAME typename
# define OM_OUT_OF_CLASS_TEMPLATE 1
# define OM_PARTIAL_SPECIALIZATION 1
# define OM_INCLUDE_TEMPLATES 1
# if defined(_REENTRANT) || defined(_MT)
# define OM_REENTRANT 1
# endif
# define OM_CC "ICC"
# define OM_CC_VERSION __INTEL_COMPILER
// currently no windows dll supported
# if defined(_MSC_VER) || defined(WIN32)
# define OM_STATIC_BUILD 1
# endif
// ------------------------------------------------------ MIPSpro Compiler ----
#elif defined(__MIPS_ISA) || defined(__mips)
// _MIPS_ISA
// _COMPILER_VERSION e.g. 730, 7 major, 3 minor
// _MIPS_FPSET 32|64
// _MIPS_SZINT 32|64
// _MIPS_SZLONG 32|64
// _MIPS_SZPTR 32|64
# define OM_CC_MIPS
# define OM_TYPENAME typename
# define OM_OUT_OF_CLASS_TEMPLATE 1
# define OM_PARTIAL_SPECIALIZATION 1
# define OM_INCLUDE_TEMPLATES 0
# define OM_CC "MIPS"
# define OM_CC_VERSION _COMPILER_VERSION
// ------------------------------------------------------------------ ???? ----
#else
# error "You're using an unsupported compiler!"
#endif
//=============================================================================
#endif // OPENMESH_COMPILER_H defined
//=============================================================================

60
Core/System/config.h Normal file
View File

@@ -0,0 +1,60 @@
//=============================================================================
//
// OpenMesh
// Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen
// www.openmesh.org
//
//-----------------------------------------------------------------------------
//
// License
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, version 2.1.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//-----------------------------------------------------------------------------
//
// $Revision: 1.2 $
// $Date: 2007-05-18 15:17:48 $
//
//=============================================================================
/** \file config.h
* \todo Move content to config.hh and include it to be compatible with old
* source.
*/
//=============================================================================
#ifndef OPENMESH_CONFIG_H
#define OPENMESH_CONFIG_H
//=============================================================================
#include <assert.h>
#include <OpenMesh/Core/System/compiler.hh>
// ----------------------------------------------------------------------------
#define OM_VERSION 0x10000
// only defined, if it is a beta version
#define OM_VERSION_BETA 4
#define OM_GET_VER ((OM_VERSION && 0xf0000) >> 16)
#define OM_GET_MAJ ((OM_VERSION && 0x0ff00) >> 8)
#define OM_GET_MIN (OM_VERSION && 0x000ff)
typedef unsigned int uint;
//=============================================================================
#endif // OPENMESH_CONFIG_H defined
//=============================================================================

1
Core/System/config.hh Normal file
View File

@@ -0,0 +1 @@
#include <OpenMesh/Core/System/config.h>

282
Core/System/mostream.hh Normal file
View File

@@ -0,0 +1,282 @@
/*===========================================================================*\
* *
* OpenMesh *
* Copyright (C) 2001-2003 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
* *
* License *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, version 2.1. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
\*===========================================================================*/
//=============================================================================
//
// multiplex streams & ultilities
//
//=============================================================================
#ifndef OPENMESH_MOSTREAM_HH
#define OPENMESH_MOSTREAM_HH
//== INCLUDES =================================================================
#include <OpenMesh/Core/System/config.h>
#include <iostream>
#if defined( OM_CC_GCC ) && OM_CC_VERSION < 30000
# include <streambuf.h>
#else
# include <streambuf>
#endif
#include <vector>
#include <map>
#include <string>
#include <algorithm>
//== NAMESPACES ===============================================================
namespace OpenMesh {
#ifndef DOXY_IGNORE_THIS
//== CLASS DEFINITION =========================================================
class basic_multiplex_target
{
public:
virtual ~basic_multiplex_target() {}
virtual void operator<<(const std::string& _s) = 0;
};
template <class T>
class multiplex_target : public basic_multiplex_target
{
public:
multiplex_target(T& _t) : target_(_t) {}
virtual void operator<<(const std::string& _s) { target_ << _s; }
private:
T& target_;
};
//== CLASS DEFINITION =========================================================
#if defined( OM_CC_GCC ) && OM_CC_VERSION < 30000
# define STREAMBUF streambuf
# define INT_TYPE int
# define TRAITS_TYPE
#else
# define STREAMBUF std::basic_streambuf<char>
#endif
class multiplex_streambuf : public STREAMBUF
{
public:
typedef STREAMBUF base_type;
#if defined( OM_CC_GCC ) && OM_CC_VERSION < 30000
typedef int int_type;
struct traits_type
{
static int_type eof() { return -1; }
static char to_char_type(int_type c) { return char(c); }
};
#else
typedef base_type::int_type int_type;
typedef base_type::traits_type traits_type;
#endif
// Constructor
multiplex_streambuf() : enabled_(true) { buffer_.reserve(100); }
// Destructor
~multiplex_streambuf()
{
tmap_iter t_it(target_map_.begin()), t_end(target_map_.end());
for (; t_it!=t_end; ++t_it)
delete t_it->second;
}
// buffer enable/disable
bool is_enabled() const { return enabled_; }
void enable() { enabled_ = true; }
void disable() { enabled_ = false; }
// construct multiplex_target<T> and add it to targets
template <class T> bool connect(T& _target)
{
void* key = (void*) &_target;
if (target_map_.find(key) != target_map_.end())
return false;
target_type* mtarget = new multiplex_target<T>(_target);
target_map_[key] = mtarget;
__connect(mtarget);
return true;
}
// disconnect target from multiplexer
template <class T> bool disconnect(T& _target)
{
void* key = (void*) &_target;
tmap_iter t_it = target_map_.find(key);
if (t_it != target_map_.end())
{
__disconnect(t_it->second);
target_map_.erase(t_it);
return true;
}
return false;
}
protected:
// output what's in buffer_
virtual int sync()
{
if (!buffer_.empty())
{
if (enabled_) multiplex();
#if defined(OM_CC_GCC) || OM_CC_VERSION < 30000
buffer_ = ""; // member clear() not available!
#else
buffer_.clear();
#endif
}
return base_type::sync();
}
// take on char and add it to buffer_
// if '\n' is encountered, trigger a sync()
virtual
int_type overflow(int_type _c = multiplex_streambuf::traits_type::eof())
{
char c = traits_type::to_char_type(_c);
buffer_.push_back(c);
if (c == '\n') sync();
return 0;
}
private:
typedef basic_multiplex_target target_type;
typedef std::vector<target_type*> target_list;
typedef target_list::iterator tlist_iter;
typedef std::map<void*, target_type*> target_map;
typedef target_map::iterator tmap_iter;
// add _target to list of multiplex targets
void __connect(target_type* _target) { targets_.push_back(_target); }
// remove _target from list of multiplex targets
void __disconnect(target_type* _target) {
targets_.erase(std::find(targets_.begin(), targets_.end(), _target));
}
// multiplex output of buffer_ to all targets
void multiplex()
{
tlist_iter t_it(targets_.begin()), t_end(targets_.end());
for (; t_it!=t_end; ++t_it)
**t_it << buffer_;
}
private:
target_list targets_;
target_map target_map_;
std::string buffer_;
bool enabled_;
};
#undef STREAMBUF
//== CLASS DEFINITION =========================================================
/** \class mostream mostream.hh <OpenMesh/Core/System/mostream.hh>
This class provides streams that can easily be multiplexed (using
the connect() method) and toggled on/off (using enable() /
disable()).
\see omlog, omout, omerr
*/
class mostream : public std::ostream
{
public:
/// Explicit constructor
explicit mostream() : std::ostream(NULL) { init(&streambuffer_); }
/// Connect target to multiplexer
template <class T> bool connect(T& _target)
{
return streambuffer_.connect(_target);
}
/// Disconnect target from multiplexer
template <class T> bool disconnect(T& _target)
{
return streambuffer_.disconnect(_target);
}
/// is buffer enabled
bool is_enabled() const { return streambuffer_.is_enabled(); }
/// enable this buffer
void enable() { streambuffer_.enable(); }
/// disable this buffer
void disable() { streambuffer_.disable(); }
private:
multiplex_streambuf streambuffer_;
};
//=============================================================================
#endif
} // namespace OpenMesh
//=============================================================================
#endif // OPENMESH_MOSTREAM_HH defined
//=============================================================================

74
Core/System/omstream.cc Normal file
View File

@@ -0,0 +1,74 @@
/*===========================================================================*\
* *
* OpenMesh *
* Copyright (C) 2001-2003 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
* *
* License *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, version 2.1. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
\*===========================================================================*/
//=============================================================================
//
// CLASS mostream - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include <OpenMesh/Core/System/omstream.hh>
//== IMPLEMENTATION ==========================================================
OpenMesh::mostream& omlog()
{
static bool initialized = false;
static OpenMesh::mostream mystream;
if (!initialized)
{
mystream.connect(std::clog);
#ifdef NDEBUG
mystream.disable();
#endif
}
return mystream;
}
OpenMesh::mostream& omout()
{
static bool initialized = false;
static OpenMesh::mostream mystream;
if (!initialized) mystream.connect(std::cout);
return mystream;
}
OpenMesh::mostream& omerr()
{
static bool initialized = false;
static OpenMesh::mostream mystream;
if (!initialized) mystream.connect(std::cerr);
return mystream;
}
//=============================================================================

61
Core/System/omstream.hh Normal file
View File

@@ -0,0 +1,61 @@
/*===========================================================================*\
* *
* OpenMesh *
* Copyright (C) 2001-2003 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org *
* *
*---------------------------------------------------------------------------*
* *
* License *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, version 2.1. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
\*===========================================================================*/
//=============================================================================
//
// OpenMesh streams: omlog, omout, omerr
//
//=============================================================================
#ifndef OPENMESH_OMSTREAMS_HH
#define OPENMESH_OMSTREAMS_HH
//== INCLUDES =================================================================
#include <OpenMesh/Core/System/mostream.hh>
//== CLASS DEFINITION =========================================================
/** \file omstream.hh
This file provides the streams omlog, omout, and omerr.
*/
//@{
/** These stream provide replacements for clog, cout, and cerr. They have
the advantage that they can easily be multiplexed.
\see OpenMesh::mostream
*/
OpenMesh::mostream& omlog();
OpenMesh::mostream& omout();
OpenMesh::mostream& omerr();
//@}
//=============================================================================
#endif // OPENMESH_OMSTREAMS_HH defined
//=============================================================================