Corrected bug in the BuildMeshFromCoordVectorIndexVector

And improved comment on usage
This commit is contained in:
Paolo Cignoni 2016-12-05 13:04:47 +01:00
parent 56dcf4a513
commit 5e03df37b7
1 changed files with 10 additions and 6 deletions

View File

@ -689,10 +689,14 @@ void SuperEllipsoid(MeshType &m, float rFeature, float sFeature, float tFeature,
tri::Clean<MeshType>::OrientCoherentlyMesh(m,oriented,orientable); tri::Clean<MeshType>::OrientCoherentlyMesh(m,oriented,orientable);
tri::UpdateSelection<MeshType>::Clear(m); tri::UpdateSelection<MeshType>::Clear(m);
} }
// this function build a mesh starting from a vector of generic coords (objects having a triple of float at their beginning)
// and a vector of faces (objects having a triple of ints at theri beginning). /** This function build a mesh starting from a vector of generic coords (InCoordType) and indexes (InFaceIndexType)
template <class MeshType,class V, class F > * InCoordsType needs to have a [] access method for accessing the three coordinates
void BuildMeshFromCoordVectorIndexVector( MeshType & in, const V & v, const F & f) * and similarly the InFaceIndexType requires [] access method for accessing the three indexes
*/
template <class MeshType, class InCoordType, class InFaceIndexType >
void BuildMeshFromCoordVectorIndexVector(MeshType & in, const std::vector<InCoordType> & v, const std::vector<InFaceIndexType> & f)
{ {
typedef typename MeshType::CoordType CoordType; typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer; typedef typename MeshType::VertexPointer VertexPointer;
@ -704,7 +708,7 @@ void BuildMeshFromCoordVectorIndexVector( MeshType & in, const V & v, const F &
for(size_t i=0;i<v.size();++i) for(size_t i=0;i<v.size();++i)
{ {
float *vv=(float *)(&v[i]); const InCoordType &vv = v[i];
in.vert[i].P() = CoordType( vv[0],vv[1],vv[2]); in.vert[i].P() = CoordType( vv[0],vv[1],vv[2]);
} }
@ -716,7 +720,7 @@ void BuildMeshFromCoordVectorIndexVector( MeshType & in, const V & v, const F &
for(size_t i=0;i<f.size();++i) for(size_t i=0;i<f.size();++i)
{ {
int * ff=(int *)(&f[i]); const InFaceIndexType &ff= f[i];
assert( ff[0]>=0 ); assert( ff[0]>=0 );
assert( ff[1]>=0 ); assert( ff[1]>=0 );
assert( ff[2]>=0 ); assert( ff[2]>=0 );