diff --git a/apps/sample/trimesh_allocate/trimesh_allocate.cpp b/apps/sample/trimesh_allocate/trimesh_allocate.cpp index 428cee49..532b12f5 100644 --- a/apps/sample/trimesh_allocate/trimesh_allocate.cpp +++ b/apps/sample/trimesh_allocate/trimesh_allocate.cpp @@ -49,7 +49,7 @@ int main() MyMesh::VertexIterator vi = vcg::tri::Allocator::AddVertices(m,3); MyMesh::FaceIterator fi = vcg::tri::Allocator::AddFaces(m,1); - MyMesh::VertexPointer ivp[3]; + MyMesh::VertexPointer ivp[4]; ivp[0]=&*vi; vi->P()=MyMesh::CoordType ( 0.0, 0.0, 0.0); ++vi; ivp[1]=&*vi; vi->P()=MyMesh::CoordType ( 1.0, 0.0, 0.0); ++vi; ivp[2]=&*vi; vi->P()=MyMesh::CoordType ( 0.0, 1.0, 0.0); ++vi; @@ -58,6 +58,12 @@ int main() fi->V(1)=ivp[1]; fi->V(2)=ivp[2]; + // Alternative, more compact, method for adding a single vertex + ivp[3]=vcg::tri::Allocator::AddVertex(m,MyMesh::CoordType ( 1.0, 1.0, 0.0)); + + // Alternative, more compact, method for adding a single face (once you have the vertex pointers) + vcg::tri::Allocator::AddFace(m, ivp[1],ivp[0],ivp[3]); + // a potentially dangerous pointer to a mesh element MyMesh::FacePointer fp = &m.face[0]; vcg::tri::Allocator::PointerUpdater pu; @@ -96,6 +102,9 @@ int main() vcg::tri::Allocator::CompactFaceVector(m); vcg::tri::Allocator::CompactVertexVector(m); + // To clean all the containers from deleted elements + vcg::tri::Allocator::CompactEveryVector(m); + // finally lets copy this mesh onto another one. MyMesh m2; vcg::tri::Append::MeshCopy(m2,m); diff --git a/apps/sample/trimesh_base/trimesh_base.cpp b/apps/sample/trimesh_base/trimesh_base.cpp index 0c8cae7f..9f879b94 100644 --- a/apps/sample/trimesh_base/trimesh_base.cpp +++ b/apps/sample/trimesh_base/trimesh_base.cpp @@ -68,6 +68,7 @@ int main( int argc, char **argv ) exit(0); } + vcg::tri::RequirePerVertexNormal(m); vcg::tri::UpdateNormal::PerVertexNormalized(m); printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN()); printf( "Mesh has %i vert and %i faces\n", m.VN(), m.FN() );