Version: 9.15.0
GLViewer_LineField Class Reference

#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_LineListgetLine (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...
 
GraphNodegetCurArray ()
 Returns current solution array. More...
 
GraphNodegetSecArray ()
 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
 
GraphNodemyGraphArray1
 
GraphNodemyGraphArray2
 
int myCurArrayIndex
 
SearchPoint myStartPoint
 
SearchPoint myEndPoint
 
int myCurCount
 

Detailed Description

Tools for solving algorithm of finding shortest path on rare grid with minimum of line turns number

Member Enumeration Documentation

◆ EndStatus

Final status of solving.

Enumerator
ES_ERROR 
ES_LOOP 
ES_SOLVED 

◆ FieldPoint

Searched point.

Enumerator
FP_Start 
FP_End 

◆ IterationStatus

Status of interation.

Enumerator
IS_ERROR 
IS_LOOP 
IS_NOT_SOLVED 
IS_SOLVED 

Constructor & Destructor Documentation

◆ GLViewer_LineField() [1/2]

GLViewer_LineField::GLViewer_LineField ( )

◆ GLViewer_LineField() [2/2]

GLViewer_LineField::GLViewer_LineField ( const int  theMAXSize,
const int  theXN,
const int  theYN 
)

◆ ~GLViewer_LineField()

GLViewer_LineField::~GLViewer_LineField ( )
virtual

Member Function Documentation

◆ addLine() [1/2]

void GLViewer_LineField::addLine ( FieldDim  theDim,
double  theMC,
double  theBegin,
double  theEnd 
)

Calls previous.

Adds line

Parameters
theDim- dimension
theMC- main co-ordinate
theBegin- start co-ordinate
theEnd- end co-ordinate

References addLine(), GLViewer_LineList::addSegment(), and GLViewer_LineList::setMainCoord().

◆ addLine() [2/2]

void GLViewer_LineField::addLine ( FieldDim  ,
GLViewer_LineList  
)

Adds new line.

best way, if line is already sorted

Adds line

◆ addRectangle()

void GLViewer_LineField::addRectangle ( double  top,
double  right,
double  bottom,
double  left 
)

Cut rectangle in grid.

Adds rectangle

Parameters
top,right- a corner of rectangle
bottom,left- other corner of rectangle

References GLViewer_LineList::mainCoord(), myXLineArray, myXSize, myYLineArray, myYSize, and GLViewer_LineList::removeSegment().

◆ checkComplete()

◆ findByCount()

int * GLViewer_LineField::findByCount ( int &  theParam)
protected

Finds LineList by counts and returns indexes.

Finds LineList by counts and returns indexes

References getCurArray(), GraphNode::myCount, myGraphArray1, myGraphArray2, myXLineArray, myYLineArray, and segmentNumber().

◆ findBySegment()

int GLViewer_LineField::findBySegment ( FieldDim  theDim,
int  theLineIndex,
int  theSegment,
bool  inCurArray = true 
)
protected

Finds LineList by segment and dimension.

Finds LineList by segment and dimension

References getCurArray(), getDimSize(), getSecArray(), GraphNode::myDim, myGraphArray1, myGraphArray2, GraphNode::myLineIndex, GraphNode::mySegmentindex, myXLineArray, myYLineArray, and segmentNumber().

◆ getCurArray()

GraphNode * GLViewer_LineField::getCurArray ( )
protected

Returns current solution array.

Returns
current solution array

References myCurArrayIndex, myGraphArray1, and myGraphArray2.

◆ getDimSize()

int GLViewer_LineField::getDimSize ( FieldDim  theDim)
Returns
size
Parameters
theDim- dimension

References FD_X, FD_Y, myXSize, and myYSize.

◆ getLine()

GLViewer_LineList * GLViewer_LineField::getLine ( int  theIndex,
FieldDim  theFD 
)

Returns line by index and dimension.

Returns
line list
Parameters
theIndex- index in list
tehFD- dimension

References FD_X, FD_Y, myXLineArray, myXSize, myYLineArray, and myYSize.

◆ getLLArray()

