added export to polygonal mesh
This commit is contained in:
parent
461ea23e75
commit
be7c2536f7
|
@ -9,31 +9,6 @@
|
|||
#include <vcg/complex/algorithms/smooth.h>
|
||||
#include <vcg/complex/algorithms/clean.h>
|
||||
|
||||
///return the list of faces that share a specified vertex
|
||||
///together with indexes those faces are sorted in ccw
|
||||
template <class FaceType>
|
||||
void SortedStar(const vcg::face::Pos<FaceType> &ep,
|
||||
std::vector< typename FaceType::VertexType*> &star)
|
||||
{
|
||||
typedef typename FaceType::VertexType VertexType;
|
||||
FaceType *f_init=ep.f;
|
||||
int edge_init=ep.z;
|
||||
vcg::face::JumpingPos<FaceType> VFI(f_init,edge_init);
|
||||
bool complete_turn=false;
|
||||
do
|
||||
{
|
||||
///take the current face
|
||||
FaceType *curr_f=VFI.F();
|
||||
int curr_edge=VFI.E();
|
||||
assert((curr_edge>=0)&&(curr_edge<=4));
|
||||
star.push_back(VFI.F()->V1(curr_edge));
|
||||
//go to next one
|
||||
VFI.NextFE();
|
||||
FaceType *next_f=VFI.F();
|
||||
///test the complete turn
|
||||
complete_turn=(next_f==f_init);
|
||||
}while (!complete_turn);
|
||||
}
|
||||
|
||||
template <class MeshType>
|
||||
inline void ExtractVertex(const MeshType & srcMesh,
|
||||
|
@ -41,14 +16,14 @@ inline void ExtractVertex(const MeshType & srcMesh,
|
|||
int whichWedge,
|
||||
const MeshType &dstMesh,
|
||||
typename MeshType::VertexType & v)
|
||||
{
|
||||
{
|
||||
(void)srcMesh;
|
||||
(void)dstMesh;
|
||||
|
||||
//v.P() = f.cP(whichWedge);
|
||||
v.ImportData(*f.cV(whichWedge));
|
||||
v.T() = f.cWT(whichWedge);
|
||||
}
|
||||
}
|
||||
|
||||
template <class MeshType>
|
||||
inline bool CompareVertex(const MeshType & m,
|
||||
|
@ -511,6 +486,33 @@ public:
|
|||
|
||||
InitIntegerEdgesVert(Tmesh,factor,tolerance);
|
||||
InitVertexQuadMesh(Tmesh);
|
||||
|
||||
///then add to the polygonal mesh
|
||||
Pmesh.Clear();
|
||||
///first create vertices
|
||||
vcg::tri::Allocator<PolyMesh>::AddVertices(Pmesh,IntegerVertex.size());
|
||||
std::map<TriVertexType*,int> VertMap;
|
||||
for(unsigned int i=0;i<IntegerVertex.size();i++)
|
||||
{
|
||||
CoordType pos=IntegerVertex[i]->P();
|
||||
CoordType norm=IntegerVertex[i]->N();
|
||||
Pmesh.vert[i].P()=typename PolyMesh::CoordType(pos.X(),pos.Y(),pos.Z());
|
||||
Pmesh.vert[i].N()=typename PolyMesh::CoordType(norm.X(),norm.Y(),norm.Z());
|
||||
VertMap[IntegerVertex[i]]=i;
|
||||
}
|
||||
///then add polygonal mesh
|
||||
vcg::tri::Allocator<PolyMesh>::AddFaces(Pmesh,polygons.size());
|
||||
for (unsigned int i=0;i<polygons.size();i++)
|
||||
{
|
||||
int size=polygons[i].size();
|
||||
Pmesh.face[i].Alloc(size);
|
||||
for (int j=0;j<size;j++)
|
||||
{
|
||||
TriVertexType* v=polygons[i][j];
|
||||
int index=VertMap[v];
|
||||
Pmesh.face[i].V(j)=&(Pmesh.vert[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue