From fd8e9de7875b10a4c87251b99231ffde49c23a8e Mon Sep 17 00:00:00 2001 From: cignoni Date: Sat, 12 Nov 2005 18:13:30 +0000 Subject: [PATCH] Added support for non triangular faces (simple fan triangulation) and removed flags intiailization. --- wrap/io_trimesh/import_ply.h | 72 +++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/wrap/io_trimesh/import_ply.h b/wrap/io_trimesh/import_ply.h index 25417016..2bf3d1e5 100644 --- a/wrap/io_trimesh/import_ply.h +++ b/wrap/io_trimesh/import_ply.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.16 2005/10/14 15:09:56 cignoni +Added LoadMask without plyinfo and some comment on the mask usage + Revision 1.15 2005/06/10 15:05:00 cignoni Made inline PlyType specializations @@ -339,7 +342,7 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi ) // init defaults VertexType tv; - tv.UberFlags() = 0; + //tv.ClearFlags(); if( VertexType::HasQuality() ) tv.Q()=1.0; if( VertexType::HasColor() ) tv.C()=Color4b(Color4b::White); @@ -389,7 +392,8 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi ) { pi.status = PlyInfo::E_NO_FACE; return pi.status; } // Descrittori facoltativi dei flags - if( pf.AddToRead(VertDesc(3))!=-1 ) + + if(VertexType::HasFlags() && (pf.AddToRead(VertDesc(3))!=-1 ) ) pi.mask |= ply::PLYMask::PM_VERTFLAGS; if( VertexType::HasQuality() ) @@ -551,7 +555,7 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi ) for(j=0;j=m.vn ) - { - pi.status = PlyInfo::E_BAD_VERT_INDEX; - return pi.status; - } - (*fi).V(k) = index[ fa.v[k] ]; + { // Non triangular face are manageable ONLY if there are no Per Wedge attributes + if( ( pi.mask & ply::PLYMask::PM_WEDGCOLOR ) || ( pi.mask & ply::PLYMask::PM_WEDGTEXCOORD ) ) + { + pi.status = PlyInfo::E_NO_3VERTINFACE; + return pi.status; + } } if( pi.mask & ply::PLYMask::PM_FACEFLAGS ) @@ -667,18 +664,57 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi ) } } } + /// Now the temporary struct 'fa' is ready to be copied into the real face '*fi' + /// This loop + for(k=0;k<3;++k) + { + if( fa.v[k]<0 || fa.v[k]>=m.vn ) + { + pi.status = PlyInfo::E_BAD_VERT_INDEX; + return pi.status; + } + (*fi).V(k) = index[ fa.v[k] ]; + } for(k=0;k3) + { + int curpos=int(fi-m.face.begin()); + Allocator::AddFaces(m,fa.size-3); + fi=m.face.begin()+curpos; + } + for(int qq=0;qq=m.vn ) + { + pi.status = PlyInfo::E_BAD_VERT_INDEX; + return pi.status; + } + (*fi).V(k) = index[ fa.v[1+qq+k] ]; + } + + for(k=0;k