# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

move_cell.cpp

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #include "stdpacs.h"
00027 
00028 #include "pacs/move_cell.h"
00029 #include "pacs/move_element.h"
00030 #include "pacs/move_primitive.h"
00031 
00032 namespace NLPACS 
00033 {
00034 
00035 // ***************************************************************************
00036 
00037 CMoveCell::CMoveCell()
00038 {
00039         _FirstX=NULL;
00040         _LastX=NULL;
00041         /*_FirstY=NULL;
00042         _LastY=NULL;*/
00043 }
00044 
00045 // ***************************************************************************
00046 
00047 void CMoveCell::unlinkX (CMoveElement *element)
00048 {
00049         // Check first last
00050         if (_FirstX==element)
00051                 _FirstX=element->NextX;
00052         if (_LastX==element)
00053                 _LastX=element->PreviousX;
00054 
00055         // Relink to others
00056         if (element->NextX)
00057                 element->NextX->PreviousX=element->PreviousX;
00058         if (element->PreviousX)
00059                 element->PreviousX->NextX=element->NextX;
00060 }
00061 
00062 // ***************************************************************************
00063 
00064 /*void CMoveCell::unlinkY (CMoveElement *element)
00065 {
00066         // Linked in list ?
00067         // Check first / last
00068         if (_FirstY==element)
00069                 _FirstY=element->NextY;
00070         if (_LastY==element)
00071                 _LastY=element->PreviousY;
00072 
00073         // Relink to others
00074         if (element->NextY)
00075                 element->NextY->PreviousY=element->PreviousY;
00076         if (element->PreviousY)
00077                 element->PreviousY->NextY=element->NextY;
00078 }*/
00079 
00080 // ***************************************************************************
00081 
00082 void CMoveCell::linkX (CMoveElement *previous, CMoveElement *element, CMoveElement *next)
00083 {
00084         // Link the element
00085         element->NextX=next;
00086         element->PreviousX=previous;
00087 
00088         // Link to others
00089         if (previous)
00090                 previous->NextX=element;
00091         if (next)
00092                 next->PreviousX=element;
00093 
00094         // Check first / last
00095         if (previous==NULL)
00096                 _FirstX=element;
00097         if (next==NULL)
00098                 _LastX=element;
00099 }
00100 
00101 // ***************************************************************************
00102 
00103 /*void CMoveCell::linkY (CMoveElement *previous, CMoveElement *element, CMoveElement *next)
00104 {
00105         // Link the element
00106         element->NextY=next;
00107         element->PreviousY=previous;
00108 
00109         // Link to others
00110         if (previous)
00111                 previous->NextY=element;
00112         if (next)
00113                 next->PreviousY=element;
00114 
00115         // Check first / last
00116         if (previous==NULL)
00117                 _FirstY=element;
00118         if (next==NULL)
00119                 _LastY=element;
00120 }*/
00121 
00122 // ***************************************************************************
00123 
00124 void CMoveCell::updateSortedLists (CMoveElement *element, uint8 worldImage)
00125 {
00126         // ** Update sorted list on X
00127 
00128         // Primitive pointer
00129         CMovePrimitive *primitive=element->Primitive;
00130 
00131         // Get the world image
00132         CPrimitiveWorldImage *wI=primitive->getWorldImage (worldImage);
00133 
00134         // Test if we will go to the right
00135         CMoveElement *ptr=element->NextX;
00136         if (ptr && (wI->getBBXMin() > ptr->Primitive->getWorldImage (worldImage)->getBBXMin()) )
00137         {
00138                 // Unlink
00139                 unlinkX (element);
00140 
00141                 // Adjust the list localisation
00142                 while (ptr->NextX && (wI->getBBXMin() > ptr->NextX->Primitive->getWorldImage (worldImage)->getBBXMin()) )
00143                 {
00144                         // Next ptr
00145                         ptr=ptr->NextX;
00146                 }
00147 
00148                 // Here we go
00149                 linkX (ptr, element, ptr->NextX);
00150         }
00151         else
00152         {
00153                 // Test if we will go to the left
00154                 ptr=element->PreviousX;
00155                 if (ptr && (ptr->Primitive->getWorldImage (worldImage)->getBBXMin() > wI->getBBXMin()) )
00156                 {
00157                         // Unlink
00158                         unlinkX (element);
00159 
00160                         // Adjust the list localisation
00161                         while (ptr->PreviousX && (ptr->PreviousX->Primitive->getWorldImage (worldImage)->getBBXMin() > wI->getBBXMin()) )
00162                         {
00163                                 // Next ptr
00164                                 ptr=ptr->PreviousX;
00165                         }
00166 
00167                         // Here we go
00168                         linkX (ptr->PreviousX, element, ptr);
00169                 }
00170         }
00171 
00172 /*      // ** Update sorted list on Y
00173 
00174         // Test if we will go to the right
00175         ptr=element->NextY;
00176         if (ptr && (primitive->getBBYMin() > ptr->Primitive->getBBYMin()) )
00177         {
00178                 // Unlink
00179                 unlinkY (element);
00180 
00181                 // Adjust the list localisation
00182                 while (ptr->NextY && (primitive->getBBYMin() > ptr->NextY->Primitive->getBBYMin()) )
00183                 {
00184                         // Next ptr
00185                         ptr=ptr->NextY;
00186                 }
00187 
00188                 // Here we go
00189                 linkY (ptr, element, ptr->NextY);
00190         }
00191         else
00192         {
00193                 // Test if we will go to the left
00194                 ptr=element->PreviousY;
00195                 if (ptr && (ptr->Primitive->getBBYMin() > primitive->getBBYMin()) )
00196                 {
00197                         // Unlink
00198                         unlinkY (element);
00199 
00200                         // Adjust the list localisation
00201                         while (ptr->PreviousY && (ptr->PreviousY->Primitive->getBBYMin() > primitive->getBBYMin()) )
00202                         {
00203                                 // Next ptr
00204                                 ptr=ptr->PreviousY;
00205                         }
00206 
00207                         // Here we go
00208                         linkY (ptr->PreviousY, element, ptr);
00209                 }
00210         }*/
00211 }
00212 
00213 // ***************************************************************************
00214 
00215 } // NLPACS