Node:Path Constructors and Setting Functions, Next:Path Destructor, Previous:Path Data Members, Up:Path Reference
void Path (void) | Default constructor |
Creates an empty Path with no
Points and no connectors.
|
void Path (const Point& p0, const Point& p1) | Constructor |
Creates a line (more precisely, a line segment) between p0
and p1. The single
connector between the two Points is set to "--" and the
data member line_switch (of type bool ) is set to
true . There are certain operations on Paths that are only
applicable to lines, so it's necessary to store the information that a
Path is a line.1
Point A(-2, -2.5, -1); Point B(3, 2, 2.5) Path p(A, B); p.show("p:"); -| p: (-2, -2.5, -1) -- (3, 2, 2.5);
|
void set (const Point& p0, const Point& p1) | Setting function |
Corresponds to the constructor above.
Point P0(1, 2, 3); Point P1(3.5, -12, 75); Path q; q.set(P0, P1); q.show("q:"); -| q: (1, 2, 3) -- (3.5, -12, 75); |
void Path (string connector, bool cycle, Point* p, [...], 0) | Constructor |
For Paths with an arbitrary number of Points
and one type of connector.
connector is passed unchanged to cycle indicates whether the p is a pointer to the first It is admittedly a bit
awkward to have to type " Point P0; Point P1(2); Point P2(2,2); Point P3(0,2); Path p("..", true, &P0, &P1, &P2, &P3, 0); p.draw();
|
void set (string connector, bool cycle, Point* p, [...], 0) | Setting function |
Corresponds to the constructor above.
Point P[4]; P[0].set(2, 1, 3); P[3] = P[2] = P[1] = P[0]; P[3] *= P[2] *= P[1].rotate(3, 12, 18); P[3] *= P[2].shift(-2, -1, 3); P[3].shear(1.5, .5, 3.5); Path q("...", false, &P[0], &P[1], &P[2], &P[3], 0); q.show("q:"); -| q: (2, 1, 3) ... (0.92139, 1.51449, 3.29505) ... (-1.07861, 0.514487, 6.29505) ... (2.84065, -3.26065, 6.29505);
|
void Path (Point* first_point_ptr, char* s, Point* p, [...], 0) | Constructor |
Constructor for Paths with an arbitrary number of Points
and connectors. The first, required, argument is a pointer to a
Point , followed by pointers to char alternating with pointers to
Points .3
The last argument must be 0, i.e., the null pointer.
There is no need to indicate by means of an argument whether the
Point A; Point B(2, 0); Point C(3, 2); Point D(1, 3); Path p(&A, "..", &B, "..", &C, "--", &D, "...", 0);
|
void set (Point *first_point_ptr, string s, Point *p, [...], 0) | Setting function |
Corresponds to the constructor above. |
void Path (const Path& p) | Copy constructor |
Creates a new Path , making it a copy of p.
|
Path* create_new<Path> (const Path* p) | Template specializations |
Path* create_new<Path> (const Path& p) |
Pseudo-constructors for dynamic allocation of Paths .
They create a Path on the free store and allocate memory for it using
new(Path) . They return a pointer to the new Path .
If p is a non-zero pointer or a reference,
the new
|
It isn't sufficient to check whether a
Path
consists of only two Points
to determine whether it
is a line or not, since a connector with ``curl
'' could cause it
to be non-linear. On the other hand, Paths
containing only
colinear Points
and the connector "--"
are perfectly
legitimate lines. I'm in the process of changing all of the code that
tests for linearity by checking the value of line_switch
, so that
it uses is_linear()
instead. When I've done this, it may be
possible to eliminate line_switch
.
See Path Reference; Data Members, and
Path Reference; Querying.
Stroustrup, The C++ Programming Language, p. 88.
Where possible, I prefer to use the C++
data
type string
rather than char*
, however it was necessary to
use char*
here because 0 is not a valid string
, even
though string
may be implemented as char*
,
and 0 must be a valid argument, since it is needed to indicate the end
of the argument list.