src/Geometry/clipFacetedVolumeByPlanes3d.cc
//------------------------------------------------------------------------------
// Return a formatted string with the current polyhedron.
//------------------------------------------------------------------------------
Return a formatted string with the current polyhedron.
Return a formatted string with the current polyhedron .
inline
string
poly2string(const vector<Dim<3>::Vector>& vertices,
            const vector<int>& vertexMask,
            const vector<pair<int, int>>& edges,
            const vector<vector<int>>& faces) {
  typedef Dim<3>::Vector Vector;
  ostringstream s;
  REQUIRE(vertices.size() == vertexMask.size());
  s << "Vertices: ";
  copy(vertices.begin(), vertices.end(), ostream_iterator<Vector>(s, " "));
  s << "\n"
    << "Vertex mask: ";
  copy(vertexMask.begin(), vertexMask.end(), ostream_iterator<int>(s, " "));
  s << "\n"
    << "Above vertices: ";
  for (auto i = 0; i < vertices.size(); ++i) {
    if (vertexMask[i] == 1) s << " ([" << i << "] " << vertices[i].x() << " " << vertices[i].y() << " " << vertices[i].z() << ")";
  }
  s << "\n"
    << "Below vertices: ";
  for (auto i = 0; i < vertices.size(); ++i) {
    if (vertexMask[i] == -1) s << " ([" << i << "] " << vertices[i].x() << " " << vertices[i].y() << " " << vertices[i].z() << ")";
  }
  s << "\n"
    << "In-plane vertices: ";
  for (auto i = 0; i < vertices.size(); ++i) {
    if (vertexMask[i] == 0) s << " ([" << i << "] " << vertices[i].x() << " " << vertices[i].y() << " " << vertices[i].z() << ")";
  }
  s << "\n"
    << "Inactive vertices: ";
  for (auto i = 0; i < vertices.size(); ++i) {
    if (vertexMask[i] == -2) s << " ([" << i << "] " << vertices[i].x() << " " << vertices[i].y() << " " << vertices[i].z() << ")";
  }
  s << "\n";
  for (auto iface = 0; iface < faces.size(); ++iface) {
    s << "Face " << iface << " : ";
    for (auto kedge = 0; kedge < faces[iface].size(); ++kedge) {
      const auto iedge = posID(faces[iface][kedge]);
      s <<  " ([" << faces[iface][kedge] << "->" << iedge << "] ";
      if (faces[iface][kedge] < 0) {
        s << edges[iedge].second << " " << edges[iedge].first << ")";;
      } else {
        s << edges[iedge].first << " " << edges[iedge].second << ")";
      }
    }
    s << "\n";
  }
  return s.str();
}
inline string poly2string ( const vector < Dim < 3 > :: Vector > & vertices , const vector < int > & vertexMask , const vector < pair < int , int > > & edges , const vector < vector < int > > & faces ) { typedef Dim < 3 > :: Vector Vector ; ostringstream s ; REQUIRE ( vertices . size ( ) == vertexMask . size ( ) ) ; s << " " ; copy ( vertices . begin ( ) , vertices . end ( ) , ostream_iterator < Vector > ( s , " " ) ) ; s << " \n " << " " ; copy ( vertexMask . begin ( ) , vertexMask . end ( ) , ostream_iterator < int > ( s , " " ) ) ; s << " \n " << " " ; for ( auto i = 0 ; i < vertices . size ( ) ; ++ i ) { if ( vertexMask [ i ] == 1 ) s << " " << i << " " << vertices [ i ] . x ( ) << " " << vertices [ i ] . y ( ) << " " << vertices [ i ] . z ( ) << " " ; } s << " \n " << " " ; for ( auto i = 0 ; i < vertices . size ( ) ; ++ i ) { if ( vertexMask [ i ] == -1 ) s << " " << i << " " << vertices [ i ] . x ( ) << " " << vertices [ i ] . y ( ) << " " << vertices [ i ] . z ( ) << " " ; } s << " \n " << " " ; for ( auto i = 0 ; i < vertices . size ( ) ; ++ i ) { if ( vertexMask [ i ] == 0 ) s << " " << i << " " << vertices [ i ] . x ( ) << " " << vertices [ i ] . y ( ) << " " << vertices [ i ] . z ( ) << " " ; } s << " \n " << " " ; for ( auto i = 0 ; i < vertices . size ( ) ; ++ i ) { if ( vertexMask [ i ] == -2 ) s << " " << i << " " << vertices [ i ] . x ( ) << " " << vertices [ i ] . y ( ) << " " << vertices [ i ] . z ( ) << " " ; } s << " \n " ; for ( auto iface = 0 ; iface < faces . size ( ) ; ++ iface ) { s << " " << iface << " " ; for ( auto kedge = 0 ; kedge < faces [ iface ] . size ( ) ; ++ kedge ) { const auto iedge = posID ( faces [ iface ] [ kedge ] ) ; s << " " << faces [ iface ] [ kedge ] << " " << iedge << " " ; if ( faces [ iface ] [ kedge ] < 0 ) { s << edges [ iedge ] . second << " " << edges [ iedge ] . first << " " ; ; } else { s << edges [ iedge ] . first << " " << edges [ iedge ] . second << " " ; } } s << " \n " ; } return s . str ( ) ; }
Return a formatted string with the current polyhedron.
Return a formatted string with the current polyhedron .