#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.  More... | |
| void | addLine (FieldDim theDim, double theMC, double theBegin, double theEnd) | 
| Calls previous.  More... | |
| int | insertLine (FieldDim theDim, GLViewer_LineList *, int thePosition) | 
| Adds new line and sorted field.  More... | |
| int | insertLine (FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition) | 
| Calls previous.  More... | |
| GLViewer_LineList * | getLine (int index, FieldDim) | 
| Returns line by index and dimension.  More... | |
| void | setBorders (double X1, double X2, double Y1, double Y2) | 
| Nullifys field and sets same continued segments.  More... | |
| void | addRectangle (double top, double right, double bottom, double left) | 
| Cut rectangle in grid.  More... | |
| int * | intersectIndexes (FieldDim theDim, int theIndex, const GLViewer_LineList *theLL, int &theSize) | 
| returns arrey of intersects indexes with  More... | |
| void | print () | 
| void | show () | 
| int | getDimSize (FieldDim) | 
| int | segmentNumber () | 
| Returns number of segment.  More... | |
| bool | setPoint (FieldPoint, double x, double y) | 
| Sets start/end search point.  More... | |
| void | optimize () | 
| Optimize field.  More... | |
| void | initialize () | 
| Some prepare actions.  More... | |
| EndStatus | startAlgorithm () | 
| Main method.  More... | |
| double * | solution (int &size) | 
| Returns solution and size of solution.  More... | |
Static Public Member Functions | |
| static FieldDim | invertDim (FieldDim) | 
| Returns other dimension.  More... | |
Protected Member Functions | |
| void | iteration () | 
| One iteration of algorithm.  More... | |
| IterationStatus | checkComplete () | 
| Checks for complete status.  More... | |
| int * | findByCount (int &theParam) | 
| Finds LineList by counts and returns indexes.  More... | |
| int | findBySegment (FieldDim, int coord1, int coord2, bool inCurArray=true) | 
| Finds LineList by segment and dimension.  More... | |
| GraphNode * | getCurArray () | 
| Returns current solution array.  More... | |
| GraphNode * | getSecArray () | 
| Returns.  More... | |
| int | maxSegmentNum () | 
| Returns maximum segment number.  More... | |
| GLViewer_LineList ** | getLLArray (FieldDim) | 
| Returns list of LileList by dimension.  More... | |
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.
Constructor
References myCurArrayIndex, myCurCount, myGraphArray1, myGraphArray2, myXLineArray, myXSize, myYLineArray, and myYSize.
      
  | 
  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().
| 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().
      
  | 
  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().
      
  | 
  protected | 
Finds LineList by counts and returns indexes
References getCurArray(), GraphNode::myCount, myGraphArray1, myGraphArray2, myXLineArray, myYLineArray, and segmentNumber().
      
  | 
  protected | 
Finds LineList by segment and dimension
References getCurArray(), getDimSize(), getSecArray(), GraphNode::myDim, myGraphArray1, myGraphArray2, GraphNode::myLineIndex, GraphNode::mySegmentindex, myXLineArray, myYLineArray, and segmentNumber().
      
  | 
  protected | 
References myCurArrayIndex, myGraphArray1, and myGraphArray2.
| int GLViewer_LineField::getDimSize | ( | FieldDim | theDim | ) | 
| 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.
      
  | 
  protected | 
| theDim | - dimension | 
References FD_X, FD_Y, myXLineArray, and myYLineArray.
      
  | 
  protected | 
References myCurArrayIndex, myGraphArray1, and myGraphArray2.
| 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(), 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().
| 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().
| 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.
      
  | 
  protected | 
One iteration of algorithm
References findByCount(), findBySegment(), getCurArray(), getLine(), intersectIndexes(), invertDim(), GraphNode::myCount, myCurCount, GraphNode::myDim, GraphNode::myLineIndex, GraphNode::mySegmentindex, and GraphNode::prevNodeIndex.
      
  | 
  protected | 
References GLViewer_LineList::count(), getDimSize(), getLine(), myXLineArray, and myYLineArray.
| void GLViewer_LineField::optimize | ( | ) | 
Removes all multiple segments
References GLViewer_LineList::count(), getDimSize(), getLine(), myEndPoint, myStartPoint, myXLineArray, SearchPoint::myXLineIndex, SearchPoint::myXSegmentIndex, myYLineArray, SearchPoint::myYLineIndex, SearchPoint::myYSegmentIndex, GLViewer_LineList::readSegment(), and GLViewer_LineList::removeSegment().
| void GLViewer_LineField::print | ( | ) | 
Prints debug info about line field
References myXLineArray, myXSize, myYLineArray, and myYSize.
| int GLViewer_LineField::segmentNumber | ( | ) | 
References GLViewer_LineList::count(), getDimSize(), getLine(), myXLineArray, and myYLineArray.
| 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().
| 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::show | ( | ) | 
Draws field with help of OpenGL
References FD_X, FD_Y, getLine(), myXSize, myYSize, GLViewer_LineList::show(), and solution().
| 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().
| 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.
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private |