mirror of https://github.com/CGAL/cgal
WIP
This commit is contained in:
parent
e269931284
commit
80e39d13f9
|
|
@ -125,7 +125,8 @@ public:
|
||||||
\ingroup PkgBGLIOFct
|
\ingroup PkgBGLIOFct
|
||||||
|
|
||||||
reads the graph `g` from data in the TS format.
|
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
|
\pre The data must represent a 2-manifold
|
||||||
|
|
||||||
|
|
@ -135,8 +136,7 @@ public:
|
||||||
*/
|
*/
|
||||||
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||||
bool read_GOCAD(std::istream& in,
|
bool read_GOCAD(std::istream& in,
|
||||||
std::string& name,
|
std::pair<std::string, std::string>& name_and_color,
|
||||||
std::string& color,
|
|
||||||
FaceGraph& g,
|
FaceGraph& g,
|
||||||
const CGAL_BGL_NP_CLASS& np)
|
const CGAL_BGL_NP_CLASS& np)
|
||||||
{
|
{
|
||||||
|
|
@ -147,19 +147,28 @@ bool read_GOCAD(std::istream& in,
|
||||||
if(!builder(g, np))
|
if(!builder(g, np))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
name = builder.name;
|
name_and_color.first = builder.name;
|
||||||
color = builder.color;
|
name_and_color.second = builder.color;
|
||||||
|
|
||||||
return is_valid(g); // @fixme keep validity check?
|
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>
|
template <typename FaceGraph>
|
||||||
bool read_GOCAD(std::istream& in,
|
bool read_GOCAD(std::istream& in,
|
||||||
std::string& name,
|
std::pair<std::string, std::string>& name_and_color,
|
||||||
std::string& color,
|
|
||||||
FaceGraph& g)
|
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
|
writes the graph `g` in the TS format into `os`. `fname` is the
|
||||||
mandatory name that will be assigned to `g`in the file.
|
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
|
\see \ref IOStreamGocad
|
||||||
*/
|
*/
|
||||||
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
template <typename FaceGraph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include <vtkCell.h>
|
#include <vtkCell.h>
|
||||||
#include <vtkXMLPolyDataReader.h>
|
#include <vtkXMLPolyDataReader.h>
|
||||||
#include <vtkPointSet.h>
|
#include <vtkPointSet.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
@ -50,7 +51,7 @@ bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data,
|
||||||
using parameters::choose_parameter;
|
using parameters::choose_parameter;
|
||||||
|
|
||||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
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_points = poly_data->GetNumberOfPoints();
|
||||||
vtkIdType nb_cells = poly_data->GetNumberOfCells();
|
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> obs =
|
||||||
vtkSmartPointer<IO::internal::ErrorObserverVtk>::New();
|
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);
|
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>::vertex_descriptor vertex_descriptor;
|
||||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||||
|
|
||||||
typedef typename CGAL::GetInitializedVertexIndexMap<Mesh, NamedParameters>::const_type Vimap;
|
typedef typename CGAL::GetInitializedVertexIndexMap<FaceGraph, NamedParameters>::const_type Vimap;
|
||||||
Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np);
|
Vimap V = CGAL::get_initialized_vertex_index_map(g, np);
|
||||||
|
|
||||||
std::vector<std::size_t> connectivity_table;
|
std::vector<std::size_t> connectivity_table;
|
||||||
std::vector<std::size_t> offsets;
|
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>::vertex_descriptor vertex_descriptor;
|
||||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||||
|
|
||||||
typedef typename CGAL::GetInitializedVertexIndexMap<Mesh, NamedParameters>::const_type Vimap;
|
typedef typename CGAL::GetInitializedVertexIndexMap<FaceGraph, NamedParameters>::const_type Vimap;
|
||||||
Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np);
|
Vimap V = CGAL::get_initialized_vertex_index_map(g, np);
|
||||||
|
|
||||||
std::string formatattribute = binary ? " format=\"appended\"" : " format=\"ascii\"";
|
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_USE_VTK
|
||||||
|
|
||||||
#endif // CGAL_BGL_IO_VTK_H
|
#endif // CGAL_BGL_IO_VTK_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,13 +134,13 @@ bool test_gocad()
|
||||||
}
|
}
|
||||||
FaceGraph fg2;
|
FaceGraph fg2;
|
||||||
std::istringstream in( out.str());
|
std::istringstream in( out.str());
|
||||||
std::string name, color;
|
std::pair<std::string, std::string> cnn;
|
||||||
CGAL::read_GOCAD(in, name, color, fg2);
|
CGAL::read_GOCAD(in, cnn, fg2);
|
||||||
if(name != "tetrahedron"){
|
if(cnn.first != "tetrahedron"){
|
||||||
std::cerr<<"reading error: tetrahedron != "<<name<<std::endl;
|
std::cerr<<"reading error: tetrahedron != "<<cnn.first<<std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if( !color.empty()){
|
if( !cnn.second.empty()){
|
||||||
std::cerr<<"reading error: there should be no color."<<std::endl;
|
std::cerr<<"reading error: there should be no color."<<std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ bool read_OFF(const char* fname,
|
||||||
std::ifstream in(fname);
|
std::ifstream in(fname);
|
||||||
return read_OFF(in, points, polygons, np);
|
return read_OFF(in, points, polygons, np);
|
||||||
}
|
}
|
||||||
|
//todo doc this too
|
||||||
template <typename PointRange, typename PolygonRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
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)
|
bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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>
|
template <typename PointRange, typename TriangleRange, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||||
bool read_STL(const char* fname,
|
bool read_STL(const char* fname,
|
||||||
PointRange& points,
|
PointRange& points,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue