2005-10-14 17:07:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program 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 General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
|
|
History
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2008-04-04 01:15:40 +02:00
|
|
|
Revision 1.15 2008/03/17 11:39:15 ganovelli
|
|
|
|
added curvature and curvatruredir (compiled .net 2005 and gcc)
|
|
|
|
|
2008-03-17 12:39:15 +01:00
|
|
|
Revision 1.14 2008/03/11 09:22:07 cignoni
|
|
|
|
Completed the garbage collecting functions CompactVertexVector and CompactFaceVector.
|
|
|
|
|
2008-03-11 10:22:07 +01:00
|
|
|
Revision 1.13 2008/02/05 20:42:43 cignoni
|
|
|
|
Other small typos
|
|
|
|
|
2008-02-05 21:42:43 +01:00
|
|
|
Revision 1.12 2008/02/04 21:26:49 ganovelli
|
|
|
|
added ImportLocal which imports all local attributes into vertexplus and faceplus.
|
|
|
|
A local attribute is everything (N(), C(), Q()....) except pointers to other simplices
|
|
|
|
(i.e. FFAdj, VFAdj, VertexRef) which are set to NULL.
|
|
|
|
Added some function for const attributes
|
|
|
|
|
2008-02-04 22:26:49 +01:00
|
|
|
Revision 1.11 2007/12/11 18:25:31 cignoni
|
|
|
|
added missing include limits
|
|
|
|
|
2007-12-11 19:25:31 +01:00
|
|
|
Revision 1.10 2007/12/11 11:36:03 cignoni
|
|
|
|
Added the CompactVertexVector garbage collecting function.
|
|
|
|
|
2007-12-11 12:36:03 +01:00
|
|
|
Revision 1.9 2006/12/11 23:42:00 ganovelli
|
|
|
|
bug Index()() instead of Index()
|
|
|
|
|
2006-12-12 00:42:00 +01:00
|
|
|
Revision 1.8 2006/12/04 11:17:42 ganovelli
|
|
|
|
added forward declaration of TriMesh
|
|
|
|
|
2006-12-04 12:17:42 +01:00
|
|
|
Revision 1.7 2006/11/07 17:22:52 cignoni
|
|
|
|
many gcc compiling issues
|
|
|
|
|
2006-11-07 18:22:53 +01:00
|
|
|
Revision 1.6 2006/11/07 15:13:57 zifnab1974
|
|
|
|
Necessary changes for compilation with gcc 3.4.6. Especially the hash function is a problem
|
|
|
|
|
2006-11-07 16:13:57 +01:00
|
|
|
Revision 1.5 2006/11/07 11:29:24 cignoni
|
|
|
|
Corrected some errors in the reflections Has*** functions
|
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
Revision 1.4 2006/10/31 16:02:59 ganovelli
|
|
|
|
vesione 2005 compliant
|
|
|
|
|
2006-10-31 17:02:59 +01:00
|
|
|
Revision 1.3 2006/02/28 11:59:55 ponchio
|
|
|
|
g++ compliance:
|
|
|
|
|
|
|
|
begin() -> (*this).begin() and for end(), size(), Base(), Index()
|
|
|
|
|
2006-02-28 12:59:55 +01:00
|
|
|
Revision 1.2 2005/12/12 11:17:32 cignoni
|
|
|
|
Corrected update function, now only the needed simplexes should be updated.
|
|
|
|
|
2005-12-12 12:17:32 +01:00
|
|
|
Revision 1.1 2005/10/14 15:07:59 cignoni
|
|
|
|
First Really Working version
|
|
|
|
|
2005-10-14 17:07:59 +02:00
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Note
|
|
|
|
OCF = Optional Component Fast (hopefully)
|
|
|
|
compare with OCC(Optional Component Compact)
|
|
|
|
|
|
|
|
Mainly the trick here is to store a base pointer in each simplex...
|
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __VCG_VERTEX_PLUS_COMPONENT_OCF
|
|
|
|
#define __VCG_VERTEX_PLUS_COMPONENT_OCF
|
|
|
|
|
|
|
|
#include <vcg/simplex/vertexplus/component.h>
|
|
|
|
#include <vector>
|
2007-12-11 19:25:31 +01:00
|
|
|
#include <limits>
|
2005-10-14 17:07:59 +02:00
|
|
|
|
|
|
|
namespace vcg {
|
|
|
|
namespace vert {
|
|
|
|
/*
|
|
|
|
All the Components that can be added to a vertex should be defined in the namespace vert:
|
|
|
|
|
|
|
|
*/
|
|
|
|
template <class VALUE_TYPE>
|
|
|
|
class vector_ocf: public std::vector<VALUE_TYPE> {
|
|
|
|
typedef std::vector<VALUE_TYPE> BaseType;
|
|
|
|
typedef typename vector_ocf<VALUE_TYPE>::iterator ThisTypeIterator;
|
|
|
|
|
|
|
|
public:
|
|
|
|
vector_ocf():std::vector<VALUE_TYPE>(){
|
2006-11-07 12:29:24 +01:00
|
|
|
QualityEnabled=false;
|
2005-10-14 17:07:59 +02:00
|
|
|
ColorEnabled=false;
|
2008-04-04 01:15:40 +02:00
|
|
|
MarkEnabled = false;
|
2005-10-14 17:07:59 +02:00
|
|
|
NormalEnabled=false;
|
|
|
|
VFAdjacencyEnabled=false;
|
2008-03-17 12:39:15 +01:00
|
|
|
CurvatureEnabled = false;
|
2008-04-04 01:15:40 +02:00
|
|
|
}
|
2005-10-14 17:07:59 +02:00
|
|
|
|
|
|
|
// override di tutte le funzioni che possono spostare
|
|
|
|
// l'allocazione in memoria del container
|
|
|
|
void push_back(const VALUE_TYPE & v)
|
|
|
|
{
|
|
|
|
BaseType::push_back(v);
|
2008-04-04 01:15:40 +02:00
|
|
|
BaseType::back()._ovp = this;
|
|
|
|
if (ColorEnabled) CV.push_back(vcg::Color4b(vcg::Color4b::White));
|
|
|
|
if (MarkEnabled) MV.push_back(0);
|
|
|
|
if (NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType());
|
|
|
|
if (VFAdjacencyEnabled) AV.push_back(VFAdjType());
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
|
|
|
void pop_back();
|
|
|
|
void resize(const unsigned int & _size)
|
|
|
|
{
|
2007-12-11 12:36:03 +01:00
|
|
|
int oldsize = BaseType::size();
|
|
|
|
BaseType::resize(_size);
|
|
|
|
if(oldsize<_size){
|
|
|
|
ThisTypeIterator firstnew = BaseType::begin();
|
|
|
|
advance(firstnew,oldsize);
|
|
|
|
_updateOVP(firstnew,(*this).end());
|
|
|
|
}
|
2008-04-04 01:15:40 +02:00
|
|
|
if (ColorEnabled) CV.resize(_size);
|
|
|
|
if (MarkEnabled) MV.resize(_size);
|
|
|
|
if (NormalEnabled) NV.resize(_size);
|
|
|
|
if (VFAdjacencyEnabled) AV.resize(_size);
|
|
|
|
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
2007-12-11 12:36:03 +01:00
|
|
|
|
|
|
|
void reserve(const unsigned int & _size)
|
2005-10-14 17:07:59 +02:00
|
|
|
{
|
|
|
|
BaseType::reserve(_size);
|
|
|
|
if (ColorEnabled) CV.reserve(_size);
|
2008-04-04 01:15:40 +02:00
|
|
|
if (MarkEnabled) MV.reserve(_size);
|
2005-10-14 17:07:59 +02:00
|
|
|
if (NormalEnabled) NV.reserve(_size);
|
2008-04-04 01:15:40 +02:00
|
|
|
if (VFAdjacencyEnabled) AV.reserve(_size);
|
|
|
|
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
2007-12-11 12:36:03 +01:00
|
|
|
void _updateOVP(ThisTypeIterator lbegin, ThisTypeIterator lend)
|
|
|
|
{
|
2005-10-14 17:07:59 +02:00
|
|
|
ThisTypeIterator vi;
|
2005-12-12 12:17:32 +01:00
|
|
|
for(vi=lbegin;vi!=lend;++vi)
|
|
|
|
(*vi)._ovp=this;
|
2007-12-11 12:36:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// this function is called by the specialized Reorder function, that is called whenever someone call the allocator::CompactVertVector
|
2008-03-11 10:22:07 +01:00
|
|
|
void ReorderVert(std::vector<size_t> &newVertIndex )
|
2007-12-11 12:36:03 +01:00
|
|
|
{
|
|
|
|
size_t pos=0;
|
|
|
|
size_t i=0;
|
2008-04-04 01:15:40 +02:00
|
|
|
if (ColorEnabled) assert( CV.size() == newVertIndex.size() );
|
|
|
|
if (MarkEnabled) assert( MV.size() == newVertIndex.size() );
|
|
|
|
if (NormalEnabled) assert( NV.size() == newVertIndex.size() );
|
|
|
|
if (VFAdjacencyEnabled) assert( AV.size() == newVertIndex.size() );
|
2007-12-11 12:36:03 +01:00
|
|
|
|
|
|
|
for(i=0;i<newVertIndex.size();++i)
|
|
|
|
{
|
|
|
|
if(newVertIndex[i] != std::numeric_limits<size_t>::max() )
|
|
|
|
{
|
|
|
|
assert(newVertIndex[i] <= i);
|
2008-04-04 01:15:40 +02:00
|
|
|
if (ColorEnabled) CV[newVertIndex[i]] = CV[i];
|
|
|
|
if (MarkEnabled) MV[newVertIndex[i]] = MV[i];
|
|
|
|
if (NormalEnabled) NV[newVertIndex[i]] = NV[i];
|
|
|
|
if (VFAdjacencyEnabled) AV[newVertIndex[i]] = AV[i];
|
2007-12-11 12:36:03 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-04 01:15:40 +02:00
|
|
|
|
|
|
|
if (ColorEnabled) CV.resize(BaseType::size());
|
|
|
|
if (MarkEnabled) MV.resize(BaseType::size());
|
|
|
|
if (NormalEnabled) NV.resize(BaseType::size());
|
|
|
|
if (VFAdjacencyEnabled) AV.resize(BaseType::size());
|
|
|
|
|
2007-12-11 12:36:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-14 17:07:59 +02:00
|
|
|
////////////////////////////////////////
|
|
|
|
// Enabling Eunctions
|
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
bool IsQualityEnabled() const {return QualityEnabled;}
|
|
|
|
void EnableQuality() {
|
|
|
|
assert(VALUE_TYPE::HasQualityOcf());
|
|
|
|
QualityEnabled=true;
|
|
|
|
QV.resize((*this).size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisableQuality() {
|
|
|
|
assert(VALUE_TYPE::HasQualityOcf());
|
|
|
|
QualityEnabled=false;
|
|
|
|
QV.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsColorEnabled() const {return ColorEnabled;}
|
2005-10-14 17:07:59 +02:00
|
|
|
void EnableColor() {
|
|
|
|
assert(VALUE_TYPE::HasColorOcf());
|
|
|
|
ColorEnabled=true;
|
2006-02-28 12:59:55 +01:00
|
|
|
CV.resize((*this).size());
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisableColor() {
|
|
|
|
assert(VALUE_TYPE::HasColorOcf());
|
|
|
|
ColorEnabled=false;
|
|
|
|
CV.clear();
|
|
|
|
}
|
|
|
|
|
2008-04-04 01:15:40 +02:00
|
|
|
bool IsMarkEnabled() const {return MarkEnabled;}
|
|
|
|
void EnableMark() {
|
|
|
|
assert(VALUE_TYPE::HasFaceMarkOcf());
|
|
|
|
MarkEnabled=true;
|
|
|
|
MV.resize((*this).size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisableMark() {
|
|
|
|
assert(VALUE_TYPE::HasFaceMarkOcf());
|
|
|
|
MarkEnabled=false;
|
|
|
|
MV.clear();
|
|
|
|
}
|
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
bool IsNormalEnabled() const {return NormalEnabled;}
|
2005-10-14 17:07:59 +02:00
|
|
|
void EnableNormal() {
|
|
|
|
assert(VALUE_TYPE::HasNormalOcf());
|
|
|
|
NormalEnabled=true;
|
2006-02-28 12:59:55 +01:00
|
|
|
NV.resize((*this).size());
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisableNormal() {
|
|
|
|
assert(VALUE_TYPE::HasNormalOcf());
|
|
|
|
NormalEnabled=false;
|
|
|
|
NV.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnableVFAdjacency() {
|
|
|
|
assert(VALUE_TYPE::HasVFAdjacencyOcf());
|
|
|
|
VFAdjacencyEnabled=true;
|
2006-02-28 12:59:55 +01:00
|
|
|
AV.resize((*this).size());
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisableVFAdjacency() {
|
|
|
|
assert(VALUE_TYPE::HasVFAdjacencyOcf());
|
|
|
|
VFAdjacencyEnabled=false;
|
|
|
|
AV.clear();
|
|
|
|
}
|
|
|
|
|
2008-03-17 12:39:15 +01:00
|
|
|
|
|
|
|
void EnableCurvature() {
|
|
|
|
assert(VALUE_TYPE::HasCurvatureOcf());
|
|
|
|
CurvatureEnabled=true;
|
|
|
|
CuV.resize((*this).size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisableCurvature() {
|
|
|
|
assert(VALUE_TYPE::HasCurvatureOcf());
|
|
|
|
CurvatureEnabled=false;
|
|
|
|
CuV.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnableCurvatureDir() {
|
|
|
|
assert(VALUE_TYPE::HasCurvatureDirOcf());
|
|
|
|
CurvatureDirEnabled=true;
|
|
|
|
CuDV.resize((*this).size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisableCurvatureDir() {
|
|
|
|
assert(VALUE_TYPE::HasCurvatureDirOcf());
|
|
|
|
CurvatureDirEnabled=false;
|
|
|
|
CuDV.clear();
|
|
|
|
}
|
2005-10-14 17:07:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct VFAdjType {
|
|
|
|
typename VALUE_TYPE::FacePointer _fp ;
|
|
|
|
int _zp ;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2006-11-07 12:29:24 +01:00
|
|
|
std::vector<typename VALUE_TYPE::QualityType> QV;
|
2008-03-17 12:39:15 +01:00
|
|
|
std::vector<typename VALUE_TYPE::CurvatureType> CuV;
|
|
|
|
std::vector<typename VALUE_TYPE::CurvatureDirType> CuDV;
|
2005-10-14 17:07:59 +02:00
|
|
|
std::vector<typename VALUE_TYPE::ColorType> CV;
|
|
|
|
std::vector<typename VALUE_TYPE::NormalType> NV;
|
|
|
|
std::vector<struct VFAdjType> AV;
|
2008-04-04 01:15:40 +02:00
|
|
|
std::vector<int> MV;
|
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
bool QualityEnabled;
|
2005-10-14 17:07:59 +02:00
|
|
|
bool ColorEnabled;
|
|
|
|
bool NormalEnabled;
|
|
|
|
bool VFAdjacencyEnabled;
|
2008-03-17 12:39:15 +01:00
|
|
|
bool CurvatureEnabled;
|
|
|
|
bool CurvatureDirEnabled;
|
2008-04-04 01:15:40 +02:00
|
|
|
bool MarkEnabled;
|
2005-10-14 17:07:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//template<> void EnableAttribute<typename VALUE_TYPE::NormalType>(){ NormalEnabled=true;}
|
|
|
|
|
|
|
|
/*------------------------- COORD -----------------------------------------*/
|
|
|
|
/*----------------------------- VFADJ ------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
template <class T> class VFAdjOcf: public T {
|
|
|
|
public:
|
|
|
|
typename T::FacePointer &VFp() {
|
2006-02-28 12:59:55 +01:00
|
|
|
assert((*this).Base().VFAdjacencyEnabled);
|
2008-03-17 12:39:15 +01:00
|
|
|
return (*this).Base().AV[(*this).Index()]._fp;
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
typename T::FacePointer cVFp() const {
|
2006-02-28 12:59:55 +01:00
|
|
|
if(! (*this).Base().VFAdjacencyEnabled ) return 0;
|
2008-03-17 12:39:15 +01:00
|
|
|
else return (*this).Base().AV[(*this).Index()]._fp;
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int &VFi() {
|
2006-02-28 12:59:55 +01:00
|
|
|
assert((*this).Base().VFAdjacencyEnabled);
|
2008-03-17 12:39:15 +01:00
|
|
|
return (*this).Base().AV[(*this).Index()]._zp;
|
2005-10-14 17:07:59 +02:00
|
|
|
}
|
2008-02-04 22:26:49 +01:00
|
|
|
template <class LeftV>
|
2008-02-05 21:42:43 +01:00
|
|
|
void ImportLocal(const LeftV & leftV){VFp() = NULL; VFi() = -1; T::ImporLocal(leftV);}
|
2008-02-04 22:26:49 +01:00
|
|
|
|
2005-10-14 17:07:59 +02:00
|
|
|
static bool HasVFAdjacency() { return true; }
|
2008-04-04 01:15:40 +02:00
|
|
|
static bool HasVFAdjacencyOcf() {assert(!T::HasVFAdjacencyOcf()); return true; }
|
2005-10-14 17:07:59 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
/*------------------------- Normal -----------------------------------------*/
|
|
|
|
|
|
|
|
template <class A, class T> class NormalOcf: public T {
|
|
|
|
public:
|
|
|
|
typedef A NormalType;
|
|
|
|
static bool HasNormal() { return true; }
|
|
|
|
static bool HasNormalOcf() { return true; }
|
|
|
|
|
|
|
|
NormalType &N() {
|
|
|
|
// you cannot use Normals before enabling them with: yourmesh.vert.EnableNormal()
|
2006-02-28 12:59:55 +01:00
|
|
|
assert((*this).Base().NormalEnabled);
|
2006-12-12 00:42:00 +01:00
|
|
|
return (*this).Base().NV[(*this).Index()]; }
|
2008-02-04 22:26:49 +01:00
|
|
|
const NormalType &N() const {
|
|
|
|
// you cannot use Normals before enabling them with: yourmesh.vert.EnableNormal()
|
|
|
|
assert((*this).Base().NormalEnabled);
|
|
|
|
return (*this).Base().NV[(*this).Index()]; }
|
|
|
|
|
|
|
|
template <class LeftV>
|
2008-02-05 21:42:43 +01:00
|
|
|
void ImportLocal(const LeftV & leftV){ N() = leftV.cN(); T::ImporLocal(leftV);}
|
2005-10-14 17:07:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> class Normal3sOcf: public NormalOcf<vcg::Point3s, T> {};
|
|
|
|
template <class T> class Normal3fOcf: public NormalOcf<vcg::Point3f, T> {};
|
|
|
|
template <class T> class Normal3dOcf: public NormalOcf<vcg::Point3d, T> {};
|
|
|
|
|
|
|
|
///*-------------------------- COLOR ----------------------------------*/
|
|
|
|
|
|
|
|
template <class A, class T> class ColorOcf: public T {
|
|
|
|
public:
|
|
|
|
typedef A ColorType;
|
2008-03-17 12:39:15 +01:00
|
|
|
ColorType &C() { assert((*this).Base().NormalEnabled); return (*this).Base().CV[(*this).Index()]; }
|
|
|
|
const ColorType &cC() const { assert((*this).Base().NormalEnabled); return (*this).Base().CV[(*this).Index()]; }
|
2008-02-04 22:26:49 +01:00
|
|
|
template <class LeftV>
|
2008-02-05 21:42:43 +01:00
|
|
|
void ImportLocal(const LeftV & leftV){ C() = leftV.cC(); T::ImporLocal(leftV);}
|
2005-10-14 17:07:59 +02:00
|
|
|
static bool HasColor() { return true; }
|
2008-04-04 01:15:40 +02:00
|
|
|
static bool HasColorOcf() { assert(!T::HasColorOcf()); return true; }
|
2005-10-14 17:07:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> class Color4bOcf: public ColorOcf<vcg::Color4b, T> {};
|
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
///*-------------------------- QUALITY ----------------------------------*/
|
|
|
|
|
|
|
|
template <class A, class T> class QualityOcf: public T {
|
|
|
|
public:
|
|
|
|
typedef A QualityType;
|
2008-03-17 12:39:15 +01:00
|
|
|
QualityType &Q() { assert((*this).Base().QualityEnabled); return (*this).Base().QV[(*this).Index()]; }
|
2008-02-04 22:26:49 +01:00
|
|
|
template <class LeftV>
|
2008-02-05 21:42:43 +01:00
|
|
|
void ImportLocal(const LeftV & leftV){ Q() = leftV.cQ(); T::ImporLocal(leftV);}
|
2006-11-07 12:29:24 +01:00
|
|
|
static bool HasQuality() { return true; }
|
2008-04-04 01:15:40 +02:00
|
|
|
static bool HasQualityOcf() { assert(!T::HasQualityOcf()); return true; }
|
2006-11-07 12:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> class QualityfOcf: public QualityOcf<float, T> {};
|
|
|
|
|
2008-04-04 01:15:40 +02:00
|
|
|
///*-------------------------- MARK ----------------------------------*/
|
|
|
|
|
|
|
|
template <class T> class MarkOcf: public T {
|
|
|
|
public:
|
|
|
|
inline int & IMark() {
|
|
|
|
assert((*this).Base().MarkEnabled);
|
|
|
|
return (*this).Base().MV[(*this).Index()];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int IMark() const {
|
|
|
|
assert((*this).Base().MarkEnabled);
|
|
|
|
return (*this).Base().MV[(*this).Index()];
|
|
|
|
} ;
|
|
|
|
|
|
|
|
template <class LeftF>
|
|
|
|
void ImportLocal(const LeftF & leftF){IMark() = leftF.cIMark(); T::ImportLocal(leftF);}
|
|
|
|
static bool HasFaceMark() { return true; }
|
|
|
|
static bool HasFaceMarkOcf() { return true; }
|
|
|
|
inline void InitIMark() { IMark() = 0; }
|
|
|
|
};
|
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
|
2008-03-17 12:39:15 +01:00
|
|
|
///*-------------------------- CURVATURE ----------------------------------*/
|
|
|
|
|
|
|
|
template <class A, class TT> class CurvatureOcf: public TT {
|
|
|
|
public:
|
|
|
|
typedef Point2<A> CurvatureType;
|
|
|
|
typedef typename CurvatureType::ScalarType ScalarType;
|
|
|
|
|
|
|
|
ScalarType &H(){ assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][0];}
|
|
|
|
ScalarType &K(){ assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][1];}
|
|
|
|
const ScalarType &cH() const { assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][0];}
|
|
|
|
const ScalarType &cK() const { assert((*this).Base().CurvatureEnabled); return (*this).Base().CuV[(*this).Index()][1];}
|
|
|
|
|
|
|
|
template <class LeftV>
|
|
|
|
void ImportLocal(const LeftV & leftV){
|
|
|
|
(*this).Base().CuV[(*this).Index()][0] = leftV.cH();
|
|
|
|
(*this).Base().CuV[(*this).Index()][1] = leftV.cK(); TT::ImporLocal(leftV);}
|
|
|
|
|
|
|
|
static bool HasCurvatureOcf() { return true; }
|
|
|
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureOcf"));TT::Name(name);}
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> class CurvaturefOcf: public CurvatureOcf<float, T> {};
|
|
|
|
template <class T> class CurvaturedOcf: public CurvatureOcf<double, T> {};
|
|
|
|
|
|
|
|
|
|
|
|
///*-------------------------- CURVATURE DIR ----------------------------------*/
|
|
|
|
|
|
|
|
template <class S>
|
|
|
|
struct CurvatureDirTypeOcf{
|
|
|
|
typedef Point3<S> VecType;
|
|
|
|
typedef S ScalarType;
|
|
|
|
CurvatureDirTypeOcf () {}
|
|
|
|
Point3<S>max_dir,min_dir;
|
|
|
|
S k1,k2;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class A, class TT> class CurvatureDirOcf: public TT {
|
|
|
|
public:
|
|
|
|
typedef A CurvatureDirType;
|
|
|
|
typedef typename CurvatureDirType::VecType VecType;
|
|
|
|
typedef typename CurvatureDirType::ScalarType ScalarType;
|
|
|
|
|
|
|
|
VecType &PD1(){ assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].max_dir;}
|
|
|
|
VecType &PD2(){ assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].max_dir;}
|
|
|
|
const VecType &cPD1() const {assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuV[(*this).Index()].max_dir;}
|
|
|
|
const VecType &cPD2() const {assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuV[(*this).Index()].max_dir;}
|
|
|
|
|
|
|
|
ScalarType &K1(){ assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k1;}
|
|
|
|
ScalarType &K2(){ assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k2;}
|
|
|
|
const ScalarType &cK1() const {assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k1;}
|
|
|
|
const ScalarType &cK2()const {assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CuDV[(*this).Index()].k2;}
|
|
|
|
|
|
|
|
static bool HasCurvatureDirOcf() { return true; }
|
|
|
|
static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirOcf"));TT::Name(name);}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CurvatureDirType _curv;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class T> class CurvatureDirfOcf: public CurvatureDirOcf<CurvatureDirTypeOcf<float>, T> {
|
|
|
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirfOcf"));T::Name(name);}
|
|
|
|
};
|
|
|
|
template <class T> class CurvatureDirdOcf: public CurvatureDirOcf<CurvatureDirTypeOcf<double>, T> {
|
|
|
|
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirdOcf"));T::Name(name);}
|
|
|
|
};
|
2005-10-14 17:07:59 +02:00
|
|
|
///*-------------------------- InfoOpt ----------------------------------*/
|
|
|
|
|
|
|
|
template < class T> class InfoOcf: public T {
|
|
|
|
public:
|
2005-12-12 12:17:32 +01:00
|
|
|
vector_ocf<typename T::VertType> &Base() const { return *_ovp;}
|
2005-10-14 17:07:59 +02:00
|
|
|
|
|
|
|
inline int Index() const {
|
|
|
|
typename T::VertType const *tp=static_cast<typename T::VertType const*>(this);
|
2005-12-12 12:17:32 +01:00
|
|
|
int tt2=tp- &*(_ovp->begin());
|
2005-10-14 17:07:59 +02:00
|
|
|
return tt2;
|
|
|
|
}
|
|
|
|
public:
|
2005-12-12 12:17:32 +01:00
|
|
|
vector_ocf<typename T::VertType> *_ovp;
|
2008-04-04 01:15:40 +02:00
|
|
|
|
|
|
|
static bool HasQualityOcf() { return false; }
|
|
|
|
static bool HasVFAdjacencyOcf() { return false; }
|
2005-10-14 17:07:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
} // end namespace vert
|
|
|
|
|
2006-12-04 12:17:42 +01:00
|
|
|
|
2006-11-07 12:29:24 +01:00
|
|
|
namespace tri
|
|
|
|
{
|
2008-04-04 01:15:40 +02:00
|
|
|
|
|
|
|
template < class, class > class TriMesh;
|
|
|
|
|
2006-11-07 18:22:53 +01:00
|
|
|
template < class VertexType, class FaceContainerType >
|
|
|
|
bool HasPerVertexQuality (const TriMesh < vert::vector_ocf< VertexType > , FaceContainerType > & m)
|
2006-11-07 12:29:24 +01:00
|
|
|
{
|
2006-11-07 18:22:53 +01:00
|
|
|
if(VertexType::HasQualityOcf()) return m.vert.IsQualityEnabled();
|
|
|
|
else return VertexType::HasQuality();
|
2006-11-07 12:29:24 +01:00
|
|
|
}
|
|
|
|
|
2007-12-11 12:36:03 +01:00
|
|
|
template < class VertexType >
|
2008-03-11 10:22:07 +01:00
|
|
|
void ReorderVert( std::vector<size_t> &newVertIndex, vert::vector_ocf< VertexType > &vertVec)
|
2007-12-11 12:36:03 +01:00
|
|
|
{
|
2008-03-11 10:22:07 +01:00
|
|
|
vertVec.ReorderVert(newVertIndex);
|
2007-12-11 12:36:03 +01:00
|
|
|
}
|
2006-11-07 12:29:24 +01:00
|
|
|
}
|
2005-10-14 17:07:59 +02:00
|
|
|
}// end namespace vcg
|
|
|
|
#endif
|