本文整理汇总了C++中MeshImpl::tag_set_vertex_data方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshImpl::tag_set_vertex_data方法的具体用法?C++ MeshImpl::tag_set_vertex_data怎么用?C++ MeshImpl::tag_set_vertex_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshImpl
的用法示例。
在下文中一共展示了MeshImpl::tag_set_vertex_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_classify_by_tag
void DomainClassifierTest::test_classify_by_tag()
{
CPPUNIT_ASSERT( !myDomains.empty() );
MsqPrintError err(std::cerr);
int def = myDomains.size();
TagHandle tag = myMesh.tag_create( "domain", Mesh::INT, 1, &def, err );
CPPUNIT_ASSERT(!err);
std::vector<MeshDomain*> dom_list;
std::vector<int> id_list;
for (unsigned i = 0; i < myDomains.size(); ++i) {
std::vector<int> vtx_data( myDomains[i].vertices.size(), i );
std::vector<int> elm_data( myDomains[i].elements.size(), i );
if (!vtx_data.empty()) {
myMesh.tag_set_vertex_data( tag, vtx_data.size(),
&(myDomains[i].vertices[0]),
&vtx_data[0], err );
CPPUNIT_ASSERT(!err);
}
if (!elm_data.empty()) {
myMesh.tag_set_element_data( tag, elm_data.size(),
&(myDomains[i].elements[0]),
&elm_data[0], err );
CPPUNIT_ASSERT(!err);
}
dom_list.push_back( myDomains[i].domain );
id_list.push_back( i );
}
DomainClassifier domain;
DomainClassifier::classify_by_tag( domain, &myMesh,
"domain",
&dom_list[0],
&id_list[0],
myDomains.size(),
err );
CPPUNIT_ASSERT(!err);
check_domain( domain );
}
示例2: main
//.........这里部分代码省略.........
EntityTopology type;
mesh.elements_get_topologies( &elem, &type, 1, err );
std::copy( conn.begin() + TopologyInfo::corners(type), conn.end(),
std::back_inserter( higher_order ) );
}
std::sort( higher_order.begin(), higher_order.end() );
higher_order.erase( std::unique( higher_order.begin(), higher_order.end() ),
higher_order.end() );
// build depth map for all vertices
while (!next.empty()) {
curr.swap( next );
next.clear();
while (!curr.empty()) {
Mesh::ElementHandle elem = curr.back();
curr.pop_back();
conn.clear();
mesh.elements_get_attached_vertices( &elem, 1, conn, off, err );
if (err) return 1;
int min = std::numeric_limits<int>::max();
for (size_t i = 0; i < conn.size(); ++i) {
d_iter = depth.find( conn[i] );
if (d_iter != depth.end() && d_iter->second < min)
min = d_iter->second;
}
if (min == std::numeric_limits<int>::max()) {
next.push_back( elem );
continue;
}
for (size_t i = 0; i < conn.size(); ++i) {
d_iter = depth.find( conn[i] );
if (d_iter == depth.end() || d_iter->second > min+1)
depth[conn[i]] = min+1;
}
}
}
// write depth map to tag for debugging purposes
std::vector<int> depth_vals(verts.size());
for (size_t i = 0; i < verts.size(); ++i)
depth_vals[i] = depth[verts[i]];
TagHandle tag = mesh.tag_create( "depth", Mesh::INT, 1, 0, err );
if (err) return 1;
mesh.tag_set_vertex_data( tag, verts.size(), arrptr(verts), arrptr(depth_vals), err );
if (err) return 1;
// set tag specifying slaved vertices
for (size_t i = 0; i < verts.size(); ++i)
if (std::binary_search( higher_order.begin(), higher_order.end(), verts[i] ))
depth_vals[i] = depth[verts[i]] > n;
else
depth_vals[i] = 0;
tag = mesh.tag_create( "slaved", Mesh::INT, 1, 0, err );
if (err) return 1;
mesh.tag_set_vertex_data( tag, verts.size(), arrptr(verts), arrptr(depth_vals), err );
if (err) return 1;
// perturb mid-edge nodes along boundary
std::vector<MsqVertex> coords;
for (size_t i = 0; i < skin.size(); ++i) {
if (!std::binary_search( higher_order.begin(), higher_order.end(), skin[i]))
continue;
curr.clear();
mesh.vertices_get_attached_elements( &skin[i], 1, curr, off, err );
if (err) return 1;
assert(curr.size() == 1);
conn.clear();
mesh.elements_get_attached_vertices( arrptr(curr), 1, conn, off, err );
if (err) return 1;
// estimate element center
coords.resize( conn.size() );
mesh.vertices_get_coordinates( arrptr(conn), arrptr(coords), conn.size(), err );
if (err) return 1;
Vector3D mean(0.0);
for (size_t j = 0; j < coords.size(); ++j)
mean += coords[j];
mean /= coords.size();
size_t idx = std::find( conn.begin(), conn.end(), skin[i] ) - conn.begin();
assert(idx < conn.size());
Vector3D init = coords[idx];
Vector3D pos = (1 - PERTURB_FRACT) * init + PERTURB_FRACT * mean;
mesh.vertex_set_coordinates( skin[i], pos, err );
if (err) return 1;
}
mesh.write_vtk( argv[3], err );
if (err) return 1;
return 0;
}