vcglib/vcg/complex/edgemesh/base.h

218 lines
6.8 KiB
C
Raw Normal View History

2004-04-26 21:10:04 +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 $
2007-05-21 15:22:40 +02:00
Revision 1.7 2007/03/12 15:38:02 tarini
Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.
Revision 1.6 2005/09/14 14:09:16 spinelli
ConstVertexPointer --> VertexPointer
ConstEdgePointer --> EdgePointer
Revision 1.5 2005/05/17 21:19:37 ganovelli
some std::and typename missing (CRS4)
2005-05-17 23:19:37 +02:00
Revision 1.4 2004/10/28 00:47:42 cignoni
Better Doxygen documentation
2004-10-28 02:56:44 +02:00
Revision 1.3 2004/09/20 09:30:03 cignoni
Better Doxygen docs
2004-09-20 11:30:03 +02:00
Revision 1.2 2004/05/10 14:41:45 ganovelli
name of adhacency function updated
2004-05-10 16:41:45 +02:00
Revision 1.1 2004/04/26 19:10:04 ganovelli
created
2004-04-26 21:10:04 +02:00
****************************************************************************/
#pragma warning( disable : 4804 )
/*
People should subclass his vertex class from these one...
*/
2004-05-10 16:41:45 +02:00
#ifndef __VCGLIB_EDGEMESH
#define __VCGLIB_EDGEMESH
2004-04-26 21:10:04 +02:00
namespace vcg {
namespace edg {
2004-09-20 11:30:03 +02:00
/** \addtogroup edgemesh */
2004-04-26 21:10:04 +02:00
/*@{*/
2004-10-28 02:56:44 +02:00
/** \class EdgeMesh.
2004-04-26 21:10:04 +02:00
This is class for definition of a mesh.
2004-10-28 02:56:44 +02:00
@param VertContainerType (Template Parameter) Specifies the type of the vertices container any the vertex type.
@param EdgeContainerType (Template Parameter) Specifies the type of the faces container any the face type.
2004-04-26 21:10:04 +02:00
*/
template < class VertContainerType, class EdgeContainerType >
2004-05-10 16:41:45 +02:00
class EdgeMesh{
2004-04-26 21:10:04 +02:00
public:
typedef EdgeContainerType EdgeContainer;
typedef VertContainerType VertContainer;
typedef typename VertContainer::value_type VertexType;
typedef typename EdgeContainerType::value_type EdgeType;
typedef typename VertexType::ScalarType ScalarType;
typedef typename VertexType::CoordType CoordType;
typedef typename VertContainer::iterator VertexIterator;
typedef typename EdgeContainerType::iterator EdgeIterator;
typedef typename VertContainer::const_iterator ConstVertexIterator;
typedef typename EdgeContainerType::const_iterator ConstEdgeIterator;
typedef VertexType * VertexPointer;
typedef const VertexType * ConstVertexPointer;
2004-05-10 16:41:45 +02:00
typedef EdgeType * EdgePointer;
2004-04-26 21:10:04 +02:00
typedef const EdgeType * ConstEdgePointer;
typedef Box3<ScalarType> BoxType;
/// Set of vertices
VertContainer vert;
/// Real number of vertices
int vn;
/// Set of faces
2004-05-10 16:41:45 +02:00
EdgeContainer edges;
2004-04-26 21:10:04 +02:00
/// Real number of faces
int en;
/// Bounding box of the mesh
Box3<ScalarType> bbox;
/// Nomi di textures
2005-05-17 23:19:37 +02:00
//std::vector<string> textures;
//std::vector<string> normalmaps;
2004-04-26 21:10:04 +02:00
/// La camera
//Camera<ScalarType> camera;
/// Il colore della mesh
private:
Color4b c;
public:
inline const Color4b & C() const
{
return c;
}
inline Color4b & C()
{
return c;
}
/// Default constructor
2004-05-10 16:41:45 +02:00
EdgeMesh()
2004-04-26 21:10:04 +02:00
{
en = vn = 0;
imark = 0;
}
inline int MemUsed() const
{
2004-09-20 11:30:03 +02:00
return sizeof(EdgeMesh)+sizeof(VertexType)*vert.size()+sizeof(EdgeType)*edges.size();
2004-04-26 21:10:04 +02:00
}
inline int MemNeeded() const
{
2007-05-21 15:22:40 +02:00
return sizeof(EdgeMesh)+sizeof(VertexType)*vn+sizeof(EdgeType)*en;
2004-04-26 21:10:04 +02:00
}
/// Function to destroy the mesh
void Clear()
{
vert.clear();
2004-05-10 16:41:45 +02:00
edges.clear();
2004-04-26 21:10:04 +02:00
// textures.clear();
// normalmaps.clear();
vn = 0;
en = 0;
}
/// Reflection functions that speak about vertex and face properties.
static bool HasPerVertexNormal() { return VertexType::HasNormal() ; }
static bool HasPerVertexColor() { return VertexType::HasColor() ; }
static bool HasPerVertexMark() { return VertexType::HasMark() ; }
static bool HasPerVertexQuality() { return VertexType::HasQuality(); }
static bool HasPerVertexTexCoord(){ return VertexType::HasTexCoord(); }
2004-04-26 21:10:04 +02:00
static bool HasPerEdgeColor() { return EdgeType::HasEdgeColor() ; }
static bool HasPerEdgeNormal() { return EdgeType::HasEdgeNormal() ; }
static bool HasPerEdgeMark() { return EdgeType::HasEdgeMark() ; }
static bool HasPerEdgeQuality() { return EdgeType::HasEdgeQuality(); }
2004-05-10 16:41:45 +02:00
static bool HasEETopology() { return EdgeType::HasEEAdjacency(); }
2007-05-21 15:22:40 +02:00
static bool HasVETopology() { return EdgeType::HasVEAdjacency(); }
2004-05-10 16:41:45 +02:00
static bool HasTopology() { return HasEETopology() || HasVETopology(); }
2004-04-26 21:10:04 +02:00
/// Initialize the imark-system of the faces
void InitEdgeIMark()
{
EdgeIterator f;
2004-05-10 16:41:45 +02:00
for(f=edges.begin();f!=edges.end();++f)
2004-04-26 21:10:04 +02:00
if( !(*f).IsDeleted() && (*f).IsR() && (*f).IsW() )
(*f).InitIMark();
}
/// Initialize the imark-system of the vertices
void InitVertexIMark()
{
VertexIterator vi;
for(vi=vert.begin();vi!=vert.end();++vi)
if( !(*vi).IsDeleted() && (*vi).IsRW() )
(*vi).InitIMark();
}
/// The incremental mark
int imark;
/** Check if the vertex incremental mark matches the one of the mesh.
*/
inline bool IsMarked( ConstVertexPointer v ) const { return v->IMark() == imark; }
/** Check if the face incremental mark matches the one of the mesh.
*/
inline bool IsMarked( ConstEdgePointer f ) const { return f->IMark() == imark; }
/** Set the vertex incremental mark of the vertex to the one of the mesh.
*/
inline void Mark( VertexPointer v ) const { v->IMark() = imark; }
2004-04-26 21:10:04 +02:00
/** Set the face incremental mark of the vertex to the one of the mesh.
*/
inline void Mark( EdgePointer f ) const { f->IMark() = imark; }
2004-04-26 21:10:04 +02:00
/// Unmark the mesh
inline void UnMarkAll() { ++imark; }
2004-09-20 11:30:03 +02:00
}; // end class EdgeMesh
2004-04-26 21:10:04 +02:00
/*@}*/
} // end namespace
} // end namespace
#endif