GLViewer_LineList ** GLViewer_LineField::getLLArray ( FieldDim  theDim)
protected

Returns list of LileList by dimension.

Returns
list of LileList by dimension
Parameters
theDim- dimension

References FD_X, FD_Y, myXLineArray, and myYLineArray.

◆ getSecArray()

GraphNode * GLViewer_LineField::getSecArray ( )
protected

Returns.

Returns
other solution array

References myCurArrayIndex, myGraphArray1, and myGraphArray2.

◆ initialize()

◆ insertLine() [1/2]

int GLViewer_LineField::insertLine ( FieldDim  theDim,
double  theMainCoord,
double  theBegin,
double  theEnd,
int  thePosition 
)

Calls previous.

Adds line

Parameters
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().

◆ insertLine() [2/2]

int GLViewer_LineField::insertLine ( FieldDim  theDim,
GLViewer_LineList theLL,
int  thePosition 
)

Adds new line and sorted field.

Returns position

Adds line

Parameters
theDim- dimension
theLL- main co-ordinate
thePosition- index in list

References getDimSize(), getLLArray(), GLViewer_LineList::mainCoord(), myXLineArray, and myYLineArray.

◆ intersectIndexes()

int * GLViewer_LineField::intersectIndexes ( FieldDim  theDim,
int  theIndex,
const GLViewer_LineList theLL,
int &  theSize 
)

returns arrey of intersects indexes with

Parameters
theLL
Returns
array of intersected indexes
Parameters
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.

◆ invertDim()

FieldDim GLViewer_LineField::invertDim ( FieldDim  theFD)
static

Returns other dimension.

Returns
other dimension

References FD_X, and FD_Y.

◆ iteration()

void GLViewer_LineField::iteration ( )
protected

◆ maxSegmentNum()

int GLViewer_LineField::maxSegmentNum ( )
protected

Returns maximum segment number.

Returns
maximum segment number

References GLViewer_LineList::count(), getDimSize(), getLine(), myXLineArray, and myYLineArray.

◆ optimize()

◆ print()

void GLViewer_LineField::print ( )

Prints debug info about line field

References myXLineArray, myXSize, myYLineArray, and myYSize.

◆ segmentNumber()

int GLViewer_LineField::segmentNumber ( )

Returns number of segment.

Returns
number of segments

References GLViewer_LineList::count(), getDimSize(), getLine(), myXLineArray, and myYLineArray.

◆ setBorders()

void GLViewer_LineField::setBorders ( double  X1,
double  X2,
double  Y1,
double  Y2 
)

Nullifys field and sets same continued segments.

Sets borders of field

Parameters
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().

◆ setPoint()

bool GLViewer_LineField::setPoint ( FieldPoint  thePoint,
double  theX,
double  theY 
)

Sets start/end search point.

Sets start/end search point

Parameters
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.

◆ show()

void GLViewer_LineField::show ( )

Draws field with help of OpenGL

References FD_X, FD_Y, getLine(), myXSize, myYSize, GLViewer_LineList::show(), and solution().

◆ solution()

double * GLViewer_LineField::solution ( int &  theSize)

◆ startAlgorithm()

GLViewer_LineField::EndStatus GLViewer_LineField::startAlgorithm ( )

Main method.

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.

Member Data Documentation

◆ myCurArrayIndex

int GLViewer_LineField::myCurArrayIndex
private

◆ myCurCount

int GLViewer_LineField::myCurCount
private

◆ myEndPoint

SearchPoint GLViewer_LineField::myEndPoint
private

◆ myGraphArray1

GraphNode* GLViewer_LineField::myGraphArray1
private

◆ myGraphArray2

GraphNode * GLViewer_LineField::myGraphArray2
private

◆ myStartPoint

SearchPoint GLViewer_LineField::myStartPoint
private

◆ myXLineArray

GLViewer_LineList** GLViewer_LineField::myXLineArray
private

◆ myXSize

int GLViewer_LineField::myXSize
private

◆ myYLineArray

GLViewer_LineList ** GLViewer_LineField::myYLineArray
private

◆ myYSize

int GLViewer_LineField::myYSize
private

The documentation for this class was generated from the following files: