Subject: CGAL users discussion list
List archive
- From: "Laurent Rineau (CGAL/GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Re: Compiling Issues of CGAL
- Date: Tue, 15 Jan 2013 12:52:48 +0100
- Organization: GeometryFactory
Le lundi 14 janvier 2013 12:37:53 thedorkknight a écrit :
> Laurent - many thanks to you.
>
> i am still confused about the data type the points must be having. I am
> reading a .txt file in c++ then converting the individual lines which are
> strings to float variable type, which are saved in a vector, one vector for
> each dimension.I am getting an error feedback.
>
> all the examples in the documentation seem to be reading in a *.cin file.
> using fstream. so i assume that even those are strings. does CGAL convert
> these values to numbers?
I have the impression that you do not know the I/O functions of the C++
standard library. For example, the following program:
#include <iostream>
int main() {
double x;
std::cin >> x;
if(!std::cin) return 1; // exit with an error if the reading failed
std::cout << "The read value is: " << x << std::endl;
return 0;
}
read a 'double' from the standard input, and display the same value on the
standard output.
Most CGAL objects have support for I/O operations. For example:
#include <iostream>
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double>::Point_2 Point_2;
int main() {
Point_2 p;
std::cin >> p;
if(!std::cin) return 1;
std::cout << "The point is: " << p << std::endl;
return 0;
}
does the same for a 2D point. In that case, a valid input is:
-2.3 5
and then the read point is the 2D point (-2.3, 5.0).
--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory http://www.geometryfactory.com/
Release Manager of the CGAL Project http://www.cgal.org/
- [cgal-discuss] Re: Compiling Issues of CGAL, thedorkknight, 01/14/2013
- Re: [cgal-discuss] Re: Compiling Issues of CGAL, Laurent Rineau (CGAL/GeometryFactory), 01/14/2013
- [cgal-discuss] Re: Compiling Issues of CGAL, thedorkknight, 01/14/2013
- Re: [cgal-discuss] Re: Compiling Issues of CGAL, Laurent Rineau (CGAL/GeometryFactory), 01/15/2013
- [cgal-discuss] Re: Compiling Issues of CGAL, thedorkknight, 01/14/2013
- Re: [cgal-discuss] Re: Compiling Issues of CGAL, Laurent Rineau (CGAL/GeometryFactory), 01/14/2013
Archive powered by MHonArc 2.6.18.