Aimsun Next Scripting
22
|
Public Types | |
enum | GKPointsCompressType { eStart , eEnd , eBoth } |
Public Member Functions | |
GKPoints () | |
GKCoord | length2D (bool closed=false) const |
GKCoord | length3D (bool closed=false) const |
GKCoord | length2DFromPointToPoint (int pointIni, int pointEnd) const |
GKPoints | leftOf (double distance) const |
GKPoints | rightOf (double distance) const |
void | cut (double distance, GKPoints &leftPart, GKPoints &rightPart) const |
void | cut (const GKPoint &p, GKPoints &leftPart, GKPoints &rightPart) const |
int | add (double offsetPercent) |
void | cutIn3 (GKCoord distanceIni, GKCoord distanceEnd, GKPoints &leftPart, GKPoints &midPart, GKPoints &rightPart) const |
GKCoord | getAltitude () const |
void | setAltitude (GKCoord value) |
bool | contains2D (const GKPoint &point, double epsilon=0.01, bool checkEdges=false) const |
bool | contains3D (const GKPoint &point, double epsilon=0.01) const |
bool | intersects2D (const GKPoints &poli2, bool includeVertexs=true, bool closed=true, GKPoint *resPoint=NULL) const |
bool | intersects2D (const GKPoint &from, const GKPoint &to, GKPoint *resPoint=NULL, bool considerThisAsClosed=false, bool includeVertexs=true) const |
GKPoints | allIntersections (const GKPoint &from, const GKPoint &to, bool closed) const |
QVector< GKPoints > | polygonIntersection (const GKPoints &secondPoints) const |
QVector< GKPoints > | polylineIntersection (const GKPoints &secondPoints) const |
void | translate (const GKPoint &delta) |
void | rotate (const GKPoint ¢er, double angle) |
void | scale (const GKPoint &scale) |
int | onPolyline (const GKPoint &point, double epsilon, bool closed=false) const |
GKPoints | getParallelPolyline (GK::RoadSide side, double distance) const |
GKPoints | getParallelPolylineExtended (GK::RoadSide side, double distance, double extendedLength) const |
GKPoints | getPolylineOnPolyline (double from, double to) const |
GKPoints | getConvexHull () const |
double | angleToPoints (const GKPoints &pointsTo) const |
double | angleBetweenLines (const GKPoint &p1, const GKPoint &p2, const GKPoint &p3, const GKPoint &p4) const |
void | simplifyPolyline (double distance=0.00001) |
GKPoint | pointAtPos (double pos, bool closed=false) const |
double | posAtPoint (const GKPoint &p, GKCoord maxDistToPoints=0.01, bool closed=false) const |
int | segmentAtPos (GKCoord pos, bool closed=false, double *length=NULL) const |
GKPoint | center () const |
GKPoint | centroid () const |
void | calculateBezier (GKPoints &bezier, uint nbmaxpoints=0, bool simplify=true) const |
GKCoord | calculateBezierLength2D (uint nbmaxpoints=0) const |
GKCoord | calculateBezierLength3D (uint nbmaxpoints=0) const |
GKPoints | compress (GKCoord sizeToReduce, GKPointsCompressType type) const |
GKPoints | expand (GKCoord extraSize, GKPointsCompressType type) const |
void | add (const GKPoints &points2) |
void | order () |
double | getParallelPosAtDist (double pos, GK::RoadSide side, double distance) const |
bool | isPointAtRightArea (const GKPoint &p) const |
double | getArea () const |
GKCoord | getSlope (int segmentPos) const |
GKCoord | getSlope (int pointPos1, int pointPos2) const |
bool | hasSlope () const |
GKCoord | distToPoint2D (const GKPoint &p) const |
void | reverse () |
int | __len__ () |
End GKPoint * | operator[] (int) |
if ((a0=sipConvertFromSequenceIndex(a0, len))< 0) | |
End void | append (const GKPoint &p) |
Public Attributes | |
MethodCode | sipRes = sipCpp->size() |
MethodCode int | len |
len = sipCpp ->size() | |
else | |
MethodCode sipCpp append * | a0 |
Static Public Attributes | |
static uint | gkDefaultBezierPoints |
static double | gkDefaultBezierPointsEpsilon |
This Vector of GKPoints adds methods to the collection of points that operates all over points. These methods are oriented to the collection of points not to a single point.
GKPoints::GKPoints | ( | ) |
int GKPoints::__len__ | ( | ) |
void GKPoints::add | ( | const GKPoints & | points2 | ) |
This function returns a new polygon constructed adding points2 to this. This function mix the points from both polygons adding each point in order taken into account the angle that the line center-point makes with the horizontal. The current polygon (or set of points) is modified.
int GKPoints::add | ( | double | offsetPercent | ) |
Adds a new point to this polyline at distance offsetPercent * length2D from the beginning. Returns the new point position. If offsetPercent <= 0.0 or offsetPercent >= 1.0 or polyline.size() < 2, it returns -1.
Returns all the intersections of the line [from,to] with this object. If closed is true the this object is interpreted as a Polygon, if not as a Polyline
double GKPoints::angleBetweenLines | ( | const GKPoint & | p1, |
const GKPoint & | p2, | ||
const GKPoint & | p3, | ||
const GKPoint & | p4 | ||
) | const |
It returns the angle between the lines (from p1 to p2) and (from p3 to p4) in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first line to the second one the direction is counterclockwise. If the lines are parallel lines it returns 0.0
double GKPoints::angleToPoints | ( | const GKPoints & | pointsTo | ) | const |
It returns the angle between the two last points of this object and the two first points in 'pointsTo' in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first line to the second one the direction is counterclockwise. If the lines are parallel lines it returns 0.0
End void GKPoints::append | ( | const GKPoint & | p | ) |
void GKPoints::calculateBezier | ( | GKPoints & | bezier, |
uint | nbmaxpoints = 0 , |
||
bool | simplify = true |
||
) | const |
Calculates a polyline that represents a bezier curve with "this" as control points of the bezier curve. The result is stored in bezier. The bezier will have as much points as nbmaxpoints. The bezier will be simplified if simplify is true and then using epsilon as the minimum distance allowed between points not to be discarded.
if nbmaxpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
GKCoord GKPoints::calculateBezierLength2D | ( | uint | nbmaxpoints = 0 | ) | const |
Calculates the length 2D of the polyline that represents a bezier curve with "this" as control points of the bezier curve Equivaled, but faster than, to:
if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
GKCoord GKPoints::calculateBezierLength3D | ( | uint | nbmaxpoints = 0 | ) | const |
Calculates the length 3D of the polyline that represents a bezier curve with "this" as control points of the bezier curve Equivaled, but faster than, to:
if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
GKPoint GKPoints::center | ( | ) | const |
Returns the center of this closed polygon.
GKPoint GKPoints::centroid | ( | ) | const |
Returns the centroid of this closed polygon.
GKPoints GKPoints::compress | ( | GKCoord | sizeToReduce, |
GKPointsCompressType | type | ||
) | const |
Returns a compressed version of this polyline (this method doesn't works on polygons). It reduce the length of the polyline in "sizeToReduce" m. The reduction on each segment is proportional to each segment length.
The reduction type can be:
bool GKPoints::contains2D | ( | const GKPoint & | point, |
double | epsilon = 0.01 , |
||
bool | checkEdges = false |
||
) | const |
If this GKPoints is a polygon (it's closed), returns true if p is inside it.
bool GKPoints::contains3D | ( | const GKPoint & | point, |
double | epsilon = 0.01 |
||
) | const |
If this GKPoints is a polygon (it's closed), returns true if p is inside it in 3D.
Calculates the left and right part of this polyline based on a cut point. LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point p, R: right part).
The cut point (p) will be part of left and right parts.
Calculates the left and right part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.
If distance is negative then distance = this->length2D() + distance.
void GKPoints::cutIn3 | ( | GKCoord | distanceIni, |
GKCoord | distanceEnd, | ||
GKPoints & | leftPart, | ||
GKPoints & | midPart, | ||
GKPoints & | rightPart | ||
) | const |
Calculates the left, middle and right part of this polyline based on two distances (the beginning of the polysection is at a distance 0.0). Both distances are from the beginning of the polyline: LLLLLLL/MM\RRRRRRR (L: left part, /:point at distanceIni, M: Middle part, \:point at distanceEnd (>distanceIni) R: right part). The cut points (at distanceIni and distanceEnd) will be part of both parts.
If distance is negative then distance = this->length2D() + distance.
GKCoord GKPoints::distToPoint2D | ( | const GKPoint & | p | ) | const |
Returns the minimum distance from any point of the group of points to the point p
GKPoints GKPoints::expand | ( | GKCoord | extraSize, |
GKPointsCompressType | type | ||
) | const |
Returns a expanded version of this polyline (this method doesn't works on polygons). It expand the length of the polyline in "extraSize" m.
The expand type can be:
GKCoord GKPoints::getAltitude | ( | ) | const |
Returns the lower Z of any point of this polyline.
double GKPoints::getArea | ( | ) | const |
Returns the area of the polygon described by this array of points. Assumes points are all at z = 0.
GKPoints GKPoints::getConvexHull | ( | ) | const |
Gets the convexhull of the collection of points
GKPoints GKPoints::getParallelPolyline | ( | GK::RoadSide | side, |
double | distance | ||
) | const |
Returns a parallel polyline to this at a distance "distance" on the specified side
GKPoints GKPoints::getParallelPolylineExtended | ( | GK::RoadSide | side, |
double | distance, | ||
double | extendedLength | ||
) | const |
Returns a parallel polyline to this at a distance "distance" on the specified side (side = 1 LEFT, side = 0 RIGHT) and with an extra segment at the beginning and at the end of extendedLength
double GKPoints::getParallelPosAtDist | ( | double | pos, |
GK::RoadSide | side, | ||
double | distance | ||
) | const |
Returns the position in the parallel polyline to this at a distance "distance" on the specified side of the point perpendicular to the one located at pos in this polyline.
GKPoints GKPoints::getPolylineOnPolyline | ( | double | from, |
double | to | ||
) | const |
Founds the polyline over this polyline that starts at a distance of "from" from the beginning of the "polyline" and ends at a distance of "to" again from the beginning of the "polyline"
GKCoord GKPoints::getSlope | ( | int | pointPos1, |
int | pointPos2 | ||
) | const |
It returns the slope for the segment definet by 'pointPos1' and 'pointPos2'. Warming: Position must exist or crash.
GKCoord GKPoints::getSlope | ( | int | segmentPos | ) | const |
It returns the slope for the segment 'segmentPos' that is, between point at 'segmentPos' and point at 'segmentPos+1'
bool GKPoints::hasSlope | ( | ) | const |
It returns true if at least two point are at a different height. It returns false if all the points are at the same height.
|
inline |
bool GKPoints::intersects2D | ( | const GKPoint & | from, |
const GKPoint & | to, | ||
GKPoint * | resPoint = NULL , |
||
bool | considerThisAsClosed = false , |
||
bool | includeVertexs = true |
||
) | const |
Returns true if the line [from,to] intersects this object. The intersection point is returned in resPoint if resPoint is not None (so it's a pointer to a valid GKPoint). It considerThisAsClosed is true then the segment between the last point and the first one is also considered. includeVertexs variable indicates if intersections on the vertexs have to be taken into account or not.
bool GKPoints::intersects2D | ( | const GKPoints & | poli2, |
bool | includeVertexs = true , |
||
bool | closed = true , |
||
GKPoint * | resPoint = NULL |
||
) | const |
Returns true if poli2 (polygon if closed = true or polyline if closed = false ) intersects with this object. If this object and poly2 have only vertexs in commom it will return true if include vertexs is true and false if includeVertexs is false. The intersection point is returned in resPoint if resPoint is not None (so it's a pointer to a valid GKPoint)
bool GKPoints::isPointAtRightArea | ( | const GKPoint & | p | ) | const |
Returns true if point p is located at the right side of this polyline (right going from the first point to the last one) and false if p is located at the left side
GKPoints GKPoints::leftOf | ( | double | distance | ) | const |
Returns the left part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.
If distance is negative then distance = this->length2D() + distance.
GKCoord GKPoints::length2D | ( | bool | closed = false | ) | const |
Returns the length of the polyline represented by this points in a 2D space (the Z coordinate is not used). If closed is true then the segment from the last point to the first point is considered.
GKCoord GKPoints::length2DFromPointToPoint | ( | int | pointIni, |
int | pointEnd | ||
) | const |
Returns the length of the segments from pointIni to pointEnd (both inclusive). pointIni and pointEnd go from 0 to nbpoints in the polyline-1
GKCoord GKPoints::length3D | ( | bool | closed = false | ) | const |
Returns the length of this polyline in a 3D space. If closed is true then the segment from the last point to the first point is considered.
int GKPoints::onPolyline | ( | const GKPoint & | point, |
double | epsilon, | ||
bool | closed = false |
||
) | const |
Returns the segment number where the point "point" is. If closed is true then the segment from the last point to the first point is considered.
This method is similar to GKPoints::segmentAtPos but considering an epsilon.
End GKPoint * GKPoints::operator[] | ( | int | ) |
void GKPoints::order | ( | ) |
This function orders the points taken into account the angle that the line center-point makes with the horizontal. The current polygon (or set of points) is modified.
GKPoint GKPoints::pointAtPos | ( | double | pos, |
bool | closed = false |
||
) | const |
Returns the point in the polyline at position "pos" relative to its start (pos = 0.0 is the start point, pos = length2D() is the end point). Is pos is negative then it will take as initial reference the last point, so it these two calls are equivalent: line.pointAtPos( -3.0 ) and line.pointAtPos( line.length2D() - 3.0 ).
If closed is true then the segment from the last point to the first point is considered.
double GKPoints::posAtPoint | ( | const GKPoint & | p, |
GKCoord | maxDistToPoints = 0.01 , |
||
bool | closed = false |
||
) | const |
Returns the position in the polyline at point "p". The point can be outside of the center line at a maximum distance "maxDistToPoints" from it and, if so, the method will calculate the point at the more close segment (perpendicular to p) and will use this new point.
If closed is true then the segment from the last point to the first point is also considered.
void GKPoints::reverse | ( | ) |
Reverses the points order.
GKPoints GKPoints::rightOf | ( | double | distance | ) | const |
Returns the right part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.
If distance is negative then distance = this->length2D() + distance.
void GKPoints::rotate | ( | const GKPoint & | center, |
double | angle | ||
) |
Rotates all the points in this polyline an angle 'angle' in radians taking 'center' as the center of rotation
void GKPoints::scale | ( | const GKPoint & | scale | ) |
Scales all the points in this polyline multiplying all them by a scale point
int GKPoints::segmentAtPos | ( | GKCoord | pos, |
bool | closed = false , |
||
double * | length = NULL |
||
) | const |
Returns the position in the vector of points that identifies the initial point of the segment where the point at position "pos" relative to the start of the polyline is located (pos = 0.0 is the start point, pos = length2D() is the end point). The length of the 0 --> pos - 1 segments is returned too if "length" is not None (it's a pointer to a double).
Examples: This -> Polyline with 3 points: p[0], p[1], p[2] Distance between p[0] & p[1] = 1.0 Distance between p[1] & p[2] = 2.0
segmentAtPos(0.0) = 0 segmentAtPos(1.0) = 0 segmentAtPos(1.5) = 1 segmentAtPos(3.0) = 1
If closed is true then the segment from the last point to the first point is considered.
void GKPoints::setAltitude | ( | GKCoord | value | ) |
Moves the Z coords of this polyline to make the lower Z equal to "value".
void GKPoints::simplifyPolyline | ( | double | distance = 0.00001 | ) |
Removes all the unnecesary points, that is the ones that belong to the same segment as their precedent and posterior points, as well as all the loops found in the polyline.
Uses distance to consider points that are too close and must be eliminated.
void GKPoints::translate | ( | const GKPoint & | delta | ) |
Applies a translation delta to all the points in this polyline
MethodCode sipCpp append* GKPoints::a0 |
GKPoints::else |
|
static |
Number of points to render a bezier curve. The default number is 10. A bigger number will produce smoother curves but using more memory.
|
static |
Epsilon to control when points are discarded as they are too close (in a bezier curve).
MethodCode int GKPoints::len |
GKPoints::len = sipCpp ->size() |
MethodCode GKPoints::sipRes = sipCpp->size() |