void FaceCellConnectivity::build_connectivity()
{

  if (used().size() == 0 )
  {
    CFwarn << "No elements are given to build faces of" << CFendl;
    return;
  }

  // declartions
  m_connectivity->resize(0);
  common::Table<Entity>::Buffer f2c = m_connectivity->create_buffer();
  common::Table<Uint>::Buffer face_number = m_face_nb_in_elem->create_buffer();
  common::List<bool>::Buffer is_bdry_face = m_is_bdry_face->create_buffer();
  common::Table<Uint>::Buffer cell_rotation = m_cell_rotation->create_buffer();
  common::Table<bool>::Buffer cell_orientation = m_cell_orientation->create_buffer();

  Dictionary& geometry_fields = find_parent_component<Mesh>(*used()[0]).geometry_fields();
  Uint tot_nb_nodes = geometry_fields.size();
  std::vector < std::vector<Uint> > mapNodeFace(tot_nb_nodes);
  std::vector<Uint> face_nodes;  face_nodes.reserve(100);
  std::vector<Entity> dummy_element_row(2);
  std::vector<Uint> tmp_row(2);
  Uint max_nb_faces(0);

  // calculate max_nb_faces
  boost_foreach ( Handle< Component > elements_comp, used() )
  {
    Handle<Elements> elements(elements_comp);
    if (elements->element_type().dimensionality() != elements->element_type().dimension() )
      continue;
    const Uint nb_faces = elements->element_type().nb_faces();
    max_nb_faces += nb_faces * elements->size() ;
  }
Exemplo n.º 2
0
void CAgpCompSpanSplitter::SaveRow(const string& s, CRef<CAgpRow> row, TRangeColl* runs_of_Ns)
{
  if( row ) {
    comp_or_gap_printed=true;
    if(object_name != row->GetObject() ) {
      object_name = row->GetObject();
      part_number = 1; // row->GetPartNumber();
    }
    CRef<CAgpRow> tmp_row( row->Clone() );

    if(runs_of_Ns && runs_of_Ns->size()) {

      if( row->GetVersion() == eAgpVersion_auto ) {
        cerr << "FATAL: need AGP version (for adding gap lines). Please use -v 1.1 or -v 2.0\n";
        exit(1);
      }
      /*
      CAgpRow tmp_gap_row = *row; // to retain the object name
      tmp_gap_row.GetComponentType() = "N";
      tmp_gap_row.is_gap   = true;
      tmp_gap_row.linkage  = true;
      tmp_gap_row.gap_type = row->GetVersion() == eAgpVersion_1_1 ? CAgpRow::eGapFragment : CAgpRow::eGapScaffold;
      tmp_gap_row.linkage_evidence_flags = CAgpRow::fLinkageEvidence_unspecified;'
      */
      CRef<CAgpRow> tmp_gap_row( CAgpRow::New(NULL, row->GetVersion(), NULL) );
      tmp_gap_row->FromString(
        row->GetObject()+
        "\t1\t100\t1\tN\t100\t"+
        string(row->GetVersion() == eAgpVersion_1_1 ? "fragment\tyes\t" : "scaffold\tyes\tunspecified")
      );

      int comp2obj_ofs = row->object_beg - row->component_beg;

      for(TRangeColl::const_iterator it = runs_of_Ns->begin(); it != runs_of_Ns->end(); ++it) {
        if( (TSeqPos) tmp_row->component_beg < it->GetFrom() ) {
          // component line
          tmp_row->component_end = it->GetFrom()-1;
          tmp_row->object_end    = comp2obj_ofs + tmp_row->component_end;

          tmp_row->part_number = part_number;
          (*m_out) << tmp_row->ToString() << endl;
          part_number++;
        }

        // gap line
        tmp_gap_row->object_beg = comp2obj_ofs + it->GetFrom();
        tmp_gap_row->object_end = comp2obj_ofs + it->GetTo();
        tmp_gap_row->gap_length = it->GetTo() - it->GetFrom() + 1;

        tmp_gap_row->part_number = part_number;
        (*m_out) << tmp_gap_row->ToString(true) << endl; // true: use linkage_evidence_flags
        part_number++;

        tmp_row->component_beg = it->GetTo() + 1;
        tmp_row->object_beg    = comp2obj_ofs + tmp_row->component_beg;
      }

      if(tmp_row->component_beg <= row->component_end) {
        // this component does not end with Ns => need to print the final component span
        tmp_row->component_end = row->component_end;
        tmp_row->object_end    = row->object_end;
      }
      else return; // ends with Ns => skip printing the component row below
    }

    tmp_row->part_number = part_number;
    (*m_out) << tmp_row->ToString() << endl;
    part_number++;
  }
  else if(!comp_or_gap_printed){
    // comment line (only at the head of file, to comply with AGP 2.0)
    (*m_out) << s << endl;
  }
}