Re-Wrote basic build function
This commit is contained in:
parent
46eb093f0f
commit
6144006bfd
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.11 2007/02/01 06:38:27 cignoni
|
||||||
|
Added small comment to grid function
|
||||||
|
|
||||||
Revision 1.10 2007/01/27 13:14:34 marfr960
|
Revision 1.10 2007/01/27 13:14:34 marfr960
|
||||||
Removed unuseful CoordType test
|
Removed unuseful CoordType test
|
||||||
|
|
||||||
|
|
@ -570,8 +573,9 @@ void Box(MeshType &in, const typename MeshType::BoxType & bb )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Questa funzione costruisce una mesh a partire da un insieme di coordiante
|
// this function build a mesh starting from a vector of generic coords (objects having a triple of float at their beginning)
|
||||||
/// ed un insieme di terne di indici di vertici
|
// and a vector of faces (objects having a triple of ints at theri beginning).
|
||||||
|
|
||||||
|
|
||||||
template <class MeshType,class V, class F >
|
template <class MeshType,class V, class F >
|
||||||
void Build( MeshType & in, const V & v, const F & f)
|
void Build( MeshType & in, const V & v, const F & f)
|
||||||
|
|
@ -582,25 +586,18 @@ void Build( MeshType & in, const V & v, const F & f)
|
||||||
typedef typename MeshType::VertexIterator VertexIterator;
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
typedef typename MeshType::FaceIterator FaceIterator;
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
|
|
||||||
in.vn = v.size();
|
Allocator<MeshType>::AddVertices(in,v.size());
|
||||||
in.fn = f.size();
|
Allocator<MeshType>::AddFaces(in,f.size());
|
||||||
|
|
||||||
in.vert.clear();
|
|
||||||
in.face.clear();
|
|
||||||
|
|
||||||
typename V::const_iterator vi;
|
typename V::const_iterator vi;
|
||||||
|
|
||||||
typename MeshType::VertexType tv;
|
typename MeshType::VertexType tv;
|
||||||
tv.Supervisor_Flags()=0;
|
// tv.Supervisor_Flags()=0;
|
||||||
|
|
||||||
for(vi=v.begin();vi!=v.end();++vi)
|
for(int i=0;i<v.size();++i)
|
||||||
{
|
{
|
||||||
tv.P() = CoordType(
|
float *vv=(float *)(&v[i]);
|
||||||
(ScalarType)(*vi).Ext(0),
|
in.vert[i].P() = CoordType( vv[0],vv[1],vv[2]);
|
||||||
(ScalarType)(*vi).Ext(1),
|
|
||||||
(ScalarType)(*vi).Ext(2)
|
|
||||||
);
|
|
||||||
in.vert.push_back(tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VertexPointer> index(in.vn);
|
std::vector<VertexPointer> index(in.vn);
|
||||||
|
|
@ -612,20 +609,20 @@ void Build( MeshType & in, const V & v, const F & f)
|
||||||
typename F::const_iterator fi;
|
typename F::const_iterator fi;
|
||||||
|
|
||||||
typename MeshType::FaceType ft;
|
typename MeshType::FaceType ft;
|
||||||
ft.Supervisor_Flags()=0;
|
|
||||||
|
|
||||||
for(fi=f.begin();fi!=f.end();++fi)
|
for(int i=0;i<f.size();++i)
|
||||||
{
|
{
|
||||||
assert( (*fi)[0]>=0 );
|
int * ff=(int *)(&f[i]);
|
||||||
assert( (*fi)[1]>=0 );
|
assert( ff[0]>=0 );
|
||||||
assert( (*fi)[2]>=0 );
|
assert( ff[1]>=0 );
|
||||||
assert( (*fi)[0]<in.vn );
|
assert( ff[2]>=0 );
|
||||||
assert( (*fi)[1]<in.vn );
|
assert( ff[0]<in.vn );
|
||||||
assert( (*fi)[2]<in.vn );
|
assert( ff[1]<in.vn );
|
||||||
ft.V(0) = index[ (*fi)[0] ];
|
assert( ff[2]<in.vn );
|
||||||
ft.V(1) = index[ (*fi)[1] ];
|
in.face[i].V(0) = &in.vert[ ff[0] ];
|
||||||
ft.V(2) = index[ (*fi)[2] ];
|
in.face[i].V(1) = &in.vert[ ff[0] ];
|
||||||
in.face.push_back(ft);
|
in.face[i].V(2) = &in.vert[ ff[0] ];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue