updated polygon triangulate funnction + corrected Dijkstra spelling

This commit is contained in:
Luigi Malomo 2019-02-28 12:37:01 +01:00
parent 5ab1b189a0
commit ce75b4e68f
3 changed files with 39 additions and 38 deletions

View File

@ -84,7 +84,7 @@ int main( int argc, char **argv )
printf("min %f max %f\n",minmax.first,minmax.second);
tri::io::ExporterPLY<MyMesh>::Save(m,"base.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY);
int t0=clock();
tri::Geodesic<MyMesh>::PerVertexDijsktraCompute(m,seedVec,ed);
tri::Geodesic<MyMesh>::PerVertexDijkstraCompute(m,seedVec,ed);
int t1=clock();
printf("Geodesic dijkstra %6.3f\n",float(t1-t0)/CLOCKS_PER_SEC);
tri::UpdateColor<MyMesh>::PerVertexQualityRamp(m);

View File

@ -514,7 +514,7 @@ It is just a simple wrapper of the basic Compute()
static inline std::string parentsAttributeName(void) { return "parent"; }
template <class DistanceFunctor>
static void PerFaceDijsktraCompute(MeshType &m, const std::vector<FacePointer> &seedVec,
static void PerFaceDijkstraCompute(MeshType &m, const std::vector<FacePointer> &seedVec,
DistanceFunctor &distFunc,
ScalarType maxDistanceThr = std::numeric_limits<ScalarType>::max(),
std::vector<FacePointer> *InInterval=NULL,
@ -579,7 +579,7 @@ It is just a simple wrapper of the basic Compute()
template <class DistanceFunctor>
static void PerVertexDijsktraCompute(MeshType &m, const std::vector<VertexPointer> &seedVec,
static void PerVertexDijkstraCompute(MeshType &m, const std::vector<VertexPointer> &seedVec,
DistanceFunctor &distFunc,
ScalarType maxDistanceThr = std::numeric_limits<ScalarType>::max(),
std::vector<VertexPointer> *InInterval=NULL,

View File

@ -72,11 +72,12 @@ This class is used to performs varisous kind of geometric optimization on generi
template <class PolyMeshType>
class PolygonalAlgorithm
{
typedef typename PolyMeshType::FaceType FaceType;
typedef typename PolyMeshType::VertexType VertexType;
typedef typename PolyMeshType::CoordType CoordType;
typedef typename PolyMeshType::ScalarType ScalarType;
typedef typename vcg::face::Pos<FaceType> PosType;
typedef typename PolyMeshType::FaceType FaceType;
typedef typename PolyMeshType::VertexType VertexType;
typedef typename PolyMeshType::VertexPointer VertexPointer;
typedef typename PolyMeshType::CoordType CoordType;
typedef typename PolyMeshType::ScalarType ScalarType;
typedef typename vcg::face::Pos<FaceType> PosType;
public:
static bool CollapseEdges(PolyMeshType &poly_m,
const std::vector<PosType> &CollapsePos,
@ -1257,42 +1258,42 @@ public:
}
}
static void Triangulate(PolyMeshType &poly_m,size_t IndexF)
{
/*! \brief Triangulate a polygonal face with a triangle fan.
* \returns pointer to the newly added vertex.
*/
static VertexPointer Triangulate(PolyMeshType & poly_m, size_t IndexF)
{
CoordType bary=vcg::PolyBarycenter(poly_m.face[IndexF]);
size_t sizeV=poly_m.face[IndexF].VN();
const CoordType bary = vcg::PolyBarycenter(poly_m.face[IndexF]);
size_t sizeV = poly_m.face[IndexF].VN();
//add the new vertex
vcg::tri::Allocator<PolyMeshType>::AddVertex(poly_m,bary);
VertexType *newV=&poly_m.vert.back();
//add the new vertex
VertexPointer newV = &(*vcg::tri::Allocator<PolyMeshType>::AddVertex(poly_m,bary));
std::vector<size_t> ToUpdateF;
//then reupdate the faces
for (size_t j=0;j<(sizeV-1);j++)
{
VertexType * v0=poly_m.face[IndexF].V0(j);
VertexType * v1=poly_m.face[IndexF].V1(j);
VertexType * v2=newV;
//then reupdate the faces
for (size_t j=0;j<(sizeV-1);j++)
{
VertexType * v0=poly_m.face[IndexF].V0(j);
VertexType * v1=poly_m.face[IndexF].V1(j);
VertexType * v2=newV;
vcg::tri::Allocator<PolyMeshType>::AddFaces(poly_m,1);
vcg::tri::Allocator<PolyMeshType>::AddFaces(poly_m,1);
poly_m.face.back().Alloc(3);
poly_m.face.back().V(0)=v0;
poly_m.face.back().V(1)=v1;
poly_m.face.back().V(2)=v2;
}
poly_m.face.back().Alloc(3);
poly_m.face.back().V(0)=v0;
poly_m.face.back().V(1)=v1;
poly_m.face.back().V(2)=v2;
ToUpdateF.push_back(poly_m.face.size()-1);
}
VertexType * v0=poly_m.face[IndexF].V0((sizeV-1));
VertexType * v1=poly_m.face[IndexF].V1((sizeV-1));
poly_m.face[IndexF].Dealloc();
poly_m.face[IndexF].Alloc(3);
poly_m.face[IndexF].V(0)=v0;
poly_m.face[IndexF].V(1)=v1;
poly_m.face[IndexF].V(2)=newV;
ToUpdateF.push_back(IndexF);
}
VertexType * v0=poly_m.face[IndexF].V0((sizeV-1));
VertexType * v1=poly_m.face[IndexF].V1((sizeV-1));
poly_m.face[IndexF].Dealloc();
poly_m.face[IndexF].Alloc(3);
poly_m.face[IndexF].V(0)=v0;
poly_m.face[IndexF].V(1)=v1;
poly_m.face[IndexF].V(2)=newV;
return newV;
}
static void ReorderFaceVert(FaceType &f,const size_t &StartI)
{