add btFileUtils::toLower to convert a string (char*) to lower case
URDF import demo: add COLLADA .dae file support add FiniteElementMethod demo, extracted from the OpenTissue library (under the zlib license) don't crash if loading an invalid STL file add comparison with Assimp for COLLADA file loading (disabled by default, to avoid library dependency) Gwen: disable some flags that make the build incompatible
This commit is contained in:
162
Demos3/FiniteElementMethod/OpenTissue/utility/utility_class_id.h
Normal file
162
Demos3/FiniteElementMethod/OpenTissue/utility/utility_class_id.h
Normal file
@@ -0,0 +1,162 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_CLASS_ID_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_CLASS_ID_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
/** @internal ID Generator class.
|
||||
* This class encapsulates the generation of unique IDs as used by ClassID.
|
||||
*
|
||||
* @warning
|
||||
* This class should never be used directly.
|
||||
*/
|
||||
class BaseIDGenerator
|
||||
{
|
||||
|
||||
template < class T >
|
||||
friend class ClassID;
|
||||
|
||||
private:
|
||||
|
||||
BaseIDGenerator(); // Disable default constructor
|
||||
|
||||
/** ID generation method
|
||||
*
|
||||
* @return
|
||||
* An increasing unique ID.
|
||||
*/
|
||||
static size_t const generate_id()
|
||||
{
|
||||
static size_t id = 0;
|
||||
return id++;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** The Class ID interface.
|
||||
*/
|
||||
class ClassIDInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** Destructor
|
||||
*/
|
||||
virtual ~ClassIDInterface(){}
|
||||
|
||||
/** Query the class ID.
|
||||
*
|
||||
* @return
|
||||
* The object's class ID
|
||||
*/
|
||||
virtual size_t const class_id() const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CRTP Implementation of the ClassIDInterface.
|
||||
*
|
||||
* Usage:
|
||||
* To enable class IDs for a custom class, simply inherite this class giving
|
||||
* itself as the template argument.
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* class SomeClass:
|
||||
* public ClassID<SomeClass>
|
||||
* { ... };
|
||||
* \endcode
|
||||
*
|
||||
* @tparam T
|
||||
* The deriving class
|
||||
*/
|
||||
template < class T >
|
||||
class ClassID
|
||||
: virtual public ClassIDInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Query the object ID.
|
||||
*
|
||||
* @return
|
||||
* The object ID
|
||||
*/
|
||||
static size_t const id()
|
||||
{
|
||||
static size_t my_id = BaseIDGenerator::generate_id();
|
||||
return my_id;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
virtual size_t const class_id() const
|
||||
{
|
||||
return id();
|
||||
}
|
||||
};
|
||||
|
||||
/** Helper class for solving ambiguousity between class IDs.
|
||||
* This class enables inheritance from another class, which already have a class ID.
|
||||
*
|
||||
* Problem:
|
||||
* \code
|
||||
* class SomeBase:
|
||||
* public ClassID<SomeBase>
|
||||
* { ... };
|
||||
* class SomeClass:
|
||||
* public SomeBase
|
||||
* , public ClassID<SomeClass>
|
||||
* { ... }; // Error: id() and class_id() will be ambiguous
|
||||
* \endcode
|
||||
*
|
||||
* Solution:
|
||||
* \code
|
||||
* class SomeClass:
|
||||
* public ClassIDCompositor<SomeBase, SomeClass>
|
||||
* { ... };
|
||||
* \endcode
|
||||
*
|
||||
* @tparam Base
|
||||
* Some base class, which will also be inherited
|
||||
* @tparam Self
|
||||
* The deriving class
|
||||
*/
|
||||
template < class Base, class Self >
|
||||
class ClassIDCompositor
|
||||
: public Base
|
||||
, public ClassID<Self>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
*/
|
||||
static size_t const id()
|
||||
{
|
||||
return ClassID<Self>::id();
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
virtual size_t const class_id() const
|
||||
{
|
||||
return ClassID<Self>::id();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace utility
|
||||
} // namespace OpenTissue
|
||||
// OPENTISSUE_UTILITY_UTILITY_CLASS_ID_H
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_EMPTY_TRAITS_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_EMPTY_TRAITS_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
/**
|
||||
* Empty Traits Class.
|
||||
* This is basically an empty class it usage
|
||||
* is intended as a default argument for the
|
||||
* many algorithms and data structures where
|
||||
* the default traits is simply the ``empty''
|
||||
* traits.
|
||||
*
|
||||
*/
|
||||
class EmptyTraits { };
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_EMPTY_TRAITS_H
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_FPS_COUNTER_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_FPS_COUNTER_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
#include <OpenTissue/utility/utility_timer.h>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
/*
|
||||
* Frame Per Second (FPS) Counter
|
||||
*/
|
||||
template<typename real_type>
|
||||
class FPSCounter
|
||||
{
|
||||
public:
|
||||
FPSCounter()
|
||||
: m_fps(0)
|
||||
, m_fpscnt(0)
|
||||
, m_time(0.)
|
||||
{
|
||||
m_hrc.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* /return the last known fps
|
||||
*/
|
||||
unsigned long operator()() const
|
||||
{
|
||||
return m_fps;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* /return true if 1 sec has passed
|
||||
*/
|
||||
bool frame()
|
||||
{
|
||||
m_hrc.stop();
|
||||
m_time += m_hrc();
|
||||
m_fpscnt++;
|
||||
if (m_time >= 1.) {
|
||||
// m_time -= 1.;
|
||||
m_time = 0.;
|
||||
m_fps = m_fpscnt;
|
||||
m_fpscnt = 0;
|
||||
}
|
||||
m_hrc.start();
|
||||
return 0 == m_fpscnt;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Timer<real_type> m_hrc;
|
||||
unsigned long m_fps;
|
||||
unsigned long m_fpscnt;
|
||||
double m_time;
|
||||
};
|
||||
|
||||
} //End of namespace utility
|
||||
|
||||
} //End of namespace OpenTissue
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_FPS_COUNTER_H
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_GET_ENVIRONMENT_VARIABLE_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_GET_ENVIRONMENT_VARIABLE_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <cstdlib> //--- For getenv
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
/**
|
||||
* Retrieve Value of Environment Variable.
|
||||
* If environment variable can not be found then a std::logic_error warning is thrown.
|
||||
*
|
||||
* @param A string containing the name of the environment
|
||||
* variable. Example: "OPENTISSUE".
|
||||
* @return A string containing the value.
|
||||
*/
|
||||
inline std::string get_environment_variable(std::string const & name)
|
||||
{
|
||||
char * value = getenv( name.c_str() );
|
||||
if(value)
|
||||
return std::string( value );
|
||||
throw std::logic_error("get_environment_variable(): the specified environment variable was not set");
|
||||
}
|
||||
|
||||
} // namespace utility
|
||||
|
||||
} // namespace OpenTissue
|
||||
|
||||
//OPENTISSUE_UTILITY_UTILITY_GET_ENVIRONMENT_VARIABLE_H
|
||||
#endif
|
||||
@@ -0,0 +1,108 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_GET_SYSTEM_MEMORY_INFO_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_GET_SYSTEM_MEMORY_INFO_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# define NOMINMAX
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# undef NOMINMAX
|
||||
#endif
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
double get_memory_usage()
|
||||
{
|
||||
typedef double real_type;
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
real_type memory_usage = statex.dwMemoryLoad;
|
||||
return memory_usage;
|
||||
}
|
||||
|
||||
unsigned int get_total_physical_memory_in_bytes()
|
||||
{
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
unsigned int total_physical_memory_in_bytes = statex.ullTotalPhys;
|
||||
return total_physical_memory_in_bytes;
|
||||
}
|
||||
|
||||
unsigned int get_free_physical_memory_in_bytes()
|
||||
{
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
unsigned int free_physical_memory_in_bytes = statex.ullAvailPhys;
|
||||
return free_physical_memory_in_bytes;
|
||||
}
|
||||
|
||||
unsigned int get_total_page_file_in_bytes()
|
||||
{
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
unsigned int total_page_file_in_bytes = statex.ullTotalPageFile;
|
||||
return total_page_file_in_bytes;
|
||||
}
|
||||
|
||||
unsigned int get_free_page_file_in_bytes()
|
||||
{
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
unsigned int free_page_file_in_bytes = statex.ullAvailPageFile;
|
||||
return free_page_file_in_bytes;
|
||||
}
|
||||
|
||||
unsigned int get_total_virtual_memory_in_bytes()
|
||||
{
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
unsigned int total_virtual_memory = statex.ullTotalVirtual;
|
||||
return total_virtual_memory;
|
||||
}
|
||||
|
||||
unsigned int get_free_virtual_memory_in_bytes()
|
||||
{
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
unsigned int free_virtual_memory_in_bytes = statex.ullAvailVirtual;
|
||||
return free_virtual_memory;
|
||||
}
|
||||
|
||||
unsigned int get_free_extended_memory_in_bytes()
|
||||
{
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
unsigned int free_extended_memory_in_bytes = statex.ullAvailExtendedVirtual;
|
||||
return free_extended_memory_in_bytes;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
} //End of namespace utility
|
||||
|
||||
} //End of namespace OpenTissue
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_GET_SYSTEM_MEMORY_INFO_H
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_GREATER_PTR_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_GREATER_PTR_H
|
||||
//
|
||||
// OpenTissue, A toolbox for physical based simulation and animation.
|
||||
// Copyright (C) 2007 Department of Computer Science, University of Copenhagen
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
/**
|
||||
* Greater Than Test.
|
||||
* This is used for doing a greater than test on data
|
||||
* structures containing pointers to data and not instances.
|
||||
*/
|
||||
template<class T>
|
||||
struct greater_ptr
|
||||
: public std::binary_function<T, T, bool>
|
||||
{
|
||||
bool operator()(const T& x, const T& y) const { return (*x)>(*y); }
|
||||
};
|
||||
|
||||
} //End of namespace utility
|
||||
|
||||
} //End of namespace OpenTissue
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_GREATER_PTR_H
|
||||
#endif
|
||||
@@ -0,0 +1,100 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_IDENTIFIER_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_IDENTIFIER_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
/**
|
||||
* Identifier Class.
|
||||
* This is an utility class that is supposed to make it easier to create
|
||||
* new objects with unique identifiers. The idea is to simply inherit the
|
||||
* new object class from the identifier class.
|
||||
*
|
||||
* At construction-time the class tries to generate a new unique
|
||||
* identifier. Hereafter it is the users responsibility not to mess
|
||||
* up the id-name string. However, end-users can always be sure that
|
||||
* the index value provided by the identifier class is unique.
|
||||
*/
|
||||
class Identifier
|
||||
{
|
||||
protected:
|
||||
|
||||
std::string m_ID; ///< An Identifier string.
|
||||
size_t m_index; ///< Unique object index.
|
||||
|
||||
public:
|
||||
|
||||
Identifier()
|
||||
{
|
||||
generate_new_index();
|
||||
m_ID = "ID" + m_index;
|
||||
}
|
||||
|
||||
virtual ~Identifier(){}
|
||||
|
||||
public:
|
||||
|
||||
Identifier(Identifier const & id)
|
||||
{
|
||||
m_ID = id.m_ID;
|
||||
m_index = id.m_index;
|
||||
}
|
||||
|
||||
Identifier & operator=(Identifier const & id)
|
||||
{
|
||||
m_ID = id.m_ID;
|
||||
m_index = id.m_index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(Identifier const & id) const { return (m_index == id.m_index); }
|
||||
|
||||
bool operator!=(Identifier const & id) const { return !(*this == id); }
|
||||
|
||||
public:
|
||||
|
||||
void set_id(std::string const & id) { m_ID = id; }
|
||||
|
||||
std::string const & get_id() const { return m_ID; }
|
||||
|
||||
size_t get_index() const {return m_index; }
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Static Member Not Initialized in Header Trick (smnih)
|
||||
*
|
||||
* This way we avoid having a
|
||||
*
|
||||
* static size_t m_next_idx
|
||||
*
|
||||
* member variable which must be initialized in a
|
||||
* source file.
|
||||
*/
|
||||
void generate_new_index()
|
||||
{
|
||||
static size_t next_index = 0;
|
||||
m_index = next_index;
|
||||
++next_index;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace utility
|
||||
|
||||
} // namespace OpenTissue
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_IDENTIFIER_H
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_LESS_PTR_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_LESS_PTR_H
|
||||
//
|
||||
// OpenTissue, A toolbox for physical based simulation and animation.
|
||||
// Copyright (C) 2007 Department of Computer Science, University of Copenhagen
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
/**
|
||||
* Less Than Test.
|
||||
* This is used for doing a less than test on data
|
||||
* structures containing pointers to data and not instances.
|
||||
*/
|
||||
template<class T>
|
||||
struct less_ptr
|
||||
: public std::binary_function<T, T, bool>
|
||||
{
|
||||
bool operator()(const T& x, const T& y) const { return (*x)<(*y); }
|
||||
};
|
||||
|
||||
} //End of namespace utility
|
||||
|
||||
} //End of namespace OpenTissue
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_LESS_PTR_H
|
||||
#endif
|
||||
108
Demos3/FiniteElementMethod/OpenTissue/utility/utility_material.h
Normal file
108
Demos3/FiniteElementMethod/OpenTissue/utility/utility_material.h
Normal file
@@ -0,0 +1,108 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_MATERIAL_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_MATERIAL_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
/**
|
||||
* A Material.
|
||||
* This class encapsulates openGL material parameters.
|
||||
*/
|
||||
class Material
|
||||
{
|
||||
protected:
|
||||
|
||||
float m_ambient[ 4 ]; ///< The ambient color rgba.
|
||||
float m_diffuse[ 4 ]; ///< The diffuse color rgba.
|
||||
float m_specular[ 4 ]; ///< The specular color rgba.
|
||||
float m_shininess; ///< The shininess of this material 0..180.
|
||||
|
||||
public:
|
||||
|
||||
Material()
|
||||
: m_shininess(128)
|
||||
{
|
||||
set_default();
|
||||
}
|
||||
|
||||
void ambient( float const & red, float const & green, float const & blue, float const & alpha = 1.0f )
|
||||
{
|
||||
m_ambient[ 0 ] = red;
|
||||
m_ambient[ 1 ] = green;
|
||||
m_ambient[ 2 ] = blue;
|
||||
m_ambient[ 3 ] = alpha;
|
||||
}
|
||||
|
||||
void diffuse( float const & red, float const & green, float const & blue, float const & alpha = 1.0f )
|
||||
{
|
||||
m_diffuse[ 0 ] = red;
|
||||
m_diffuse[ 1 ] = green;
|
||||
m_diffuse[ 2 ] = blue;
|
||||
m_diffuse[ 3 ] = alpha;
|
||||
}
|
||||
|
||||
void specular( float const & red, float const & green, float const & blue, float const & alpha = 1.0f )
|
||||
{
|
||||
m_specular[ 0 ] = red;
|
||||
m_specular[ 1 ] = green;
|
||||
m_specular[ 2 ] = blue;
|
||||
m_specular[ 3 ] = alpha;
|
||||
}
|
||||
|
||||
void shininess( float const & value )
|
||||
{
|
||||
m_shininess = value;
|
||||
}
|
||||
|
||||
/*
|
||||
void use()
|
||||
{
|
||||
if ( glIsEnabled( GL_COLOR_MATERIAL ) || !glIsEnabled( GL_LIGHTING ) )
|
||||
{
|
||||
glColor4f( m_diffuse[ 0 ], m_diffuse[ 1 ], m_diffuse[ 2 ], m_diffuse[ 3 ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, m_ambient );
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, m_diffuse );
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, m_specular );
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, &m_shininess );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void set_default()
|
||||
{
|
||||
m_ambient[ 0 ] = 0.1f;
|
||||
m_ambient[ 1 ] = 0.1f;
|
||||
m_ambient[ 2 ] = 0.0f;
|
||||
m_ambient[ 3 ] = 1.0f;
|
||||
m_diffuse[ 0 ] = 0.6f;
|
||||
m_diffuse[ 1 ] = 0.6f;
|
||||
m_diffuse[ 2 ] = 0.1f;
|
||||
m_diffuse[ 3 ] = 1.0f;
|
||||
m_specular[ 0 ] = 1.0f;
|
||||
m_specular[ 1 ] = 1.0f;
|
||||
m_specular[ 2 ] = 0.75f;
|
||||
m_specular[ 3 ] = 1.0f;
|
||||
m_shininess = 128;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace utility
|
||||
|
||||
} // namespace OpenTissue
|
||||
|
||||
//OPENTISSUE_UTILITY_UTILITY_MATERIAL_H
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#if (_MSC_VER >= 1200)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#if (_MSC_VER >= 1200)
|
||||
# pragma warning(push)
|
||||
//# pragma warning(disable: 99) // 'identifier' : type name first seen using 'objecttype1' now seen using 'objecttype2'
|
||||
//# pragma warning(disable: 100) // 'identifier' : unreferenced formal parameter
|
||||
//# pragma warning(disable: 127) // conditional expression is constant
|
||||
//# pragma warning(disable: 217) // 'operator' : member template functions cannot be used for copy-assignment or copy-construction
|
||||
# pragma warning(disable: 265) // 'class' : class has virtual functions, but destructor is not virtual
|
||||
//# pragma warning(disable: 267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
|
||||
//# pragma warning(disable: 347) // behavior change: 'function template' is called instead of 'function'
|
||||
//# pragma warning(disable: 390) // ';' : empty controlled statement found; is this the intent?
|
||||
//# pragma warning(disable: 503) // 'identifier' : decorated name length exceeded, name was truncated
|
||||
//# pragma warning(disable: 511) // 'class' : copy constructor could not be generated
|
||||
//# pragma warning(disable: 512) // 'class' : assignment operator could not be generated
|
||||
//# pragma warning(disable: 701) // Potentially uninitialized local variable 'name' used
|
||||
//# pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_QHULL_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_QHULL_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is a bit tricky, I cant just include qhull_a.h as
|
||||
// QHull advices, because MVC complains about math.h which
|
||||
// is included "indirectly by qhull_a.h
|
||||
//
|
||||
// Hopefully furture releases of QHull will allow me to
|
||||
// just write:
|
||||
//
|
||||
// extern "C"
|
||||
// {
|
||||
// #include <Qhull/qhull_a.h>
|
||||
// }
|
||||
//
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <qhull/qhull.h>
|
||||
#include <qhull/mem.h>
|
||||
#include <qhull/qset.h>
|
||||
#include <qhull/geom.h>
|
||||
#include <qhull/merge.h>
|
||||
#include <qhull/poly.h>
|
||||
#include <qhull/io.h>
|
||||
#include <qhull/stat.h>
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
//OPENTISSUE_UTILITY_UTILITY_QHULL_H
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_RUNTIME_TYPE_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_RUNTIME_TYPE_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
/**
|
||||
* Runtime type.
|
||||
* great for passing non-integral values as template arguments.
|
||||
*/
|
||||
template < typename Type >
|
||||
struct RuntimeType
|
||||
{
|
||||
typedef Type type;
|
||||
RuntimeType(){}
|
||||
RuntimeType(const RuntimeType& rhs):m_value(rhs.m_value){}
|
||||
RuntimeType& operator = (const type& rhs) {m_value=rhs; return *this;}
|
||||
operator const type& () const {return m_value;}
|
||||
protected:
|
||||
type m_value;
|
||||
};
|
||||
|
||||
} // namespace utility
|
||||
|
||||
} // namespace OpenTissue
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_RUNTIME_TYPE_H
|
||||
#endif
|
||||
102
Demos3/FiniteElementMethod/OpenTissue/utility/utility_timer.h
Normal file
102
Demos3/FiniteElementMethod/OpenTissue/utility/utility_timer.h
Normal file
@@ -0,0 +1,102 @@
|
||||
#ifndef OPENTISSUE_UTILITY_UTILITY_TIMER_H
|
||||
#define OPENTISSUE_UTILITY_UTILITY_TIMER_H
|
||||
//
|
||||
// OpenTissue Template Library
|
||||
// - A generic toolbox for physics-based modeling and simulation.
|
||||
// Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
|
||||
//
|
||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||
//
|
||||
#include <OpenTissue/configuration.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# define NOMINMAX
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# undef NOMINMAX
|
||||
#else
|
||||
# include<sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace OpenTissue
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
/**
|
||||
* High Resoultion Timer.
|
||||
* Based on http://www-106.ibm.com/developerworks/library/l-rt1/
|
||||
*
|
||||
* RunTime: High-performance programming techniques on Linux and Windows 2000
|
||||
* Setting up timing routines
|
||||
* by
|
||||
* Edward G. Bradford (egb@us.ibm.com)
|
||||
* Senior Programmer, IBM
|
||||
* 01 Apr 2001
|
||||
*
|
||||
* Example usage (We recommand doubles):
|
||||
*
|
||||
* Timer<double> timer;
|
||||
*
|
||||
* timer.start()
|
||||
* ...
|
||||
* timer.stop()
|
||||
* std::cout << "It took " << timer() << " seconds to do it" << std::endl;
|
||||
*/
|
||||
template<typename real_type>
|
||||
class Timer
|
||||
{
|
||||
#ifdef WIN32
|
||||
private:
|
||||
LARGE_INTEGER m_start; ///<
|
||||
LARGE_INTEGER m_end; ///<
|
||||
LARGE_INTEGER m_freq; ///<
|
||||
bool m_first; ///<
|
||||
public:
|
||||
Timer():m_first(true){}
|
||||
public:
|
||||
void start()
|
||||
{
|
||||
if(m_first)
|
||||
{
|
||||
QueryPerformanceFrequency(&m_freq);
|
||||
m_first = false;
|
||||
}
|
||||
QueryPerformanceCounter(&m_start);
|
||||
}
|
||||
void stop()
|
||||
{
|
||||
QueryPerformanceCounter(&m_end);
|
||||
}
|
||||
real_type operator()()const
|
||||
{
|
||||
real_type end = static_cast<real_type>(m_end.QuadPart);
|
||||
real_type start = static_cast<real_type>(m_start.QuadPart);
|
||||
real_type freq = static_cast<real_type>(m_freq.QuadPart);
|
||||
return (end - start)/ freq;
|
||||
}
|
||||
#else
|
||||
private:
|
||||
struct timeval m_start; ///<
|
||||
struct timeval m_end; ///<
|
||||
struct timezone m_tz; ///<
|
||||
public:
|
||||
void start() { gettimeofday(&m_start, &m_tz); }
|
||||
void stop() { gettimeofday(&m_end,&m_tz); }
|
||||
real_type operator()()const
|
||||
{
|
||||
real_type t1 = static_cast<real_type>(m_start.tv_sec) + static_cast<real_type>(m_start.tv_usec)/(1000*1000);
|
||||
real_type t2 = static_cast<real_type>(m_end.tv_sec) + static_cast<real_type>(m_end.tv_usec)/(1000*1000);
|
||||
return t2-t1;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
} //End of namespace utility
|
||||
} //End of namespace OpenTissue
|
||||
|
||||
// OPENTISSUE_UTILITY_UTILITY_TIMER_H
|
||||
#endif
|
||||
Reference in New Issue
Block a user