Laxkit
0.0.7.1
|
The basic coordinate class for points. More...
Public Member Functions | |
Coordinate () | |
Your basic constructor. | |
Coordinate (flatpoint p) | |
Constructor to make a vertex point at p. | |
Coordinate (double x, double y) | |
Constructor to make a vertex point at (x,y). | |
Coordinate (flatpoint pp, unsigned long nflags, SegmentControls *ctl) | |
Coordinate (double x, double y, unsigned long nflags, SegmentControls *ctl) | |
Constructor to make a vertex point at (x,y). Incs count of ctl. | |
Coordinate (const Coordinate &p) | |
Creates copy with next and prev equal to NULL. | |
virtual | ~Coordinate () |
Deletes both prev and next if they exist. | |
const Coordinate & | operator= (const Coordinate &p) |
virtual double | x () |
virtual void | x (double xx) |
virtual double | y () |
virtual void | y (double yy) |
virtual flatpoint | p () |
virtual void | p (double xx, double yy) |
virtual void | p (flatpoint pp) |
virtual int | isAttachedTo (Coordinate *v) |
Return 1 if this==v. Return 2 if is TOPREV of v, or -1 if is TONEXT of v. Else 0. | |
virtual int | isEndpoint () |
Return whether this is an endpoint, or is a handle connected to an endpoint. | |
virtual Coordinate * | previousVertex (int n=0) |
Find the previous vertex from this. | |
virtual Coordinate * | nextVertex (int n=0) |
Finds the next vertex after this. | |
virtual Coordinate * | firstPoint (int v=0) |
Return the most previous point in line, or this if line is closed. | |
virtual Coordinate * | lastPoint (int v=0) |
Return the most next point in open line, or this, if the line is a closed loop. | |
virtual int | hasCoord (Coordinate *co) |
Return 1 if co is somewhere in path, else 0. | |
virtual void | ShiftPoint (flatpoint p) |
virtual Coordinate * | duplicate () |
Sort of a workaround for copy constructor, copy point, flags, iid, info, but set next, prev to NULL. | |
virtual Coordinate * | duplicateAll () |
Return a complete copy of the path, SegmentControls and all. | |
virtual void | append (double x, double y, unsigned long flags=POINT_VERTEX, SegmentControls *ctl=NULL) |
Append a new vertex point (x,y) to the next NULL, with iid=0. | |
virtual void | close () |
Make this a closed loop if it is not already. | |
virtual int | isClosed () |
Return whether the coordinate is part of a closed path or not. | |
virtual void | connect (Coordinate *np, char after=1) |
This connects a SINGLE point np either after or before (after==0). | |
virtual Coordinate * | disconnect (char after=1) |
This severs the link between this and this->next (or prev if after=0) | |
virtual Coordinate * | detach () |
Removes this from the path. | |
virtual Coordinate * | detachThrough (Coordinate *p) |
Removes all points from this to and including p from the path, closing the connection of the remaining path. | |
virtual int | insert (Coordinate *c, int after=1) |
Insert point after *this (if after!=0) else before *this. | |
virtual int | NumPoints (int v) |
Return the number of individual points (v==0), or the number of vertices if v==1. | |
virtual flatpoint | direction (int after) |
Return a vector pointing in the visual direction the line seems to go in. |
Public Attributes | |
flatpoint | fp |
unsigned long | flags |
int | iid |
int | info |
SegmentControls * | controls |
Coordinate * | next |
Coordinate * | prev |
The basic coordinate class for points.
The point's actual values are wrapped in x(), y(), and p(). This will help out making coordinate references later on.. Many of the functions in here must be called with care, lest memory leaks occur. PathInterface takes, or at least ought to be taking, the appropriate precautions.
Here are the defines for flags:
LaxInterfaces::Coordinate::Coordinate | ( | flatpoint | pp, |
unsigned long | nflags, | ||
SegmentControls * | ctl | ||
) |
Incs count of ctl.
References Laxkit::anObject::inc_count().
LaxInterfaces::Coordinate::Coordinate | ( | const Coordinate & | p | ) |
Creates copy with next and prev equal to NULL.
This will result in count of this->controls being incremented by 1.
References Laxkit::anObject::inc_count().
|
virtual |
Deletes both prev and next if they exist.
Assumes simple connections to other nodes, Care taken here to destroy loops of unknown size, meaning that if this point is connected to a loop, the whole loop is deleted properly, without segfaulting.
|
virtual |
Append a new vertex point (x,y) to the next NULL, with iid=0.
Puts the point in the next most NULL. If this is a closed loop, then puts in this->next. It does not check for consistency with controls...
This function is for convenience of making simple lines on the fly. If ctl!=NULL, then its count is incremented.
References Laxkit::anObject::inc_count().
|
virtual |
This connects a SINGLE point np either after or before (after==0).
Assumes that np->next==np->prev==NULL. To insert a string of points, use insert().
This function only concerns itself with the immediately next connection. It does not check for consistency with control points. That is the duty of PathInterface. It does not scan down the line. It assumes that the relevant next/prevs are of this and of np are all NULL. It does not do error checking.
Referenced by LaxInterfaces::PathInterface::CutNear(), and LaxInterfaces::MeasureInterface::LBDown().
|
virtual |
Removes this from the path.
This completely removes *this from the line by setting next=prev=NULL, and next->prev=next, and prev->next=next if next and/or prev exist.
Returns a coordinate that is on the remaining path, if any.
This function would only be called by PathInterface, PathsData, or Path, which take the necessary precautions to ensure that no path heads are screwed up.
Referenced by LaxInterfaces::PathInterface::removeSegment().
|
virtual |
Removes all points from this to and including p from the path, closing the connection of the remaining path.
This completely removes the points from the line by setting next=prev=NULL, and next->prev=next, and prev->next=next if next and/or prev exist. p is assumed to be in the next direction from this.
Returns a coordinate that is on the remaining path, if any. If this was on a closed path, then the segment this..p will now be open.
This function would only be called by PathInterface, PathsData, or Path, which take the necessary precautions to ensure that no path heads are screwed up.
Referenced by LaxInterfaces::PathInterface::DeletePoint().
Return a vector pointing in the visual direction the line seems to go in.
Note this is different than a tangent. If prev or next points are attached, then use those, but if there is a null tangent, then the numerical tangent will be 0. In this case, assume bezier points, and calculate the visual direction. If we are on a terminator, then grab the tangent from the non-null side.
A unit vector will always be returned. Default on not possible is (1,0).
References Laxkit::bez_point(), and norm().
Referenced by LaxInterfaces::PathInterface::MouseMove(), LaxInterfaces::Path::PointAlongPath(), LaxInterfaces::PathInterface::SetCurvertex(), and LaxInterfaces::PathInterface::UpdateDir().
|
virtual |
This severs the link between this and this->next (or prev if after=0)
This function should only be called by PathInterface, PathsData, or Path, which take the necessary precautions.
Returns pointer to the coordinate on the other side of the break, if any.
|
virtual |
Sort of a workaround for copy constructor, copy point, flags, iid, info, but set next, prev to NULL.
I might simply not understand copy constructors, but this function exists in case there are points that are supposed to be accessed and set the same as a normal Coordinate, but the internals are worked around somehow. Normal copy constructors do not afford such flexiblity.
controls count will end up being incremented by 1.
|
virtual |
Return the most previous point in line, or this if line is closed.
If v!=0, find the first vertex. If there is no first vertex (path is all control points) returns the first point (or this if closed loop). firstPoint will never return NULL.
References nextVertex().
Referenced by LaxInterfaces::PathInterface::AddPoint(), LaxInterfaces::Path::ClosestPoint(), LaxInterfaces::Path::distance_to_t(), LaxInterfaces::Path::fixpath(), insert(), LaxInterfaces::Path::Intersect(), LaxInterfaces::Path::Length(), LaxInterfaces::PathInterface::MergeEndpoints(), LaxInterfaces::Path::PointAlongPath(), LaxInterfaces::PathInterface::Refresh(), LaxInterfaces::Path::Reverse(), LaxInterfaces::PathInterface::scan(), and LaxInterfaces::Path::t_to_distance().
|
virtual |
Return 1 if co is somewhere in path, else 0.
See also PathsData::hasCoord().
Referenced by LaxInterfaces::PathInterface::DeletePoint().
|
virtual |
Insert point after *this (if after!=0) else before *this.
Assumes that c is the most previous point in a list of one or more points, that is open or closed. Also assumes that the segment is sectioned correctly, that is, it does not sever control segments. PathInterface is supposed to check for that. Returns 1 on success.
References firstPoint(), and lastPoint().
Referenced by LaxInterfaces::PathInterface::AddPoint(), LaxInterfaces::Path::append(), and LaxInterfaces::PathInterface::CutNear().
|
virtual |
Return whether this is an endpoint, or is a handle connected to an endpoint.
If this is a handle, return 2 if it is a TOPREV and there is no next vertex, or -2 if is a TONEXT and there is no previous vertex.
If this is a vertex, return 1 if there is no next vertex, or -1 if there is no previous vertex.
Else return 0.
Referenced by LaxInterfaces::PathInterface::LBDown(), LaxInterfaces::PathInterface::MergeEndpoints(), and LaxInterfaces::PathInterface::MouseMove().
|
virtual |
Return the most next point in open line, or this, if the line is a closed loop.
If v!=0, find the last vertex. If there is no last vertex (path is all control points) returns the last point (or this if closed loop). lastPoint will never return NULL.
References previousVertex().
Referenced by LaxInterfaces::Path::append(), LaxInterfaces::Path::dump_in_atts(), LaxInterfaces::Path::dump_out(), insert(), LaxInterfaces::Path::lastPoint(), LaxInterfaces::PathInterface::MergeEndpoints(), and LaxInterfaces::Path::PointAlongPath().
|
virtual |
Finds the next vertex after this.
Returns next vertex starting AFTER this, if n==0.
Returns next vertex starting WITH this, if n==1.
returns NULL if there is no such next vertex.
Referenced by LaxInterfaces::PathInterface::AddPoint(), LaxInterfaces::PathsData::FindBBox(), firstPoint(), LaxInterfaces::PathsData::GetCoordinate(), and LaxInterfaces::PathInterface::scan().
const Coordinate & LaxInterfaces::Coordinate::operator= | ( | const Coordinate & | p | ) |
Does not modify next and prev. Everything else is copied over. controls count will end up being incremented by 1.
References Laxkit::anObject::inc_count().
|
virtual |
Find the previous vertex from this.
Returns previous vertex starting BEFORE this, if n==0.
Returns previous vertex starting WITH this, if n==1.
Returns NULL if can't find any previous vertex.
Referenced by lastPoint().