本文整理汇总了C++中MeshImpl::tag_get_element_data方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshImpl::tag_get_element_data方法的具体用法?C++ MeshImpl::tag_get_element_data怎么用?C++ MeshImpl::tag_get_element_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshImpl
的用法示例。
在下文中一共展示了MeshImpl::tag_get_element_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_field_attrib
void VtkTest::check_field_attrib( const char* temp_file_name )
{
MeshImpl mesh;
MsqPrintError err(cout);
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
std::vector<Mesh::ElementHandle> elems;
mesh.get_all_elements( elems, err );
CPPUNIT_ASSERT( !err );
CPPUNIT_ASSERT_EQUAL( elems.size(), (size_t)8 );
std::string name;
Mesh::TagType type;
unsigned tagsize;
void* th = mesh.tag_get( "test_field elem_vects", err );
CPPUNIT_ASSERT( !err );
mesh.tag_properties( th, name, type, tagsize, err );
CPPUNIT_ASSERT( !err && type == Mesh::DOUBLE && tagsize == 3 );
double elem_data[24];
mesh.tag_get_element_data( th, 8, arrptr(elems), elem_data, err );
CPPUNIT_ASSERT( !err );
for (int i = 0; i < 8; ++i)
CPPUNIT_ASSERT( Vector3D( elem_data+3*i ) == Vector3D( i+1, i+1, i+1 ) );
th = mesh.tag_get( "test_field elem_ids", err );
CPPUNIT_ASSERT( !err );
mesh.tag_properties( th, name, type, tagsize, err );
CPPUNIT_ASSERT( !err && type == Mesh::INT && tagsize == 1 );
int elem_ids[8];
mesh.tag_get_element_data( th, 8, arrptr(elems), elem_ids, err );
CPPUNIT_ASSERT( !err );
for (int i = 0; i < 8; ++i)
CPPUNIT_ASSERT( elem_ids[i] == i+1 );
th = mesh.tag_get( "field1", err );
CPPUNIT_ASSERT( !err );
mesh.tag_properties( th, name, type, tagsize, err );
CPPUNIT_ASSERT( !err && type == Mesh::INT && tagsize == 1 );
int values[8];
mesh.tag_get_element_data( th, 8, arrptr(elems), values, err );
CPPUNIT_ASSERT( !err );
for (int i = 0; i < 8; ++i)
CPPUNIT_ASSERT( values[i] == 8-i );
}
示例2: test_read_vector_attrib
// Test reading Vtk vector attribute
void VtkTest::test_read_vector_attrib()
{
MeshImpl mesh;
MsqPrintError err(cout);
FILE* file = fopen( temp_file_name, "w+" );
fputs( structured_3d_points_data, file );
fputs( simple_vector_attrib, file );
fclose( file );
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
std::vector<Mesh::ElementHandle> elems;
mesh.get_all_elements( elems, err );
CPPUNIT_ASSERT( !err );
CPPUNIT_ASSERT_EQUAL( elems.size(), (size_t)8 );
void* th = mesh.tag_get( "hexvect", err );
CPPUNIT_ASSERT( !err );
std::string name;
Mesh::TagType type;
unsigned tagsize;
mesh.tag_properties( th, name, type, tagsize, err );
CPPUNIT_ASSERT( !err && type == Mesh::DOUBLE && tagsize == 3 );
double elem_data[24];
mesh.tag_get_element_data( th, 8, arrptr(elems), elem_data, err );
CPPUNIT_ASSERT( !err );
for (int i = 0; i < 8; ++i)
CPPUNIT_ASSERT( Vector3D( elem_data+3*i ) == Vector3D( i+1, i+1, i+1 ) );
}
示例3: test_read_simple_scalar_attrib
// Test reading Vtk simple (one-component) scalar attribute
void VtkTest::test_read_simple_scalar_attrib()
{
MeshImpl mesh;
MsqPrintError err(cout);
FILE* file = fopen( temp_file_name, "w+" );
fputs( structured_3d_points_data, file );
fputs( simple_scalar_attrib, file );
fclose( file );
mesh.read_vtk( temp_file_name, err );
remove( temp_file_name );
ASSERT_NO_ERROR(err);
std::vector<Mesh::ElementHandle> elems;
mesh.get_all_elements( elems, err );
CPPUNIT_ASSERT( !err );
CPPUNIT_ASSERT_EQUAL( elems.size(), (size_t)8 );
void* th = mesh.tag_get( "global_id", err );
CPPUNIT_ASSERT( !err );
std::string name;
Mesh::TagType type;
unsigned tagsize;
mesh.tag_properties( th, name, type, tagsize, err );
CPPUNIT_ASSERT( !err && type == Mesh::INT && tagsize == 1 );
int elem_data[8];
mesh.tag_get_element_data( th, 8, arrptr(elems), elem_data, err );
CPPUNIT_ASSERT( !err );
for (int i = 0; i < 8; ++i)
CPPUNIT_ASSERT( elem_data[i] == (1+i) );
}