Ignore:
Timestamp:
06/15/06 11:50:48 (18 years ago)
Author:
gumbau
Message:

LodStripsConstructor? optimized and fixed bug building a lodtree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp

    r1014 r1017  
    55 
    66using namespace Geometry; 
     7 
    78 
    89//-------------------------------------------------------------------------- 
     
    2324} 
    2425 
    25 //---------------------------------------------------------------------------- 
    26 //      It makes Lods changes and count them. 
    27 //---------------------------------------------------------------------------- 
     26//----------------------------------------------------------------------------------- 
     27//It makes Lods changes and count them 
     28//----------------------------------------------------------------------------------- 
    2829void LodStripsConstructor::CalcularCambiosLODsVNuevaED(TIPOFUNC upb) 
    2930{ 
     31//      LODPosition                                             pos; 
     32//      vector  <LODPosition>   listaPos; 
    3033        long            int                                                     k; 
    3134        long            int                                                     i; 
     
    3437        unsigned long           int             v; 
    3538        long            int                                                     p0; 
     39        long            int                                                     lod     =       0; 
    3640        long            int                                                     sigue; 
    37         unsigned long           int             lod                             =       0; 
    38         long            int                                                     ac[3]                   =       {0,0,0}; 
     41        long            int                                                     ac[3]   =       {0,0,0}; 
    3942        long            int                                                     totalRegs       =       0; 
    4043        long            int                                                     RegsCambios; 
    41         vector  <VECTORINT>                     TiraOriginal; 
     44        ObjList<ObjList<int> >                  TiraOriginal; 
    4245        LODData                                                                 regLOD; 
    43         LODChanges                                                      listaCambios; 
    44  
    45         //      Progress bar. 
     46        //LODChanges                                                    listaCambios; 
     47        ObjList<LODData>                                                listaCambios; 
    4648        float                                                                           percent; 
    4749        float                                                                           increment; 
    4850        long            int                                                     update; 
    4951 
    50         VECTORINT::iterator                                     it; 
    51         VECTORINT::iterator                                     itFin; 
    52         vector <VECTORINT>::iterator    itTiras; 
    53         vector <VECTORINT>::iterator    itTirasFin; 
    54         VECTORVERTEX::iterator                          itVertex; 
    55         VECTORVERTEX::iterator                          itVertexFin; 
    56  
    5752        //      Saves original copy. 
    5853        TiraOriginal                    =       this->cStrips; 
     
    6257        listaCambios.clear(); 
    6358 
    64         //      Progress bar. 
    6559        //      Initialize increment. 
    6660        increment       =       0.0; 
     
    7569        percent         =       1.0; 
    7670         
    77         this->LodsDisp  =       this->TOTALCAMBIOS;//   =       lod; 
     71        this->LodsDisp  =       this->TOTALCAMBIOS      =       lod; 
    7872        pCambios                                =       new uint32[this->TOTALCAMBIOS]; 
    7973        pCambios[0]                     =       0; 
    8074         
    81         listaCambios.reserve(this->TOTALCAMBIOS * 2); 
    82         cDatos.reserve(this->TOTALCAMBIOS * 2 * 2); 
    83  
    84         printf("\nEmpiezan los cambios...%d",this->TOTALCAMBIOS); 
    85  
    86         for     (       lod     =       0,      itVertex        =       this->cVerts.begin(); 
    87                                 lod < this->TOTALCAMBIOS; 
    88                                 lod++,  itVertex++) 
    89         { 
    90                 //      Progress bar. 
    91                 if (update      != (int)(increment * lod)) 
     75        for     (lod = 0; ((this->cVerts[lod].Next) != -1); lod++) 
     76        { 
     77/*              if (update      != (int)(increment * lod)) 
    9278                { 
    9379                        update  =       (int)(increment * lod); 
    9480                        upb(percent); 
    95                 } 
    96                  
    97                 /* 
    98                 if ((lod % 100)==0) 
    99                 { 
    100                         printf("*%d*",lod); 
    101                 } 
    102                 */ 
    103                  
    104                 RegsCambios     =       0; 
    105                  
    106                 //      Last strip. 
    107                 itTirasFin      =       this->cStrips.end(); 
    108                  
    109                 for(t   =       0,      itTiras =       this->cStrips.begin(); 
    110                                 itTiras != itTirasFin; 
    111                                 itTiras++,      t++) 
    112                 { 
     81                }*/ 
     82 
     83                tipoVertice & cVertsLOD = this->cVerts[lod]; 
     84                 
     85                RegsCambios                             =       0; 
     86                regLOD.obligatory       =       this->Ordenacion[lod].obligatorio; 
     87                 
     88                for(t = 0; t < this->cStrips.size(); t++) 
     89                { 
     90 
     91                        ObjList<int> & cStripsT = this->cStrips[t]; 
     92 
    11393                        //      Initialize. 
    11494                        regLOD.strip    =       this->MARCAVACIO; 
     
    11797                        totalRegs               =       0; 
    11898                         
    119                         //      Last index of the current strip. 
    120                         itFin                           =       itTiras->end(); 
    121                          
    122                         for (   it      =       itTiras->begin(),       v       =       0; 
    123                                                 it != itFin; 
    124                                                 it++,   v++) 
    125                         { 
    126                                 if ((*it) == lod) 
    127                                 { 
     99                        for (v = 0; v < cStripsT.size(); v++) 
     100                        { 
     101                                if (cStripsT[v] == lod)  
     102                                {  
    128103                                        //      Strips. 
    129104                                        if (regLOD.strip == this->MARCAVACIO) 
     
    136111                                        cDatos.push_back(v); 
    137112 
    138                                         *it     =       itVertex->Next; 
     113                                        cStripsT[v]     =       cVertsLOD.Next; 
    139114                                } 
    140115                        } 
     
    148123                        r                                       =       0; 
    149124                        sigue                   =       0; 
    150                         k                                       =       long(itTiras->size() - 3); 
    151                         it                              =       itTiras->begin(); 
    152  
     125                        k                                       =       long(cStripsT.size()-3); 
     126                         
    153127                        while (i < k) 
    154128                        { 
    155                                 if (    ((*it) == (*(it + 1))) && ((*(it + 1)) == (*(it + 2)))) 
    156                                 { 
     129                                if (    (cStripsT[i] == cStripsT[i+1]) 
     130                                                        && 
     131                                                        (cStripsT[i+1] == cStripsT[i+2]) 
     132                                                ) 
     133                                {  
    157134                                        //      Saves beginning of repetition. 
    158135                                        if (!r) 
     
    161138                                        } 
    162139                                         
    163                                         itTiras->erase(itTiras->begin() + i); 
     140                                        cStripsT.eraseAtPos(i); 
     141                                        //this->cStrips[t].erase(this->cStrips[t].begin()+i); 
    164142                                        i--; 
    165                                         it--; 
    166143                                        r++; 
    167144                                         
    168                                         if ((i + 1) != (itTiras->size() - 1)) 
     145                                        if ((i+1) != cStripsT.size()-1) 
    169146                                        { 
    170147                                                sigue   =       1; 
     
    194171 
    195172                                        r       =       0; 
    196                                         k       =       long(itTiras->size() - r - 3); 
     173                                        k       =       long(cStripsT.size()-r-3); 
    197174                                } 
    198175 
    199176                                i++; 
    200                                 it++; 
    201177                        } 
    202178                         
     
    208184                        r                                       =       0; 
    209185                        sigue                   =       0; 
    210                         k                                       =       long(itTiras->size() - 4); 
     186                        k                                       =       long(cStripsT.size() - 4); 
    211187                         
    212                         it = itTiras->begin(); 
    213  
    214188                        while   (i < k) 
    215189                        { 
    216                                 if (((*it) == (*(it + 2))) && ((*(it + 1)) == (*(it + 3)))) 
     190                                if (    (cStripsT[i] == cStripsT[i+2]) 
     191                                                        && 
     192                                                        (cStripsT[i+1] == cStripsT[i+3]) 
     193                                                ) 
    217194                                { 
    218195                                        if (!r) 
     
    221198                                        } 
    222199                                         
    223                                         itTiras->erase(itTiras->begin() + i); 
    224                                         itTiras->erase(itTiras->begin() + i); 
    225  
     200                                        cStripsT.eraseAtPos(i); 
     201                                        //this->cStrips[t].erase(this->cStrips[t].begin()+i); 
     202                                        cStripsT.eraseAtPos(i); 
     203                                        //this->cStrips[t].erase(this->cStrips[t].begin()+i); 
    226204                                        r++; 
    227205                                         
    228206                                        i       -=      2; 
    229207                                         
    230                                         it--; 
    231                                         it--; 
     208                                        if ((i+1) != cStripsT.size()-3) 
     209                                        { 
     210                                                sigue   =       1; 
     211                                        } 
     212                                        else 
     213                                        { 
     214                                                sigue   =       0; 
     215                                        } 
    232216                                         
    233                                         if ((i + 1) != itTiras->size() - 3) 
    234                                         { 
    235                                                 sigue   =       1; 
    236                                         } 
    237                                         else 
    238                                         { 
    239                                                 sigue   =       0; 
    240                                         } 
    241217                                } 
    242218                                else 
     
    258234                                         
    259235                                        r       =       0; 
    260                                         k       =       long(itTiras->size() - 4 - 2 * r); 
     236                                        k       =       long((cStripsT.size()-4-2*r)); 
    261237                                } 
    262238 
    263239                                i++; 
    264                                 it++; 
    265240                        } 
    266241                         
     
    277252        }//     End for lod. 
    278253 
    279         printf("\nFin de los cambios..."); 
    280  
    281254        this->cCambios  =       listaCambios; 
    282255 
    283256        //      Guardar el numero de LODS disponibles. 
    284         //this->TOTALCAMBIOS    =       this->LodsDisp=lod; 
     257        this->TOTALCAMBIOS      =       this->LodsDisp=lod; 
    285258 
    286259        //Retornar a la lista original 
     
    291264//Put in order vertex of Mesh from simplification sequence 
    292265//----------------------------------------------------------------------- 
     266#include <time.h> 
    293267void LodStripsConstructor::OrdenarModeloVQSLIM(TIPOFUNC upb) 
    294268{ 
     
    298272        unsigned long int v; 
    299273        long int vSig; 
    300         //long int k; 
     274        long int k; 
    301275        VECTORVERTEX                            Vertices; 
    302         VECTORVERTEX                            NuevosVerts; 
    303         vector  <VECTORINT>     NuevasTiras; 
    304         VECTORINT                                               tira; 
    305         VECTORINT::iterator it; 
    306         VECTORINT::iterator itFin; 
     276        ObjList<tipoVertice>            NuevosVerts; 
     277        //vector        <VECTORINT>     NuevasTiras; 
     278        ObjList<ObjList<int> > NuevasTiras; 
     279//      VECTORINT                                               tira; 
     280        ObjList<int> tira; 
    307281        vector  <Index>                 mV1Aux; 
    308282        tipoOrden                                               Orden; 
    309283        tipoOrden                                               *Ord; 
    310         tipoOrden                                               *Ord2; 
    311284        bool                                                            bEncontrado; 
    312285        long    int                                             c1; 
    313286        long    int                                             c2; 
    314          
    315         //      Progress bar. 
     287        //      Progress bar 
    316288        float                   percent; 
    317289        float                   increment; 
    318290        long    int     update; 
    319291 
    320         unsigned long int       totalSize; 
    321  
    322292        bEncontrado = false; 
    323293 
    324         printf("\n---->Lectura de Ordenacion"); 
    325          
    326         totalSize       =       (long int)this->geoMeshSQ->mSteps.size(); 
     294        int mStepsSize = geoMeshSQ->mSteps.size(); 
    327295 
    328296        c1                                      =       0; 
    329297        c2                                      =       0; 
    330298         
    331         //      Progress bar. 
    332299        update                  =       -1; 
    333300        percent                 =       1.0; 
    334         increment               =       (float)(10.0) / (float)(totalSize); 
    335  
    336         for     (i = 0; i < totalSize; i++) 
     301        increment               =       (float)(10.0) / (float)mStepsSize; 
     302         
     303        for     (i = 0; i < mStepsSize; i++) 
    337304        { 
    338305                if (update      != (int)(i * increment)) 
     
    342309                } 
    343310                 
    344                 mV1Aux.push_back(this->geoMeshSQ->mSteps[i].mV1); 
    345  
    346                 Orden.vQslimNext        =       this->geoMeshSQ->mSteps[i].mV0; 
    347                 Orden.vQslim                    =       this->geoMeshSQ->mSteps[i].mV1; 
    348                 Orden.obligatorio       =       this->geoMeshSQ->mSteps[i].obligatorio; 
     311                const Geometry::MeshSimplificationSequence::Step & theStep = this->geoMeshSQ->mSteps[i]; 
     312 
     313                mV1Aux.push_back(theStep.mV1); 
     314 
     315                Orden.vQslimNext        =       theStep.mV0; 
     316                Orden.vQslim                    =       theStep.mV1; 
     317                Orden.obligatorio       =       theStep.obligatorio; 
    349318                Orden.vLS                                       =       i; 
    350319 
    351                 Orden.x                                         =       this->geoMeshSQ->mSteps[i].x; 
     320                Orden.x                                         =       theStep.x; 
    352321                Orden.vLSNext                   =       -1; 
    353322                Orden.cambio                    =       "n"; 
     
    355324                Ordenacion.push_back(Orden); 
    356325        } 
    357  
     326         
    358327        this->NumVertsRepetidos = c2; 
    359328 
    360         printf("\n---->Cambiar vertices con x!0, Verts: %d",Ordenacion.size()); 
     329        update          =       -1; 
     330        increment       =       (float)(10.0) / (float)(Ordenacion.size()); 
     331        percent         =       1.0; 
    361332 
    362333        //      Change all vertices that have x != 0. 
    363         totalSize       =       (long int)Ordenacion.size(); 
    364         Ord                             =       &(Ordenacion[0]); 
    365  
    366         //      Progress bar. 
    367         update          =       -1; 
    368         increment       =       (float)(10.0) / (float)(totalSize); 
    369         percent         =       1.0; 
    370  
    371         //      Change all vertices that have x != 0. 
    372         for(i   =       0;      i < totalSize;  i++) 
    373         { 
    374                 //      Progress bar. 
     334        for(i   =       0;      i < Ordenacion.size();  i++) 
     335        { 
    375336                if (update      != (int)(i * increment)) 
    376337                { 
     
    379340                } 
    380341                 
    381                 if (Ord->x != 0) 
     342                Ord     =       &(Ordenacion[i]); 
     343 
     344                if (Ord->x!=0) 
    382345                { 
    383346                        //      Change the simplification order. 
     
    385348                        Ord->vQslim                     =       Ord->vQslimNext; 
    386349                        Ord->vQslimNext =       v; 
    387                         Ord2                                            =       &(Ordenacion[i + 1]); 
    388                          
    389                         for (j = i + 1; j < totalSize; j++,Ord2++) 
    390                         { 
    391                                 if (Ord2->vQslim == Ord->vQslim) 
    392                                 { 
    393                                         Ord2->vQslim    =       Ord->vQslimNext; 
    394                                         Ord2->cambio    =       "y"; 
    395                                 } 
    396                                 else if (Ord2->vQslimNext == Ord->vQslim) 
    397                                 { 
    398                                         Ord2->vQslimNext        =       Ord->vQslimNext;         
    399                                         Ord2->cambio                    =       "y"; 
    400                                 } 
    401                         } 
    402                 } 
    403  
    404                 Ord++; 
    405         } 
    406  
    407         printf("\n---->Nuevos vertices"); 
    408  
    409         totalSize       =       (long int)Ordenacion.size(); 
    410         Ord                             =       &(Ordenacion[0]); 
    411  
    412         //      Progress bar. 
     350 
     351                        for (j = i+1; j < Ordenacion.size(); j++) 
     352                        { 
     353                                tipoOrden & ordJ = Ordenacion[j]; 
     354                                if (ordJ.vQslim == Ord->vQslim) 
     355                                { 
     356                                        ordJ.vQslim     =       Ord->vQslimNext; 
     357                                        ordJ.cambio     =       "y"; 
     358                                } 
     359                                else if (ordJ.vQslimNext == Ord->vQslim) 
     360                                { 
     361                                        ordJ.vQslimNext =       Ord->vQslimNext;         
     362                                        ordJ.cambio                     =       "y"; 
     363                                } 
     364                        } 
     365                } 
     366        } 
     367 
    413368        update          =       -1; 
    414         increment       =       (float)(10.0) / (float)(totalSize); 
     369        increment       =       (float)(10.0) / (float)(Ordenacion.size()); 
    415370        percent         =       1.0; 
    416371 
    417         //      Vertex sort. 
    418         for(i = 0; i < totalSize; i++) 
    419         { 
    420                 //      Progress bar. 
     372        //      3 seg. 
     373        //Ordenacion de los vertices 
     374        for(i = 0; i < Ordenacion.size(); i++) 
     375        { 
    421376                if (update      !=      (int)(i * increment)) 
    422377                { 
     
    426381 
    427382                c1++; 
    428                 NuevosVerts.push_back(this->cVerts[Ord->vQslim]); 
    429  
    430                 cVerts[Ord->vQslim].Next        =       -1; 
    431  
    432                 //-------- 
    433                 Ord++; 
    434                 //-------- 
    435         } 
    436  
    437         printf( "\n---->Meter los que no se simplifican -> Ahora Hay: %d", 
    438                                         Ordenacion.size()); 
    439  
    440         //      Adds new vertices not in NuevosVerts. 
     383                NuevosVerts.push_back(this->cVerts[Ordenacion[i].vQslim]); 
     384 
     385                cVerts[Ordenacion[i].vQslim].Next       =       -1; 
     386 
     387        } 
     388 
     389        //      Añadir aquellos vertices que no estaban en NuevosVerts  
     390        //      y no se simplificaban. 
    441391        int cont                                =       0; 
    442392        int contestaban =       0; 
    443393 
    444         for(i = 0; i < this->cVerts.size(); i++) 
     394        int cVertsSize = this->cVerts.size(); 
     395        for(i = 0; i < cVertsSize; i++) 
    445396        { 
    446397                if (this->cVerts[i].Next != -1) 
     
    462413        } 
    463414 
    464         totalSize       =       (long int)Ordenacion.size(); 
    465  
    466         printf("\n---->Siguientes QSLIM: %d",totalSize); 
    467  
    468         //      Progress bar. 
    469415        update          =       -1; 
    470         increment       =       (float)(10.0)   /       (float)(totalSize); 
     416        increment       =       (float)(10.0)   /       (float)(Ordenacion.size()); 
    471417        percent         =       1.0; 
    472418         
    473         //      Obtain nexts. 
    474         if (totalSize > 0) 
    475         { 
    476                 Ord     =       &(Ordenacion[0]); 
    477         } 
    478  
    479         for (i = 0; i < totalSize; i++) 
    480         { 
    481                 //      Progress bar. 
     419        //      2 min. 
     420        //      Calcular los siguiente teniendo en cuenta el QSLIM. 
     421        for (i = 0; i < Ordenacion.size(); i++) 
     422        { 
    482423                if (update      !=      (int)(i * increment)) 
    483424                { 
     
    486427                } 
    487428                 
    488                 v                       =       Ord->vQslimNext; 
     429                v       =       Ordenacion[i].vQslimNext; 
     430 
     431                //Buscar ese vertice v cual es ahora 
    489432                vSig    =       0; 
    490                 Ord2    =       &(Ordenacion[0]); 
    491                  
    492                 for (t  =       0;      (t < totalSize) && !vSig;       t++) 
    493                 { 
    494                         if (Ord2->vQslim == v) 
    495                         { 
    496                                 vSig    =       Ord2->vLS; 
    497                         } 
    498                          
    499                         Ord2++; 
    500                 } 
    501                  
    502                 if (vSig != 0) 
    503                 { 
    504                         Ord->vLSNext    =       vSig; 
    505                 } 
    506                  
    507                 Ord++; 
    508         } 
    509  
    510         printf("\n---->Crear nuevas de tiras"); 
    511  
    512         /* 
    513         //      Create new strips with same dimensions. 
    514         for(t = 0; t < this->cStrips.size(); t++) 
     433 
     434                for (t = 0; t < Ordenacion.size() && !vSig;t++) 
     435                { 
     436                        if (Ordenacion[t].vQslim==v) 
     437                        { 
     438                                vSig=Ordenacion[t].vLS; 
     439                        } 
     440                } 
     441 
     442                if (vSig!=0) 
     443                { 
     444                        Ordenacion[i].vLSNext   =       vSig; 
     445                } 
     446        } 
     447 
     448        //Creacion de nuevas tiras con las mismas dimensiones 
     449        int cStripsSize = this->cStrips.size(); 
     450        for(t = 0; t < cStripsSize; t++) 
    515451        { 
    516452                tira.clear(); 
    517453 
    518                 itFin   =       this->cStrips[t].end(); 
    519  
    520                 for(it = cStrips[t].begin(); it != itFin; it++) 
    521                 { 
    522                         //      For each new vertex. 
    523                         for     (v = 0; v < NuevosVerts.size(); v++) 
    524                         { 
    525                                 Ord     =       &(Ordenacion[v]); 
    526  
    527                                 if ((*it) == Ord->vQslim) 
    528                                 { 
    529                                         tira.push_back(v); 
    530  
    531                                         //      Delete vertex inserted. 
    532                                         //NuevosVerts.erase(v); 
    533                                 } 
    534                         } 
    535                 } 
     454                int cStripsSizeT = this->cStrips[t].size(); 
     455                for(i = 0; i < cStripsSizeT; i++) 
     456                        tira.push_back(0); 
    536457 
    537458                NuevasTiras.push_back(tira); 
    538459        } 
    539         */ 
    540          
    541         //Creacion de nuevas tiras con las mismas dimensiones 
    542         for(t = 0; t < this->cStrips.size(); t++) 
    543         { 
    544                 tira.clear(); 
    545  
    546                 for(i = 0; i < this->cStrips[t].size(); i++) 
    547                 { 
    548                         tira.push_back(0); 
    549                 } 
    550  
    551                 NuevasTiras.push_back(tira); 
    552         } 
    553          
    554         update  =       long(NuevosVerts.size() / 40); 
    555         percent =       0.5; 
     460 
     461        update          =       -1; 
     462        increment       =       (float)(20.0) / (float)(NuevosVerts.size()); 
     463        percent         =       1.0; 
     464 
     465        k       =       0; 
    556466 
    557467        //      2 min. 
    558468        //Cambiar los vertices de las tiras 
    559         for(v = 0; v < NuevosVerts.size(); v++) 
    560         { 
    561                 if ((v % update) == 0) 
    562                 { 
     469        int NuevosVertsSize = NuevosVerts.size();        
     470        for(v = 0; v < NuevosVertsSize; v++) 
     471        { 
     472                if (update != (int)(v * increment)) 
     473                { 
     474                        update  =       (int)(v * increment); 
    563475                        upb(percent); 
    564                 } 
    565  
    566                 for(t = 0; t < this->cStrips.size(); t++) 
    567                 { 
    568                         for(i = 0; i < this->cStrips[t].size(); i++) 
    569                         { 
    570                                 if (this->cStrips[t][i] == Ordenacion[v].vQslim) 
    571                                 { 
    572                                         NuevasTiras[t][i]       =       v; 
    573                                 } 
    574                         } 
    575                 } 
    576         } 
    577  
    578         printf("\n---->Copiar los datos"); 
    579  
    580         //      Change to new strips. 
     476                }                
     477 
     478                const tipoOrden & OrdenacionV = Ordenacion[v]; 
     479 
     480                for(t = 0; t < cStrips.size(); t++) 
     481                { 
     482                        ObjList<int> & thisStrip = cStrips[t];                   
     483                        ObjList<int> & NuevasTirasT = NuevasTiras[t]; 
     484                        int cStripsSizeT = thisStrip.size(); 
     485                        for(i = 0; i < cStripsSizeT; i++) 
     486                        { 
     487                                if (thisStrip[i] == OrdenacionV.vQslim) 
     488                                { 
     489                                        k++; 
     490                                        NuevasTirasT[i] =       v; 
     491                                } 
     492                        } 
     493                } 
     494        } 
     495 
     496        //Cambiar a Tiras Nuevas 
    581497        this->cStrips   =       NuevasTiras; 
    582498 
    583         //      Same size for NuevosVerts and Ordenacion. 
    584         this->TOTALCAMBIOS      =       0; 
    585          
    586         totalSize       =       (long int)NuevosVerts.size(); 
    587          
    588         //      For each new vertex. 
    589         for(i = 0; i < totalSize; i++) 
     499        //NuevosVerts y Ordenacion = tamaño. 
     500        NuevosVertsSize = NuevosVerts.size(); 
     501        for(i = 0; i < NuevosVertsSize; i++) 
    590502        { 
    591503                NuevosVerts[i].Next     =       Ordenacion[i].vLSNext; 
    592                  
    593                 if ((this->TOTALCAMBIOS == 0) && (NuevosVerts[i].Next == -1)) 
    594                 { 
    595                         this->TOTALCAMBIOS      =       i; 
    596                 } 
    597504        } 
    598505 
    599506        //Cambiar cVerts por nuevosVerts. 
    600507        this->cVerts    =       NuevosVerts; 
    601  
    602         printf( "--->Vertices: %d  * Cambios: %d", 
    603                                         NuevosVerts.size(), 
    604                                         this->TOTALCAMBIOS); 
    605508 
    606509        //percent       =       100.0; 
     
    626529        this->geoMesh           =       new Geometry::Mesh(); 
    627530        *this->geoMesh  =       *m; 
    628         this->geoMeshSQ = ms; 
     531        this->geoMeshSQ = const_cast<MeshSimplificationSequence*>(ms); 
    629532 
    630533        //      Set the leaves submesh. 
    631534        mSubMeshLeaves  =       submesh; 
    632  
    633          
    634535        this->GenerarModeloCompleto(upb); 
    635536} 
     
    643544        delete [] vDatos; 
    644545        delete [] vCambios; 
    645         vector <LODData> cCambiosTemp; 
    646         cCambios.swap(cCambiosTemp); 
    647  
    648         VECTORUNINT cDatosTemp; 
    649         cDatos.swap(cDatosTemp); 
     546/*      vector <LODData> cCambiosTemp; 
     547        cCambios.swap(cCambiosTemp);*/ 
     548        cCambios.clear(); 
     549 
     550/*      VECTORUNINT cDatosTemp; 
     551        cDatos.swap(cDatosTemp);*/ 
     552        cDatos.clear(); 
    650553 
    651554        delete [] vStrips; 
     
    653556        delete [] vVerts; 
    654557 
    655         vector <VECTORINT> cStripsTemp; 
    656         cStrips.swap(cStripsTemp);; 
    657  
    658         VECTORVERTEX cVertsTemp; 
    659         cVerts.swap(cVertsTemp); 
     558//      vector <VECTORINT> cStripsTemp; 
     559//      cStrips.swap(cStripsTemp);; 
     560        cStrips.clear(); 
     561 
     562//      VECTORVERTEX cVertsTemp; 
     563//      cVerts.swap(cVertsTemp); 
     564        cVerts.clear(); 
    660565 
    661566        delete [] pCambios; 
     
    713618                oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
    714619        } 
    715  
    716620        //      Lines starting with a b. 
    717621        //      Data. 
     
    853757        } 
    854758         
     759 
     760 
    855761        int indice_acum = 0; 
    856762        for(i=0;i<this->geoMesh->mSubMeshCount;i++) 
    857763        { 
    858                 for (size_t ind=0; ind < meshoriginal->mSubMesh[i].mIndexCount; ind++)  
    859                 { 
    860                         if (meshoriginal->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
     764                Geometry::SubMesh & subMesh = meshoriginal->mSubMesh[i]; 
     765                Geometry::SubMesh & geoMeshSubMesh = this->geoMesh->mSubMesh[i]; 
     766 
     767                for (size_t ind=0; ind < subMesh.mIndexCount; ind++)  
     768                { 
     769                        Index indIndex = subMesh.mIndex[ind]; 
     770                        if (subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    861771                        { 
    862772                                //Hay coordenadas de textura y normales 
    863                                 if(meshoriginal->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    864                                 { 
    865                                         for (size_t indvo=0; indvo<this->geoMesh->mSubMesh[i].mVertexBuffer->mVertexCount; indvo++) 
    866                                         { 
    867                                                 if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mPosition[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mPosition[indvo])) 
     773                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     774                                { 
     775                                        for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     776                                        { 
     777                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    868778                                                { 
    869                                                         if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mNormal[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mNormal[indvo])) 
     779                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],geoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
    870780                                                        { 
    871                                                                 if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mTexCoords[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mTexCoords[indvo])) 
     781                                                                if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],geoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
    872782                                                                { 
    873                                                                         this->geoMesh->mSubMesh[i].mIndex[ind]= int(indvo);//+indice_acum; 
     783                                                                        geoMeshSubMesh.mIndex[ind]= int(indvo);//+indice_acum; 
    874784                                                                } 
    875785                                                        } 
     
    879789                                else            //Hay coordenadas de textura pero no hay normales 
    880790                                { 
    881                                         for (size_t indvo=0; indvo<this->geoMesh->mSubMesh[i].mVertexBuffer->mVertexCount; indvo++) 
    882                                         { 
    883                                                 if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mPosition[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mPosition[indvo])) 
     791                                        for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     792                                        { 
     793                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    884794                                                { 
    885                                                         if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mTexCoords[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mTexCoords[indvo])) 
     795                                                        if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],geoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
    886796                                                        { 
    887                                                                 this->geoMesh->mSubMesh[i].mIndex[ind]=int(indvo);//+indice_acum; 
     797                                                                geoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    888798                                                        } 
    889799                                                } 
     
    894804                        { 
    895805                                // No hay coordenadas de textura pero si normales 
    896                                 if(meshoriginal->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    897                                 { 
    898                                         for (size_t indvo=0; indvo<this->geoMesh->mSubMesh[i].mVertexBuffer->mVertexCount; indvo++) 
    899                                         { 
    900                                                 if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mPosition[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mPosition[indvo])) 
     806                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     807                                { 
     808                                        for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     809                                        { 
     810                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    901811                                                { 
    902                                                         if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mNormal[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mNormal[indvo])) 
     812                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],geoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
    903813                                                        { 
    904                                                                 this->geoMesh->mSubMesh[i].mIndex[ind]=int(indvo);//+indice_acum; 
     814                                                                geoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    905815                                                        } 
    906816                                                } 
     
    909819                                else            //No hay coordenadas de texturas ni normales 
    910820                                { 
    911                                         for (size_t indvo=0; indvo<this->geoMesh->mSubMesh[i].mVertexBuffer->mVertexCount; indvo++) 
    912                                         { 
    913                                                 if (igual(meshoriginal->mSubMesh[i].mVertexBuffer->mPosition[meshoriginal->mSubMesh[i].mIndex[ind]],this->geoMesh->mSubMesh[i].mVertexBuffer->mPosition[indvo])) 
     821                                        for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     822                                        { 
     823                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    914824                                                { 
    915                                                         this->geoMesh->mSubMesh[i].mIndex[ind]=int(indvo);//+indice_acum; 
     825                                                        geoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    916826                                                } 
    917827                                        } 
     
    920830                } 
    921831        } 
    922  
     832         
    923833} 
    924834 
     
    949859//de los vertices y los indices 
    950860//----------------------------------------------------------------------------------------------- 
     861 
    951862void LodStripsConstructor::GenerarModeloV(TIPOFUNC      upb) 
    952863{ 
     
    962873        upb(percent); 
    963874 
    964         //      6 min. 
     875        //      6 min.   
    965876        this->OrdenarModeloVQSLIM(upb); 
    966877 
     
    979890 
    980891        this->MARCA     =       max + 1; 
    981  
    982         //      5 min. 
    983892        this->CalcularCambiosLODsVNuevaED(upb); 
    984  
    985893} 
    986894 
     
    1067975{ 
    1068976        tipoVertice     vAux; 
    1069         VECTORINT               tira; 
     977        ObjList<int>            tira; 
    1070978        size_t                  i; 
    1071979        size_t                  j; 
     
    12471155                //      Error. 
    12481156        } 
    1249  
    1250         //--------------------------------------------- 
    1251         //      Debug. 
    1252         //--------------------------------------------- 
    1253         FILE    *file_aux; 
    1254         file_aux        =       fopen("StripsModel.txt","w"); 
    1255         for (unsigned   int i = 0; i < cStrips.size(); i++) 
    1256         { 
    1257                 for (unsigned   int j = 0; j < cStrips[i].size();       j++) 
    1258                 { 
    1259                         fprintf(file_aux,"%d ",cStrips[i][j]); 
    1260                 } 
    1261                 fprintf(file_aux,"\n"); 
    1262         } 
    1263         //--------------------------------------------- 
    1264  
    12651157} 
    12661158 
Note: See TracChangeset for help on using the changeset viewer.