Beispiel #1
0
EFAFragment3D::EFAFragment3D(EFAElement3D * host,
                             bool create_faces,
                             const EFAElement3D * from_host,
                             unsigned int frag_id)
  : EFAFragment(), _host_elem(host)
{
  if (create_faces)
  {
    if (!from_host)
      EFAError("EFAfragment3D constructor must have a from_host to copy from");
    if (frag_id == std::numeric_limits<unsigned int>::max()) // copy the from_host itself
    {
      for (unsigned int i = 0; i < from_host->numFaces(); ++i)
        _faces.push_back(new EFAFace(*from_host->getFace(i)));
    }
    else
    {
      if (frag_id > from_host->numFragments() - 1)
        EFAError("In EFAfragment3D constructor fragment_copy_index out of bounds");
      for (unsigned int i = 0; i < from_host->getFragment(frag_id)->numFaces(); ++i)
        _faces.push_back(new EFAFace(*from_host->getFragmentFace(frag_id, i)));
    }
    findFacesAdjacentToFaces(); // IMPORTANT
  }
}
Beispiel #2
0
void
EFAFragment3D::combine_two_faces(unsigned int face_id1, unsigned int face_id2, const EFAFace* elem_face)
{
  // get the new full face
  EFAFace* full_face = _faces[face_id1]->combineWithFace(_faces[face_id2]);
  full_face->resetEdgeIntersection(elem_face); // IMPORTANT

  // take care of the common adjacent faces (combine their tip edges)
  std::set<EFAFace*> face1_neigh;
  face1_neigh.insert(_faces_adjacent_to_faces[face_id1].begin(), _faces_adjacent_to_faces[face_id1].end());
  std::set<EFAFace*> face2_neigh;
  face2_neigh.insert(_faces_adjacent_to_faces[face_id2].begin(), _faces_adjacent_to_faces[face_id2].end());
  std::vector<EFAFace*> common_adjacent_faces = Efa::getCommonElems(face1_neigh, face2_neigh);

  for (unsigned int i = 0; i < common_adjacent_faces.size(); ++i)
  {
    EFAFace* comm_face = common_adjacent_faces[i];
    if (comm_face != NULL)
    {
      unsigned int edge_id1 = comm_face->adjacentCommonEdge(_faces[face_id1]);
      unsigned int edge_id2 = comm_face->adjacentCommonEdge(_faces[face_id2]);
      comm_face->combineTwoEdges(edge_id1, edge_id2);
      comm_face->resetEdgeIntersection(elem_face); // IMPORTANT
    }
  }

  // delete old faces and update private members of EFAfragment3D
  delete _faces[face_id1];
  delete _faces[face_id2];
  _faces[face_id1] = full_face;
  _faces.erase(_faces.begin() + face_id2);
  findFacesAdjacentToFaces(); // rebuild _adjacent_face_ix: IMPORTANT
}