corrected bug in the allocation of the result of multiple connected triangulations (poligons with holes, and added parameter to revert the order of outlines)
This commit is contained in:
parent
a53887e893
commit
fbe0b23839
|
@ -2,6 +2,8 @@
|
||||||
#define GLU_TESSELLATOR_CAP_H
|
#define GLU_TESSELLATOR_CAP_H
|
||||||
#include "glu_tesselator.h"
|
#include "glu_tesselator.h"
|
||||||
#include <vcg/simplex/edge/pos.h>
|
#include <vcg/simplex/edge/pos.h>
|
||||||
|
#include <vcg/complex/algorithms/clean.h>
|
||||||
|
#include <vcg/complex/algorithms/update/bounding.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
|
@ -10,7 +12,7 @@ namespace tri {
|
||||||
// This function take a mesh with one or more boundary stored as edges, and fill another mesh with a triangulation of that boundaries.
|
// This function take a mesh with one or more boundary stored as edges, and fill another mesh with a triangulation of that boundaries.
|
||||||
// it assumes that boundary are planar and exploits glutessellator for the triangulaiton
|
// it assumes that boundary are planar and exploits glutessellator for the triangulaiton
|
||||||
template <class MeshType>
|
template <class MeshType>
|
||||||
void CapEdgeMesh(MeshType &em, MeshType &cm)
|
void CapEdgeMesh(MeshType &em, MeshType &cm, bool revertFlag=false)
|
||||||
{
|
{
|
||||||
typedef typename MeshType::EdgeType EdgeType;
|
typedef typename MeshType::EdgeType EdgeType;
|
||||||
std::vector< std::vector<Point3f> > outlines;
|
std::vector< std::vector<Point3f> > outlines;
|
||||||
|
@ -32,7 +34,7 @@ void CapEdgeMesh(MeshType &em, MeshType &cm)
|
||||||
nv++;
|
nv++;
|
||||||
}
|
}
|
||||||
while(curE != startE);
|
while(curE != startE);
|
||||||
|
if(revertFlag) std::reverse(outline.begin(),outline.end());
|
||||||
outlines.push_back(outline);
|
outlines.push_back(outline);
|
||||||
outline.clear();
|
outline.clear();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +53,8 @@ void CapEdgeMesh(MeshType &em, MeshType &cm)
|
||||||
glu_tesselator::tesselate(outlines, indices);
|
glu_tesselator::tesselate(outlines, indices);
|
||||||
std::vector<Point3f> points;
|
std::vector<Point3f> points;
|
||||||
glu_tesselator::unroll(outlines, points);
|
glu_tesselator::unroll(outlines, points);
|
||||||
typename MeshType::FaceIterator fi=tri::Allocator<MeshType>::AddFaces(cm,nv-2);
|
//typename MeshType::FaceIterator fi=tri::Allocator<MeshType>::AddFaces(cm,nv-2);
|
||||||
|
typename MeshType::FaceIterator fi=tri::Allocator<MeshType>::AddFaces(cm,indices.size()/3);
|
||||||
for (size_t i=0; i<indices.size(); i+=3,++fi)
|
for (size_t i=0; i<indices.size(); i+=3,++fi)
|
||||||
{
|
{
|
||||||
(*&fi)->V(0)=&cm.vert[ indices[i+0] ];
|
(*&fi)->V(0)=&cm.vert[ indices[i+0] ];
|
||||||
|
|
Loading…
Reference in New Issue