adding of Curvature, compilation with GCC

This commit is contained in:
ganovelli 2008-03-17 11:25:27 +00:00
parent 35848b0a77
commit 84adadf680
3 changed files with 59 additions and 47 deletions

View File

@ -24,11 +24,14 @@
History
$Log: not supported by cvs2svn $
Revision 1.9 2006/12/03 18:01:01 ganovelli
versione compliant vs2005
Revision 1.8 2006/06/08 20:28:57 ganovelli
aggiunto qualche const sui parametri
Revision 1.7 2005/10/15 16:21:48 ganovelli
Working release (compilata solo su MSVC), vector_occ è migrato da component_opt
Working release (compilata solo su MSVC), vector_occ <EFBFBD> migrato da component_opt
Revision 1.6 2005/07/07 13:33:51 ganovelli
some comment
@ -59,8 +62,8 @@ First Working Release (with this comment)
namespace vcg {
/*@{*/
/*!
* CATBase is the abstract class for all the allocation tables. THese table keep track of
* where the traced vector (see traced_ector.h) are kepth in memory.
* CATBase is the abstract class for all the allocation tables. These table keep track of
* where the traced vector (see traced_ector.h) are kept in memory.
* The goal is to know (given a pointer to a memory location), which is the vector the pointed
* element is in
*
@ -69,7 +72,7 @@ namespace vcg {
template <typename STL_CONT>
class CATBase{
public:
typedef typename typename STL_CONT::value_type ValueType;
typedef typename STL_CONT::value_type ValueType;
virtual void Resort(ValueType*,ValueType*) =0;
virtual void Remove(const STL_CONT&) = 0;
@ -89,8 +92,8 @@ static int & Id(){
template <typename STL_CONT, class ENTRY_TYPE>
class CATEntry: public CATBase<STL_CONT>{
public:
typedef typename typename STL_CONT::value_type ValueType;
typedef typename ENTRY_TYPE EntryType;
typedef typename STL_CONT::value_type ValueType;
typedef ENTRY_TYPE EntryType;
CATEntry(){if(Id()==0){
Id() = CATBase<STL_CONT>::Id()+1;
@ -131,7 +134,7 @@ static ValueType *& Upper() {
}
static typename std::list<ENTRY_TYPE>::iterator & Curr(){ // container that was last accessed
static std::list<ENTRY_TYPE>::iterator currEntry;
static typename std::list<ENTRY_TYPE>::iterator currEntry;
return currEntry;
}
@ -168,7 +171,7 @@ typename std::list<ENTRY_TYPE>::iterator CATEntry<STL_CONT,ENTRY_TYPE>::
FindBase(const ValueType * pt)
{
std::list<ENTRY_TYPE>::iterator ite,curr_base,_;
typename std::list<ENTRY_TYPE>::iterator ite,curr_base,_;
ite = AT().begin();
curr_base = AT().end();
@ -196,7 +199,7 @@ void CATEntry< STL_CONT, ENTRY_TYPE>::
Update(const ValueType * pt)
{
if(!IsTheSameAsLast(pt)){
std::list<ENTRY_TYPE>::iterator lower_ite,upper_ite;
typename std::list<ENTRY_TYPE>::iterator lower_ite,upper_ite;
lower_ite = FindBase(pt);
assert( lower_ite!=AT().end());
@ -228,7 +231,7 @@ void CATEntry<STL_CONT, ENTRY_TYPE>::
Remove( const STL_CONT & c )
{
std::list<ENTRY_TYPE>::iterator ite;
typename std::list<ENTRY_TYPE>::iterator ite;
for(ite = AT().begin(); ite != AT().end(); ++ite)
if((*ite).C() == &c)
{
@ -243,7 +246,7 @@ void CATEntry<STL_CONT, ENTRY_TYPE>::
RemoveIfEmpty( const STL_CONT & c )
{
std::list<ENTRY_TYPE>::iterator ite;
typename std::list<ENTRY_TYPE>::iterator ite;
for(ite = AT().begin(); ite != AT().end(); ++ite)
if((*ite).C() == &c)
if(!(*ite).Empty())
@ -256,7 +259,7 @@ void CATEntry<STL_CONT, ENTRY_TYPE>::
Remove(ValueType * pt)
{
std::list<ENTRY_TYPE>::iterator lower_ite;
typename std::list<ENTRY_TYPE>::iterator lower_ite;
lower_ite = FindBase(pt);
AT().erase(lower_ite);
UTD() = false;
@ -269,7 +272,7 @@ void CATEntry<STL_CONT, ENTRY_TYPE>::
Insert( STL_CONT & c,bool cond )
{
ENTRY_TYPE entry(c);
std::list<ENTRY_TYPE>::iterator lower_ite,upper_ite;
typename std::list<ENTRY_TYPE>::iterator lower_ite,upper_ite;
upper_ite = FindBase( c.Pointer2begin());
bool isIn = (upper_ite != AT().end());
if(isIn){
@ -314,7 +317,8 @@ Curr()->Resize(n);
//--------------------------------------------------------------------------------------------
template <typename STL_CONT,class ATTR_TYPE>
class CAT:public CATEntry<STL_CONT, EntryCAT<STL_CONT,ATTR_TYPE> >{
typedef typename typename STL_CONT::value_type ValueType;
typedef typename STL_CONT::value_type ValueType;
typedef CATEntry<STL_CONT, EntryCAT<STL_CONT,ATTR_TYPE> > TT;
public:
static ATTR_TYPE & Get(const ValueType * pt);
static CAT<STL_CONT,ATTR_TYPE> * New();
@ -327,8 +331,8 @@ ATTR_TYPE & CAT<STL_CONT,ATTR_TYPE>::
Get(const ValueType * pt)
{
int ord = Ord(pt);
//int ord = pt- &(* ((*AT().begin()).C()->begin())); se AT() contiene un solo elemento funziona anche così
return Curr()->Data()[ord];
//int ord = pt- &(* ((*AT().begin()).C()->begin())); se AT() contiene un solo elemento funziona anche cos
return TT::Curr()->Data()[ord];
}
template <typename STL_CONT, class ATTR_TYPE>
@ -344,6 +348,23 @@ New(){
//---------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// TempData implements a handle to one of the vector od data stored in EntryCATMulti
template <class STL_CONT, class ATTR_TYPE>
class TempData{
public:
TempData(std::vector<ATTR_TYPE> *d):item(d){};
typedef ATTR_TYPE attr_type;
std::vector<ATTR_TYPE> * Item(){return item;};
std::vector<ATTR_TYPE> * item;
ATTR_TYPE & operator []( typename STL_CONT::value_type * v)
{
int pos = CATEntry<STL_CONT, EntryCATMulti<STL_CONT> >::Ord(v);
return (*item)[pos];
}
};
//----------------------------------------------------------------------------------
};//end namespace vcg

View File

@ -25,6 +25,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.7 2007/01/18 01:31:12 cignoni
Many small syntax changes for mac compiling
Revision 1.6 2006/12/03 18:01:01 ganovelli
versione compliant vs2005
@ -42,6 +45,7 @@ First Working Release (with this comment)
#ifndef __VCGLIB_ENTRIES__
#define __VCGLIB_ENTRIES__
namespace vcg {
// EntryCATBase: base class for the entry of the allocation table
@ -145,23 +149,6 @@ private:
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// TempData implements a handle to one of the vector od data stored in EntryCATMulti
template <class STL_CONT, class ATTR_TYPE>
class TempData{
public:
TempData(std::vector<ATTR_TYPE> *d):item(d){};
typedef ATTR_TYPE attr_type;
std::vector<ATTR_TYPE> * Item(){return item;};
std::vector<ATTR_TYPE> * item;
ATTR_TYPE & operator []( typename STL_CONT::value_type * v)
{
int pos = CATEntry<STL_CONT, EntryCATMulti<STL_CONT> >::Ord(v);
return (*item)[pos];
}
};
//----------------------------------------------------------------------------------
}; // end namespace vcg

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.4 2006/12/04 11:11:07 ganovelli
add const to IsEnabledAttribute
Revision 1.3 2006/12/03 18:01:01 ganovelli
versione compliant vs2005
@ -31,7 +34,7 @@ Revision 1.2 2006/06/08 20:28:38 ganovelli
Corretto IsEnabledAttribute
Revision 1.1 2005/10/15 16:21:49 ganovelli
Working release (compilata solo su MSVC), vector_occ è migrato da component_opt
Working release (compilata solo su MSVC), vector_occ <EFBFBD> migrato da component_opt
Revision 1.5 2005/07/07 13:33:52 ganovelli
some comment
@ -56,7 +59,7 @@ First Working Release (with this comment)
namespace vcg {
/*@{*/
/*!
* This class represent a Traced Vector. A vector_occ is derived by a std::vector.
* This class represent a vector_occ. A vector_occ is derived by a std::vector.
* The characteristic of a vector_occ is that you can add (at run time) new attributes
* to the container::value_type elements contained in the vector. (see the example..)
* The position in memory of a traced vector is kept by the Container Allocation Table,
@ -65,14 +68,15 @@ namespace vcg {
template <class VALUE_TYPE>
class vector_occ: public std::vector<VALUE_TYPE>{
typedef typename vector_occ<VALUE_TYPE> ThisType;
typedef vector_occ<VALUE_TYPE> ThisType;
typedef std::vector<VALUE_TYPE> TT;
public:
vector_occ():std::vector<VALUE_TYPE>(){id = ID(); ID()=ID()+1; reserve(1);}
~vector_occ();
VALUE_TYPE * Pointer2begin(){
if(empty()) return (VALUE_TYPE *)id; else return &*std::vector<VALUE_TYPE>::begin();
if(TT::empty()) return (VALUE_TYPE *)id; else return &*std::vector<VALUE_TYPE>::begin();
}
std::list < CATBase<ThisType>* > attributes;
// override di tutte le funzioni che possono spostare
@ -94,7 +98,7 @@ public:
/// Note: once an attribute is disabled, its data is lost (the memory freed)
template <class ATTR_TYPE>
bool IsEnabledAttribute() const{
std::list < CATBase<ThisType> * >::const_iterator ia;
typename std::list < CATBase<ThisType> * >::const_iterator ia;
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
if((*ia)->Id() == CAT<ThisType,ATTR_TYPE>::Id())
return true;
@ -106,7 +110,7 @@ public:
/// Note: once an attribute is disabled, its data is lost (the memory freed)
template <class ATTR_TYPE>
void DisableAttribute(){
std::list < CATBase<ThisType> * >::iterator ia;
typename std::list < CATBase<ThisType> * >::iterator ia;
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
if((*ia)->Id() == CAT<ThisType,ATTR_TYPE>::Id())
{
@ -131,8 +135,8 @@ public:
EntryTypeMulti entry = CATEntry<ThisType,EntryTypeMulti >::GetEntry(Pointer2begin());
entry.Data().push_back(new Wrap< ATTR_TYPE>);
((Wrap<ATTR_TYPE>*)entry.Data().back())->reserve(capacity());
((Wrap<ATTR_TYPE>*)entry.Data().back())->resize(size());
((Wrap<ATTR_TYPE>*)entry.Data().back())->reserve(TT::capacity());
((Wrap<ATTR_TYPE>*)entry.Data().back())->resize(TT::size());
return TempData<ThisType,ATTR_TYPE>((Wrap<ATTR_TYPE>*) entry.Data().back());
}
@ -163,7 +167,7 @@ template <class VALUE_TYPE>
void vector_occ<VALUE_TYPE>::push_back(const VALUE_TYPE & v){
std::vector<VALUE_TYPE>::push_back(v);
Update();
std::list < CATBase<ThisType> * >::iterator ia;
typename std::list < CATBase<ThisType> * >::iterator ia;
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
(*ia)->AddDataElem(&(*(this->begin())),1);
@ -178,7 +182,7 @@ template <class VALUE_TYPE>
void vector_occ<VALUE_TYPE>::resize(const unsigned int & size){
std::vector<VALUE_TYPE>::resize(size);
Update();
std::list < CATBase<ThisType> * >::iterator ia;
typename std::list < CATBase<ThisType> * >::iterator ia;
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
(*ia)->
Resize(&(*(this->begin())),size);
@ -193,7 +197,7 @@ void vector_occ<VALUE_TYPE>::reserve(const unsigned int & size){
template <class VALUE_TYPE>
void vector_occ<VALUE_TYPE>::
Update(){
std::list < CATBase<ThisType> * >::iterator ia;
typename std::list < CATBase<ThisType> * >::iterator ia;
if(Pointer2begin() != old_start)
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
(*ia)->Resort(old_start,Pointer2begin());
@ -205,7 +209,7 @@ template <class VALUE_TYPE>
template <class VALUE_TYPE>
vector_occ<VALUE_TYPE>::~vector_occ(){
std::list < CATBase<ThisType> * >::iterator ia;
typename std::list < CATBase<ThisType> * >::iterator ia;
for(ia = attributes.begin(); ia != attributes.end(); ++ia)
{
(*ia)->Remove(*this);