From 0f320aa6710d60e2940432d07757ef91d835e19c Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 6 Jul 2021 16:43:22 +0200 Subject: [PATCH] fix off polygon export --- vcg/complex/algorithms/polygon_support.h | 7 +++++-- wrap/io_trimesh/export_off.h | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/vcg/complex/algorithms/polygon_support.h b/vcg/complex/algorithms/polygon_support.h index bce0d219..801a35bb 100644 --- a/vcg/complex/algorithms/polygon_support.h +++ b/vcg/complex/algorithms/polygon_support.h @@ -24,6 +24,9 @@ #ifndef __VCGLIB_POLYGON_SUPPORT #define __VCGLIB_POLYGON_SUPPORT +#include +#include +#include #include #include @@ -141,8 +144,8 @@ namespace tri { { std::vector vs;// vertices of the polygon ExtractPolygon(&*tfi,vs); - if (vs.size() > 3) - std::reverse(vs.begin(), vs.end()); + if (vs.size() > 3) + std::reverse(vs.begin(), vs.end()); //now vs contains all the vertices of the polygon (still in the trimesh) if (vs.size()==0)continue; typename PolyMeshType::FaceIterator pfi = tri::Allocator::AddFaces(pm,1); diff --git a/wrap/io_trimesh/export_off.h b/wrap/io_trimesh/export_off.h index 3a9fec97..d4b8435b 100644 --- a/wrap/io_trimesh/export_off.h +++ b/wrap/io_trimesh/export_off.h @@ -104,10 +104,17 @@ public: tri::UpdateFlags::FaceClearV(m); for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) if (!fi->IsD()) if (!fi->IsV()) { vcg::tri::PolygonSupport::ExtractPolygon(&*fi,polygon); + //not sure why this std::reverse is needed. ExtractPolygon is used in + //many other functions, and nobody complained. however, this list is + //clockwise wrt fi normal. + std::reverse(polygon.begin(), polygon.end()); if(!polygon.empty()) { fprintf(fpout,"%d ", int(polygon.size()) ); - for (size_t i=0; iFlags() ); + for (size_t i=0; iC()[0],fi->C()[1],fi->C()[2] ); fprintf(fpout,"\n"); } }