Skip to content

CGAL IO namespace#5677

Merged
lrineau merged 26 commits intoCGAL:masterfrom
sloriot:CGAL-IO_namespace
May 18, 2021
Merged

CGAL IO namespace#5677
lrineau merged 26 commits intoCGAL:masterfrom
sloriot:CGAL-IO_namespace

Conversation

@sloriot
Copy link
Copy Markdown
Member

@sloriot sloriot commented May 5, 2021

Move documented function/class in subdirectories CGAL/IO into the CGAL::IO namespace

Follow up of #4255

Comment on lines +348 to +389
template <typename Point>
bool read_OFF(std::istream& is,
Surface_mesh<Point>& sm)
{
return read_OFF(is, sm, parameters::all_default());
}
template <typename Point,
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF(const char* fname,
Surface_mesh<Point>& sm,
const CGAL_BGL_NP_CLASS& np)
{
std::ifstream in(fname);
return read_OFF(in, sm, np);
}

template <typename Point,
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF(const char* fname,
Surface_mesh<Point>& sm)
{
return read_OFF(fname, sm, parameters::all_default());
}


template <typename Point,
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF(std::string& fname,
Surface_mesh<Point>& sm,
const CGAL_BGL_NP_CLASS& np)
{
return read_OFF(fname.c_str(), sm, np);
}

template <typename Point,
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_OFF(std::string& fname,
Surface_mesh<Point>& sm)
{
return read_OFF(fname, sm, parameters::all_default());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be something really wrong with that API, if one needs to define so many overloads!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WELL, normally BGL would take care of all the extra and only the overload that's already here is necessary, but with the CGAL::IO:: namespace and this ADL problem we discussed, it seems that now, ALL OF THE OVERLOADS need to be defined, so yes, there is something really wrong.

Copy link
Copy Markdown
Member

@MaelRL MaelRL May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a conclusion on the "really wrong" aspect? (23be657 handles it and everything is figured out?)

Copy link
Copy Markdown
Member

@lrineau lrineau May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no conclusion. I am sorry if any of you two felt attacked by my comment. It was just a statement, without any proposed solution.

The issue seems to be a problem a double-dispatch, not with dynamic polymorphism but with templates. The main key of that double-dispatch is the face-graph type. So maybe the facing function templates in CGAL::IO:: could be generic for the first parameter:

template <typename Input, typename Face_graph>
bool read_OFF(Input&& input,
              Face_graph& graph);

template <typename Input, typename Point
bool read_OFF(Input&& input,
              Surface_mesh<Point>& graph);
              
// ...

and then, those function templates could dispatch again on the first parameter Input input calling functions in another namespace (CGAL::IO::internal::?)...

But I would recommend to refactor that way only for CGAL-5.4. That seems too late for CGAL-5.3. And anyway, the refactoring would be compatible with the API of CGAL-5.3.

... I am also surprised to see non-const references as parameter: std::string& fname. That seems to limit how users can call the function, and it should be fixed, in my opinion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I was just confused how moving namespaces across all functions could introduce such ADL issues that require these new overloads. But I haven't looked into it in detail (and so I was just wondering if the problem was already solved).

The string parameter should indeed be a const&.

@maxGimeno
Copy link
Copy Markdown
Contributor

write_vtu.h can not exist in the same directory of write_VTU.h in a windows platform.

@lrineau lrineau added the rm only: release blocker For the release team only: the next release requires this issue/PR to be solved/merge label May 10, 2021
@maxGimeno
Copy link
Copy Markdown
Contributor

@lrineau lrineau added rm only: ready for master For the release team only: that indicates that a PR is about to be merged in 'master' and removed Under Testing Ready to be tested labels May 18, 2021
@lrineau lrineau merged commit e0a4dd0 into CGAL:master May 18, 2021
@lrineau lrineau removed the rm only: ready for master For the release team only: that indicates that a PR is about to be merged in 'master' label May 19, 2021
@lrineau lrineau deleted the CGAL-IO_namespace branch May 19, 2021 07:24
lrineau added a commit to MaelRL/cgal that referenced this pull request Jun 2, 2021
@lrineau

This comment was marked as resolved.

@sloriot

This comment was marked as resolved.

@lrineau

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants