Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Beta/3D/Topolog.hpp

Go to the documentation of this file.
00001 // Déclaration des classes de numérotation des modeleurs.
00002 
00003 #ifndef  __J2K__TOPOLOGIE_HPP__
00004 #define  __J2K__TOPOLOGIE_HPP__
00005 
00006 #include <j2k/Fred/Standard.hpp>
00007 
00008 #define MOD_NUM_ERROR_BAD_FIC_OPEN  1
00009 #define MOD_NUM_ERROR_BAD_FIC_WRITE 2
00010 #define MOD_NUM_ERROR_BAD_DATA      3
00011 
00012 #ifndef SUCCESS
00013 #define SUCCESS 0
00014 #endif
00015 
00016 #ifndef __CARDINAL
00017 #define __CARDINAL
00018 typedef unsigned       Cardinal;
00019 #endif
00020 
00021 #ifndef __INDEX
00022 #define __INDEX
00023 typedef unsigned       Index;
00024 #define NULLINDEX 0L
00025 #endif
00026 
00027 #define INDEXATION  0
00028 #define CREATION    1
00029 
00030 // le décalage signifis que l'indexation commence à 1 même en RAM.
00031 // Le premier élément des tables correspond à l'èlèment nul.
00032 // Nb - la logique de numérotation quand à elle commence avec m et n = 0.
00033 // -----------------------------------------------------------------------
00034 #define  __Decal  1
00035 class numerotation
00036     {
00037     public :
00038     Cardinal  m,n;
00039     char      UseMode;  // Création ou indexation .
00040 
00041     numerotation(Cardinal m = 0,
00042                  Cardinal n = 0 ) : m(m),
00043                                       n(n),
00044                                       UseMode(INDEXATION){ }
00045 
00046 
00047     static int NumArc ( numerotation& n,
00048                         FILE* f );
00049 
00050     static int NumFace( numerotation& n,
00051                         FILE* f );
00052 
00053     virtual Cardinal CardinalSommet() { return m*n; }
00054     virtual Cardinal CardinalArc   () =0;
00055     virtual Cardinal CardinalFace  () =0;
00056 
00057     protected :
00058 
00059     virtual Index Noeud (Index i, Index j) =0;
00060 
00061     virtual Index Arete1(Index i, Index j) =0;
00062 
00063     virtual Index Arete2(Index i, Index j) =0;
00064 
00065     Index Arete3(Index i, Index j) { return Arete1(i,j+1); }
00066 
00067     Index Arete4(Index i, Index j) { return Arete2(i+1,j); }
00068 
00069     virtual Index Face(Index i, Index j) =0;
00070 
00071     virtual Index som1(Index i, Index j) { return Noeud(i,j); }
00072 
00073     virtual Index som2(Index i, Index j) { return Noeud(i+1,j); }
00074 
00075     virtual Index som3(Index i, Index j) { return Noeud(i,j+1); }
00076 
00077     virtual Index som4(Index i, Index j) { return Noeud(i+1,j+1); }
00078     };
00079 /*
00080 ////////////////////////////////////////////////////////////////////////////////
00081 //
00082 ////////////////////////////////////////////////////////////////////////////////
00083 */
00084 class OuvertOuvert : public numerotation
00085     {
00086     public :
00087     OuvertOuvert ( UINT       m=0,
00088                    UINT       n=0 ) : numerotation(m,n){ }
00089 
00090     protected :
00091     Cardinal CardinalArc ()   { return m*(n+1) + n*(m+1);}
00092     Cardinal CardinalFace()   { return n*m; }
00093 
00094     Index Noeud(Index i, Index j)
00095     { return j + i* ( n+1 ) + __Decal; }
00096 
00097     Index Arete1(Index i, Index j)
00098     { if ( UseMode == CREATION&& (j > n || i == m) ) return NULLINDEX;
00099       return j + n + i* ( 2*n + 1 ) + __Decal; }
00100 
00101     Index Arete2(Index i, Index j)
00102     { if ( UseMode == CREATION&& (i > m || j == n) ) return NULLINDEX;
00103       return j + i* ( 2*n + 1 ) + __Decal; }
00104 
00105     Index Face(Index i, Index j)
00106     { if ( UseMode == CREATION&& (i == m || j == n) ) return NULLINDEX;
00107       return Noeud(i,j)-i; }
00108     };
00109 /*
00110 ////////////////////////////////////////////////////////////////////////////////
00111 //
00112 ////////////////////////////////////////////////////////////////////////////////
00113 */
00114 class OuvertFerme  : public numerotation
00115     {
00116     public:
00117     OuvertFerme ( UINT       m=0,
00118                   UINT       n=0 ) : numerotation(m,n){ }
00119 
00120     protected :
00121     Cardinal CardinalArc () { return (2*m+1)*(n+1);}
00122     Cardinal CardinalFace() { return (n+1)*m; }
00123 
00124     Index Noeud(Index i, Index j)
00125     { return (j!=n+1) ? (j + i* ( n+1 ) + __Decal) :
00126                         (i* ( n+1 )+ __Decal); }
00127 
00128     Index Arete1(Index i, Index j)
00129     { if (UseMode == CREATION&& ( j > n || i == m )) return NULLINDEX;
00130       return (j!=n+1) ? (j + n + 1 + i* ( 2*n + 2 )+ __Decal) :
00131                         (n + 1 + i* ( 2*n + 2 )+ __Decal); }
00132 
00133     Index Arete2(Index i, Index j)
00134     { if (UseMode == CREATION&& (j > n || i > m ) ) return NULLINDEX;
00135       return j + i* ( 2*n + 2 ) + __Decal; }
00136 
00137     Index Face(Index i, Index j)
00138     { if (UseMode == CREATION&& (j > n || i >= m) ) return NULLINDEX;
00139       return Noeud(i,j); }
00140     };
00141 
00142 /*
00143 ////////////////////////////////////////////////////////////////////////////////
00144 //
00145 ////////////////////////////////////////////////////////////////////////////////
00146 */
00147 class FermeOuvert  : public numerotation
00148     {
00149     public :
00150     FermeOuvert ( UINT       m=0,
00151                   UINT       n=0 ) : numerotation(m,n){ }
00152 
00153     protected :
00154     Cardinal CardinalArc () { return (m+1)*n + (m+1)*(n+1); }
00155     Cardinal CardinalFace() { return n*(m+1); }
00156 
00157     Index Noeud(Index i, Index j)
00158     { return (i!=m+1) ? (j + i* ( n+1 )+ __Decal) : (j+ __Decal); }
00159 
00160     Index Arete1(Index i, Index j)
00161     { if (UseMode == CREATION&& ( j > n || i > m ) ) return NULLINDEX;
00162       return j + n + i* ( 2*n + 1 ) + __Decal; }
00163 
00164     Index Arete2(Index i, Index j)
00165     { if (UseMode == CREATION&& ( j == n || i > m ) ) return NULLINDEX;
00166       return (i!=m+1) ? (j + i* ( 2*n + 1 )+ __Decal) : (j+ __Decal); }
00167 
00168     Index Face(Index i, Index j)
00169     { if (UseMode == CREATION&& (j == n || i > m ) ) return NULLINDEX;
00170       return Noeud(i,j)-i; }
00171 
00172     };
00173 
00174 /*
00175 ////////////////////////////////////////////////////////////////////////////////
00176 //
00177 ////////////////////////////////////////////////////////////////////////////////
00178 */
00179 class FermeFerme  : public numerotation
00180     {
00181     public :
00182     FermeFerme ( UINT       m=0,
00183                  UINT       n=0 ) : numerotation(m,n){ }
00184 
00185     protected :
00186     Cardinal CardinalArc ()  { return (m+1)*(n+1)*2; }
00187     Cardinal CardinalFace()  { return (n+1)*(m+1); }
00188 
00189     Index Noeud(Index i, Index j)
00190     { return (j!=n+1)? ((i!=m+1)? (j + i* ( n+1 )+ __Decal):(j+ __Decal) ) :
00191                        (i*(n+1)+ __Decal); }
00192 
00193     Index Arete1(Index i, Index j)
00194     { if (UseMode == CREATION&& (j >n || i > m ) ) return NULLINDEX;
00195       return (j!=n+1) ? (j + n + 1 + i* 2* (n+1) + __Decal) :
00196                         (n + 1 + i* 2* (n+1) + __Decal); }
00197 
00198     Index Arete2(Index i, Index j)
00199     { if (UseMode == CREATION&& (j > n || i > m ) ) return NULLINDEX;
00200       return (i!=m+1) ? (j + i* 2* (n+1) + __Decal) : (j+ __Decal); }
00201 
00202     Index Face(Index i, Index j)
00203     { if (UseMode == CREATION&& (j > n || i > m ) ) return NULLINDEX;
00204       return Noeud(i,j); }
00205 
00206     };
00207 
00208 /*
00209 ////////////////////////////////////////////////////////////////////////////////
00210 //
00211 ////////////////////////////////////////////////////////////////////////////////
00212 */
00213 class OuvertOuvertOnAxisSup : public OuvertOuvert
00214     {
00215     public :
00216     OuvertOuvertOnAxisSup ( UINT       m=0,
00217                             UINT       n=0 ) : OuvertOuvert(m,n){ }
00218 
00219     protected :
00220     Cardinal CardinalSommet () { return (m+1)*n + 1; }
00221     Cardinal CardinalArc    () { return m*n + n*(m+1);}
00222 
00223     Index Noeud(Index i, Index j)
00224     { return (j==0)? CardinalSommet() : // __Decal est dejas implicite.
00225                      j - 1 + i* n + __Decal; }
00226 
00227     Index Arete1(Index i, Index j)
00228     { if ( UseMode == CREATION&& (j == 0 || j > n || i == m)) return NULLINDEX;
00229       return j + n - 1 + i* ( 2*n ) + __Decal; }
00230 
00231     Index Arete2(Index i, Index j)
00232     { if ( UseMode == CREATION&& (i > m || j == n) ) return NULLINDEX;
00233       return j + i* ( 2*n ) + __Decal; }
00234 
00235     Index som2(Index i, Index j)
00236     { return (j==0) ? som1(i,j) : numerotation::som2(i,j); }
00237 
00238     };
00239 
00240 /*
00241 ////////////////////////////////////////////////////////////////////////////////
00242 //
00243 ////////////////////////////////////////////////////////////////////////////////
00244 */
00245 class OuvertOuvertOnAxisInf : public OuvertOuvert
00246     {
00247     public :
00248     OuvertOuvertOnAxisInf ( UINT       m=0,
00249                             UINT       n=0 ) : OuvertOuvert(m,n){ }
00250 
00251     protected :
00252     Cardinal CardinalSommet () { return (m+1)*n + 1; }
00253     Cardinal CardinalArc    () { return m*n + n*(m+1);}
00254 
00255     Index Noeud(Index i, Index j)
00256     { return (j==n)? CardinalSommet() : // __Decal est dejas implicite.
00257                      j + i* n + __Decal; }
00258 
00259     Index Arete1(Index i, Index j)
00260     { if ( UseMode == CREATION&& (j == n || j > n || i == m)) return NULLINDEX;
00261       return j + n + i* ( 2*n ) + __Decal; }
00262 
00263     Index Arete2(Index i, Index j)
00264     { if ( UseMode == CREATION&& (i > m || j == n) ) return NULLINDEX;
00265       return j + i* ( 2*n ) + __Decal; }
00266 
00267 
00268     Index som4(Index i, Index j)
00269     { return (j==n) ? som3(i,j) : numerotation::som4(i,j); }
00270 
00271     };
00272 
00273 /*
00274 ////////////////////////////////////////////////////////////////////////////////
00275 //
00276 ////////////////////////////////////////////////////////////////////////////////
00277 */
00278 class OuvertOuvertOnAxisBoth : public OuvertOuvert
00279     {
00280     public :
00281     OuvertOuvertOnAxisBoth( UINT       m=0,
00282                             UINT       n=0 ) : OuvertOuvert(m,n){ }
00283 
00284     protected :
00285     Cardinal CardinalSommet () { return (m+1)*(n-1)+2; }
00286     Cardinal CardinalArc    () { return (m+1)*n + m*(n-1); }
00287 
00288     Index Noeud(Index i, Index j)
00289     { return (j==0)? CardinalSommet()-1 : // __Decal est dejas implicite.
00290                      ((j ==n)? CardinalSommet() : // Idem.
00291                                j - 1 + i* ( n-1 ) + __Decal ); }
00292 
00293     Index Arete1(Index i, Index j)
00294     { if ( UseMode == CREATION&&
00295      (j == 0 || j == n || j > n || i == m) ) return NULLINDEX;
00296       return j + (n-1) + i* ( 2* n - 1 ) + __Decal; }
00297 
00298     Index Arete2(Index i, Index j)
00299     { if ( UseMode == CREATION&& (i > m || j == n) ) return NULLINDEX;
00300       return j + i* ( 2*n-1 ) + __Decal; }
00301 
00302     Index som2(Index i, Index j)
00303     { return (j==0) ? som1(i,j) : numerotation::som2(i,j); }
00304 
00305     Index som4(Index i, Index j)
00306     { return (j==n) ? som3(i,j) : numerotation::som4(i,j); }
00307 
00308     };
00309 
00310 /*
00311 ////////////////////////////////////////////////////////////////////////////////
00312 //
00313 ////////////////////////////////////////////////////////////////////////////////
00314 */
00315 class FermeOuvertOnAxisSup : public FermeOuvert
00316     {
00317     public :
00318     FermeOuvertOnAxisSup ( UINT       m=0,
00319                            UINT       n=0 ) : FermeOuvert(m,n){ }
00320 
00321     protected :
00322     Cardinal CardinalSommet(){ return n*(m+1) + 1;}
00323     Cardinal CardinalArc   (){ return (m+1)*n*2; }
00324 
00325     Index Noeud(Index i, Index j)
00326     { return (j==0)? CardinalSommet() :
00327                     (i!=m+1) ? (j - 1 + i* n + __Decal) :
00328                                (j - 1 + __Decal); }
00329 
00330     Index Arete1(Index i, Index j)
00331     { if (UseMode == CREATION&& ( j ==0 || j > n || i > m ) ) return NULLINDEX;
00332       return j + n - 1 + i* ( 2*n ) + __Decal; }
00333 
00334     Index Arete2(Index i, Index j)
00335     { if (UseMode == CREATION&& ( j == n || i > m ) ) return NULLINDEX;
00336       return (i!=m+1) ? (j + i* ( 2*n )+ __Decal) : (j+ __Decal); }
00337 
00338     Index som2(Index i, Index j)
00339     { return (j==0) ? som1(i,j) : numerotation::som2(i,j); }
00340 
00341     };
00342 
00343 /*
00344 ////////////////////////////////////////////////////////////////////////////////
00345 //
00346 ////////////////////////////////////////////////////////////////////////////////
00347 */
00348 class FermeOuvertOnAxisInf : public FermeOuvert
00349     {
00350     public :
00351     FermeOuvertOnAxisInf ( UINT       m=0,
00352                            UINT       n=0 ) : FermeOuvert(m,n){ }
00353 
00354     protected :
00355     Cardinal CardinalSommet(){ return n*(m+1) + 1;}
00356     Cardinal CardinalArc ()  { return (m+1)*n*2; }
00357 
00358     Index Noeud(Index i, Index j)
00359     { return (j==n)? CardinalSommet() :
00360                      (i!=m+1) ? (j + i* n + __Decal) :
00361                                 (j + __Decal); }
00362 
00363     Index Arete1(Index i, Index j)
00364     { if (UseMode == CREATION&& ( j ==n || j > n || i > m )) return NULLINDEX;
00365       return j + n + i* ( 2*n ) + __Decal; }
00366 
00367     Index Arete2(Index i, Index j)
00368     { if (UseMode == CREATION&& ( j == n || i > m ) ) return NULLINDEX;
00369       return (i!=m+1) ? (j + i* ( 2*n )+ __Decal) : (j+ __Decal); }
00370 
00371     Index som4(Index i, Index j)
00372     { return (j==n) ? som3(i,j) : numerotation::som4(i,j); }
00373 
00374     };
00375 
00376 /*
00377 ////////////////////////////////////////////////////////////////////////////////
00378 //
00379 ////////////////////////////////////////////////////////////////////////////////
00380 */
00381 class FermeOuvertOnAxisBoth : public FermeOuvert
00382     {
00383     public :
00384     FermeOuvertOnAxisBoth ( UINT       m=0,
00385                             UINT       n=0 ) : FermeOuvert(m,n){ }
00386 
00387     protected :
00388     Cardinal CardinalSommet(){ return (m+1)*(n-1) +2; }
00389     Cardinal CardinalArc   (){ return (m+1)*n + (m+1)*(n-1); }
00390 
00391     Index Noeud(Index i, Index j)
00392     { return (j==0)? CardinalSommet()-1 :
00393                      (j==n)? CardinalSommet() :
00394                              (i!=m+1) ? (j - 1 + i* ( n - 1 )+ __Decal) :
00395                                         (j - 1 + __Decal); }
00396 
00397     Index Arete1(Index i, Index j)
00398     { if (UseMode == CREATION&&
00399           (j ==n || j == 0 || j > n || i > m ) ) return NULLINDEX;
00400       return j + (n-1) + i* ( 2*n-1 ) + __Decal; }
00401 
00402     Index Arete2(Index i, Index j)
00403     { if (UseMode == CREATION&& ( j == n || i > m ) ) return NULLINDEX;
00404       return (i!=m+1) ? (j + i* ( 2*n-1)+ __Decal) : (j+ __Decal); }
00405 
00406     Index som2(Index i, Index j)
00407     { return (j==0) ? som1(i,j) : numerotation::som2(i,j); }
00408 
00409     Index som4(Index i, Index j)
00410     { return (j==n) ? som3(i,j) : numerotation::som4(i,j); }
00411 
00412     };
00413 
00414 #endif
00415 

Generated on Sun Oct 14 18:46:08 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001