CGAL geometry kernel primitives #6006
-
Hi, I have very naive and simple question, but it pops out from time to time. How do you normally copy simple geometry kernels such point, line, segement, direction, plane? Is it enough to write: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
You question is a C++ question, and it is not specific to CGAL. All you have to know is that geometry kernel primitives are class templates, and they have copy constructors. Copy initializationPoint a = b; This is a copy initialization. As Direct initializationPoint a(b); This is a direct initilization. ConclusionPoint a = b;
Point aa(b); For CGAL geometric objects, those two ways of initialization are completely equivalent. Side-notePoint a;
a = b That is completely different: that is a value initialization (that class the default constructor) followed by a assignment (that calls the copy assignment operator of the class). |
Beta Was this translation helpful? Give feedback.
You question is a C++ question, and it is not specific to CGAL. All you have to know is that geometry kernel primitives are class templates, and they have copy constructors.
Copy initialization
Point a = b;
This is a copy initialization. As
Point
is a class, and botha
andb
are of typePoint
, andb
is not a prvalue, then the copy constructor ofPoint
is called to initializea
with a copy ofb
.Direct initialization
This is a direct initilization.
Point
is a class and botha
andb
are of typePoint
, andb
is not a prvalue, then the copy constructor ofPoint
is called to initializea
with a copy ofb
.Conclusion
For CGAL geometric objects, those two wa…