This commit is contained in:
Maxime Gimeno 2020-04-20 16:09:50 +02:00
parent e269931284
commit 80e39d13f9
5 changed files with 39 additions and 20 deletions

View File

@ -125,7 +125,8 @@ public:
\ingroup PkgBGLIOFct
reads the graph `g` from data in the TS format.
`name` and `color` will be filled according to the values contained in the file.
`name_and_color` is an optionnal argument, containing the
values specified in the file.
\pre The data must represent a 2-manifold
@ -135,8 +136,7 @@ public:
*/
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(std::istream& in,
std::string& name,
std::string& color,
std::pair<std::string, std::string>& name_and_color,
FaceGraph& g,
const CGAL_BGL_NP_CLASS& np)
{
@ -147,19 +147,28 @@ bool read_GOCAD(std::istream& in,
if(!builder(g, np))
return false;
name = builder.name;
color = builder.color;
name_and_color.first = builder.name;
name_and_color.second = builder.color;
return is_valid(g); // @fixme keep validity check?
}
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_GOCAD(std::istream& in,
FaceGraph& g,
const CGAL_BGL_NP_CLASS& np)
{
std::pair<std::string, std::string> dummy;
return read_GOCAD(in, dummy,g, np);
}
template <typename FaceGraph>
bool read_GOCAD(std::istream& in,
std::string& name,
std::string& color,
std::pair<std::string, std::string>& name_and_color,
FaceGraph& g)
{
return read_GOCAD(in, name, color, g, parameters::all_default());
return read_GOCAD(in, name_and_color, g, parameters::all_default());
}
/*!
@ -206,6 +215,13 @@ bool read_GOCAD(const std::string& fname, FaceGraph& g) { return read_GOCAD(fnam
writes the graph `g` in the TS format into `os`. `fname` is the
mandatory name that will be assigned to `g`in the file.
\cgalNamedParamsBegin
\cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `g`.
If this parameter is omitted, an internal property map for
`CGAL::vertex_point_t` should be available in `FaceGraph`
\cgalParamEnd
\cgalNamedParamsEnd
\see \ref IOStreamGocad
*/
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>

View File

@ -24,6 +24,7 @@
#include <vtkCell.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkPointSet.h>
#include <vtkPolyData.h>
namespace CGAL {
@ -50,7 +51,7 @@ bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data,
using parameters::choose_parameter;
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_const_property_map(CGAL::vertex_point, g));
get_property_map(CGAL::vertex_point, g));
vtkIdType nb_points = poly_data->GetNumberOfPoints();
vtkIdType nb_cells = poly_data->GetNumberOfCells();
@ -122,7 +123,7 @@ bool read_VTP(const char* fname, FaceGraph& g, const NamedParameters& np)
vtkSmartPointer<IO::internal::ErrorObserverVtk> obs =
vtkSmartPointer<IO::internal::ErrorObserverVtk>::New();
data = IO::internal::read_vtk_file<vtkXMLPolyDataReader>(fname, obs)->GetOutput();
data = vtkPolyData::SafeDownCast(IO::internal::read_vtk_file<vtkXMLPolyDataReader>(fname, obs)->GetOutput());
return IO::internal::vtkPointSet_to_polygon_mesh(data, g, np);
}
@ -178,8 +179,8 @@ void write_polys(std::ostream& os,
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
typedef typename CGAL::GetInitializedVertexIndexMap<Mesh, NamedParameters>::const_type Vimap;
Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np);
typedef typename CGAL::GetInitializedVertexIndexMap<FaceGraph, NamedParameters>::const_type Vimap;
Vimap V = CGAL::get_initialized_vertex_index_map(g, np);
std::vector<std::size_t> connectivity_table;
std::vector<std::size_t> offsets;
@ -211,8 +212,8 @@ void write_polys_tag(std::ostream& os,
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
typedef typename CGAL::GetInitializedVertexIndexMap<Mesh, NamedParameters>::const_type Vimap;
Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np);
typedef typename CGAL::GetInitializedVertexIndexMap<FaceGraph, NamedParameters>::const_type Vimap;
Vimap V = CGAL::get_initialized_vertex_index_map(g, np);
std::string formatattribute = binary ? " format=\"appended\"" : " format=\"ascii\"";
@ -452,3 +453,4 @@ void write_VTP(std::ostream& os, const FaceGraph& g)
#endif // CGAL_USE_VTK
#endif // CGAL_BGL_IO_VTK_H

View File

@ -134,13 +134,13 @@ bool test_gocad()
}
FaceGraph fg2;
std::istringstream in( out.str());
std::string name, color;
CGAL::read_GOCAD(in, name, color, fg2);
if(name != "tetrahedron"){
std::cerr<<"reading error: tetrahedron != "<<name<<std::endl;
std::pair<std::string, std::string> cnn;
CGAL::read_GOCAD(in, cnn, fg2);
if(cnn.first != "tetrahedron"){
std::cerr<<"reading error: tetrahedron != "<<cnn.first<<std::endl;
return 1;
}
if( !color.empty()){
if( !cnn.second.empty()){
std::cerr<<"reading error: there should be no color."<<std::endl;
return 1;
}

View File

@ -185,7 +185,7 @@ bool read_OFF(const char* fname,
std::ifstream in(fname);
return read_OFF(in, points, polygons, np);
}
//todo doc this too
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np)
{

View File

@ -120,6 +120,7 @@ bool read_STL(std::istream& is,
}
}
//todo doc this too
template <typename PointRange, typename TriangleRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_STL(const char* fname,
PointRange& points,