本文整理汇总了C++中SWIFT_Array::Data方法的典型用法代码示例。如果您正苦于以下问题:C++ SWIFT_Array::Data方法的具体用法?C++ SWIFT_Array::Data怎么用?C++ SWIFT_Array::Data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SWIFT_Array
的用法示例。
在下文中一共展示了SWIFT_Array::Data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save_Decomposition_File
// Save a decomposition file
bool Save_Decomposition_File( const char* filename, SWIFT_Tri_Mesh* m,
SWIFT_Array<int>& piece_ids,
SWIFT_Array< SWIFT_Array<int> >& mfs,
SWIFT_Array< SWIFT_Array<SWIFT_Tri_Face> >& vfs )
{
int i, j, k;
int num_vfaces;
int num_mfaces;
ofstream fout;
SWIFT_Real* vs;
SWIFT_Real* vs_walk;
int* fs;
// Try to open the file
if( filename == NULL ) {
cerr << "Error: Invalid filename given to write decomp" << endl;
return false;
}
#ifdef WIN32
fout.open( filename, ios::out | ios::binary );
#else
fout.open( filename, ios::out );
#endif
if( !fout.rdbuf()->is_open( ) ) {
cerr << "Error: file could not be opened for writing \""
<< filename << "\"" << endl;
return false;
}
fout << '\0';
fout << "Convex_Decomposition" << endl;
if( machine_is_big_endian ) {
fout << "binary big_endian" << endl;
} else {
fout << "binary little_endian" << endl;
}
if( sizeof(SWIFT_Real) == sizeof(float) ) {
fout << "real float" << endl;
} else {
fout << "real double" << endl;
}
fout << "vertices " << m->Num_Vertices() << endl;
fout << "faces " << m->Num_Faces() << endl;
fout << "map_vids " << m->Map_Vertex_Ids().Length() << endl;
fout << "map_fids " << m->Map_Face_Ids().Length() << endl;
fout << "pieces " << mfs.Length() << endl;
// Compose the vertices into an array
vs = new SWIFT_Real[m->Num_Vertices()*3];
vs_walk = vs;
for( i = 0; i < m->Num_Vertices(); i++, vs_walk += 3 ) {
m->Vertices()[i].Coords().Get_Value( vs_walk );
}
// Write the vertices
fout.write( (char*)vs, m->Num_Vertices()*3*sizeof(SWIFT_Real) );
delete [] vs;
// Compose the faces into an array
fs = new int[m->Num_Faces()*3];
for( i = 0, j = 0; i < m->Num_Faces(); i++, j += 3 ) {
fs[j] = m->Vertex_Id( m->Faces()[i].Edge1().Origin() );
fs[j+1] = m->Vertex_Id( m->Faces()[i].Edge2().Origin() );
fs[j+2] = m->Vertex_Id( m->Faces()[i].Edge3().Origin() );
}
// Write out the faces
fout.write( (char*)fs, m->Num_Faces()*3*sizeof(int) );
delete [] fs;
// Write out vertex mapping
if( !m->No_Duplicate_Vertices() ) {
fout.write( (char*)m->Map_Vertex_Ids().Data(),
m->Num_Vertices()*sizeof(int) );
}
// Write out face mapping
if( !m->Only_Triangles() ) {
fout.write( (char*)m->Map_Face_Ids().Data(),
m->Num_Faces()*sizeof(int) );
}
// Write out piece ids array
fout.write( (char*)piece_ids.Data(), piece_ids.Length()*sizeof(int) );
// Compose the original faces lengths into an array
fs = new int[mfs.Length()];
for( i = 0; i < mfs.Length(); i++ ) {
fs[i] = mfs[i].Length();
}
// Write out the original faces lengths
fout.write( (char*)fs, mfs.Length()*sizeof(int) );
delete [] fs;
//.........这里部分代码省略.........