mirror of https://github.com/CGAL/cgal
Fix is>>point_d
Now it matches what os<<point_d does at least.
This commit is contained in:
parent
f64ae1b240
commit
cfbb3ef977
|
|
@ -21,6 +21,7 @@
|
||||||
#define CGAL_WRAPPER_POINT_D_H
|
#define CGAL_WRAPPER_POINT_D_H
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <istream>
|
||||||
#include <CGAL/Origin.h>
|
#include <CGAL/Origin.h>
|
||||||
#include <CGAL/Kernel/mpl.h>
|
#include <CGAL/Kernel/mpl.h>
|
||||||
#include <CGAL/representation_tags.h>
|
#include <CGAL/representation_tags.h>
|
||||||
|
|
@ -246,8 +247,6 @@ public:
|
||||||
template <class R_> Point_d<R_>::Point_d(Point_d &)=default;
|
template <class R_> Point_d<R_>::Point_d(Point_d &)=default;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//TODO: IO
|
|
||||||
|
|
||||||
template <class R_>
|
template <class R_>
|
||||||
std::ostream& operator <<(std::ostream& os, const Point_d<R_>& p)
|
std::ostream& operator <<(std::ostream& os, const Point_d<R_>& p)
|
||||||
{
|
{
|
||||||
|
|
@ -269,26 +268,20 @@ std::ostream& operator <<(std::ostream& os, const Point_d<R_>& p)
|
||||||
// TODO: test if the stream is binary or text?
|
// TODO: test if the stream is binary or text?
|
||||||
template<typename K>
|
template<typename K>
|
||||||
std::istream &
|
std::istream &
|
||||||
operator>>(std::istream &is, typename Point_d<K> & p)
|
operator>>(std::istream &is, Point_d<K> & p)
|
||||||
{
|
{
|
||||||
typedef typename Point_d<K> P;
|
typedef Point_d<K> P;
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
std::vector<FT> coords;
|
int dim;
|
||||||
|
is >> dim;
|
||||||
|
if(!is) return is;
|
||||||
|
|
||||||
std::string line;
|
std::vector<FT> coords(dim);
|
||||||
for(;;)
|
for(int i=0;i<dim;++i)
|
||||||
{
|
is >> coords[i];
|
||||||
if (!std::getline(is, line))
|
|
||||||
return is;
|
|
||||||
if (line != "")
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
std::stringstream line_sstr(line);
|
|
||||||
FT temp;
|
|
||||||
while (line_sstr >> temp)
|
|
||||||
coords.push_back(temp);
|
|
||||||
|
|
||||||
p = P(coords.begin(), coords.end());
|
if(is)
|
||||||
|
p = P(coords.begin(), coords.end());
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -622,6 +622,9 @@ void test3(){
|
||||||
std::ostringstream output;
|
std::ostringstream output;
|
||||||
output << showit;
|
output << showit;
|
||||||
assert(output.str()=="3 1 2 4");
|
assert(output.str()=="3 1 2 4");
|
||||||
|
std::istringstream input("3 5 6 9");
|
||||||
|
input >> showit;
|
||||||
|
assert(ed(showit,cp(5,6,9)));
|
||||||
P t1[]={cp(1,2,3),cp(3,2,1),cp(2,4,2)};
|
P t1[]={cp(1,2,3),cp(3,2,1),cp(2,4,2)};
|
||||||
assert(sbds(t1+0,t1+2,cp(2,2,3.414)) == CGAL::ON_BOUNDED_SIDE);
|
assert(sbds(t1+0,t1+2,cp(2,2,3.414)) == CGAL::ON_BOUNDED_SIDE);
|
||||||
assert(sbds(t1+0,t1+2,cp(1,2,3)) == CGAL::ON_BOUNDARY);
|
assert(sbds(t1+0,t1+2,cp(1,2,3)) == CGAL::ON_BOUNDARY);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue