Back to index

salome-gui  6.5.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
GLViewer_LineField Class Reference

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

#include <GLViewer_Tools.h>

Collaboration diagram for GLViewer_LineField:
Collaboration graph
[legend]

List of all members.

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 ()
 Constructor.
 GLViewer_LineField (const int theMAXSize, const int xn, const int yn)
 Constructor.
virtual ~GLViewer_LineField ()
 Destructor.
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_LineListgetLine (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 ()
 Prints debug info about line field.
void show ()
 Draws field with help of OpenGL.
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.
GraphNodegetCurArray ()
 Returns current solution array.
GraphNodegetSecArray ()
 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
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.

Definition at line 127 of file GLViewer_Tools.h.


Member Enumeration Documentation

Final status of solving.

Enumerator:
ES_ERROR 
ES_LOOP 
ES_SOLVED 

Definition at line 147 of file GLViewer_Tools.h.

Searched point.

Enumerator:
FP_Start 
FP_End 

Definition at line 131 of file GLViewer_Tools.h.

  {
    FP_Start = 0,
    FP_End = 1
  };

Status of interation.

Enumerator:
IS_ERROR 
IS_LOOP 
IS_NOT_SOLVED 
IS_SOLVED 

Definition at line 138 of file GLViewer_Tools.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 434 of file GLViewer_Tools.cxx.

{
  myCurArrayIndex = 0;
  myGraphArray1 = NULL;
  myGraphArray2 = NULL;

  myCurCount = 0;

  myXSize = 0;    
  myYSize = 0;
  myXLineArray = NULL;
  myYLineArray = NULL;
}
GLViewer_LineField::GLViewer_LineField ( const int  theMAXSize,
const int  xn,
const int  yn 
)

Constructor.

Definition at line 451 of file GLViewer_Tools.cxx.

{
  myCurArrayIndex = 0;
  myGraphArray1 = NULL;
  myGraphArray2 = NULL;

  myCurCount = 0;

  if( theXN <= 0 || theYN <= 0 )
  {
    myXSize = 0;    
    myYSize = 0;
    myXLineArray = NULL;
    myYLineArray = NULL;
  }
  else
  {
    myXLineArray = new GLViewer_LineList*[theXN];
    myYLineArray = new GLViewer_LineList*[theYN];

    for( int i = 0; i < theXN; i++ )
      myXLineArray[i] = new GLViewer_LineList( theMAXSize );

    for( int j = 0; j < theYN; j++ )
      myYLineArray[j] = new GLViewer_LineList( theMAXSize );

    myXSize = theXN;    
    myYSize = theYN;
  }
}

Destructor.

Definition at line 485 of file GLViewer_Tools.cxx.

{
  if( myXLineArray )
  {
    for( int i = 0; i < myXSize; i++ )
      delete myXLineArray[i];

    delete myXLineArray;
  }

  if( myYLineArray )
  {
    for( int j = 0; j < myYSize; j++ )
      delete myYLineArray[j];

    delete myYLineArray;
  }

  if( myGraphArray1 )
    delete myGraphArray1;

  if( myGraphArray2 )
    delete myGraphArray2;
}

Member Function Documentation

Adds new line.

Adds line.

best way, if line is already sorted

Definition at line 513 of file GLViewer_Tools.cxx.

{
  //not implemented
}

Here is the caller graph for this function:

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

Definition at line 525 of file GLViewer_Tools.cxx.

{
  GLViewer_LineList* aLL = new GLViewer_LineList( 1 );
  aLL->addSegment( theBegin, theEnd );
  aLL->setMainCoord( theMC );
  addLine( theDim, aLL );
}

Here is the call graph for this function:

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

Definition at line 675 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return;
  for( int i = 0; i < myXSize; i++ )
  {
    double mainCoord = myXLineArray[i]->mainCoord();
    if( mainCoord < top && mainCoord > bottom )
      myXLineArray[i]->removeSegment( left, right );
  }

  for( int j = 0; j < myYSize; j++ )
  {
    double mainCoord = myYLineArray[j]->mainCoord();
    if( mainCoord < right && mainCoord > left )
      myYLineArray[j]->removeSegment( bottom, top );
  }
}

Here is the call graph for this function:

Checks for complete status.

Definition at line 993 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
    return IS_ERROR; 
   
  int count = 0;
  GraphNode* aCurArray = getCurArray(),
           * aSecArray = getSecArray();
  
  for( int i = 0, n = segmentNumber(); i < n; i++ )
  {
    if( aCurArray[i].myCount != aSecArray[i].myCount )
    {
      if( aCurArray[i].myDim == FD_X && 
          aCurArray[i].myLineIndex == myEndPoint.myXLineIndex && 
          aCurArray[i].mySegmentindex == myEndPoint.myXSegmentIndex )
      {
        std::cout << "Algorithm complete X!!!!!!!" << std::endl;
        myEndPoint.mySolveIndex = i;
        return IS_SOLVED;
      }
      else if( aCurArray[i].myDim == FD_Y && 
               aCurArray[i].myLineIndex == myEndPoint.myYLineIndex && 
               aCurArray[i].mySegmentindex == myEndPoint.myYSegmentIndex )
      {
        std::cout << "Algorithm complete Y!!!!!!!" << std::endl;
        myEndPoint.mySolveIndex = i;  
        return IS_SOLVED;
      }
      else
      {
        count++;
        aSecArray[i].myCount = aCurArray[i].myCount;
        aSecArray[i].prevNodeIndex = aCurArray[i].prevNodeIndex;
      }
    }
  }  
  
  if( myCurArrayIndex == 0)
    myCurArrayIndex = 1;
  else
    myCurArrayIndex = 0;

  std::cout << "Number of ways: " << count << std::endl;
  if( count == 0 )
    return IS_LOOP;

  return IS_NOT_SOLVED;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Finds LineList by counts and returns indexes.

Definition at line 1046 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
    return NULL;

  int count = segmentNumber();
  int* anArray = new int[count];
  int aSize = 0;

  GraphNode* aCurArray = getCurArray();  
  for( int i = 0; i < count; i++ )
  {
    GraphNode aCurNode = aCurArray[i];
    if( aCurNode.myCount == theParam )
    {
      anArray[aSize] = i;
      aSize++;
    }
  }

  theParam = aSize;
  return anArray;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int GLViewer_LineField::findBySegment ( FieldDim  theDim,
int  coord1,
int  coord2,
bool  inCurArray = true 
) [protected]

Finds LineList by segment and dimension.

Definition at line 1073 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 || getDimSize( theDim ) <= theLineIndex )
    return -1;

  GraphNode* aCurArray;
  if( inCurArray )
    aCurArray = getCurArray();
  else
    aCurArray = getSecArray();

  for( int i = 0, n = segmentNumber(); i < n; i++ )
  {
    GraphNode aCurNode = aCurArray[i];
    if( aCurNode.myDim == theDim && aCurNode.myLineIndex == theLineIndex && aCurNode.mySegmentindex == theSegment )
      return i;
  }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns current solution array.

Returns:
current solution array

Definition at line 1167 of file GLViewer_Tools.cxx.

{
  if( !myGraphArray1 || !myGraphArray2 )
    return NULL;

  if( myCurArrayIndex == 0)
    return myGraphArray1;
  else
    return myGraphArray2;
}

Here is the caller graph for this function:

Returns:
size
Parameters:
theDim- dimension

Definition at line 736 of file GLViewer_Tools.cxx.

{
  if( theDim == FD_X )
    return myXSize;
  else if( theDim == FD_Y )
    return myYSize;

  return -1;
}

Here is the caller graph for this function:

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

Definition at line 622 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return NULL;

  if( theFD == FD_X )
  {
    if( theIndex > myXSize )
      return NULL;
    
    return myXLineArray[theIndex];
  }
  else if( theFD == FD_Y )
  {
    if( theIndex > myYSize )
      return NULL;
    
    return myYLineArray[theIndex];
  }

  return NULL;
}

Here is the caller graph for this function:

Returns list of LileList by dimension.

Returns:
list of LileList by dimension
Parameters:
theDim- dimension

Definition at line 1218 of file GLViewer_Tools.cxx.

{
  if( theDim == FD_X )
    return myXLineArray;
  else if( theDim == FD_Y )
    return myYLineArray;
  else
    return NULL;
}

Here is the caller graph for this function:

Returns.

Returns:
other solution array

Definition at line 1181 of file GLViewer_Tools.cxx.

{
  if( !myGraphArray1 || !myGraphArray2 )
    return NULL;

  if( myCurArrayIndex == 0)
    return myGraphArray2;
  else
    return myGraphArray1;
}

Here is the caller graph for this function:

Some prepare actions.

Some prepare actions Needs call setPoint before.

Needs call setPoint before

Definition at line 903 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return;

  int size = segmentNumber();

  myCurArrayIndex = 0;
  myCurCount = 0;

  myGraphArray1 = new GraphNode[size];
  myGraphArray2 = new GraphNode[size];

  int index = 0;
  bool isXSet = false,
       isYSet = false;
  for( int aDim = 0; aDim < 2; aDim++ )
  {
    for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
    {
      GLViewer_LineList* aLL = getLine( i, (FieldDim)aDim  );
      for( int k =0, aSegNum = aLL->count(); k < aSegNum; k++ )
      {
        myGraphArray1[index].myCount = size;
        myGraphArray1[index].myDim = (FieldDim)aDim;
        myGraphArray1[index].myLineIndex = i;
        myGraphArray1[index].mySegmentindex = k;
        myGraphArray1[index].prevNodeIndex = -1;

        myGraphArray2[index].myCount = size;
        myGraphArray2[index].myDim = (FieldDim)aDim;
        myGraphArray2[index].myLineIndex = i;
        myGraphArray2[index].mySegmentindex = k;
        myGraphArray2[index].prevNodeIndex = -1;

        if( !isXSet && aDim == FD_X && myStartPoint.myXLineIndex == i && myStartPoint.myXSegmentIndex == k )
        {
          myGraphArray1[index].myCount = 0;
          isXSet = true;
        }

        if( aDim == FD_Y && !isYSet && myStartPoint.myYLineIndex == i && myStartPoint.myYSegmentIndex == k )
        {
          myGraphArray1[index].myCount = 0;
          isYSet = true;
        }

        index++;
      }
    }
  }
}

Here is the call graph for this function:

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

Adds new line and sorted field.

Adds line.

Returns position

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

Definition at line 539 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return -1;

  GLViewer_LineList** anArray = getLLArray( theDim );
  if( !anArray )
    return -1;

  int size = getDimSize( theDim ); 

  if( thePosition >= size )
    return -1;
  else if( thePosition < 0 )
  {    
    if( anArray[size-1]->count() != 0 ) // no more space
      return -1;

    for( int i = 0; i < size; i++ )
    {
      if( anArray[i]->count() == 0 )
      {
        delete anArray[i];
        anArray[i] = theLL;
        return i;
      }

      double cur_mc = anArray[i]->mainCoord();
      if( theLL->mainCoord() < cur_mc )
      {        
        for( int j = 0; j+i+1 < size; j++ )
        {
          delete anArray[size-j-1];
          anArray[size-j-1] = anArray[size-j-2];
        }
        delete anArray[i];
        anArray[i] = theLL;
        return i;
      }          
    }
  }
  else
  {
    delete anArray[thePosition];
    anArray[thePosition] = theLL;
    return thePosition;
  }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 598 of file GLViewer_Tools.cxx.

{
  GLViewer_LineList* aLL = new GLViewer_LineList( 1 );
  aLL->addSegment( theBegin, theEnd );
  aLL->setMainCoord( theMainCoord );
  return insertLine( theDim, aLL, thePosition );
}

Here is the call graph for this function:

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

Definition at line 753 of file GLViewer_Tools.cxx.

{
  theSize = 0;
  if( !myXLineArray || !myYLineArray )
    return NULL;

  int aDimSize = getDimSize( theDim );
  int* anArray = new int[aDimSize*2 ];

  for( int i = 0; i < aDimSize; i++ )
  {
    GLViewer_LineList* aLL = getLine( i, theDim );      
    int index = aLL->contains( theLL->mainCoord() );       
    if( index != -1 && theLL->contains( aLL->mainCoord() ) == theIndex )
    {
      anArray[theSize*2] = i;
      anArray[theSize*2+1] = index;
      theSize++;
    }
  }
  
  return anArray;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns other dimension.

Returns:
other dimension

Definition at line 609 of file GLViewer_Tools.cxx.

{
  if( theFD == FD_X )
    return FD_Y;
  else
    return FD_X;
}

Here is the caller graph for this function:

One iteration of algorithm.

Definition at line 959 of file GLViewer_Tools.cxx.

{
  int aParam = myCurCount;
  myCurCount++;

  int* aNodes = findByCount( aParam );
  GraphNode* aCurArray = getCurArray();

  for( int i = 0; i < aParam; i++ )
  {
    GraphNode aCurNode = aCurArray[aNodes[i]];
    int aSize = 0;
    int* aInterNodes = intersectIndexes( invertDim( aCurNode.myDim ), aCurNode.mySegmentindex,
                                         getLine( aCurNode.myLineIndex, aCurNode.myDim ), aSize );
    for( int j = 0; j < aSize; j++ )
    {
      int index = findBySegment( invertDim( aCurNode.myDim ), aInterNodes[2*j], aInterNodes[2*j+1], false );
      if( index != -1 )
        if( aCurArray[index].myCount > myCurCount )
        {
          aCurArray[index].myCount = myCurCount;
          aCurArray[index].prevNodeIndex = aNodes[i];
        }
    }

    delete[] aInterNodes;
  }

  delete[] aNodes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int GLViewer_LineField::maxSegmentNum ( ) [protected]

Returns maximum segment number.

Returns:
maximum segment number

Definition at line 1195 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return -1;

  int max_num = -1;
  for( int aDim = 0; aDim < 2; aDim++ )
  {
    for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
    {
      int count = getLine( i, (FieldDim)aDim  )->count();
      if( count > max_num )
        max_num = count;
    }
  }

  return max_num;
}

Here is the call graph for this function:

Optimize field.

Removes all multiple segments.

Removes all multiple segments

Definition at line 852 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return;

  for( int aDim = 0; aDim < 2; aDim++ )
  {
    for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
    {
      GLViewer_LineList* aLL = getLine( i, (FieldDim)aDim  );
      for( int k =0, aSegNum = aLL->count(); k < aSegNum; k++ )
      {
        // int index = i; unused
        double a1, a2;
        aLL->readSegment( k, a1, a2 );
        for( int l = i+1, m = getDimSize( (FieldDim)aDim ); l < m; l++ )
        {
          int end = -1;
          GLViewer_LineList* aCurLL = getLine( l, (FieldDim)aDim );
          for( int j = 0, count = aCurLL->count(); j < count; j++  )
          {
            double c1, c2;
            aCurLL->readSegment( j, c1, c2 );
            if( a1 == c1 && a2 == c2 )
            {
              if( !(aDim == 0 && myStartPoint.myXLineIndex == l && myStartPoint.myXSegmentIndex == j) &&
                  !(aDim == 0 && myEndPoint.myXLineIndex == l && myEndPoint.myXSegmentIndex == j) &&
                  !(aDim == 1 && myStartPoint.myYLineIndex == l && myStartPoint.myYSegmentIndex == j) &&
                  !(aDim == 1 && myEndPoint.myYLineIndex == l && myEndPoint.myYSegmentIndex == j) )
                aCurLL->removeSegment( j );
              end = 0;
              break;
            }
            if( a1 < c1 )
            {
              end = 1;
              break;
            }            
          }
          if( end == -1 || end == 1)
              break;
        }
      }
    }
  }
}

Here is the call graph for this function:

Prints debug info about line field.

Definition at line 697 of file GLViewer_Tools.cxx.

{
  std::cout << "My X matrix Number: " << myXSize << std::endl;
  for( int i = 0; i < myXSize; i++ )
    myXLineArray[i]->print();

  std::cout << "My Y matrix Number: " << myYSize << std::endl;
  for( int j = 0; j < myYSize; j++ )
    myYLineArray[j]->print();
}

Returns number of segment.

Returns:
number of segments

Definition at line 836 of file GLViewer_Tools.cxx.

{
  if( !(myXLineArray || myYLineArray) )
    return -1;

  int aNumber = 0;
  for( int aDim = 0; aDim < 2; aDim++ )
    for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
      aNumber += getLine( i, (FieldDim)aDim  )->count();

  return aNumber;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 650 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return;
    
  for( int i = 0; i < myXSize; i++ )
  {
    myXLineArray[i]->clear();
    myXLineArray[i]->addSegment( X1, X2 );
    myXLineArray[i]->setMainCoord( Y1 + (Y2-Y1)*(double(i)/(myXSize-1)) );
  }

  for( int j = 0; j < myYSize; j++ )
  {
    myYLineArray[j]->clear();
    myYLineArray[j]->addSegment( Y1, Y2 );
    myYLineArray[j]->setMainCoord( X1 + (X2-X1)*(double(j)/(myYSize-1)) );
  }
} 

Here is the call graph for this function:

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

Sets start/end search point.

Parameters:
thePoint- type of point (start: FP_Start; end: FP_End )
theX,theY- point co-ordinates

Definition at line 782 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray )
    return false;

  int i = -1, j = -1;
  int xSeg = -1, ySeg = -1;
  for( i = 0; i < myXSize; i++ )
  {
    GLViewer_LineList* aLL = getLine( i, FD_X );
    if( aLL->mainCoord() == theY )
    {
      xSeg = aLL->contains( theX );
      break;
    }
  }

  for( j = 0; j < myYSize; j++ )
  {
    GLViewer_LineList* aLL = getLine( j, FD_Y );
    if( aLL->mainCoord() == theX )
    {
      ySeg = aLL->contains( theY );
      break;
    }
  }

  if( xSeg != -1 && ySeg != -1 )
  {
    if( thePoint == FP_Start )
    {
      myStartPoint.myXLineIndex = i;
      myStartPoint.myXSegmentIndex = xSeg;
      myStartPoint.myYLineIndex = j;
      myStartPoint.myYSegmentIndex = ySeg;
      myStartPoint.mySolveIndex = -1;
    }
    else
    {
      myEndPoint.myXLineIndex = i;
      myEndPoint.myXSegmentIndex = xSeg;
      myEndPoint.myYLineIndex = j;
      myEndPoint.myYSegmentIndex = ySeg;
      myEndPoint.mySolveIndex = -1;
    }
    return true;
  }
  else
    return false;
}

Here is the call graph for this function:

Draws field with help of OpenGL.

Definition at line 711 of file GLViewer_Tools.cxx.

{
  for( int i = 0; i < myXSize; i++ )
    getLine( i, FD_X )->show( FD_X );

  for( int j = 0; j < myYSize; j++ )
    getLine( j, FD_Y )->show( FD_Y );
  int count = 0;
  double* anArray = solution( count );
  glColor3f( 1.0, 0.0, 0.0 );
  glBegin( GL_LINES );
  for( int k = 0; k < count; k++ )
  {
     glVertex2d( anArray[4*k], anArray[4*k+1] );
     glVertex2d( anArray[4*k+2], anArray[4*k+3] );
  }
  glEnd();
  delete[] anArray;
  std::cout << "Show function" << std::endl;
}

Here is the call graph for this function:

double * GLViewer_LineField::solution ( int &  theSize)

Returns solution and size of solution.

Returns:
solution and size of solution

Definition at line 1121 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
    return NULL;

  if( myEndPoint.mySolveIndex == -1 )
    return NULL;

  theSize = myCurCount+1;
  double* anArray = new double[theSize*4];

  GraphNode* aCurArray = getCurArray();
  
  int index = myEndPoint.mySolveIndex;
  for( int i = 0; i <= myCurCount; i++  )
  {
    if( index == -1 )
      break;
    double c1, c2;
    GLViewer_LineList* aLL = getLine( aCurArray[index].myLineIndex, aCurArray[index].myDim );
    aLL->readSegment( aCurArray[index].mySegmentindex, c1, c2 );

    if( aCurArray[index].myDim == FD_X )
    {
      anArray[i*4] = c1;
      anArray[i*4+1] = aLL->mainCoord();
      anArray[i*4+2] = c2;
      anArray[i*4+3] = aLL->mainCoord();
    }
    else
    {
      anArray[i*4] = aLL->mainCoord();
      anArray[i*4+1] = c1;
      anArray[i*4+2] = aLL->mainCoord();
      anArray[i*4+3] = c2;
    }

    index = aCurArray[index].prevNodeIndex;    
  }

  return anArray;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Main method.

Main method, performs algorithm execution.

Definition at line 1097 of file GLViewer_Tools.cxx.

{
  if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
    return ES_ERROR;

  while( true )
  {
    std::cout << "-----------Iteration #" << myCurCount << "-------------" << std::endl;
    iteration();

    IterationStatus is = checkComplete();
    if( is == IS_ERROR )
      return ES_ERROR;
    else if( is == IS_LOOP )
      return ES_LOOP;
    else if( is == IS_SOLVED )
      return ES_SOLVED;
  }
  return ES_SOLVED;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 238 of file GLViewer_Tools.h.

Definition at line 242 of file GLViewer_Tools.h.

Definition at line 240 of file GLViewer_Tools.h.

Definition at line 236 of file GLViewer_Tools.h.

Definition at line 236 of file GLViewer_Tools.h.

Definition at line 240 of file GLViewer_Tools.h.

Definition at line 230 of file GLViewer_Tools.h.

Definition at line 233 of file GLViewer_Tools.h.

Definition at line 230 of file GLViewer_Tools.h.

Definition at line 233 of file GLViewer_Tools.h.


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