updated to comply with:
[introduction of half edges as alternative representation] No modification should be necessary for the existing code. most relevant changes: creation of folder: vcg/connectors vcg/connectors/hedge.h vcg/connectors/hedge_component.h addition to the container of half edges to the trimesh: HEdgeContainer hedge; // container int hn; // number of half edges addition of vcg/trimesh/update/halfedge_indexed.h which contains: - the functions to compute the half edge representation from the indexed and vivecersa - the functions to add or remove an half edge
This commit is contained in:
parent
e06c7f7e70
commit
6aa09931c4
|
@ -30,7 +30,7 @@
|
||||||
#include <vcg/simplex/face/base.h>
|
#include <vcg/simplex/face/base.h>
|
||||||
|
|
||||||
/*include the base definition for the edge */
|
/*include the base definition for the edge */
|
||||||
#include <vcg/simplex/edge/base.h>
|
#include <vcg/connectors/hedge.h>
|
||||||
|
|
||||||
/*include the base definition for the trimesh*/
|
/*include the base definition for the trimesh*/
|
||||||
#include <vcg/complex/trimesh/base.h>
|
#include <vcg/complex/trimesh/base.h>
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
#include <vcg/simplex/face/component_polygon.h>
|
#include <vcg/simplex/face/component_polygon.h>
|
||||||
|
|
||||||
/* include the support for half edges */
|
/* include the support for half edges */
|
||||||
#include <vcg/complex/trimesh/edge_support.h>
|
#include <vcg/complex/trimesh/update/halfedge_indexed.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
|
@ -65,7 +65,7 @@ using namespace std;
|
||||||
// forward declarations
|
// forward declarations
|
||||||
class CFace;
|
class CFace;
|
||||||
class CVertex;
|
class CVertex;
|
||||||
class CEdge;
|
class CHEdge;
|
||||||
class DummyEdge;
|
class DummyEdge;
|
||||||
class MyPolyVertex;
|
class MyPolyVertex;
|
||||||
|
|
||||||
|
@ -96,25 +96,26 @@ class CMesh : public vcg::tri::TriMesh< vector<CVertex>, vector<CFace> > {};
|
||||||
*/
|
*/
|
||||||
class MyPolyFace;
|
class MyPolyFace;
|
||||||
class MyPolyVertex;
|
class MyPolyVertex;
|
||||||
struct PolyUsedTypes: public vcg::UsedTypes< vcg::Use<MyPolyVertex>::AsVertexType,
|
struct PolyUsedTypes: public vcg::UsedTypes<vcg::Use<MyPolyVertex> ::AsVertexType,
|
||||||
vcg::Use<CEdge>::AsEdgeType,
|
vcg::Use<CHEdge> ::AsHEdgeType,
|
||||||
vcg::Use<MyPolyFace>::AsFaceType >{};
|
vcg::Use<MyPolyFace> ::AsFaceType
|
||||||
|
>{};
|
||||||
|
|
||||||
|
|
||||||
class MyPolyVertex:public vcg::Vertex<PolyUsedTypes,
|
class MyPolyVertex:public vcg::Vertex< PolyUsedTypes,
|
||||||
vcg::vertex::Coord3f,
|
vcg::vertex::Coord3f,
|
||||||
vcg::vertex::Normal3f,
|
vcg::vertex::Normal3f,
|
||||||
vcg::vertex::Mark,
|
vcg::vertex::Mark,
|
||||||
vcg::vertex::BitFlags,
|
vcg::vertex::BitFlags,
|
||||||
vcg::vertex::VEAdj>{} ;
|
vcg::vertex::VHAdj>{} ;
|
||||||
|
|
||||||
class CEdge : public Edge< PolyUsedTypes, edge::BitFlags,
|
class CHEdge : public HEdge< PolyUsedTypes, hedge::BitFlags,
|
||||||
//edge::EFAdj, // pointer to the face
|
//hedge::HFAdj, // pointer to the face
|
||||||
//edge::HEOppAdj, // pointer to the opposite edge
|
//hedge::HOppAdj, // pointer to the opposite edge
|
||||||
//edge::HEVAdj, // pointer to the vertex
|
//hedge::HVAdj, // pointer to the vertex
|
||||||
//edge::HENextAdj, // pointer to the next halfedge
|
//hedge::HNextAdj, // pointer to the next halfedge
|
||||||
edge::HEdgeData // the previous 4 components (just more handy, you can comment this and uncomment the previous four lines)
|
hedge::HEdgeData // the previous 4 components (just more handy, you can comment this and uncomment the previous four lines)
|
||||||
//,edge::HEPrevAdj // pointer to the previous halfedge
|
//,hedge::HPrevAdj // pointer to the previous halfedge
|
||||||
>{};
|
>{};
|
||||||
|
|
||||||
class MyPolyFace:public vcg::Face<
|
class MyPolyFace:public vcg::Face<
|
||||||
|
@ -123,8 +124,9 @@ class MyPolyFace:public vcg::Face<
|
||||||
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
|
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
|
||||||
// will be allocated dynamically")
|
// will be allocated dynamically")
|
||||||
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
|
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
|
||||||
|
,vcg::face::PFVAdj
|
||||||
,vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj )
|
,vcg::face::PFFAdj // Pointer to edge-adjacent face (just like FFAdj )
|
||||||
,vcg::face::PFHEAdj // Pointer its half -edges ( you may need this if you use half edges)
|
,vcg::face::PFHAdj // Pointer its half -edges ( you may need this if you use half edges)
|
||||||
,vcg::face::BitFlags // bit flags
|
,vcg::face::BitFlags // bit flags
|
||||||
,vcg::face::Normal3f // normal
|
,vcg::face::Normal3f // normal
|
||||||
> {};
|
> {};
|
||||||
|
@ -132,7 +134,7 @@ class MyPolyFace:public vcg::Face<
|
||||||
class MyPolyMesh: public
|
class MyPolyMesh: public
|
||||||
vcg::tri::TriMesh< std::vector<MyPolyVertex>, // the vector of vertices
|
vcg::tri::TriMesh< std::vector<MyPolyVertex>, // the vector of vertices
|
||||||
std::vector<MyPolyFace >, // the vector of faces
|
std::vector<MyPolyFace >, // the vector of faces
|
||||||
std::vector<CEdge> // the vector of edges
|
std::vector<CHEdge> // the vector of edges
|
||||||
>{};
|
>{};
|
||||||
|
|
||||||
MyPolyMesh pm;
|
MyPolyMesh pm;
|
||||||
|
@ -142,15 +144,13 @@ MyPolyMesh pm;
|
||||||
// Globals: the mesh, the OpenGL wrapper to draw the mesh and the trackball.
|
// Globals: the mesh, the OpenGL wrapper to draw the mesh and the trackball.
|
||||||
CMesh mesh,mesh1;
|
CMesh mesh,mesh1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int loadmask;
|
int loadmask;
|
||||||
|
|
||||||
vcg::tri::io::PlyInfo pi;
|
vcg::tri::io::PlyInfo pi;
|
||||||
|
|
||||||
|
// pm.hedge.reserve(100000);
|
||||||
if(false){
|
if(false){
|
||||||
/*
|
/*
|
||||||
first way:
|
first way:
|
||||||
|
@ -186,42 +186,44 @@ else
|
||||||
|
|
||||||
|
|
||||||
// compute the half edges because I'm a half-edge programmer
|
// compute the half edges because I'm a half-edge programmer
|
||||||
vcg::tri::EdgeSupport<MyPolyMesh>::ComputeHalfEdgeFromIndexed(pm);
|
vcg::tri::UpdateHalfEdges<MyPolyMesh>::FromIndexed(pm);
|
||||||
|
|
||||||
// .... my half edge based code ......
|
// .... my half edge based code ......
|
||||||
|
|
||||||
// check for consistency
|
// check for consistency
|
||||||
assert(vcg::tri::EdgeSupport<MyPolyMesh>::CheckConsistency(pm));
|
assert(vcg::tri::UpdateHalfEdges<MyPolyMesh>::CheckConsistency(pm));
|
||||||
|
|
||||||
int size = pm.face.size();
|
int size = pm.face.size();
|
||||||
|
|
||||||
// add a face to each face with more than 3 vertices ( just one pass)
|
// add a face to each face with more than 3 vertices ( just one pass)
|
||||||
|
|
||||||
for(int i = 0; i < size; ++i)
|
for(int i = 0; i < size; ++i)
|
||||||
if(!(pm.face[i].IsD()))
|
if(!(pm.face[i].IsD()))
|
||||||
if(pm.face[i].VN()>3){
|
if(pm.face[i].VN()>3){
|
||||||
MyPolyMesh::EdgePointer ef = pm.face[i].FHEp();
|
MyPolyMesh::HEdgePointer ef = pm.face[i].FHp();
|
||||||
MyPolyMesh::EdgePointer ef1 = ef -> HENp();
|
MyPolyMesh::HEdgePointer ef1 = ef -> HNp();
|
||||||
ef1 = ef1->HENp();
|
ef1 = ef1->HNp();
|
||||||
vcg::tri::EdgeSupport<MyPolyMesh>::AddEdge(pm, ef, ef1 );
|
vcg::tri::UpdateHalfEdges<MyPolyMesh>::AddHEdge(pm, ef, ef1 );
|
||||||
}
|
}
|
||||||
assert(vcg::tri::EdgeSupport<MyPolyMesh>::CheckConsistency(pm));
|
assert(vcg::tri::UpdateHalfEdges<MyPolyMesh>::CheckConsistency(pm));
|
||||||
size = pm.face.size();
|
size = pm.face.size();
|
||||||
|
|
||||||
// remove an edge for each face
|
// remove an edge for each face
|
||||||
|
|
||||||
for(int i = 0; i < size; ++i)
|
for(int i = 0; i < size; ++i)
|
||||||
if(!(pm.face[i].IsD() ))
|
if(!(pm.face[i].IsD() ))
|
||||||
{
|
{
|
||||||
MyPolyMesh::EdgePointer ef = pm.face[i].FHEp();
|
MyPolyMesh::HEdgePointer ef = pm.face[i].FHp();
|
||||||
if( ef->HEOp()->EFp() !=NULL){
|
if( ef->HOp()->HFp() !=NULL){
|
||||||
vcg::tri::EdgeSupport<MyPolyMesh>::RemoveEdge(pm,ef);
|
vcg::tri::UpdateHalfEdges<MyPolyMesh>::RemoveHEdge(pm,ef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for consistency
|
// check for consistency
|
||||||
assert(vcg::tri::EdgeSupport<MyPolyMesh>::CheckConsistency(pm));
|
assert(vcg::tri::UpdateHalfEdges<MyPolyMesh>::CheckConsistency(pm));
|
||||||
|
|
||||||
// recompute indexed data structure from the half edge data structure
|
// recompute indexed data structure from the half edge data structure
|
||||||
vcg::tri::EdgeSupport<MyPolyMesh>::ComputeIndexedFromHalfEdge(pm );
|
vcg::tri::UpdateIndexed<MyPolyMesh>::FromHalfEdges(pm );
|
||||||
|
|
||||||
// create a triangle mesh from a polygon mesh
|
// create a triangle mesh from a polygon mesh
|
||||||
vcg::tri::PolygonSupport<CMesh,MyPolyMesh>::ImportFromPolyMesh(mesh1,pm);
|
vcg::tri::PolygonSupport<CMesh,MyPolyMesh>::ImportFromPolyMesh(mesh1,pm);
|
||||||
|
|
Loading…
Reference in New Issue