**** SIGNIFICANT CHANGES *****

- Cleaned up include order: Now you only need to include <vcg/complex/complex.h> (no more vertex/base.h etc) 
- Added official VN() EN() FN() const members for knowing number of vertexes etc...
- Added exceptions (at last!)
    Now instead of:
       assert(HasPerVertexNormal(m)) 
    you should write:
      if(!HasPerFaceNormal(m)) throw vcg::MissingComponentException();
This commit is contained in:
Paolo Cignoni 2012-10-04 11:10:25 +00:00
parent c342c99e74
commit 2577210a54
13 changed files with 88 additions and 171 deletions

View File

@ -25,12 +25,8 @@
#define __VCGLIB_TRIALLOCATOR
#include <typeinfo>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <assert.h>
#include <vcg/container/simple_temporary_data.h>
namespace vcg {
@ -66,9 +62,9 @@ namespace vcg {
template<class MeshType>
size_t Index(MeshType &m, const typename MeshType::FaceType * fp) {return fp-&*m.face.begin();}
template<class MeshType>
size_t Index(MeshType &m, const typename MeshType::EdgeType* e) {return e-&*m.edge.begin();}
size_t Index(MeshType &m, const typename MeshType::EdgeType* e) {return e-&*m.edge.begin();}
template<class MeshType>
size_t Index(MeshType &m, const typename MeshType::HEdgeType* h) {return h-&*m.hedge.begin();}
size_t Index(MeshType &m, const typename MeshType::HEdgeType* h) {return h-&*m.hedge.begin();}
template <class MeshType, class ATTR_CONT>
void ReorderAttribute(ATTR_CONT &c,std::vector<size_t> & newVertIndex, MeshType & /* m */){
@ -78,7 +74,7 @@ namespace vcg {
}
template <class MeshType, class ATTR_CONT>
void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
void ResizeAttribute(ATTR_CONT &c,const int & sz , MeshType &/*m*/){
typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
for(ai =c.begin(); ai != c.end(); ++ai)
((typename MeshType::PointerToAttribute)(*ai)).Resize(sz);

View File

@ -2,7 +2,7 @@
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Copyright(C) 2004-2012 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
@ -21,30 +21,20 @@
* *
****************************************************************************/
#if defined(_MSC_VER)
#pragma warning( disable : 4804 )
#endif
#ifndef __VCG_MESH
#define __VCG_MESH
#include <assert.h>
#include <string>
#include <vector>
#include <set>
#include <vcg/space/box3.h>
#include <vcg/space/color4.h>
#include <vcg/math/shot.h>
#include <exception>
#include <vcg/complex/exception.h>
#include <vcg/container/simple_temporary_data.h>
#include <vcg/simplex/vertex/base.h>
#include <vcg/simplex/edge/base.h>
#include <vcg/simplex/face/base.h>
#include <vcg/connectors/hedge.h>
#include <vcg/complex/used_types.h>
#include <vcg/container/derivation_chain.h>
#include <vcg/complex/allocate.h>
#ifndef __VCG_MESH
#define __VCG_MESH
namespace vcg {
namespace tri {
/** \addtogroup trimesh */
@ -197,22 +187,34 @@ class TriMesh
typedef Box3<ScalarType> BoxType;
/// Set of vertices
/// Container of vertices, usually a vector.
VertContainer vert;
/// Actual number of vertices
/// Current number of vertices; this member is for internal use only. You should always use the VN() member
int vn;
/// Set of faces
FaceContainer face;
/// Actual number of faces
int fn;
/// Set of edges
/// Current number of vertices
inline int VN() const { return vn; }
/// Container of edges, usually a vector.
EdgeContainer edge;
/// Actual number of edges
/// Current number of edges; this member is for internal use only. You should always use the EN() member
int en;
/// Set of hedges
HEdgeContainer hedge;
/// Actual number of hedges
/// Current number of edges
inline int EN() const { return en; }
/// Container of faces, usually a vector.
FaceContainer face;
/// Current number of faces; this member is for internal use only. You should always use the FN() member
int fn;
/// Current number of faces
inline int FN() const { return fn; }
/// Container of half edges, usually a vector.
HEdgeContainer hedge;
/// Current number of hedges
int hn;
/// Current number of hedges; this member is for internal use only. You should always use the HN() member
inline int HN() const { return hn; }
/// Bounding box of the mesh
Box3<ScalarType> bbox;
@ -361,7 +363,7 @@ void Clear()
{
vert.clear();
face.clear();
edge.clear();
edge.clear();
// textures.clear();
// normalmaps.clear();
vn = 0;
@ -380,38 +382,6 @@ int & VertexNumber(){ return vn;}
/// The incremental mark
int imark;
/// Calcolo del volume di una mesh chiusa
ScalarType Volume()
{
FaceIterator fi;
int j,k;
ScalarType V = 0;
CoordType T,N,B;
for(fi = face.begin(); fi!=face.end(); ++fi)
{
for(j = 0; j < 3; ++j)
{
/*calcolo tangente, normale e binormale (6 volte)*/
k = (j+1)%3;
T = (*fi).P(k) - (*fi).P(j);
T.Normalize();
B = ( (*fi).P( k ) - (*fi).P(j) ) ^
( (*fi).P((k+1)%3) - (*fi).P(j) ) ;
B.Normalize();
N = T ^ B;
CoordType pj = (*fi).P(j);
CoordType pk = (*fi).P(k);
V += (pk* T )*(pk*N)*(pk*B);
V += (pj*(-T))*(pj*N)*(pj*B);
}
}
return V/6.0;
}
private:
// TriMesh cannot be copied. Use Append (see vcg/complex/append.h)
TriMesh operator =(const TriMesh & /*m*/){assert(0);return TriMesh();}

35
vcg/complex/exception.h Normal file
View File

@ -0,0 +1,35 @@
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2012 \/)\/ *
* 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. *
* *
****************************************************************************/
#ifndef __VCG_EXCEPTION_H
#define __VCG_EXCEPTION_H
namespace vcg
{
class MissingComponentException : public std::exception
{
public:
MissingComponentException() {}
};
}
#endif // EXCEPTION_H

View File

@ -1,13 +1,23 @@
#ifndef VCG_USED_TYPES_H
#define VCG_USED_TYPES_H
#include <string>
#include <vcg/space/point3.h>
#include <vcg/container/derivation_chain.h>
#include <vcg/space/box3.h>
#include <vcg/space/color4.h>
#include <vcg/math/shot.h>
#include <vcg/space/texcoord2.h>
#include <vcg/space/triangle3.h>
#include <vcg/container/derivation_chain.h>
#include <vcg/complex/all_types.h>
#include <vcg/simplex/vertex/component.h>
#include <vcg/simplex/vertex/base.h>
#include <vcg/simplex/face/component.h>
#include <vcg/simplex/face/component_polygon.h>
#include <vcg/simplex/face/base.h>
#include <vcg/simplex/edge/component.h>
#include <vcg/simplex/edge/base.h>
#include <vcg/connectors/hedge_component.h>
#include <vcg/connectors/hedge.h>
namespace vcg{

View File

@ -20,18 +20,11 @@
* for more details. *
* *
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_HEDGE_
#define __VCG_HEDGE_
//#include <vcg/space/point3.h>
//#include <vcg/space/texcoord2.h>
//#include <vcg/space/color4.h>
#include <vcg/complex/all_types.h>
//#include <vcg/complex/used_types.h>
#include <vcg/connectors/hedge_component.h>
#include <vcg/container/derivation_chain.h>
namespace vcg {
/*------------------------------------------------------------------*/

View File

@ -20,14 +20,10 @@
* for more details. *
* *
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_HEDGE_COMPONENT
#define __VCG_HEDGE_COMPONENT
//#include <vector>
#include <string>
//#include <vcg/space/point3.h>
//#include <vcg/space/texcoord2.h>
#include <vcg/space/color4.h>
namespace vcg {
namespace hedge {

View File

@ -20,17 +20,11 @@
* for more details. *
* *
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_EDGE_PLUS
#define __VCG_EDGE_PLUS
//#include <vcg/space/point3.h>
//#include <vcg/space/texcoord2.h>
//#include <vcg/space/color4.h>
#include <vcg/complex/all_types.h>
//#include <vcg/complex/used_types.h>
#include <vcg/simplex/edge/component.h>
#include <vcg/container/derivation_chain.h>
namespace vcg {

View File

@ -20,14 +20,10 @@
* for more details. *
* *
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_EDGE_PLUS_COMPONENT
#define __VCG_EDGE_PLUS_COMPONENT
#include <vector>
#include <string>
//#include <vcg/space/point3.h>
//#include <vcg/space/texcoord2.h>
#include <vcg/space/color4.h>
namespace vcg {
namespace edge {

View File

@ -20,18 +20,11 @@
* for more details. *
* *
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_FACE_PLUS
#define __VCG_FACE_PLUS
#include <vcg/space/point3.h>
#include <vcg/space/texcoord2.h>
#include <vcg/space/color4.h>
#include <vcg/complex/all_types.h>
#include <vcg/simplex/face/component.h>
#include <vcg/simplex/face/component_polygon.h>
#include <vcg/container/derivation_chain.h>
namespace vcg {
/*------------------------------------------------------------------*/

View File

@ -20,14 +20,10 @@
* for more details. *
* *
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_FACE_PLUS_COMPONENT
#define __VCG_FACE_PLUS_COMPONENT
#include <vector>
#include <vcg/space/triangle3.h>
#include <vcg/space/texcoord2.h>
#include <vcg/space/color4.h>
namespace vcg {

View File

@ -24,11 +24,6 @@
#ifndef __VCG_POLYGON_COMPONENT
#define __VCG_POLYGON_COMPONENT
//#include <vector>
//#include <vcg/space/triangle3.h>
//#include <vcg/space/texcoord2.h>
//#include <vcg/space/color4.h>
namespace vcg {
namespace face {
/*

View File

@ -20,62 +20,10 @@
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
Revision 1.12 2008/03/17 11:39:14 ganovelli
added curvature and curvatruredir (compiled .net 2005 and gcc)
Revision 1.11 2008/02/04 21:26:49 ganovelli
added ImportData 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
Revision 1.10 2007/03/12 15:37:21 tarini
Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.
Revision 1.9 2007/02/12 19:00:56 ganovelli
added Name(std:vector<std::string>& n) that fills n with the names of the attribute of the vertex type
Revision 1.8 2006/09/28 17:34:11 cignoni
Added Missing GetBBox function
Revision 1.7 2006/02/27 17:42:43 ponchio
Added some documentation.
Revision 1.6 2005/12/05 15:58:10 cignoni
Removed spurious definition of flags in Aritymax that was overriding the correct definition in EmplyBitFlags and BitFlags classes
Revision 1.5 2005/12/02 00:44:41 cignoni
Reformatted and compacted flags code.
Revision 1.4 2005/11/16 22:59:35 cignoni
Standardized name of flags. It is plural becouse each simplex has many flag.
Revision 1.3 2005/11/12 18:36:51 cignoni
Added 'Visited' flag functions
Revision 1.2 lags2004/04/03 13:33:55 cignoni
Missing include
Revision 1.1 2004/03/29 08:36:26 cignoni
First working version!
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_VERTEX_PLUS
#define __VCG_VERTEX_PLUS
//#include <vcg/space/point3.h>
#include <vcg/space/texcoord2.h>
#include <vcg/space/color4.h>
#include <vcg/complex/all_types.h>
#include <vcg/simplex/vertex/component.h>
//#include <vcg/complex/used_types.h>
#include <vcg/container/derivation_chain.h>
namespace vcg {
/*------------------------------------------------------------------*/

View File

@ -20,14 +20,9 @@
* for more details. *
* *
****************************************************************************/
#include <vcg/complex/complex.h>
#ifndef __VCG_VERTEX_PLUS_COMPONENT
#define __VCG_VERTEX_PLUS_COMPONENT
#include <vector>
#include <string>
#include <vcg/space/point3.h>
#include <vcg/space/texcoord2.h>
#include <vcg/space/color4.h>
namespace vcg {
namespace vertex {
/*