Search code examples
arrayspointcgal

cgal + array of points


I know that in CGAL we can have access to elements of Point_2 in the following way:

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
Point_2 points(1.0,1.0);

int main(){
std::cout<<points.x()<<"\t"<<points.y();
return 0;}

but how can I do this for an array of points:

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef std::vector<Point_2> Vector;

Vector points;
points.reserve(N);

int main(){
points[0].x() =1;
points[0].y() =1;
return 0;}

points[i].x() or points[i].x produces error.


Solution

  • As the friend mentioned in the commentary, you can do:

        int main(){
    
            points.push_back(Point_2(1.0,1.0));
            return 0;
    
        }