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 = bThat 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
This is a copy initialization. As
Pointis a class, and bothaandbare of typePoint, andbis not a prvalue, then the copy constructor ofPointis called to initializeawith a copy ofb.Direct initialization
Point a(b);This is a direct initilization.
Pointis a class and bothaandbare of typePoint, andbis not a prvalue, then the copy constructor ofPointis called to initializeawith a copy ofb.Conclusion
Point a = b; Point aa(b);For CGAL geometric objects, those two wa…