当前位置: 首页>>代码示例>>C++>>正文


C++ MeshImpl::vertices_get_byte方法代码示例

本文整理汇总了C++中MeshImpl::vertices_get_byte方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshImpl::vertices_get_byte方法的具体用法?C++ MeshImpl::vertices_get_byte怎么用?C++ MeshImpl::vertices_get_byte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MeshImpl的用法示例。


在下文中一共展示了MeshImpl::vertices_get_byte方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_slaved_common


//.........这里部分代码省略.........
      if (dim[i] <= boundary) {
        depths[0].push_back( verts[i] );
        non_slave.insert( verts[i] );
      }
  }
  
    // check that our input is usable for this test
  CPPUNIT_ASSERT( !verts.empty() );
  
    // find all vertices up to specified depth
  for (unsigned d = 0; d < depth; ++d) {
    for (size_t i = 0; i < depths[d].size(); ++i) {
      std::vector<Mesh::ElementHandle> adj;
      std::vector<size_t> junk;
      mesh.vertices_get_attached_elements( &depths[d][i], 1, adj, junk, err );
      ASSERT_NO_ERROR(err);
      for(size_t j = 0; j < adj.size(); ++j) {
        junk.clear();
        std::vector<Mesh::VertexHandle> conn;
        mesh.elements_get_attached_vertices( &adj[j], 1, conn, junk, err );
        ASSERT_NO_ERROR(err);
        for (size_t k = 0; k < conn.size(); ++k) {
          p = non_slave.find(conn[k]);
          if (p == non_slave.end()) {
            non_slave.insert( p, conn[k] );
            depths[d+1].push_back( conn[k] );
          }
        }
      }
    }
  }
  
    // Check that our input is usable for this test:
    // Should have some vertices that are not within the specified depth of 
    // the boundary.
  CPPUNIT_ASSERT( non_slave.size() < verts.size() );
  
    // Now build a map of all higher-order nodes in the mesh
  std::set<Mesh::VertexHandle> higher_order;
  std::vector<Mesh::ElementHandle> elems;
  mesh.get_all_elements( elems, err ); 
  ASSERT_NO_ERROR(err);
  CPPUNIT_ASSERT(!elems.empty());
  std::vector<EntityTopology> types(elems.size());
  mesh.elements_get_topologies( arrptr(elems), arrptr(types), elems.size(), err );
  ASSERT_NO_ERROR(err);
  for (size_t i = 0; i < elems.size(); ++i) {
    std::vector<Mesh::VertexHandle> conn;
    std::vector<size_t> junk;
    mesh.elements_get_attached_vertices( &elems[i], 1, conn, junk, err );
    ASSERT_NO_ERROR(err);
    for (size_t j = TopologyInfo::corners( types[i] ); j < conn.size(); ++j)
      higher_order.insert( conn[j] );
  }
  
    // Check that our input is usable for this test:
    // Should have some higher-order vertices
  CPPUNIT_ASSERT( !higher_order.empty() );
  
    // Now build a map of all fixed vertices
  std::set<Mesh::VertexHandle> fixed_vertices;
  std::vector<bool> fixed;
  mesh.vertices_get_fixed_flag( arrptr(verts), fixed, verts.size(), err );
  ASSERT_NO_ERROR(err);
  for (size_t i = 0; i < verts.size(); ++i)
    if (fixed[i])
      fixed_vertices.insert( verts[i] );

    // Now actually run the tool
  Settings settings;
  settings.set_slaved_ho_node_mode( Settings::SLAVE_CALCULATED );
  SlaveBoundaryVertices tool( depth, boundary );
  tool.loop_over_mesh( &mesh, &domain, &settings, err );
  ASSERT_NO_ERROR(err);
  
    // Now verify the results
  std::vector<unsigned char> bytes( verts.size() );
  mesh.vertices_get_byte( arrptr(verts), arrptr(bytes), verts.size(), err );
  ASSERT_NO_ERROR(err);
  for (size_t i = 0; i < verts.size(); ++i) {
    bool in_non_slave = (non_slave.find( verts[i] ) != non_slave.end());
    bool in_fixed = (fixed_vertices.find( verts[i] ) != fixed_vertices.end());
    bool in_higher_order = (higher_order.find( verts[i] ) != higher_order.end());
    if (bytes[i] & MsqVertex::MSQ_DEPENDENT) { // if slave node
        // must not be within 'depth' of boundary
      CPPUNIT_ASSERT( !in_non_slave );
        // must be a higher-order vertex
      CPPUNIT_ASSERT( in_higher_order );
        // must not be fixed
      CPPUNIT_ASSERT( !in_fixed );
    }
    else {
        // there are three reasons that a vertex isn't slaved
      bool in_non_slave = (non_slave.find( verts[i] ) != non_slave.end());
      bool in_fixed = (fixed_vertices.find( verts[i] ) != fixed_vertices.end());
      bool in_higher_order = (higher_order.find( verts[i] ) != higher_order.end());
      CPPUNIT_ASSERT( in_fixed || !in_higher_order || in_non_slave );
    }
  }
}
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的MeshImpl::vertices_get_byte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。