コード例 #1
0
    void Geometry::info(const bool verbous) const {
        if (is_nested_) {
            std::cout << "This geometry is a NESTED geometry." << std::endl;
        } else {
            int shared = -vertices_.size();
            for (const_iterator mit=begin();mit!=end();++mit)
                shared += mit->nb_vertices();
            // those are not the number of shared vertices but the number of demands for adding the same vertex...
            std::cout << "This geometry is a NON NESTED geometry. (There was " << shared << " demands for adding same vertices)." << std::endl;
        }

        for (const_iterator mit=begin();mit!=end();++mit)
            mit->info();

        for (Domains::const_iterator dit=domain_begin();dit!=domain_end();++dit)
            dit->info();

        if (verbous) {
            for (Vertices::const_iterator vit=vertex_begin();vit!=vertex_end();++vit)
                std::cout << "[" << *vit << "] = " << vit->index() << std::endl;

            for (const_iterator mit=begin();mit!=end();++mit)
                for (Mesh::const_iterator tit=mit->begin();tit!=mit->end();++tit)
                    std::cout << "[[" << tit->s1() << "] , [" << tit->s2() << "] , ["<< tit->s3() << "]] \t = " << tit->index() << std::endl;
        }
    }
コード例 #2
0
ファイル: has_cycle.cpp プロジェクト: alyssaq/graphs
bool Graph<Vertex, Edge_value>::Has_cycle(void)
{
  set< Vertex, less<Vertex> > processed;
  set< Vertex, less<Vertex> > visited;

  Graph<Vertex, Edge_value>::vertex_iterator i;
  bool has_cycle;

  // Go through each vertex and do a depth first search
  // starting there.
  i = vertex_begin();
  has_cycle = false;
  while (!has_cycle && i != vertex_end()) {
    has_cycle = has_cycle || Check_node_for_cycle(*i, processed, visited);
    // After each pass through check_node_for_cycle, there should
    // be no nodes left in visited.
    assert(visited.size() == 0);
    ++i;
  }

  // We have either processed every vertex, or we found a cycle and bailed early.
  assert(has_cycle || (processed.size() == Num_vertices()));

  return(has_cycle);
}
コード例 #3
0
    void Geometry::generate_indices(const bool OLD_ORDERING) {

        // Either unknowns (potentials and currents) are ordered by mesh (i.e. V_1, p_1, V_2, p_2,...) (this is the OLD_ORDERING)
        // or by type (V_1,V_2,V_3 .. p_1, p_2...) (by DEFAULT)
        // or by the user himself encoded into the vtp file.
        // if you use OLD_ORDERING make sure to iterate only once on each vertex: not to overwrite index (meshes have shared vertices).
        if (begin()->begin()->index()==unsigned(-1)) {
            unsigned index = 0;
            if (!OLD_ORDERING)
                for (Vertices::iterator pit=vertex_begin();pit != vertex_end();++pit)
                    (invalid_vertices_.empty()||invalid_vertices_.count(*pit)==0) ? pit->index()=index++ : unsigned(-1);

            for(iterator mit=begin();mit!=end();++mit){
                if(OLD_ORDERING){
                    om_error(is_nested_); // OR non nested but without shared vertices
                    for (Mesh::const_vertex_iterator vit=mit->vertex_begin();vit!=mit->vertex_end();++vit,++index)
                        (*vit)->index() = index;
                }
                if(!mit->isolated()&&!mit->current_barrier())
                    for ( Mesh::iterator tit = mit->begin(); tit != mit->end(); ++tit)
                        tit->index() = index++;
            }
            // even the last surface triangles (yes for EIT... )
            nb_current_barrier_triangles()=0;
            for (iterator mit=begin(); mit!=end();++mit)
                if(mit->current_barrier())
                    if(!mit->isolated()){
                        nb_current_barrier_triangles()+=mit->nb_triangles();
                        for (Mesh::iterator tit=mit->begin(); tit!=mit->end(); ++tit)
                            tit->index() = index++;
                    } else {
                        for(Mesh::iterator tit=mit->begin();tit!=mit->end();++tit)
                            tit->index()=unsigned(-1);
                    }

            size_ = index;
        }else{
            std::cout << "vertex_begin()->index() " << vertex_begin()->index() << std::endl;
            size_ = vertices_.size();
            for (iterator mit=begin();mit!=end();++mit)
                size_ += mit->size();
        }
    }