#include <GLViewer_Tools.h>
Public Types | |
| enum | FieldPoint { FP_Start = 0, FP_End = 1 } |
Searched point. More... | |
| enum | IterationStatus { IS_ERROR = 0, IS_LOOP, IS_NOT_SOLVED, IS_SOLVED } |
Status of interation. More... | |
| enum | EndStatus { ES_ERROR = 0, ES_LOOP, ES_SOLVED } |
Final status of solving. More... | |
Public Member Functions | |
| GLViewer_LineField () | |
| GLViewer_LineField (const int theMAXSize, const int xn, const int yn) | |
| virtual | ~GLViewer_LineField () |
| void | addLine (FieldDim, GLViewer_LineList *) |
| Adds new line. | |
| void | addLine (FieldDim theDim, double theMC, double theBegin, double theEnd) |
| Calls previous. | |
| int | insertLine (FieldDim theDim, GLViewer_LineList *, int thePosition) |
| Adds new line and sorted field. | |
| int | insertLine (FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition) |
| Calls previous. | |
| GLViewer_LineList * | getLine (int index, FieldDim) |
| Returns line by index and dimension. | |
| void | setBorders (double X1, double X2, double Y1, double Y2) |
| Nullifys field and sets same continued segments. | |
| void | addRectangle (double top, double right, double bottom, double left) |
| Cut rectangle in grid. | |
| int * | intersectIndexes (FieldDim theDim, int theIndex, const GLViewer_LineList *theLL, int &theSize) |
| returns arrey of intersects indexes with | |
| void | print () |
| void | show () |
| int | getDimSize (FieldDim) |
| int | segmentNumber () |
| Returns number of segment. | |
| bool | setPoint (FieldPoint, double x, double y) |
| Sets start/end search point. | |
| void | optimize () |
| Optimize field. | |
| void | initialize () |
| Some prepare actions. | |
| EndStatus | startAlgorithm () |
| Main method. | |
| double * | solution (int &size) |
| Returns solution and size of solution. | |
Static Public Member Functions | |
| static FieldDim | invertDim (FieldDim) |
| Returns other dimension. | |
Protected Member Functions | |
| void | iteration () |
| One iteration of algorithm. | |
| IterationStatus | checkComplete () |
| Checks for complete status. | |
| int * | findByCount (int &theParam) |
| Finds LineList by counts and returns indexes. | |
| int | findBySegment (FieldDim, int coord1, int coord2, bool inCurArray=true) |
| Finds LineList by segment and dimension. | |
| GraphNode * | getCurArray () |
| Returns current solution array. | |
| GraphNode * | getSecArray () |
| Returns. | |
| int | maxSegmentNum () |
| Returns maximum segment number. | |
| GLViewer_LineList ** | getLLArray (FieldDim) |
| Returns list of LileList by dimension. | |
Private Attributes | |
| GLViewer_LineList ** | myXLineArray |
| GLViewer_LineList ** | myYLineArray |
| int | myXSize |
| int | myYSize |
| GraphNode * | myGraphArray1 |
| GraphNode * | myGraphArray2 |
| int | myCurArrayIndex |
| SearchPoint | myStartPoint |
| SearchPoint | myEndPoint |
| int | myCurCount |
Tools for solving algorithm of finding shortest path on rare grid with minimum of line turns number
| GLViewer_LineField::GLViewer_LineField | ( | ) |
Constructor
References myCurArrayIndex, myCurCount, myGraphArray1, myGraphArray2, myXLineArray, myXSize, myYLineArray, and myYSize.
| GLViewer_LineField::GLViewer_LineField | ( | const int | theMAXSize, |
| const int | theXN, | ||
| const int | theYN | ||
| ) |
Constructor
References myCurArrayIndex, myCurCount, myGraphArray1, myGraphArray2, myXLineArray, myXSize, myYLineArray, and myYSize.
| GLViewer_LineField::~GLViewer_LineField | ( | ) | [virtual] |
Destructor
References myGraphArray1, myGraphArray2, myXLineArray, myXSize, myYLineArray, and myYSize.
| void GLViewer_LineField::addLine | ( | FieldDim | theDim, |
| GLViewer_LineList * | |||
| ) |
best way, if line is already sorted
Adds line
| void GLViewer_LineField::addLine | ( | FieldDim | theDim, |
| double | theMC, | ||
| double | theBegin, | ||
| double | theEnd | ||
| ) |
Adds line
| theDim | - dimension |
| theMC | - main co-ordinate |
| theBegin | - start co-ordinate |
| theEnd | - end co-ordinate |
References addLine(), GLViewer_LineList.addSegment(), and GLViewer_LineList.setMainCoord().
| int GLViewer_LineField::insertLine | ( | FieldDim | theDim, |
| GLViewer_LineList * | theLL, | ||
| int | thePosition | ||
| ) |
Returns position
Adds line
| theDim | - dimension |
| theLL | - main co-ordinate |
| thePosition | - index in list |
References getDimSize(), getLLArray(), GLViewer_LineList.mainCoord(), myXLineArray, and myYLineArray.
| int GLViewer_LineField::insertLine | ( | FieldDim | theDim, |
| double | theMainCoord, | ||
| double | theBegin, | ||
| double | theEnd, | ||
| int | thePosition | ||
| ) |
Adds line
| theDim | - dimension |
| theMainCoord | - main co-ordinate |
| theBegin | - start co-ordinate |
| theEnd | - end co-ordinate |
| thePosition | - index in list |
References GLViewer_LineList.addSegment(), insertLine(), and GLViewer_LineList.setMainCoord().
| GLViewer_LineList * GLViewer_LineField::getLine | ( | int | theIndex, |
| FieldDim | theFD | ||
| ) |
| theIndex | - index in list |
| tehFD | - dimension |
References FD_X, FD_Y, myXLineArray, myXSize, myYLineArray, and myYSize.
| void GLViewer_LineField::setBorders | ( | double | X1, |
| double | X2, | ||
| double | Y1, | ||
| double | Y2 | ||
| ) |
Sets borders of field
| X1,X2 | - minimal and maximal abscisses |
| Y1,Y2 | - minimal and maximal ordinates |
References GLViewer_LineList.addSegment(), GLViewer_LineList.clear(), myXLineArray, myXSize, myYLineArray, myYSize, and GLViewer_LineList.setMainCoord().
| void GLViewer_LineField::addRectangle | ( | double | top, |
| double | right, | ||
| double | bottom, | ||
| double | left | ||
| ) |
Adds rectangle
| top,right | - a corner of rectangle |
| bottom,left | - other corner of rectangle |
References GLViewer_LineList.mainCoord(), myXLineArray, myXSize, myYLineArray, myYSize, and GLViewer_LineList.removeSegment().
| int * GLViewer_LineField::intersectIndexes | ( | FieldDim | theDim, |
| int | theIndex, | ||
| const GLViewer_LineList * | theLL, | ||
| int & | theSize | ||
| ) |
| theLL |
| theDim | - dimension |
| theIndex | - index |
| theLL | - line with that intersection is checked |
| theSize | - to return value of array size |
References GLViewer_LineList.contains(), getDimSize(), getLine(), GLViewer_LineList.mainCoord(), myXLineArray, and myYLineArray.
| void GLViewer_LineField::print | ( | ) |
Prints debug info about line field
References myXLineArray, myXSize, myYLineArray, and myYSize.
| void GLViewer_LineField::show | ( | ) |
Draws field with help of OpenGL
References FD_X, FD_Y, getLine(), test_big_table.k, myXSize, myYSize, GLViewer_LineList.show(), and solution().
| int GLViewer_LineField::getDimSize | ( | FieldDim | theDim | ) |
| int GLViewer_LineField::segmentNumber | ( | ) |
References GLViewer_LineList.count(), getDimSize(), getLine(), myXLineArray, and myYLineArray.
| bool GLViewer_LineField::setPoint | ( | FieldPoint | thePoint, |
| double | theX, | ||
| double | theY | ||
| ) |
Sets start/end search point
| thePoint | - type of point (start: FP_Start; end: FP_End ) |
| theX,theY | - point co-ordinates |
References GLViewer_LineList.contains(), FD_X, FD_Y, FP_Start, getLine(), GLViewer_LineList.mainCoord(), myEndPoint, SearchPoint.mySolveIndex, myStartPoint, myXLineArray, SearchPoint.myXLineIndex, SearchPoint.myXSegmentIndex, myXSize, myYLineArray, SearchPoint.myYLineIndex, SearchPoint.myYSegmentIndex, and myYSize.
| void GLViewer_LineField::optimize | ( | ) |
Removes all multiple segments
References GLViewer_LineList.count(), getDimSize(), getLine(), test_big_table.k, test_table.l, myEndPoint, myStartPoint, myXLineArray, SearchPoint.myXLineIndex, SearchPoint.myXSegmentIndex, myYLineArray, SearchPoint.myYLineIndex, SearchPoint.myYSegmentIndex, GLViewer_LineList.readSegment(), and GLViewer_LineList.removeSegment().
| void GLViewer_LineField::initialize | ( | ) |
Needs call setPoint before
Some prepare actions Needs call setPoint before
References GLViewer_LineList.count(), FD_X, FD_Y, getDimSize(), getLine(), test_big_table.k, GraphNode.myCount, myCurArrayIndex, myCurCount, GraphNode.myDim, myGraphArray1, myGraphArray2, GraphNode.myLineIndex, GraphNode.mySegmentindex, myStartPoint, myXLineArray, SearchPoint.myXLineIndex, SearchPoint.myXSegmentIndex, myYLineArray, SearchPoint.myYLineIndex, SearchPoint.myYSegmentIndex, GraphNode.prevNodeIndex, and segmentNumber().
| GLViewer_LineField::EndStatus GLViewer_LineField::startAlgorithm | ( | ) |
Main method, performs algorithm execution
References checkComplete(), ES_ERROR, ES_LOOP, ES_SOLVED, IS_ERROR, IS_LOOP, IS_SOLVED, iteration(), myCurCount, myGraphArray1, myGraphArray2, myXLineArray, and myYLineArray.
| double * GLViewer_LineField::solution | ( | int & | theSize | ) |
References FD_X, getCurArray(), getLine(), GLViewer_LineList.mainCoord(), myCurCount, myEndPoint, myGraphArray1, myGraphArray2, SearchPoint.mySolveIndex, myXLineArray, myYLineArray, GraphNode.prevNodeIndex, and GLViewer_LineList.readSegment().
| void GLViewer_LineField::iteration | ( | ) | [protected] |
One iteration of algorithm
References findByCount(), findBySegment(), getCurArray(), getLine(), intersectIndexes(), invertDim(), GraphNode.myCount, myCurCount, GraphNode.myDim, GraphNode.myLineIndex, GraphNode.mySegmentindex, and GraphNode.prevNodeIndex.
| GLViewer_LineField::IterationStatus GLViewer_LineField::checkComplete | ( | ) | [protected] |
Checks for complete status
References FD_X, FD_Y, getCurArray(), getSecArray(), IS_ERROR, IS_LOOP, IS_NOT_SOLVED, IS_SOLVED, GraphNode.myCount, myCurArrayIndex, myEndPoint, myGraphArray1, myGraphArray2, GraphNode.mySegmentindex, SearchPoint.mySolveIndex, myXLineArray, SearchPoint.myXLineIndex, SearchPoint.myXSegmentIndex, myYLineArray, SearchPoint.myYLineIndex, SearchPoint.myYSegmentIndex, GraphNode.prevNodeIndex, and segmentNumber().
| int * GLViewer_LineField::findByCount | ( | int & | theParam | ) | [protected] |
Finds LineList by counts and returns indexes
References getCurArray(), GraphNode.myCount, myGraphArray1, myGraphArray2, myXLineArray, myYLineArray, and segmentNumber().
| int GLViewer_LineField::findBySegment | ( | FieldDim | theDim, |
| int | theLineIndex, | ||
| int | theSegment, | ||
| bool | inCurArray = true |
||
| ) | [protected] |
Finds LineList by segment and dimension
References getCurArray(), getDimSize(), getSecArray(), GraphNode.myDim, myGraphArray1, myGraphArray2, GraphNode.myLineIndex, GraphNode.mySegmentindex, myXLineArray, myYLineArray, and segmentNumber().
| GraphNode * GLViewer_LineField::getCurArray | ( | ) | [protected] |
References myCurArrayIndex, myGraphArray1, and myGraphArray2.
| GraphNode * GLViewer_LineField::getSecArray | ( | ) | [protected] |
References myCurArrayIndex, myGraphArray1, and myGraphArray2.
| int GLViewer_LineField::maxSegmentNum | ( | ) | [protected] |
References GLViewer_LineList.count(), getDimSize(), getLine(), myXLineArray, and myYLineArray.
| GLViewer_LineList ** GLViewer_LineField::getLLArray | ( | FieldDim | theDim | ) | [protected] |
| theDim | - dimension |
References FD_X, FD_Y, myXLineArray, and myYLineArray.
GLViewer_LineList** GLViewer_LineField.myXLineArray [private] |
GLViewer_LineList ** GLViewer_LineField.myYLineArray [private] |
int GLViewer_LineField.myXSize [private] |
int GLViewer_LineField.myYSize [private] |
GraphNode* GLViewer_LineField.myGraphArray1 [private] |
GraphNode * GLViewer_LineField.myGraphArray2 [private] |
int GLViewer_LineField.myCurArrayIndex [private] |
SearchPoint GLViewer_LineField.myStartPoint [private] |
SearchPoint GLViewer_LineField.myEndPoint [private] |
int GLViewer_LineField.myCurCount [private] |